nervoscan-js-sdk 1.0.6-9 → 1.0.7

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 Ec=Object.defineProperty;var wc=(n,e,t)=>e in n?Ec(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var A=(n,e,t)=>wc(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class P extends Error{constructor(e){super(e)}}class Ai extends P{constructor(e){super(e)}}class Oi extends P{constructor(e){super(e)}}class xi extends P{constructor(e){super(e)}}class Pi extends P{constructor(e){super(e)}}class Di extends P{constructor(e){super(e)}}class Li extends P{constructor(e){super(e)}}class Fi extends P{constructor(e){super(e)}}class Mi extends P{constructor(e){super(e)}}class Bi extends P{constructor(e){super(e)}}class Ui extends P{constructor(e){super(e)}}class Hi extends P{constructor(e){super(e)}}class Wi extends P{constructor(e){super(e)}}class qi extends P{constructor(e){super(e)}}class Vi extends P{constructor(e){super(e)}}class $i extends P{constructor(e){super(e)}}class zi extends P{constructor(e){super(e)}}class ji extends P{constructor(e){super(e)}}class Ki extends P{constructor(e){super(e)}}class Ps extends P{constructor(t){super(t.message);A(this,"errorCode");this.errorCode=t.code}}class Gi extends P{constructor(e){super(e)}}class Yi extends P{constructor(e){super(e)}}class Qi extends P{constructor(e){super(e)}}class Ji extends P{constructor(e){super(e)}}class Xi extends P{constructor(e){super(e)}}class Zi extends P{constructor(e){super(e)}}class eo extends P{constructor(e){super(e)}}const D={NotInitializedError:Ai,EmptyVideoError:Oi,VideoTypeError:xi,InvalidUsernameError:Pi,InvalidPasswordError:Di,NoScansAvailableError:Li,InvalidAccessTokenError:Fi,NoScanDataError:Mi,InvalidServerTypeError:Bi,NotImplementedError:Ui,LowFPSError:Hi,FPSCalculationError:Wi,FaceNotCenteredError:qi,FaceTooFarError:Vi,FaceTooCloseError:$i,FaceLookingLeftError:zi,FaceLookingRightError:ji,ErrorCallbackNotSetError:Ki,UnhandledScanError:Ps,SkinExtractionError:Gi,InvalidContentTypeError:Yi,JobNotRegisteredError:Qi,LowFrameCountError:Xi,ConnectionLostError:Zi,ScanFailedError:eo,UnhandledError:Ji},v={NotInitializedError:new D.NotInitializedError("Nervoscan Client not initialized!"),EmptyVideoError:new D.EmptyVideoError("Video is empty!"),VideoTypeError:new D.VideoTypeError("Video is not a Blob!"),InvalidUsernameError:new D.InvalidUsernameError("Invalid username!"),InvalidPasswordError:new D.InvalidPasswordError("Invalid password!"),NoScansAvailableError:new D.NoScansAvailableError("No scans available, Please purchase a plan!"),InvalidAccessTokenError:new D.InvalidAccessTokenError("Invalid access token!"),NoScanDataError:new D.NoScanDataError("No scan data found!"),InvalidServerTypeError:new D.InvalidServerTypeError("Invalid server type!"),NotImplementedError:new D.NotImplementedError("Not implemented!"),LowFPSError:new D.LowFPSError("Low FPS!"),FPSCalculationError:new D.FPSCalculationError("Error calculating FPS!"),FaceNotCenteredError:new D.FaceNotCenteredError("Face not centered!"),FaceTooFarError:new D.FaceTooFarError("Face too far!"),FaceTooCloseError:new D.FaceTooCloseError("Face too close!"),FaceLookingLeftError:new D.FaceLookingLeftError("Face looking left!"),FaceLookingRightError:new D.FaceLookingRightError("Face looking right!"),ErrorCallbackNotSetError:new D.ErrorCallbackNotSetError("Error callback not set!"),SkinExtractionError:new D.SkinExtractionError("Skin extraction error! Please use a better lighting!"),InvalidContentTypeError:new D.InvalidContentTypeError("Invalid content type!"),JobNotRegisteredError:new D.JobNotRegisteredError("Job not registered! Please await initializeStreaming method!"),LowFrameCountError:new D.LowFrameCountError("Low frame count! Don't stop streaming prematurely!"),ConnectionLostError:new D.ConnectionLostError("Connection lost! Run Client.initializeStreaming() again!"),ScanFailedError:new D.ScanFailedError("Scan failed! Please try again!"),UnhandledError:new D.UnhandledError("Unhandled error! Please contact support!")},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:new Ps(e)}};A(G,"instance");let R=G;function to(n,e){return function(){return n.apply(e,arguments)}}const{toString:vc}=Object.prototype,{getPrototypeOf:Ds}=Object,vn=(n=>e=>{const t=vc.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 bc(n){return n!==null&&!gt(n)&&n.constructor!==null&&!gt(n.constructor)&&ee(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const no=le("ArrayBuffer");function Cc(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&no(n.buffer),e}const Sc=bn("string"),ee=bn("function"),so=bn("number"),Cn=n=>n!==null&&typeof n=="object",Tc=n=>n===!0||n===!1,qt=n=>{if(vn(n)!=="object")return!1;const e=Ds(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Rc=le("Date"),Ic=le("File"),Nc=le("Blob"),kc=le("FileList"),Ac=n=>Cn(n)&&ee(n.pipe),Oc=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]"))},xc=le("URLSearchParams"),[Pc,Dc,Lc,Fc]=["ReadableStream","Request","Response","Headers"].map(le),Mc=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 ro(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,io=n=>!gt(n)&&n!==Ae;function ns(){const{caseless:n}=io(this)&&this||{},e={},t=(s,r)=>{const i=n&&ro(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 Bc=(n,e,t,{allOwnKeys:s}={})=>(Nt(e,(r,i)=>{t&&ee(r)?n[i]=to(r,t):n[i]=r},{allOwnKeys:s}),n),Uc=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Hc=(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)},Wc=(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&&Ds(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},qc=(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},Vc=n=>{if(!n)return null;if(Xe(n))return n;let e=n.length;if(!so(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},$c=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&Ds(Uint8Array)),zc=(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])}},jc=(n,e)=>{let t;const s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},Kc=le("HTMLFormElement"),Gc=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),br=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Yc=le("RegExp"),oo=(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)},Qc=n=>{oo(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+"'")})}})},Jc=(n,e)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return Xe(n)?s(n):s(String(n).split(e)),t},Xc=()=>{},Zc=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function el(n){return!!(n&&ee(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const tl=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)},nl=le("AsyncFunction"),sl=n=>n&&(Cn(n)||ee(n))&&ee(n.then)&&ee(n.catch),ao=((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)),rl=typeof queueMicrotask<"u"?queueMicrotask.bind(Ae):typeof process<"u"&&process.nextTick||ao,f={isArray:Xe,isArrayBuffer:no,isBuffer:bc,isFormData:Oc,isArrayBufferView:Cc,isString:Sc,isNumber:so,isBoolean:Tc,isObject:Cn,isPlainObject:qt,isReadableStream:Pc,isRequest:Dc,isResponse:Lc,isHeaders:Fc,isUndefined:gt,isDate:Rc,isFile:Ic,isBlob:Nc,isRegExp:Yc,isFunction:ee,isStream:Ac,isURLSearchParams:xc,isTypedArray:$c,isFileList:kc,forEach:Nt,merge:ns,extend:Bc,trim:Mc,stripBOM:Uc,inherits:Hc,toFlatObject:Wc,kindOf:vn,kindOfTest:le,endsWith:qc,toArray:Vc,forEachEntry:zc,matchAll:jc,isHTMLForm:Kc,hasOwnProperty:br,hasOwnProp:br,reduceDescriptors:oo,freezeMethods:Qc,toObjectSet:Jc,toCamelCase:Gc,noop:Xc,toFiniteNumber:Zc,findKey:ro,global:Ae,isContextDefined:io,isSpecCompliantForm:el,toJSONObject:tl,isAsyncFn:nl,isThenable:sl,setImmediate:ao,asap:rl};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 co=w.prototype,lo={};["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=>{lo[n]={value:n}});Object.defineProperties(w,lo);Object.defineProperty(co,"isAxiosError",{value:!0});w.from=(n,e,t,s,r,i)=>{const o=Object.create(co);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 il=null;function ss(n){return f.isPlainObject(n)||f.isArray(n)}function ho(n){return f.endsWith(n,"[]")?n.slice(0,-2):n}function Cr(n,e,t){return n?n.concat(e).map(function(r,i){return r=ho(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function ol(n){return f.isArray(n)&&!n.some(ss)}const al=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)&&ol(p)||(f.isFileList(p)||f.endsWith(y,"[]"))&&(I=f.toArray(p)))return y=ho(y),I.forEach(function(B,se){!(f.isUndefined(B)||B===null)&&e.append(o===!0?Cr([y],se,i):o===null?y:y+"[]",l(B))}),!1}return ss(p)?!0:(e.append(Cr(g,y,i),l(p)),!1)}const u=[],d=Object.assign(al,{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 Sr(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Ls(n,e){this._pairs=[],n&&Sn(n,this,e)}const uo=Ls.prototype;uo.append=function(e,t){this._pairs.push([e,t])};uo.toString=function(e){const t=e?function(s){return e.call(this,s,Sr)}:Sr;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function cl(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function fo(n,e,t){if(!e)return n;const s=t&&t.encode||cl;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 Ls(e,t).toString(s),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Tr{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 po={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ll=typeof URLSearchParams<"u"?URLSearchParams:Ls,hl=typeof FormData<"u"?FormData:null,ul=typeof Blob<"u"?Blob:null,dl={isBrowser:!0,classes:{URLSearchParams:ll,FormData:hl,Blob:ul},protocols:["http","https","file","blob","url","data"]},Fs=typeof window<"u"&&typeof document<"u",rs=typeof navigator=="object"&&navigator||void 0,fl=Fs&&(!rs||["ReactNative","NativeScript","NS"].indexOf(rs.product)<0),pl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",_l=Fs&&window.location.href||"http://localhost",ml=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fs,hasStandardBrowserEnv:fl,hasStandardBrowserWebWorkerEnv:pl,navigator:rs,origin:_l},Symbol.toStringTag,{value:"Module"})),K={...ml,...dl};function gl(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 yl(n){return f.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function El(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 _o(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]=El(r[o])),!a)}if(f.isFormData(n)&&f.isFunction(n.entries)){const t={};return f.forEachEntry(n,(s,r)=>{e(yl(s),r,t,0)}),t}return null}function wl(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:po,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(_o(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 gl(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),wl(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 vl=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"]),bl=n=>{const e={};let t,s,r;return n&&n.split(`
2
- `).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!t||e[t]&&vl[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e},Rr=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 Cl(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 Sl=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 Tl(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function Rl(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())&&!Sl(e))o(bl(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 Cl(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?Tl(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[Rr]=this[Rr]={accessors:{}}).accessors,r=this.prototype;function i(o){const a=rt(o);s[a]||(Rl(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 mo(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 go(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 Il(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function Nl(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=Nl(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)},Ir=(n,e)=>{const t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},Nr=n=>(...e)=>f.asap(()=>n(...e)),Al=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,Ol=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 xl(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Pl(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function yo(n,e,t){let s=!xl(e);return n&&(s||t==!1)?Pl(n,e):e}const kr=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(kr(l),kr(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 Eo=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=fo(yo(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&&Al(e.url))){const l=r&&i&&Ol.read(i);l&&o.set(r,l)}return e},Dl=typeof XMLHttpRequest<"u",Ll=Dl&&function(n){return new Promise(function(t,s){const r=Eo(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};go(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||po;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=Il(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)})},Fl=(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}},Ml=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},Bl=async function*(n,e){for await(const t of Ul(n))yield*Ml(t,e)},Ul=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=Bl(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",wo=Tn&&typeof ReadableStream=="function",Hl=Tn&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),vo=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Wl=wo&&vo(()=>{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}),Or=64*1024,is=wo&&vo(()=>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 ql=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 Hl(n)).byteLength},Vl=async(n,e)=>{const t=f.toFiniteNumber(n.getContentLength());return t??ql(e)},$l=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}=Eo(n);l=l?(l+"").toLowerCase():"text";let _=Fl([r,i&&i.toAbortSignal()],o),p;const y=_&&_.unsubscribe&&(()=>{_.unsubscribe()});let g;try{if(c&&Wl&&t!=="get"&&t!=="head"&&(g=await Vl(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]=Ir(g,Zt(Nr(c)));s=Ar(Y.body,Or,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(vr=>{Y[vr]=O[vr]});const ye=f.toFiniteNumber(O.headers.get("content-length")),[Te,Mt]=a&&Ir(ye,Zt(Nr(a),!0))||[];O=new Response(Ar(O.body,Or,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)=>{go(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:il,xhr:Ll,fetch:$l};f.forEach(os,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const xr=n=>`- ${n}`,zl=n=>f.isFunction(n)||n===null||n===!1,bo={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,!zl(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
- `+i.map(xr).join(`
5
- `):" "+xr(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 Pr(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),bo.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 mo(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 Co="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 Dr={};Rn.transitional=function(e,t,s){function r(i,o){return"[Axios v"+Co+"] 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&&!Dr[o]&&(Dr[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 jl(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:jl,validators:Rn},he=$t.validators;let xe=class{constructor(e){this.defaults=e,this.interceptors={request:new Tr,response:new Tr}}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=[Pr.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=Pr.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=yo(e.baseURL,e.url,e.allowAbsoluteUrls);return fo(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 Kl=class So{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 So(function(r){e=r}),cancel:e}}};function Gl(n){return function(t){return n.apply(null,t)}}function Yl(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 To(n){const e=new xe(n),t=to(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 To(Pe(n,r))},t}const k=To(kt);k.Axios=xe;k.CanceledError=Ze;k.CancelToken=Kl;k.isCancel=mo;k.VERSION=Co;k.toFormData=Sn;k.AxiosError=w;k.Cancel=k.CanceledError;k.all=function(e){return Promise.all(e)};k.spread=Gl;k.isAxiosError=Yl;k.mergeConfig=Pe;k.AxiosHeaders=X;k.formToJSON=n=>_o(f.isHTMLForm(n)?new FormData(n):n);k.getAdapter=bo.getAdapter;k.HttpStatusCode=as;k.default=k;const{Axios:W_,AxiosError:q_,CanceledError:V_,isCancel:$_,CancelToken:z_,VERSION:j_,all:K_,Cancel:G_,isAxiosError:Y_,spread:Q_,toFormData:J_,AxiosHeaders:X_,HttpStatusCode:Z_,formToJSON:em,getAdapter:tm,mergeConfig:nm}=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"},Ro=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Io=typeof ArrayBuffer=="function",No=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,Ms=({type:n,data:e},t,s)=>Ro&&e instanceof Blob?t?s(e):Lr(e,s):Io&&(e instanceof ArrayBuffer||No(e))?t?s(e):Lr(new Blob([e]),s):s(ue[n]+(e||"")),Lr=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function Fr(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let qn;function Ql(n,e){if(Ro&&n.data instanceof Blob)return n.data.arrayBuffer().then(Fr).then(e);if(Io&&(n.data instanceof ArrayBuffer||No(n.data)))return e(Fr(n.data));Ms(n,!1,t=>{qn||(qn=new TextEncoder),e(qn.encode(t))})}const Mr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ht=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<Mr.length;n++)ht[Mr.charCodeAt(n)]=n;const Jl=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},Xl=typeof ArrayBuffer=="function",Bs=(n,e)=>{if(typeof n!="string")return{type:"message",data:ko(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:Zl(n.substring(1),e)}:zt[t]?n.length>1?{type:zt[t],data:n.substring(1)}:{type:zt[t]}:cs},Zl=(n,e)=>{if(Xl){const t=Jl(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}},Ao="",eh=(n,e)=>{const t=n.length,s=new Array(t);let r=0;n.forEach((i,o)=>{Ms(i,!1,a=>{s[o]=a,++r===t&&e(s.join(Ao))})})},th=(n,e)=>{const t=n.split(Ao),s=[];for(let r=0;r<t.length;r++){const i=Bs(t[r],e);if(s.push(i),i.type==="error")break}return s};function nh(){return new TransformStream({transform(n,e){Ql(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 sh(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(Bs(i?c:Vn.decode(c),e)),s=0}if(r===0||r>n){a.enqueue(cs);break}}}})}const Oo=4;function H(n){if(n)return rh(n)}function rh(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")(),ih="arraybuffer";function xo(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const oh=ne.setTimeout,ah=ne.clearTimeout;function Nn(n,e){e.useNativeTimers?(n.setTimeoutFn=oh.bind(ne),n.clearTimeoutFn=ah.bind(ne)):(n.setTimeoutFn=ne.setTimeout.bind(ne),n.clearTimeoutFn=ne.clearTimeout.bind(ne))}const ch=1.33;function lh(n){return typeof n=="string"?hh(n):Math.ceil((n.byteLength||n.size)*ch)}function hh(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 Po(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function uh(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function dh(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 fh extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class Us 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 fh(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=Bs(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=uh(e);return t.length?"?"+t:""}}class ph extends Us{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)};th(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,eh(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]=Po()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let Do=!1;try{Do=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const _h=Do;function mh(){}class gh extends ph{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=xo(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=mh,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",Br);else if(typeof addEventListener=="function"){const n="onpagehide"in ne?"pagehide":"unload";addEventListener(n,Br,!1)}}function Br(){for(let n in Ve.requests)Ve.requests.hasOwnProperty(n)&&Ve.requests[n].abort()}const yh=function(){const n=Lo({xdomain:!1});return n&&n.responseType!==null}();class Eh extends gh{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=yh&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ve(Lo,this.uri(),e)}}function Lo(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||_h))return new XMLHttpRequest}catch{}if(!e)try{return new ne[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Fo=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class wh extends Us{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=Fo?{}:xo(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;Ms(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]=Po()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const $n=ne.WebSocket||ne.MozWebSocket;class vh extends wh{createSocket(e,t,s){return Fo?new $n(e,t,s):t?new $n(e,t):new $n(e)}doWrite(e,t){this.ws.send(t)}}class bh extends Us{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=sh(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),r=nh();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 Ch={websocket:vh,webtransport:bh,polling:Eh},Sh=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Th=["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=Sh.exec(n||""),i={},o=14;for(;o--;)i[Th[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=Rh(i,i.path),i.queryKey=Ih(i,i.query),i}function Rh(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 Ih(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=ih,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=dh(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=Oo,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+=lh(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=Oo;class Nh 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 Nh{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=>Ch[r]).filter(r=>!!r)),super(e,s)}};function Ah(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 Oh=typeof ArrayBuffer=="function",xh=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Mo=Object.prototype.toString,Ph=typeof Blob=="function"||typeof Blob<"u"&&Mo.call(Blob)==="[object BlobConstructor]",Dh=typeof File=="function"||typeof File<"u"&&Mo.call(File)==="[object FileConstructor]";function Hs(n){return Oh&&(n instanceof ArrayBuffer||xh(n))||Ph&&n instanceof Blob||Dh&&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(Hs(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 Lh(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(Hs(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 Fh(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 Mh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Bh=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 Uh{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=Lh(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}}function Ur(n){return Object.prototype.toString.call(n)==="[object Object]"}class Ws 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 Hh(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Hs(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(Ws.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 Ur(t);case T.DISCONNECT:return t===void 0;case T.CONNECT_ERROR:return typeof t=="string"||Ur(t);case T.EVENT:case T.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Mh.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 Hh{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=Fh(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Wh=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Ws,Encoder:Uh,get PacketType(){return T},protocol:Bh},Symbol.toStringTag,{value:"Module"}));function re(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const qh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Bo 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(qh.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||Wh;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 Bo(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=Ah(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:Bo,io:Yt,connect:Yt});const Vh=()=>{};/**
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(`
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 :
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=()=>{};/**
7
7
  * @license
8
8
  * Copyright 2017 Google LLC
9
9
  *
@@ -18,7 +18,7 @@
18
18
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
- */const Uo={NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};/**
21
+ */const Ho={NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"};/**
22
22
  * @license
23
23
  * Copyright 2017 Google LLC
24
24
  *
@@ -33,7 +33,7 @@
33
33
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
34
  * See the License for the specific language governing permissions and
35
35
  * limitations under the License.
36
- */const m=function(n,e){if(!n)throw tt(e)},tt=function(n){return new Error("Firebase Database ("+Uo.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)};/**
36
+ */const m=function(n,e){if(!n)throw tt(e)},tt=function(n){return new Error("Firebase Database ("+Ho.SDK_VERSION+") INTERNAL ASSERT FAILED: "+n)};/**
37
37
  * @license
38
38
  * Copyright 2017 Google LLC
39
39
  *
@@ -48,7 +48,7 @@
48
48
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
49
  * See the License for the specific language governing permissions and
50
50
  * limitations under the License.
51
- */const Ho=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);r<128?e[t++]=r:r<2048?(e[t++]=r>>6|192,e[t++]=r&63|128):(r&64512)===55296&&s+1<n.length&&(n.charCodeAt(s+1)&64512)===56320?(r=65536+((r&1023)<<10)+(n.charCodeAt(++s)&1023),e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=r&63|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=r&63|128)}return e},$h=function(n){const e=[];let t=0,s=0;for(;t<n.length;){const r=n[t++];if(r<128)e[s++]=String.fromCharCode(r);else if(r>191&&r<224){const i=n[t++];e[s++]=String.fromCharCode((r&31)<<6|i&63)}else if(r>239&&r<365){const i=n[t++],o=n[t++],a=n[t++],c=((r&7)<<18|(i&63)<<12|(o&63)<<6|a&63)-65536;e[s++]=String.fromCharCode(55296+(c>>10)),e[s++]=String.fromCharCode(56320+(c&1023))}else{const i=n[t++],o=n[t++];e[s++]=String.fromCharCode((r&15)<<12|(i&63)<<6|o&63)}}return e.join("")},qs={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<n.length;r+=3){const i=n[r],o=r+1<n.length,a=o?n[r+1]:0,c=r+2<n.length,l=c?n[r+2]:0,h=i>>2,u=(i&3)<<4|a>>4;let d=(a&15)<<2|l>>6,_=l&63;c||(_=64,o||(d=64)),s.push(t[h],t[u],t[d],t[_])}return s.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Ho(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):$h(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let r=0;r<n.length;){const i=t[n.charAt(r++)],a=r<n.length?t[n.charAt(r)]:0;++r;const l=r<n.length?t[n.charAt(r)]:64;++r;const u=r<n.length?t[n.charAt(r)]:64;if(++r,i==null||a==null||l==null||u==null)throw new zh;const d=i<<2|a>>4;if(s.push(d),l!==64){const _=a<<4&240|l>>2;if(s.push(_),u!==64){const p=l<<6&192|u;s.push(p)}}}return s},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class zh extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Wo=function(n){const e=Ho(n);return qs.encodeByteArray(e,!0)},tn=function(n){return Wo(n).replace(/\./g,"")},ps=function(n){try{return qs.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
51
+ */const Wo=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);r<128?e[t++]=r:r<2048?(e[t++]=r>>6|192,e[t++]=r&63|128):(r&64512)===55296&&s+1<n.length&&(n.charCodeAt(s+1)&64512)===56320?(r=65536+((r&1023)<<10)+(n.charCodeAt(++s)&1023),e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=r&63|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=r&63|128)}return e},zh=function(n){const e=[];let t=0,s=0;for(;t<n.length;){const r=n[t++];if(r<128)e[s++]=String.fromCharCode(r);else if(r>191&&r<224){const i=n[t++];e[s++]=String.fromCharCode((r&31)<<6|i&63)}else if(r>239&&r<365){const i=n[t++],o=n[t++],a=n[t++],c=((r&7)<<18|(i&63)<<12|(o&63)<<6|a&63)-65536;e[s++]=String.fromCharCode(55296+(c>>10)),e[s++]=String.fromCharCode(56320+(c&1023))}else{const i=n[t++],o=n[t++];e[s++]=String.fromCharCode((r&15)<<12|(i&63)<<6|o&63)}}return e.join("")},Ws={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<n.length;r+=3){const i=n[r],o=r+1<n.length,a=o?n[r+1]:0,c=r+2<n.length,l=c?n[r+2]:0,h=i>>2,u=(i&3)<<4|a>>4;let d=(a&15)<<2|l>>6,_=l&63;c||(_=64,o||(d=64)),s.push(t[h],t[u],t[d],t[_])}return s.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Wo(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):zh(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let r=0;r<n.length;){const i=t[n.charAt(r++)],a=r<n.length?t[n.charAt(r)]:0;++r;const l=r<n.length?t[n.charAt(r)]:64;++r;const u=r<n.length?t[n.charAt(r)]:64;if(++r,i==null||a==null||l==null||u==null)throw new jh;const d=i<<2|a>>4;if(s.push(d),l!==64){const _=a<<4&240|l>>2;if(s.push(_),u!==64){const p=l<<6&192|u;s.push(p)}}}return s},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class jh extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const qo=function(n){const e=Wo(n);return Ws.encodeByteArray(e,!0)},tn=function(n){return qo(n).replace(/\./g,"")},ps=function(n){try{return Ws.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
52
52
  * @license
53
53
  * Copyright 2017 Google LLC
54
54
  *
@@ -63,7 +63,7 @@
63
63
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64
64
  * See the License for the specific language governing permissions and
65
65
  * limitations under the License.
66
- */function jh(n){return qo(void 0,n)}function qo(n,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:const t=e;return new Date(t.getTime());case Object:n===void 0&&(n={});break;case Array:n=[];break;default:return e}for(const t in e)!e.hasOwnProperty(t)||!Kh(t)||(n[t]=qo(n[t],e[t]));return n}function Kh(n){return n!=="__proto__"}/**
66
+ */function Kh(n){return Vo(void 0,n)}function Vo(n,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:const t=e;return new Date(t.getTime());case Object:n===void 0&&(n={});break;case Array:n=[];break;default:return e}for(const t in e)!e.hasOwnProperty(t)||!Gh(t)||(n[t]=Vo(n[t],e[t]));return n}function Gh(n){return n!=="__proto__"}/**
67
67
  * @license
68
68
  * Copyright 2022 Google LLC
69
69
  *
@@ -78,7 +78,7 @@
78
78
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79
79
  * See the License for the specific language governing permissions and
80
80
  * limitations under the License.
81
- */function Gh(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
81
+ */function Yh(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
82
82
  * @license
83
83
  * Copyright 2022 Google LLC
84
84
  *
@@ -93,7 +93,7 @@
93
93
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
94
94
  * See the License for the specific language governing permissions and
95
95
  * limitations under the License.
96
- */const Yh=()=>Gh().__FIREBASE_DEFAULTS__,Qh=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Jh=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&ps(n[1]);return e&&JSON.parse(e)},Vo=()=>{try{return Vh()||Yh()||Qh()||Jh()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Xh=n=>{var e,t;return(t=(e=Vo())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},Zh=n=>{const e=Xh(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const s=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),s]:[e.substring(0,t),s]},$o=()=>{var n;return(n=Vo())===null||n===void 0?void 0:n.config};/**
96
+ */const Qh=()=>Yh().__FIREBASE_DEFAULTS__,Jh=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Xh=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&ps(n[1]);return e&&JSON.parse(e)},$o=()=>{try{return $h()||Qh()||Jh()||Xh()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Zh=n=>{var e,t;return(t=(e=$o())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},eu=n=>{const e=Zh(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const s=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),s]:[e.substring(0,t),s]},zo=()=>{var n;return(n=$o())===null||n===void 0?void 0:n.config};/**
97
97
  * @license
98
98
  * Copyright 2017 Google LLC
99
99
  *
@@ -108,7 +108,7 @@
108
108
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
109
109
  * See the License for the specific language governing permissions and
110
110
  * limitations under the License.
111
- */class Vs{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,s)=>{t?this.reject(t):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,s))}}}/**
111
+ */class qs{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,s)=>{t?this.reject(t):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,s))}}}/**
112
112
  * @license
113
113
  * Copyright 2021 Google LLC
114
114
  *
@@ -123,7 +123,7 @@
123
123
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124
124
  * See the License for the specific language governing permissions and
125
125
  * limitations under the License.
126
- */function eu(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},s=e||"demo-project",r=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${s}`,aud:s,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},n);return[tn(JSON.stringify(t)),tn(JSON.stringify(o)),""].join(".")}/**
126
+ */function tu(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},s=e||"demo-project",r=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${s}`,aud:s,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},n);return[tn(JSON.stringify(t)),tn(JSON.stringify(o)),""].join(".")}/**
127
127
  * @license
128
128
  * Copyright 2017 Google LLC
129
129
  *
@@ -138,7 +138,7 @@
138
138
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139
139
  * See the License for the specific language governing permissions and
140
140
  * limitations under the License.
141
- */function tu(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function zo(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(tu())}function nu(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function su(){return Uo.NODE_ADMIN===!0}function ru(){try{return typeof indexedDB=="object"}catch{return!1}}function iu(){return new Promise((n,e)=>{try{let t=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),t||self.indexedDB.deleteDatabase(s),n(!0)},r.onupgradeneeded=()=>{t=!1},r.onerror=()=>{var i;e(((i=r.error)===null||i===void 0?void 0:i.message)||"")}}catch(t){e(t)}})}/**
141
+ */function nu(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function jo(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(nu())}function su(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function ru(){return Ho.NODE_ADMIN===!0}function iu(){try{return typeof indexedDB=="object"}catch{return!1}}function ou(){return new Promise((n,e)=>{try{let t=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),t||self.indexedDB.deleteDatabase(s),n(!0)},r.onupgradeneeded=()=>{t=!1},r.onerror=()=>{var i;e(((i=r.error)===null||i===void 0?void 0:i.message)||"")}}catch(t){e(t)}})}/**
142
142
  * @license
143
143
  * Copyright 2017 Google LLC
144
144
  *
@@ -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 ou="FirebaseError";class At extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name=ou,Object.setPrototypeOf(this,At.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,jo.prototype.create)}}class jo{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?au(i,s):"Error",a=`${this.serviceName}: ${o} (${r}).`;return new At(r,a,s)}}function au(n,e){return n.replace(cu,(t,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`})}const cu=/\{\$([^}]+)}/g;/**
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;/**
157
157
  * @license
158
158
  * Copyright 2017 Google LLC
159
159
  *
@@ -183,7 +183,7 @@
183
183
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
184
184
  * See the License for the specific language governing permissions and
185
185
  * limitations under the License.
186
- */const Ko=function(n){let e={},t={},s={},r="";try{const i=n.split(".");e=yt(ps(i[0])||""),t=yt(ps(i[1])||""),r=i[2],s=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:s,signature:r}},lu=function(n){const e=Ko(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},hu=function(n){const e=Ko(n).claims;return typeof e=="object"&&e.admin===!0};/**
186
+ */const Go=function(n){let e={},t={},s={},r="";try{const i=n.split(".");e=yt(ps(i[0])||""),t=yt(ps(i[1])||""),r=i[2],s=t.d||{},delete t.d}catch{}return{header:e,claims:t,data:s,signature:r}},hu=function(n){const e=Go(n),t=e.claims;return!!t&&typeof t=="object"&&t.hasOwnProperty("iat")},uu=function(n){const e=Go(n).claims;return typeof e=="object"&&e.admin===!0};/**
187
187
  * @license
188
188
  * Copyright 2017 Google LLC
189
189
  *
@@ -198,7 +198,7 @@
198
198
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
199
  * See the License for the specific language governing permissions and
200
200
  * limitations under the License.
201
- */function me(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Ge(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function Hr(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function nn(n,e,t){const s={};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(s[r]=e.call(t,n[r],r,n));return s}function sn(n,e){if(n===e)return!0;const t=Object.keys(n),s=Object.keys(e);for(const r of t){if(!s.includes(r))return!1;const i=n[r],o=e[r];if(Wr(i)&&Wr(o)){if(!sn(i,o))return!1}else if(i!==o)return!1}for(const r of s)if(!t.includes(r))return!1;return!0}function Wr(n){return n!==null&&typeof n=="object"}/**
201
+ */function me(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function Ge(n,e){if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}function Ur(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function nn(n,e,t){const s={};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(s[r]=e.call(t,n[r],r,n));return s}function sn(n,e){if(n===e)return!0;const t=Object.keys(n),s=Object.keys(e);for(const r of t){if(!s.includes(r))return!1;const i=n[r],o=e[r];if(Hr(i)&&Hr(o)){if(!sn(i,o))return!1}else if(i!==o)return!1}for(const r of s)if(!t.includes(r))return!1;return!0}function Hr(n){return n!==null&&typeof n=="object"}/**
202
202
  * @license
203
203
  * Copyright 2017 Google LLC
204
204
  *
@@ -213,7 +213,7 @@
213
213
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
214
214
  * See the License for the specific language governing permissions and
215
215
  * limitations under the License.
216
- */function uu(n){const e=[];for(const[t,s]of Object.entries(n))Array.isArray(s)?s.forEach(r=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(r))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}/**
216
+ */function du(n){const e=[];for(const[t,s]of Object.entries(n))Array.isArray(s)?s.forEach(r=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(r))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}/**
217
217
  * @license
218
218
  * Copyright 2017 Google LLC
219
219
  *
@@ -228,7 +228,7 @@
228
228
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
229
229
  * See the License for the specific language governing permissions and
230
230
  * limitations under the License.
231
- */class du{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const s=this.W_;if(typeof e=="string")for(let u=0;u<16;u++)s[u]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let u=0;u<16;u++)s[u]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let u=16;u<80;u++){const d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=(d<<1|d>>>31)&4294967295}let r=this.chain_[0],i=this.chain_[1],o=this.chain_[2],a=this.chain_[3],c=this.chain_[4],l,h;for(let u=0;u<80;u++){u<40?u<20?(l=a^i&(o^a),h=1518500249):(l=i^o^a,h=1859775393):u<60?(l=i&o|a&(i|o),h=2400959708):(l=i^o^a,h=3395469782);const d=(r<<5|r>>>27)+l+c+h+s[u]&4294967295;c=a,a=o,o=(i<<30|i>>>2)&4294967295,i=r,r=d}this.chain_[0]=this.chain_[0]+r&4294967295,this.chain_[1]=this.chain_[1]+i&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const s=t-this.blockSize;let r=0;const i=this.buf_;let o=this.inbuf_;for(;r<t;){if(o===0)for(;r<=s;)this.compress_(e,r),r+=this.blockSize;if(typeof e=="string"){for(;r<t;)if(i[o]=e.charCodeAt(r),++o,++r,o===this.blockSize){this.compress_(i),o=0;break}}else for(;r<t;)if(i[o]=e[r],++o,++r,o===this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=t}digest(){const e=[];let t=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let r=this.blockSize-1;r>=56;r--)this.buf_[r]=t&255,t/=256;this.compress_(this.buf_);let s=0;for(let r=0;r<5;r++)for(let i=24;i>=0;i-=8)e[s]=this.chain_[r]>>i&255,++s;return e}}function Go(n,e){return`${n} failed: ${e} argument `}/**
231
+ */class fu{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=512/8,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const s=this.W_;if(typeof e=="string")for(let u=0;u<16;u++)s[u]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let u=0;u<16;u++)s[u]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let u=16;u<80;u++){const d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=(d<<1|d>>>31)&4294967295}let r=this.chain_[0],i=this.chain_[1],o=this.chain_[2],a=this.chain_[3],c=this.chain_[4],l,h;for(let u=0;u<80;u++){u<40?u<20?(l=a^i&(o^a),h=1518500249):(l=i^o^a,h=1859775393):u<60?(l=i&o|a&(i|o),h=2400959708):(l=i^o^a,h=3395469782);const d=(r<<5|r>>>27)+l+c+h+s[u]&4294967295;c=a,a=o,o=(i<<30|i>>>2)&4294967295,i=r,r=d}this.chain_[0]=this.chain_[0]+r&4294967295,this.chain_[1]=this.chain_[1]+i&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+a&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(e==null)return;t===void 0&&(t=e.length);const s=t-this.blockSize;let r=0;const i=this.buf_;let o=this.inbuf_;for(;r<t;){if(o===0)for(;r<=s;)this.compress_(e,r),r+=this.blockSize;if(typeof e=="string"){for(;r<t;)if(i[o]=e.charCodeAt(r),++o,++r,o===this.blockSize){this.compress_(i),o=0;break}}else for(;r<t;)if(i[o]=e[r],++o,++r,o===this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=t}digest(){const e=[];let t=this.total_*8;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let r=this.blockSize-1;r>=56;r--)this.buf_[r]=t&255,t/=256;this.compress_(this.buf_);let s=0;for(let r=0;r<5;r++)for(let i=24;i>=0;i-=8)e[s]=this.chain_[r]>>i&255,++s;return e}}function Yo(n,e){return`${n} failed: ${e} argument `}/**
232
232
  * @license
233
233
  * Copyright 2017 Google LLC
234
234
  *
@@ -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 fu=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},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};/**
247
247
  * @license
248
248
  * Copyright 2021 Google LLC
249
249
  *
@@ -288,7 +288,7 @@
288
288
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
289
289
  * See the License for the specific language governing permissions and
290
290
  * limitations under the License.
291
- */class pu{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const s=new Vs;if(this.instancesDeferred.set(t,s),this.isInitialized(t)||this.shouldAutoInitialize())try{const r=this.getOrInitializeService({instanceIdentifier:t});r&&s.resolve(r)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const s=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(s)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:s})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(mu(e))try{this.getOrInitializeService({instanceIdentifier:Re})}catch{}for(const[t,s]of this.instancesDeferred.entries()){const r=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:r});s.resolve(i)}catch{}}}}clearInstance(e=Re){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Re){return this.instances.has(e)}getOptions(e=Re){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[i,o]of this.instancesDeferred.entries()){const a=this.normalizeInstanceIdentifier(i);s===a&&o.resolve(r)}return r}onInit(e,t){var s;const r=this.normalizeInstanceIdentifier(t),i=(s=this.onInitCallbacks.get(r))!==null&&s!==void 0?s:new Set;i.add(e),this.onInitCallbacks.set(r,i);const o=this.instances.get(r);return o&&e(o,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const r of s)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:_u(e),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=Re){return this.component?this.component.multipleInstances?e:Re:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function _u(n){return n===Re?void 0:n}function mu(n){return n.instantiationMode==="EAGER"}/**
291
+ */class _u{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const s=new qs;if(this.instancesDeferred.set(t,s),this.isInitialized(t)||this.shouldAutoInitialize())try{const r=this.getOrInitializeService({instanceIdentifier:t});r&&s.resolve(r)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const s=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(s)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:s})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(gu(e))try{this.getOrInitializeService({instanceIdentifier:Re})}catch{}for(const[t,s]of this.instancesDeferred.entries()){const r=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:r});s.resolve(i)}catch{}}}}clearInstance(e=Re){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Re){return this.instances.has(e)}getOptions(e=Re){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[i,o]of this.instancesDeferred.entries()){const a=this.normalizeInstanceIdentifier(i);s===a&&o.resolve(r)}return r}onInit(e,t){var s;const r=this.normalizeInstanceIdentifier(t),i=(s=this.onInitCallbacks.get(r))!==null&&s!==void 0?s:new Set;i.add(e),this.onInitCallbacks.set(r,i);const o=this.instances.get(r);return o&&e(o,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const r of s)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:mu(e),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=Re){return this.component?this.component.multipleInstances?e:Re:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function mu(n){return n===Re?void 0:n}function gu(n){return n.instantiationMode==="EAGER"}/**
292
292
  * @license
293
293
  * Copyright 2019 Google LLC
294
294
  *
@@ -303,7 +303,7 @@
303
303
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
304
304
  * See the License for the specific language governing permissions and
305
305
  * limitations under the License.
306
- */class gu{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new pu(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
306
+ */class yu{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new _u(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
307
307
  * @license
308
308
  * Copyright 2017 Google LLC
309
309
  *
@@ -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 yu={debug:L.DEBUG,verbose:L.VERBOSE,info:L.INFO,warn:L.WARN,error:L.ERROR,silent:L.SILENT},Eu=L.INFO,wu={[L.DEBUG]:"log",[L.VERBOSE]:"log",[L.INFO]:"info",[L.WARN]:"warn",[L.ERROR]:"error"},vu=(n,e,...t)=>{if(e<n.logLevel)return;const s=new Date().toISOString(),r=wu[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 Yo{constructor(e){this.name=e,this._logLevel=Eu,this._logHandler=vu,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"?yu[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 bu=(n,e)=>e.some(t=>n instanceof t);let qr,Vr;function Cu(){return qr||(qr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Su(){return Vr||(Vr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Qo=new WeakMap,_s=new WeakMap,Jo=new WeakMap,zn=new WeakMap,$s=new WeakMap;function Tu(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&&Qo.set(t,n)}).catch(()=>{}),$s.set(e,n),e}function Ru(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||Jo.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 Iu(n){ms=n(ms)}function Nu(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(jn(this),e,...t);return Jo.set(s,e.sort?e.sort():[e]),we(s)}:Su().includes(n)?function(...e){return n.apply(jn(this),e),we(Qo.get(this))}:function(...e){return we(n.apply(jn(this),e))}}function ku(n){return typeof n=="function"?Nu(n):(n instanceof IDBTransaction&&Ru(n),bu(n,Cu())?new Proxy(n,ms):n)}function we(n){if(n instanceof IDBRequest)return Tu(n);if(zn.has(n))return zn.get(n);const e=ku(n);return e!==n&&(zn.set(n,e),$s.set(e,n)),e}const jn=n=>$s.get(n);function Au(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 Ou=["get","getKey","getAll","getAllKeys","count"],xu=["put","add","delete","clear"],Kn=new Map;function $r(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=xu.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(r||Ou.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}Iu(n=>({...n,get:(e,t,s)=>$r(e,t)||n.get(e,t,s),has:(e,t)=>!!$r(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 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)}));/**
322
322
  * @license
323
323
  * Copyright 2019 Google LLC
324
324
  *
@@ -333,7 +333,7 @@
333
333
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
334
334
  * See the License for the specific language governing permissions and
335
335
  * limitations under the License.
336
- */class Pu{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Du(t)){const s=t.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(t=>t).join(" ")}}function Du(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const gs="@firebase/app",zr="0.11.5";/**
336
+ */class Du{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Lu(t)){const s=t.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(t=>t).join(" ")}}function Lu(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const gs="@firebase/app",$r="0.11.5";/**
337
337
  * @license
338
338
  * Copyright 2019 Google LLC
339
339
  *
@@ -348,7 +348,7 @@
348
348
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
349
349
  * See the License for the specific language governing permissions and
350
350
  * limitations under the License.
351
- */const pe=new Yo("@firebase/app"),Lu="@firebase/app-compat",Fu="@firebase/analytics-compat",Mu="@firebase/analytics",Bu="@firebase/app-check-compat",Uu="@firebase/app-check",Hu="@firebase/auth",Wu="@firebase/auth-compat",qu="@firebase/database",Vu="@firebase/data-connect",$u="@firebase/database-compat",zu="@firebase/functions",ju="@firebase/functions-compat",Ku="@firebase/installations",Gu="@firebase/installations-compat",Yu="@firebase/messaging",Qu="@firebase/messaging-compat",Ju="@firebase/performance",Xu="@firebase/performance-compat",Zu="@firebase/remote-config",ed="@firebase/remote-config-compat",td="@firebase/storage",nd="@firebase/storage-compat",sd="@firebase/firestore",rd="@firebase/vertexai",id="@firebase/firestore-compat",od="firebase",ad="11.6.1";/**
351
+ */const pe=new Qo("@firebase/app"),Fu="@firebase/app-compat",Mu="@firebase/analytics-compat",Bu="@firebase/analytics",Uu="@firebase/app-check-compat",Hu="@firebase/app-check",Wu="@firebase/auth",qu="@firebase/auth-compat",Vu="@firebase/database",$u="@firebase/data-connect",zu="@firebase/database-compat",ju="@firebase/functions",Ku="@firebase/functions-compat",Gu="@firebase/installations",Yu="@firebase/installations-compat",Qu="@firebase/messaging",Ju="@firebase/messaging-compat",Xu="@firebase/performance",Zu="@firebase/performance-compat",ed="@firebase/remote-config",td="@firebase/remote-config-compat",nd="@firebase/storage",sd="@firebase/storage-compat",rd="@firebase/firestore",id="@firebase/vertexai",od="@firebase/firestore-compat",ad="firebase",cd="11.6.1";/**
352
352
  * @license
353
353
  * Copyright 2019 Google LLC
354
354
  *
@@ -363,7 +363,7 @@
363
363
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
364
364
  * See the License for the specific language governing permissions and
365
365
  * limitations under the License.
366
- */const ys="[DEFAULT]",cd={[gs]:"fire-core",[Lu]:"fire-core-compat",[Mu]:"fire-analytics",[Fu]:"fire-analytics-compat",[Uu]:"fire-app-check",[Bu]:"fire-app-check-compat",[Hu]:"fire-auth",[Wu]:"fire-auth-compat",[qu]:"fire-rtdb",[Vu]:"fire-data-connect",[$u]:"fire-rtdb-compat",[zu]:"fire-fn",[ju]:"fire-fn-compat",[Ku]:"fire-iid",[Gu]:"fire-iid-compat",[Yu]:"fire-fcm",[Qu]:"fire-fcm-compat",[Ju]:"fire-perf",[Xu]:"fire-perf-compat",[Zu]:"fire-rc",[ed]:"fire-rc-compat",[td]:"fire-gcs",[nd]:"fire-gcs-compat",[sd]:"fire-fst",[id]:"fire-fst-compat",[rd]:"fire-vertex","fire-js":"fire-js",[od]:"fire-js-all"};/**
366
+ */const ys="[DEFAULT]",ld={[gs]:"fire-core",[Fu]:"fire-core-compat",[Bu]:"fire-analytics",[Mu]:"fire-analytics-compat",[Hu]:"fire-app-check",[Uu]:"fire-app-check-compat",[Wu]:"fire-auth",[qu]:"fire-auth-compat",[Vu]:"fire-rtdb",[$u]:"fire-data-connect",[zu]:"fire-rtdb-compat",[ju]:"fire-fn",[Ku]:"fire-fn-compat",[Gu]:"fire-iid",[Yu]:"fire-iid-compat",[Qu]:"fire-fcm",[Ju]:"fire-fcm-compat",[Xu]:"fire-perf",[Zu]:"fire-perf-compat",[ed]:"fire-rc",[td]:"fire-rc-compat",[nd]:"fire-gcs",[sd]:"fire-gcs-compat",[rd]:"fire-fst",[od]:"fire-fst-compat",[id]:"fire-vertex","fire-js":"fire-js",[ad]:"fire-js-all"};/**
367
367
  * @license
368
368
  * Copyright 2019 Google LLC
369
369
  *
@@ -378,7 +378,7 @@
378
378
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
379
379
  * See the License for the specific language governing permissions and
380
380
  * limitations under the License.
381
- */const rn=new Map,ld=new Map,Es=new Map;function jr(n,e){try{n.container.addComponent(e)}catch(t){pe.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function on(n){const e=n.name;if(Es.has(e))return pe.debug(`There were multiple attempts to register component ${e}.`),!1;Es.set(e,n);for(const t of rn.values())jr(t,n);for(const t of ld.values())jr(t,n);return!0}function hd(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function ud(n){return n==null?!1:n.settings!==void 0}/**
381
+ */const rn=new Map,hd=new Map,Es=new Map;function zr(n,e){try{n.container.addComponent(e)}catch(t){pe.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function on(n){const e=n.name;if(Es.has(e))return pe.debug(`There were multiple attempts to register component ${e}.`),!1;Es.set(e,n);for(const t of rn.values())zr(t,n);for(const t of hd.values())zr(t,n);return!0}function ud(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function dd(n){return n==null?!1:n.settings!==void 0}/**
382
382
  * @license
383
383
  * Copyright 2019 Google LLC
384
384
  *
@@ -393,7 +393,7 @@
393
393
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
394
394
  * See the License for the specific language governing permissions and
395
395
  * limitations under the License.
396
- */const dd={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},ve=new jo("app","Firebase",dd);/**
396
+ */const fd={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},ve=new Ko("app","Firebase",fd);/**
397
397
  * @license
398
398
  * Copyright 2019 Google LLC
399
399
  *
@@ -408,7 +408,7 @@
408
408
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
409
409
  * See the License for the specific language governing permissions and
410
410
  * limitations under the License.
411
- */class fd{constructor(e,t,s){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new Et("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw ve.create("app-deleted",{appName:this._name})}}/**
411
+ */class pd{constructor(e,t,s){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new Et("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw ve.create("app-deleted",{appName:this._name})}}/**
412
412
  * @license
413
413
  * Copyright 2019 Google LLC
414
414
  *
@@ -423,7 +423,7 @@
423
423
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
424
424
  * See the License for the specific language governing permissions and
425
425
  * limitations under the License.
426
- */const pd=ad;function Xo(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const s=Object.assign({name:ys,automaticDataCollectionEnabled:!1},e),r=s.name;if(typeof r!="string"||!r)throw ve.create("bad-app-name",{appName:String(r)});if(t||(t=$o()),!t)throw ve.create("no-options");const i=rn.get(r);if(i){if(sn(t,i.options)&&sn(s,i.config))return i;throw ve.create("duplicate-app",{appName:r})}const o=new gu(r);for(const c of Es.values())o.addComponent(c);const a=new fd(t,s,o);return rn.set(r,a),a}function _d(n=ys){const e=rn.get(n);if(!e&&n===ys&&$o())return Xo();if(!e)throw ve.create("no-app",{appName:n});return e}function $e(n,e,t){var s;let r=(s=cd[n])!==null&&s!==void 0?s:n;t&&(r+=`-${t}`);const i=r.match(/\s|\//),o=e.match(/\s|\//);if(i||o){const a=[`Unable to register library "${r}" with version "${e}":`];i&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),pe.warn(a.join(" "));return}on(new Et(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}/**
426
+ */const _d=cd;function Zo(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const s=Object.assign({name:ys,automaticDataCollectionEnabled:!1},e),r=s.name;if(typeof r!="string"||!r)throw ve.create("bad-app-name",{appName:String(r)});if(t||(t=zo()),!t)throw ve.create("no-options");const i=rn.get(r);if(i){if(sn(t,i.options)&&sn(s,i.config))return i;throw ve.create("duplicate-app",{appName:r})}const o=new yu(r);for(const c of Es.values())o.addComponent(c);const a=new pd(t,s,o);return rn.set(r,a),a}function md(n=ys){const e=rn.get(n);if(!e&&n===ys&&zo())return Zo();if(!e)throw ve.create("no-app",{appName:n});return e}function $e(n,e,t){var s;let r=(s=ld[n])!==null&&s!==void 0?s:n;t&&(r+=`-${t}`);const i=r.match(/\s|\//),o=e.match(/\s|\//);if(i||o){const a=[`Unable to register library "${r}" with version "${e}":`];i&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),pe.warn(a.join(" "));return}on(new Et(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}/**
427
427
  * @license
428
428
  * Copyright 2021 Google LLC
429
429
  *
@@ -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 md="firebase-heartbeat-database",gd=1,wt="firebase-heartbeat-store";let Gn=null;function Zo(){return Gn||(Gn=Au(md,gd,{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 yd(n){try{const t=(await Zo()).transaction(wt),s=await t.objectStore(wt).get(ea(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 Kr(n,e){try{const s=(await Zo()).transaction(wt,"readwrite");await s.objectStore(wt).put(e,ea(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 ea(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 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}`}/**
442
442
  * @license
443
443
  * Copyright 2021 Google LLC
444
444
  *
@@ -453,7 +453,7 @@
453
453
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
454
454
  * See the License for the specific language governing permissions and
455
455
  * limitations under the License.
456
- */const Ed=1024,wd=30;class vd{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Cd(t),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){var e,t;try{const r=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=Gr();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(o=>o.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:r}),this._heartbeatsCache.heartbeats.length>wd){const o=Sd(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(o,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(s){pe.warn(s)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Gr(),{heartbeatsToSend:s,unsentEntries:r}=bd(this._heartbeatsCache.heartbeats),i=tn(JSON.stringify({version:2,heartbeats:s}));return this._heartbeatsCache.lastSentHeartbeatDate=t,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(t){return pe.warn(t),""}}}function Gr(){return new Date().toISOString().substring(0,10)}function bd(n,e=Ed){const t=[];let s=n.slice();for(const r of n){const i=t.find(o=>o.agent===r.agent);if(i){if(i.dates.push(r.date),Yr(t)>e){i.dates.pop();break}}else if(t.push({agent:r.agent,dates:[r.date]}),Yr(t)>e){t.pop();break}s=s.slice(1)}return{heartbeatsToSend:t,unsentEntries:s}}class Cd{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ru()?iu().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await yd(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const r=await this.read();return Kr(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const r=await this.read();return Kr(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Yr(n){return tn(JSON.stringify({version:2,heartbeats:n})).length}function Sd(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let s=1;s<n.length;s++)n[s].date<t&&(t=n[s].date,e=s);return e}/**
456
+ */const wd=1024,vd=30;class bd{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Sd(t),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){var e,t;try{const r=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=Kr();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(o=>o.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:r}),this._heartbeatsCache.heartbeats.length>vd){const o=Td(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(o,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(s){pe.warn(s)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Kr(),{heartbeatsToSend:s,unsentEntries:r}=Cd(this._heartbeatsCache.heartbeats),i=tn(JSON.stringify({version:2,heartbeats:s}));return this._heartbeatsCache.lastSentHeartbeatDate=t,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(t){return pe.warn(t),""}}}function Kr(){return new Date().toISOString().substring(0,10)}function Cd(n,e=wd){const t=[];let s=n.slice();for(const r of n){const i=t.find(o=>o.agent===r.agent);if(i){if(i.dates.push(r.date),Gr(t)>e){i.dates.pop();break}}else if(t.push({agent:r.agent,dates:[r.date]}),Gr(t)>e){t.pop();break}s=s.slice(1)}return{heartbeatsToSend:t,unsentEntries:s}}class Sd{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return iu()?ou().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await Ed(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const r=await this.read();return jr(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const r=await this.read();return jr(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Gr(n){return tn(JSON.stringify({version:2,heartbeats:n})).length}function Td(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let s=1;s<n.length;s++)n[s].date<t&&(t=n[s].date,e=s);return e}/**
457
457
  * @license
458
458
  * Copyright 2019 Google LLC
459
459
  *
@@ -468,7 +468,7 @@
468
468
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
469
469
  * See the License for the specific language governing permissions and
470
470
  * limitations under the License.
471
- */function Td(n){on(new Et("platform-logger",e=>new Pu(e),"PRIVATE")),on(new Et("heartbeat",e=>new vd(e),"PRIVATE")),$e(gs,zr,n),$e(gs,zr,"esm2017"),$e("fire-js","")}Td("");const Qr="@firebase/database",Jr="1.0.14";/**
471
+ */function Rd(n){on(new Et("platform-logger",e=>new Du(e),"PRIVATE")),on(new Et("heartbeat",e=>new bd(e),"PRIVATE")),$e(gs,$r,n),$e(gs,$r,"esm2017"),$e("fire-js","")}Rd("");const Yr="@firebase/database",Qr="1.0.14";/**
472
472
  * @license
473
473
  * Copyright 2019 Google LLC
474
474
  *
@@ -483,7 +483,7 @@
483
483
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
484
484
  * See the License for the specific language governing permissions and
485
485
  * limitations under the License.
486
- */let ta="";function Rd(n){ta=n}/**
486
+ */let na="";function Id(n){na=n}/**
487
487
  * @license
488
488
  * Copyright 2017 Google LLC
489
489
  *
@@ -498,7 +498,7 @@
498
498
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
499
499
  * See the License for the specific language governing permissions and
500
500
  * limitations under the License.
501
- */class Id{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){t==null?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),$(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:yt(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}/**
501
+ */class Nd{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){t==null?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),$(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return t==null?null:yt(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}/**
502
502
  * @license
503
503
  * Copyright 2017 Google LLC
504
504
  *
@@ -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 Nd{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 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]}}/**
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 na=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 Id(e)}}catch{}return new Nd},Oe=na("localStorage"),kd=na("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 kd},Oe=sa("localStorage"),Ad=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 Yo("@firebase/database"),Ad=function(){let n=1;return function(){return n++}}(),sa=function(n){const e=fu(n),t=new du;t.update(e);const s=t.digest();return qs.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,Xr=!0;const Od=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(Xr===!0&&(Xr=!1,dt===null&&kd.get("logging_enabled")===!0&&Od()),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)},xd=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().")},ra=function(n){return typeof n=="number"&&(n!==n||n===Number.POSITIVE_INFINITY||n===Number.NEGATIVE_INFINITY)},Pd=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=Zr(n),s=Zr(e);return t!==null?s!==null?t-s===0?n.length-e.length:t-s:-1:s!==null?1:n<e?-1:1}},Dd=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))},zs=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+=zs(n[e[s]]);return t+="}",t},ia=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 oa=function(n){m(!ra(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()},Ld=function(){return!!(typeof window=="object"&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href))},Fd=function(){return typeof Windows=="object"&&typeof Windows.UI=="object"};function Md(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 Bd=new RegExp("^-?(0*)\\d{1,10}$"),Ud=-2147483648,Hd=2147483647,Zr=function(n){if(Bd.test(n)){const e=Number(n);if(e>=Ud&&e<=Hd)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))}},Wd=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&&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};/**
547
547
  * @license
548
548
  * Copyright 2021 Google LLC
549
549
  *
@@ -558,7 +558,7 @@
558
558
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
559
559
  * See the License for the specific language governing permissions and
560
560
  * limitations under the License.
561
- */class qd{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,ud(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t==null?void 0:t.getImmediate({optional:!0}),this.appCheck||t==null||t.get().then(s=>this.appCheck=s)}getToken(e){if(this.serverAppAppCheckToken){if(e)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(e):new Promise((t,s)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){var t;(t=this.appCheckProvider)===null||t===void 0||t.get().then(s=>s.addTokenListener(e))}notifyForInvalidToken(){te(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}}/**
561
+ */class Vd{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,dd(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t==null?void 0:t.getImmediate({optional:!0}),this.appCheck||t==null||t.get().then(s=>this.appCheck=s)}getToken(e){if(this.serverAppAppCheckToken){if(e)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(e):new Promise((t,s)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){var t;(t=this.appCheckProvider)===null||t===void 0||t.get().then(s=>s.addTokenListener(e))}notifyForInvalidToken(){te(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}}/**
562
562
  * @license
563
563
  * Copyright 2017 Google LLC
564
564
  *
@@ -573,7 +573,7 @@
573
573
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
574
574
  * See the License for the specific language governing permissions and
575
575
  * limitations under the License.
576
- */class Vd{constructor(e,t,s){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=s,this.auth_=null,this.auth_=s.getImmediate({optional:!0}),this.auth_||s.onInit(r=>this.auth_=r)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(z("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)):new Promise((t,s)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',te(e)}}class Qt{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Qt.OWNER="owner";/**
576
+ */class $d{constructor(e,t,s){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=s,this.auth_=null,this.auth_=s.getImmediate({optional:!0}),this.auth_||s.onInit(r=>this.auth_=r)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(t=>t&&t.code==="auth/token-not-initialized"?(z("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)):new Promise((t,s)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,s):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',te(e)}}class Qt{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}Qt.OWNER="owner";/**
577
577
  * @license
578
578
  * Copyright 2017 Google LLC
579
579
  *
@@ -588,7 +588,7 @@
588
588
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
589
589
  * See the License for the specific language governing permissions and
590
590
  * limitations under the License.
591
- */const js="5",aa="v",ca="s",la="r",ha="f",ua=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,da="ls",fa="p",vs="ac",pa="websocket",_a="long_polling";/**
591
+ */const zs="5",ca="v",la="s",ha="r",ua="f",da=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,fa="ls",pa="p",vs="ac",_a="websocket",ma="long_polling";/**
592
592
  * @license
593
593
  * Copyright 2017 Google LLC
594
594
  *
@@ -603,7 +603,7 @@
603
603
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
604
604
  * See the License for the specific language governing permissions and
605
605
  * limitations under the License.
606
- */class ma{constructor(e,t,s,r,i=!1,o="",a=!1,c=!1,l=null){this.secure=t,this.namespace=s,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=c,this.emulatorOptions=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Oe.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&Oe.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function $d(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function ga(n,e,t){m(typeof e=="string","typeof type must == string"),m(typeof t=="object","typeof params must == object");let s;if(e===pa)s=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===_a)s=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);$d(n)&&(t.ns=n.namespace);const r=[];return Z(t,(i,o)=>{r.push(i+"="+o)}),s+r.join("&")}/**
606
+ */class ga{constructor(e,t,s,r,i=!1,o="",a=!1,c=!1,l=null){this.secure=t,this.namespace=s,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=c,this.emulatorOptions=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Oe.get("host:"+e)||this._host}isCacheableHost(){return this.internalHost.substr(0,2)==="s-"}isCustomHost(){return this._domain!=="firebaseio.com"&&this._domain!=="firebaseio-demo.com"}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&Oe.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function zd(n){return n.host!==n.internalHost||n.isCustomHost()||n.includeNamespaceInQueryParams}function ya(n,e,t){m(typeof e=="string","typeof type must == string"),m(typeof t=="object","typeof params must == object");let s;if(e===_a)s=(n.secure?"wss://":"ws://")+n.internalHost+"/.ws?";else if(e===ma)s=(n.secure?"https://":"http://")+n.internalHost+"/.lp?";else throw new Error("Unknown connection type: "+e);zd(n)&&(t.ns=n.namespace);const r=[];return Z(t,(i,o)=>{r.push(i+"="+o)}),s+r.join("&")}/**
607
607
  * @license
608
608
  * Copyright 2017 Google LLC
609
609
  *
@@ -618,7 +618,7 @@
618
618
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
619
619
  * See the License for the specific language governing permissions and
620
620
  * limitations under the License.
621
- */class zd{constructor(){this.counters_={}}incrementCounter(e,t=1){me(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return jh(this.counters_)}}/**
621
+ */class jd{constructor(){this.counters_={}}incrementCounter(e,t=1){me(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return Kh(this.counters_)}}/**
622
622
  * @license
623
623
  * Copyright 2017 Google LLC
624
624
  *
@@ -633,7 +633,7 @@
633
633
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
634
634
  * See the License for the specific language governing permissions and
635
635
  * limitations under the License.
636
- */const Yn={},Qn={};function Ks(n){const e=n.toString();return Yn[e]||(Yn[e]=new zd),Yn[e]}function jd(n,e){const t=n.toString();return Qn[t]||(Qn[t]=e()),Qn[t]}/**
636
+ */const Yn={},Qn={};function js(n){const e=n.toString();return Yn[e]||(Yn[e]=new jd),Yn[e]}function Kd(n,e){const t=n.toString();return Qn[t]||(Qn[t]=e()),Qn[t]}/**
637
637
  * @license
638
638
  * Copyright 2017 Google LLC
639
639
  *
@@ -648,7 +648,7 @@
648
648
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
649
649
  * See the License for the specific language governing permissions and
650
650
  * limitations under the License.
651
- */class Kd{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const s=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let r=0;r<s.length;++r)s[r]&&Pt(()=>{this.onMessage_(s[r])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}/**
651
+ */class Gd{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const s=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let r=0;r<s.length;++r)s[r]&&Pt(()=>{this.onMessage_(s[r])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}/**
652
652
  * @license
653
653
  * Copyright 2017 Google LLC
654
654
  *
@@ -663,7 +663,7 @@
663
663
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
664
664
  * See the License for the specific language governing permissions and
665
665
  * limitations under the License.
666
- */const ei="start",Gd="close",Yd="pLPCommand",Qd="pRTLPCB",ya="id",Ea="pw",wa="ser",Jd="cb",Xd="seg",Zd="ts",ef="d",tf="dframe",va=1870,ba=30,nf=va-ba,sf=25e3,rf=3e4;class We{constructor(e,t,s,r,i,o,a){this.connId=e,this.repoInfo=t,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=xt(e),this.stats_=Ks(t),this.urlFn=c=>(this.appCheckToken&&(c[vs]=this.appCheckToken),ga(t,_a,c))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Kd(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(rf)),Pd(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Gs((...i)=>{const[o,a,c,l,h]=i;if(this.incrementIncomingBytes_(i),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===ei)this.id=a,this.password=c;else if(o===Gd)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...i)=>{const[o,a]=i;this.incrementIncomingBytes_(i),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const s={};s[ei]="t",s[wa]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(s[Jd]=this.scriptTagHolder.uniqueCallbackIdentifier),s[aa]=js,this.transportSessionId&&(s[ca]=this.transportSessionId),this.lastSessionId&&(s[da]=this.lastSessionId),this.applicationId&&(s[fa]=this.applicationId),this.appCheckToken&&(s[vs]=this.appCheckToken),typeof location<"u"&&location.hostname&&ua.test(location.hostname)&&(s[la]=ha);const r=this.urlFn(s);this.log_("Connecting via long-poll to "+r),this.scriptTagHolder.addTag(r,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){We.forceAllow_=!0}static forceDisallow(){We.forceDisallow_=!0}static isAvailable(){return We.forceAllow_?!0:!We.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!Ld()&&!Fd()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=$(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=Wo(t),r=ia(s,nf);for(let i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const s={};s[tf]="t",s[ya]=e,s[Ea]=t,this.myDisconnFrame.src=this.urlFn(s),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=$(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Gs{constructor(e,t,s,r){this.onDisconnect=s,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=Ad(),window[Yd+this.uniqueCallbackIdentifier]=e,window[Qd+this.uniqueCallbackIdentifier]=t,this.myIFrame=Gs.createIFrame_();let i="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(i='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+i+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){z("frame writing exception"),a.stack&&z(a.stack),z(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||z("No IE domain setting required")}catch{const s=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+s+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[ya]=this.myID,e[Ea]=this.myPW,e[wa]=this.currentSerial;let t=this.urlFn(e),s="",r=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+ba+s.length<=va;){const o=this.pendingSegs.shift();s=s+"&"+Xd+r+"="+o.seg+"&"+Zd+r+"="+o.ts+"&"+ef+r+"="+o.d,r++}return t=t+s,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,s){this.pendingSegs.push({seg:e,ts:t,d:s}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const s=()=>{this.outstandingRequests.delete(t),this.newRequest_()},r=setTimeout(s,Math.floor(sf)),i=()=>{clearTimeout(r),s()};this.addTag(e,i)}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const s=this.myIFrame.doc.createElement("script");s.type="text/javascript",s.async=!0,s.src=e,s.onload=s.onreadystatechange=function(){const r=s.readyState;(!r||r==="loaded"||r==="complete")&&(s.onload=s.onreadystatechange=null,s.parentNode&&s.parentNode.removeChild(s),t())},s.onerror=()=>{z("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(s)}catch{}},Math.floor(1))}}/**
666
+ */const Zr="start",Yd="close",Qd="pLPCommand",Jd="pRTLPCB",Ea="id",wa="pw",va="ser",Xd="cb",Zd="seg",ef="ts",tf="d",nf="dframe",ba=1870,Ca=30,sf=ba-Ca,rf=25e3,of=3e4;class We{constructor(e,t,s,r,i,o,a){this.connId=e,this.repoInfo=t,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=xt(e),this.stats_=js(t),this.urlFn=c=>(this.appCheckToken&&(c[vs]=this.appCheckToken),ya(t,ma,c))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Gd(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(of)),Dd(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Ks((...i)=>{const[o,a,c,l,h]=i;if(this.incrementIncomingBytes_(i),!!this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,o===Zr)this.id=a,this.password=c;else if(o===Yd)a?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(a,()=>{this.onClosed_()})):this.onClosed_();else throw new Error("Unrecognized command received: "+o)},(...i)=>{const[o,a]=i;this.incrementIncomingBytes_(i),this.myPacketOrderer.handleResponse(o,a)},()=>{this.onClosed_()},this.urlFn);const s={};s[Zr]="t",s[va]=Math.floor(Math.random()*1e8),this.scriptTagHolder.uniqueCallbackIdentifier&&(s[Xd]=this.scriptTagHolder.uniqueCallbackIdentifier),s[ca]=zs,this.transportSessionId&&(s[la]=this.transportSessionId),this.lastSessionId&&(s[fa]=this.lastSessionId),this.applicationId&&(s[pa]=this.applicationId),this.appCheckToken&&(s[vs]=this.appCheckToken),typeof location<"u"&&location.hostname&&da.test(location.hostname)&&(s[ha]=ua);const r=this.urlFn(s);this.log_("Connecting via long-poll to "+r),this.scriptTagHolder.addTag(r,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){We.forceAllow_=!0}static forceDisallow(){We.forceDisallow_=!0}static isAvailable(){return We.forceAllow_?!0:!We.forceDisallow_&&typeof document<"u"&&document.createElement!=null&&!Fd()&&!Md()}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=$(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=qo(t),r=oa(s,sf);for(let i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const s={};s[nf]="t",s[Ea]=e,s[wa]=t,this.myDisconnFrame.src=this.urlFn(s),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=$(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Ks{constructor(e,t,s,r){this.onDisconnect=s,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(Math.random()*1e8),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=Od(),window[Qd+this.uniqueCallbackIdentifier]=e,window[Jd+this.uniqueCallbackIdentifier]=t,this.myIFrame=Ks.createIFrame_();let i="";this.myIFrame.src&&this.myIFrame.src.substr(0,11)==="javascript:"&&(i='<script>document.domain="'+document.domain+'";<\/script>');const o="<html><body>"+i+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(a){z("frame writing exception"),a.stack&&z(a.stack),z(a)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",document.body){document.body.appendChild(e);try{e.contentWindow.document||z("No IE domain setting required")}catch{const s=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+s+"';document.close();})())"}}else throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{this.myIFrame!==null&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e[Ea]=this.myID,e[wa]=this.myPW,e[va]=this.currentSerial;let t=this.urlFn(e),s="",r=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+Ca+s.length<=ba;){const o=this.pendingSegs.shift();s=s+"&"+Zd+r+"="+o.seg+"&"+ef+r+"="+o.ts+"&"+tf+r+"="+o.d,r++}return t=t+s,this.addLongPollTag_(t,this.currentSerial),!0}else return!1}enqueueSegment(e,t,s){this.pendingSegs.push({seg:e,ts:t,d:s}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const s=()=>{this.outstandingRequests.delete(t),this.newRequest_()},r=setTimeout(s,Math.floor(rf)),i=()=>{clearTimeout(r),s()};this.addTag(e,i)}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const s=this.myIFrame.doc.createElement("script");s.type="text/javascript",s.async=!0,s.src=e,s.onload=s.onreadystatechange=function(){const r=s.readyState;(!r||r==="loaded"||r==="complete")&&(s.onload=s.onreadystatechange=null,s.parentNode&&s.parentNode.removeChild(s),t())},s.onerror=()=>{z("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(s)}catch{}},Math.floor(1))}}/**
667
667
  * @license
668
668
  * Copyright 2017 Google LLC
669
669
  *
@@ -678,7 +678,7 @@
678
678
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
679
679
  * See the License for the specific language governing permissions and
680
680
  * limitations under the License.
681
- */const of=16384,af=45e3;let an=null;typeof MozWebSocket<"u"?an=MozWebSocket:typeof WebSocket<"u"&&(an=WebSocket);class ie{constructor(e,t,s,r,i,o,a){this.connId=e,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=xt(this.connId),this.stats_=Ks(t),this.connURL=ie.connectionURL_(t,o,a,r,s),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,s,r,i){const o={};return o[aa]=js,typeof location<"u"&&location.hostname&&ua.test(location.hostname)&&(o[la]=ha),t&&(o[ca]=t),s&&(o[da]=s),r&&(o[vs]=r),i&&(o[fa]=i),ga(e,pa,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Oe.set("previous_websocket_failure",!0);try{let s;su(),this.mySock=new an(this.connURL,[],s)}catch(s){this.log_("Error instantiating WebSocket.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=s=>{this.handleIncomingFrame(s)},this.mySock.onerror=s=>{this.log_("WebSocket error. Closing connection.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_()}}start(){}static forceDisallow(){ie.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,s=navigator.userAgent.match(t);s&&s.length>1&&parseFloat(s[1])<4.4&&(e=!0)}return!e&&an!==null&&!ie.forceDisallow_}static previouslyFailed(){return Oe.isInMemoryStorage||Oe.get("previous_websocket_failure")===!0}markConnectionHealthy(){Oe.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const s=yt(t);this.onMessage(s)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(m(this.frames===null,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(t);else{const s=this.extractFrameCount_(t);s!==null&&this.appendFrame_(s)}}send(e){this.resetKeepAlive();const t=$(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=ia(t,of);s.length>1&&this.sendString_(String(s.length));for(let r=0;r<s.length;r++)this.sendString_(s[r])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(af))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}ie.responsesRequiredToBeHealthy=2;ie.healthyTimeout=3e4;/**
681
+ */const af=16384,cf=45e3;let an=null;typeof MozWebSocket<"u"?an=MozWebSocket:typeof WebSocket<"u"&&(an=WebSocket);class ie{constructor(e,t,s,r,i,o,a){this.connId=e,this.applicationId=s,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=xt(this.connId),this.stats_=js(t),this.connURL=ie.connectionURL_(t,o,a,r,s),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,s,r,i){const o={};return o[ca]=zs,typeof location<"u"&&location.hostname&&da.test(location.hostname)&&(o[ha]=ua),t&&(o[la]=t),s&&(o[fa]=s),r&&(o[vs]=r),i&&(o[pa]=i),ya(e,_a,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Oe.set("previous_websocket_failure",!0);try{let s;ru(),this.mySock=new an(this.connURL,[],s)}catch(s){this.log_("Error instantiating WebSocket.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_();return}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=s=>{this.handleIncomingFrame(s)},this.mySock.onerror=s=>{this.log_("WebSocket error. Closing connection.");const r=s.message||s.data;r&&this.log_(r),this.onClosed_()}}start(){}static forceDisallow(){ie.forceDisallow_=!0}static isAvailable(){let e=!1;if(typeof navigator<"u"&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,s=navigator.userAgent.match(t);s&&s.length>1&&parseFloat(s[1])<4.4&&(e=!0)}return!e&&an!==null&&!ie.forceDisallow_}static previouslyFailed(){return Oe.isInMemoryStorage||Oe.get("previous_websocket_failure")===!0}markConnectionHealthy(){Oe.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const s=yt(t);this.onMessage(s)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(m(this.frames===null,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(this.mySock===null)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),this.frames!==null)this.appendFrame_(t);else{const s=this.extractFrameCount_(t);s!==null&&this.appendFrame_(s)}}send(e){this.resetKeepAlive();const t=$(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const s=oa(t,af);s.length>1&&this.sendString_(String(s.length));for(let r=0;r<s.length;r++)this.sendString_(s[r])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(cf))}sendString_(e){try{this.mySock.send(e)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}ie.responsesRequiredToBeHealthy=2;ie.healthyTimeout=3e4;/**
682
682
  * @license
683
683
  * Copyright 2017 Google LLC
684
684
  *
@@ -708,7 +708,7 @@
708
708
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
709
709
  * See the License for the specific language governing permissions and
710
710
  * limitations under the License.
711
- */const cf=6e4,lf=5e3,hf=10*1024,uf=100*1024,Jn="t",ti="d",df="s",ni="r",ff="e",si="o",ri="a",ii="n",oi="p",pf="h";class _f{constructor(e,t,s,r,i,o,a,c,l,h){this.id=e,this.repoInfo_=t,this.applicationId_=s,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=c,this.onKill_=l,this.lastSessionId=h,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=xt("c:"+this.id+":"),this.transportManager_=new vt(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),s=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,s)},Math.floor(0));const r=e.healthyTimeout||0;r>0&&(this.healthyTimeout_=ft(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>uf?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>hf?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(r)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{this.state_!==2&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if(Jn in e){const t=e[Jn];t===ri?this.upgradeIfSecondaryHealthy_():t===ni?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===si&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=ot("t",e),s=ot("d",e);if(t==="c")this.onSecondaryControl_(s);else if(t==="d")this.pendingDataMessages.push(s);else throw new Error("Unknown protocol layer: "+t)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:oi,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:ri,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:ii,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=ot("t",e),s=ot("d",e);t==="c"?this.onControl_(s):t==="d"&&this.onDataMessage_(s)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=ot(Jn,e);if(ti in e){const s=e[ti];if(t===pf){const r=Object.assign({},s);this.repoInfo_.isUsingEmulator&&(r.h=this.repoInfo_.host),this.onHandshake_(r)}else if(t===ii){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let r=0;r<this.pendingDataMessages.length;++r)this.onDataMessage_(this.pendingDataMessages[r]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===df?this.onConnectionShutdown_(s):t===ni?this.onReset_(s):t===ff?ws("Server Error: "+s):t===si?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):ws("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,s=e.v,r=e.h;this.sessionId=e.s,this.repoInfo_.host=r,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),js!==s&&te("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),s=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,s),ft(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(cf))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):ft(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(lf))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:oi,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===e||this.rx_===e)&&this.close()}onConnectionLost_(e){this.conn_=null,!e&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Oe.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(e)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}/**
711
+ */const lf=6e4,hf=5e3,uf=10*1024,df=100*1024,Jn="t",ei="d",ff="s",ti="r",pf="e",ni="o",si="a",ri="n",ii="p",_f="h";class mf{constructor(e,t,s,r,i,o,a,c,l,h){this.id=e,this.repoInfo_=t,this.applicationId_=s,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=c,this.onKill_=l,this.lastSessionId=h,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=xt("c:"+this.id+":"),this.transportManager_=new vt(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),s=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,s)},Math.floor(0));const r=e.healthyTimeout||0;r>0&&(this.healthyTimeout_=ft(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>df?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>uf?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(r)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{this.state_!==2&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if(Jn in e){const t=e[Jn];t===si?this.upgradeIfSecondaryHealthy_():t===ti?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),(this.tx_===this.secondaryConn_||this.rx_===this.secondaryConn_)&&this.close()):t===ni&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=ot("t",e),s=ot("d",e);if(t==="c")this.onSecondaryControl_(s);else if(t==="d")this.pendingDataMessages.push(s);else throw new Error("Unknown protocol layer: "+t)}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:ii,d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:si,d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:ri,d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=ot("t",e),s=ot("d",e);t==="c"?this.onControl_(s):t==="d"&&this.onDataMessage_(s)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=ot(Jn,e);if(ei in e){const s=e[ei];if(t===_f){const r=Object.assign({},s);this.repoInfo_.isUsingEmulator&&(r.h=this.repoInfo_.host),this.onHandshake_(r)}else if(t===ri){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let r=0;r<this.pendingDataMessages.length;++r)this.onDataMessage_(this.pendingDataMessages[r]);this.pendingDataMessages=[],this.tryCleanupConnection()}else t===ff?this.onConnectionShutdown_(s):t===ti?this.onReset_(s):t===pf?ws("Server Error: "+s):t===ni?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):ws("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,s=e.v,r=e.h;this.sessionId=e.s,this.repoInfo_.host=r,this.state_===0&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),zs!==s&&te("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),s=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,s),ft(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(lf))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,this.state_===1?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),this.primaryResponsesRequired_===0?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):ft(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(hf))}sendPingOnPrimaryIfNecessary_(){!this.isHealthy_&&this.state_===1&&(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:ii,d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,(this.tx_===e||this.rx_===e)&&this.close()}onConnectionLost_(e){this.conn_=null,!e&&this.state_===0?(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Oe.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)):this.state_===1&&this.log_("Realtime connection lost."),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(this.state_!==1)throw"Connection is not connected";this.tx_.send(e)}close(){this.state_!==2&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}/**
712
712
  * @license
713
713
  * Copyright 2017 Google LLC
714
714
  *
@@ -723,7 +723,7 @@
723
723
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
724
724
  * See the License for the specific language governing permissions and
725
725
  * limitations under the License.
726
- */class Ca{put(e,t,s,r){}merge(e,t,s,r){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,s){}onDisconnectMerge(e,t,s){}onDisconnectCancel(e,t){}reportStats(e){}}/**
726
+ */class Sa{put(e,t,s,r){}merge(e,t,s,r){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,s){}onDisconnectMerge(e,t,s){}onDisconnectCancel(e,t){}reportStats(e){}}/**
727
727
  * @license
728
728
  * Copyright 2017 Google LLC
729
729
  *
@@ -738,7 +738,7 @@
738
738
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
739
739
  * See the License for the specific language governing permissions and
740
740
  * limitations under the License.
741
- */class Sa{constructor(e){this.allowedEvents_=e,this.listeners_={},m(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const s=[...this.listeners_[e]];for(let r=0;r<s.length;r++)s[r].callback.apply(s[r].context,t)}}on(e,t,s){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:s});const r=this.getInitialEvent(e);r&&t.apply(s,r)}off(e,t,s){this.validateEventType_(e);const r=this.listeners_[e]||[];for(let i=0;i<r.length;i++)if(r[i].callback===t&&(!s||s===r[i].context)){r.splice(i,1);return}}validateEventType_(e){m(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}/**
741
+ */class Ta{constructor(e){this.allowedEvents_=e,this.listeners_={},m(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const s=[...this.listeners_[e]];for(let r=0;r<s.length;r++)s[r].callback.apply(s[r].context,t)}}on(e,t,s){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:s});const r=this.getInitialEvent(e);r&&t.apply(s,r)}off(e,t,s){this.validateEventType_(e);const r=this.listeners_[e]||[];for(let i=0;i<r.length;i++)if(r[i].callback===t&&(!s||s===r[i].context)){r.splice(i,1);return}}validateEventType_(e){m(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}/**
742
742
  * @license
743
743
  * Copyright 2017 Google LLC
744
744
  *
@@ -753,7 +753,7 @@
753
753
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
754
754
  * See the License for the specific language governing permissions and
755
755
  * limitations under the License.
756
- */class cn extends Sa{static getInstance(){return new cn}constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!zo()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return m(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}/**
756
+ */class cn extends Ta{static getInstance(){return new cn}constructor(){super(["online"]),this.online_=!0,typeof window<"u"&&typeof window.addEventListener<"u"&&!jo()&&(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return m(e==="online","Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}/**
757
757
  * @license
758
758
  * Copyright 2017 Google LLC
759
759
  *
@@ -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 ai=32,ci=768;class x{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 x("")}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 x(n.pieces_,e)}function Ta(n){return n.pieceNum_<n.pieces_.length?n.pieces_[n.pieces_.length-1]:null}function mf(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 Ra(n,e=0){return n.pieces_.slice(n.pieceNum_+e)}function Ia(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 x(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 x)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 x(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 Ys(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 gf{constructor(e,t){this.errorPrefix_=t,this.parts_=Ra(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]);Na(this)}}function yf(n,e){n.parts_.length>0&&(n.byteLength_+=1),n.parts_.push(e),n.byteLength_+=kn(e),Na(n)}function Ef(n){const e=n.parts_.pop();n.byteLength_-=kn(e),n.parts_.length>0&&(n.byteLength_-=1)}function Na(n){if(n.byteLength_>ci)throw new Error(n.errorPrefix_+"has a key path longer than "+ci+" bytes ("+n.byteLength_+").");if(n.parts_.length>ai)throw new Error(n.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+ai+") 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_+=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(".")+"'"}/**
772
772
  * @license
773
773
  * Copyright 2017 Google LLC
774
774
  *
@@ -783,7 +783,7 @@
783
783
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
784
784
  * See the License for the specific language governing permissions and
785
785
  * limitations under the License.
786
- */class Qs extends Sa{static getInstance(){return new Qs}constructor(){super(["visible"]);let e,t;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(t="visibilitychange",e="hidden"):typeof document.mozHidden<"u"?(t="mozvisibilitychange",e="mozHidden"):typeof document.msHidden<"u"?(t="msvisibilitychange",e="msHidden"):typeof document.webkitHidden<"u"&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const s=!document[e];s!==this.visible_&&(this.visible_=s,this.trigger("visible",s))},!1)}getInitialEvent(e){return m(e==="visible","Unknown event type: "+e),[this.visible_]}}/**
786
+ */class Ys extends Ta{static getInstance(){return new Ys}constructor(){super(["visible"]);let e,t;typeof document<"u"&&typeof document.addEventListener<"u"&&(typeof document.hidden<"u"?(t="visibilitychange",e="hidden"):typeof document.mozHidden<"u"?(t="mozvisibilitychange",e="mozHidden"):typeof document.msHidden<"u"?(t="msvisibilitychange",e="msHidden"):typeof document.webkitHidden<"u"&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const s=!document[e];s!==this.visible_&&(this.visible_=s,this.trigger("visible",s))},!1)}getInitialEvent(e){return m(e==="visible","Unknown event type: "+e),[this.visible_]}}/**
787
787
  * @license
788
788
  * Copyright 2017 Google LLC
789
789
  *
@@ -798,10 +798,10 @@
798
798
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
799
799
  * See the License for the specific language governing permissions and
800
800
  * limitations under the License.
801
- */const at=1e3,wf=60*5*1e3,li=30*1e3,vf=1.3,bf=3e4,Cf="server_kill",hi=3;class fe extends Ca{constructor(e,t,s,r,i,o,a,c){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=s,this.onConnectStatus_=r,this.onServerInfoUpdate_=i,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=c,this.id=fe.nextPersistentConnectionId_++,this.log_=xt("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=at,this.maxReconnectDelay_=wf,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,c)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Qs.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&cn.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,s){const r=++this.requestNumber_,i={r,a:e,b:t};this.log_($(i)),m(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),s&&(this.requestCBHash_[r]=s)}get(e){this.initConnection_();const t=new Vs,r={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const a=o.d;o.s==="ok"?t.resolve(a):t.reject(a)}};this.outstandingGets_.push(r),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),t.promise}listen(e,t,s,r){this.initConnection_();const i=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+i),this.listens.has(o)||this.listens.set(o,new Map),m(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),m(!this.listens.get(o).has(i),"listen() called twice for same path/queryId.");const a={onComplete:r,hashFn:t,query:e,tag:s};this.listens.get(o).set(i,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,s=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(s)})}sendListen_(e){const t=e.query,s=t._path.toString(),r=t._queryIdentifier;this.log_("Listen on "+s+" for "+r);const i={p:s},o="q";e.tag&&(i.q=t._queryObject,i.t=e.tag),i.h=e.hashFn(),this.sendRequest(o,i,a=>{const c=a.d,l=a.s;fe.warnOnListenWarnings_(c,t),(this.listens.get(s)&&this.listens.get(s).get(r))===e&&(this.log_("listen response",a),l!=="ok"&&this.removeListen_(s,r),e.onComplete&&e.onComplete(l,c))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&me(e,"w")){const s=Ge(e,"w");if(Array.isArray(s)&&~s.indexOf("no_index")){const r='".indexOn": "'+t._queryParams.getIndex().toString()+'"',i=t._path.toString();te(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${r} at ${i} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||hu(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=li)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=lu(e)?"auth":"gauth",s={cred:e};this.authOverride_===null?s.noauth=!0:typeof this.authOverride_=="object"&&(s.authvar=this.authOverride_),this.sendRequest(t,s,r=>{const i=r.s,o=r.d||"error";this.authToken_===e&&(i==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(i,o))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,s=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,s)})}unlisten(e,t){const s=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+s+" "+r),m(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(s,r)&&this.connected_&&this.sendUnlisten_(s,r,e._queryObject,t)}sendUnlisten_(e,t,s,r){this.log_("Unlisten on "+e+" for "+t);const i={p:e},o="n";r&&(i.q=s,i.t=r),this.sendRequest(o,i)}onDisconnectPut(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:s})}onDisconnectMerge(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:s})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,s,r){const i={p:t,d:s};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,o=>{r&&setTimeout(()=>{r(o.s,o.d)},Math.floor(0))})}put(e,t,s,r){this.putInternal("p",e,t,s,r)}merge(e,t,s,r){this.putInternal("m",e,t,s,r)}putInternal(e,t,s,r,i){this.initConnection_();const o={p:t,d:s};i!==void 0&&(o.h=i),this.outstandingPuts_.push({action:e,request:o,onComplete:r}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,s=this.outstandingPuts_[e].request,r=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,s,i=>{this.log_(t+" response",i),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),r&&r(i.s,i.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,s=>{if(s.s!=="ok"){const i=s.d;this.log_("reportStats","Error sending stats: "+i)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+$(e));const t=e.r,s=this.requestCBHash_[t];s&&(delete this.requestCBHash_[t],s(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),e==="d"?this.onDataUpdate_(t.p,t.d,!1,t.t):e==="m"?this.onDataUpdate_(t.p,t.d,!0,t.t):e==="c"?this.onListenRevoked_(t.p,t.q):e==="ac"?this.onAuthRevoked_(t.s,t.d):e==="apc"?this.onAppCheckRevoked_(t.s,t.d):e==="sd"?this.onSecurityDebugPacket_(t):ws("Unrecognized action received from server: "+$(e)+`
802
- Are you using the latest client?`)}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){m(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=at,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=at,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>bf&&(this.reconnectDelay_=at),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());const e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_);let t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*vf)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),s=this.onRealtimeDisconnect_.bind(this),r=this.id+":"+fe.nextConnectionId_++,i=this.lastSessionId;let o=!1,a=null;const c=function(){a?a.close():(o=!0,s())},l=function(u){m(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(u)};this.realtime_={close:c,sendRequest:l};const h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[u,d]=await Promise.all([this.authTokenProvider_.getToken(h),this.appCheckTokenProvider_.getToken(h)]);o?z("getToken() completed but was canceled"):(z("getToken() completed. Creating connection."),this.authToken_=u&&u.accessToken,this.appCheckToken_=d&&d.token,a=new _f(r,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,s,_=>{te(_+" ("+this.repoInfo_.toString()+")"),this.interrupt(Cf)},i))}catch(u){this.log_("Failed to get token: "+u),o||(this.repoInfo_.nodeAdmin&&te(u),c())}}}interrupt(e){z("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){z("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Hr(this.interruptReasons_)&&(this.reconnectDelay_=at,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let s;t?s=t.map(i=>zs(i)).join("$"):s="default";const r=this.removeListen_(e,s);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,t){const s=new x(e).toString();let r;if(this.listens.has(s)){const i=this.listens.get(s);r=i.get(t),i.delete(t),i.size===0&&this.listens.delete(s)}else r=void 0;return r}onAuthRevoked_(e,t){z("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=hi&&(this.reconnectDelay_=li,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){z("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=hi&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
801
+ */const at=1e3,vf=60*5*1e3,ci=30*1e3,bf=1.3,Cf=3e4,Sf="server_kill",li=3;class fe extends Sa{constructor(e,t,s,r,i,o,a,c){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=s,this.onConnectStatus_=r,this.onServerInfoUpdate_=i,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=c,this.id=fe.nextPersistentConnectionId_++,this.log_=xt("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=at,this.maxReconnectDelay_=vf,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,c)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Ys.getInstance().on("visible",this.onVisible_,this),e.host.indexOf("fblocal")===-1&&cn.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,s){const r=++this.requestNumber_,i={r,a:e,b:t};this.log_($(i)),m(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),s&&(this.requestCBHash_[r]=s)}get(e){this.initConnection_();const t=new qs,r={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:o=>{const a=o.d;o.s==="ok"?t.resolve(a):t.reject(a)}};this.outstandingGets_.push(r),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),t.promise}listen(e,t,s,r){this.initConnection_();const i=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+i),this.listens.has(o)||this.listens.set(o,new Map),m(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),m(!this.listens.get(o).has(i),"listen() called twice for same path/queryId.");const a={onComplete:r,hashFn:t,query:e,tag:s};this.listens.get(o).set(i,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,s=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,this.outstandingGetCount_===0&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(s)})}sendListen_(e){const t=e.query,s=t._path.toString(),r=t._queryIdentifier;this.log_("Listen on "+s+" for "+r);const i={p:s},o="q";e.tag&&(i.q=t._queryObject,i.t=e.tag),i.h=e.hashFn(),this.sendRequest(o,i,a=>{const c=a.d,l=a.s;fe.warnOnListenWarnings_(c,t),(this.listens.get(s)&&this.listens.get(s).get(r))===e&&(this.log_("listen response",a),l!=="ok"&&this.removeListen_(s,r),e.onComplete&&e.onComplete(l,c))})}static warnOnListenWarnings_(e,t){if(e&&typeof e=="object"&&me(e,"w")){const s=Ge(e,"w");if(Array.isArray(s)&&~s.indexOf("no_index")){const r='".indexOn": "'+t._queryParams.getIndex().toString()+'"',i=t._path.toString();te(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${r} at ${i} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&e.length===40||uu(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=ci)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=hu(e)?"auth":"gauth",s={cred:e};this.authOverride_===null?s.noauth=!0:typeof this.authOverride_=="object"&&(s.authvar=this.authOverride_),this.sendRequest(t,s,r=>{const i=r.s,o=r.d||"error";this.authToken_===e&&(i==="ok"?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(i,o))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,s=e.d||"error";t==="ok"?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,s)})}unlisten(e,t){const s=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+s+" "+r),m(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(s,r)&&this.connected_&&this.sendUnlisten_(s,r,e._queryObject,t)}sendUnlisten_(e,t,s,r){this.log_("Unlisten on "+e+" for "+t);const i={p:e},o="n";r&&(i.q=s,i.t=r),this.sendRequest(o,i)}onDisconnectPut(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:s})}onDisconnectMerge(e,t,s){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,s):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:s})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,s,r){const i={p:t,d:s};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,o=>{r&&setTimeout(()=>{r(o.s,o.d)},Math.floor(0))})}put(e,t,s,r){this.putInternal("p",e,t,s,r)}merge(e,t,s,r){this.putInternal("m",e,t,s,r)}putInternal(e,t,s,r,i){this.initConnection_();const o={p:t,d:s};i!==void 0&&(o.h=i),this.outstandingPuts_.push({action:e,request:o,onComplete:r}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,s=this.outstandingPuts_[e].request,r=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,s,i=>{this.log_(t+" response",i),delete this.outstandingPuts_[e],this.outstandingPutCount_--,this.outstandingPutCount_===0&&(this.outstandingPuts_=[]),r&&r(i.s,i.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,s=>{if(s.s!=="ok"){const i=s.d;this.log_("reportStats","Error sending stats: "+i)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+$(e));const t=e.r,s=this.requestCBHash_[t];s&&(delete this.requestCBHash_[t],s(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),e==="d"?this.onDataUpdate_(t.p,t.d,!1,t.t):e==="m"?this.onDataUpdate_(t.p,t.d,!0,t.t):e==="c"?this.onListenRevoked_(t.p,t.q):e==="ac"?this.onAuthRevoked_(t.s,t.d):e==="apc"?this.onAppCheckRevoked_(t.s,t.d):e==="sd"?this.onSecurityDebugPacket_(t):ws("Unrecognized action received from server: "+$(e)+`
802
+ Are you using the latest client?`)}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=new Date().getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){m(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=at,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=at,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(new Date().getTime()-this.lastConnectionEstablishedTime_>Cf&&(this.reconnectDelay_=at),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=new Date().getTime());const e=Math.max(0,new Date().getTime()-this.lastConnectionAttemptTime_);let t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,this.reconnectDelay_*bf)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=new Date().getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),s=this.onRealtimeDisconnect_.bind(this),r=this.id+":"+fe.nextConnectionId_++,i=this.lastSessionId;let o=!1,a=null;const c=function(){a?a.close():(o=!0,s())},l=function(u){m(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(u)};this.realtime_={close:c,sendRequest:l};const h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[u,d]=await Promise.all([this.authTokenProvider_.getToken(h),this.appCheckTokenProvider_.getToken(h)]);o?z("getToken() completed but was canceled"):(z("getToken() completed. Creating connection."),this.authToken_=u&&u.accessToken,this.appCheckToken_=d&&d.token,a=new mf(r,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,s,_=>{te(_+" ("+this.repoInfo_.toString()+")"),this.interrupt(Sf)},i))}catch(u){this.log_("Failed to get token: "+u),o||(this.repoInfo_.nodeAdmin&&te(u),c())}}}interrupt(e){z("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){z("Resuming connection for reason: "+e),delete this.interruptReasons_[e],Ur(this.interruptReasons_)&&(this.reconnectDelay_=at,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-new Date().getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}this.outstandingPutCount_===0&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let s;t?s=t.map(i=>$s(i)).join("$"):s="default";const r=this.removeListen_(e,s);r&&r.onComplete&&r.onComplete("permission_denied")}removeListen_(e,t){const s=new D(e).toString();let r;if(this.listens.has(s)){const i=this.listens.get(s);r=i.get(t),i.delete(t),i.size===0&&this.listens.delete(s)}else r=void 0;return r}onAuthRevoked_(e,t){z("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),(e==="invalid_token"||e==="permission_denied")&&(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=li&&(this.reconnectDelay_=ci,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){z("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,(e==="invalid_token"||e==="permission_denied")&&(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=li&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace(`
803
803
  `,`
804
- FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";e["sdk."+t+"."+ta.replace(/\./g,"-")]=1,zo()?e["framework.cordova"]=1:nu()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=cn.getInstance().currentlyOnline();return Hr(this.interruptReasons_)&&e}}fe.nextPersistentConnectionId_=0;fe.nextConnectionId_=0;/**
804
+ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";e["sdk."+t+"."+na.replace(/\./g,"-")]=1,jo()?e["framework.cordova"]=1:su()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=cn.getInstance().currentlyOnline();return Ur(this.interruptReasons_)&&e}}fe.nextPersistentConnectionId_=0;fe.nextConnectionId_=0;/**
805
805
  * @license
806
806
  * Copyright 2017 Google LLC
807
807
  *
@@ -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 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;/**
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;/**
850
850
  * @license
851
851
  * Copyright 2017 Google LLC
852
852
  *
@@ -861,7 +861,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
861
861
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
862
862
  * See the License for the specific language governing permissions and
863
863
  * limitations under the License.
864
- */class Wt{constructor(e,t,s,r,i=null){this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];let o=1;for(;!e.isEmpty();)if(e=e,o=t?s(e.key,t):1,r&&(o*=-1),o<0)this.isReverse_?e=e.left:e=e.right;else if(o===0){this.nodeStack_.push(e);break}else this.nodeStack_.push(e),this.isReverse_?e=e.right:e=e.left}getNext(){if(this.nodeStack_.length===0)return null;let e=this.nodeStack_.pop(),t;if(this.resultGenerator_?t=this.resultGenerator_(e.key,e.value):t={key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class V{constructor(e,t,s,r,i){this.key=e,this.value=t,this.color=s??V.RED,this.left=r??J.EMPTY_NODE,this.right=i??J.EMPTY_NODE}copy(e,t,s,r,i){return new V(e??this.key,t??this.value,s??this.color,r??this.left,i??this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,s){let r=this;const i=s(e,r.key);return i<0?r=r.copy(null,null,null,r.left.insert(e,t,s),null):i===0?r=r.copy(null,t,null,null,null):r=r.copy(null,null,null,null,r.right.insert(e,t,s)),r.fixUp_()}removeMin_(){if(this.left.isEmpty())return J.EMPTY_NODE;let e=this;return!e.left.isRed_()&&!e.left.left.isRed_()&&(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let s,r;if(s=this,t(e,s.key)<0)!s.left.isEmpty()&&!s.left.isRed_()&&!s.left.left.isRed_()&&(s=s.moveRedLeft_()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed_()&&(s=s.rotateRight_()),!s.right.isEmpty()&&!s.right.isRed_()&&!s.right.left.isRed_()&&(s=s.moveRedRight_()),t(e,s.key)===0){if(s.right.isEmpty())return J.EMPTY_NODE;r=s.right.min_(),s=s.copy(r.key,r.value,null,null,s.right.removeMin_())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,V.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,V.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}V.RED=!0;V.BLACK=!1;class Sf{copy(e,t,s,r,i){return this}insert(e,t,s){return new V(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class J{constructor(e,t=J.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new J(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,V.BLACK,null,null))}remove(e){return new J(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,V.BLACK,null,null))}get(e){let t,s=this.root_;for(;!s.isEmpty();){if(t=this.comparator_(e,s.key),t===0)return s.value;t<0?s=s.left:t>0&&(s=s.right)}return null}getPredecessorKey(e){let t,s=this.root_,r=null;for(;!s.isEmpty();)if(t=this.comparator_(e,s.key),t===0){if(s.left.isEmpty())return r?r.key:null;for(s=s.left;!s.right.isEmpty();)s=s.right;return s.key}else t<0?s=s.left:t>0&&(r=s,s=s.right);throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new Wt(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Wt(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Wt(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Wt(this.root_,null,this.comparator_,!0,e)}}J.EMPTY_NODE=new Sf;/**
864
+ */class Wt{constructor(e,t,s,r,i=null){this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];let o=1;for(;!e.isEmpty();)if(e=e,o=t?s(e.key,t):1,r&&(o*=-1),o<0)this.isReverse_?e=e.left:e=e.right;else if(o===0){this.nodeStack_.push(e);break}else this.nodeStack_.push(e),this.isReverse_?e=e.right:e=e.left}getNext(){if(this.nodeStack_.length===0)return null;let e=this.nodeStack_.pop(),t;if(this.resultGenerator_?t=this.resultGenerator_(e.key,e.value):t={key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t}hasNext(){return this.nodeStack_.length>0}peek(){if(this.nodeStack_.length===0)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class V{constructor(e,t,s,r,i){this.key=e,this.value=t,this.color=s??V.RED,this.left=r??J.EMPTY_NODE,this.right=i??J.EMPTY_NODE}copy(e,t,s,r,i){return new V(e??this.key,t??this.value,s??this.color,r??this.left,i??this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,s){let r=this;const i=s(e,r.key);return i<0?r=r.copy(null,null,null,r.left.insert(e,t,s),null):i===0?r=r.copy(null,t,null,null,null):r=r.copy(null,null,null,null,r.right.insert(e,t,s)),r.fixUp_()}removeMin_(){if(this.left.isEmpty())return J.EMPTY_NODE;let e=this;return!e.left.isRed_()&&!e.left.left.isRed_()&&(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let s,r;if(s=this,t(e,s.key)<0)!s.left.isEmpty()&&!s.left.isRed_()&&!s.left.left.isRed_()&&(s=s.moveRedLeft_()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed_()&&(s=s.rotateRight_()),!s.right.isEmpty()&&!s.right.isRed_()&&!s.right.left.isRed_()&&(s=s.moveRedRight_()),t(e,s.key)===0){if(s.right.isEmpty())return J.EMPTY_NODE;r=s.right.min_(),s=s.copy(r.key,r.value,null,null,s.right.removeMin_())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&&!e.left.isRed_()&&(e=e.rotateLeft_()),e.left.isRed_()&&e.left.left.isRed_()&&(e=e.rotateRight_()),e.left.isRed_()&&e.right.isRed_()&&(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,V.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,V.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}V.RED=!0;V.BLACK=!1;class Tf{copy(e,t,s,r,i){return this}insert(e,t,s){return new V(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}}class J{constructor(e,t=J.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new J(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,V.BLACK,null,null))}remove(e){return new J(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,V.BLACK,null,null))}get(e){let t,s=this.root_;for(;!s.isEmpty();){if(t=this.comparator_(e,s.key),t===0)return s.value;t<0?s=s.left:t>0&&(s=s.right)}return null}getPredecessorKey(e){let t,s=this.root_,r=null;for(;!s.isEmpty();)if(t=this.comparator_(e,s.key),t===0){if(s.left.isEmpty())return r?r.key:null;for(s=s.left;!s.right.isEmpty();)s=s.right;return s.key}else t<0?s=s.left:t>0&&(r=s,s=s.right);throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new Wt(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new Wt(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new Wt(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new Wt(this.root_,null,this.comparator_,!0,e)}}J.EMPTY_NODE=new Tf;/**
865
865
  * @license
866
866
  * Copyright 2017 Google LLC
867
867
  *
@@ -876,7 +876,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
876
876
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
877
877
  * See the License for the specific language governing permissions and
878
878
  * limitations under the License.
879
- */function Tf(n,e){return nt(n.name,e.name)}function Js(n,e){return nt(n,e)}/**
879
+ */function Rf(n,e){return nt(n.name,e.name)}function Qs(n,e){return nt(n,e)}/**
880
880
  * @license
881
881
  * Copyright 2017 Google LLC
882
882
  *
@@ -891,7 +891,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
891
891
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
892
892
  * See the License for the specific language governing permissions and
893
893
  * limitations under the License.
894
- */let bs;function Rf(n){bs=n}const Aa=function(n){return typeof n=="number"?"number:"+oa(n):"string:"+n},Oa=function(n){if(n.isLeafNode()){const e=n.val();m(typeof e=="string"||typeof e=="number"||typeof e=="object"&&me(e,".sv"),"Priority must be a string or number.")}else m(n===bs||n.isEmpty(),"priority of unexpected type.");m(n===bs||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};/**
894
+ */let bs;function If(n){bs=n}const Oa=function(n){return typeof n=="number"?"number:"+aa(n):"string:"+n},xa=function(n){if(n.isLeafNode()){const e=n.val();m(typeof e=="string"||typeof e=="number"||typeof e=="object"&&me(e,".sv"),"Priority must be a string or number.")}else m(n===bs||n.isEmpty(),"priority of unexpected type.");m(n===bs||n.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};/**
895
895
  * @license
896
896
  * Copyright 2017 Google LLC
897
897
  *
@@ -906,7 +906,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
906
906
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
907
907
  * See the License for the specific language governing permissions and
908
908
  * limitations under the License.
909
- */let ui;class q{static set __childrenNodeConstructor(e){ui=e}static get __childrenNodeConstructor(){return ui}constructor(e,t=q.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,m(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),Oa(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new q(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:q.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return S(e)?this:C(e)===".priority"?this.priorityNode_:q.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return e===".priority"?this.updatePriority(t):t.isEmpty()&&e!==".priority"?this:q.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const s=C(e);return s===null?t:t.isEmpty()&&s!==".priority"?this:(m(s!==".priority"||Ce(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(s,q.__childrenNodeConstructor.EMPTY_NODE.updateChild(F(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+Aa(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=oa(this.value_):e+=this.value_,this.lazyHash_=sa(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===q.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof q.__childrenNodeConstructor?-1:(m(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,s=typeof this.value_,r=q.VALUE_TYPE_ORDER.indexOf(t),i=q.VALUE_TYPE_ORDER.indexOf(s);return m(r>=0,"Unknown leaf type: "+t),m(i>=0,"Unknown leaf type: "+s),r===i?s==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}else return!1}}q.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
909
+ */let hi;class q{static set __childrenNodeConstructor(e){hi=e}static get __childrenNodeConstructor(){return hi}constructor(e,t=q.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,m(this.value_!==void 0&&this.value_!==null,"LeafNode shouldn't be created with null/undefined value."),xa(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new q(this.value_,e)}getImmediateChild(e){return e===".priority"?this.priorityNode_:q.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return S(e)?this:C(e)===".priority"?this.priorityNode_:q.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return e===".priority"?this.updatePriority(t):t.isEmpty()&&e!==".priority"?this:q.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const s=C(e);return s===null?t:t.isEmpty()&&s!==".priority"?this:(m(s!==".priority"||Ce(e)===1,".priority must be the last token in a path"),this.updateImmediateChild(s,q.__childrenNodeConstructor.EMPTY_NODE.updateChild(F(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(this.lazyHash_===null){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+Oa(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",t==="number"?e+=aa(this.value_):e+=this.value_,this.lazyHash_=ra(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===q.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof q.__childrenNodeConstructor?-1:(m(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,s=typeof this.value_,r=q.VALUE_TYPE_ORDER.indexOf(t),i=q.VALUE_TYPE_ORDER.indexOf(s);return m(r>=0,"Unknown leaf type: "+t),m(i>=0,"Unknown leaf type: "+s),r===i?s==="object"?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}else return!1}}q.VALUE_TYPE_ORDER=["object","boolean","number","string"];/**
910
910
  * @license
911
911
  * Copyright 2017 Google LLC
912
912
  *
@@ -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 xa,Pa;function If(n){xa=n}function Nf(n){Pa=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]",Pa))}makePost(e,t){const s=xa(e);return new b(t,new q("[PRIORITY-POST]",s))}toString(){return".priority"}}const U=new kf;/**
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;/**
925
925
  * @license
926
926
  * Copyright 2017 Google LLC
927
927
  *
@@ -936,7 +936,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
936
936
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
937
937
  * See the License for the specific language governing permissions and
938
938
  * limitations under the License.
939
- */const Af=Math.log(2);class Of{constructor(e){const t=i=>parseInt(Math.log(i)/Af,10),s=i=>parseInt(Array(i+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const r=s(this.count);this.bits_=e+1&r}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const ln=function(n,e,t,s){n.sort(e);const r=function(c,l){const h=l-c;let u,d;if(h===0)return null;if(h===1)return u=n[c],d=t?t(u):u,new V(d,u.node,V.BLACK,null,null);{const _=parseInt(h/2,10)+c,p=r(c,_),y=r(_+1,l);return u=n[_],d=t?t(u):u,new V(d,u.node,V.BLACK,p,y)}},i=function(c){let l=null,h=null,u=n.length;const d=function(p,y){const g=u-p,I=u;u-=p;const O=r(g+1,I),B=n[g],se=t?t(B):B;_(new V(se,B.node,y,null,O))},_=function(p){l?(l.left=p,l=p):(h=p,l=p)};for(let p=0;p<c.count;++p){const y=c.nextBitIsOne(),g=Math.pow(2,c.count-(p+1));y?d(g,V.BLACK):(d(g,V.BLACK),d(g,V.RED))}return h},o=new Of(n.length),a=i(o);return new J(s||e,a)};/**
939
+ */const Of=Math.log(2);class xf{constructor(e){const t=i=>parseInt(Math.log(i)/Of,10),s=i=>parseInt(Array(i+1).join("1"),2);this.count=t(e+1),this.current_=this.count-1;const r=s(this.count);this.bits_=e+1&r}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const ln=function(n,e,t,s){n.sort(e);const r=function(c,l){const h=l-c;let u,d;if(h===0)return null;if(h===1)return u=n[c],d=t?t(u):u,new V(d,u.node,V.BLACK,null,null);{const _=parseInt(h/2,10)+c,p=r(c,_),y=r(_+1,l);return u=n[_],d=t?t(u):u,new V(d,u.node,V.BLACK,p,y)}},i=function(c){let l=null,h=null,u=n.length;const d=function(p,y){const g=u-p,I=u;u-=p;const O=r(g+1,I),B=n[g],se=t?t(B):B;_(new V(se,B.node,y,null,O))},_=function(p){l?(l.left=p,l=p):(h=p,l=p)};for(let p=0;p<c.count;++p){const y=c.nextBitIsOne(),g=Math.pow(2,c.count-(p+1));y?d(g,V.BLACK):(d(g,V.BLACK),d(g,V.RED))}return h},o=new xf(n.length),a=i(o);return new J(s||e,a)};/**
940
940
  * @license
941
941
  * Copyright 2017 Google LLC
942
942
  *
@@ -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(Js),null,de.Default))}constructor(e,t,s){this.children_=e,this.priorityNode_=t,this.indexMap_=s,this.lazyHash_=null,this.priorityNode_&&Oa(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:"+Aa(this.getPriority().val())+":"),this.forEachChild(U,(t,s)=>{const r=s.hash();r!==""&&(e+=":"+t+":"+r)}),this.lazyHash_=e===""?"":sa(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 xf extends E{constructor(){super(new J(Js),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 xf;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;Rf(Dt);Nf(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)}});Aa.__EMPTY_NODE=E.EMPTY_NODE;q.__childrenNodeConstructor=E;If(Dt);kf(Dt);/**
970
970
  * @license
971
971
  * Copyright 2017 Google LLC
972
972
  *
@@ -981,7 +981,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
981
981
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
982
982
  * See the License for the specific language governing permissions and
983
983
  * limitations under the License.
984
- */const Pf=!0;function j(n,e=null){if(n===null)return E.EMPTY_NODE;if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),m(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof n=="object"&&".value"in n&&n[".value"]!==null&&(n=n[".value"]),typeof n!="object"||".sv"in n){const t=n;return new q(t,j(e))}if(!(n instanceof Array)&&Pf){const t=[];let s=!1;if(Z(n,(o,a)=>{if(o.substring(0,1)!=="."){const c=j(a);c.isEmpty()||(s=s||!c.getPriority().isEmpty(),t.push(new b(o,c)))}}),t.length===0)return E.EMPTY_NODE;const i=ln(t,Tf,o=>o.name,Js);if(s){const o=ln(t,U.getCompare());return new E(i,j(e),new de({".priority":o},{".priority":U}))}else return new E(i,j(e),de.Default)}else{let t=E.EMPTY_NODE;return Z(n,(s,r)=>{if(me(n,s)&&s.substring(0,1)!=="."){const i=j(r);(i.isLeafNode()||!i.isEmpty())&&(t=t.updateImmediateChild(s,i))}}),t.updatePriority(j(e))}}If(j);/**
984
+ */const Df=!0;function j(n,e=null){if(n===null)return E.EMPTY_NODE;if(typeof n=="object"&&".priority"in n&&(e=n[".priority"]),m(e===null||typeof e=="string"||typeof e=="number"||typeof e=="object"&&".sv"in e,"Invalid priority type found: "+typeof e),typeof n=="object"&&".value"in n&&n[".value"]!==null&&(n=n[".value"]),typeof n!="object"||".sv"in n){const t=n;return new q(t,j(e))}if(!(n instanceof Array)&&Df){const t=[];let s=!1;if(Z(n,(o,a)=>{if(o.substring(0,1)!=="."){const c=j(a);c.isEmpty()||(s=s||!c.getPriority().isEmpty(),t.push(new b(o,c)))}}),t.length===0)return E.EMPTY_NODE;const i=ln(t,Rf,o=>o.name,Qs);if(s){const o=ln(t,U.getCompare());return new E(i,j(e),new de({".priority":o},{".priority":U}))}else return new E(i,j(e),de.Default)}else{let t=E.EMPTY_NODE;return Z(n,(s,r)=>{if(me(n,s)&&s.substring(0,1)!=="."){const i=j(r);(i.isLeafNode()||!i.isEmpty())&&(t=t.updateImmediateChild(s,i))}}),t.updatePriority(j(e))}}Nf(j);/**
985
985
  * @license
986
986
  * Copyright 2017 Google LLC
987
987
  *
@@ -996,7 +996,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
996
996
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
997
997
  * See the License for the specific language governing permissions and
998
998
  * limitations under the License.
999
- */class Df extends On{constructor(e){super(),this.indexPath_=e,m(!S(e)&&C(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const s=this.extractChild(e.node),r=this.extractChild(t.node),i=s.compareTo(r);return i===0?nt(e.name,t.name):i}makePost(e,t){const s=j(e),r=E.EMPTY_NODE.updateChild(this.indexPath_,s);return new b(t,r)}maxPost(){const e=E.EMPTY_NODE.updateChild(this.indexPath_,Dt);return new b(De,e)}toString(){return Ra(this.indexPath_,0).join("/")}}/**
999
+ */class Lf extends On{constructor(e){super(),this.indexPath_=e,m(!S(e)&&C(e)!==".priority","Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const s=this.extractChild(e.node),r=this.extractChild(t.node),i=s.compareTo(r);return i===0?nt(e.name,t.name):i}makePost(e,t){const s=j(e),r=E.EMPTY_NODE.updateChild(this.indexPath_,s);return new b(t,r)}maxPost(){const e=E.EMPTY_NODE.updateChild(this.indexPath_,Dt);return new b(De,e)}toString(){return Ia(this.indexPath_,0).join("/")}}/**
1000
1000
  * @license
1001
1001
  * Copyright 2017 Google LLC
1002
1002
  *
@@ -1011,7 +1011,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1011
1011
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1012
1012
  * See the License for the specific language governing permissions and
1013
1013
  * limitations under the License.
1014
- */class Lf extends On{compare(e,t){const s=e.node.compareTo(t.node);return s===0?nt(e.name,t.name):s}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return b.MIN}maxPost(){return b.MAX}makePost(e,t){const s=j(e);return new b(t,s)}toString(){return".value"}}const Ff=new Lf;/**
1014
+ */class Ff extends On{compare(e,t){const s=e.node.compareTo(t.node);return s===0?nt(e.name,t.name):s}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return b.MIN}maxPost(){return b.MAX}makePost(e,t){const s=j(e);return new b(t,s)}toString(){return".value"}}const Mf=new Ff;/**
1015
1015
  * @license
1016
1016
  * Copyright 2017 Google LLC
1017
1017
  *
@@ -1026,7 +1026,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1026
1026
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1027
1027
  * See the License for the specific language governing permissions and
1028
1028
  * limitations under the License.
1029
- */function Da(n){return{type:"value",snapshotNode:n}}function Qe(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function bt(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function Ct(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function Mf(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}/**
1029
+ */function La(n){return{type:"value",snapshotNode:n}}function Qe(n,e){return{type:"child_added",snapshotNode:e,childName:n}}function bt(n,e){return{type:"child_removed",snapshotNode:e,childName:n}}function Ct(n,e,t){return{type:"child_changed",snapshotNode:e,childName:n,oldSnap:t}}function Bf(n,e){return{type:"child_moved",snapshotNode:e,childName:n}}/**
1030
1030
  * @license
1031
1031
  * Copyright 2017 Google LLC
1032
1032
  *
@@ -1041,7 +1041,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1041
1041
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1042
1042
  * See the License for the specific language governing permissions and
1043
1043
  * limitations under the License.
1044
- */class Xs{constructor(e){this.index_=e}updateChild(e,t,s,r,i,o){m(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(r).equals(s.getChild(r))&&a.isEmpty()===s.isEmpty()||(o!=null&&(s.isEmpty()?e.hasChild(t)?o.trackChildChange(bt(t,a)):m(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(Qe(t,s)):o.trackChildChange(Ct(t,s,a))),e.isLeafNode()&&s.isEmpty())?e:e.updateImmediateChild(t,s).withIndex(this.index_)}updateFullNode(e,t,s){return s!=null&&(e.isLeafNode()||e.forEachChild(U,(r,i)=>{t.hasChild(r)||s.trackChildChange(bt(r,i))}),t.isLeafNode()||t.forEachChild(U,(r,i)=>{if(e.hasChild(r)){const o=e.getImmediateChild(r);o.equals(i)||s.trackChildChange(Ct(r,i,o))}else s.trackChildChange(Qe(r,i))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?E.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}/**
1044
+ */class Js{constructor(e){this.index_=e}updateChild(e,t,s,r,i,o){m(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(r).equals(s.getChild(r))&&a.isEmpty()===s.isEmpty()||(o!=null&&(s.isEmpty()?e.hasChild(t)?o.trackChildChange(bt(t,a)):m(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(Qe(t,s)):o.trackChildChange(Ct(t,s,a))),e.isLeafNode()&&s.isEmpty())?e:e.updateImmediateChild(t,s).withIndex(this.index_)}updateFullNode(e,t,s){return s!=null&&(e.isLeafNode()||e.forEachChild(U,(r,i)=>{t.hasChild(r)||s.trackChildChange(bt(r,i))}),t.isLeafNode()||t.forEachChild(U,(r,i)=>{if(e.hasChild(r)){const o=e.getImmediateChild(r);o.equals(i)||s.trackChildChange(Ct(r,i,o))}else s.trackChildChange(Qe(r,i))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?E.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}/**
1045
1045
  * @license
1046
1046
  * Copyright 2017 Google LLC
1047
1047
  *
@@ -1056,7 +1056,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1056
1056
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1057
1057
  * See the License for the specific language governing permissions and
1058
1058
  * limitations under the License.
1059
- */class St{constructor(e){this.indexedFilter_=new Xs(e.getIndex()),this.index_=e.getIndex(),this.startPost_=St.getStartPost_(e),this.endPost_=St.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,s=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&s}updateChild(e,t,s,r,i,o){return this.matches(new b(t,s))||(s=E.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,s,r,i,o)}updateFullNode(e,t,s){t.isLeafNode()&&(t=E.EMPTY_NODE);let r=t.withIndex(this.index_);r=r.updatePriority(E.EMPTY_NODE);const i=this;return t.forEachChild(U,(o,a)=>{i.matches(new b(o,a))||(r=r.updateImmediateChild(o,E.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,r,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}else return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}else return e.getIndex().maxPost()}}/**
1059
+ */class St{constructor(e){this.indexedFilter_=new Js(e.getIndex()),this.index_=e.getIndex(),this.startPost_=St.getStartPost_(e),this.endPost_=St.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,s=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&s}updateChild(e,t,s,r,i,o){return this.matches(new b(t,s))||(s=E.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,s,r,i,o)}updateFullNode(e,t,s){t.isLeafNode()&&(t=E.EMPTY_NODE);let r=t.withIndex(this.index_);r=r.updatePriority(E.EMPTY_NODE);const i=this;return t.forEachChild(U,(o,a)=>{i.matches(new b(o,a))||(r=r.updateImmediateChild(o,E.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,r,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}else return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}else return e.getIndex().maxPost()}}/**
1060
1060
  * @license
1061
1061
  * Copyright 2017 Google LLC
1062
1062
  *
@@ -1071,7 +1071,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1071
1071
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1072
1072
  * See the License for the specific language governing permissions and
1073
1073
  * limitations under the License.
1074
- */class Bf{constructor(e){this.withinDirectionalStart=t=>this.reverse_?this.withinEndPost(t):this.withinStartPost(t),this.withinDirectionalEnd=t=>this.reverse_?this.withinStartPost(t):this.withinEndPost(t),this.withinStartPost=t=>{const s=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?s<=0:s<0},this.withinEndPost=t=>{const s=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?s<=0:s<0},this.rangedFilter_=new St(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,s,r,i,o){return this.rangedFilter_.matches(new b(t,s))||(s=E.EMPTY_NODE),e.getImmediateChild(t).equals(s)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,s,r,i,o):this.fullLimitUpdateChild_(e,t,s,i,o)}updateFullNode(e,t,s){let r;if(t.isLeafNode()||t.isEmpty())r=E.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<t.numChildren()&&t.isIndexed(this.index_)){r=E.EMPTY_NODE.withIndex(this.index_);let i;this.reverse_?i=t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):i=t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let o=0;for(;i.hasNext()&&o<this.limit_;){const a=i.getNext();if(this.withinDirectionalStart(a))if(this.withinDirectionalEnd(a))r=r.updateImmediateChild(a.name,a.node),o++;else break;else continue}}else{r=t.withIndex(this.index_),r=r.updatePriority(E.EMPTY_NODE);let i;this.reverse_?i=r.getReverseIterator(this.index_):i=r.getIterator(this.index_);let o=0;for(;i.hasNext();){const a=i.getNext();o<this.limit_&&this.withinDirectionalStart(a)&&this.withinDirectionalEnd(a)?o++:r=r.updateImmediateChild(a.name,E.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,r,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,s,r,i){let o;if(this.reverse_){const u=this.index_.getCompare();o=(d,_)=>u(_,d)}else o=this.index_.getCompare();const a=e;m(a.numChildren()===this.limit_,"");const c=new b(t,s),l=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),h=this.rangedFilter_.matches(c);if(a.hasChild(t)){const u=a.getImmediateChild(t);let d=r.getChildAfterChild(this.index_,l,this.reverse_);for(;d!=null&&(d.name===t||a.hasChild(d.name));)d=r.getChildAfterChild(this.index_,d,this.reverse_);const _=d==null?1:o(d,c);if(h&&!s.isEmpty()&&_>=0)return i!=null&&i.trackChildChange(Ct(t,s,u)),a.updateImmediateChild(t,s);{i!=null&&i.trackChildChange(bt(t,u));const y=a.updateImmediateChild(t,E.EMPTY_NODE);return d!=null&&this.rangedFilter_.matches(d)?(i!=null&&i.trackChildChange(Qe(d.name,d.node)),y.updateImmediateChild(d.name,d.node)):y}}else return s.isEmpty()?e:h&&o(l,c)>=0?(i!=null&&(i.trackChildChange(bt(l.name,l.node)),i.trackChildChange(Qe(t,s))),a.updateImmediateChild(t,s).updateImmediateChild(l.name,E.EMPTY_NODE)):e}}/**
1074
+ */class Uf{constructor(e){this.withinDirectionalStart=t=>this.reverse_?this.withinEndPost(t):this.withinStartPost(t),this.withinDirectionalEnd=t=>this.reverse_?this.withinStartPost(t):this.withinEndPost(t),this.withinStartPost=t=>{const s=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?s<=0:s<0},this.withinEndPost=t=>{const s=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?s<=0:s<0},this.rangedFilter_=new St(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,s,r,i,o){return this.rangedFilter_.matches(new b(t,s))||(s=E.EMPTY_NODE),e.getImmediateChild(t).equals(s)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,s,r,i,o):this.fullLimitUpdateChild_(e,t,s,i,o)}updateFullNode(e,t,s){let r;if(t.isLeafNode()||t.isEmpty())r=E.EMPTY_NODE.withIndex(this.index_);else if(this.limit_*2<t.numChildren()&&t.isIndexed(this.index_)){r=E.EMPTY_NODE.withIndex(this.index_);let i;this.reverse_?i=t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):i=t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let o=0;for(;i.hasNext()&&o<this.limit_;){const a=i.getNext();if(this.withinDirectionalStart(a))if(this.withinDirectionalEnd(a))r=r.updateImmediateChild(a.name,a.node),o++;else break;else continue}}else{r=t.withIndex(this.index_),r=r.updatePriority(E.EMPTY_NODE);let i;this.reverse_?i=r.getReverseIterator(this.index_):i=r.getIterator(this.index_);let o=0;for(;i.hasNext();){const a=i.getNext();o<this.limit_&&this.withinDirectionalStart(a)&&this.withinDirectionalEnd(a)?o++:r=r.updateImmediateChild(a.name,E.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,r,s)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,s,r,i){let o;if(this.reverse_){const u=this.index_.getCompare();o=(d,_)=>u(_,d)}else o=this.index_.getCompare();const a=e;m(a.numChildren()===this.limit_,"");const c=new b(t,s),l=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),h=this.rangedFilter_.matches(c);if(a.hasChild(t)){const u=a.getImmediateChild(t);let d=r.getChildAfterChild(this.index_,l,this.reverse_);for(;d!=null&&(d.name===t||a.hasChild(d.name));)d=r.getChildAfterChild(this.index_,d,this.reverse_);const _=d==null?1:o(d,c);if(h&&!s.isEmpty()&&_>=0)return i!=null&&i.trackChildChange(Ct(t,s,u)),a.updateImmediateChild(t,s);{i!=null&&i.trackChildChange(bt(t,u));const y=a.updateImmediateChild(t,E.EMPTY_NODE);return d!=null&&this.rangedFilter_.matches(d)?(i!=null&&i.trackChildChange(Qe(d.name,d.node)),y.updateImmediateChild(d.name,d.node)):y}}else return s.isEmpty()?e:h&&o(l,c)>=0?(i!=null&&(i.trackChildChange(bt(l.name,l.node)),i.trackChildChange(Qe(t,s))),a.updateImmediateChild(t,s).updateImmediateChild(l.name,E.EMPTY_NODE)):e}}/**
1075
1075
  * @license
1076
1076
  * Copyright 2017 Google LLC
1077
1077
  *
@@ -1086,7 +1086,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1086
1086
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1087
1087
  * See the License for the specific language governing permissions and
1088
1088
  * limitations under the License.
1089
- */class Zs{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=U}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return m(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return m(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Ye}hasEnd(){return this.endSet_}getIndexEndValue(){return m(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return m(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:De}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return m(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===U}copy(){const e=new Zs;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function Uf(n){return n.loadsAllData()?new Xs(n.getIndex()):n.hasLimit()?new Bf(n):new St(n)}function di(n){const e={};if(n.isDefault())return e;let t;if(n.index_===U?t="$priority":n.index_===Ff?t="$value":n.index_===je?t="$key":(m(n.index_ instanceof Df,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=$(t),n.startSet_){const s=n.startAfterSet_?"startAfter":"startAt";e[s]=$(n.indexStartValue_),n.startNameSet_&&(e[s]+=","+$(n.indexStartName_))}if(n.endSet_){const s=n.endBeforeSet_?"endBefore":"endAt";e[s]=$(n.indexEndValue_),n.endNameSet_&&(e[s]+=","+$(n.indexEndName_))}return n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function fi(n){const e={};if(n.startSet_&&(e.sp=n.indexStartValue_,n.startNameSet_&&(e.sn=n.indexStartName_),e.sin=!n.startAfterSet_),n.endSet_&&(e.ep=n.indexEndValue_,n.endNameSet_&&(e.en=n.indexEndName_),e.ein=!n.endBeforeSet_),n.limitSet_){e.l=n.limit_;let t=n.viewFrom_;t===""&&(n.isViewFromLeft()?t="l":t="r"),e.vf=t}return n.index_!==U&&(e.i=n.index_.toString()),e}/**
1089
+ */class Xs{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=U}hasStart(){return this.startSet_}isViewFromLeft(){return this.viewFrom_===""?this.startSet_:this.viewFrom_==="l"}getIndexStartValue(){return m(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return m(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:Ye}hasEnd(){return this.endSet_}getIndexEndValue(){return m(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return m(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:De}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&this.viewFrom_!==""}getLimit(){return m(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===U}copy(){const e=new Xs;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function Hf(n){return n.loadsAllData()?new Js(n.getIndex()):n.hasLimit()?new Uf(n):new St(n)}function ui(n){const e={};if(n.isDefault())return e;let t;if(n.index_===U?t="$priority":n.index_===Mf?t="$value":n.index_===je?t="$key":(m(n.index_ instanceof Lf,"Unrecognized index type!"),t=n.index_.toString()),e.orderBy=$(t),n.startSet_){const s=n.startAfterSet_?"startAfter":"startAt";e[s]=$(n.indexStartValue_),n.startNameSet_&&(e[s]+=","+$(n.indexStartName_))}if(n.endSet_){const s=n.endBeforeSet_?"endBefore":"endAt";e[s]=$(n.indexEndValue_),n.endNameSet_&&(e[s]+=","+$(n.indexEndName_))}return n.limitSet_&&(n.isViewFromLeft()?e.limitToFirst=n.limit_:e.limitToLast=n.limit_),e}function di(n){const e={};if(n.startSet_&&(e.sp=n.indexStartValue_,n.startNameSet_&&(e.sn=n.indexStartName_),e.sin=!n.startAfterSet_),n.endSet_&&(e.ep=n.indexEndValue_,n.endNameSet_&&(e.en=n.indexEndName_),e.ein=!n.endBeforeSet_),n.limitSet_){e.l=n.limit_;let t=n.viewFrom_;t===""&&(n.isViewFromLeft()?t="l":t="r"),e.vf=t}return n.index_!==U&&(e.i=n.index_.toString()),e}/**
1090
1090
  * @license
1091
1091
  * Copyright 2017 Google LLC
1092
1092
  *
@@ -1101,7 +1101,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1101
1101
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1102
1102
  * See the License for the specific language governing permissions and
1103
1103
  * limitations under the License.
1104
- */class hn extends Ca{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(m(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,s,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=s,this.appCheckTokenProvider_=r,this.log_=xt("p:rest:"),this.listens_={}}listen(e,t,s,r){const i=e._path.toString();this.log_("Listen called for "+i+" "+e._queryIdentifier);const o=hn.getListenId_(e,s),a={};this.listens_[o]=a;const c=di(e._queryParams);this.restRequest_(i+".json",c,(l,h)=>{let u=h;if(l===404&&(u=null,l=null),l===null&&this.onDataUpdate_(i,u,!1,s),Ge(this.listens_,o)===a){let d;l?l===401?d="permission_denied":d="rest_error:"+l:d="ok",r(d,null)}})}unlisten(e,t){const s=hn.getListenId_(e,t);delete this.listens_[s]}get(e){const t=di(e._queryParams),s=e._path.toString(),r=new Vs;return this.restRequest_(s+".json",t,(i,o)=>{let a=o;i===404&&(a=null,i=null),i===null?(this.onDataUpdate_(s,a,!1,null),r.resolve(a)):r.reject(new Error(a))}),r.promise}refreshAuthToken(e){}restRequest_(e,t={},s){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([r,i])=>{r&&r.accessToken&&(t.auth=r.accessToken),i&&i.token&&(t.ac=i.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+uu(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(s&&a.readyState===4){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let c=null;if(a.status>=200&&a.status<300){try{c=yt(a.responseText)}catch{te("Failed to parse JSON response for "+o+": "+a.responseText)}s(null,c)}else a.status!==401&&a.status!==404&&te("Got unsuccessful REST response for "+o+" Status: "+a.status),s(a.status);s=null}},a.open("GET",o,!0),a.send()})}}/**
1104
+ */class hn extends Sa{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return t!==void 0?"tag$"+t:(m(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,s,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=s,this.appCheckTokenProvider_=r,this.log_=xt("p:rest:"),this.listens_={}}listen(e,t,s,r){const i=e._path.toString();this.log_("Listen called for "+i+" "+e._queryIdentifier);const o=hn.getListenId_(e,s),a={};this.listens_[o]=a;const c=ui(e._queryParams);this.restRequest_(i+".json",c,(l,h)=>{let u=h;if(l===404&&(u=null,l=null),l===null&&this.onDataUpdate_(i,u,!1,s),Ge(this.listens_,o)===a){let d;l?l===401?d="permission_denied":d="rest_error:"+l:d="ok",r(d,null)}})}unlisten(e,t){const s=hn.getListenId_(e,t);delete this.listens_[s]}get(e){const t=ui(e._queryParams),s=e._path.toString(),r=new qs;return this.restRequest_(s+".json",t,(i,o)=>{let a=o;i===404&&(a=null,i=null),i===null?(this.onDataUpdate_(s,a,!1,null),r.resolve(a)):r.reject(new Error(a))}),r.promise}refreshAuthToken(e){}restRequest_(e,t={},s){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([r,i])=>{r&&r.accessToken&&(t.auth=r.accessToken),i&&i.token&&(t.ac=i.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+du(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(s&&a.readyState===4){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let c=null;if(a.status>=200&&a.status<300){try{c=yt(a.responseText)}catch{te("Failed to parse JSON response for "+o+": "+a.responseText)}s(null,c)}else a.status!==401&&a.status!==404&&te("Got unsuccessful REST response for "+o+" Status: "+a.status),s(a.status);s=null}},a.open("GET",o,!0),a.send()})}}/**
1105
1105
  * @license
1106
1106
  * Copyright 2017 Google LLC
1107
1107
  *
@@ -1116,7 +1116,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1116
1116
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1117
1117
  * See the License for the specific language governing permissions and
1118
1118
  * limitations under the License.
1119
- */class Hf{constructor(){this.rootNode_=E.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}/**
1119
+ */class Wf{constructor(){this.rootNode_=E.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}/**
1120
1120
  * @license
1121
1121
  * Copyright 2017 Google LLC
1122
1122
  *
@@ -1131,7 +1131,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1131
1131
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1132
1132
  * See the License for the specific language governing permissions and
1133
1133
  * limitations under the License.
1134
- */function un(){return{value:null,children:new Map}}function La(n,e,t){if(S(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const s=C(e);n.children.has(s)||n.children.set(s,un());const r=n.children.get(s);e=F(e),La(r,e,t)}}function Cs(n,e,t){n.value!==null?t(e,n.value):Wf(n,(s,r)=>{const i=new x(e.toString()+"/"+s);Cs(r,i,t)})}function Wf(n,e){n.children.forEach((t,s)=>{e(s,t)})}/**
1134
+ */function un(){return{value:null,children:new Map}}function Fa(n,e,t){if(S(e))n.value=t,n.children.clear();else if(n.value!==null)n.value=n.value.updateChild(e,t);else{const s=C(e);n.children.has(s)||n.children.set(s,un());const r=n.children.get(s);e=F(e),Fa(r,e,t)}}function Cs(n,e,t){n.value!==null?t(e,n.value):qf(n,(s,r)=>{const i=new D(e.toString()+"/"+s);Cs(r,i,t)})}function qf(n,e){n.children.forEach((t,s)=>{e(s,t)})}/**
1135
1135
  * @license
1136
1136
  * Copyright 2017 Google LLC
1137
1137
  *
@@ -1146,7 +1146,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1146
1146
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1147
1147
  * See the License for the specific language governing permissions and
1148
1148
  * limitations under the License.
1149
- */class qf{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&Z(this.last_,(s,r)=>{t[s]=t[s]-r}),this.last_=e,t}}/**
1149
+ */class Vf{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&&Z(this.last_,(s,r)=>{t[s]=t[s]-r}),this.last_=e,t}}/**
1150
1150
  * @license
1151
1151
  * Copyright 2017 Google LLC
1152
1152
  *
@@ -1161,7 +1161,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1161
1161
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1162
1162
  * See the License for the specific language governing permissions and
1163
1163
  * limitations under the License.
1164
- */const pi=10*1e3,Vf=30*1e3,$f=5*60*1e3;class zf{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new qf(e);const s=pi+(Vf-pi)*Math.random();ft(this.reportStats_.bind(this),Math.floor(s))}reportStats_(){const e=this.statsListener_.get(),t={};let s=!1;Z(e,(r,i)=>{i>0&&me(this.statsToReport_,r)&&(t[r]=i,s=!0)}),s&&this.server_.reportStats(t),ft(this.reportStats_.bind(this),Math.floor(Math.random()*2*$f))}}/**
1164
+ */const fi=10*1e3,$f=30*1e3,zf=5*60*1e3;class jf{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new Vf(e);const s=fi+($f-fi)*Math.random();ft(this.reportStats_.bind(this),Math.floor(s))}reportStats_(){const e=this.statsListener_.get(),t={};let s=!1;Z(e,(r,i)=>{i>0&&me(this.statsToReport_,r)&&(t[r]=i,s=!0)}),s&&this.server_.reportStats(t),ft(this.reportStats_.bind(this),Math.floor(Math.random()*2*zf))}}/**
1165
1165
  * @license
1166
1166
  * Copyright 2017 Google LLC
1167
1167
  *
@@ -1176,7 +1176,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1176
1176
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1177
1177
  * See the License for the specific language governing permissions and
1178
1178
  * limitations under the License.
1179
- */var ae;(function(n){n[n.OVERWRITE=0]="OVERWRITE",n[n.MERGE=1]="MERGE",n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE",n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"})(ae||(ae={}));function Fa(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function er(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function tr(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}/**
1179
+ */var ae;(function(n){n[n.OVERWRITE=0]="OVERWRITE",n[n.MERGE=1]="MERGE",n[n.ACK_USER_WRITE=2]="ACK_USER_WRITE",n[n.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"})(ae||(ae={}));function Ma(){return{fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}function Zs(){return{fromUser:!1,fromServer:!0,queryId:null,tagged:!1}}function er(n){return{fromUser:!1,fromServer:!0,queryId:n,tagged:!0}}/**
1180
1180
  * @license
1181
1181
  * Copyright 2017 Google LLC
1182
1182
  *
@@ -1191,7 +1191,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1191
1191
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1192
1192
  * See the License for the specific language governing permissions and
1193
1193
  * limitations under the License.
1194
- */class dn{constructor(e,t,s){this.path=e,this.affectedTree=t,this.revert=s,this.type=ae.ACK_USER_WRITE,this.source=Fa()}operationForChild(e){if(S(this.path)){if(this.affectedTree.value!=null)return m(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new x(e));return new dn(N(),t,this.revert)}}else return m(C(this.path)===e,"operationForChild called for unrelated child."),new dn(F(this.path),this.affectedTree,this.revert)}}/**
1194
+ */class dn{constructor(e,t,s){this.path=e,this.affectedTree=t,this.revert=s,this.type=ae.ACK_USER_WRITE,this.source=Ma()}operationForChild(e){if(S(this.path)){if(this.affectedTree.value!=null)return m(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new D(e));return new dn(N(),t,this.revert)}}else return m(C(this.path)===e,"operationForChild called for unrelated child."),new dn(F(this.path),this.affectedTree,this.revert)}}/**
1195
1195
  * @license
1196
1196
  * Copyright 2017 Google LLC
1197
1197
  *
@@ -1236,7 +1236,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1236
1236
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1237
1237
  * See the License for the specific language governing permissions and
1238
1238
  * limitations under the License.
1239
- */class Rt{constructor(e,t,s){this.source=e,this.path=t,this.children=s,this.type=ae.MERGE}operationForChild(e){if(S(this.path)){const t=this.children.subtree(new x(e));return t.isEmpty()?null:t.value?new Le(this.source,N(),t.value):new Rt(this.source,N(),t)}else return m(C(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new Rt(this.source,F(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
1239
+ */class Rt{constructor(e,t,s){this.source=e,this.path=t,this.children=s,this.type=ae.MERGE}operationForChild(e){if(S(this.path)){const t=this.children.subtree(new D(e));return t.isEmpty()?null:t.value?new Le(this.source,N(),t.value):new Rt(this.source,N(),t)}else return m(C(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new Rt(this.source,F(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}/**
1240
1240
  * @license
1241
1241
  * Copyright 2017 Google LLC
1242
1242
  *
@@ -1266,7 +1266,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1266
1266
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1267
1267
  * See the License for the specific language governing permissions and
1268
1268
  * limitations under the License.
1269
- */class jf{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Kf(n,e,t,s){const r=[],i=[];return e.forEach(o=>{o.type==="child_changed"&&n.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&i.push(Mf(o.childName,o.snapshotNode))}),lt(n,r,"child_removed",e,s,t),lt(n,r,"child_added",e,s,t),lt(n,r,"child_moved",i,s,t),lt(n,r,"child_changed",e,s,t),lt(n,r,"value",e,s,t),r}function lt(n,e,t,s,r,i){const o=s.filter(a=>a.type===t);o.sort((a,c)=>Yf(n,a,c)),o.forEach(a=>{const c=Gf(n,a,i);r.forEach(l=>{l.respondsTo(a.type)&&e.push(l.createEvent(c,n.query_))})})}function Gf(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function Yf(n,e,t){if(e.childName==null||t.childName==null)throw tt("Should only compare child_ events.");const s=new b(e.childName,e.snapshotNode),r=new b(t.childName,t.snapshotNode);return n.index_.compare(s,r)}/**
1269
+ */class Kf{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Gf(n,e,t,s){const r=[],i=[];return e.forEach(o=>{o.type==="child_changed"&&n.index_.indexedValueChanged(o.oldSnap,o.snapshotNode)&&i.push(Bf(o.childName,o.snapshotNode))}),lt(n,r,"child_removed",e,s,t),lt(n,r,"child_added",e,s,t),lt(n,r,"child_moved",i,s,t),lt(n,r,"child_changed",e,s,t),lt(n,r,"value",e,s,t),r}function lt(n,e,t,s,r,i){const o=s.filter(a=>a.type===t);o.sort((a,c)=>Qf(n,a,c)),o.forEach(a=>{const c=Yf(n,a,i);r.forEach(l=>{l.respondsTo(a.type)&&e.push(l.createEvent(c,n.query_))})})}function Yf(n,e,t){return e.type==="value"||e.type==="child_removed"||(e.prevName=t.getPredecessorChildName(e.childName,e.snapshotNode,n.index_)),e}function Qf(n,e,t){if(e.childName==null||t.childName==null)throw tt("Should only compare child_ events.");const s=new b(e.childName,e.snapshotNode),r=new b(t.childName,t.snapshotNode);return n.index_.compare(s,r)}/**
1270
1270
  * @license
1271
1271
  * Copyright 2017 Google LLC
1272
1272
  *
@@ -1281,7 +1281,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1281
1281
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1282
1282
  * See the License for the specific language governing permissions and
1283
1283
  * limitations under the License.
1284
- */function xn(n,e){return{eventCache:n,serverCache:e}}function pt(n,e,t,s){return xn(new Fe(e,t,s),n.serverCache)}function Ma(n,e,t,s){return xn(n.eventCache,new Fe(e,t,s))}function Ss(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function Me(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}/**
1284
+ */function xn(n,e){return{eventCache:n,serverCache:e}}function pt(n,e,t,s){return xn(new Fe(e,t,s),n.serverCache)}function Ba(n,e,t,s){return xn(n.eventCache,new Fe(e,t,s))}function Ss(n){return n.eventCache.isFullyInitialized()?n.eventCache.getNode():null}function Me(n){return n.serverCache.isFullyInitialized()?n.serverCache.getNode():null}/**
1285
1285
  * @license
1286
1286
  * Copyright 2017 Google LLC
1287
1287
  *
@@ -1296,7 +1296,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1296
1296
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1297
1297
  * See the License for the specific language governing permissions and
1298
1298
  * limitations under the License.
1299
- */let Zn;const Qf=()=>(Zn||(Zn=new J(Dd)),Zn);class M{static fromObject(e){let t=new M(null);return Z(e,(s,r)=>{t=t.set(new x(s),r)}),t}constructor(e,t=Qf()){this.value=e,this.children=t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:N(),value:this.value};if(S(e))return null;{const s=C(e),r=this.children.get(s);if(r!==null){const i=r.findRootMostMatchingPathAndValue(F(e),t);return i!=null?{path:W(new x(s),i.path),value:i.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(S(e))return this;{const t=C(e),s=this.children.get(t);return s!==null?s.subtree(F(e)):new M(null)}}set(e,t){if(S(e))return new M(t,this.children);{const s=C(e),i=(this.children.get(s)||new M(null)).set(F(e),t),o=this.children.insert(s,i);return new M(this.value,o)}}remove(e){if(S(e))return this.children.isEmpty()?new M(null):new M(null,this.children);{const t=C(e),s=this.children.get(t);if(s){const r=s.remove(F(e));let i;return r.isEmpty()?i=this.children.remove(t):i=this.children.insert(t,r),this.value===null&&i.isEmpty()?new M(null):new M(this.value,i)}else return this}}get(e){if(S(e))return this.value;{const t=C(e),s=this.children.get(t);return s?s.get(F(e)):null}}setTree(e,t){if(S(e))return t;{const s=C(e),i=(this.children.get(s)||new M(null)).setTree(F(e),t);let o;return i.isEmpty()?o=this.children.remove(s):o=this.children.insert(s,i),new M(this.value,o)}}fold(e){return this.fold_(N(),e)}fold_(e,t){const s={};return this.children.inorderTraversal((r,i)=>{s[r]=i.fold_(W(e,r),t)}),t(e,this.value,s)}findOnPath(e,t){return this.findOnPath_(e,N(),t)}findOnPath_(e,t,s){const r=this.value?s(t,this.value):!1;if(r)return r;if(S(e))return null;{const i=C(e),o=this.children.get(i);return o?o.findOnPath_(F(e),W(t,i),s):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,N(),t)}foreachOnPath_(e,t,s){if(S(e))return this;{this.value&&s(t,this.value);const r=C(e),i=this.children.get(r);return i?i.foreachOnPath_(F(e),W(t,r),s):new M(null)}}foreach(e){this.foreach_(N(),e)}foreach_(e,t){this.children.inorderTraversal((s,r)=>{r.foreach_(W(e,s),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,s)=>{s.value&&e(t,s.value)})}}/**
1299
+ */let Zn;const Jf=()=>(Zn||(Zn=new J(Ld)),Zn);class M{static fromObject(e){let t=new M(null);return Z(e,(s,r)=>{t=t.set(new D(s),r)}),t}constructor(e,t=Jf()){this.value=e,this.children=t}isEmpty(){return this.value===null&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(this.value!=null&&t(this.value))return{path:N(),value:this.value};if(S(e))return null;{const s=C(e),r=this.children.get(s);if(r!==null){const i=r.findRootMostMatchingPathAndValue(F(e),t);return i!=null?{path:W(new D(s),i.path),value:i.value}:null}else return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(S(e))return this;{const t=C(e),s=this.children.get(t);return s!==null?s.subtree(F(e)):new M(null)}}set(e,t){if(S(e))return new M(t,this.children);{const s=C(e),i=(this.children.get(s)||new M(null)).set(F(e),t),o=this.children.insert(s,i);return new M(this.value,o)}}remove(e){if(S(e))return this.children.isEmpty()?new M(null):new M(null,this.children);{const t=C(e),s=this.children.get(t);if(s){const r=s.remove(F(e));let i;return r.isEmpty()?i=this.children.remove(t):i=this.children.insert(t,r),this.value===null&&i.isEmpty()?new M(null):new M(this.value,i)}else return this}}get(e){if(S(e))return this.value;{const t=C(e),s=this.children.get(t);return s?s.get(F(e)):null}}setTree(e,t){if(S(e))return t;{const s=C(e),i=(this.children.get(s)||new M(null)).setTree(F(e),t);let o;return i.isEmpty()?o=this.children.remove(s):o=this.children.insert(s,i),new M(this.value,o)}}fold(e){return this.fold_(N(),e)}fold_(e,t){const s={};return this.children.inorderTraversal((r,i)=>{s[r]=i.fold_(W(e,r),t)}),t(e,this.value,s)}findOnPath(e,t){return this.findOnPath_(e,N(),t)}findOnPath_(e,t,s){const r=this.value?s(t,this.value):!1;if(r)return r;if(S(e))return null;{const i=C(e),o=this.children.get(i);return o?o.findOnPath_(F(e),W(t,i),s):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,N(),t)}foreachOnPath_(e,t,s){if(S(e))return this;{this.value&&s(t,this.value);const r=C(e),i=this.children.get(r);return i?i.foreachOnPath_(F(e),W(t,r),s):new M(null)}}foreach(e){this.foreach_(N(),e)}foreach_(e,t){this.children.inorderTraversal((s,r)=>{r.foreach_(W(e,s),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,s)=>{s.value&&e(t,s.value)})}}/**
1300
1300
  * @license
1301
1301
  * Copyright 2017 Google LLC
1302
1302
  *
@@ -1311,7 +1311,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1311
1311
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1312
1312
  * See the License for the specific language governing permissions and
1313
1313
  * limitations under the License.
1314
- */class ce{constructor(e){this.writeTree_=e}static empty(){return new ce(new M(null))}}function _t(n,e,t){if(S(e))return new ce(new M(t));{const s=n.writeTree_.findRootMostValueAndPath(e);if(s!=null){const r=s.path;let i=s.value;const o=Q(r,e);return i=i.updateChild(o,t),new ce(n.writeTree_.set(r,i))}else{const r=new M(t),i=n.writeTree_.setTree(e,r);return new ce(i)}}}function _i(n,e,t){let s=n;return Z(t,(r,i)=>{s=_t(s,W(e,r),i)}),s}function mi(n,e){if(S(e))return ce.empty();{const t=n.writeTree_.setTree(e,new M(null));return new ce(t)}}function Ts(n,e){return Be(n,e)!=null}function Be(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(Q(t.path,e)):null}function gi(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(U,(s,r)=>{e.push(new b(s,r))}):n.writeTree_.children.inorderTraversal((s,r)=>{r.value!=null&&e.push(new b(s,r.value))}),e}function be(n,e){if(S(e))return n;{const t=Be(n,e);return t!=null?new ce(new M(t)):new ce(n.writeTree_.subtree(e))}}function Rs(n){return n.writeTree_.isEmpty()}function Je(n,e){return Ba(N(),n.writeTree_,e)}function Ba(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let s=null;return e.children.inorderTraversal((r,i)=>{r===".priority"?(m(i.value!==null,"Priority writes must always be leaf nodes"),s=i.value):t=Ba(W(n,r),i,t)}),!t.getChild(n).isEmpty()&&s!==null&&(t=t.updateChild(W(n,".priority"),s)),t}}/**
1314
+ */class ce{constructor(e){this.writeTree_=e}static empty(){return new ce(new M(null))}}function _t(n,e,t){if(S(e))return new ce(new M(t));{const s=n.writeTree_.findRootMostValueAndPath(e);if(s!=null){const r=s.path;let i=s.value;const o=Q(r,e);return i=i.updateChild(o,t),new ce(n.writeTree_.set(r,i))}else{const r=new M(t),i=n.writeTree_.setTree(e,r);return new ce(i)}}}function pi(n,e,t){let s=n;return Z(t,(r,i)=>{s=_t(s,W(e,r),i)}),s}function _i(n,e){if(S(e))return ce.empty();{const t=n.writeTree_.setTree(e,new M(null));return new ce(t)}}function Ts(n,e){return Be(n,e)!=null}function Be(n,e){const t=n.writeTree_.findRootMostValueAndPath(e);return t!=null?n.writeTree_.get(t.path).getChild(Q(t.path,e)):null}function mi(n){const e=[],t=n.writeTree_.value;return t!=null?t.isLeafNode()||t.forEachChild(U,(s,r)=>{e.push(new b(s,r))}):n.writeTree_.children.inorderTraversal((s,r)=>{r.value!=null&&e.push(new b(s,r.value))}),e}function be(n,e){if(S(e))return n;{const t=Be(n,e);return t!=null?new ce(new M(t)):new ce(n.writeTree_.subtree(e))}}function Rs(n){return n.writeTree_.isEmpty()}function Je(n,e){return Ua(N(),n.writeTree_,e)}function Ua(n,e,t){if(e.value!=null)return t.updateChild(n,e.value);{let s=null;return e.children.inorderTraversal((r,i)=>{r===".priority"?(m(i.value!==null,"Priority writes must always be leaf nodes"),s=i.value):t=Ua(W(n,r),i,t)}),!t.getChild(n).isEmpty()&&s!==null&&(t=t.updateChild(W(n,".priority"),s)),t}}/**
1315
1315
  * @license
1316
1316
  * Copyright 2017 Google LLC
1317
1317
  *
@@ -1326,7 +1326,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1326
1326
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1327
1327
  * See the License for the specific language governing permissions and
1328
1328
  * limitations under the License.
1329
- */function nr(n,e){return qa(e,n)}function Jf(n,e,t,s,r){m(s>n.lastWriteId,"Stacking an older write on top of newer ones"),r===void 0&&(r=!0),n.allWrites.push({path:e,snap:t,writeId:s,visible:r}),r&&(n.visibleWrites=_t(n.visibleWrites,e,t)),n.lastWriteId=s}function Xf(n,e){for(let t=0;t<n.allWrites.length;t++){const s=n.allWrites[t];if(s.writeId===e)return s}return null}function Zf(n,e){const t=n.allWrites.findIndex(a=>a.writeId===e);m(t>=0,"removeWrite called with nonexistent writeId.");const s=n.allWrites[t];n.allWrites.splice(t,1);let r=s.visible,i=!1,o=n.allWrites.length-1;for(;r&&o>=0;){const a=n.allWrites[o];a.visible&&(o>=t&&ep(a,s.path)?r=!1:oe(s.path,a.path)&&(i=!0)),o--}if(r){if(i)return tp(n),!0;if(s.snap)n.visibleWrites=mi(n.visibleWrites,s.path);else{const a=s.children;Z(a,c=>{n.visibleWrites=mi(n.visibleWrites,W(s.path,c))})}return!0}else return!1}function ep(n,e){if(n.snap)return oe(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&oe(W(n.path,t),e))return!0;return!1}function tp(n){n.visibleWrites=Ua(n.allWrites,np,N()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function np(n){return n.visible}function Ua(n,e,t){let s=ce.empty();for(let r=0;r<n.length;++r){const i=n[r];if(e(i)){const o=i.path;let a;if(i.snap)oe(t,o)?(a=Q(t,o),s=_t(s,a,i.snap)):oe(o,t)&&(a=Q(o,t),s=_t(s,N(),i.snap.getChild(a)));else if(i.children){if(oe(t,o))a=Q(t,o),s=_i(s,a,i.children);else if(oe(o,t))if(a=Q(o,t),S(a))s=_i(s,N(),i.children);else{const c=Ge(i.children,C(a));if(c){const l=c.getChild(F(a));s=_t(s,N(),l)}}}else throw tt("WriteRecord should have .snap or .children")}}return s}function Ha(n,e,t,s,r){if(!s&&!r){const i=Be(n.visibleWrites,e);if(i!=null)return i;{const o=be(n.visibleWrites,e);if(Rs(o))return t;if(t==null&&!Ts(o,N()))return null;{const a=t||E.EMPTY_NODE;return Je(o,a)}}}else{const i=be(n.visibleWrites,e);if(!r&&Rs(i))return t;if(!r&&t==null&&!Ts(i,N()))return null;{const o=function(l){return(l.visible||r)&&(!s||!~s.indexOf(l.writeId))&&(oe(l.path,e)||oe(e,l.path))},a=Ua(n.allWrites,o,e),c=t||E.EMPTY_NODE;return Je(a,c)}}}function sp(n,e,t){let s=E.EMPTY_NODE;const r=Be(n.visibleWrites,e);if(r)return r.isLeafNode()||r.forEachChild(U,(i,o)=>{s=s.updateImmediateChild(i,o)}),s;if(t){const i=be(n.visibleWrites,e);return t.forEachChild(U,(o,a)=>{const c=Je(be(i,new x(o)),a);s=s.updateImmediateChild(o,c)}),gi(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}else{const i=be(n.visibleWrites,e);return gi(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}}function rp(n,e,t,s,r){m(s||r,"Either existingEventSnap or existingServerSnap must exist");const i=W(e,t);if(Ts(n.visibleWrites,i))return null;{const o=be(n.visibleWrites,i);return Rs(o)?r.getChild(t):Je(o,r.getChild(t))}}function ip(n,e,t,s){const r=W(e,t),i=Be(n.visibleWrites,r);if(i!=null)return i;if(s.isCompleteForChild(t)){const o=be(n.visibleWrites,r);return Je(o,s.getNode().getImmediateChild(t))}else return null}function op(n,e){return Be(n.visibleWrites,e)}function ap(n,e,t,s,r,i,o){let a;const c=be(n.visibleWrites,e),l=Be(c,N());if(l!=null)a=l;else if(t!=null)a=Je(c,t);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const h=[],u=o.getCompare(),d=i?a.getReverseIteratorFrom(s,o):a.getIteratorFrom(s,o);let _=d.getNext();for(;_&&h.length<r;)u(_,s)!==0&&h.push(_),_=d.getNext();return h}else return[]}function cp(){return{visibleWrites:ce.empty(),allWrites:[],lastWriteId:-1}}function fn(n,e,t,s){return Ha(n.writeTree,n.treePath,e,t,s)}function sr(n,e){return sp(n.writeTree,n.treePath,e)}function yi(n,e,t,s){return rp(n.writeTree,n.treePath,e,t,s)}function pn(n,e){return op(n.writeTree,W(n.treePath,e))}function lp(n,e,t,s,r,i){return ap(n.writeTree,n.treePath,e,t,s,r,i)}function rr(n,e,t){return ip(n.writeTree,n.treePath,e,t)}function Wa(n,e){return qa(W(n.treePath,e),n.writeTree)}function qa(n,e){return{treePath:n,writeTree:e}}/**
1329
+ */function tr(n,e){return Va(e,n)}function Xf(n,e,t,s,r){m(s>n.lastWriteId,"Stacking an older write on top of newer ones"),r===void 0&&(r=!0),n.allWrites.push({path:e,snap:t,writeId:s,visible:r}),r&&(n.visibleWrites=_t(n.visibleWrites,e,t)),n.lastWriteId=s}function Zf(n,e){for(let t=0;t<n.allWrites.length;t++){const s=n.allWrites[t];if(s.writeId===e)return s}return null}function ep(n,e){const t=n.allWrites.findIndex(a=>a.writeId===e);m(t>=0,"removeWrite called with nonexistent writeId.");const s=n.allWrites[t];n.allWrites.splice(t,1);let r=s.visible,i=!1,o=n.allWrites.length-1;for(;r&&o>=0;){const a=n.allWrites[o];a.visible&&(o>=t&&tp(a,s.path)?r=!1:oe(s.path,a.path)&&(i=!0)),o--}if(r){if(i)return np(n),!0;if(s.snap)n.visibleWrites=_i(n.visibleWrites,s.path);else{const a=s.children;Z(a,c=>{n.visibleWrites=_i(n.visibleWrites,W(s.path,c))})}return!0}else return!1}function tp(n,e){if(n.snap)return oe(n.path,e);for(const t in n.children)if(n.children.hasOwnProperty(t)&&oe(W(n.path,t),e))return!0;return!1}function np(n){n.visibleWrites=Ha(n.allWrites,sp,N()),n.allWrites.length>0?n.lastWriteId=n.allWrites[n.allWrites.length-1].writeId:n.lastWriteId=-1}function sp(n){return n.visible}function Ha(n,e,t){let s=ce.empty();for(let r=0;r<n.length;++r){const i=n[r];if(e(i)){const o=i.path;let a;if(i.snap)oe(t,o)?(a=Q(t,o),s=_t(s,a,i.snap)):oe(o,t)&&(a=Q(o,t),s=_t(s,N(),i.snap.getChild(a)));else if(i.children){if(oe(t,o))a=Q(t,o),s=pi(s,a,i.children);else if(oe(o,t))if(a=Q(o,t),S(a))s=pi(s,N(),i.children);else{const c=Ge(i.children,C(a));if(c){const l=c.getChild(F(a));s=_t(s,N(),l)}}}else throw tt("WriteRecord should have .snap or .children")}}return s}function Wa(n,e,t,s,r){if(!s&&!r){const i=Be(n.visibleWrites,e);if(i!=null)return i;{const o=be(n.visibleWrites,e);if(Rs(o))return t;if(t==null&&!Ts(o,N()))return null;{const a=t||E.EMPTY_NODE;return Je(o,a)}}}else{const i=be(n.visibleWrites,e);if(!r&&Rs(i))return t;if(!r&&t==null&&!Ts(i,N()))return null;{const o=function(l){return(l.visible||r)&&(!s||!~s.indexOf(l.writeId))&&(oe(l.path,e)||oe(e,l.path))},a=Ha(n.allWrites,o,e),c=t||E.EMPTY_NODE;return Je(a,c)}}}function rp(n,e,t){let s=E.EMPTY_NODE;const r=Be(n.visibleWrites,e);if(r)return r.isLeafNode()||r.forEachChild(U,(i,o)=>{s=s.updateImmediateChild(i,o)}),s;if(t){const i=be(n.visibleWrites,e);return t.forEachChild(U,(o,a)=>{const c=Je(be(i,new D(o)),a);s=s.updateImmediateChild(o,c)}),mi(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}else{const i=be(n.visibleWrites,e);return mi(i).forEach(o=>{s=s.updateImmediateChild(o.name,o.node)}),s}}function ip(n,e,t,s,r){m(s||r,"Either existingEventSnap or existingServerSnap must exist");const i=W(e,t);if(Ts(n.visibleWrites,i))return null;{const o=be(n.visibleWrites,i);return Rs(o)?r.getChild(t):Je(o,r.getChild(t))}}function op(n,e,t,s){const r=W(e,t),i=Be(n.visibleWrites,r);if(i!=null)return i;if(s.isCompleteForChild(t)){const o=be(n.visibleWrites,r);return Je(o,s.getNode().getImmediateChild(t))}else return null}function ap(n,e){return Be(n.visibleWrites,e)}function cp(n,e,t,s,r,i,o){let a;const c=be(n.visibleWrites,e),l=Be(c,N());if(l!=null)a=l;else if(t!=null)a=Je(c,t);else return[];if(a=a.withIndex(o),!a.isEmpty()&&!a.isLeafNode()){const h=[],u=o.getCompare(),d=i?a.getReverseIteratorFrom(s,o):a.getIteratorFrom(s,o);let _=d.getNext();for(;_&&h.length<r;)u(_,s)!==0&&h.push(_),_=d.getNext();return h}else return[]}function lp(){return{visibleWrites:ce.empty(),allWrites:[],lastWriteId:-1}}function fn(n,e,t,s){return Wa(n.writeTree,n.treePath,e,t,s)}function nr(n,e){return rp(n.writeTree,n.treePath,e)}function gi(n,e,t,s){return ip(n.writeTree,n.treePath,e,t,s)}function pn(n,e){return ap(n.writeTree,W(n.treePath,e))}function hp(n,e,t,s,r,i){return cp(n.writeTree,n.treePath,e,t,s,r,i)}function sr(n,e,t){return op(n.writeTree,n.treePath,e,t)}function qa(n,e){return Va(W(n.treePath,e),n.writeTree)}function Va(n,e){return{treePath:n,writeTree:e}}/**
1330
1330
  * @license
1331
1331
  * Copyright 2017 Google LLC
1332
1332
  *
@@ -1341,7 +1341,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1341
1341
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1342
1342
  * See the License for the specific language governing permissions and
1343
1343
  * limitations under the License.
1344
- */class hp{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,s=e.childName;m(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),m(s!==".priority","Only non-priority child changes can be tracked.");const r=this.changeMap.get(s);if(r){const i=r.type;if(t==="child_added"&&i==="child_removed")this.changeMap.set(s,Ct(s,e.snapshotNode,r.snapshotNode));else if(t==="child_removed"&&i==="child_added")this.changeMap.delete(s);else if(t==="child_removed"&&i==="child_changed")this.changeMap.set(s,bt(s,r.oldSnap));else if(t==="child_changed"&&i==="child_added")this.changeMap.set(s,Qe(s,e.snapshotNode));else if(t==="child_changed"&&i==="child_changed")this.changeMap.set(s,Ct(s,e.snapshotNode,r.oldSnap));else throw tt("Illegal combination of changes: "+e+" occurred after "+r)}else this.changeMap.set(s,e)}getChanges(){return Array.from(this.changeMap.values())}}/**
1344
+ */class up{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,s=e.childName;m(t==="child_added"||t==="child_changed"||t==="child_removed","Only child changes supported for tracking"),m(s!==".priority","Only non-priority child changes can be tracked.");const r=this.changeMap.get(s);if(r){const i=r.type;if(t==="child_added"&&i==="child_removed")this.changeMap.set(s,Ct(s,e.snapshotNode,r.snapshotNode));else if(t==="child_removed"&&i==="child_added")this.changeMap.delete(s);else if(t==="child_removed"&&i==="child_changed")this.changeMap.set(s,bt(s,r.oldSnap));else if(t==="child_changed"&&i==="child_added")this.changeMap.set(s,Qe(s,e.snapshotNode));else if(t==="child_changed"&&i==="child_changed")this.changeMap.set(s,Ct(s,e.snapshotNode,r.oldSnap));else throw tt("Illegal combination of changes: "+e+" occurred after "+r)}else this.changeMap.set(s,e)}getChanges(){return Array.from(this.changeMap.values())}}/**
1345
1345
  * @license
1346
1346
  * Copyright 2017 Google LLC
1347
1347
  *
@@ -1356,7 +1356,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1356
1356
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1357
1357
  * See the License for the specific language governing permissions and
1358
1358
  * limitations under the License.
1359
- */class up{getCompleteChild(e){return null}getChildAfterChild(e,t,s){return null}}const Va=new up;class ir{constructor(e,t,s=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=s}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const s=this.optCompleteServerCache_!=null?new Fe(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return rr(this.writes_,e,s)}}getChildAfterChild(e,t,s){const r=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:Me(this.viewCache_),i=lp(this.writes_,r,t,1,s,e);return i.length===0?null:i[0]}}/**
1359
+ */class dp{getCompleteChild(e){return null}getChildAfterChild(e,t,s){return null}}const $a=new dp;class rr{constructor(e,t,s=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=s}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const s=this.optCompleteServerCache_!=null?new Fe(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return sr(this.writes_,e,s)}}getChildAfterChild(e,t,s){const r=this.optCompleteServerCache_!=null?this.optCompleteServerCache_:Me(this.viewCache_),i=hp(this.writes_,r,t,1,s,e);return i.length===0?null:i[0]}}/**
1360
1360
  * @license
1361
1361
  * Copyright 2017 Google LLC
1362
1362
  *
@@ -1371,7 +1371,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1371
1371
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1372
1372
  * See the License for the specific language governing permissions and
1373
1373
  * limitations under the License.
1374
- */function dp(n){return{filter:n}}function fp(n,e){m(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),m(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function pp(n,e,t,s,r){const i=new hp;let o,a;if(t.type===ae.OVERWRITE){const l=t;l.source.fromUser?o=Is(n,e,l.path,l.snap,s,r,i):(m(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered()&&!S(l.path),o=_n(n,e,l.path,l.snap,s,r,a,i))}else if(t.type===ae.MERGE){const l=t;l.source.fromUser?o=mp(n,e,l.path,l.children,s,r,i):(m(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered(),o=Ns(n,e,l.path,l.children,s,r,a,i))}else if(t.type===ae.ACK_USER_WRITE){const l=t;l.revert?o=Ep(n,e,l.path,s,r,i):o=gp(n,e,l.path,l.affectedTree,s,r,i)}else if(t.type===ae.LISTEN_COMPLETE)o=yp(n,e,t.path,s,i);else throw tt("Unknown operation type: "+t.type);const c=i.getChanges();return _p(e,o,c),{viewCache:o,changes:c}}function _p(n,e,t){const s=e.eventCache;if(s.isFullyInitialized()){const r=s.getNode().isLeafNode()||s.getNode().isEmpty(),i=Ss(n);(t.length>0||!n.eventCache.isFullyInitialized()||r&&!s.getNode().equals(i)||!s.getNode().getPriority().equals(i.getPriority()))&&t.push(Da(Ss(e)))}}function $a(n,e,t,s,r,i){const o=e.eventCache;if(pn(s,t)!=null)return e;{let a,c;if(S(t))if(m(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const l=Me(e),h=l instanceof E?l:E.EMPTY_NODE,u=sr(s,h);a=n.filter.updateFullNode(e.eventCache.getNode(),u,i)}else{const l=fn(s,Me(e));a=n.filter.updateFullNode(e.eventCache.getNode(),l,i)}else{const l=C(t);if(l===".priority"){m(Ce(t)===1,"Can't have a priority with additional path components");const h=o.getNode();c=e.serverCache.getNode();const u=yi(s,t,h,c);u!=null?a=n.filter.updatePriority(h,u):a=o.getNode()}else{const h=F(t);let u;if(o.isCompleteForChild(l)){c=e.serverCache.getNode();const d=yi(s,t,o.getNode(),c);d!=null?u=o.getNode().getImmediateChild(l).updateChild(h,d):u=o.getNode().getImmediateChild(l)}else u=rr(s,l,e.serverCache);u!=null?a=n.filter.updateChild(o.getNode(),l,u,h,r,i):a=o.getNode()}}return pt(e,a,o.isFullyInitialized()||S(t),n.filter.filtersNodes())}}function _n(n,e,t,s,r,i,o,a){const c=e.serverCache;let l;const h=o?n.filter:n.filter.getIndexedFilter();if(S(t))l=h.updateFullNode(c.getNode(),s,null);else if(h.filtersNodes()&&!c.isFiltered()){const _=c.getNode().updateChild(t,s);l=h.updateFullNode(c.getNode(),_,null)}else{const _=C(t);if(!c.isCompleteForPath(t)&&Ce(t)>1)return e;const p=F(t),g=c.getNode().getImmediateChild(_).updateChild(p,s);_===".priority"?l=h.updatePriority(c.getNode(),g):l=h.updateChild(c.getNode(),_,g,p,Va,null)}const u=Ma(e,l,c.isFullyInitialized()||S(t),h.filtersNodes()),d=new ir(r,u,i);return $a(n,u,t,r,d,a)}function Is(n,e,t,s,r,i,o){const a=e.eventCache;let c,l;const h=new ir(r,e,i);if(S(t))l=n.filter.updateFullNode(e.eventCache.getNode(),s,o),c=pt(e,l,!0,n.filter.filtersNodes());else{const u=C(t);if(u===".priority")l=n.filter.updatePriority(e.eventCache.getNode(),s),c=pt(e,l,a.isFullyInitialized(),a.isFiltered());else{const d=F(t),_=a.getNode().getImmediateChild(u);let p;if(S(d))p=s;else{const y=h.getCompleteChild(u);y!=null?Ta(d)===".priority"&&y.getChild(Ia(d)).isEmpty()?p=y:p=y.updateChild(d,s):p=E.EMPTY_NODE}if(_.equals(p))c=e;else{const y=n.filter.updateChild(a.getNode(),u,p,d,h,o);c=pt(e,y,a.isFullyInitialized(),n.filter.filtersNodes())}}}return c}function Ei(n,e){return n.eventCache.isCompleteForChild(e)}function mp(n,e,t,s,r,i,o){let a=e;return s.foreach((c,l)=>{const h=W(t,c);Ei(e,C(h))&&(a=Is(n,a,h,l,r,i,o))}),s.foreach((c,l)=>{const h=W(t,c);Ei(e,C(h))||(a=Is(n,a,h,l,r,i,o))}),a}function wi(n,e,t){return t.foreach((s,r)=>{e=e.updateChild(s,r)}),e}function Ns(n,e,t,s,r,i,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let c=e,l;S(t)?l=s:l=new M(null).setTree(t,s);const h=e.serverCache.getNode();return l.children.inorderTraversal((u,d)=>{if(h.hasChild(u)){const _=e.serverCache.getNode().getImmediateChild(u),p=wi(n,_,d);c=_n(n,c,new x(u),p,r,i,o,a)}}),l.children.inorderTraversal((u,d)=>{const _=!e.serverCache.isCompleteForChild(u)&&d.value===null;if(!h.hasChild(u)&&!_){const p=e.serverCache.getNode().getImmediateChild(u),y=wi(n,p,d);c=_n(n,c,new x(u),y,r,i,o,a)}}),c}function gp(n,e,t,s,r,i,o){if(pn(r,t)!=null)return e;const a=e.serverCache.isFiltered(),c=e.serverCache;if(s.value!=null){if(S(t)&&c.isFullyInitialized()||c.isCompleteForPath(t))return _n(n,e,t,c.getNode().getChild(t),r,i,a,o);if(S(t)){let l=new M(null);return c.getNode().forEachChild(je,(h,u)=>{l=l.set(new x(h),u)}),Ns(n,e,t,l,r,i,a,o)}else return e}else{let l=new M(null);return s.foreach((h,u)=>{const d=W(t,h);c.isCompleteForPath(d)&&(l=l.set(h,c.getNode().getChild(d)))}),Ns(n,e,t,l,r,i,a,o)}}function yp(n,e,t,s,r){const i=e.serverCache,o=Ma(e,i.getNode(),i.isFullyInitialized()||S(t),i.isFiltered());return $a(n,o,t,s,Va,r)}function Ep(n,e,t,s,r,i){let o;if(pn(s,t)!=null)return e;{const a=new ir(s,e,r),c=e.eventCache.getNode();let l;if(S(t)||C(t)===".priority"){let h;if(e.serverCache.isFullyInitialized())h=fn(s,Me(e));else{const u=e.serverCache.getNode();m(u instanceof E,"serverChildren would be complete if leaf node"),h=sr(s,u)}h=h,l=n.filter.updateFullNode(c,h,i)}else{const h=C(t);let u=rr(s,h,e.serverCache);u==null&&e.serverCache.isCompleteForChild(h)&&(u=c.getImmediateChild(h)),u!=null?l=n.filter.updateChild(c,h,u,F(t),a,i):e.eventCache.getNode().hasChild(h)?l=n.filter.updateChild(c,h,E.EMPTY_NODE,F(t),a,i):l=c,l.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=fn(s,Me(e)),o.isLeafNode()&&(l=n.filter.updateFullNode(l,o,i)))}return o=e.serverCache.isFullyInitialized()||pn(s,N())!=null,pt(e,l,o,n.filter.filtersNodes())}}/**
1374
+ */function fp(n){return{filter:n}}function pp(n,e){m(e.eventCache.getNode().isIndexed(n.filter.getIndex()),"Event snap not indexed"),m(e.serverCache.getNode().isIndexed(n.filter.getIndex()),"Server snap not indexed")}function _p(n,e,t,s,r){const i=new up;let o,a;if(t.type===ae.OVERWRITE){const l=t;l.source.fromUser?o=Is(n,e,l.path,l.snap,s,r,i):(m(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered()&&!S(l.path),o=_n(n,e,l.path,l.snap,s,r,a,i))}else if(t.type===ae.MERGE){const l=t;l.source.fromUser?o=gp(n,e,l.path,l.children,s,r,i):(m(l.source.fromServer,"Unknown source."),a=l.source.tagged||e.serverCache.isFiltered(),o=Ns(n,e,l.path,l.children,s,r,a,i))}else if(t.type===ae.ACK_USER_WRITE){const l=t;l.revert?o=wp(n,e,l.path,s,r,i):o=yp(n,e,l.path,l.affectedTree,s,r,i)}else if(t.type===ae.LISTEN_COMPLETE)o=Ep(n,e,t.path,s,i);else throw tt("Unknown operation type: "+t.type);const c=i.getChanges();return mp(e,o,c),{viewCache:o,changes:c}}function mp(n,e,t){const s=e.eventCache;if(s.isFullyInitialized()){const r=s.getNode().isLeafNode()||s.getNode().isEmpty(),i=Ss(n);(t.length>0||!n.eventCache.isFullyInitialized()||r&&!s.getNode().equals(i)||!s.getNode().getPriority().equals(i.getPriority()))&&t.push(La(Ss(e)))}}function za(n,e,t,s,r,i){const o=e.eventCache;if(pn(s,t)!=null)return e;{let a,c;if(S(t))if(m(e.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),e.serverCache.isFiltered()){const l=Me(e),h=l instanceof E?l:E.EMPTY_NODE,u=nr(s,h);a=n.filter.updateFullNode(e.eventCache.getNode(),u,i)}else{const l=fn(s,Me(e));a=n.filter.updateFullNode(e.eventCache.getNode(),l,i)}else{const l=C(t);if(l===".priority"){m(Ce(t)===1,"Can't have a priority with additional path components");const h=o.getNode();c=e.serverCache.getNode();const u=gi(s,t,h,c);u!=null?a=n.filter.updatePriority(h,u):a=o.getNode()}else{const h=F(t);let u;if(o.isCompleteForChild(l)){c=e.serverCache.getNode();const d=gi(s,t,o.getNode(),c);d!=null?u=o.getNode().getImmediateChild(l).updateChild(h,d):u=o.getNode().getImmediateChild(l)}else u=sr(s,l,e.serverCache);u!=null?a=n.filter.updateChild(o.getNode(),l,u,h,r,i):a=o.getNode()}}return pt(e,a,o.isFullyInitialized()||S(t),n.filter.filtersNodes())}}function _n(n,e,t,s,r,i,o,a){const c=e.serverCache;let l;const h=o?n.filter:n.filter.getIndexedFilter();if(S(t))l=h.updateFullNode(c.getNode(),s,null);else if(h.filtersNodes()&&!c.isFiltered()){const _=c.getNode().updateChild(t,s);l=h.updateFullNode(c.getNode(),_,null)}else{const _=C(t);if(!c.isCompleteForPath(t)&&Ce(t)>1)return e;const p=F(t),g=c.getNode().getImmediateChild(_).updateChild(p,s);_===".priority"?l=h.updatePriority(c.getNode(),g):l=h.updateChild(c.getNode(),_,g,p,$a,null)}const u=Ba(e,l,c.isFullyInitialized()||S(t),h.filtersNodes()),d=new rr(r,u,i);return za(n,u,t,r,d,a)}function Is(n,e,t,s,r,i,o){const a=e.eventCache;let c,l;const h=new rr(r,e,i);if(S(t))l=n.filter.updateFullNode(e.eventCache.getNode(),s,o),c=pt(e,l,!0,n.filter.filtersNodes());else{const u=C(t);if(u===".priority")l=n.filter.updatePriority(e.eventCache.getNode(),s),c=pt(e,l,a.isFullyInitialized(),a.isFiltered());else{const d=F(t),_=a.getNode().getImmediateChild(u);let p;if(S(d))p=s;else{const y=h.getCompleteChild(u);y!=null?Ra(d)===".priority"&&y.getChild(Na(d)).isEmpty()?p=y:p=y.updateChild(d,s):p=E.EMPTY_NODE}if(_.equals(p))c=e;else{const y=n.filter.updateChild(a.getNode(),u,p,d,h,o);c=pt(e,y,a.isFullyInitialized(),n.filter.filtersNodes())}}}return c}function yi(n,e){return n.eventCache.isCompleteForChild(e)}function gp(n,e,t,s,r,i,o){let a=e;return s.foreach((c,l)=>{const h=W(t,c);yi(e,C(h))&&(a=Is(n,a,h,l,r,i,o))}),s.foreach((c,l)=>{const h=W(t,c);yi(e,C(h))||(a=Is(n,a,h,l,r,i,o))}),a}function Ei(n,e,t){return t.foreach((s,r)=>{e=e.updateChild(s,r)}),e}function Ns(n,e,t,s,r,i,o,a){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let c=e,l;S(t)?l=s:l=new M(null).setTree(t,s);const h=e.serverCache.getNode();return l.children.inorderTraversal((u,d)=>{if(h.hasChild(u)){const _=e.serverCache.getNode().getImmediateChild(u),p=Ei(n,_,d);c=_n(n,c,new D(u),p,r,i,o,a)}}),l.children.inorderTraversal((u,d)=>{const _=!e.serverCache.isCompleteForChild(u)&&d.value===null;if(!h.hasChild(u)&&!_){const p=e.serverCache.getNode().getImmediateChild(u),y=Ei(n,p,d);c=_n(n,c,new D(u),y,r,i,o,a)}}),c}function yp(n,e,t,s,r,i,o){if(pn(r,t)!=null)return e;const a=e.serverCache.isFiltered(),c=e.serverCache;if(s.value!=null){if(S(t)&&c.isFullyInitialized()||c.isCompleteForPath(t))return _n(n,e,t,c.getNode().getChild(t),r,i,a,o);if(S(t)){let l=new M(null);return c.getNode().forEachChild(je,(h,u)=>{l=l.set(new D(h),u)}),Ns(n,e,t,l,r,i,a,o)}else return e}else{let l=new M(null);return s.foreach((h,u)=>{const d=W(t,h);c.isCompleteForPath(d)&&(l=l.set(h,c.getNode().getChild(d)))}),Ns(n,e,t,l,r,i,a,o)}}function Ep(n,e,t,s,r){const i=e.serverCache,o=Ba(e,i.getNode(),i.isFullyInitialized()||S(t),i.isFiltered());return za(n,o,t,s,$a,r)}function wp(n,e,t,s,r,i){let o;if(pn(s,t)!=null)return e;{const a=new rr(s,e,r),c=e.eventCache.getNode();let l;if(S(t)||C(t)===".priority"){let h;if(e.serverCache.isFullyInitialized())h=fn(s,Me(e));else{const u=e.serverCache.getNode();m(u instanceof E,"serverChildren would be complete if leaf node"),h=nr(s,u)}h=h,l=n.filter.updateFullNode(c,h,i)}else{const h=C(t);let u=sr(s,h,e.serverCache);u==null&&e.serverCache.isCompleteForChild(h)&&(u=c.getImmediateChild(h)),u!=null?l=n.filter.updateChild(c,h,u,F(t),a,i):e.eventCache.getNode().hasChild(h)?l=n.filter.updateChild(c,h,E.EMPTY_NODE,F(t),a,i):l=c,l.isEmpty()&&e.serverCache.isFullyInitialized()&&(o=fn(s,Me(e)),o.isLeafNode()&&(l=n.filter.updateFullNode(l,o,i)))}return o=e.serverCache.isFullyInitialized()||pn(s,N())!=null,pt(e,l,o,n.filter.filtersNodes())}}/**
1375
1375
  * @license
1376
1376
  * Copyright 2017 Google LLC
1377
1377
  *
@@ -1386,7 +1386,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1386
1386
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1387
1387
  * See the License for the specific language governing permissions and
1388
1388
  * limitations under the License.
1389
- */class wp{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const s=this.query_._queryParams,r=new Xs(s.getIndex()),i=Uf(s);this.processor_=dp(i);const o=t.serverCache,a=t.eventCache,c=r.updateFullNode(E.EMPTY_NODE,o.getNode(),null),l=i.updateFullNode(E.EMPTY_NODE,a.getNode(),null),h=new Fe(c,o.isFullyInitialized(),r.filtersNodes()),u=new Fe(l,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=xn(u,h),this.eventGenerator_=new jf(this.query_)}get query(){return this.query_}}function vp(n){return n.viewCache_.serverCache.getNode()}function bp(n,e){const t=Me(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!S(e)&&!t.getImmediateChild(C(e)).isEmpty())?t.getChild(e):null}function vi(n){return n.eventRegistrations_.length===0}function Cp(n,e){n.eventRegistrations_.push(e)}function bi(n,e,t){const s=[];if(t){m(e==null,"A cancel should cancel all event registrations.");const r=n.query._path;n.eventRegistrations_.forEach(i=>{const o=i.createCancelEvent(t,r);o&&s.push(o)})}if(e){let r=[];for(let i=0;i<n.eventRegistrations_.length;++i){const o=n.eventRegistrations_[i];if(!o.matches(e))r.push(o);else if(e.hasAnyCallback()){r=r.concat(n.eventRegistrations_.slice(i+1));break}}n.eventRegistrations_=r}else n.eventRegistrations_=[];return s}function Ci(n,e,t,s){e.type===ae.MERGE&&e.source.queryId!==null&&(m(Me(n.viewCache_),"We should always have a full cache before handling merges"),m(Ss(n.viewCache_),"Missing event cache, even though we have a server cache"));const r=n.viewCache_,i=pp(n.processor_,r,e,t,s);return fp(n.processor_,i.viewCache),m(i.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=i.viewCache,za(n,i.changes,i.viewCache.eventCache.getNode(),null)}function Sp(n,e){const t=n.viewCache_.eventCache,s=[];return t.getNode().isLeafNode()||t.getNode().forEachChild(U,(i,o)=>{s.push(Qe(i,o))}),t.isFullyInitialized()&&s.push(Da(t.getNode())),za(n,s,t.getNode(),e)}function za(n,e,t,s){const r=s?[s]:n.eventRegistrations_;return Kf(n.eventGenerator_,e,t,r)}/**
1389
+ */class vp{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const s=this.query_._queryParams,r=new Js(s.getIndex()),i=Hf(s);this.processor_=fp(i);const o=t.serverCache,a=t.eventCache,c=r.updateFullNode(E.EMPTY_NODE,o.getNode(),null),l=i.updateFullNode(E.EMPTY_NODE,a.getNode(),null),h=new Fe(c,o.isFullyInitialized(),r.filtersNodes()),u=new Fe(l,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=xn(u,h),this.eventGenerator_=new Kf(this.query_)}get query(){return this.query_}}function bp(n){return n.viewCache_.serverCache.getNode()}function Cp(n,e){const t=Me(n.viewCache_);return t&&(n.query._queryParams.loadsAllData()||!S(e)&&!t.getImmediateChild(C(e)).isEmpty())?t.getChild(e):null}function wi(n){return n.eventRegistrations_.length===0}function Sp(n,e){n.eventRegistrations_.push(e)}function vi(n,e,t){const s=[];if(t){m(e==null,"A cancel should cancel all event registrations.");const r=n.query._path;n.eventRegistrations_.forEach(i=>{const o=i.createCancelEvent(t,r);o&&s.push(o)})}if(e){let r=[];for(let i=0;i<n.eventRegistrations_.length;++i){const o=n.eventRegistrations_[i];if(!o.matches(e))r.push(o);else if(e.hasAnyCallback()){r=r.concat(n.eventRegistrations_.slice(i+1));break}}n.eventRegistrations_=r}else n.eventRegistrations_=[];return s}function bi(n,e,t,s){e.type===ae.MERGE&&e.source.queryId!==null&&(m(Me(n.viewCache_),"We should always have a full cache before handling merges"),m(Ss(n.viewCache_),"Missing event cache, even though we have a server cache"));const r=n.viewCache_,i=_p(n.processor_,r,e,t,s);return pp(n.processor_,i.viewCache),m(i.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),n.viewCache_=i.viewCache,ja(n,i.changes,i.viewCache.eventCache.getNode(),null)}function Tp(n,e){const t=n.viewCache_.eventCache,s=[];return t.getNode().isLeafNode()||t.getNode().forEachChild(U,(i,o)=>{s.push(Qe(i,o))}),t.isFullyInitialized()&&s.push(La(t.getNode())),ja(n,s,t.getNode(),e)}function ja(n,e,t,s){const r=s?[s]:n.eventRegistrations_;return Gf(n.eventGenerator_,e,t,r)}/**
1390
1390
  * @license
1391
1391
  * Copyright 2017 Google LLC
1392
1392
  *
@@ -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 Tp{constructor(){this.views=new Map}}function Rp(n){m(!mn,"__referenceConstructor has already been defined"),mn=n}function Ip(){return m(mn,"Reference.ts has not been loaded"),mn}function Np(n){return n.views.size===0}function or(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."),Ci(i,e,t,s)}else{let i=[];for(const o of n.views.values())i=i.concat(Ci(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=sr(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 wp(e,l)}return o}function Ap(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),Cp(o,t),Sp(o,t)}function Op(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(bi(l,t,s)),vi(l)&&(n.views.delete(c),l.query._queryParams.loadsAllData()||i.push(l.query));else{const c=n.views.get(r);c&&(o=o.concat(bi(c,t,s)),vi(c)&&(n.views.delete(r),c.query._queryParams.loadsAllData()||i.push(c.query)))}return a&&!Se(n)&&i.push(new(Ip())(e._repo,e._path)),{removed:i,events:o}}function ja(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||bp(s,e);return t}function Ka(n,e){if(e._queryParams.loadsAllData())return Pn(n);{const s=e._queryIdentifier;return n.views.get(s)}}function Ga(n,e){return Ka(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 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}/**
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 xp(n){m(!gn,"__referenceConstructor has already been defined"),gn=n}function Pp(){return m(gn,"Reference.ts has not been loaded"),gn}let Dp=1;class Si{constructor(e){this.listenProvider_=e,this.syncPointTree_=new M(null),this.pendingWriteTree_=cp(),this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Lp(n,e,t,s,r){return Jf(n.pendingWriteTree_,e,t,s,r),r?Lt(n,new Le(Fa(),e,t)):[]}function qe(n,e,t=!1){const s=Xf(n.pendingWriteTree_,e);if(Zf(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 x(o),!0)}),Lt(n,new dn(s.path,i,t))}else return[]}function Dn(n,e,t){return Lt(n,new Le(er(),e,t))}function Fp(n,e,t){const s=M.fromObject(t);return Lt(n,new Rt(er(),e,s))}function Mp(n,e){return Lt(n,new Tt(er(),e))}function Bp(n,e,t){const s=ar(n,t);if(s){const r=cr(s),i=r.path,o=r.queryId,a=Q(i,e),c=new Tt(tr(o),a);return lr(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"||Ga(o,e))){const c=Op(o,e,t,s);Np(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 _=Wp(d);for(let p=0;p<_.length;++p){const y=_[p],g=y.query,I=Xa(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),_)}))}qp(n,l)}return a}function Up(n,e,t,s){const r=ar(n,s);if(r!=null){const i=cr(r),o=i.path,a=i.queryId,c=Q(o,e),l=new Le(tr(a),c,t);return lr(n,o,l)}else return[]}function Hp(n,e,t,s){const r=ar(n,s);if(r){const i=cr(r),o=i.path,a=i.queryId,c=Q(o,e),l=M.fromObject(t),h=new Rt(tr(a),c,l);return lr(n,o,h)}else return[]}function Ti(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 Tp,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=Ga(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 _=Vp();n.queryToTagMap.set(d,_),n.tagToQueryMap.set(_,d)}const h=nr(n.pendingWriteTree_,r);let u=Ap(a,e,t,h,i,c);if(!l&&!o&&!s){const d=Ka(a,e);u=u.concat($p(n,e,d))}return u}function Ya(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 Ha(r,e,i,t,!0)}function Lt(n,e){return Qa(e,n.syncPointTree_,null,nr(n.pendingWriteTree_,N()))}function Qa(n,e,t,s){if(S(n.path))return Ja(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=Wa(s,o);i=i.concat(Qa(a,c,l,h))}return r&&(i=i.concat(or(r,n,s,t))),i}}function Ja(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=Wa(s,o),h=n.operationForChild(o);h&&(i=i.concat(Ja(h,a,c,l)))}),r&&(i=i.concat(or(r,n,s,t))),i}function Xa(n,e){const t=e.query,s=yn(n,t);return{hashFn:()=>(vp(e)||E.EMPTY_NODE).hash(),onComplete:r=>{if(r==="ok")return s?Bp(n,t._path,s):Mp(n,t._path);{const i=Md(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 ar(n,e){return n.tagToQueryMap.get(e)}function cr(n){const e=n.indexOf("$");return m(e!==-1&&e<n.length-1,"Bad queryKey."),{queryId:n.substr(e+1),path:new x(n.substr(0,e))}}function lr(n,e,t){const s=n.syncPointTree_.get(e);m(s,"Missing sync point for query tag that we're tracking");const r=nr(n.pendingWriteTree_,e);return or(s,t,r,null)}function Wp(n){return n.fold((e,t,s)=>{if(t&&Se(t))return[Pn(t)];{let r=[];return t&&(r=ja(t)),Z(s,(i,o)=>{r=r.concat(o)}),r}})}function mt(n){return n._queryParams.loadsAllData()&&!n._queryParams.isDefault()?new(Pp())(n._repo,n._path):n}function qp(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 Vp(){return Dp++}function $p(n,e,t){const s=e._path,r=yn(n,e),i=Xa(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(ja(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 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}/**
1420
1420
  * @license
1421
1421
  * Copyright 2017 Google LLC
1422
1422
  *
@@ -1431,7 +1431,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1431
1431
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1432
1432
  * See the License for the specific language governing permissions and
1433
1433
  * limitations under the License.
1434
- */class hr{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new hr(t)}node(){return this.node_}}class ur{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=W(this.path_,e);return new ur(this.syncTree_,t)}node(){return Ya(this.syncTree_,this.path_)}}const zp=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},Ri=function(n,e,t){if(!n||typeof n!="object")return n;if(m(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return jp(n[".sv"],e,t);if(typeof n[".sv"]=="object")return Kp(n[".sv"],e);m(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},jp=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:m(!1,"Unexpected server value: "+n)}},Kp=function(n,e,t){n.hasOwnProperty("increment")||m(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const s=n.increment;typeof s!="number"&&m(!1,"Unexpected increment value: "+s);const r=e.node();if(m(r!==null&&typeof r<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return s;const o=r.getValue();return typeof o!="number"?s:o+s},Gp=function(n,e,t,s){return dr(e,new ur(t,n),s)},Yp=function(n,e,t){return dr(n,new hr(e),t)};function dr(n,e,t){const s=n.getPriority().val(),r=Ri(s,e.getImmediateChild(".priority"),t);let i;if(n.isLeafNode()){const o=n,a=Ri(o.getValue(),e,t);return a!==o.getValue()||r!==o.getPriority().val()?new q(a,j(r)):n}else{const o=n;return i=o,r!==o.getPriority().val()&&(i=i.updatePriority(new q(r))),o.forEachChild(U,(a,c)=>{const l=dr(c,e.getImmediateChild(a),t);l!==c&&(i=i.updateImmediateChild(a,l))}),i}}/**
1434
+ */class lr{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new lr(t)}node(){return this.node_}}class hr{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=W(this.path_,e);return new hr(this.syncTree_,t)}node(){return Qa(this.syncTree_,this.path_)}}const jp=function(n){return n=n||{},n.timestamp=n.timestamp||new Date().getTime(),n},Ti=function(n,e,t){if(!n||typeof n!="object")return n;if(m(".sv"in n,"Unexpected leaf node or priority contents"),typeof n[".sv"]=="string")return Kp(n[".sv"],e,t);if(typeof n[".sv"]=="object")return Gp(n[".sv"],e);m(!1,"Unexpected server value: "+JSON.stringify(n,null,2))},Kp=function(n,e,t){switch(n){case"timestamp":return t.timestamp;default:m(!1,"Unexpected server value: "+n)}},Gp=function(n,e,t){n.hasOwnProperty("increment")||m(!1,"Unexpected server value: "+JSON.stringify(n,null,2));const s=n.increment;typeof s!="number"&&m(!1,"Unexpected increment value: "+s);const r=e.node();if(m(r!==null&&typeof r<"u","Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return s;const o=r.getValue();return typeof o!="number"?s:o+s},Yp=function(n,e,t,s){return ur(e,new hr(t,n),s)},Qp=function(n,e,t){return ur(n,new lr(e),t)};function ur(n,e,t){const s=n.getPriority().val(),r=Ti(s,e.getImmediateChild(".priority"),t);let i;if(n.isLeafNode()){const o=n,a=Ti(o.getValue(),e,t);return a!==o.getValue()||r!==o.getPriority().val()?new q(a,j(r)):n}else{const o=n;return i=o,r!==o.getPriority().val()&&(i=i.updatePriority(new q(r))),o.forEachChild(U,(a,c)=>{const l=ur(c,e.getImmediateChild(a),t);l!==c&&(i=i.updateImmediateChild(a,l))}),i}}/**
1435
1435
  * @license
1436
1436
  * Copyright 2017 Google LLC
1437
1437
  *
@@ -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 fr{constructor(e="",t=null,s={children:{},childCount:0}){this.name=e,this.parent=t,this.node=s}}function pr(n,e){let t=e instanceof x?e:new x(e),s=n,r=C(t);for(;r!==null;){const i=Ge(s.node.children,r)||{children:{},childCount:0};s=new fr(r,s,i),t=F(t),r=C(t)}return s}function st(n){return n.node.value}function Za(n,e){n.node.value=e,As(n)}function ec(n){return n.node.childCount>0}function Qp(n){return st(n)===void 0&&!ec(n)}function Fn(n,e){Z(n.node.children,(t,s)=>{e(new fr(t,n,s))})}function tc(n,e,t,s){t&&e(n),Fn(n,r=>{tc(r,e,!0)})}function Jp(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 x(n.parent===null?n.name:Ft(n.parent)+"/"+n.name)}function As(n){n.parent!==null&&Xp(n.parent,n.name,n)}function Xp(n,e,t){const s=Qp(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,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))}/**
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 Zp=/[\[\].#$\/\u0000-\u001F\u007F]/,e_=/[\[\].#$\u0000-\u001F\u007F]/,es=10*1024*1024,nc=function(n){return typeof n=="string"&&n.length!==0&&!Zp.test(n)},sc=function(n){return typeof n=="string"&&n.length!==0&&!e_.test(n)},t_=function(n){return n&&(n=n.replace(/^\/*\.info(\/|$)/,"/")),sc(n)},rc=function(n,e,t){const s=t instanceof x?new gf(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(ra(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,!nc(o)))throw new Error(n+" contains an invalid key ("+o+") "+Ie(s)+`. Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"`);yf(s,o),rc(n,a,s),Ef(s)}),r&&i)throw new Error(n+' contains ".value" child '+Ie(s)+" in addition to actual children.")}},ic=function(n,e,t,s){if(!sc(t))throw new Error(Go(n,e)+'was an invalid path = "'+t+`". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"`)},n_=function(n,e,t,s){t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),ic(n,e,t)},s_=function(n,e){const t=e.path.toString();if(typeof e.repoInfo.host!="string"||e.repoInfo.host.length===0||!nc(e.repoInfo.namespace)&&e.repoInfo.host.split(":")[0]!=="localhost"||t.length!==0&&!t_(t))throw new Error(Go(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&&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 "]".`)};/**
1465
1465
  * @license
1466
1466
  * Copyright 2017 Google LLC
1467
1467
  *
@@ -1476,7 +1476,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1476
1476
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1477
1477
  * See the License for the specific language governing permissions and
1478
1478
  * limitations under the License.
1479
- */class r_{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function oc(n,e){let t=null;for(let s=0;s<e.length;s++){const r=e[s],i=r.getPath();t!==null&&!Ys(i,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:i}),t.events.push(r)}t&&n.eventLists_.push(t)}function ac(n,e,t){oc(n,t),cc(n,s=>Ys(s,e))}function Ue(n,e,t){oc(n,t),cc(n,s=>oe(s,e)||oe(e,s))}function cc(n,e){n.recursionDepth_++;let t=!0;for(let s=0;s<n.eventLists_.length;s++){const r=n.eventLists_[s];if(r){const i=r.path;e(i)?(i_(n.eventLists_[s]),n.eventLists_[s]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function i_(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const s=t.getEventRunner();dt&&z("event: "+t.toString()),Pt(s)}}}/**
1479
+ */class i_{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function ac(n,e){let t=null;for(let s=0;s<e.length;s++){const r=e[s],i=r.getPath();t!==null&&!Gs(i,t.path)&&(n.eventLists_.push(t),t=null),t===null&&(t={events:[],path:i}),t.events.push(r)}t&&n.eventLists_.push(t)}function cc(n,e,t){ac(n,t),lc(n,s=>Gs(s,e))}function Ue(n,e,t){ac(n,t),lc(n,s=>oe(s,e)||oe(e,s))}function lc(n,e){n.recursionDepth_++;let t=!0;for(let s=0;s<n.eventLists_.length;s++){const r=n.eventLists_[s];if(r){const i=r.path;e(i)?(o_(n.eventLists_[s]),n.eventLists_[s]=null):t=!1}}t&&(n.eventLists_=[]),n.recursionDepth_--}function o_(n){for(let e=0;e<n.events.length;e++){const t=n.events[e];if(t!==null){n.events[e]=null;const s=t.getEventRunner();dt&&z("event: "+t.toString()),Pt(s)}}}/**
1480
1480
  * @license
1481
1481
  * Copyright 2017 Google LLC
1482
1482
  *
@@ -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 o_="repo_interrupt",a_=25;class c_{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 r_,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=un(),this.transactionQueueTree_=new fr,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function l_(n,e,t){if(n.stats_=Ks(n.repoInfo_),n.forceRestClient_||Wd())n.server_=new hn(n.repoInfo_,(s,r,i,o)=>{Ii(n,s,r,i,o)},n.authTokenProvider_,n.appCheckProvider_),setTimeout(()=>Ni(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)=>{Ii(n,s,r,i,o)},s=>{Ni(n,s)},s=>{u_(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_=jd(n.repoInfo_,()=>new zf(n.stats_,n.server_)),n.infoData_=new Hf,n.infoSyncTree_=new Si({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:()=>{}}),_r(n,"connected",!1),n.serverSyncTree_=new Si({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 h_(n){const t=n.infoData_.getNode(new x(".info/serverTimeOffset")).val()||0;return new Date().getTime()+t}function lc(n){return zp({timestamp:h_(n)})}function Ii(n,e,t,s,r){n.dataUpdateCount++;const i=new x(e);t=n.interceptServerDataCallback_?n.interceptServerDataCallback_(e,t):t;let o=[];if(r)if(s){const c=nn(t,l=>j(l));o=Hp(n.serverSyncTree_,i,c,r)}else{const c=j(t);o=Up(n.serverSyncTree_,i,c,r)}else if(s){const c=nn(t,l=>j(l));o=Fp(n.serverSyncTree_,i,c)}else{const c=j(t);o=Dn(n.serverSyncTree_,i,c)}let a=i;o.length>0&&(a=gr(n,i)),Ue(n.eventQueue_,a,o)}function Ni(n,e){_r(n,"connected",e),e===!1&&f_(n)}function u_(n,e){Z(e,(t,s)=>{_r(n,t,s)})}function _r(n,e,t){const s=new x("/.info/"+e),r=j(t);n.infoData_.updateSnapshot(s,r);const i=Dn(n.infoSyncTree_,s,r);Ue(n.eventQueue_,s,i)}function d_(n){return n.nextWriteId_++}function f_(n){hc(n,"onDisconnectEvents");const e=lc(n),t=un();Cs(n.onDisconnect_,N(),(r,i)=>{const o=Gp(r,i,n.serverSyncTree_,e);La(t,r,o)});let s=[];Cs(t,N(),(r,i)=>{s=s.concat(Dn(n.serverSyncTree_,r,i));const o=E_(n,r);gr(n,o)}),n.onDisconnect_=un(),Ue(n.eventQueue_,N(),s)}function p_(n,e,t){let s;C(e._path)===".info"?s=Ti(n.infoSyncTree_,e,t):s=Ti(n.serverSyncTree_,e,t),ac(n.eventQueue_,e._path,s)}function __(n,e,t){let s;C(e._path)===".info"?s=ks(n.infoSyncTree_,e,t):s=ks(n.serverSyncTree_,e,t),ac(n.eventQueue_,e._path,s)}function m_(n){n.persistentConnection_&&n.persistentConnection_.interrupt(o_)}function hc(n,...e){let t="";n.persistentConnection_&&(t=n.persistentConnection_.id+":"),z(t,...e)}function uc(n,e,t){return Ya(n.serverSyncTree_,e,t)||E.EMPTY_NODE}function mr(n,e=n.transactionQueueTree_){if(e||Mn(n,e),st(e)){const t=fc(n,e);m(t.length>0,"Sending zero length transaction queue"),t.every(r=>r.status===0)&&g_(n,Ft(e),t)}else ec(e)&&Fn(e,t=>{mr(n,t)})}function g_(n,e,t){const s=t.map(l=>l.currentWriteId),r=uc(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=>{hc(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,pr(n.transactionQueueTree_,e)),mr(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}gr(n,e)}},o)}function gr(n,e){const t=dc(n,e),s=Ft(t),r=fc(n,t);return y_(n,r,s),s}function y_(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>=a_)h=!0,u="maxretry",r=r.concat(qe(n.serverSyncTree_,c.currentWriteId,!0));else{const d=uc(n,c.path,o);c.currentInputSnapshot=d;const _=e[a].update(d.val());if(_!==void 0){rc("transaction failed: Data returned ",_,c.path);let p=j(_);typeof _=="object"&&_!=null&&me(_,".priority")||(p=p.updatePriority(d.getPriority()));const g=c.currentWriteId,I=lc(n),O=Yp(p,d,I);c.currentOutputSnapshotRaw=p,c.currentOutputSnapshotResolved=O,c.currentWriteId=d_(n),o.splice(o.indexOf(g),1),r=r.concat(Lp(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]);mr(n,n.transactionQueueTree_)}function dc(n,e){let t,s=n.transactionQueueTree_;for(t=C(e);t!==null&&st(s)===void 0;)s=pr(s,t),e=F(e),t=C(e);return s}function fc(n,e){const t=[];return pc(n,e,t),t.sort((s,r)=>s.order-r.order),t}function pc(n,e,t){const s=st(e);if(s)for(let r=0;r<s.length;r++)t.push(s[r]);Fn(e,r=>{pc(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,Za(e,t.length>0?t:void 0)}Fn(e,s=>{Mn(n,s)})}function E_(n,e){const t=Ft(dc(n,e)),s=pr(n.transactionQueueTree_,e);return Jp(s,r=>{ts(n,r)}),ts(n,s),tc(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?Za(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=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])}}/**
1495
1495
  * @license
1496
1496
  * Copyright 2017 Google LLC
1497
1497
  *
@@ -1506,7 +1506,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1506
1506
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1507
1507
  * See the License for the specific language governing permissions and
1508
1508
  * limitations under the License.
1509
- */function w_(n){let e="";const t=n.split("/");for(let s=0;s<t.length;s++)if(t[s].length>0){let r=t[s];try{r=decodeURIComponent(r.replace(/\+/g," "))}catch{}e+="/"+r}return e}function v_(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const s=t.split("=");s.length===2?e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):te(`Invalid query segment '${t}' in query '${n}'`)}return e}const ki=function(n,e){const t=b_(n),s=t.namespace;t.domain==="firebase.com"&&_e(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!s||s==="undefined")&&t.domain!=="localhost"&&_e("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||xd();const r=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new ma(t.host,t.secure,s,r,e,"",s!==t.subdomain),path:new x(t.pathString)}},b_=function(n){let e="",t="",s="",r="",i="",o=!0,a="https",c=443;if(typeof n=="string"){let l=n.indexOf("//");l>=0&&(a=n.substring(0,l-1),n=n.substring(l+2));let h=n.indexOf("/");h===-1&&(h=n.length);let u=n.indexOf("?");u===-1&&(u=n.length),e=n.substring(0,Math.min(h,u)),h<u&&(r=w_(n.substring(h,u)));const d=v_(n.substring(Math.min(n.length,u)));l=e.indexOf(":"),l>=0?(o=a==="https"||a==="wss",c=parseInt(e.substring(l+1),10)):l=e.length;const _=e.slice(0,l);if(_.toLowerCase()==="localhost")t="localhost";else if(_.split(".").length<=2)t=_;else{const p=e.indexOf(".");s=e.substring(0,p).toLowerCase(),t=e.substring(p+1),i=s}"ns"in d&&(i=d.ns)}return{host:e,port:c,domain:t,subdomain:s,secure:o,scheme:a,pathString:r,namespace:i}};/**
1509
+ */function v_(n){let e="";const t=n.split("/");for(let s=0;s<t.length;s++)if(t[s].length>0){let r=t[s];try{r=decodeURIComponent(r.replace(/\+/g," "))}catch{}e+="/"+r}return e}function b_(n){const e={};n.charAt(0)==="?"&&(n=n.substring(1));for(const t of n.split("&")){if(t.length===0)continue;const s=t.split("=");s.length===2?e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):te(`Invalid query segment '${t}' in query '${n}'`)}return e}const Ni=function(n,e){const t=C_(n),s=t.namespace;t.domain==="firebase.com"&&_e(t.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),(!s||s==="undefined")&&t.domain!=="localhost"&&_e("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),t.secure||Pd();const r=t.scheme==="ws"||t.scheme==="wss";return{repoInfo:new ga(t.host,t.secure,s,r,e,"",s!==t.subdomain),path:new D(t.pathString)}},C_=function(n){let e="",t="",s="",r="",i="",o=!0,a="https",c=443;if(typeof n=="string"){let l=n.indexOf("//");l>=0&&(a=n.substring(0,l-1),n=n.substring(l+2));let h=n.indexOf("/");h===-1&&(h=n.length);let u=n.indexOf("?");u===-1&&(u=n.length),e=n.substring(0,Math.min(h,u)),h<u&&(r=v_(n.substring(h,u)));const d=b_(n.substring(Math.min(n.length,u)));l=e.indexOf(":"),l>=0?(o=a==="https"||a==="wss",c=parseInt(e.substring(l+1),10)):l=e.length;const _=e.slice(0,l);if(_.toLowerCase()==="localhost")t="localhost";else if(_.split(".").length<=2)t=_;else{const p=e.indexOf(".");s=e.substring(0,p).toLowerCase(),t=e.substring(p+1),i=s}"ns"in d&&(i=d.ns)}return{host:e,port:c,domain:t,subdomain:s,secure:o,scheme:a,pathString:r,namespace:i}};/**
1510
1510
  * @license
1511
1511
  * Copyright 2017 Google LLC
1512
1512
  *
@@ -1521,7 +1521,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1521
1521
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1522
1522
  * See the License for the specific language governing permissions and
1523
1523
  * limitations under the License.
1524
- */class _c{constructor(e,t,s,r){this.eventType=e,this.eventRegistration=t,this.snapshot=s,this.prevName=r}getPath(){const e=this.snapshot.ref;return this.eventType==="value"?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+$(this.snapshot.exportVal())}}class mc{constructor(e,t,s){this.eventRegistration=e,this.error=t,this.path=s}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}/**
1524
+ */class mc{constructor(e,t,s,r){this.eventType=e,this.eventRegistration=t,this.snapshot=s,this.prevName=r}getPath(){const e=this.snapshot.ref;return this.eventType==="value"?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+$(this.snapshot.exportVal())}}class gc{constructor(e,t,s){this.eventRegistration=e,this.error=t,this.path=s}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}/**
1525
1525
  * @license
1526
1526
  * Copyright 2017 Google LLC
1527
1527
  *
@@ -1536,7 +1536,7 @@ FIREBASE: `))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of t
1536
1536
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1537
1537
  * See the License for the specific language governing permissions and
1538
1538
  * limitations under the License.
1539
- */class C_{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return m(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}/**
1539
+ */class S_{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return m(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||this.snapshotCallback.userCallback!==void 0&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}/**
1540
1540
  * @license
1541
1541
  * Copyright 2020 Google LLC
1542
1542
  *
@@ -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 yr{constructor(e,t,s,r){this._repo=e,this._path=t,this._queryParams=s,this._orderByCalled=r}get key(){return S(this._path)?null:Ta(this._path)}get ref(){return new ge(this._repo,this._path)}get _queryIdentifier(){const e=fi(this._queryParams),t=zs(e);return t==="{}"?"default":t}get _queryObject(){return fi(this._queryParams)}isEqual(e){if(e=An(e),!(e instanceof yr))return!1;const t=this._repo===e._repo,s=Ys(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return t&&s&&r}toJSON(){return this.toString()}toString(){return this._repo.toString()+mf(this._path)}}class ge extends yr{constructor(e,t){super(e,t,new Zs,!1)}get parent(){const e=Ia(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 x(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 x(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?n_("child","path",e):ic("child","path",e),new ge(n._repo,W(n._path,e))}class Er{constructor(e){this.callbackContext=e}respondsTo(e){return e==="value"}createEvent(e,t){const s=t._queryParams.getIndex();return new _c("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 mc(this,e,t):null}matches(e){return e instanceof Er?!e.callbackContext||!this.callbackContext?!0:e.callbackContext.matches(this.callbackContext):!1}hasAnyCallback(){return this.callbackContext!==null}}class wr{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 mc(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 _c(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 wr?this.eventType===e.eventType&&(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext)):!1}hasAnyCallback(){return!!this.callbackContext}}function gc(n,e,t,s,r){const i=new C_(t,void 0),o=e==="value"?new Er(i):new wr(e,i);return p_(n._repo,n,o),()=>__(n._repo,n,o)}function Jt(n,e,t,s){return gc(n,"value",e)}function S_(n,e,t,s){return gc(n,"child_added",e)}Rp(ge);xp(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=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);/**
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 T_="FIREBASE_DATABASE_EMULATOR_HOST",Os={};let R_=!1;function I_(n,e,t,s){n.repoInfo_=new ma(e,!1,n.repoInfo_.namespace,n.repoInfo_.webSocketOnly,n.repoInfo_.nodeAdmin,n.repoInfo_.persistenceKey,n.repoInfo_.includeNamespaceInQueryParams,!0,t),s&&(n.authTokenProvider_=s)}function N_(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=ki(i,r),a=o.repoInfo,c;typeof process<"u"&&process.env&&(c=process.env[T_]),c?(i=`http://${c}?ns=${a.namespace}`,o=ki(i,r),a=o.repoInfo):o.repoInfo.secure;const l=new Vd(n.name,n.options,e);s_("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=A_(a,n,l,new qd(n,t));return new O_(h,n)}function k_(n,e){const t=Os[e];(!t||t[n.key]!==n)&&_e(`Database ${e}(${n.repoInfo_}) has already been deleted.`),m_(n),delete t[n.key]}function A_(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 c_(n,R_,t,s),r[n.toURLString()]=i,i}class O_{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(l_(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=_d(),e){const t=hd(n,"database").getImmediate({identifier:e});if(!t._instanceStarted){const s=Zh("database");s&&x_(t,...s)}return t}function x_(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:eu(s.mockUserToken,n.app.options.projectId);o=new Qt(a)}I_(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 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)}/**
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 P_(n){Rd(pd),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 N_(s,r,i,t)},"PUBLIC").setMultipleInstances(!0)),$e(Qr,Jr,n),$e(Qr,Jr,"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)};P_();const Bn=n=>n==="server"?"https://backend.nervoscan.com":"https://backendv2-dev.nervoscan.com",Ne=class Ne{constructor(){A(this,"socket");A(this,"backendUrl",Bn("server"));A(this,"videoStream");A(this,"videoElement");A(this,"isConnected",!1);A(this,"isStreaming",!1);A(this,"jobId");A(this,"onDisconnection");A(this,"onConnectionLost");A(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)});A(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=>{this.onConnectionLost&&this.onConnectionLost(v.ConnectionLostError),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}setOnConnectionLost(e){this.onConnectionLost=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())})}};A(Ne,"instance");let wn=Ne;class yc{constructor(e,t){A(this,"backendUrl",Bn("server"));A(this,"username");A(this,"password");A(this,"streamingManager",wn.getInstance());this.username=e,this.password=t}}class D_ extends yc{constructor(t,s){super(t,s);A(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 L_ extends yc{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 F_="firebase",M_="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 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";/**
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(F_,M_,"app");const ke=class ke{constructor(){A(this,"initialized",!1);A(this,"accessToken");A(this,"backendRepository");A(this,"onWindowResults");A(this,"onFinalResults");A(this,"onError");A(this,"firebaseHandlers",[]);Xo({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 D_(e,t):s==="serverless"?this.backendRepository=new L_(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 setOnConnectionLost(e){var t;(t=this.backendRepository)==null||t.streamingManager.setOnConnectionLost(e)}async addfirebaseListeners(e){this.addWindowListener(e),this.addFinalListener(e),this.addErrorListener(e)}addWindowListener(e){const t=Xt(),s=ut(t,`${e}`),r=S_(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()===!1&&this.onError&&(this.onError(v.ScanFailedError),this.removefirebaseListeners())});this.firebaseHandlers.push(r),this.firebaseHandlers.push(o)}};A(ke,"instance");let xs=ke;exports.Client=xs;exports.ConnectionLostError=Zi;exports.EmptyVideoError=Oi;exports.ErrorCallbackNotSetError=Ki;exports.Errors=D;exports.FPSCalculationError=Wi;exports.FaceLookingLeftError=zi;exports.FaceLookingRightError=ji;exports.FaceNotCenteredError=qi;exports.FaceTooCloseError=$i;exports.FaceTooFarError=Vi;exports.InvalidAccessTokenError=Fi;exports.InvalidContentTypeError=Yi;exports.InvalidPasswordError=Di;exports.InvalidServerTypeError=Bi;exports.InvalidUsernameError=Pi;exports.JobNotRegisteredError=Qi;exports.LowFPSError=Hi;exports.LowFrameCountError=Xi;exports.NervoscanError=P;exports.NoScanDataError=Mi;exports.NoScansAvailableError=Li;exports.NotImplementedError=Ui;exports.NotInitializedError=Ai;exports.ScanFailedError=eo;exports.SkinExtractionError=Gi;exports.UnhandledError=Ji;exports.UnhandledScanError=Ps;exports.VideoTypeError=xi;
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;