UNPKG

firebase

Version:

Firebase JavaScript library for web and Node.js

1 lines • 133 kB
import{_isFirebaseServerApp as e,getApp as i,_getProvider,_removeServiceInstance as s,_registerComponent as T,registerVersion as E,SDK_VERSION as V}from"https://www.gstatic.com/firebasejs/12.17.1/firebase-app.js";const stringToByteArray$1=function(e){const i=[];let s=0;for(let T=0;T<e.length;T++){let E=e.charCodeAt(T);E<128?i[s++]=E:E<2048?(i[s++]=E>>6|192,i[s++]=63&E|128):55296==(64512&E)&&T+1<e.length&&56320==(64512&e.charCodeAt(T+1))?(E=65536+((1023&E)<<10)+(1023&e.charCodeAt(++T)),i[s++]=E>>18|240,i[s++]=E>>12&63|128,i[s++]=E>>6&63|128,i[s++]=63&E|128):(i[s++]=E>>12|224,i[s++]=E>>6&63|128,i[s++]=63&E|128)}return i},R={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:"function"==typeof atob,encodeByteArray(e,i){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const s=i?this.byteToCharMapWebSafe_:this.byteToCharMap_,T=[];for(let i=0;i<e.length;i+=3){const E=e[i],V=i+1<e.length,R=V?e[i+1]:0,N=i+2<e.length,O=N?e[i+2]:0,M=E>>2,L=(3&E)<<4|R>>4;let U=(15&R)<<2|O>>6,Q=63&O;N||(Q=64,V||(U=64)),T.push(s[M],s[L],s[U],s[Q])}return T.join("")},encodeString(e,i){return this.HAS_NATIVE_SUPPORT&&!i?btoa(e):this.encodeByteArray(stringToByteArray$1(e),i)},decodeString(e,i){return this.HAS_NATIVE_SUPPORT&&!i?atob(e):function(e){const i=[];let s=0,T=0;for(;s<e.length;){const E=e[s++];if(E<128)i[T++]=String.fromCharCode(E);else if(E>191&&E<224){const V=e[s++];i[T++]=String.fromCharCode((31&E)<<6|63&V)}else if(E>239&&E<365){const V=((7&E)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536;i[T++]=String.fromCharCode(55296+(V>>10)),i[T++]=String.fromCharCode(56320+(1023&V))}else{const V=e[s++],R=e[s++];i[T++]=String.fromCharCode((15&E)<<12|(63&V)<<6|63&R)}}return i.join("")}(this.decodeStringToByteArray(e,i))},decodeStringToByteArray(e,i){this.init_();const s=i?this.charToByteMapWebSafe_:this.charToByteMap_,T=[];for(let i=0;i<e.length;){const E=s[e.charAt(i++)],V=i<e.length?s[e.charAt(i)]:0;++i;const R=i<e.length?s[e.charAt(i)]:64;++i;const N=i<e.length?s[e.charAt(i)]:64;if(++i,null==E||null==V||null==R||null==N)throw new DecodeBase64StringError;const O=E<<2|V>>4;if(T.push(O),64!==R){const e=V<<4&240|R>>2;if(T.push(e),64!==N){const e=R<<6&192|N;T.push(e)}}}return T},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class DecodeBase64StringError extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const base64urlEncodeWithoutPadding=function(e){return function(e){const i=stringToByteArray$1(e);return R.encodeByteArray(i,!0)}(e).replace(/\./g,"")};const getDefaultsFromGlobal=()=>function getGlobal(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__,getDefaultsFromCookie=()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const i=e&&function(e){try{return R.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null}(e[1]);return i&&JSON.parse(i)},getDefaults=()=>{try{return getDefaultsFromGlobal()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||getDefaultsFromCookie()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},getDefaultEmulatorHostnameAndPort=e=>{const i=(e=>getDefaults()?.emulatorHosts?.[e])(e);if(!i)return;const s=i.lastIndexOf(":");if(s<=0||s+1===i.length)throw new Error(`Invalid host ${i} with no separate hostname and port!`);const T=parseInt(i.substring(s+1),10);return"["===i[0]?[i.substring(1,s-1),T]:[i.substring(0,s),T]};class FirebaseError extends Error{constructor(e,i,s){super(i),this.code=e,this.customData=s,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,i,s){this.service=e,this.serviceName=i,this.errors=s}create(e,...i){const s=i[0]||{},T=`${this.service}/${e}`,E=this.errors[e],V=E?function replaceTemplate(e,i){try{let s=0,T="";for(;s<e.length;){const E=e.indexOf("{$",s);if(-1===E){T+=e.substring(s);break}const V=e.indexOf("}",E+2);if(-1===V){T+=e.substring(s);break}const R=e.substring(E+2,V),N=i[R];T+=e.substring(s,E)+(null!=N?String(N):`<${R}?>`),s=V+1}return T}catch(i){return e}}(E,s):"Error",R=`${this.serviceName}: ${V} (${T}).`;return new FirebaseError(T,R,s)}}function deepEqual(e,i){if(e===i)return!0;const s=Object.keys(e),T=Object.keys(i);for(const E of s){if(!T.includes(E))return!1;const s=e[E],V=i[E];if(isObject(s)&&isObject(V)){if(!deepEqual(s,V))return!1}else if(s!==V)return!1}for(const e of T)if(!s.includes(e))return!1;return!0}function isObject(e){return null!==e&&"object"==typeof e}function getModularInstance(e){return e&&e._delegate?e._delegate:e}function isCloudWorkstation(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}class Component{constructor(e,i,s){this.name=e,this.instanceFactory=i,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}var N;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(N||(N={}));const O={debug:N.DEBUG,verbose:N.VERBOSE,info:N.INFO,warn:N.WARN,error:N.ERROR,silent:N.SILENT},M=N.INFO,L={[N.DEBUG]:"log",[N.VERBOSE]:"log",[N.INFO]:"info",[N.WARN]:"warn",[N.ERROR]:"error"},defaultLogHandler=(e,i,...s)=>{if(i<e.logLevel)return;const T=(new Date).toISOString(),E=L[i];if(!E)throw new Error(`Attempted to log a message with an invalid logType (value: ${i})`);console[E](`[${T}] ${e.name}:`,...s)};var U,Q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};(function(){var e;function m(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}function n(e,i,s){s||(s=0);const T=Array(16);if("string"==typeof i)for(var E=0;E<16;++E)T[E]=i.charCodeAt(s++)|i.charCodeAt(s++)<<8|i.charCodeAt(s++)<<16|i.charCodeAt(s++)<<24;else for(E=0;E<16;++E)T[E]=i[s++]|i[s++]<<8|i[s++]<<16|i[s++]<<24;i=e.g[0],s=e.g[1],E=e.g[2];let V,R=e.g[3];V=i+(R^s&(E^R))+T[0]+3614090360&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[1]+3905402710&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[2]+606105819&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[3]+3250441966&4294967295,V=i+(R^(s=E+(V<<22&4294967295|V>>>10))&(E^R))+T[4]+4118548399&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[5]+1200080426&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[6]+2821735955&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[7]+4249261313&4294967295,V=i+(R^(s=E+(V<<22&4294967295|V>>>10))&(E^R))+T[8]+1770035416&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[9]+2336552879&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[10]+4294925233&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[11]+2304563134&4294967295,V=i+(R^(s=E+(V<<22&4294967295|V>>>10))&(E^R))+T[12]+1804603682&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[13]+4254626195&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[14]+2792965006&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[15]+1236535329&4294967295,V=i+(E^R&((s=E+(V<<22&4294967295|V>>>10))^E))+T[1]+4129170786&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[6]+3225465664&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[11]+643717713&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[0]+3921069994&4294967295,V=i+(E^R&((s=E+(V<<20&4294967295|V>>>12))^E))+T[5]+3593408605&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[10]+38016083&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[15]+3634488961&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[4]+3889429448&4294967295,V=i+(E^R&((s=E+(V<<20&4294967295|V>>>12))^E))+T[9]+568446438&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[14]+3275163606&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[3]+4107603335&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[8]+1163531501&4294967295,V=i+(E^R&((s=E+(V<<20&4294967295|V>>>12))^E))+T[13]+2850285829&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[2]+4243563512&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[7]+1735328473&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[12]+2368359562&4294967295,V=i+((s=E+(V<<20&4294967295|V>>>12))^E^R)+T[5]+4294588738&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[8]+2272392833&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[11]+1839030562&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[14]+4259657740&4294967295,V=i+((s=E+(V<<23&4294967295|V>>>9))^E^R)+T[1]+2763975236&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[4]+1272893353&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[7]+4139469664&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[10]+3200236656&4294967295,V=i+((s=E+(V<<23&4294967295|V>>>9))^E^R)+T[13]+681279174&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[0]+3936430074&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[3]+3572445317&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[6]+76029189&4294967295,V=i+((s=E+(V<<23&4294967295|V>>>9))^E^R)+T[9]+3654602809&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[12]+3873151461&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[15]+530742520&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[2]+3299628645&4294967295,V=i+(E^((s=E+(V<<23&4294967295|V>>>9))|~R))+T[0]+4096336452&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[7]+1126891415&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[14]+2878612391&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[5]+4237533241&4294967295,V=i+(E^((s=E+(V<<21&4294967295|V>>>11))|~R))+T[12]+1700485571&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[3]+2399980690&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[10]+4293915773&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[1]+2240044497&4294967295,V=i+(E^((s=E+(V<<21&4294967295|V>>>11))|~R))+T[8]+1873313359&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[15]+4264355552&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[6]+2734768916&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[13]+1309151649&4294967295,V=i+(E^((s=E+(V<<21&4294967295|V>>>11))|~R))+T[4]+4149444226&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[11]+3174756917&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[2]+718787259&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[9]+3951481745&4294967295,e.g[0]=e.g[0]+i&4294967295,e.g[1]=e.g[1]+(E+(V<<21&4294967295|V>>>11))&4294967295,e.g[2]=e.g[2]+E&4294967295,e.g[3]=e.g[3]+R&4294967295}function t(e,i){this.h=i;const s=[];let T=!0;for(let E=e.length-1;E>=0;E--){const V=0|e[E];T&&V==i||(s[E]=V,T=!1)}this.g=s}!function k(e,i){function c(){}c.prototype=i.prototype,e.F=i.prototype,e.prototype=new c,e.prototype.constructor=e,e.D=function(e,s,T){for(var E=Array(arguments.length-2),V=2;V<arguments.length;V++)E[V-2]=arguments[V];return i.prototype[s].apply(e,E)}}(m,(function l(){this.blockSize=-1})),m.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},m.prototype.v=function(e,i){void 0===i&&(i=e.length);const s=i-this.blockSize,T=this.C;let E=this.h,V=0;for(;V<i;){if(0==E)for(;V<=s;)n(this,e,V),V+=this.blockSize;if("string"==typeof e){for(;V<i;)if(T[E++]=e.charCodeAt(V++),E==this.blockSize){n(this,T),E=0;break}}else for(;V<i;)if(T[E++]=e[V++],E==this.blockSize){n(this,T),E=0;break}}this.h=E,this.o+=i},m.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var i=1;i<e.length-8;++i)e[i]=0;i=8*this.o;for(var s=e.length-8;s<e.length;++s)e[s]=255&i,i/=256;for(this.v(e),e=Array(16),i=0,s=0;s<4;++s)for(let T=0;T<32;T+=8)e[i++]=this.g[s]>>>T&255;return e};var i={};function u(e){return-128<=e&&e<128?function p(e,s){var T=i;return Object.prototype.hasOwnProperty.call(T,e)?T[e]:T[e]=s(e)}(e,(function(e){return new t([0|e],e<0?-1:0)})):new t([0|e],e<0?-1:0)}function v(e){if(isNaN(e)||!isFinite(e))return s;if(e<0)return x(v(-e));const i=[];let T=1;for(let s=0;e>=T;s++)i[s]=e/T|0,T*=4294967296;return new t(i,0)}var s=u(0),T=u(1),E=u(16777216);function C(e){if(0!=e.h)return!1;for(let i=0;i<e.g.length;i++)if(0!=e.g[i])return!1;return!0}function B(e){return-1==e.h}function x(e){const i=e.g.length,s=[];for(let T=0;T<i;T++)s[T]=~e.g[T];return new t(s,~e.h).add(T)}function F(e,i){return e.add(x(i))}function G(e,i){for(;(65535&e[i])!=e[i];)e[i+1]+=e[i]>>>16,e[i]&=65535,i++}function H(e,i){this.g=e,this.h=i}function D(e,i){if(C(i))throw Error("division by zero");if(C(e))return new H(s,s);if(B(e))return i=D(x(e),i),new H(x(i.g),x(i.h));if(B(i))return i=D(e,x(i)),new H(x(i.g),i.h);if(e.g.length>30){if(B(e)||B(i))throw Error("slowDivide_ only works with positive integers.");for(var E=T,V=i;V.l(e)<=0;)E=I(E),V=I(V);var R=J(E,1),N=J(V,1);for(V=J(V,2),E=J(E,2);!C(V);){var O=N.add(V);O.l(e)<=0&&(R=R.add(E),N=O),V=J(V,1),E=J(E,1)}return i=F(e,R.j(i)),new H(R,i)}for(R=s;e.l(i)>=0;){for(E=Math.max(1,Math.floor(e.m()/i.m())),V=(V=Math.ceil(Math.log(E)/Math.LN2))<=48?1:Math.pow(2,V-48),O=(N=v(E)).j(i);B(O)||O.l(e)>0;)O=(N=v(E-=V)).j(i);C(N)&&(N=T),R=R.add(N),e=F(e,O)}return new H(R,e)}function I(e){const i=e.g.length+1,s=[];for(let T=0;T<i;T++)s[T]=e.i(T)<<1|e.i(T-1)>>>31;return new t(s,e.h)}function J(e,i){const s=i>>5;i%=32;const T=e.g.length-s,E=[];for(let V=0;V<T;V++)E[V]=i>0?e.i(V+s)>>>i|e.i(V+s+1)<<32-i:e.i(V+s);return new t(E,e.h)}(e=t.prototype).m=function(){if(B(this))return-x(this).m();let e=0,i=1;for(let s=0;s<this.g.length;s++){const T=this.i(s);e+=(T>=0?T:4294967296+T)*i,i*=4294967296}return e},e.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(C(this))return"0";if(B(this))return"-"+x(this).toString(e);const i=v(Math.pow(e,6));var s=this;let T="";for(;;){const E=D(s,i).g;let V=(((s=F(s,E.j(i))).g.length>0?s.g[0]:s.h)>>>0).toString(e);if(C(s=E))return V+T;for(;V.length<6;)V="0"+V;T=V+T}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return B(e=F(this,e))?-1:C(e)?0:1},e.abs=function(){return B(this)?x(this):this},e.add=function(e){const i=Math.max(this.g.length,e.g.length),s=[];let T=0;for(let E=0;E<=i;E++){let i=T+(65535&this.i(E))+(65535&e.i(E)),V=(i>>>16)+(this.i(E)>>>16)+(e.i(E)>>>16);T=V>>>16,i&=65535,V&=65535,s[E]=V<<16|i}return new t(s,-2147483648&s[s.length-1]?-1:0)},e.j=function(e){if(C(this)||C(e))return s;if(B(this))return B(e)?x(this).j(x(e)):x(x(this).j(e));if(B(e))return x(this.j(x(e)));if(this.l(E)<0&&e.l(E)<0)return v(this.m()*e.m());const i=this.g.length+e.g.length,T=[];for(var V=0;V<2*i;V++)T[V]=0;for(V=0;V<this.g.length;V++)for(let i=0;i<e.g.length;i++){const s=this.i(V)>>>16,E=65535&this.i(V),R=e.i(i)>>>16,N=65535&e.i(i);T[2*V+2*i]+=E*N,G(T,2*V+2*i),T[2*V+2*i+1]+=s*N,G(T,2*V+2*i+1),T[2*V+2*i+1]+=E*R,G(T,2*V+2*i+1),T[2*V+2*i+2]+=s*R,G(T,2*V+2*i+2)}for(e=0;e<i;e++)T[e]=T[2*e+1]<<16|T[2*e];for(e=i;e<2*i;e++)T[e]=0;return new t(T,0)},e.B=function(e){return D(this,e).h},e.and=function(e){const i=Math.max(this.g.length,e.g.length),s=[];for(let T=0;T<i;T++)s[T]=this.i(T)&e.i(T);return new t(s,this.h&e.h)},e.or=function(e){const i=Math.max(this.g.length,e.g.length),s=[];for(let T=0;T<i;T++)s[T]=this.i(T)|e.i(T);return new t(s,this.h|e.h)},e.xor=function(e){const i=Math.max(this.g.length,e.g.length),s=[];for(let T=0;T<i;T++)s[T]=this.i(T)^e.i(T);return new t(s,this.h^e.h)},m.prototype.digest=m.prototype.A,m.prototype.reset=m.prototype.u,m.prototype.update=m.prototype.v,t.prototype.add=t.prototype.add,t.prototype.multiply=t.prototype.j,t.prototype.modulo=t.prototype.B,t.prototype.compare=t.prototype.l,t.prototype.toNumber=t.prototype.m,t.prototype.toString=t.prototype.toString,t.prototype.getBits=t.prototype.i,t.fromNumber=v,t.fromString=function y(e,i){if(0==e.length)throw Error("number format error: empty string");if((i=i||10)<2||36<i)throw Error("radix out of range: "+i);if("-"==e.charAt(0))return x(y(e.substring(1),i));if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character');const T=v(Math.pow(i,8));let E=s;for(let s=0;s<e.length;s+=8){var V=Math.min(8,e.length-s);const R=parseInt(e.substring(s,s+V),i);V<8?(V=v(Math.pow(i,V)),E=E.j(V).add(v(R))):(E=E.j(T),E=E.add(v(R)))}return E},U=t}).apply(void 0!==Q?Q:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});class User{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}User.UNAUTHENTICATED=new User(null),User.GOOGLE_CREDENTIALS=new User("google-credentials-uid"),User.FIRST_PARTY=new User("first-party-uid"),User.MOCK_USER=new User("mock-user");let $="12.17.1";const W=new class Logger{constructor(e){this.name=e,this._logLevel=M,this._logHandler=defaultLogHandler,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in N))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?O[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)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,N.DEBUG,...e),this._logHandler(this,N.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,N.VERBOSE,...e),this._logHandler(this,N.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,N.INFO,...e),this._logHandler(this,N.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,N.WARN,...e),this._logHandler(this,N.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,N.ERROR,...e),this._logHandler(this,N.ERROR,...e)}}("@firebase/firestore");function setLogLevel(e){W.setLogLevel(e)}function a(e,...i){if(W.logLevel<=N.DEBUG){const s=i.map(__PRIVATE_argToString);W.debug(`Firestore (${$}): ${e}`,...s)}}function st(e,...i){if(W.logLevel<=N.ERROR){const s=i.map(__PRIVATE_argToString);W.error(`Firestore (${$}): ${e}`,...s)}}function __PRIVATE_logWarn(e,...i){if(W.logLevel<=N.WARN){const s=i.map(__PRIVATE_argToString);W.warn(`Firestore (${$}): ${e}`,...s)}}function __PRIVATE_argToString(e){if("string"==typeof e)return e;try{return function __PRIVATE_formatJSON(e){return JSON.stringify(e)}(e)}catch(i){return e}}function z(e,i,s){let T="Unexpected state";"string"==typeof i?T=i:s=i,__PRIVATE__fail(e,T,s)}function __PRIVATE__fail(e,i,s){let T=`FIRESTORE (${$}) INTERNAL ASSERTION FAILED: ${i} (ID: ${e.toString(16)})`;if(void 0!==s)try{T+=" CONTEXT: "+JSON.stringify(s)}catch(e){T+=" CONTEXT: "+s}throw st(T),new Error(T)}function __PRIVATE_hardAssert(e,i,s,T){let E="Unexpected state";"string"==typeof s?E=s:T=s,e||__PRIVATE__fail(i,E,T)}function __PRIVATE_debugCast(e,i){return e}const K="ok",Y="cancelled",X="unknown",Z="invalid-argument",ee="deadline-exceeded",te="not-found",re="already-exists",ne="permission-denied",ie="unauthenticated",se="resource-exhausted",oe="failed-precondition",ae="aborted",ue="out-of-range",le="unimplemented",ce="internal",he="unavailable",_e="data-loss";class k extends FirebaseError{constructor(e,i){super(e,i),this.code=e,this.message=i,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class __PRIVATE_OAuthToken{constructor(e,i){this.user=i,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class __PRIVATE_EmptyAuthCredentialsProvider{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,i){e.enqueueRetryable((()=>i(User.UNAUTHENTICATED)))}shutdown(){}}class __PRIVATE_EmulatorAuthCredentialsProvider{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,i){this.changeListener=i,e.enqueueRetryable((()=>i(this.token.user)))}shutdown(){this.changeListener=null}}class r{constructor(e){this.auth=null,e.onInit((e=>{this.auth=e}))}getToken(){return this.auth?this.auth.getToken().then((e=>e?(__PRIVATE_hardAssert("string"==typeof e.accessToken,42297,{Z:e}),new __PRIVATE_OAuthToken(e.accessToken,new User(this.auth.getUid()))):null)):Promise.resolve(null)}invalidateToken(){}start(e,i){}shutdown(){}}class __PRIVATE_FirstPartyToken{constructor(e,i,s){this.ee=e,this.te=i,this.re=s,this.type="FirstParty",this.user=User.FIRST_PARTY,this.ne=new Map}ie(){return this.re?this.re():null}get headers(){this.ne.set("X-Goog-AuthUser",this.ee);const e=this.ie();return e&&this.ne.set("Authorization",e),this.te&&this.ne.set("X-Goog-Iam-Authorization-Token",this.te),this.ne}}class __PRIVATE_FirstPartyAuthCredentialsProvider{constructor(e,i,s){this.ee=e,this.te=i,this.re=s}getToken(){return Promise.resolve(new __PRIVATE_FirstPartyToken(this.ee,this.te,this.re))}start(e,i){e.enqueueRetryable((()=>i(User.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class AppCheckToken{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class o{constructor(i,s){this.se=s,this.appCheck=null,this.oe=null,e(i)&&i.settings.appCheckToken&&(this.oe=i.settings.appCheckToken),s.onInit((e=>{this.appCheck=e}))}getToken(){return this.oe?Promise.resolve(new AppCheckToken(this.oe)):this.appCheck?this.appCheck.getToken().then((e=>e?(__PRIVATE_hardAssert("string"==typeof e.token,3470,{tokenResult:e}),new AppCheckToken(e.token)):null)):Promise.resolve(null)}invalidateToken(){}start(e,i){}shutdown(){}}class DatabaseInfo{constructor(e,i,s,T,E,V,R,N,O,M,L,U,Q){this.databaseId=e,this.appId=i,this.persistenceKey=s,this.host=T,this.ssl=E,this.forceLongPolling=V,this.autoDetectLongPolling=R,this.longPollingOptions=N,this.useFetchStreams=O,this.isUsingEmulator=M,this.apiKey=L,this._customHeaders=U,this.grpcFlowControlWindow=Q}}const de="(default)";class DatabaseId{constructor(e,i){this.projectId=e,this.database=i||de}static empty(){return new DatabaseId("","")}get isDefaultDatabase(){return this.database===de}isEqual(e){return e instanceof DatabaseId&&e.projectId===this.projectId&&e.database===this.database}}function __PRIVATE_randomBytes(e){const i="undefined"!=typeof self&&(self.crypto||self.msCrypto),s=new Uint8Array(e);if(i&&"function"==typeof i.getRandomValues)i.getRandomValues(s);else for(let i=0;i<e;i++)s[i]=Math.floor(256*Math.random());return s}class __PRIVATE_AutoId{static newId(){const e=62*Math.floor(256/62);let i="";for(;i.length<20;){const s=__PRIVATE_randomBytes(40);for(let T=0;T<s.length;++T)i.length<20&&s[T]<e&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(s[T]%62))}return i}}function __PRIVATE_primitiveComparator(e,i){return e<i?-1:e>i?1:0}function __PRIVATE_compareUtf8Strings(e,i){const s=Math.min(e.length,i.length);for(let T=0;T<s;T++){const s=e.charAt(T),E=i.charAt(T);if(s!==E)return __PRIVATE_isSurrogate(s)===__PRIVATE_isSurrogate(E)?__PRIVATE_primitiveComparator(s,E):__PRIVATE_isSurrogate(s)?1:-1}return __PRIVATE_primitiveComparator(e.length,i.length)}const fe=55296,me=57343;function __PRIVATE_isSurrogate(e){const i=e.charCodeAt(0);return i>=fe&&i<=me}function __PRIVATE_arrayEquals(e,i,s){return e.length===i.length&&e.every(((e,T)=>s(e,i[T])))}const pe="__name__";class BasePath{constructor(e,i,s){void 0===i?i=0:i>e.length&&z(637,{offset:i,range:e.length}),void 0===s?s=e.length-i:s>e.length-i&&z(1746,{length:s,range:e.length-i}),this.segments=e,this.offset=i,this.len=s}get length(){return this.len}isEqual(e){return 0===BasePath.comparator(this,e)}child(e){const i=this.segments.slice(this.offset,this.limit());return e instanceof BasePath?e.forEach((e=>{i.push(e)})):i.push(e),this.construct(i)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let i=0;i<this.length;i++)if(this.get(i)!==e.get(i))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let i=0;i<this.length;i++)if(this.get(i)!==e.get(i))return!1;return!0}forEach(e){for(let i=this.offset,s=this.limit();i<s;i++)e(this.segments[i])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,i){const s=Math.min(e.length,i.length);for(let T=0;T<s;T++){const s=BasePath.compareSegments(e.get(T),i.get(T));if(0!==s)return s}return __PRIVATE_primitiveComparator(e.length,i.length)}static compareSegments(e,i){const s=BasePath.isNumericId(e),T=BasePath.isNumericId(i);return s&&!T?-1:!s&&T?1:s&&T?BasePath.extractNumericId(e).compare(BasePath.extractNumericId(i)):__PRIVATE_compareUtf8Strings(e,i)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return U.fromString(e.substring(4,e.length-2))}}class ResourcePath extends BasePath{construct(e,i,s){return new ResourcePath(e,i,s)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const i=[];for(const s of e){if(s.indexOf("//")>=0)throw new k(Z,`Invalid segment (${s}). Paths must not contain // in them.`);i.push(...s.split("/").filter((e=>e.length>0)))}return new ResourcePath(i)}static emptyPath(){return new ResourcePath([])}}const ge=/^[_a-zA-Z][_a-zA-Z0-9]*$/;let ye=class FieldPath extends BasePath{construct(e,i,s){return new FieldPath(e,i,s)}static isValidIdentifier(e){return ge.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),FieldPath.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===pe}static keyField(){return new FieldPath([pe])}static fromServerFormat(e){const i=[];let s="",T=0;const __PRIVATE_addCurrentSegment=()=>{if(0===s.length)throw new k(Z,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);i.push(s),s=""};let E=!1;for(;T<e.length;){const i=e[T];if("\\"===i){if(T+1===e.length)throw new k(Z,"Path has trailing escape character: "+e);const i=e[T+1];if("\\"!==i&&"."!==i&&"`"!==i)throw new k(Z,"Path has invalid escape sequence: "+e);s+=i,T+=2}else"`"===i?(E=!E,T++):"."!==i||E?(s+=i,T++):(__PRIVATE_addCurrentSegment(),T++)}if(__PRIVATE_addCurrentSegment(),E)throw new k(Z,"Unterminated ` in path: "+e);return new FieldPath(i)}static emptyPath(){return new FieldPath([])}};class x{constructor(e){this.path=e}static fromPath(e){return new x(ResourcePath.fromString(e))}static fromName(e){return new x(ResourcePath.fromString(e).popFirst(5))}static empty(){return new x(ResourcePath.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===ResourcePath.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,i){return ResourcePath.comparator(e.path,i.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new x(new ResourcePath(e.slice()))}}function __PRIVATE_validateNonEmptyArgument(e,i,s){if(!s)throw new k(Z,`Function ${e}() cannot be called with an empty ${i}.`)}function __PRIVATE_validateDocumentPath(e){if(!x.isDocumentKey(e))throw new k(Z,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function __PRIVATE_validateCollectionPath(e){if(x.isDocumentKey(e))throw new k(Z,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function __PRIVATE_isPlainObject(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function __PRIVATE_valueDescription(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const i=function __PRIVATE_tryGetCustomObjectType(e){return e.constructor?e.constructor.name:null}(e);return i?`a custom ${i} object`:"an object"}}return"function"==typeof e?"a function":z(12329,{type:typeof e})}function f(e,i){if("_delegate"in e&&(e=e._delegate),!(e instanceof i)){if(i.name===e.constructor.name)throw new k(Z,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const s=__PRIVATE_valueDescription(e);throw new k(Z,`Expected type '${i.name}', but it was: ${s}`)}}return e}function __PRIVATE_validatePositiveNumber(e,i){if(i<=0)throw new k(Z,`Function ${e}() requires a positive number, but it was: ${i}.`)}function __PRIVATE_cloneLongPollingOptions(e){const i={};return void 0!==e.timeoutSeconds&&(i.timeoutSeconds=e.timeoutSeconds),i}let Te=null;function tt(e){return null==e}function __PRIVATE_isNegativeZero(e){return 0===e&&1/e==-1/0}const Ee="RestConnection",Ae={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class __PRIVATE_RestConnection{get ae(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const i=e.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),T=encodeURIComponent(this.databaseId.database);this.ue=i+"://"+e.host,this._e=`projects/${s}/databases/${T}`,this.ce=this.databaseId.database===de?`project_id=${s}`:`project_id=${s}&database_id=${T}`}le(e,i,s,T,E){const V=function __PRIVATE_generateUniqueDebugId(){return null===Te?Te=function __PRIVATE_generateInitialUniqueDebugId(){return 268435456+Math.round(2147483648*Math.random())}():Te++,"0x"+Te.toString(16)}(),R=this.he(e,i.toUriEncodedString());a(Ee,`Sending RPC '${e}' ${V}:`,R,s);const N={"google-cloud-resource-prefix":this._e,"x-goog-request-params":this.ce};this.fe(N,T,E);const{host:O}=new URL(R),M=isCloudWorkstation(O);return this.me(e,R,N,s,M).then((i=>(a(Ee,`Received RPC '${e}' ${V}: `,i),i)),(i=>{throw __PRIVATE_logWarn(Ee,`RPC '${e}' ${V} failed with error: `,i,"url: ",R,"request:",s),i}))}de(e,i,s,T,E,V){return this.le(e,i,s,T,E)}fe(e,i,s){if(e["X-Goog-Api-Client"]=function __PRIVATE_getGoogApiClientValue(){return"gl-js/ fire/"+$}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),i&&i.headers.forEach(((i,s)=>e[s]=i)),s&&s.headers.forEach(((i,s)=>e[s]=i)),this.databaseInfo._customHeaders)for(const i of Object.keys(this.databaseInfo._customHeaders))e[i]=this.databaseInfo._customHeaders[i]}he(e,i){const s=Ae[e];let T=`${this.ue}/v1/${i}:${s}`;return this.databaseInfo.apiKey&&(T=`${T}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),T}terminate(){}}var Ie,Ve;function __PRIVATE_mapCodeFromHttpStatus(e){if(void 0===e)return st("RPC_ERROR","HTTP error has no status"),X;switch(e){case 200:return K;case 400:return oe;case 401:return ie;case 403:return ne;case 404:return te;case 409:return ae;case 416:return ue;case 429:return se;case 499:return Y;case 500:return X;case 501:return le;case 503:return he;case 504:return ee;default:return e>=200&&e<300?K:e>=400&&e<500?oe:e>=500&&e<600?ce:X}}(Ve=Ie||(Ie={}))[Ve.OK=0]="OK",Ve[Ve.CANCELLED=1]="CANCELLED",Ve[Ve.UNKNOWN=2]="UNKNOWN",Ve[Ve.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Ve[Ve.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Ve[Ve.NOT_FOUND=5]="NOT_FOUND",Ve[Ve.ALREADY_EXISTS=6]="ALREADY_EXISTS",Ve[Ve.PERMISSION_DENIED=7]="PERMISSION_DENIED",Ve[Ve.UNAUTHENTICATED=16]="UNAUTHENTICATED",Ve[Ve.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Ve[Ve.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Ve[Ve.ABORTED=10]="ABORTED",Ve[Ve.OUT_OF_RANGE=11]="OUT_OF_RANGE",Ve[Ve.UNIMPLEMENTED=12]="UNIMPLEMENTED",Ve[Ve.INTERNAL=13]="INTERNAL",Ve[Ve.UNAVAILABLE=14]="UNAVAILABLE",Ve[Ve.DATA_LOSS=15]="DATA_LOSS";class __PRIVATE_FetchConnection extends __PRIVATE_RestConnection{Ee(e,i){throw new Error("Not supported by FetchConnection")}async me(e,i,s,T,E){const V=JSON.stringify(T);let R;try{const e={method:"POST",headers:s,body:V};E&&(e.credentials="include"),R=await fetch(i,e)}catch(e){const i=e;throw new k(__PRIVATE_mapCodeFromHttpStatus(i.status),"Request failed with error: "+i.statusText)}if(!R.ok){let e=await R.json();Array.isArray(e)&&(e=e[0]);const i=e?.error?.message;throw new k(__PRIVATE_mapCodeFromHttpStatus(R.status),`Request failed with error: ${i??R.statusText}`)}return R.json()}}function __PRIVATE_objectSize(e){let i=0;for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i++;return i}function forEach(e,i){for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i(s,e[s])}class __PRIVATE_Base64DecodeError extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class ByteString{constructor(e){this.binaryString=e}static fromBase64String(e){const i=function __PRIVATE_decodeBase64(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new __PRIVATE_Base64DecodeError("Invalid base64 string: "+e):e}}(e);return new ByteString(i)}static fromUint8Array(e){const i=function __PRIVATE_binaryStringFromUint8Array(e){let i="";for(let s=0;s<e.length;++s)i+=String.fromCharCode(e[s]);return i}(e);return new ByteString(i)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function __PRIVATE_encodeBase64(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function __PRIVATE_uint8ArrayFromBinaryString(e){const i=new Uint8Array(e.length);for(let s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return i}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return __PRIVATE_primitiveComparator(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}ByteString.EMPTY_BYTE_STRING=new ByteString("");const Pe=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function __PRIVATE_normalizeTimestamp(e){if(__PRIVATE_hardAssert(!!e,39018),"string"==typeof e){let i=0;const s=Pe.exec(e);if(__PRIVATE_hardAssert(!!s,46558,{timestamp:e}),s[1]){let e=s[1];e=(e+"000000000").substr(0,9),i=Number(e)}const T=new Date(e);return{seconds:Math.floor(T.getTime()/1e3),nanos:i}}return{seconds:__PRIVATE_normalizeNumber(e.seconds),nanos:__PRIVATE_normalizeNumber(e.nanos)}}function __PRIVATE_normalizeNumber(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function __PRIVATE_normalizeByteString(e){return"string"==typeof e?ByteString.fromBase64String(e):ByteString.fromUint8Array(e)}function property(e,i){const s={typeString:e};return i&&(s.value=i),s}function __PRIVATE_validateJSON(e,i){if(!__PRIVATE_isPlainObject(e))throw new k(Z,"JSON must be an object");let s;for(const T in i)if(i[T]){const E=i[T].typeString,V="value"in i[T]?{value:i[T].value}:void 0;if(!(T in e)){s=`JSON missing required field: '${T}'`;break}const R=e[T];if(E&&typeof R!==E){s=`JSON field '${T}' must be a ${E}.`;break}if(void 0!==V&&R!==V.value){s=`Expected '${T}' field to equal '${V.value}'`;break}}if(s)throw new k(Z,s);return!0}const Re=-62135596800,we=1e6;class Timestamp{static now(){return Timestamp.fromMillis(Date.now())}static fromDate(e){return Timestamp.fromMillis(e.getTime())}static fromMillis(e){const i=Math.floor(e/1e3),s=Math.floor((e-1e3*i)*we);return new Timestamp(i,s)}constructor(e,i){if(this.seconds=e,this.nanoseconds=i,i<0)throw new k(Z,"Timestamp nanoseconds out of range: "+i);if(i>=1e9)throw new k(Z,"Timestamp nanoseconds out of range: "+i);if(e<Re)throw new k(Z,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new k(Z,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/we}_compareTo(e){return this.seconds===e.seconds?__PRIVATE_primitiveComparator(this.nanoseconds,e.nanoseconds):__PRIVATE_primitiveComparator(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:Timestamp._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(__PRIVATE_validateJSON(e,Timestamp._jsonSchema))return new Timestamp(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Re;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}function __PRIVATE_isServerTimestamp(e){const i=(e?.mapValue?.fields||{}).__type__?.stringValue;return"server_timestamp"===i}function __PRIVATE_getPreviousValue(e){const i=e.mapValue.fields.__previous_value__;return __PRIVATE_isServerTimestamp(i)?__PRIVATE_getPreviousValue(i):i}function __PRIVATE_getLocalWriteTime(e){const i=__PRIVATE_normalizeTimestamp(e.mapValue.fields.__local_write_time__.timestampValue);return new Timestamp(i.seconds,i.nanos)}Timestamp._jsonSchemaVersion="firestore/timestamp/1.0",Timestamp._jsonSchema={type:property("string",Timestamp._jsonSchemaVersion),seconds:property("number"),nanoseconds:property("number")};const ve="__type__",Se={},be="__vector__",Fe="value";function __PRIVATE_typeOrder(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?__PRIVATE_isServerTimestamp(e)?4:function __PRIVATE_isMaxValue(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}(e)?9007199254740991:function __PRIVATE_isVectorValue(e){const i=(e?.mapValue?.fields||{})[ve]?.stringValue;return i===be}(e)?10:11:z(28295,{value:e})}function __PRIVATE_valueEquals(e,i,s){if(e===i)return!0;const T=__PRIVATE_typeOrder(e);if(T!==__PRIVATE_typeOrder(i))return!1;switch(T){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===i.booleanValue;case 4:return __PRIVATE_getLocalWriteTime(e).isEqual(__PRIVATE_getLocalWriteTime(i));case 3:return function __PRIVATE_timestampEquals(e,i){if("string"==typeof e.timestampValue&&"string"==typeof i.timestampValue&&e.timestampValue.length===i.timestampValue.length)return e.timestampValue===i.timestampValue;const s=__PRIVATE_normalizeTimestamp(e.timestampValue),T=__PRIVATE_normalizeTimestamp(i.timestampValue);return s.seconds===T.seconds&&s.nanos===T.nanos}(e,i);case 5:return e.stringValue===i.stringValue;case 6:return function __PRIVATE_blobEquals(e,i){return __PRIVATE_normalizeByteString(e.bytesValue).isEqual(__PRIVATE_normalizeByteString(i.bytesValue))}(e,i);case 7:return e.referenceValue===i.referenceValue;case 8:return function __PRIVATE_geoPointEquals(e,i){return __PRIVATE_normalizeNumber(e.geoPointValue.latitude)===__PRIVATE_normalizeNumber(i.geoPointValue.latitude)&&__PRIVATE_normalizeNumber(e.geoPointValue.longitude)===__PRIVATE_normalizeNumber(i.geoPointValue.longitude)}(e,i);case 2:return function __PRIVATE_numberEquals(e,i,s){if("integerValue"in e&&"integerValue"in i)return __PRIVATE_normalizeNumber(e.integerValue)===__PRIVATE_normalizeNumber(i.integerValue);let T,E;return"doubleValue"in e&&"doubleValue"in i&&(T=__PRIVATE_normalizeNumber(e.doubleValue),E=__PRIVATE_normalizeNumber(i.doubleValue),T===E?__PRIVATE_isNegativeZero(T)===__PRIVATE_isNegativeZero(E):!(void 0!==s&&!s.Pe)&&isNaN(T)&&isNaN(E))}(e,i,s);case 9:return __PRIVATE_arrayEquals(e.arrayValue.values||[],i.arrayValue.values||[],((e,i)=>__PRIVATE_valueEquals(e,i,s)));case 10:case 11:return function __PRIVATE_objectEquals(e,i,s){const T=e.mapValue.fields||{},E=i.mapValue.fields||{};if(__PRIVATE_objectSize(T)!==__PRIVATE_objectSize(E))return!1;for(const e in T)if(T.hasOwnProperty(e)&&(void 0===E[e]||!__PRIVATE_valueEquals(T[e],E[e],s)))return!1;return!0}(e,i,s);default:return z(52216,{left:e})}}function __PRIVATE_arrayValueContains(e,i){return void 0!==(e.values||[]).find((e=>__PRIVATE_valueEquals(e,i)))}function __PRIVATE_valueCompare(e,i){if(e===i)return 0;const s=__PRIVATE_typeOrder(e),T=__PRIVATE_typeOrder(i);if(s!==T)return __PRIVATE_primitiveComparator(s,T);switch(s){case 0:case 9007199254740991:return 0;case 1:return __PRIVATE_primitiveComparator(e.booleanValue,i.booleanValue);case 2:return function __PRIVATE_compareNumbers(e,i){const s=__PRIVATE_normalizeNumber(e.integerValue||e.doubleValue),T=__PRIVATE_normalizeNumber(i.integerValue||i.doubleValue);return s<T?-1:s>T?1:s===T?0:isNaN(s)?isNaN(T)?0:-1:1}(e,i);case 3:return __PRIVATE_compareTimestamps(e.timestampValue,i.timestampValue);case 4:return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e),__PRIVATE_getLocalWriteTime(i));case 5:return __PRIVATE_compareUtf8Strings(e.stringValue,i.stringValue);case 6:return function __PRIVATE_compareBlobs(e,i){const s=__PRIVATE_normalizeByteString(e),T=__PRIVATE_normalizeByteString(i);return s.compareTo(T)}(e.bytesValue,i.bytesValue);case 7:return function __PRIVATE_compareReferences(e,i){const s=e.split("/"),T=i.split("/");for(let e=0;e<s.length&&e<T.length;e++){const i=__PRIVATE_primitiveComparator(s[e],T[e]);if(0!==i)return i}return __PRIVATE_primitiveComparator(s.length,T.length)}(e.referenceValue,i.referenceValue);case 8:return function __PRIVATE_compareGeoPoints(e,i){const s=__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(i.latitude));return 0!==s?s:__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.longitude),__PRIVATE_normalizeNumber(i.longitude))}(e.geoPointValue,i.geoPointValue);case 9:return __PRIVATE_compareArrays(e.arrayValue,i.arrayValue);case 10:return function __PRIVATE_compareVectors(e,i){const s=e.fields||{},T=i.fields||{},E=s[Fe]?.arrayValue,V=T[Fe]?.arrayValue,R=__PRIVATE_primitiveComparator(E?.values?.length||0,V?.values?.length||0);return 0!==R?R:__PRIVATE_compareArrays(E,V)}(e.mapValue,i.mapValue);case 11:return function __PRIVATE_compareMaps(e,i){if(e===Se&&i===Se)return 0;if(e===Se)return 1;if(i===Se)return-1;const s=e.fields||{},T=Object.keys(s),E=i.fields||{},V=Object.keys(E);T.sort(),V.sort();for(let e=0;e<T.length&&e<V.length;++e){const i=__PRIVATE_compareUtf8Strings(T[e],V[e]);if(0!==i)return i;const R=__PRIVATE_valueCompare(s[T[e]],E[V[e]]);if(0!==R)return R}return __PRIVATE_primitiveComparator(T.length,V.length)}(e.mapValue,i.mapValue);default:throw z(23264,{Ve:s})}}function __PRIVATE_compareTimestamps(e,i){if("string"==typeof e&&"string"==typeof i&&e.length===i.length)return __PRIVATE_primitiveComparator(e,i);const s=__PRIVATE_normalizeTimestamp(e),T=__PRIVATE_normalizeTimestamp(i),E=__PRIVATE_primitiveComparator(s.seconds,T.seconds);return 0!==E?E:__PRIVATE_primitiveComparator(s.nanos,T.nanos)}function __PRIVATE_compareArrays(e,i){const s=e.values||[],T=i.values||[];for(let e=0;e<s.length&&e<T.length;++e){const i=__PRIVATE_valueCompare(s[e],T[e]);if(void 0!==i&&0!==i)return i}return __PRIVATE_primitiveComparator(s.length,T.length)}function __PRIVATE_refValue(e,i){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${i.path.canonicalString()}`}}function isArray(e){return!!e&&"arrayValue"in e}function __PRIVATE_isNullValue(e){return!!e&&"nullValue"in e}function __PRIVATE_isNanValue(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function __PRIVATE_isMapValue(e){return!!e&&"mapValue"in e}function __PRIVATE_deepClone(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){const i={mapValue:{fields:{}}};return forEach(e.mapValue.fields,((e,s)=>i.mapValue.fields[e]=__PRIVATE_deepClone(s))),i}if(e.arrayValue){const i={arrayValue:{values:[]}};for(let s=0;s<(e.arrayValue.values||[]).length;++s)i.arrayValue.values[s]=__PRIVATE_deepClone(e.arrayValue.values[s]);return i}return{...e}}class Bound{constructor(e,i){this.position=e,this.inclusive=i}}function __PRIVATE_boundEquals(e,i){if(null===e)return null===i;if(null===i)return!1;if(e.inclusive!==i.inclusive||e.position.length!==i.position.length)return!1;for(let s=0;s<e.position.length;s++)if(!__PRIVATE_valueEquals(e.position[s],i.position[s]))return!1;return!0}class Filter{}class FieldFilter extends Filter{constructor(e,i,s){super(),this.field=e,this.op=i,this.value=s}static create(e,i,s){return e.isKeyField()?"in"===i||"not-in"===i?this.createKeyFieldInFilter(e,i,s):new __PRIVATE_KeyFieldFilter(e,i,s):"array-contains"===i?new __PRIVATE_ArrayContainsFilter(e,s):"in"===i?new __PRIVATE_InFilter(e,s):"not-in"===i?new __PRIVATE_NotInFilter(e,s):"array-contains-any"===i?new __PRIVATE_ArrayContainsAnyFilter(e,s):new FieldFilter(e,i,s)}static createKeyFieldInFilter(e,i,s){return"in"===i?new __PRIVATE_KeyFieldInFilter(e,s):new __PRIVATE_KeyFieldNotInFilter(e,s)}matches(e){const i=e.data.field(this.field);return"!="===this.op?null!==i&&void 0===i.nullValue&&this.matchesComparison(__PRIVATE_valueCompare(i,this.value)):null!==i&&__PRIVATE_typeOrder(this.value)===__PRIVATE_typeOrder(i)&&this.matchesComparison(__PRIVATE_valueCompare(i,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return z(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class CompositeFilter extends Filter{constructor(e,i){super(),this.filters=e,this.op=i,this.Re=null}static create(e,i){return new CompositeFilter(e,i)}matches(e){return function __PRIVATE_compositeFilterIsConjunction(e){return"and"===e.op}(this)?void 0===this.filters.find((i=>!i.matches(e))):void 0!==this.filters.find((i=>i.matches(e)))}getFlattenedFilters(){return null!==this.Re||(this.Re=this.filters.reduce(((e,i)=>e.concat(i.getFlattenedFilters())),[])),this.Re}getFilters(){return Object.assign([],this.filters)}}function __PRIVATE_filterEquals(e,i){return e instanceof FieldFilter?function __PRIVATE_fieldFilterEquals(e,i){return i instanceof FieldFilter&&e.op===i.op&&e.field.isEqual(i.field)&&__PRIVATE_valueEquals(e.value,i.value)}(e,i):e instanceof CompositeFilter?function __PRIVATE_compositeFilterEquals(e,i){return i instanceof CompositeFilter&&e.op===i.op&&e.filters.length===i.filters.length&&e.filters.reduce(((e,s,T)=>e&&__PRIVATE_filterEquals(s,i.filters[T])),!0)}(e,i):void z(19439)}class __PRIVATE_KeyFieldFilter extends FieldFilter{constructor(e,i,s){super(e,i,s),this.key=x.fromName(s.referenceValue)}matches(e){const i=x.comparator(e.key,this.key);return this.matchesComparison(i)}}class __PRIVATE_KeyFieldInFilter extends FieldFilter{constructor(e,i){super(e,"in",i),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("in",i)}matches(e){return this.keys.some((i=>i.isEqual(e.key)))}}class __PRIVATE_KeyFieldNotInFilter extends FieldFilter{constructor(e,i){super(e,"not-in",i),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("not-in",i)}matches(e){return!this.keys.some((i=>i.isEqual(e.key)))}}function __PRIVATE_extractDocumentKeysFromArrayValue(e,i){return(i.arrayValue?.values||[]).map((e=>x.fromName(e.referenceValue)))}class __PRIVATE_ArrayContainsFilter extends FieldFilter{constructor(e,i){super(e,"array-contains",i)}matches(e){const i=e.data.field(this.field);return isArray(i)&&__PRIVATE_arrayValueContains(i.arrayValue,this.value)}}class __PRIVATE_InFilter extends FieldFilter{constructor(e,i){super(e,"in",i)}matches(e){const i=e.data.field(this.field);return null!==i&&__PRIVATE_arrayValueContains(this.value.arrayValue,i)}}class __PRIVATE_NotInFilter extends FieldFilter{constructor(e,i){super(e,"not-in",i)}matches(e){if(__PRIVATE_arrayValueContains(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const i=e.data.field(this.field);return null!==i&&void 0===i.nullValue&&!__PRIVATE_array