firebase 9.12.1 → 9.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/app/dist/index.cjs.js +1 -1
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.mjs +1 -1
- package/compat/app/dist/index.cjs.js +1 -1
- package/compat/app/dist/index.esm.js +1 -1
- package/compat/app/dist/index.mjs +1 -1
- package/compat/dist/index.esm.js +2 -2
- package/compat/dist/index.node.cjs +2 -2
- package/compat/dist/index.rn.cjs.js +2 -2
- package/firebase-analytics-compat.js +1 -1
- package/firebase-analytics.js +1 -1
- package/firebase-app-check-compat.js +1 -1
- package/firebase-app-check.js +1 -1
- package/firebase-app-compat.js +2 -2
- package/firebase-app.js +5 -5
- package/firebase-auth-compat.js +1 -1
- package/firebase-auth-cordova.js +1 -1
- package/firebase-auth-react-native.js +1 -1
- package/firebase-auth.js +1 -1
- package/firebase-compat.js +3 -3
- package/firebase-compat.js.map +1 -1
- package/firebase-database-compat.js +1 -1
- package/firebase-database-compat.js.map +1 -1
- package/firebase-database.js +1 -1
- package/firebase-database.js.map +1 -1
- package/firebase-firestore-compat.js +1 -1
- package/firebase-firestore-compat.js.map +1 -1
- package/firebase-firestore-lite.js +1 -1
- package/firebase-firestore-lite.js.map +1 -1
- package/firebase-firestore.js +1 -1
- package/firebase-firestore.js.map +1 -1
- package/firebase-functions-compat.js +1 -1
- package/firebase-functions.js +1 -1
- package/firebase-installations-compat.js +1 -1
- package/firebase-installations.js +1 -1
- package/firebase-messaging-compat.js +1 -1
- package/firebase-messaging-compat.js.map +1 -1
- package/firebase-messaging-sw.js +1 -1
- package/firebase-messaging-sw.js.map +1 -1
- package/firebase-messaging.js +1 -1
- package/firebase-messaging.js.map +1 -1
- package/firebase-performance-compat.js +1 -1
- package/firebase-performance-standalone-compat.es2017.js +7 -7
- package/firebase-performance-standalone-compat.js +1 -1
- package/firebase-performance.js +1 -1
- package/firebase-remote-config-compat.js +1 -1
- package/firebase-remote-config.js +1 -1
- package/firebase-storage-compat.js +1 -1
- package/firebase-storage-compat.js.map +1 -1
- package/firebase-storage.js +1 -1
- package/firebase-storage.js.map +1 -1
- package/package.json +28 -28
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{_registerComponent as t,registerVersion as e,_getProvider as n,getApp as r,_removeServiceInstance as s,SDK_VERSION as i}from"https://www.gstatic.com/firebasejs/9.12.1/firebase-app.js";const o=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=63&s|128):55296==(64512&s)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++r)),e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=63&s|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=63&s|128)}return e},a={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(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let e=0;e<t.length;e+=3){const s=t[e],i=e+1<t.length,o=i?t[e+1]:0,a=e+2<t.length,u=a?t[e+2]:0,l=s>>2,c=(3&s)<<4|o>>4;let h=(15&o)<<2|u>>6,d=63&u;a||(d=64,i||(h=64)),r.push(n[l],n[c],n[h],n[d])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(o(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=t[n++];e[r++]=String.fromCharCode((31&s)<<6|63&i)}else if(s>239&&s<365){const i=((7&s)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(i>>10)),e[r++]=String.fromCharCode(56320+(1023&i))}else{const i=t[n++],o=t[n++];e[r++]=String.fromCharCode((15&s)<<12|(63&i)<<6|63&o)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let e=0;e<t.length;){const s=n[t.charAt(e++)],i=e<t.length?n[t.charAt(e)]:0;++e;const o=e<t.length?n[t.charAt(e)]:64;++e;const a=e<t.length?n[t.charAt(e)]:64;if(++e,null==s||null==i||null==o||null==a)throw Error();const u=s<<2|i>>4;if(r.push(u),64!==o){const t=i<<4&240|o>>2;if(r.push(t),64!==a){const t=o<<6&192|a;r.push(t)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},u=function(t){return function(t){const e=o(t);return a.encodeByteArray(e,!0)}(t).replace(/\./g,"")};const l=()=>function(){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__,c=()=>{if("undefined"==typeof document)return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(t){return}const e=t&&function(t){try{return a.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}(t[1]);return e&&JSON.parse(e)},h=()=>{try{return l()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const t=process.env.__FIREBASE_DEFAULTS__;return t?JSON.parse(t):void 0})()||c()}catch(t){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`)}},d=t=>{const e=(t=>{var e,n;return null===(n=null===(e=h())||void 0===e?void 0:e.emulatorHosts)||void 0===n?void 0:n[t]})(t);if(!e)return;const n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(n+1),10);return"["===e[0]?[e.substring(1,n-1),r]:[e.substring(0,n),r]};class f extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,f.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,p.prototype.create)}}class p{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},r=`${this.service}/${t}`,s=this.errors[t],i=s?function(t,e){return t.replace(m,((t,n)=>{const r=e[n];return null!=r?String(r):`<${n}?>`}))}(s,n):"Error",o=`${this.serviceName}: ${i} (${r}).`;return new f(r,o,n)}}const m=/\{\$([^}]+)}/g;function g(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const s of n){if(!r.includes(s))return!1;const n=t[s],i=e[s];if(y(n)&&y(i)){if(!g(n,i))return!1}else if(n!==i)return!1}for(const t of r)if(!n.includes(t))return!1;return!0}function y(t){return null!==t&&"object"==typeof t}function w(t){return t&&t._delegate?t._delegate:t}var _;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(_||(_={}));const v={debug:_.DEBUG,verbose:_.VERBOSE,info:_.INFO,warn:_.WARN,error:_.ERROR,silent:_.SILENT},b=_.INFO,E={[_.DEBUG]:"log",[_.VERBOSE]:"log",[_.INFO]:"info",[_.WARN]:"warn",[_.ERROR]:"error"},S=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),s=E[e];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[s](`[${r}] ${t.name}:`,...n)};class T{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}T.UNAUTHENTICATED=new T(null),T.GOOGLE_CREDENTIALS=new T("google-credentials-uid"),T.FIRST_PARTY=new T("first-party-uid"),T.MOCK_USER=new T("mock-user");let A="9.12.1";const k=new class{constructor(t){this.name=t,this._logLevel=b,this._logHandler=S,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in _))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?v[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,_.DEBUG,...t),this._logHandler(this,_.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,_.VERBOSE,...t),this._logHandler(this,_.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,_.INFO,...t),this._logHandler(this,_.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,_.WARN,...t),this._logHandler(this,_.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,_.ERROR,...t),this._logHandler(this,_.ERROR,...t)}}("@firebase/firestore");function I(t){k.setLogLevel(t)}function V(t,...e){if(k.logLevel<=_.DEBUG){const n=e.map(R);k.debug(`Firestore (${A}): ${t}`,...n)}}function D(t,...e){if(k.logLevel<=_.ERROR){const n=e.map(R);k.error(`Firestore (${A}): ${t}`,...n)}}function N(t,...e){if(k.logLevel<=_.WARN){const n=e.map(R);k.warn(`Firestore (${A}): ${t}`,...n)}}function R(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function F(t="Unexpected state"){const e=`FIRESTORE (${A}) INTERNAL ASSERTION FAILED: `+t;throw D(e),new Error(e)}function L(t,e){t||F()}function O(t,e){return t}const x="cancelled",C="unknown",P="invalid-argument",q="deadline-exceeded",M="not-found",B="permission-denied",$="unauthenticated",U="resource-exhausted",j="failed-precondition",W="aborted",G="out-of-range",H="unimplemented",z="internal",K="unavailable";class Q extends f{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Y{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class J{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class X{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(T.UNAUTHENTICATED)))}shutdown(){}}class Z{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class tt{constructor(t){this.auth=null,t.onInit((t=>{this.auth=t}))}getToken(){return this.auth?this.auth.getToken().then((t=>t?(L("string"==typeof t.accessToken),new J(t.accessToken,new T(this.auth.getUid()))):null)):Promise.resolve(null)}invalidateToken(){}start(t,e){}shutdown(){}}class et{constructor(t,e,n,r){this.t=t,this.i=e,this.o=n,this.u=r,this.type="FirstParty",this.user=T.FIRST_PARTY,this.h=new Map}l(){return this.u?this.u():(L(!("object"!=typeof this.t||null===this.t||!this.t.auth||!this.t.auth.getAuthHeaderValueForFirstParty)),this.t.auth.getAuthHeaderValueForFirstParty([]))}get headers(){this.h.set("X-Goog-AuthUser",this.i);const t=this.l();return t&&this.h.set("Authorization",t),this.o&&this.h.set("X-Goog-Iam-Authorization-Token",this.o),this.h}}class nt{constructor(t,e,n,r){this.t=t,this.i=e,this.o=n,this.u=r}getToken(){return Promise.resolve(new et(this.t,this.i,this.o,this.u))}start(t,e){t.enqueueRetryable((()=>e(T.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class rt{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class st{constructor(t){this.m=t,this.appCheck=null,t.onInit((t=>{this.appCheck=t}))}getToken(){return this.appCheck?this.appCheck.getToken().then((t=>t?(L("string"==typeof t.token),new rt(t.token)):null)):Promise.resolve(null)}invalidateToken(){}start(t,e){}shutdown(){}}class it{constructor(t,e,n,r,s,i,o,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=s,this.forceLongPolling=i,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class ot{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new ot("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(t){return t instanceof ot&&t.projectId===this.projectId&&t.database===this.database}}class at{constructor(t,e,n){void 0===e?e=0:e>t.length&&F(),void 0===n?n=t.length-e:n>t.length-e&&F(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===at.comparator(this,t)}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof at?t.forEach((t=>{e.push(t)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}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(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let r=0;r<n;r++){const n=t.get(r),s=e.get(r);if(n<s)return-1;if(n>s)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class ut extends at{construct(t,e,n){return new ut(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new Q(P,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((t=>t.length>0)))}return new ut(e)}static emptyPath(){return new ut([])}}const lt=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ct extends at{construct(t,e,n){return new ct(t,e,n)}static isValidIdentifier(t){return lt.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ct.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new ct(["__name__"])}static fromServerFormat(t){const e=[];let n="",r=0;const s=()=>{if(0===n.length)throw new Q(P,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let i=!1;for(;r<t.length;){const e=t[r];if("\\"===e){if(r+1===t.length)throw new Q(P,"Path has trailing escape character: "+t);const e=t[r+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new Q(P,"Path has invalid escape sequence: "+t);n+=e,r+=2}else"`"===e?(i=!i,r++):"."!==e||i?(n+=e,r++):(s(),r++)}if(s(),i)throw new Q(P,"Unterminated ` in path: "+t);return new ct(e)}static emptyPath(){return new ct([])}}class ht{constructor(t){this.path=t}static fromPath(t){return new ht(ut.fromString(t))}static fromName(t){return new ht(ut.fromString(t).popFirst(5))}static empty(){return new ht(ut.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return null!==t&&0===ut.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return ut.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new ht(new ut(t.slice()))}}function dt(t,e,n){if(!n)throw new Q(P,`Function ${t}() cannot be called with an empty ${e}.`)}function ft(t){if(!ht.isDocumentKey(t))throw new Q(P,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function pt(t){if(ht.isDocumentKey(t))throw new Q(P,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function mt(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{const e=function(t){return t.constructor?t.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return"function"==typeof t?"a function":F()}function gt(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Q(P,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=mt(t);throw new Q(P,`Expected type '${e.name}', but it was: ${n}`)}}return t}function yt(t,e){if(e<=0)throw new Q(P,`Function ${t}() requires a positive number, but it was: ${e}.`)}function wt(t){return null==t}function _t(t){return 0===t&&1/t==-1/0}const vt={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};var bt,Et;function St(t){if(void 0===t)return D("RPC_ERROR","HTTP error has no status"),C;switch(t){case 200:return"ok";case 400:return j;case 401:return $;case 403:return B;case 404:return M;case 409:return W;case 416:return G;case 429:return U;case 499:return x;case 500:return C;case 501:return H;case 503:return K;case 504:return q;default:return t>=200&&t<300?"ok":t>=400&&t<500?j:t>=500&&t<600?z:C}}(Et=bt||(bt={}))[Et.OK=0]="OK",Et[Et.CANCELLED=1]="CANCELLED",Et[Et.UNKNOWN=2]="UNKNOWN",Et[Et.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Et[Et.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Et[Et.NOT_FOUND=5]="NOT_FOUND",Et[Et.ALREADY_EXISTS=6]="ALREADY_EXISTS",Et[Et.PERMISSION_DENIED=7]="PERMISSION_DENIED",Et[Et.UNAUTHENTICATED=16]="UNAUTHENTICATED",Et[Et.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Et[Et.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Et[Et.ABORTED=10]="ABORTED",Et[Et.OUT_OF_RANGE=11]="OUT_OF_RANGE",Et[Et.UNIMPLEMENTED=12]="UNIMPLEMENTED",Et[Et.INTERNAL=13]="INTERNAL",Et[Et.UNAVAILABLE=14]="UNAVAILABLE",Et[Et.DATA_LOSS=15]="DATA_LOSS";class Tt extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.p=e+"://"+t.host,this.g="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get v(){return!1}I(t,e,n,r,s){const i=this.T(t,e);V("RestConnection","Sending: ",i,n);const o={};return this.A(o,r,s),this.R(t,i,o,n).then((t=>(V("RestConnection","Received: ",t),t)),(e=>{throw N("RestConnection",`${t} failed with error: `,e,"url: ",i,"request:",n),e}))}P(t,e,n,r,s,i){return this.I(t,e,n,r,s)}A(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+A,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}T(t,e){const n=vt[t];return`${this.p}/v1/${e}:${n}`}}{constructor(t,e){super(t),this.V=e}N(t,e){throw new Error("Not supported by FetchConnection")}async R(t,e,n,r){const s=JSON.stringify(r);let i;try{i=await this.V(e,{method:"POST",headers:n,body:s})}catch(t){throw new Q(St(t.status),"Request failed with error: "+t.statusText)}if(!i.ok)throw new Q(St(i.status),"Request failed with error: "+i.statusText);return i.json()}}function At(t){const e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let e=0;e<t;e++)n[e]=Math.floor(256*Math.random());return n}class kt{static D(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const r=At(40);for(let s=0;s<r.length;++s)n.length<20&&r[s]<e&&(n+=t.charAt(r[s]%t.length))}return n}}function It(t,e){return t<e?-1:t>e?1:0}function Vt(t,e,n){return t.length===e.length&&t.every(((t,r)=>n(t,e[r])))}class Dt{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new Q(P,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new Q(P,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Q(P,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new Q(P,"Timestamp seconds out of range: "+t)}static now(){return Dt.fromMillis(Date.now())}static fromDate(t){return Dt.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new Dt(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?It(this.nanoseconds,t.nanoseconds):It(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class Nt{constructor(t){this.timestamp=t}static fromTimestamp(t){return new Nt(t)}static min(){return new Nt(new Dt(0,0))}static max(){return new Nt(new Dt(253402300799,999999999))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}function Rt(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Ft(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}class Lt{constructor(t,e){this.comparator=t,this.root=e||xt.EMPTY}insert(t,e){return new Lt(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,xt.BLACK,null,null))}remove(t){return new Lt(this.comparator,this.root.remove(t,this.comparator).copy(null,null,xt.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Ot(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Ot(this.root,t,this.comparator,!1)}getReverseIterator(){return new Ot(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Ot(this.root,t,this.comparator,!0)}}class Ot{constructor(t,e,n,r){this.isReverse=r,this.nodeStack=[];let s=1;for(;!t.isEmpty();)if(s=e?n(t.key,e):1,e&&r&&(s*=-1),s<0)t=this.isReverse?t.left:t.right;else{if(0===s){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class xt{constructor(t,e,n,r,s){this.key=t,this.value=e,this.color=null!=n?n:xt.RED,this.left=null!=r?r:xt.EMPTY,this.right=null!=s?s:xt.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,r,s){return new xt(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=s?s:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}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(t,e,n){let r=this;const s=n(t,r.key);return r=s<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===s?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return xt.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===e(t,r.key)){if(r.right.isEmpty())return xt.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,xt.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,xt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw F();if(this.right.isRed())throw F();const t=this.left.check();if(t!==this.right.check())throw F();return t+(this.isRed()?0:1)}}xt.EMPTY=null,xt.RED=!0,xt.BLACK=!1,xt.EMPTY=new class{constructor(){this.size=0}get key(){throw F()}get value(){throw F()}get color(){throw F()}get left(){throw F()}get right(){throw F()}copy(t,e,n,r,s){return this}insert(t,e,n){return new xt(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class Ct{constructor(t){this.comparator=t,this.data=new Lt(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Pt(this.data.getIterator())}getIteratorFrom(t){return new Pt(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach((t=>{e=e.add(t)})),e}isEqual(t){if(!(t instanceof Ct))return!1;if(this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(0!==this.comparator(t,r))return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new Ct(this.comparator);return e.data=t,e}}class Pt{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class qt{constructor(t){this.fields=t,t.sort(ct.comparator)}static empty(){return new qt([])}unionWith(t){let e=new Ct(ct.comparator);for(const t of this.fields)e=e.add(t);for(const n of t)e=e.add(n);return new qt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Vt(this.fields,t.fields,((t,e)=>t.isEqual(e)))}}class Mt{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new Mt(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new Mt(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return It(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}Mt.EMPTY_BYTE_STRING=new Mt("");const Bt=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function $t(t){if(L(!!t),"string"==typeof t){let e=0;const n=Bt.exec(t);if(L(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Ut(t.seconds),nanos:Ut(t.nanos)}}function Ut(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function jt(t){return"string"==typeof t?Mt.fromBase64String(t):Mt.fromUint8Array(t)}function Wt(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Gt(t){const e=t.mapValue.fields.__previous_value__;return Wt(e)?Gt(e):e}function Ht(t){const e=$t(t.mapValue.fields.__local_write_time__.timestampValue);return new Dt(e.seconds,e.nanos)}const zt={fields:{__type__:{stringValue:"__max__"}}};function Kt(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?Wt(t)?4:function(t){return"__max__"===(((t.mapValue||{}).fields||{}).__type__||{}).stringValue}(t)?9007199254740991:10:F()}function Qt(t,e){if(t===e)return!0;const n=Kt(t);if(n!==Kt(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Ht(t).isEqual(Ht(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;const n=$t(t.timestampValue),r=$t(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return jt(t.bytesValue).isEqual(jt(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return Ut(t.geoPointValue.latitude)===Ut(e.geoPointValue.latitude)&&Ut(t.geoPointValue.longitude)===Ut(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return Ut(t.integerValue)===Ut(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=Ut(t.doubleValue),r=Ut(e.doubleValue);return n===r?_t(n)===_t(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return Vt(t.arrayValue.values||[],e.arrayValue.values||[],Qt);case 10:return function(t,e){const n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(Rt(n)!==Rt(r))return!1;for(const t in n)if(n.hasOwnProperty(t)&&(void 0===r[t]||!Qt(n[t],r[t])))return!1;return!0}(t,e);default:return F()}}function Yt(t,e){return void 0!==(t.values||[]).find((t=>Qt(t,e)))}function Jt(t,e){if(t===e)return 0;const n=Kt(t),r=Kt(e);if(n!==r)return It(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return It(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=Ut(t.integerValue||t.doubleValue),r=Ut(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return Xt(t.timestampValue,e.timestampValue);case 4:return Xt(Ht(t),Ht(e));case 5:return It(t.stringValue,e.stringValue);case 6:return function(t,e){const n=jt(t),r=jt(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),r=e.split("/");for(let t=0;t<n.length&&t<r.length;t++){const e=It(n[t],r[t]);if(0!==e)return e}return It(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){const n=It(Ut(t.latitude),Ut(e.latitude));return 0!==n?n:It(Ut(t.longitude),Ut(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){const n=t.values||[],r=e.values||[];for(let t=0;t<n.length&&t<r.length;++t){const e=Jt(n[t],r[t]);if(e)return e}return It(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){if(t===zt&&e===zt)return 0;if(t===zt)return 1;if(e===zt)return-1;const n=t.fields||{},r=Object.keys(n),s=e.fields||{},i=Object.keys(s);r.sort(),i.sort();for(let t=0;t<r.length&&t<i.length;++t){const e=It(r[t],i[t]);if(0!==e)return e;const o=Jt(n[r[t]],s[i[t]]);if(0!==o)return o}return It(r.length,i.length)}(t.mapValue,e.mapValue);default:throw F()}}function Xt(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return It(t,e);const n=$t(t),r=$t(e),s=It(n.seconds,r.seconds);return 0!==s?s:It(n.nanos,r.nanos)}function Zt(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function te(t){return!!t&&"arrayValue"in t}function ee(t){return!!t&&"nullValue"in t}function ne(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function re(t){return!!t&&"mapValue"in t}function se(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const e={mapValue:{fields:{}}};return Ft(t.mapValue.fields,((t,n)=>e.mapValue.fields[t]=se(n))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=se(t.arrayValue.values[n]);return e}return Object.assign({},t)}class ie{constructor(t){this.value=t}static empty(){return new ie({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!re(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=se(e)}setAll(t){let e=ct.emptyPath(),n={},r=[];t.forEach(((t,s)=>{if(!e.isImmediateParentOf(s)){const t=this.getFieldsMap(e);this.applyChanges(t,n,r),n={},r=[],e=s.popLast()}t?n[s.lastSegment()]=se(t):r.push(s.lastSegment())}));const s=this.getFieldsMap(e);this.applyChanges(s,n,r)}delete(t){const e=this.field(t.popLast());re(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Qt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let r=e.mapValue.fields[t.get(n)];re(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields}applyChanges(t,e,n){Ft(e,((e,n)=>t[e]=n));for(const e of n)delete t[e]}clone(){return new ie(se(this.value))}}class oe{constructor(t,e,n,r,s,i){this.key=t,this.documentType=e,this.version=n,this.readTime=r,this.data=s,this.documentState=i}static newInvalidDocument(t){return new oe(t,0,Nt.min(),Nt.min(),ie.empty(),0)}static newFoundDocument(t,e,n){return new oe(t,1,e,Nt.min(),n,0)}static newNoDocument(t,e){return new oe(t,2,e,Nt.min(),ie.empty(),0)}static newUnknownDocument(t,e){return new oe(t,3,e,Nt.min(),ie.empty(),2)}convertToFoundDocument(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=ie.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=ie.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Nt.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(t){return t instanceof oe&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new oe(this.key,this.documentType,this.version,this.readTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class ae{constructor(t,e=null,n=[],r=[],s=null,i=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=s,this.startAt=i,this.endAt=o,this.$=null}}function ue(t,e=null,n=[],r=[],s=null,i=null,o=null){return new ae(t,e,n,r,s,i,o)}class le extends class{}{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.F(t,e,n):new ce(t,e,n):"array-contains"===e?new pe(t,n):"in"===e?new me(t,n):"not-in"===e?new ge(t,n):"array-contains-any"===e?new ye(t,n):new le(t,e,n)}static F(t,e,n){return"in"===e?new he(t,n):new de(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&this.S(Jt(e,this.value)):null!==e&&Kt(this.value)===Kt(e)&&this.S(Jt(e,this.value))}S(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return F()}}q(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class ce extends le{constructor(t,e,n){super(t,e,n),this.key=ht.fromName(n.referenceValue)}matches(t){const e=ht.comparator(t.key,this.key);return this.S(e)}}class he extends le{constructor(t,e){super(t,"in",e),this.keys=fe("in",e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class de extends le{constructor(t,e){super(t,"not-in",e),this.keys=fe("not-in",e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function fe(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((t=>ht.fromName(t.referenceValue)))}class pe extends le{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return te(e)&&Yt(e.arrayValue,this.value)}}class me extends le{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Yt(this.value.arrayValue,e)}}class ge extends le{constructor(t,e){super(t,"not-in",e)}matches(t){if(Yt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&!Yt(this.value.arrayValue,e)}}class ye extends le{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!te(e)||!e.arrayValue.values)&&e.arrayValue.values.some((t=>Yt(this.value.arrayValue,t)))}}class we{constructor(t,e){this.position=t,this.inclusive=e}}class _e{constructor(t,e="asc"){this.field=t,this.dir=e}}function ve(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function be(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.inclusive!==e.inclusive||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!Qt(t.position[n],e.position[n]))return!1;return!0}class Ee{constructor(t,e=null,n=[],r=[],s=null,i="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=s,this.limitType=i,this.startAt=o,this.endAt=a,this.O=null,this.k=null,this.startAt,this.endAt}}function Se(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Te(t){for(const e of t.filters)if(e.q())return e.field;return null}function Ae(t){return null!==t.collectionGroup}function ke(t){const e=O(t);if(null===e.O){e.O=[];const t=Te(e),n=Se(e);if(null!==t&&null===n)t.isKeyField()||e.O.push(new _e(t)),e.O.push(new _e(ct.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.O.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.O.push(new _e(ct.keyField(),t))}}}return e.O}function Ie(t){const e=O(t);if(!e.k)if("F"===e.limitType)e.k=ue(e.path,e.collectionGroup,ke(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of ke(e)){const e="desc"===n.dir?"asc":"desc";t.push(new _e(n.field,e))}const n=e.endAt?new we(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new we(e.startAt.position,e.startAt.inclusive):null;e.k=ue(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e.k}function Ve(t,e){return function(t){return"number"==typeof t&&Number.isInteger(t)&&!_t(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}(e)?function(t){return{integerValue:""+t}}(e):function(t,e){if(t.C){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:_t(e)?"-0":e}}(t,e)}class De{constructor(){this._=void 0}}class Ne extends De{}class Re extends De{constructor(t){super(),this.elements=t}}class Fe extends De{constructor(t){super(),this.elements=t}}class Le extends De{constructor(t,e){super(),this.L=t,this.M=e}}class Oe{constructor(t,e){this.field=t,this.transform=e}}class xe{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new xe}static exists(t){return new xe(void 0,t)}static updateTime(t){return new xe(t)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}class Ce{}class Pe extends Ce{constructor(t,e,n,r=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class qe extends Ce{constructor(t,e,n,r,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=r,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}class Me extends Ce{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Be extends Ce{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}const $e={asc:"ASCENDING",desc:"DESCENDING"},Ue={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"};class je{constructor(t,e){this.databaseId=t,this.C=e}}function We(t,e){return t.C?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Ge(t,e){return t.C?e.toBase64():e.toUint8Array()}function He(t,e){return We(t,e.toTimestamp())}function ze(t){return L(!!t),Nt.fromTimestamp(function(t){const e=$t(t);return new Dt(e.seconds,e.nanos)}(t))}function Ke(t,e){return function(t){return new ut(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function Qe(t,e){return Ke(t.databaseId,e.path)}function Ye(t,e){const n=function(t){const e=ut.fromString(t);return L(on(e)),e}(e);if(n.get(1)!==t.databaseId.projectId)throw new Q(P,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Q(P,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new ht((L((r=n).length>4&&"documents"===r.get(4)),r.popFirst(5)));var r}function Je(t,e){return Ke(t.databaseId,e)}function Xe(t){return new ut(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function Ze(t,e,n){return{name:Qe(t,e),fields:n.value.mapValue.fields}}function tn(t,e){const n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Je(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Je(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);const s=function(t){if(0===t.length)return;const e=t.map((t=>function(t){if("=="===t.op){if(ne(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NAN"}};if(ee(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(ne(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NOT_NAN"}};if(ee(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:rn(t.field),op:nn(t.op),value:t.value}}}(t)));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}(e.filters);s&&(n.structuredQuery.where=s);const i=function(t){if(0!==t.length)return t.map((t=>function(t){return{field:rn(t.field),direction:en(t.dir)}}(t)))}(e.orderBy);i&&(n.structuredQuery.orderBy=i);const o=function(t,e){return t.C||wt(e)?e:{value:e}}(t,e.limit);var a;return null!==o&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt={before:(a=e.startAt).inclusive,values:a.position}),e.endAt&&(n.structuredQuery.endAt=function(t){return{before:!t.inclusive,values:t.position}}(e.endAt)),n}function en(t){return $e[t]}function nn(t){return Ue[t]}function rn(t){return{fieldPath:t.canonicalString()}}function sn(t){const e=[];return t.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function on(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function an(t){return new je(t,!0)}class un{constructor(t,e,n=1e3,r=1.5,s=6e4){this.U=t,this.timerId=e,this.j=n,this.B=r,this.G=s,this.W=0,this.K=null,this.Y=Date.now(),this.reset()}reset(){this.W=0}H(){this.W=this.G}J(t){this.cancel();const e=Math.floor(this.W+this.X()),n=Math.max(0,Date.now()-this.Y),r=Math.max(0,e-n);r>0&&V("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.W} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.K=this.U.enqueueAfterDelay(this.timerId,r,(()=>(this.Y=Date.now(),t()))),this.W*=this.B,this.W<this.j&&(this.W=this.j),this.W>this.G&&(this.W=this.G)}Z(){null!==this.K&&(this.K.skipDelay(),this.K=null)}cancel(){null!==this.K&&(this.K.cancel(),this.K=null)}X(){return(Math.random()-.5)*this.W}}class ln extends class{}{constructor(t,e,n,r){super(),this.authCredentials=t,this.appCheckCredentials=e,this.tt=n,this.L=r,this.et=!1}nt(){if(this.et)throw new Q(j,"The client has already been terminated.")}I(t,e,n){return this.nt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,s])=>this.tt.I(t,e,n,r,s))).catch((t=>{throw"FirebaseError"===t.name?(t.code===$&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Q(C,t.toString())}))}P(t,e,n,r){return this.nt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,i])=>this.tt.P(t,e,n,s,i,r))).catch((t=>{throw"FirebaseError"===t.name?(t.code===$&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Q(C,t.toString())}))}terminate(){this.et=!0}}async function cn(t,e){const n=O(t),r=Xe(n.L)+"/documents",s={writes:e.map((t=>function(t,e){let n;if(e instanceof Pe)n={update:Ze(t,e.key,e.value)};else if(e instanceof Me)n={delete:Qe(t,e.key)};else if(e instanceof qe)n={update:Ze(t,e.key,e.data),updateMask:sn(e.fieldMask)};else{if(!(e instanceof Be))return F();n={verify:Qe(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof Ne)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Re)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Fe)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Le)return{fieldPath:e.field.canonicalString(),increment:n.M};throw F()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:He(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:F()}(t,e.precondition)),n}(n.L,t)))};await n.I("Commit",r,s)}async function hn(t,e){const n=O(t),r=Xe(n.L)+"/documents",s={documents:e.map((t=>Qe(n.L,t)))},i=await n.P("BatchGetDocuments",r,s,e.length),o=new Map;i.forEach((t=>{const e=function(t,e){return"found"in e?function(t,e){L(!!e.found),e.found.name,e.found.updateTime;const n=Ye(t,e.found.name),r=ze(e.found.updateTime),s=new ie({mapValue:{fields:e.found.fields}});return oe.newFoundDocument(n,r,s)}(t,e):"missing"in e?function(t,e){L(!!e.missing),L(!!e.readTime);const n=Ye(t,e.missing),r=ze(e.readTime);return oe.newNoDocument(n,r)}(t,e):F()}(n.L,t);o.set(e.key.toString(),e)}));const a=[];return e.forEach((t=>{const e=o.get(t.toString());L(!!e),a.push(e)})),a}const dn=new Map;function fn(t){if(t._terminated)throw new Q(j,"The client has already been terminated.");if(!dn.has(t)){V("ComponentProvider","Initializing Datastore");const i=function(t){return new Tt(t,fetch.bind(null))}((e=t._databaseId,n=t.app.options.appId||"",r=t._persistenceKey,s=t._freezeSettings(),new it(e,n,r,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams))),o=an(t._databaseId),a=function(t,e,n,r){return new ln(t,e,n,r)}(t._authCredentials,t._appCheckCredentials,i,o);dn.set(t,a)}var e,n,r,s;return dn.get(t)}class pn{constructor(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new Q(P,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Q(P,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,function(t,e,n,r){if(!0===e&&!0===r)throw new Q(P,"experimentalForceLongPolling and experimentalAutoDetectLongPolling cannot be used together.")}(0,t.experimentalForceLongPolling,0,t.experimentalAutoDetectLongPolling)}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class mn{constructor(t,e,n,r){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new pn({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new Q(j,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new Q(j,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new pn(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new X;switch(t.type){case"gapi":const e=t.client;return new nt(e,t.sessionIndex||"0",t.iamToken||null,t.authTokenFactory||null);case"provider":return t.client;default:throw new Q(P,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=dn.get(t);e&&(V("ComponentProvider","Removing Datastore"),dn.delete(t),e.terminate())}(this),Promise.resolve()}}function gn(t,e,r){r||(r="(default)");const s=n(t,"firestore/lite");if(s.isInitialized(r))throw new Q(j,"Firestore can only be initialized once per app.");return s.initialize({options:e,instanceIdentifier:r})}function yn(t,e){const s="object"==typeof t?t:r(),i="string"==typeof t?t:e||"(default)",o=n(s,"firestore/lite").getImmediate({identifier:i});if(!o._initialized){const t=d("firestore");t&&wn(o,...t)}return o}function wn(t,e,n,r={}){var s;const i=(t=gt(t,mn))._getSettings();if("firestore.googleapis.com"!==i.host&&i.host!==e&&N("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},i),{host:`${e}:${n}`,ssl:!1})),r.mockUserToken){let e,n;if("string"==typeof r.mockUserToken)e=r.mockUserToken,n=T.MOCK_USER;else{e=function(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=e||"demo-project",r=t.iat||0,s=t.sub||t.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const i=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},t);return[u(JSON.stringify({alg:"none",type:"JWT"})),u(JSON.stringify(i)),""].join(".")}(r.mockUserToken,null===(s=t._app)||void 0===s?void 0:s.options.projectId);const i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new Q(P,"mockUserToken must contain 'sub' or 'user_id' field!");n=new T(i)}t._authCredentials=new Z(new J(e,n))}}function _n(t){return t=gt(t,mn),s(t.app,"firestore/lite"),t._delete()}class vn{constructor(){this.type="AggregateField"}}class bn{constructor(t,e){this._data=e,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._data}}class En{constructor(t,e,n){this.query=t,this.datastore=e,this.userDataWriter=n}run(){return async function(t,e){const n=O(t),r=function(t,e){const n=tn(t,e);return{structuredAggregationQuery:{aggregations:[{count:{},alias:"count_alias"}],structuredQuery:n.structuredQuery},parent:n.parent}}(n.L,Ie(e)),s=r.parent;return n.tt.v||delete r.parent,(await n.P("RunAggregationQuery",s,r,1)).filter((t=>!!t.result)).map((t=>t.result.aggregateFields))}(this.datastore,this.query._query).then((t=>{L(void 0!==t[0]);const e=Object.entries(t[0]).filter((([t,e])=>"count_alias"===t)).map((([t,e])=>this.userDataWriter.convertValue(e)))[0];return L("number"==typeof e),Promise.resolve(new bn(this.query,{count:e}))}))}}class Sn{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new An(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Sn(this.firestore,t,this._key)}}class Tn{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new Tn(this.firestore,t,this._query)}}class An extends Tn{constructor(t,e,n){super(t,e,new Ee(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Sn(this.firestore,null,new ht(t))}withConverter(t){return new An(this.firestore,t,this._path)}}function kn(t,e,...n){if(t=w(t),dt("collection","path",e),t instanceof mn){const r=ut.fromString(e,...n);return pt(r),new An(t,null,r)}{if(!(t instanceof Sn||t instanceof An))throw new Q(P,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ut.fromString(e,...n));return pt(r),new An(t.firestore,null,r)}}function In(t,e){if(t=gt(t,mn),dt("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new Q(P,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Tn(t,null,function(t){return new Ee(ut.emptyPath(),t)}(e))}function Vn(t,e,...n){if(t=w(t),1===arguments.length&&(e=kt.D()),dt("doc","path",e),t instanceof mn){const r=ut.fromString(e,...n);return ft(r),new Sn(t,null,new ht(r))}{if(!(t instanceof Sn||t instanceof An))throw new Q(P,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ut.fromString(e,...n));return ft(r),new Sn(t.firestore,t instanceof An?t.converter:null,new ht(r))}}function Dn(t,e){return t=w(t),e=w(e),(t instanceof Sn||t instanceof An)&&(e instanceof Sn||e instanceof An)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Nn(t,e){return t=w(t),e=w(e),t instanceof Tn&&e instanceof Tn&&t.firestore===e.firestore&&function(t,e){return function(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!ve(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let s=0;s<t.filters.length;s++)if(n=t.filters[s],r=e.filters[s],n.op!==r.op||!n.field.isEqual(r.field)||!Qt(n.value,r.value))return!1;var n,r;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!be(t.startAt,e.startAt)&&be(t.endAt,e.endAt)}(Ie(t),Ie(e))&&t.limitType===e.limitType}(t._query,e._query)&&t.converter===e.converter}class Rn{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Rn(Mt.fromBase64String(t))}catch(t){throw new Q(P,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new Rn(Mt.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}class Fn{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Q(P,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ct(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function Ln(){return new Fn("__name__")}class On{constructor(t){this._methodName=t}}class xn{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new Q(P,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new Q(P,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return It(this._lat,t._lat)||It(this._long,t._long)}}const Cn=/^__.*__$/;class Pn{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new qe(t,this.data,this.fieldMask,e,this.fieldTransforms):new Pe(t,this.data,e,this.fieldTransforms)}}class qn{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new qe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Mn(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw F()}}class Bn{constructor(t,e,n,r,s,i){this.settings=t,this.databaseId=e,this.L=n,this.ignoreUndefinedProperties=r,void 0===s&&this.rt(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get st(){return this.settings.st}it(t){return new Bn(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.L,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ot(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.it({path:n,ut:!1});return r.ct(t),r}at(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.it({path:n,ut:!1});return r.rt(),r}ht(t){return this.it({path:void 0,ut:!0})}lt(t){return or(t,this.settings.methodName,this.settings.ft||!1,this.path,this.settings.dt)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}rt(){if(this.path)for(let t=0;t<this.path.length;t++)this.ct(this.path.get(t))}ct(t){if(0===t.length)throw this.lt("Document fields must not be empty");if(Mn(this.st)&&Cn.test(t))throw this.lt('Document fields cannot begin and end with "__"')}}class $n{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.L=n||an(t)}wt(t,e,n,r=!1){return new Bn({st:t,methodName:e,dt:n,path:ct.emptyPath(),ut:!1,ft:r},this.databaseId,this.L,this.ignoreUndefinedProperties)}}function Un(t){const e=t._freezeSettings(),n=an(t._databaseId);return new $n(t._databaseId,!!e.ignoreUndefinedProperties,n)}function jn(t,e,n,r,s,i={}){const o=t.wt(i.merge||i.mergeFields?2:0,e,n,s);nr("Data must be an object, but it was:",o,r);const a=tr(r,o);let u,l;if(i.merge)u=new qt(o.fieldMask),l=o.fieldTransforms;else if(i.mergeFields){const t=[];for(const r of i.mergeFields){const s=rr(e,r,n);if(!o.contains(s))throw new Q(P,`Field '${s}' is specified in your field mask but missing from your input data.`);ar(t,s)||t.push(s)}u=new qt(t),l=o.fieldTransforms.filter((t=>u.covers(t.field)))}else u=null,l=o.fieldTransforms;return new Pn(new ie(a),u,l)}class Wn extends On{_toFieldTransform(t){if(2!==t.st)throw 1===t.st?t.lt(`${this._methodName}() can only appear at the top level of your update data`):t.lt(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Wn}}function Gn(t,e,n){return new Bn({st:3,dt:e.settings.dt,methodName:t._methodName,ut:n},e.databaseId,e.L,e.ignoreUndefinedProperties)}class Hn extends On{_toFieldTransform(t){return new Oe(t.path,new Ne)}isEqual(t){return t instanceof Hn}}class zn extends On{constructor(t,e){super(t),this.yt=e}_toFieldTransform(t){const e=Gn(this,t,!0),n=this.yt.map((t=>Zn(t,e))),r=new Re(n);return new Oe(t.path,r)}isEqual(t){return this===t}}class Kn extends On{constructor(t,e){super(t),this.yt=e}_toFieldTransform(t){const e=Gn(this,t,!0),n=this.yt.map((t=>Zn(t,e))),r=new Fe(n);return new Oe(t.path,r)}isEqual(t){return this===t}}class Qn extends On{constructor(t,e){super(t),this._t=e}_toFieldTransform(t){const e=new Le(t.L,Ve(t.L,this._t));return new Oe(t.path,e)}isEqual(t){return this===t}}function Yn(t,e,n,r){const s=t.wt(1,e,n);nr("Data must be an object, but it was:",s,r);const i=[],o=ie.empty();Ft(r,((t,r)=>{const a=ir(e,t,n);r=w(r);const u=s.at(a);if(r instanceof Wn)i.push(a);else{const t=Zn(r,u);null!=t&&(i.push(a),o.set(a,t))}}));const a=new qt(i);return new qn(o,a,s.fieldTransforms)}function Jn(t,e,n,r,s,i){const o=t.wt(1,e,n),a=[rr(e,r,n)],u=[s];if(i.length%2!=0)throw new Q(P,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let t=0;t<i.length;t+=2)a.push(rr(e,i[t])),u.push(i[t+1]);const l=[],c=ie.empty();for(let t=a.length-1;t>=0;--t)if(!ar(l,a[t])){const e=a[t];let n=u[t];n=w(n);const r=o.at(e);if(n instanceof Wn)l.push(e);else{const t=Zn(n,r);null!=t&&(l.push(e),c.set(e,t))}}const h=new qt(l);return new qn(c,h,o.fieldTransforms)}function Xn(t,e,n,r=!1){return Zn(n,t.wt(r?4:3,e))}function Zn(t,e){if(er(t=w(t)))return nr("Unsupported field value:",e,t),tr(t,e);if(t instanceof On)return function(t,e){if(!Mn(e.st))throw e.lt(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.lt(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.ut&&4!==e.st)throw e.lt("Nested arrays are not supported");return function(t,e){const n=[];let r=0;for(const s of t){let t=Zn(s,e.ht(r));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=w(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Ve(e.L,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=Dt.fromDate(t);return{timestampValue:We(e.L,n)}}if(t instanceof Dt){const n=new Dt(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:We(e.L,n)}}if(t instanceof xn)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Rn)return{bytesValue:Ge(e.L,t._byteString)};if(t instanceof Sn){const n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.lt(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ke(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.lt(`Unsupported field value: ${mt(t)}`)}(t,e)}function tr(t,e){const n={};return function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Ft(t,((t,r)=>{const s=Zn(r,e.ot(t));null!=s&&(n[t]=s)})),{mapValue:{fields:n}}}function er(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Dt||t instanceof xn||t instanceof Rn||t instanceof Sn||t instanceof On)}function nr(t,e,n){if(!er(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const r=mt(n);throw"an object"===r?e.lt(t+" a custom object"):e.lt(t+" "+r)}}function rr(t,e,n){if((e=w(e))instanceof Fn)return e._internalPath;if("string"==typeof e)return ir(t,e);throw or("Field path arguments must be of type string or ",t,!1,void 0,n)}const sr=new RegExp("[~\\*/\\[\\]]");function ir(t,e,n){if(e.search(sr)>=0)throw or(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new Fn(...e.split("."))._internalPath}catch(r){throw or(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function or(t,e,n,r,s){const i=r&&!r.isEmpty(),o=void 0!==s;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let u="";return(i||o)&&(u+=" (found",i&&(u+=` in field ${r}`),o&&(u+=` in document ${s}`),u+=")"),new Q(P,a+t+u)}function ar(t,e){return t.some((t=>t.isEqual(e)))}class ur{constructor(t,e,n,r,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new Sn(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new lr(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(dr("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class lr extends ur{data(){return super.data()}}class cr{constructor(t,e){this._docs=e,this.query=t}get docs(){return[...this._docs]}get size(){return this.docs.length}get empty(){return 0===this.docs.length}forEach(t,e){this._docs.forEach(t,e)}}function hr(t,e){return t=w(t),e=w(e),t instanceof ur&&e instanceof ur?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof cr&&e instanceof cr&&Nn(t.query,e.query)&&Vt(t.docs,e.docs,hr)}function dr(t,e){return"string"==typeof e?ir(t,e):e instanceof Fn?e._internalPath:e._delegate._internalPath}class fr{}function pr(t,...e){for(const n of e)t=n._apply(t);return t}class mr extends fr{constructor(t,e,n){super(),this.gt=t,this.vt=e,this.bt=n,this.type="where"}_apply(t){const e=Un(t.firestore),n=function(t,e,n,r,s,i,o){let a;if(s.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new Q(P,`Invalid Query. You can't perform '${i}' queries on documentId().`);if("in"===i||"not-in"===i){Nr(o,i);const e=[];for(const n of o)e.push(Dr(r,t,n));a={arrayValue:{values:e}}}else a=Dr(r,t,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||Nr(o,i),a=Xn(n,"where",o,"in"===i||"not-in"===i);const u=le.create(s,i,a);return function(t,e){if(e.q()){const n=Te(t);if(null!==n&&!n.isEqual(e.field))throw new Q(P,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);const r=Se(t);null!==r&&Rr(t,e.field,r)}const n=function(t,e){for(const n of t.filters)if(e.indexOf(n.op)>=0)return n.op;return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Q(P,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Q(P,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}(t,u),u}(t._query,0,e,t.firestore._databaseId,this.gt,this.vt,this.bt);return new Tn(t.firestore,t.converter,function(t,e){const n=t.filters.concat([e]);return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))}}function gr(t,e,n){const r=e,s=dr("where",t);return new mr(s,r,n)}class yr extends fr{constructor(t,e){super(),this.gt=t,this.Et=e,this.type="orderBy"}_apply(t){const e=function(t,e,n){if(null!==t.startAt)throw new Q(P,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Q(P,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const r=new _e(e,n);return function(t,e){if(null===Se(t)){const n=Te(t);null!==n&&Rr(t,n,e.field)}}(t,r),r}(t._query,this.gt,this.Et);return new Tn(t.firestore,t.converter,function(t,e){const n=t.explicitOrderBy.concat([e]);return new Ee(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))}}function wr(t,e="asc"){const n=e,r=dr("orderBy",t);return new yr(r,n)}class _r extends fr{constructor(t,e,n){super(),this.type=t,this.It=e,this.Tt=n}_apply(t){return new Tn(t.firestore,t.converter,function(t,e,n){return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}(t._query,this.It,this.Tt))}}function vr(t){return yt("limit",t),new _r("limit",t,"F")}function br(t){return yt("limitToLast",t),new _r("limitToLast",t,"L")}class Er extends fr{constructor(t,e,n){super(),this.type=t,this.At=e,this.Rt=n}_apply(t){const e=Vr(t,this.type,this.At,this.Rt);return new Tn(t.firestore,t.converter,function(t,e){return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))}}function Sr(...t){return new Er("startAt",t,!0)}function Tr(...t){return new Er("startAfter",t,!1)}class Ar extends fr{constructor(t,e,n){super(),this.type=t,this.At=e,this.Rt=n}_apply(t){const e=Vr(t,this.type,this.At,this.Rt);return new Tn(t.firestore,t.converter,function(t,e){return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))}}function kr(...t){return new Ar("endBefore",t,!1)}function Ir(...t){return new Ar("endAt",t,!0)}function Vr(t,e,n,r){if(n[0]=w(n[0]),n[0]instanceof ur)return function(t,e,n,r,s){if(!r)throw new Q(M,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const i=[];for(const n of ke(t))if(n.field.isKeyField())i.push(Zt(e,r.key));else{const t=r.data.field(n.field);if(Wt(t))throw new Q(P,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===t){const t=n.field.canonicalString();throw new Q(P,`Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`)}i.push(t)}return new we(i,s)}(t._query,t.firestore._databaseId,e,n[0]._document,r);{const s=Un(t.firestore);return function(t,e,n,r,s,i){const o=t.explicitOrderBy;if(s.length>o.length)throw new Q(P,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let i=0;i<s.length;i++){const u=s[i];if(o[i].field.isKeyField()){if("string"!=typeof u)throw new Q(P,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof u}`);if(!Ae(t)&&-1!==u.indexOf("/"))throw new Q(P,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${u}' contains a slash.`);const n=t.path.child(ut.fromString(u));if(!ht.isDocumentKey(n))throw new Q(P,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);const s=new ht(n);a.push(Zt(e,s))}else{const t=Xn(n,r,u);a.push(t)}}return new we(a,i)}(t._query,t.firestore._databaseId,s,e,n,r)}}function Dr(t,e,n){if("string"==typeof(n=w(n))){if(""===n)throw new Q(P,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ae(e)&&-1!==n.indexOf("/"))throw new Q(P,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(ut.fromString(n));if(!ht.isDocumentKey(r))throw new Q(P,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Zt(t,new ht(r))}if(n instanceof Sn)return Zt(t,n._key);throw new Q(P,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${mt(n)}.`)}function Nr(t,e){if(!Array.isArray(t)||0===t.length)throw new Q(P,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Q(P,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function Rr(t,e,n){if(!n.isEqual(e))throw new Q(P,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}function Fr(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}class Lr extends class{convertValue(t,e="none"){switch(Kt(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Ut(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(jt(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw F()}}convertObject(t,e){const n={};return Ft(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new xn(Ut(t.latitude),Ut(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=Gt(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Ht(t));default:return null}}convertTimestamp(t){const e=$t(t);return new Dt(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=ut.fromString(t);L(on(n));const r=new ot(n.get(1),n.get(3)),s=new ht(n.popFirst(5));return r.isEqual(e)||D(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),s}}{constructor(t){super(),this.firestore=t}convertBytes(t){return new Rn(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Sn(this.firestore,null,e)}}function Or(t){const e=fn((t=gt(t,Sn)).firestore),n=new Lr(t.firestore);return hn(e,[t._key]).then((e=>{L(1===e.length);const r=e[0];return new ur(t.firestore,n,t._key,r.isFoundDocument()?r:null,t.converter)}))}function xr(t){!function(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new Q(H,"limitToLast() queries require specifying at least one orderBy() clause")}((t=gt(t,Tn))._query);const e=fn(t.firestore),n=new Lr(t.firestore);return async function(t,e){const n=O(t),r=tn(n.L,Ie(e));return(await n.P("RunQuery",r.parent,{structuredQuery:r.structuredQuery})).filter((t=>!!t.document)).map((t=>function(t,e,n){const r=Ye(t,e.name),s=ze(e.updateTime),i=new ie({mapValue:{fields:e.fields}});return oe.newFoundDocument(r,s,i)}(n.L,t.document)))}(e,t._query).then((e=>{const r=e.map((e=>new lr(t.firestore,n,e.key,e,t.converter)));return"L"===t._query.limitType&&r.reverse(),new cr(t,r)}))}function Cr(t,e,n){const r=Fr((t=gt(t,Sn)).converter,e,n),s=jn(Un(t.firestore),"setDoc",t._key,r,null!==t.converter,n);return cn(fn(t.firestore),[s.toMutation(t._key,xe.none())])}function Pr(t,e,n,...r){const s=Un((t=gt(t,Sn)).firestore);let i;return i="string"==typeof(e=w(e))||e instanceof Fn?Jn(s,"updateDoc",t._key,e,n,r):Yn(s,"updateDoc",t._key,e),cn(fn(t.firestore),[i.toMutation(t._key,xe.exists(!0))])}function qr(t){return cn(fn((t=gt(t,Sn)).firestore),[new Me(t._key,xe.none())])}function Mr(t,e){const n=Vn(t=gt(t,An)),r=Fr(t.converter,e),s=jn(Un(t.firestore),"addDoc",n._key,r,null!==n.converter,{});return cn(fn(t.firestore),[s.toMutation(n._key,xe.exists(!1))]).then((()=>n))}function Br(t){const e=gt(t.firestore,mn),n=fn(e),r=new Lr(e);return new En(t,n,r).run()}function $r(t,e){return Nn(t.query,e.query)&&g(t.data(),e.data())}function Ur(){return new Wn("deleteField")}function jr(){return new Hn("serverTimestamp")}function Wr(...t){return new zn("arrayUnion",t)}function Gr(...t){return new Kn("arrayRemove",t)}function Hr(t){return new Qn("increment",t)}class zr{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=Un(t)}set(t,e,n){this._verifyNotCommitted();const r=Kr(t,this._firestore),s=Fr(r.converter,e,n),i=jn(this._dataReader,"WriteBatch.set",r._key,s,null!==r.converter,n);return this._mutations.push(i.toMutation(r._key,xe.none())),this}update(t,e,n,...r){this._verifyNotCommitted();const s=Kr(t,this._firestore);let i;return i="string"==typeof(e=w(e))||e instanceof Fn?Jn(this._dataReader,"WriteBatch.update",s._key,e,n,r):Yn(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(i.toMutation(s._key,xe.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=Kr(t,this._firestore);return this._mutations=this._mutations.concat(new Me(e._key,xe.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Q(j,"A write batch can no longer be used after commit() has been called.")}}function Kr(t,e){if((t=w(t)).firestore!==e)throw new Q(P,"Provided document reference is from a different Firestore instance.");return t}function Qr(t){const e=fn(t=gt(t,mn));return new zr(t,(t=>cn(e,t)))}class Yr{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new Q(P,"Firestore transactions require all reads to be executed before all writes.");const e=await hn(this.datastore,t);return e.forEach((t=>this.recordVersion(t))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())}delete(t){this.write(new Me(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((t,e)=>{const n=ht.fromPath(e);this.mutations.push(new Be(n,this.precondition(n)))})),await cn(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw F();e=Nt.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Q(W,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(Nt.min())?xe.exists(!1):xe.updateTime(e):xe.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(Nt.min()))throw new Q(P,"Can't update a document that doesn't exist.");return xe.updateTime(e)}return xe.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}const Jr={maxAttempts:5};class Xr{constructor(t,e,n,r,s){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=r,this.deferred=s,this.Pt=n.maxAttempts,this.Vt=new un(this.asyncQueue,"transaction_retry")}run(){this.Pt-=1,this.Nt()}Nt(){this.Vt.J((async()=>{const t=new Yr(this.datastore),e=this.Dt(t);e&&e.then((e=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(e)})).catch((t=>{this.$t(t)}))))})).catch((t=>{this.$t(t)}))}))}Dt(t){try{const e=this.updateFunction(t);return!wt(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}$t(t){this.Pt>0&&this.xt(t)?(this.Pt-=1,this.asyncQueue.enqueueAndForget((()=>(this.Nt(),Promise.resolve())))):this.deferred.reject(t)}xt(t){if("FirebaseError"===t.name){const e=t.code;return"aborted"===e||"failed-precondition"===e||!function(t){switch(t){default:return F();case x:case C:case q:case U:case z:case K:case $:return!1;case P:case M:case"already-exists":case B:case j:case W:case G:case H:case"data-loss":return!0}}(e)}return!1}}function Zr(){return"undefined"!=typeof document?document:null}class ts{constructor(t,e,n,r,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=s,this.deferred=new Y,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((t=>{}))}static createAndSchedule(t,e,n,r,s){const i=Date.now()+n,o=new ts(t,e,i,r,s);return o.start(n),o}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Q(x,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}class es{constructor(){this.Ft=Promise.resolve(),this.St=[],this.qt=!1,this.Ot=[],this.kt=null,this.Ct=!1,this.Lt=!1,this.Mt=[],this.Vt=new un(this,"async_queue_retry"),this.Ut=()=>{const t=Zr();t&&V("AsyncQueue","Visibility state changed to "+t.visibilityState),this.Vt.Z()};const t=Zr();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Ut)}get isShuttingDown(){return this.qt}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.jt(),this.Bt(t)}enterRestrictedMode(t){if(!this.qt){this.qt=!0,this.Lt=t||!1;const e=Zr();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Ut)}}enqueue(t){if(this.jt(),this.qt)return new Promise((()=>{}));const e=new Y;return this.Bt((()=>this.qt&&this.Lt?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.St.push(t),this.Qt())))}async Qt(){if(0!==this.St.length){try{await this.St[0](),this.St.shift(),this.Vt.reset()}catch(t){if(!function(t){return"IndexedDbTransactionError"===t.name}(t))throw t;V("AsyncQueue","Operation failed with retryable error: "+t)}this.St.length>0&&this.Vt.J((()=>this.Qt()))}}Bt(t){const e=this.Ft.then((()=>(this.Ct=!0,t().catch((t=>{this.kt=t,this.Ct=!1;const e=function(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t);throw D("INTERNAL UNHANDLED ERROR: ",e),t})).then((t=>(this.Ct=!1,t))))));return this.Ft=e,e}enqueueAfterDelay(t,e,n){this.jt(),this.Mt.indexOf(t)>-1&&(e=0);const r=ts.createAndSchedule(this,t,e,n,(t=>this.zt(t)));return this.Ot.push(r),r}jt(){this.kt&&F()}verifyOperationInProgress(){}async Gt(){let t;do{t=this.Ft,await t}while(t!==this.Ft)}Wt(t){for(const e of this.Ot)if(e.timerId===t)return!0;return!1}Kt(t){return this.Gt().then((()=>{this.Ot.sort(((t,e)=>t.targetTimeMs-e.targetTimeMs));for(const e of this.Ot)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.Gt()}))}Yt(t){this.Mt.push(t)}zt(t){const e=this.Ot.indexOf(t);this.Ot.splice(e,1)}}class ns{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=Un(t)}get(t){const e=Kr(t,this._firestore),n=new Lr(this._firestore);return this._transaction.lookup([e._key]).then((t=>{if(!t||1!==t.length)return F();const r=t[0];if(r.isFoundDocument())return new ur(this._firestore,n,r.key,r,e.converter);if(r.isNoDocument())return new ur(this._firestore,n,e._key,null,e.converter);throw F()}))}set(t,e,n){const r=Kr(t,this._firestore),s=Fr(r.converter,e,n),i=jn(this._dataReader,"Transaction.set",r._key,s,null!==r.converter,n);return this._transaction.set(r._key,i),this}update(t,e,n,...r){const s=Kr(t,this._firestore);let i;return i="string"==typeof(e=w(e))||e instanceof Fn?Jn(this._dataReader,"Transaction.update",s._key,e,n,r):Yn(this._dataReader,"Transaction.update",s._key,e),this._transaction.update(s._key,i),this}delete(t){const e=Kr(t,this._firestore);return this._transaction.delete(e._key),this}}function rs(t,e,n){const r=fn(t=gt(t,mn)),s=Object.assign(Object.assign({},Jr),n);!function(t){if(t.maxAttempts<1)throw new Q(P,"Max attempts must be at least 1")}(s);const i=new Y;return new Xr(new es,r,s,(n=>e(new ns(t,n))),i).run(),i.promise}A=`${i}_lite`,t(new class{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}("firestore/lite",((t,{instanceIdentifier:e,options:n})=>{const r=t.getProvider("app").getImmediate(),s=new mn(new tt(t.getProvider("auth-internal")),new st(t.getProvider("app-check-internal")),function(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Q(P,'"projectId" not provided in firebase.initializeApp.');return new ot(t.options.projectId,e)}(r,e),r);return n&&s._setSettings(n),s}),"PUBLIC").setMultipleInstances(!0)),e("firestore-lite","3.7.1",""),e("firestore-lite","3.7.1","esm2017");export{vn as AggregateField,bn as AggregateQuerySnapshot,Rn as Bytes,An as CollectionReference,Sn as DocumentReference,ur as DocumentSnapshot,Fn as FieldPath,On as FieldValue,mn as Firestore,Q as FirestoreError,xn as GeoPoint,Tn as Query,fr as QueryConstraint,lr as QueryDocumentSnapshot,cr as QuerySnapshot,Dt as Timestamp,ns as Transaction,zr as WriteBatch,Mr as addDoc,$r as aggregateQuerySnapshotEqual,Gr as arrayRemove,Wr as arrayUnion,kn as collection,In as collectionGroup,wn as connectFirestoreEmulator,qr as deleteDoc,Ur as deleteField,Vn as doc,Ln as documentId,Ir as endAt,kr as endBefore,Br as getCount,Or as getDoc,xr as getDocs,yn as getFirestore,Hr as increment,gn as initializeFirestore,vr as limit,br as limitToLast,wr as orderBy,pr as query,Nn as queryEqual,Dn as refEqual,rs as runTransaction,jr as serverTimestamp,Cr as setDoc,I as setLogLevel,hr as snapshotEqual,Tr as startAfter,Sr as startAt,_n as terminate,Pr as updateDoc,gr as where,Qr as writeBatch};
|
|
1
|
+
import{_registerComponent as t,registerVersion as e,_getProvider as n,getApp as r,_removeServiceInstance as s,SDK_VERSION as i}from"https://www.gstatic.com/firebasejs/9.13.0/firebase-app.js";const o=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=63&s|128):55296==(64512&s)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++r)),e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=63&s|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=63&s|128)}return e},a={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(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let e=0;e<t.length;e+=3){const s=t[e],i=e+1<t.length,o=i?t[e+1]:0,a=e+2<t.length,u=a?t[e+2]:0,l=s>>2,c=(3&s)<<4|o>>4;let h=(15&o)<<2|u>>6,d=63&u;a||(d=64,i||(h=64)),r.push(n[l],n[c],n[h],n[d])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(o(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=t[n++];e[r++]=String.fromCharCode((31&s)<<6|63&i)}else if(s>239&&s<365){const i=((7&s)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(i>>10)),e[r++]=String.fromCharCode(56320+(1023&i))}else{const i=t[n++],o=t[n++];e[r++]=String.fromCharCode((15&s)<<12|(63&i)<<6|63&o)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let e=0;e<t.length;){const s=n[t.charAt(e++)],i=e<t.length?n[t.charAt(e)]:0;++e;const o=e<t.length?n[t.charAt(e)]:64;++e;const a=e<t.length?n[t.charAt(e)]:64;if(++e,null==s||null==i||null==o||null==a)throw Error();const u=s<<2|i>>4;if(r.push(u),64!==o){const t=i<<4&240|o>>2;if(r.push(t),64!==a){const t=o<<6&192|a;r.push(t)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},u=function(t){return function(t){const e=o(t);return a.encodeByteArray(e,!0)}(t).replace(/\./g,"")};const l=()=>function(){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__,c=()=>{if("undefined"==typeof document)return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(t){return}const e=t&&function(t){try{return a.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}(t[1]);return e&&JSON.parse(e)},h=()=>{try{return l()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const t=process.env.__FIREBASE_DEFAULTS__;return t?JSON.parse(t):void 0})()||c()}catch(t){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`)}},d=t=>{const e=(t=>{var e,n;return null===(n=null===(e=h())||void 0===e?void 0:e.emulatorHosts)||void 0===n?void 0:n[t]})(t);if(!e)return;const n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(n+1),10);return"["===e[0]?[e.substring(1,n-1),r]:[e.substring(0,n),r]};class f extends Error{constructor(t,e,n){super(e),this.code=t,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,f.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,p.prototype.create)}}class p{constructor(t,e,n){this.service=t,this.serviceName=e,this.errors=n}create(t,...e){const n=e[0]||{},r=`${this.service}/${t}`,s=this.errors[t],i=s?function(t,e){return t.replace(m,((t,n)=>{const r=e[n];return null!=r?String(r):`<${n}?>`}))}(s,n):"Error",o=`${this.serviceName}: ${i} (${r}).`;return new f(r,o,n)}}const m=/\{\$([^}]+)}/g;function g(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const s of n){if(!r.includes(s))return!1;const n=t[s],i=e[s];if(y(n)&&y(i)){if(!g(n,i))return!1}else if(n!==i)return!1}for(const t of r)if(!n.includes(t))return!1;return!0}function y(t){return null!==t&&"object"==typeof t}function w(t){return t&&t._delegate?t._delegate:t}var _;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(_||(_={}));const v={debug:_.DEBUG,verbose:_.VERBOSE,info:_.INFO,warn:_.WARN,error:_.ERROR,silent:_.SILENT},b=_.INFO,E={[_.DEBUG]:"log",[_.VERBOSE]:"log",[_.INFO]:"info",[_.WARN]:"warn",[_.ERROR]:"error"},S=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),s=E[e];if(!s)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[s](`[${r}] ${t.name}:`,...n)};class T{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}T.UNAUTHENTICATED=new T(null),T.GOOGLE_CREDENTIALS=new T("google-credentials-uid"),T.FIRST_PARTY=new T("first-party-uid"),T.MOCK_USER=new T("mock-user");let A="9.13.0";const k=new class{constructor(t){this.name=t,this._logLevel=b,this._logHandler=S,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(t){if(!(t in _))throw new TypeError(`Invalid value "${t}" assigned to \`logLevel\``);this._logLevel=t}setLogLevel(t){this._logLevel="string"==typeof t?v[t]:t}get logHandler(){return this._logHandler}set logHandler(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t}get userLogHandler(){return this._userLogHandler}set userLogHandler(t){this._userLogHandler=t}debug(...t){this._userLogHandler&&this._userLogHandler(this,_.DEBUG,...t),this._logHandler(this,_.DEBUG,...t)}log(...t){this._userLogHandler&&this._userLogHandler(this,_.VERBOSE,...t),this._logHandler(this,_.VERBOSE,...t)}info(...t){this._userLogHandler&&this._userLogHandler(this,_.INFO,...t),this._logHandler(this,_.INFO,...t)}warn(...t){this._userLogHandler&&this._userLogHandler(this,_.WARN,...t),this._logHandler(this,_.WARN,...t)}error(...t){this._userLogHandler&&this._userLogHandler(this,_.ERROR,...t),this._logHandler(this,_.ERROR,...t)}}("@firebase/firestore");function I(t){k.setLogLevel(t)}function D(t,...e){if(k.logLevel<=_.DEBUG){const n=e.map(F);k.debug(`Firestore (${A}): ${t}`,...n)}}function V(t,...e){if(k.logLevel<=_.ERROR){const n=e.map(F);k.error(`Firestore (${A}): ${t}`,...n)}}function N(t,...e){if(k.logLevel<=_.WARN){const n=e.map(F);k.warn(`Firestore (${A}): ${t}`,...n)}}function F(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function R(t="Unexpected state"){const e=`FIRESTORE (${A}) INTERNAL ASSERTION FAILED: `+t;throw V(e),new Error(e)}function L(t,e){t||R()}function O(t,e){return t}const x="cancelled",P="unknown",C="invalid-argument",q="deadline-exceeded",M="not-found",B="permission-denied",$="unauthenticated",U="resource-exhausted",j="failed-precondition",W="aborted",H="out-of-range",G="unimplemented",z="internal",K="unavailable";class Q extends f{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Y{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class J{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class X{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(T.UNAUTHENTICATED)))}shutdown(){}}class Z{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class tt{constructor(t){this.auth=null,t.onInit((t=>{this.auth=t}))}getToken(){return this.auth?this.auth.getToken().then((t=>t?(L("string"==typeof t.accessToken),new J(t.accessToken,new T(this.auth.getUid()))):null)):Promise.resolve(null)}invalidateToken(){}start(t,e){}shutdown(){}}class et{constructor(t,e,n,r){this.t=t,this.i=e,this.o=n,this.u=r,this.type="FirstParty",this.user=T.FIRST_PARTY,this.h=new Map}l(){return this.u?this.u():(L(!("object"!=typeof this.t||null===this.t||!this.t.auth||!this.t.auth.getAuthHeaderValueForFirstParty)),this.t.auth.getAuthHeaderValueForFirstParty([]))}get headers(){this.h.set("X-Goog-AuthUser",this.i);const t=this.l();return t&&this.h.set("Authorization",t),this.o&&this.h.set("X-Goog-Iam-Authorization-Token",this.o),this.h}}class nt{constructor(t,e,n,r){this.t=t,this.i=e,this.o=n,this.u=r}getToken(){return Promise.resolve(new et(this.t,this.i,this.o,this.u))}start(t,e){t.enqueueRetryable((()=>e(T.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class rt{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class st{constructor(t){this.m=t,this.appCheck=null,t.onInit((t=>{this.appCheck=t}))}getToken(){return this.appCheck?this.appCheck.getToken().then((t=>t?(L("string"==typeof t.token),new rt(t.token)):null)):Promise.resolve(null)}invalidateToken(){}start(t,e){}shutdown(){}}class it{constructor(t,e,n,r,s,i,o,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=s,this.forceLongPolling=i,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class ot{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new ot("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(t){return t instanceof ot&&t.projectId===this.projectId&&t.database===this.database}}class at{constructor(t,e,n){void 0===e?e=0:e>t.length&&R(),void 0===n?n=t.length-e:n>t.length-e&&R(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===at.comparator(this,t)}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof at?t.forEach((t=>{e.push(t)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}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(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let r=0;r<n;r++){const n=t.get(r),s=e.get(r);if(n<s)return-1;if(n>s)return 1}return t.length<e.length?-1:t.length>e.length?1:0}}class ut extends at{construct(t,e,n){return new ut(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new Q(C,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((t=>t.length>0)))}return new ut(e)}static emptyPath(){return new ut([])}}const lt=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ct extends at{construct(t,e,n){return new ct(t,e,n)}static isValidIdentifier(t){return lt.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ct.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new ct(["__name__"])}static fromServerFormat(t){const e=[];let n="",r=0;const s=()=>{if(0===n.length)throw new Q(C,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let i=!1;for(;r<t.length;){const e=t[r];if("\\"===e){if(r+1===t.length)throw new Q(C,"Path has trailing escape character: "+t);const e=t[r+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new Q(C,"Path has invalid escape sequence: "+t);n+=e,r+=2}else"`"===e?(i=!i,r++):"."!==e||i?(n+=e,r++):(s(),r++)}if(s(),i)throw new Q(C,"Unterminated ` in path: "+t);return new ct(e)}static emptyPath(){return new ct([])}}class ht{constructor(t){this.path=t}static fromPath(t){return new ht(ut.fromString(t))}static fromName(t){return new ht(ut.fromString(t).popFirst(5))}static empty(){return new ht(ut.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return null!==t&&0===ut.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return ut.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new ht(new ut(t.slice()))}}function dt(t,e,n){if(!n)throw new Q(C,`Function ${t}() cannot be called with an empty ${e}.`)}function ft(t){if(!ht.isDocumentKey(t))throw new Q(C,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function pt(t){if(ht.isDocumentKey(t))throw new Q(C,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function mt(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{const e=function(t){return t.constructor?t.constructor.name:null}(t);return e?`a custom ${e} object`:"an object"}}return"function"==typeof t?"a function":R()}function gt(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new Q(C,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=mt(t);throw new Q(C,`Expected type '${e.name}', but it was: ${n}`)}}return t}function yt(t,e){if(e<=0)throw new Q(C,`Function ${t}() requires a positive number, but it was: ${e}.`)}function wt(t){return null==t}function _t(t){return 0===t&&1/t==-1/0}const vt={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};var bt,Et;function St(t){if(void 0===t)return V("RPC_ERROR","HTTP error has no status"),P;switch(t){case 200:return"ok";case 400:return j;case 401:return $;case 403:return B;case 404:return M;case 409:return W;case 416:return H;case 429:return U;case 499:return x;case 500:return P;case 501:return G;case 503:return K;case 504:return q;default:return t>=200&&t<300?"ok":t>=400&&t<500?j:t>=500&&t<600?z:P}}(Et=bt||(bt={}))[Et.OK=0]="OK",Et[Et.CANCELLED=1]="CANCELLED",Et[Et.UNKNOWN=2]="UNKNOWN",Et[Et.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Et[Et.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Et[Et.NOT_FOUND=5]="NOT_FOUND",Et[Et.ALREADY_EXISTS=6]="ALREADY_EXISTS",Et[Et.PERMISSION_DENIED=7]="PERMISSION_DENIED",Et[Et.UNAUTHENTICATED=16]="UNAUTHENTICATED",Et[Et.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Et[Et.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Et[Et.ABORTED=10]="ABORTED",Et[Et.OUT_OF_RANGE=11]="OUT_OF_RANGE",Et[Et.UNIMPLEMENTED=12]="UNIMPLEMENTED",Et[Et.INTERNAL=13]="INTERNAL",Et[Et.UNAVAILABLE=14]="UNAVAILABLE",Et[Et.DATA_LOSS=15]="DATA_LOSS";class Tt extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.p=e+"://"+t.host,this.g="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get v(){return!1}I(t,e,n,r,s){const i=this.T(t,e);D("RestConnection","Sending: ",i,n);const o={};return this.A(o,r,s),this.R(t,i,o,n).then((t=>(D("RestConnection","Received: ",t),t)),(e=>{throw N("RestConnection",`${t} failed with error: `,e,"url: ",i,"request:",n),e}))}P(t,e,n,r,s,i){return this.I(t,e,n,r,s)}A(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+A,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}T(t,e){const n=vt[t];return`${this.p}/v1/${e}:${n}`}}{constructor(t,e){super(t),this.V=e}N(t,e){throw new Error("Not supported by FetchConnection")}async R(t,e,n,r){const s=JSON.stringify(r);let i;try{i=await this.V(e,{method:"POST",headers:n,body:s})}catch(t){throw new Q(St(t.status),"Request failed with error: "+t.statusText)}if(!i.ok)throw new Q(St(i.status),"Request failed with error: "+i.statusText);return i.json()}}function At(t){const e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let e=0;e<t;e++)n[e]=Math.floor(256*Math.random());return n}class kt{static D(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length;let n="";for(;n.length<20;){const r=At(40);for(let s=0;s<r.length;++s)n.length<20&&r[s]<e&&(n+=t.charAt(r[s]%t.length))}return n}}function It(t,e){return t<e?-1:t>e?1:0}function Dt(t,e,n){return t.length===e.length&&t.every(((t,r)=>n(t,e[r])))}class Vt{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new Q(C,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new Q(C,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Q(C,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new Q(C,"Timestamp seconds out of range: "+t)}static now(){return Vt.fromMillis(Date.now())}static fromDate(t){return Vt.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new Vt(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?It(this.nanoseconds,t.nanoseconds):It(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class Nt{constructor(t){this.timestamp=t}static fromTimestamp(t){return new Nt(t)}static min(){return new Nt(new Vt(0,0))}static max(){return new Nt(new Vt(253402300799,999999999))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}function Ft(t){let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Rt(t,e){for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}class Lt{constructor(t,e){this.comparator=t,this.root=e||xt.EMPTY}insert(t,e){return new Lt(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,xt.BLACK,null,null))}remove(t){return new Lt(this.comparator,this.root.remove(t,this.comparator).copy(null,null,xt.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Ot(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Ot(this.root,t,this.comparator,!1)}getReverseIterator(){return new Ot(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Ot(this.root,t,this.comparator,!0)}}class Ot{constructor(t,e,n,r){this.isReverse=r,this.nodeStack=[];let s=1;for(;!t.isEmpty();)if(s=e?n(t.key,e):1,e&&r&&(s*=-1),s<0)t=this.isReverse?t.left:t.right;else{if(0===s){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class xt{constructor(t,e,n,r,s){this.key=t,this.value=e,this.color=null!=n?n:xt.RED,this.left=null!=r?r:xt.EMPTY,this.right=null!=s?s:xt.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,r,s){return new xt(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=s?s:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}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(t,e,n){let r=this;const s=n(t,r.key);return r=s<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===s?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return xt.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===e(t,r.key)){if(r.right.isEmpty())return xt.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,xt.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,xt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw R();if(this.right.isRed())throw R();const t=this.left.check();if(t!==this.right.check())throw R();return t+(this.isRed()?0:1)}}xt.EMPTY=null,xt.RED=!0,xt.BLACK=!1,xt.EMPTY=new class{constructor(){this.size=0}get key(){throw R()}get value(){throw R()}get color(){throw R()}get left(){throw R()}get right(){throw R()}copy(t,e,n,r,s){return this}insert(t,e,n){return new xt(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class Pt{constructor(t){this.comparator=t,this.data=new Lt(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Ct(this.data.getIterator())}getIteratorFrom(t){return new Ct(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach((t=>{e=e.add(t)})),e}isEqual(t){if(!(t instanceof Pt))return!1;if(this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const t=e.getNext().key,r=n.getNext().key;if(0!==this.comparator(t,r))return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new Pt(this.comparator);return e.data=t,e}}class Ct{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class qt{constructor(t){this.fields=t,t.sort(ct.comparator)}static empty(){return new qt([])}unionWith(t){let e=new Pt(ct.comparator);for(const t of this.fields)e=e.add(t);for(const n of t)e=e.add(n);return new qt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Dt(this.fields,t.fields,((t,e)=>t.isEqual(e)))}}class Mt{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new Mt(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new Mt(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return It(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}Mt.EMPTY_BYTE_STRING=new Mt("");const Bt=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function $t(t){if(L(!!t),"string"==typeof t){let e=0;const n=Bt.exec(t);if(L(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Ut(t.seconds),nanos:Ut(t.nanos)}}function Ut(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function jt(t){return"string"==typeof t?Mt.fromBase64String(t):Mt.fromUint8Array(t)}function Wt(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Ht(t){const e=t.mapValue.fields.__previous_value__;return Wt(e)?Ht(e):e}function Gt(t){const e=$t(t.mapValue.fields.__local_write_time__.timestampValue);return new Vt(e.seconds,e.nanos)}const zt={fields:{__type__:{stringValue:"__max__"}}};function Kt(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?Wt(t)?4:function(t){return"__max__"===(((t.mapValue||{}).fields||{}).__type__||{}).stringValue}(t)?9007199254740991:10:R()}function Qt(t,e){if(t===e)return!0;const n=Kt(t);if(n!==Kt(e))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Gt(t).isEqual(Gt(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;const n=$t(t.timestampValue),r=$t(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return jt(t.bytesValue).isEqual(jt(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return Ut(t.geoPointValue.latitude)===Ut(e.geoPointValue.latitude)&&Ut(t.geoPointValue.longitude)===Ut(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return Ut(t.integerValue)===Ut(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){const n=Ut(t.doubleValue),r=Ut(e.doubleValue);return n===r?_t(n)===_t(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return Dt(t.arrayValue.values||[],e.arrayValue.values||[],Qt);case 10:return function(t,e){const n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(Ft(n)!==Ft(r))return!1;for(const t in n)if(n.hasOwnProperty(t)&&(void 0===r[t]||!Qt(n[t],r[t])))return!1;return!0}(t,e);default:return R()}}function Yt(t,e){return void 0!==(t.values||[]).find((t=>Qt(t,e)))}function Jt(t,e){if(t===e)return 0;const n=Kt(t),r=Kt(e);if(n!==r)return It(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return It(t.booleanValue,e.booleanValue);case 2:return function(t,e){const n=Ut(t.integerValue||t.doubleValue),r=Ut(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return Xt(t.timestampValue,e.timestampValue);case 4:return Xt(Gt(t),Gt(e));case 5:return It(t.stringValue,e.stringValue);case 6:return function(t,e){const n=jt(t),r=jt(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){const n=t.split("/"),r=e.split("/");for(let t=0;t<n.length&&t<r.length;t++){const e=It(n[t],r[t]);if(0!==e)return e}return It(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){const n=It(Ut(t.latitude),Ut(e.latitude));return 0!==n?n:It(Ut(t.longitude),Ut(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){const n=t.values||[],r=e.values||[];for(let t=0;t<n.length&&t<r.length;++t){const e=Jt(n[t],r[t]);if(e)return e}return It(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){if(t===zt&&e===zt)return 0;if(t===zt)return 1;if(e===zt)return-1;const n=t.fields||{},r=Object.keys(n),s=e.fields||{},i=Object.keys(s);r.sort(),i.sort();for(let t=0;t<r.length&&t<i.length;++t){const e=It(r[t],i[t]);if(0!==e)return e;const o=Jt(n[r[t]],s[i[t]]);if(0!==o)return o}return It(r.length,i.length)}(t.mapValue,e.mapValue);default:throw R()}}function Xt(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return It(t,e);const n=$t(t),r=$t(e),s=It(n.seconds,r.seconds);return 0!==s?s:It(n.nanos,r.nanos)}function Zt(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function te(t){return!!t&&"arrayValue"in t}function ee(t){return!!t&&"nullValue"in t}function ne(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function re(t){return!!t&&"mapValue"in t}function se(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){const e={mapValue:{fields:{}}};return Rt(t.mapValue.fields,((t,n)=>e.mapValue.fields[t]=se(n))),e}if(t.arrayValue){const e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=se(t.arrayValue.values[n]);return e}return Object.assign({},t)}class ie{constructor(t){this.value=t}static empty(){return new ie({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!re(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=se(e)}setAll(t){let e=ct.emptyPath(),n={},r=[];t.forEach(((t,s)=>{if(!e.isImmediateParentOf(s)){const t=this.getFieldsMap(e);this.applyChanges(t,n,r),n={},r=[],e=s.popLast()}t?n[s.lastSegment()]=se(t):r.push(s.lastSegment())}));const s=this.getFieldsMap(e);this.applyChanges(s,n,r)}delete(t){const e=this.field(t.popLast());re(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Qt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let r=e.mapValue.fields[t.get(n)];re(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields}applyChanges(t,e,n){Rt(e,((e,n)=>t[e]=n));for(const e of n)delete t[e]}clone(){return new ie(se(this.value))}}class oe{constructor(t,e,n,r,s,i){this.key=t,this.documentType=e,this.version=n,this.readTime=r,this.data=s,this.documentState=i}static newInvalidDocument(t){return new oe(t,0,Nt.min(),Nt.min(),ie.empty(),0)}static newFoundDocument(t,e,n){return new oe(t,1,e,Nt.min(),n,0)}static newNoDocument(t,e){return new oe(t,2,e,Nt.min(),ie.empty(),0)}static newUnknownDocument(t,e){return new oe(t,3,e,Nt.min(),ie.empty(),2)}convertToFoundDocument(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=ie.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=ie.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Nt.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(t){return t instanceof oe&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new oe(this.key,this.documentType,this.version,this.readTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class ae{constructor(t,e=null,n=[],r=[],s=null,i=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=s,this.startAt=i,this.endAt=o,this.$=null}}function ue(t,e=null,n=[],r=[],s=null,i=null,o=null){return new ae(t,e,n,r,s,i,o)}class le extends class{}{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.F(t,e,n):new ce(t,e,n):"array-contains"===e?new pe(t,n):"in"===e?new me(t,n):"not-in"===e?new ge(t,n):"array-contains-any"===e?new ye(t,n):new le(t,e,n)}static F(t,e,n){return"in"===e?new he(t,n):new de(t,n)}matches(t){const e=t.data.field(this.field);return"!="===this.op?null!==e&&this.S(Jt(e,this.value)):null!==e&&Kt(this.value)===Kt(e)&&this.S(Jt(e,this.value))}S(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return R()}}q(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}}class ce extends le{constructor(t,e,n){super(t,e,n),this.key=ht.fromName(n.referenceValue)}matches(t){const e=ht.comparator(t.key,this.key);return this.S(e)}}class he extends le{constructor(t,e){super(t,"in",e),this.keys=fe("in",e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class de extends le{constructor(t,e){super(t,"not-in",e),this.keys=fe("not-in",e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function fe(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((t=>ht.fromName(t.referenceValue)))}class pe extends le{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return te(e)&&Yt(e.arrayValue,this.value)}}class me extends le{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return null!==e&&Yt(this.value.arrayValue,e)}}class ge extends le{constructor(t,e){super(t,"not-in",e)}matches(t){if(Yt(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return null!==e&&!Yt(this.value.arrayValue,e)}}class ye extends le{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!te(e)||!e.arrayValue.values)&&e.arrayValue.values.some((t=>Yt(this.value.arrayValue,t)))}}class we{constructor(t,e){this.position=t,this.inclusive=e}}class _e{constructor(t,e="asc"){this.field=t,this.dir=e}}function ve(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function be(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.inclusive!==e.inclusive||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!Qt(t.position[n],e.position[n]))return!1;return!0}class Ee{constructor(t,e=null,n=[],r=[],s=null,i="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=s,this.limitType=i,this.startAt=o,this.endAt=a,this.O=null,this.k=null,this.startAt,this.endAt}}function Se(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Te(t){for(const e of t.filters)if(e.q())return e.field;return null}function Ae(t){return null!==t.collectionGroup}function ke(t){const e=O(t);if(null===e.O){e.O=[];const t=Te(e),n=Se(e);if(null!==t&&null===n)t.isKeyField()||e.O.push(new _e(t)),e.O.push(new _e(ct.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.O.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.O.push(new _e(ct.keyField(),t))}}}return e.O}function Ie(t){const e=O(t);if(!e.k)if("F"===e.limitType)e.k=ue(e.path,e.collectionGroup,ke(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of ke(e)){const e="desc"===n.dir?"asc":"desc";t.push(new _e(n.field,e))}const n=e.endAt?new we(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new we(e.startAt.position,e.startAt.inclusive):null;e.k=ue(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e.k}function De(t,e){return function(t){return"number"==typeof t&&Number.isInteger(t)&&!_t(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}(e)?function(t){return{integerValue:""+t}}(e):function(t,e){if(t.C){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:_t(e)?"-0":e}}(t,e)}class Ve{constructor(){this._=void 0}}class Ne extends Ve{}class Fe extends Ve{constructor(t){super(),this.elements=t}}class Re extends Ve{constructor(t){super(),this.elements=t}}class Le extends Ve{constructor(t,e){super(),this.L=t,this.M=e}}class Oe{constructor(t,e){this.field=t,this.transform=e}}class xe{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new xe}static exists(t){return new xe(void 0,t)}static updateTime(t){return new xe(t)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}class Pe{}class Ce extends Pe{constructor(t,e,n,r=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class qe extends Pe{constructor(t,e,n,r,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=r,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}class Me extends Pe{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Be extends Pe{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}const $e={asc:"ASCENDING",desc:"DESCENDING"},Ue={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"};class je{constructor(t,e){this.databaseId=t,this.C=e}}function We(t,e){return t.C?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function He(t,e){return t.C?e.toBase64():e.toUint8Array()}function Ge(t,e){return We(t,e.toTimestamp())}function ze(t){return L(!!t),Nt.fromTimestamp(function(t){const e=$t(t);return new Vt(e.seconds,e.nanos)}(t))}function Ke(t,e){return function(t){return new ut(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function Qe(t,e){return Ke(t.databaseId,e.path)}function Ye(t,e){const n=function(t){const e=ut.fromString(t);return L(on(e)),e}(e);if(n.get(1)!==t.databaseId.projectId)throw new Q(C,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new Q(C,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new ht((L((r=n).length>4&&"documents"===r.get(4)),r.popFirst(5)));var r}function Je(t,e){return Ke(t.databaseId,e)}function Xe(t){return new ut(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function Ze(t,e,n){return{name:Qe(t,e),fields:n.value.mapValue.fields}}function tn(t,e){const n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Je(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Je(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);const s=function(t){if(0===t.length)return;const e=t.map((t=>function(t){if("=="===t.op){if(ne(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NAN"}};if(ee(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(ne(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NOT_NAN"}};if(ee(t.value))return{unaryFilter:{field:rn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:rn(t.field),op:nn(t.op),value:t.value}}}(t)));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}(e.filters);s&&(n.structuredQuery.where=s);const i=function(t){if(0!==t.length)return t.map((t=>function(t){return{field:rn(t.field),direction:en(t.dir)}}(t)))}(e.orderBy);i&&(n.structuredQuery.orderBy=i);const o=function(t,e){return t.C||wt(e)?e:{value:e}}(t,e.limit);var a;return null!==o&&(n.structuredQuery.limit=o),e.startAt&&(n.structuredQuery.startAt={before:(a=e.startAt).inclusive,values:a.position}),e.endAt&&(n.structuredQuery.endAt=function(t){return{before:!t.inclusive,values:t.position}}(e.endAt)),n}function en(t){return $e[t]}function nn(t){return Ue[t]}function rn(t){return{fieldPath:t.canonicalString()}}function sn(t){const e=[];return t.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function on(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function an(t){return new je(t,!0)}class un{constructor(t,e,n=1e3,r=1.5,s=6e4){this.U=t,this.timerId=e,this.j=n,this.B=r,this.G=s,this.W=0,this.K=null,this.Y=Date.now(),this.reset()}reset(){this.W=0}H(){this.W=this.G}J(t){this.cancel();const e=Math.floor(this.W+this.X()),n=Math.max(0,Date.now()-this.Y),r=Math.max(0,e-n);r>0&&D("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.W} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.K=this.U.enqueueAfterDelay(this.timerId,r,(()=>(this.Y=Date.now(),t()))),this.W*=this.B,this.W<this.j&&(this.W=this.j),this.W>this.G&&(this.W=this.G)}Z(){null!==this.K&&(this.K.skipDelay(),this.K=null)}cancel(){null!==this.K&&(this.K.cancel(),this.K=null)}X(){return(Math.random()-.5)*this.W}}class ln extends class{}{constructor(t,e,n,r){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.L=r,this.tt=!1}et(){if(this.tt)throw new Q(j,"The client has already been terminated.")}I(t,e,n){return this.et(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,s])=>this.connection.I(t,e,n,r,s))).catch((t=>{throw"FirebaseError"===t.name?(t.code===$&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Q(P,t.toString())}))}P(t,e,n,r){return this.et(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,i])=>this.connection.P(t,e,n,s,i,r))).catch((t=>{throw"FirebaseError"===t.name?(t.code===$&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new Q(P,t.toString())}))}terminate(){this.tt=!0}}async function cn(t,e){const n=O(t),r=Xe(n.L)+"/documents",s={writes:e.map((t=>function(t,e){let n;if(e instanceof Ce)n={update:Ze(t,e.key,e.value)};else if(e instanceof Me)n={delete:Qe(t,e.key)};else if(e instanceof qe)n={update:Ze(t,e.key,e.data),updateMask:sn(e.fieldMask)};else{if(!(e instanceof Be))return R();n={verify:Qe(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof Ne)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Fe)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Re)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Le)return{fieldPath:e.field.canonicalString(),increment:n.M};throw R()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Ge(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:R()}(t,e.precondition)),n}(n.L,t)))};await n.I("Commit",r,s)}async function hn(t,e){const n=O(t),r=Xe(n.L)+"/documents",s={documents:e.map((t=>Qe(n.L,t)))},i=await n.P("BatchGetDocuments",r,s,e.length),o=new Map;i.forEach((t=>{const e=function(t,e){return"found"in e?function(t,e){L(!!e.found),e.found.name,e.found.updateTime;const n=Ye(t,e.found.name),r=ze(e.found.updateTime),s=new ie({mapValue:{fields:e.found.fields}});return oe.newFoundDocument(n,r,s)}(t,e):"missing"in e?function(t,e){L(!!e.missing),L(!!e.readTime);const n=Ye(t,e.missing),r=ze(e.readTime);return oe.newNoDocument(n,r)}(t,e):R()}(n.L,t);o.set(e.key.toString(),e)}));const a=[];return e.forEach((t=>{const e=o.get(t.toString());L(!!e),a.push(e)})),a}const dn=new Map;function fn(t){if(t._terminated)throw new Q(j,"The client has already been terminated.");if(!dn.has(t)){D("ComponentProvider","Initializing Datastore");const i=function(t){return new Tt(t,fetch.bind(null))}((e=t._databaseId,n=t.app.options.appId||"",r=t._persistenceKey,s=t._freezeSettings(),new it(e,n,r,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,s.useFetchStreams))),o=an(t._databaseId),a=function(t,e,n,r){return new ln(t,e,n,r)}(t._authCredentials,t._appCheckCredentials,i,o);dn.set(t,a)}var e,n,r,s;return dn.get(t)}class pn{constructor(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new Q(C,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new Q(C,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,function(t,e,n,r){if(!0===e&&!0===r)throw new Q(C,"experimentalForceLongPolling and experimentalAutoDetectLongPolling cannot be used together.")}(0,t.experimentalForceLongPolling,0,t.experimentalAutoDetectLongPolling)}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class mn{constructor(t,e,n,r){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new pn({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new Q(j,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new Q(j,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new pn(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new X;switch(t.type){case"gapi":const e=t.client;return new nt(e,t.sessionIndex||"0",t.iamToken||null,t.authTokenFactory||null);case"provider":return t.client;default:throw new Q(C,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const e=dn.get(t);e&&(D("ComponentProvider","Removing Datastore"),dn.delete(t),e.terminate())}(this),Promise.resolve()}}function gn(t,e,r){r||(r="(default)");const s=n(t,"firestore/lite");if(s.isInitialized(r))throw new Q(j,"Firestore can only be initialized once per app.");return s.initialize({options:e,instanceIdentifier:r})}function yn(t,e){const s="object"==typeof t?t:r(),i="string"==typeof t?t:e||"(default)",o=n(s,"firestore/lite").getImmediate({identifier:i});if(!o._initialized){const t=d("firestore");t&&wn(o,...t)}return o}function wn(t,e,n,r={}){var s;const i=(t=gt(t,mn))._getSettings();if("firestore.googleapis.com"!==i.host&&i.host!==e&&N("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},i),{host:`${e}:${n}`,ssl:!1})),r.mockUserToken){let e,n;if("string"==typeof r.mockUserToken)e=r.mockUserToken,n=T.MOCK_USER;else{e=function(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=e||"demo-project",r=t.iat||0,s=t.sub||t.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const i=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},t);return[u(JSON.stringify({alg:"none",type:"JWT"})),u(JSON.stringify(i)),""].join(".")}(r.mockUserToken,null===(s=t._app)||void 0===s?void 0:s.options.projectId);const i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new Q(C,"mockUserToken must contain 'sub' or 'user_id' field!");n=new T(i)}t._authCredentials=new Z(new J(e,n))}}function _n(t){return t=gt(t,mn),s(t.app,"firestore/lite"),t._delete()}class vn{constructor(){this.type="AggregateField"}}class bn{constructor(t,e){this._data=e,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._data}}class En{constructor(t,e,n){this.query=t,this.datastore=e,this.userDataWriter=n}run(){return async function(t,e){const n=O(t),r=function(t,e){const n=tn(t,e);return{structuredAggregationQuery:{aggregations:[{count:{},alias:"count_alias"}],structuredQuery:n.structuredQuery},parent:n.parent}}(n.L,Ie(e)),s=r.parent;return n.connection.v||delete r.parent,(await n.P("RunAggregationQuery",s,r,1)).filter((t=>!!t.result)).map((t=>t.result.aggregateFields))}(this.datastore,this.query._query).then((t=>{L(void 0!==t[0]);const e=Object.entries(t[0]).filter((([t,e])=>"count_alias"===t)).map((([t,e])=>this.userDataWriter.convertValue(e)))[0];return L("number"==typeof e),Promise.resolve(new bn(this.query,{count:e}))}))}}class Sn{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new An(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new Sn(this.firestore,t,this._key)}}class Tn{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new Tn(this.firestore,t,this._query)}}class An extends Tn{constructor(t,e,n){super(t,e,new Ee(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new Sn(this.firestore,null,new ht(t))}withConverter(t){return new An(this.firestore,t,this._path)}}function kn(t,e,...n){if(t=w(t),dt("collection","path",e),t instanceof mn){const r=ut.fromString(e,...n);return pt(r),new An(t,null,r)}{if(!(t instanceof Sn||t instanceof An))throw new Q(C,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ut.fromString(e,...n));return pt(r),new An(t.firestore,null,r)}}function In(t,e){if(t=gt(t,mn),dt("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new Q(C,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Tn(t,null,function(t){return new Ee(ut.emptyPath(),t)}(e))}function Dn(t,e,...n){if(t=w(t),1===arguments.length&&(e=kt.D()),dt("doc","path",e),t instanceof mn){const r=ut.fromString(e,...n);return ft(r),new Sn(t,null,new ht(r))}{if(!(t instanceof Sn||t instanceof An))throw new Q(C,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=t._path.child(ut.fromString(e,...n));return ft(r),new Sn(t.firestore,t instanceof An?t.converter:null,new ht(r))}}function Vn(t,e){return t=w(t),e=w(e),(t instanceof Sn||t instanceof An)&&(e instanceof Sn||e instanceof An)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Nn(t,e){return t=w(t),e=w(e),t instanceof Tn&&e instanceof Tn&&t.firestore===e.firestore&&function(t,e){return function(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!ve(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let s=0;s<t.filters.length;s++)if(n=t.filters[s],r=e.filters[s],n.op!==r.op||!n.field.isEqual(r.field)||!Qt(n.value,r.value))return!1;var n,r;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!be(t.startAt,e.startAt)&&be(t.endAt,e.endAt)}(Ie(t),Ie(e))&&t.limitType===e.limitType}(t._query,e._query)&&t.converter===e.converter}class Fn{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Fn(Mt.fromBase64String(t))}catch(t){throw new Q(C,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new Fn(Mt.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}class Rn{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new Q(C,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ct(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function Ln(){return new Rn("__name__")}class On{constructor(t){this._methodName=t}}class xn{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new Q(C,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new Q(C,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return It(this._lat,t._lat)||It(this._long,t._long)}}const Pn=/^__.*__$/;class Cn{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new qe(t,this.data,this.fieldMask,e,this.fieldTransforms):new Ce(t,this.data,e,this.fieldTransforms)}}class qn{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new qe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Mn(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw R()}}class Bn{constructor(t,e,n,r,s,i){this.settings=t,this.databaseId=e,this.L=n,this.ignoreUndefinedProperties=r,void 0===s&&this.nt(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get rt(){return this.settings.rt}st(t){return new Bn(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.L,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}it(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.st({path:n,ot:!1});return r.ut(t),r}ct(t){var e;const n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.st({path:n,ot:!1});return r.nt(),r}at(t){return this.st({path:void 0,ot:!0})}ht(t){return or(t,this.settings.methodName,this.settings.lt||!1,this.path,this.settings.ft)}contains(t){return void 0!==this.fieldMask.find((e=>t.isPrefixOf(e)))||void 0!==this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))}nt(){if(this.path)for(let t=0;t<this.path.length;t++)this.ut(this.path.get(t))}ut(t){if(0===t.length)throw this.ht("Document fields must not be empty");if(Mn(this.rt)&&Pn.test(t))throw this.ht('Document fields cannot begin and end with "__"')}}class $n{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.L=n||an(t)}dt(t,e,n,r=!1){return new Bn({rt:t,methodName:e,ft:n,path:ct.emptyPath(),ot:!1,lt:r},this.databaseId,this.L,this.ignoreUndefinedProperties)}}function Un(t){const e=t._freezeSettings(),n=an(t._databaseId);return new $n(t._databaseId,!!e.ignoreUndefinedProperties,n)}function jn(t,e,n,r,s,i={}){const o=t.dt(i.merge||i.mergeFields?2:0,e,n,s);nr("Data must be an object, but it was:",o,r);const a=tr(r,o);let u,l;if(i.merge)u=new qt(o.fieldMask),l=o.fieldTransforms;else if(i.mergeFields){const t=[];for(const r of i.mergeFields){const s=rr(e,r,n);if(!o.contains(s))throw new Q(C,`Field '${s}' is specified in your field mask but missing from your input data.`);ar(t,s)||t.push(s)}u=new qt(t),l=o.fieldTransforms.filter((t=>u.covers(t.field)))}else u=null,l=o.fieldTransforms;return new Cn(new ie(a),u,l)}class Wn extends On{_toFieldTransform(t){if(2!==t.rt)throw 1===t.rt?t.ht(`${this._methodName}() can only appear at the top level of your update data`):t.ht(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Wn}}function Hn(t,e,n){return new Bn({rt:3,ft:e.settings.ft,methodName:t._methodName,ot:n},e.databaseId,e.L,e.ignoreUndefinedProperties)}class Gn extends On{_toFieldTransform(t){return new Oe(t.path,new Ne)}isEqual(t){return t instanceof Gn}}class zn extends On{constructor(t,e){super(t),this.wt=e}_toFieldTransform(t){const e=Hn(this,t,!0),n=this.wt.map((t=>Zn(t,e))),r=new Fe(n);return new Oe(t.path,r)}isEqual(t){return this===t}}class Kn extends On{constructor(t,e){super(t),this.wt=e}_toFieldTransform(t){const e=Hn(this,t,!0),n=this.wt.map((t=>Zn(t,e))),r=new Re(n);return new Oe(t.path,r)}isEqual(t){return this===t}}class Qn extends On{constructor(t,e){super(t),this.yt=e}_toFieldTransform(t){const e=new Le(t.L,De(t.L,this.yt));return new Oe(t.path,e)}isEqual(t){return this===t}}function Yn(t,e,n,r){const s=t.dt(1,e,n);nr("Data must be an object, but it was:",s,r);const i=[],o=ie.empty();Rt(r,((t,r)=>{const a=ir(e,t,n);r=w(r);const u=s.ct(a);if(r instanceof Wn)i.push(a);else{const t=Zn(r,u);null!=t&&(i.push(a),o.set(a,t))}}));const a=new qt(i);return new qn(o,a,s.fieldTransforms)}function Jn(t,e,n,r,s,i){const o=t.dt(1,e,n),a=[rr(e,r,n)],u=[s];if(i.length%2!=0)throw new Q(C,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let t=0;t<i.length;t+=2)a.push(rr(e,i[t])),u.push(i[t+1]);const l=[],c=ie.empty();for(let t=a.length-1;t>=0;--t)if(!ar(l,a[t])){const e=a[t];let n=u[t];n=w(n);const r=o.ct(e);if(n instanceof Wn)l.push(e);else{const t=Zn(n,r);null!=t&&(l.push(e),c.set(e,t))}}const h=new qt(l);return new qn(c,h,o.fieldTransforms)}function Xn(t,e,n,r=!1){return Zn(n,t.dt(r?4:3,e))}function Zn(t,e){if(er(t=w(t)))return nr("Unsupported field value:",e,t),tr(t,e);if(t instanceof On)return function(t,e){if(!Mn(e.rt))throw e.ht(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e.ht(`${t._methodName}() is not currently supported inside arrays`);const n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.ot&&4!==e.rt)throw e.ht("Nested arrays are not supported");return function(t,e){const n=[];let r=0;for(const s of t){let t=Zn(s,e.at(r));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=w(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return De(e.L,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){const n=Vt.fromDate(t);return{timestampValue:We(e.L,n)}}if(t instanceof Vt){const n=new Vt(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:We(e.L,n)}}if(t instanceof xn)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Fn)return{bytesValue:He(e.L,t._byteString)};if(t instanceof Sn){const n=e.databaseId,r=t.firestore._databaseId;if(!r.isEqual(n))throw e.ht(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ke(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.ht(`Unsupported field value: ${mt(t)}`)}(t,e)}function tr(t,e){const n={};return function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Rt(t,((t,r)=>{const s=Zn(r,e.it(t));null!=s&&(n[t]=s)})),{mapValue:{fields:n}}}function er(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Vt||t instanceof xn||t instanceof Fn||t instanceof Sn||t instanceof On)}function nr(t,e,n){if(!er(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){const r=mt(n);throw"an object"===r?e.ht(t+" a custom object"):e.ht(t+" "+r)}}function rr(t,e,n){if((e=w(e))instanceof Rn)return e._internalPath;if("string"==typeof e)return ir(t,e);throw or("Field path arguments must be of type string or ",t,!1,void 0,n)}const sr=new RegExp("[~\\*/\\[\\]]");function ir(t,e,n){if(e.search(sr)>=0)throw or(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new Rn(...e.split("."))._internalPath}catch(r){throw or(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function or(t,e,n,r,s){const i=r&&!r.isEmpty(),o=void 0!==s;let a=`Function ${e}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let u="";return(i||o)&&(u+=" (found",i&&(u+=` in field ${r}`),o&&(u+=` in document ${s}`),u+=")"),new Q(C,a+t+u)}function ar(t,e){return t.some((t=>t.isEqual(e)))}class ur{constructor(t,e,n,r,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new Sn(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const t=new lr(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(dr("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class lr extends ur{data(){return super.data()}}class cr{constructor(t,e){this._docs=e,this.query=t}get docs(){return[...this._docs]}get size(){return this.docs.length}get empty(){return 0===this.docs.length}forEach(t,e){this._docs.forEach(t,e)}}function hr(t,e){return t=w(t),e=w(e),t instanceof ur&&e instanceof ur?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof cr&&e instanceof cr&&Nn(t.query,e.query)&&Dt(t.docs,e.docs,hr)}function dr(t,e){return"string"==typeof e?ir(t,e):e instanceof Rn?e._internalPath:e._delegate._internalPath}class fr{}function pr(t,...e){for(const n of e)t=n._apply(t);return t}class mr extends fr{constructor(t,e,n){super(),this._t=t,this.gt=e,this.vt=n,this.type="where"}_apply(t){const e=Un(t.firestore),n=function(t,e,n,r,s,i,o){let a;if(s.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new Q(C,`Invalid Query. You can't perform '${i}' queries on documentId().`);if("in"===i||"not-in"===i){Nr(o,i);const e=[];for(const n of o)e.push(Vr(r,t,n));a={arrayValue:{values:e}}}else a=Vr(r,t,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||Nr(o,i),a=Xn(n,"where",o,"in"===i||"not-in"===i);const u=le.create(s,i,a);return function(t,e){if(e.q()){const n=Te(t);if(null!==n&&!n.isEqual(e.field))throw new Q(C,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${e.field.toString()}'`);const r=Se(t);null!==r&&Fr(t,e.field,r)}const n=function(t,e){for(const n of t.filters)if(e.indexOf(n.op)>=0)return n.op;return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Q(C,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Q(C,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}(t,u),u}(t._query,0,e,t.firestore._databaseId,this._t,this.gt,this.vt);return new Tn(t.firestore,t.converter,function(t,e){const n=t.filters.concat([e]);return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))}}function gr(t,e,n){const r=e,s=dr("where",t);return new mr(s,r,n)}class yr extends fr{constructor(t,e){super(),this._t=t,this.bt=e,this.type="orderBy"}_apply(t){const e=function(t,e,n){if(null!==t.startAt)throw new Q(C,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new Q(C,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const r=new _e(e,n);return function(t,e){if(null===Se(t)){const n=Te(t);null!==n&&Fr(t,n,e.field)}}(t,r),r}(t._query,this._t,this.bt);return new Tn(t.firestore,t.converter,function(t,e){const n=t.explicitOrderBy.concat([e]);return new Ee(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))}}function wr(t,e="asc"){const n=e,r=dr("orderBy",t);return new yr(r,n)}class _r extends fr{constructor(t,e,n){super(),this.type=t,this.Et=e,this.It=n}_apply(t){return new Tn(t.firestore,t.converter,function(t,e,n){return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}(t._query,this.Et,this.It))}}function vr(t){return yt("limit",t),new _r("limit",t,"F")}function br(t){return yt("limitToLast",t),new _r("limitToLast",t,"L")}class Er extends fr{constructor(t,e,n){super(),this.type=t,this.Tt=e,this.At=n}_apply(t){const e=Dr(t,this.type,this.Tt,this.At);return new Tn(t.firestore,t.converter,function(t,e){return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))}}function Sr(...t){return new Er("startAt",t,!0)}function Tr(...t){return new Er("startAfter",t,!1)}class Ar extends fr{constructor(t,e,n){super(),this.type=t,this.Tt=e,this.At=n}_apply(t){const e=Dr(t,this.type,this.Tt,this.At);return new Tn(t.firestore,t.converter,function(t,e){return new Ee(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))}}function kr(...t){return new Ar("endBefore",t,!1)}function Ir(...t){return new Ar("endAt",t,!0)}function Dr(t,e,n,r){if(n[0]=w(n[0]),n[0]instanceof ur)return function(t,e,n,r,s){if(!r)throw new Q(M,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const i=[];for(const n of ke(t))if(n.field.isKeyField())i.push(Zt(e,r.key));else{const t=r.data.field(n.field);if(Wt(t))throw new Q(C,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===t){const t=n.field.canonicalString();throw new Q(C,`Invalid query. You are trying to start or end a query using a document for which the field '${t}' (used as the orderBy) does not exist.`)}i.push(t)}return new we(i,s)}(t._query,t.firestore._databaseId,e,n[0]._document,r);{const s=Un(t.firestore);return function(t,e,n,r,s,i){const o=t.explicitOrderBy;if(s.length>o.length)throw new Q(C,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let i=0;i<s.length;i++){const u=s[i];if(o[i].field.isKeyField()){if("string"!=typeof u)throw new Q(C,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof u}`);if(!Ae(t)&&-1!==u.indexOf("/"))throw new Q(C,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${u}' contains a slash.`);const n=t.path.child(ut.fromString(u));if(!ht.isDocumentKey(n))throw new Q(C,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);const s=new ht(n);a.push(Zt(e,s))}else{const t=Xn(n,r,u);a.push(t)}}return new we(a,i)}(t._query,t.firestore._databaseId,s,e,n,r)}}function Vr(t,e,n){if("string"==typeof(n=w(n))){if(""===n)throw new Q(C,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ae(e)&&-1!==n.indexOf("/"))throw new Q(C,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(ut.fromString(n));if(!ht.isDocumentKey(r))throw new Q(C,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Zt(t,new ht(r))}if(n instanceof Sn)return Zt(t,n._key);throw new Q(C,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${mt(n)}.`)}function Nr(t,e){if(!Array.isArray(t)||0===t.length)throw new Q(C,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Q(C,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function Fr(t,e,n){if(!n.isEqual(e))throw new Q(C,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}function Rr(t,e,n){let r;return r=t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e,r}class Lr extends class{convertValue(t,e="none"){switch(Kt(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Ut(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(jt(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw R()}}convertObject(t,e){const n={};return Rt(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new xn(Ut(t.latitude),Ut(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=Ht(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Gt(t));default:return null}}convertTimestamp(t){const e=$t(t);return new Vt(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=ut.fromString(t);L(on(n));const r=new ot(n.get(1),n.get(3)),s=new ht(n.popFirst(5));return r.isEqual(e)||V(`Document ${s} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),s}}{constructor(t){super(),this.firestore=t}convertBytes(t){return new Fn(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new Sn(this.firestore,null,e)}}function Or(t){const e=fn((t=gt(t,Sn)).firestore),n=new Lr(t.firestore);return hn(e,[t._key]).then((e=>{L(1===e.length);const r=e[0];return new ur(t.firestore,n,t._key,r.isFoundDocument()?r:null,t.converter)}))}function xr(t){!function(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new Q(G,"limitToLast() queries require specifying at least one orderBy() clause")}((t=gt(t,Tn))._query);const e=fn(t.firestore),n=new Lr(t.firestore);return async function(t,e){const n=O(t),r=tn(n.L,Ie(e));return(await n.P("RunQuery",r.parent,{structuredQuery:r.structuredQuery})).filter((t=>!!t.document)).map((t=>function(t,e,n){const r=Ye(t,e.name),s=ze(e.updateTime),i=new ie({mapValue:{fields:e.fields}});return oe.newFoundDocument(r,s,i)}(n.L,t.document)))}(e,t._query).then((e=>{const r=e.map((e=>new lr(t.firestore,n,e.key,e,t.converter)));return"L"===t._query.limitType&&r.reverse(),new cr(t,r)}))}function Pr(t,e,n){const r=Rr((t=gt(t,Sn)).converter,e,n),s=jn(Un(t.firestore),"setDoc",t._key,r,null!==t.converter,n);return cn(fn(t.firestore),[s.toMutation(t._key,xe.none())])}function Cr(t,e,n,...r){const s=Un((t=gt(t,Sn)).firestore);let i;return i="string"==typeof(e=w(e))||e instanceof Rn?Jn(s,"updateDoc",t._key,e,n,r):Yn(s,"updateDoc",t._key,e),cn(fn(t.firestore),[i.toMutation(t._key,xe.exists(!0))])}function qr(t){return cn(fn((t=gt(t,Sn)).firestore),[new Me(t._key,xe.none())])}function Mr(t,e){const n=Dn(t=gt(t,An)),r=Rr(t.converter,e),s=jn(Un(t.firestore),"addDoc",n._key,r,null!==n.converter,{});return cn(fn(t.firestore),[s.toMutation(n._key,xe.exists(!1))]).then((()=>n))}function Br(t){const e=gt(t.firestore,mn),n=fn(e),r=new Lr(e);return new En(t,n,r).run()}function $r(t,e){return Nn(t.query,e.query)&&g(t.data(),e.data())}function Ur(){return new Wn("deleteField")}function jr(){return new Gn("serverTimestamp")}function Wr(...t){return new zn("arrayUnion",t)}function Hr(...t){return new Kn("arrayRemove",t)}function Gr(t){return new Qn("increment",t)}class zr{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=Un(t)}set(t,e,n){this._verifyNotCommitted();const r=Kr(t,this._firestore),s=Rr(r.converter,e,n),i=jn(this._dataReader,"WriteBatch.set",r._key,s,null!==r.converter,n);return this._mutations.push(i.toMutation(r._key,xe.none())),this}update(t,e,n,...r){this._verifyNotCommitted();const s=Kr(t,this._firestore);let i;return i="string"==typeof(e=w(e))||e instanceof Rn?Jn(this._dataReader,"WriteBatch.update",s._key,e,n,r):Yn(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(i.toMutation(s._key,xe.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=Kr(t,this._firestore);return this._mutations=this._mutations.concat(new Me(e._key,xe.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Q(j,"A write batch can no longer be used after commit() has been called.")}}function Kr(t,e){if((t=w(t)).firestore!==e)throw new Q(C,"Provided document reference is from a different Firestore instance.");return t}function Qr(t){const e=fn(t=gt(t,mn));return new zr(t,(t=>cn(e,t)))}class Yr{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new Q(C,"Firestore transactions require all reads to be executed before all writes.");const e=await hn(this.datastore,t);return e.forEach((t=>this.recordVersion(t))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())}delete(t){this.write(new Me(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((t,e)=>{const n=ht.fromPath(e);this.mutations.push(new Be(n,this.precondition(n)))})),await cn(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw R();e=Nt.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new Q(W,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(Nt.min())?xe.exists(!1):xe.updateTime(e):xe.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(Nt.min()))throw new Q(C,"Can't update a document that doesn't exist.");return xe.updateTime(e)}return xe.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}const Jr={maxAttempts:5};class Xr{constructor(t,e,n,r,s){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=r,this.deferred=s,this.Rt=n.maxAttempts,this.Pt=new un(this.asyncQueue,"transaction_retry")}run(){this.Rt-=1,this.Vt()}Vt(){this.Pt.J((async()=>{const t=new Yr(this.datastore),e=this.Nt(t);e&&e.then((e=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(e)})).catch((t=>{this.Dt(t)}))))})).catch((t=>{this.Dt(t)}))}))}Nt(t){try{const e=this.updateFunction(t);return!wt(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}}Dt(t){this.Rt>0&&this.$t(t)?(this.Rt-=1,this.asyncQueue.enqueueAndForget((()=>(this.Vt(),Promise.resolve())))):this.deferred.reject(t)}$t(t){if("FirebaseError"===t.name){const e=t.code;return"aborted"===e||"failed-precondition"===e||!function(t){switch(t){default:return R();case x:case P:case q:case U:case z:case K:case $:return!1;case C:case M:case"already-exists":case B:case j:case W:case H:case G:case"data-loss":return!0}}(e)}return!1}}function Zr(){return"undefined"!=typeof document?document:null}class ts{constructor(t,e,n,r,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=s,this.deferred=new Y,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((t=>{}))}static createAndSchedule(t,e,n,r,s){const i=Date.now()+n,o=new ts(t,e,i,r,s);return o.start(n),o}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Q(x,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}class es{constructor(){this.xt=Promise.resolve(),this.Ft=[],this.St=!1,this.qt=[],this.Ot=null,this.kt=!1,this.Ct=!1,this.Lt=[],this.Pt=new un(this,"async_queue_retry"),this.Mt=()=>{const t=Zr();t&&D("AsyncQueue","Visibility state changed to "+t.visibilityState),this.Pt.Z()};const t=Zr();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Mt)}get isShuttingDown(){return this.St}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.Ut(),this.jt(t)}enterRestrictedMode(t){if(!this.St){this.St=!0,this.Ct=t||!1;const e=Zr();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Mt)}}enqueue(t){if(this.Ut(),this.St)return new Promise((()=>{}));const e=new Y;return this.jt((()=>this.St&&this.Ct?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.Ft.push(t),this.Bt())))}async Bt(){if(0!==this.Ft.length){try{await this.Ft[0](),this.Ft.shift(),this.Pt.reset()}catch(t){if(!function(t){return"IndexedDbTransactionError"===t.name}(t))throw t;D("AsyncQueue","Operation failed with retryable error: "+t)}this.Ft.length>0&&this.Pt.J((()=>this.Bt()))}}jt(t){const e=this.xt.then((()=>(this.kt=!0,t().catch((t=>{this.Ot=t,this.kt=!1;const e=function(t){let e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t);throw V("INTERNAL UNHANDLED ERROR: ",e),t})).then((t=>(this.kt=!1,t))))));return this.xt=e,e}enqueueAfterDelay(t,e,n){this.Ut(),this.Lt.indexOf(t)>-1&&(e=0);const r=ts.createAndSchedule(this,t,e,n,(t=>this.Qt(t)));return this.qt.push(r),r}Ut(){this.Ot&&R()}verifyOperationInProgress(){}async zt(){let t;do{t=this.xt,await t}while(t!==this.xt)}Gt(t){for(const e of this.qt)if(e.timerId===t)return!0;return!1}Wt(t){return this.zt().then((()=>{this.qt.sort(((t,e)=>t.targetTimeMs-e.targetTimeMs));for(const e of this.qt)if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.zt()}))}Kt(t){this.Lt.push(t)}Qt(t){const e=this.qt.indexOf(t);this.qt.splice(e,1)}}class ns{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=Un(t)}get(t){const e=Kr(t,this._firestore),n=new Lr(this._firestore);return this._transaction.lookup([e._key]).then((t=>{if(!t||1!==t.length)return R();const r=t[0];if(r.isFoundDocument())return new ur(this._firestore,n,r.key,r,e.converter);if(r.isNoDocument())return new ur(this._firestore,n,e._key,null,e.converter);throw R()}))}set(t,e,n){const r=Kr(t,this._firestore),s=Rr(r.converter,e,n),i=jn(this._dataReader,"Transaction.set",r._key,s,null!==r.converter,n);return this._transaction.set(r._key,i),this}update(t,e,n,...r){const s=Kr(t,this._firestore);let i;return i="string"==typeof(e=w(e))||e instanceof Rn?Jn(this._dataReader,"Transaction.update",s._key,e,n,r):Yn(this._dataReader,"Transaction.update",s._key,e),this._transaction.update(s._key,i),this}delete(t){const e=Kr(t,this._firestore);return this._transaction.delete(e._key),this}}function rs(t,e,n){const r=fn(t=gt(t,mn)),s=Object.assign(Object.assign({},Jr),n);!function(t){if(t.maxAttempts<1)throw new Q(C,"Max attempts must be at least 1")}(s);const i=new Y;return new Xr(new es,r,s,(n=>e(new ns(t,n))),i).run(),i.promise}A=`${i}_lite`,t(new class{constructor(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}("firestore/lite",((t,{instanceIdentifier:e,options:n})=>{const r=t.getProvider("app").getImmediate(),s=new mn(new tt(t.getProvider("auth-internal")),new st(t.getProvider("app-check-internal")),function(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new Q(C,'"projectId" not provided in firebase.initializeApp.');return new ot(t.options.projectId,e)}(r,e),r);return n&&s._setSettings(n),s}),"PUBLIC").setMultipleInstances(!0)),e("firestore-lite","3.7.2",""),e("firestore-lite","3.7.2","esm2017");export{vn as AggregateField,bn as AggregateQuerySnapshot,Fn as Bytes,An as CollectionReference,Sn as DocumentReference,ur as DocumentSnapshot,Rn as FieldPath,On as FieldValue,mn as Firestore,Q as FirestoreError,xn as GeoPoint,Tn as Query,fr as QueryConstraint,lr as QueryDocumentSnapshot,cr as QuerySnapshot,Vt as Timestamp,ns as Transaction,zr as WriteBatch,Mr as addDoc,$r as aggregateQuerySnapshotEqual,Hr as arrayRemove,Wr as arrayUnion,kn as collection,In as collectionGroup,wn as connectFirestoreEmulator,qr as deleteDoc,Ur as deleteField,Dn as doc,Ln as documentId,Ir as endAt,kr as endBefore,Br as getCount,Or as getDoc,xr as getDocs,yn as getFirestore,Gr as increment,gn as initializeFirestore,vr as limit,br as limitToLast,wr as orderBy,pr as query,Nn as queryEqual,Vn as refEqual,rs as runTransaction,jr as serverTimestamp,Pr as setDoc,I as setLogLevel,hr as snapshotEqual,Tr as startAfter,Sr as startAt,_n as terminate,Cr as updateDoc,gr as where,Qr as writeBatch};
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=firebase-firestore-lite.js.map
|