1/*! For license information please see 7112840a-dc6ace70c766ea78d1fc.js.LICENSE.txt */ 2"use strict";(self.webpackChunkpropoze=self.webpackChunkpropoze||[]).push([[883],{15790:function(e,t,n){n.d(t,{BN:function(){return Na},GG:function(){return Da},H9:function(){return Ao},My:function(){return pa},P:function(){return ha},W6:function(){return E},aQ:function(){return La},aU:function(){return xo},gS:function(){return Ra},kd:function(){return xa},mZ:function(){return ka},rJ:function(){return bo},wP:function(){return Fa},x7:function(){return ba}});var r=n(31990),s=n(5125),i=n(63424),o=n(36743),a=n(6517);const u="@firebase/firestore";class c{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}c.UNAUTHENTICATED=new c(null),c.GOOGLE_CREDENTIALS=new c("google-credentials-uid"),c.FIRST_PARTY=new c("first-party-uid"),c.MOCK_USER=new c("mock-user");let l="10.9.0";const h=new i.Vy("@firebase/firestore");function d(){return h.logLevel}function f(e,...t){if(h.logLevel<=i.$b.DEBUG){const n=t.map(g);h.debug(`Firestore (${l}): ${e}`,...n)}}function m(e,...t){if(h.logLevel<=i.$b.ERROR){const n=t.map(g);h.error(`Firestore (${l}): ${e}`,...n)}}function p(e,...t){if(h.logLevel<=i.$b.WARN){const n=t.map(g);h.warn(`Firestore (${l}): ${e}`,...n)}}function g(e){if("string"==typeof e)return e;try{return function(e){return JSON.stringify(e)}(e)}catch(t){return e}}function y(e="Unexpected state"){const t=`FIRESTORE (${l}) INTERNAL ASSERTION FAILED: `+e;throw m(t),new Error(t)}function w(e,t){e||y()}function v(e,t){return e}const _={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class E extends o.g{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class T{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class I{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class C{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(c.UNAUTHENTICATED)))}shutdown(){}}class S{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class b{constructor(e){this.t=e,this.currentUser=c.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let s=new T;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new T,e.enqueueRetryable((()=>r(this.currentUser)))};const i=()=>{const t=s;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{f("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),i()};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(f("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new T)}}),0),i()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i!==e?(f("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(w("string"==typeof t.accessToken),new I(t.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return w(null===e||"string"==typeof e),new c(e)}}class A{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=c.FIRST_PARTY,this.I=new Map}T(){return this.P?this.P():null}get headers(){this.I.set("X-Goog-AuthUser",this.l);const e=this.T();return e&&this.I.set("Authorization",e),this.h&&this.I.set("X-Goog-Iam-Authorization-Token",this.h),this.I}}class D{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new A(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable((()=>t(c.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class N{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class k{constructor(e){this.A=e,this.forceRefresh=!1,this.appCheck=null,this.R=null}start(e,t){const n=e=>{null!=e.error&&f("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.R;return this.R=e.token,f("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};const r=e=>{f("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.A.onInit((e=>r(e))),setTimeout((()=>
2{if(!this.appCheck){const e=this.A.getImmediate({optional:!0});e?r(e):f("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(w("string"==typeof e.token),this.R=e.token,new N(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}function x(e){const t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let r=0;r<e;r++)n[r]=Math.floor(256*Math.random());return n}class R{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(256/62);let n="";for(;n.length<20;){const r=x(40);for(let s=0;s<r.length;++s)n.length<20&&r[s]<t&&(n+=e.charAt(r[s]%62))}return n}}function L(e,t){return e<t?-1:e>t?1:0}function V(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}class M{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new E(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new E(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new E(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new E(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return M.fromMillis(Date.now())}static fromDate(e){return M.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new M(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?L(this.nanoseconds,e.nanoseconds):L(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class O{constructor(e){this.timestamp=e}static fromTimestamp(e){return new O(e)}static min(){return new O(new M(0,0))}static max(){return new O(new M(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class P{constructor(e,t,n){void 0===t?t=0:t>e.length&&y(),void 0===n?n=e.length-t:n>e.length-t&&y(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===P.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof P?e.forEach((e=>{t.push(e)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e.get(r),s=t.get(r);if(n<s)return-1;if(n>s)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class F extends P{construct(e,t,n){return new F(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
vendor: 5,205 bytes, line 2
2toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")>=0)throw new E(_.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter((e=>e.length>0)))}return new F(t)}static emptyPath(){return new F([])}}const U=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class q extends P{construct(e,t,n){return new q(e,t,n)}static isValidIdentifier(e){return U.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),q.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new q(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;const s=()=>{if(0===n.length)throw new E(_.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let i=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new E(_.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new E(_.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?(i=!i,r++):"."!==t||i?(n+=t,r++):(s(),r++)}if(s(),i)throw new E(_.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new q(t)}static emptyPath(){return new q([])}}class B{constructor(e){this.path=e}static fromPath(e){return new B(F.fromString(e))}static fromName(e){return new B(F.fromString(e).popFirst(5))}static empty(){return new B(F.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===F.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return F.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new B(new F(e.slice()))}}class ${constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}$.UNKNOWN_ID=-1;function z(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,s=O.fromTimestamp(1e9===r?new M(n+1,0):new M(n,r));return new Q(s,B.empty(),t)}function K(e){return new Q(e.readTime,e.key,-1)}class Q{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new Q(O.min(),B.empty(),-1)}static max(){return new Q(O.max(),B.empty(),-1)}}function G(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=B.comparator(e.documentKey,t.documentKey),0!==n?n:L(e.largestBatchId,t.largestBatchId))}const j="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class W{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function H(e){if(e.code!==_.FAILED_PRECONDITION||e.message!==j)throw e;f("LocalStore","Unexpectedly lost primary lease")}class Y{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)}),(e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&y(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new Y(((n,r)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof Y?t:Y.resolve(t)}catch(e){return Y.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):Y.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):Y.reject(t)}static resolve(e){return new Y(((t,n)=>{t(e)}))}static reject(e){return new Y(((t,n)=>{n(e)}))}static waitFor(e){return new Y(((t,n)=>{let r=0,s=0,i=!1;e.forEach((e=>{++r,e.next((()=>{++s,i&&s===r&&t()}),(e=>n(e)))})),i=!0,s===r&&t()}))}static or(e){let t=Y.resolve(!1);for(const n of e)t=t.next((e=>e?Y.resolve(e):n()));return t}static forEach(e,t){const n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(e,t){return new Y(((n,r)=>{const s=e.length,i=new Array(s);let o=0;for(let a=0;a<s;a++){const u=a;t(e[u]).next((e=>{i[u]=e,++o,o===s&&n(i)}),(e=>r(e)))}}))}static doWhile(e,t){return new Y(((n,r)=>{const s=()=>{!0===e()?t().next((()=>{s()}),r):n()};s()}))}}class J{constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.V=new T,this.transaction.oncomplete=()=>{this.V.resolve()},this.transaction.onabort=()=>{t.error?this.V.reject(new ee(e,t.error)):this.V.resolve()},this.transaction.onerror=t=>{const n=ie(t.target.error);this.V.reject(new ee(e,n))}}
2static open(e,t,n,r){try{return new J(t,e.transaction(r,n))}catch(e){throw new ee(t,e)}}get m(){return this.V.promise}abort(e){e&&this.V.reject(e),this.aborted||(f("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}g(){const e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){const t=this.transaction.objectStore(e);return new ne(t)}}class X{constructor(e,t,n){this.name=e,this.version=t,this.p=n,12.2===X.S((0,o.ZQ)())&&m("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(e){return f("SimpleDb","Removing database:",e),re(window.indexedDB.deleteDatabase(e)).toPromise()}static D(){if(!(0,o.zW)())return!1;if(X.C())return!0;const e=(0,o.ZQ)(),t=X.S(e),n=0<t&&t<10,r=X.v(e),s=0<r&&r<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||n||s)}static C(){var e;return"undefined"!=typeof process&&"YES"===(null===(e=process.__PRIVATE_env)||void 0===e?void 0:e.F)}static M(e,t){return e.store(t)}static S(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static v(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async O(e){return this.db||(f("SimpleDb","Opening database:",this.name),this.db=await new Promise(((t,n)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=e=>{const n=e.target.result;t(n)},r.onblocked=()=>{n(new ee(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=t=>{const r=t.target.error;"VersionError"===r.name?n(new E(_.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===r.name?n(new E(_.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+r)):n(new ee(e,r))},r.onupgradeneeded=e=>{f("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);const t=e.target.result;this.p.N(t,r.transaction,e.oldVersion,this.version).next((()=>{f("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.L&&(this.db.onversionchange=e=>this.L(e)),this.db}B(e){this.L=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){const s="readonly"===t;let i=0;for(;;){++i;try{this.db=await this.O(e);const t=J.open(this.db,e,s?"readonly":"readwrite",n),i=r(t).next((e=>(t.g(),e))).catch((e=>(t.abort(e),Y.reject(e)))).toPromise();return i.catch((()=>{})),await t.m,i}catch(e){const t=e,n="FirebaseError"!==t.name&&i<3;if(f("SimpleDb","Transaction failed with error:",t.message,"Retrying:",n),this.close(),!n)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}class Z{constructor(e){this.k=e,this.q=!1,this.K=null}get isDone(){return this.q}get $(){return this.K}set cursor(e){this.k=e}done(){this.q=!0}U(e){this.K=e}delete(){return re(this.k.delete())}}class ee extends E{constructor(e,t){super(_.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function te(e){return"IndexedDbTransactionError"===e.name}class ne{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(f("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(f("SimpleDb","PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),re(n)}add(e){return f("SimpleDb","ADD",this.store.name,e,e),re(this.store.add(e))}get(e){return re(this.store.get(e)).next((t=>(void 0===t&&(t=null),f("SimpleDb","GET",this.store.name,e,t),t)))}delete(e){return f("SimpleDb","DELETE",this.store.name,e),re(this.store.delete(e))}count(){return f("SimpleDb","COUNT",this.store.name),re(this.store.count())}W(e,t){const n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){const e=r.getAll(n.range);return new Y(((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}}))}{const e=this.cursor(n),t=[];return this.G(e,((e,n)=>{t.push(n)})).next((()=>t))}}j(e,t){const n=this.store.getAll(e,null===t?void 0:t);return new Y(((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}}))}H(e,t){f("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.J=!1;const r=this.cursor(n);
vendor: 4,655 bytes, line 2
2return this.G(r,((e,t,n)=>n.delete()))}Y(e,t){let n;t?n=e:(n={},t=e);const r=this.cursor(n);return this.G(r,t)}Z(e){const t=this.cursor({});return new Y(((n,r)=>{t.onerror=e=>{const t=ie(e.target.error);r(t)},t.onsuccess=t=>{const r=t.target.result;r?e(r.primaryKey,r.value).next((e=>{e?r.continue():n()})):n()}}))}G(e,t){const n=[];return new Y(((r,s)=>{e.onerror=e=>{s(e.target.error)},e.onsuccess=e=>{const s=e.target.result;if(!s)return void r();const i=new Z(s),o=t(s.primaryKey,s.value,i);if(o instanceof Y){const e=o.catch((e=>(i.done(),Y.reject(e))));n.push(e)}i.isDone?r():null===i.$?s.continue():s.continue(i.$)}})).next((()=>Y.waitFor(n)))}options(e,t){let n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){const n=this.store.index(e.index);return e.J?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function re(e){return new Y(((t,n)=>{e.onsuccess=e=>{const n=e.target.result;t(n)},e.onerror=e=>{const t=ie(e.target.error);n(t)}}))}let se=!1;function ie(e){const t=X.S((0,o.ZQ)());if(t>=12.2&&t<13){const t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){const e=new E("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return se||(se=!0,setTimeout((()=>{throw e}),0)),e}}return e}class oe{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.se(e),this.oe=e=>t.writeSequenceNumber(e))}se(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.oe&&this.oe(e),e}}function ae(e){return null==e}function ue(e){return 0===e&&1/e==-1/0}function ce(e){return"number"==typeof e&&Number.isInteger(e)&&!ue(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}oe._e=-1;const le=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],he=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],de=he;function fe(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function me(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function pe(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class ge{constructor(e,t){this.comparator=e,this.root=t||we.EMPTY}insert(e,t){return new ge(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,we.BLACK,null,null))}remove(e){return new ge(this.comparator,this.root.remove(e,this.comparator).copy(null,null,we.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=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(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,n)=>(e(t,n),!1)))}toString(){const e=[];return this.inorderTraversal(((t,n)=>(e.push(`${t}:${n}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new ye(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new ye(this.root,e,this.comparator,!1)}getReverseIterator(){return new ye(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new ye(this.root,e,this.comparator,!0)}}class ye{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=t?n(e.key,t):1,t&&r&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(0===s){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}
vendor: 4,677 bytes, line 2
2class we{constructor(e,t,n,r,s){this.key=e,this.value=t,this.color=null!=n?n:we.RED,this.left=null!=r?r:we.EMPTY,this.right=null!=s?s:we.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,s){return new we(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=s?s:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let r=this;const s=n(e,r.key);return r=s<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===s?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return we.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,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(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return we.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(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,we.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,we.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw y();if(this.right.isRed())throw y();const e=this.left.check();if(e!==this.right.check())throw y();return e+(this.isRed()?0:1)}}we.EMPTY=null,we.RED=!0,we.BLACK=!1,we.EMPTY=new class{constructor(){this.size=0}get key(){throw y()}get value(){throw y()}get color(){throw y()}get left(){throw y()}get right(){throw y()}copy(e,t,n,r,s){return this}insert(e,t,n){return new we(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class ve{constructor(e){this.comparator=e,this.data=new ge(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,n)=>(e(t),!1)))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new _e(this.data.getIterator())}getIteratorFrom(e){return new _e(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((e=>{t=t.add(e)})),t}isEqual(e){if(!(e instanceof ve))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new ve(this.comparator);return t.data=e,t}}
2class _e{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Ee{constructor(e){this.fields=e,e.sort(q.comparator)}static empty(){return new Ee([])}unionWith(e){let t=new ve(q.comparator);for(const n of this.fields)t=t.add(n);for(const n of e)t=t.add(n);return new Ee(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return V(this.fields,e.fields,((e,t)=>e.isEqual(t)))}}class Te extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Ie{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new Te("Invalid base64 string: "+e):e}}(e);return new Ie(t)}static fromUint8Array(e){const t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new Ie(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return L(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Ie.EMPTY_BYTE_STRING=new Ie("");const Ce=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Se(e){if(w(!!e),"string"==typeof e){let t=0;const n=Ce.exec(e);if(w(!!n),n[1]){let e=n[1];e=(e+"000000000").substr(0,9),t=Number(e)}const r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:be(e.seconds),nanos:be(e.nanos)}}function be(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function Ae(e){return"string"==typeof e?Ie.fromBase64String(e):Ie.fromUint8Array(e)}function De(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Ne(e){const t=e.mapValue.fields.__previous_value__;return De(t)?Ne(t):t}function ke(e){const t=Se(e.mapValue.fields.__local_write_time__.timestampValue);return new M(t.seconds,t.nanos)}class xe{constructor(e,t,n,r,s,i,o,a,u){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=s,this.forceLongPolling=i,this.autoDetectLongPolling=o,this.longPollingOptions=a,this.useFetchStreams=u}}class Re{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new Re("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof Re&&e.projectId===this.projectId&&e.database===this.database}}const Le={mapValue:{fields:{__type__:{stringValue:"__max__"}}}};function Ve(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?De(e)?4:We(e)?9007199254740991:10:y()}function Me(e,t){if(e===t)return!0;const n=Ve(e);if(n!==Ve(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return ke(e).isEqual(ke(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=Se(e.timestampValue),r=Se(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Ae(e.bytesValue).isEqual(Ae(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return be(e.geoPointValue.latitude)===be(t.geoPointValue.latitude)&&be(e.geoPointValue.longitude)===be(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return be(e.integerValue)===be(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=be(e.doubleValue),r=be(t.doubleValue);return n===r?ue(n)===ue(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return V(e.arrayValue.values||[],t.arrayValue.values||[],Me);case 10:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(fe(n)!==fe(r))return!1;for(const s in n)if(n.hasOwnProperty(s)&&(void 0===r[s]||!Me(n[s],r[s])))return!1;return!0}(e,t);default:return y()}}function Oe(e,t){return void 0!==(e.values||[]).find((e=>Me(e,t)))}function Pe(e,t){if(e===t)return 0;const n=Ve(e),r=Ve(t);if(n!==r)return L(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return L(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=be(e.integerValue||e.doubleValue),r=be(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Fe(e.timestampValue,t.timestampValue);case 4:return Fe(ke(e),ke(t));case 5:return L(e.stringValue,t.stringValue);case 6:return function(e,t){const n=Ae(e),r=Ae(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let s=0;s<n.length&&s<r.length;s++){const e=L(n[s],r[s]);if(0!==e)return e}return L(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=L(be(e.latitude),be(t.latitude));return 0!==n?n:L(be(e.longitude),be(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return function(e,t){const n=e.values||[],r=t.values||[];for(let s=0;s<n.length&&s<r.length;++s){const e=Pe(n[s],r[s]);if(e)return e}return L(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){if(e===Le.mapValue&&t===Le.mapValue)return 0;if(e===Le.mapValue)return 1;if(t===Le.mapValue)return-1;const n=e.fields||{},r=Object.keys(n),s=t.fields||{},i=Object.keys(s);r.sort(),i.sort();for(let o=0;o<r.length&&o<i.length;++o){const e=L(r[o],i[o]);if(0!==e)return e;const t=Pe(n[r[o]],s[i[o]]);if(0!==t)return t}return L(r.length,i.length)}(e.mapValue,t.mapValue);default:throw y()}}function Fe(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return L(e,t);const n=Se(e),r=Se(t),s=L(n.seconds,r.seconds);return 0!==s?s:L(n.nanos,r.nanos)}function Ue(e){return qe(e)}function qe(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=Se(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?function(e){return Ae(e).toBase64()}
vendor: 4,792 bytes, line 2
2(e.bytesValue):"referenceValue"in e?function(e){return B.fromName(e).toString()}(e.referenceValue):"geoPointValue"in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=qe(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const s of t)r?r=!1:n+=",",n+=`${s}:${qe(e.fields[s])}`;return n+"}"}(e.mapValue):y()}function Be(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function $e(e){return!!e&&"integerValue"in e}function ze(e){return!!e&&"arrayValue"in e}function Ke(e){return!!e&&"nullValue"in e}function Qe(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Ge(e){return!!e&&"mapValue"in e}function je(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return me(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=je(n))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=je(e.arrayValue.values[n]);return t}return Object.assign({},e)}function We(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}class He{constructor(e){this.value=e}static empty(){return new He({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!Ge(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=je(t)}setAll(e){let t=q.emptyPath(),n={},r=[];e.forEach(((e,s)=>{if(!t.isImmediateParentOf(s)){const e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=s.popLast()}e?n[s.lastSegment()]=je(e):r.push(s.lastSegment())}));const s=this.getFieldsMap(t);this.applyChanges(s,n,r)}delete(e){const t=this.field(e.popLast());Ge(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Me(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];Ge(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){me(t,((t,n)=>e[t]=n));for(const r of n)delete e[r]}clone(){return new He(je(this.value))}}function Ye(e){const t=[];return me(e.fields,((e,n)=>{const r=new q([e]);if(Ge(n)){const e=Ye(n.mapValue).fields;if(0===e.length)t.push(r);else for(const n of e)t.push(r.child(n))}else t.push(r)})),new Ee(t)}class Je{constructor(e,t,n,r,s,i,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=s,this.data=i,this.documentState=o}static newInvalidDocument(e){return new Je(e,0,O.min(),O.min(),O.min(),He.empty(),0)}static newFoundDocument(e,t,n,r){return new Je(e,1,t,O.min(),n,r,0)}static newNoDocument(e,t){return new Je(e,2,t,O.min(),O.min(),He.empty(),0)}static newUnknownDocument(e,t){return new Je(e,3,t,O.min(),O.min(),He.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(O.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=He.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=He.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=O.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof Je&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Je(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}
vendor: 6,371 bytes, line 2
2class Xe{constructor(e,t){this.position=e,this.inclusive=t}}function Ze(e,t,n){let r=0;for(let s=0;s<e.position.length;s++){const i=t[s],o=e.position[s];if(r=i.field.isKeyField()?B.comparator(B.fromName(o.referenceValue),n.key):Pe(o,n.data.field(i.field)),"desc"===i.dir&&(r*=-1),0!==r)break}return r}function et(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!Me(e.position[n],t.position[n]))return!1;return!0}class tt{constructor(e,t="asc"){this.field=e,this.dir=t}}function nt(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}class rt{}class st extends rt{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new dt(e,t,n):"array-contains"===t?new gt(e,n):"in"===t?new yt(e,n):"not-in"===t?new wt(e,n):"array-contains-any"===t?new vt(e,n):new st(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new ft(e,n):new mt(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&&this.matchesComparison(Pe(t,this.value)):null!==t&&Ve(this.value)===Ve(t)&&this.matchesComparison(Pe(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return y()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class it extends rt{constructor(e,t){super(),this.filters=e,this.op=t,this.ue=null}static create(e,t){return new it(e,t)}matches(e){return ot(this)?void 0===this.filters.find((t=>!t.matches(e))):void 0!==this.filters.find((t=>t.matches(e)))}getFlattenedFilters(){return null!==this.ue||(this.ue=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.ue}getFilters(){return Object.assign([],this.filters)}}function ot(e){return"and"===e.op}function at(e){return ut(e)&&ot(e)}function ut(e){for(const t of e.filters)if(t instanceof it)return!1;return!0}function ct(e){if(e instanceof st)return e.field.canonicalString()+e.op.toString()+Ue(e.value);if(at(e))return e.filters.map((e=>ct(e))).join(",");{const t=e.filters.map((e=>ct(e))).join(",");return`${e.op}(${t})`}}function lt(e,t){return e instanceof st?function(e,t){return t instanceof st&&e.op===t.op&&e.field.isEqual(t.field)&&Me(e.value,t.value)}(e,t):e instanceof it?function(e,t){return t instanceof it&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce(((e,n,r)=>e&<(n,t.filters[r])),!0)}(e,t):void y()}function ht(e){return e instanceof st?function(e){return`${e.field.canonicalString()} ${e.op} ${Ue(e.value)}`}(e):e instanceof it?function(e){return e.op.toString()+" {"+e.getFilters().map(ht).join(" ,")+"}"}(e):"Filter"}class dt extends st{constructor(e,t,n){super(e,t,n),this.key=B.fromName(n.referenceValue)}matches(e){const t=B.comparator(e.key,this.key);return this.matchesComparison(t)}}class ft extends st{constructor(e,t){super(e,"in",t),this.keys=pt("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class mt extends st{constructor(e,t){super(e,"not-in",t),this.keys=pt("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function pt(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map((e=>B.fromName(e.referenceValue)))}class gt extends st{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return ze(t)&&Oe(t.arrayValue,this.value)}}class yt extends st{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&&Oe(this.value.arrayValue,t)}}class wt extends st{constructor(e,t){super(e,"not-in",t)}matches(e){if(Oe(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&&!Oe(this.value.arrayValue,t)}}class vt extends st{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!ze(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>Oe(this.value.arrayValue,e)))}}class _t{constructor(e,t=null,n=[],r=[],s=null,i=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=s,this.startAt=i,this.endAt=o,this.ce=null}}function Et(e,t=null,n=[],r=[],s=null,i=null,o=null){return new _t(e,t,n,r,s,i,o)}function Tt(e){const t=v(e);if(null===t.ce){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map((e=>ct(e))).join(","),e+="|ob:",e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(","),ae(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((e=>Ue(e))).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((e=>Ue(e))).join(",")),t.ce=e}return t.ce}function It(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!nt(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!lt(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!et(e.startAt,t.startAt)&&et(e.endAt,t.endAt)}function Ct(e){return B.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class St{constructor(e,t=null,n=[],r=[],s=null,i="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=s,this.limitType=i,this.startAt=o,this.endAt=a,this.le=null,this.he=null,this.Pe=null,this.startAt,this.endAt}}function bt(e,t,n,r,s,i,o,a){return new St(e,t,n,r,s,i,o,a)}function At(e){return new St(e)}function Dt(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function Nt(e){return null!==e.collectionGroup}function kt(e){const t=v(e);if(null===t.le){t.le=[];const e=new Set;for(const s of t.explicitOrderBy)t.le.push(s),e.add(s.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc",r=function(e){let t=new ve(q.comparator);
2return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t}(t);r.forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.le.push(new tt(r,n))})),e.has(q.keyField().canonicalString())||t.le.push(new tt(q.keyField(),n))}return t.le}function xt(e){const t=v(e);return t.he||(t.he=Rt(t,kt(e))),t.he}function Rt(e,t){if("F"===e.limitType)return Et(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((e=>{const t="desc"===e.dir?"asc":"desc";return new tt(e.field,t)}));const n=e.endAt?new Xe(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Xe(e.startAt.position,e.startAt.inclusive):null;return Et(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function Lt(e,t){const n=e.filters.concat([t]);return new St(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Vt(e,t,n){return new St(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Mt(e,t){return It(xt(e),xt(t))&&e.limitType===t.limitType}function Ot(e){return`${Tt(xt(e))}|lt:${e.limitType}`}function Pt(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>ht(e))).join(", ")}]`),ae(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((e=>Ue(e))).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((e=>Ue(e))).join(",")),`Target(${t})`}(xt(e))}; limitType=${e.limitType})`}function Ft(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):B.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of kt(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const r=Ze(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,kt(e),t))&&!(e.endAt&&!function(e,t,n){const r=Ze(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,kt(e),t))}(e,t)}function Ut(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function qt(e){return(t,n)=>{let r=!1;for(const s of kt(e)){const e=Bt(s,t,n);if(0!==e)return e;r=r||s.field.isKeyField()}return 0}}function Bt(e,t,n){const r=e.field.isKeyField()?B.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),s=n.data.field(e);return null!==r&&null!==s?Pe(r,s):y()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return y()}}class $t{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[r,s]of n)if(this.equalsFn(r,e))return s}has(e){return void 0!==this.get(e)}set(e,t){const n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return void(r[s]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){me(this.inner,((t,n)=>{for(const[r,s]of n)e(r,s)}))}isEmpty(){return pe(this.inner)}size(){return this.innerSize}}const zt=new ge(B.comparator);function Kt(){return zt}const Qt=new ge(B.comparator);function Gt(...e){let t=Qt;for(const n of e)t=t.insert(n.key,n);return t}function jt(e){let t=Qt;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Wt(){return Yt()}function Ht(){return Yt()}function Yt(){return new $t((e=>e.toString()),((e,t)=>e.isEqual(t)))}const Jt=new ge(B.comparator),Xt=new ve(B.comparator);function Zt(...e){let t=Xt;for(const n of e)t=t.add(n);return t}const en=new ve(L);function tn(){return en}function nn(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ue(t)?"-0":t}}function rn(e){return{integerValue:""+e}}function sn(e,t){return ce(t)?rn(t):nn(e,t)}class on{constructor(){this._=void 0}}function an(e,t,n){return e instanceof ln?function(e,t){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&De(t)&&(t=Ne(t)),t&&(n.fields.__previous_value__=t),{mapValue:n}}(n,t):e instanceof hn?dn(e,t):e instanceof fn?mn(e,t):function(e,t){const n=cn(e,t),r=gn(n)+gn(e.Ie);return $e(n)&&$e(e.Ie)?rn(r):nn(e.serializer,r)}(e,t)}
2function un(e,t,n){return e instanceof hn?dn(e,t):e instanceof fn?mn(e,t):n}function cn(e,t){return e instanceof pn?function(e){return $e(e)||function(e){return!!e&&"doubleValue"in e}(e)}(t)?t:{integerValue:0}:null}class ln extends on{}class hn extends on{constructor(e){super(),this.elements=e}}function dn(e,t){const n=yn(t);for(const r of e.elements)n.some((e=>Me(e,r)))||n.push(r);return{arrayValue:{values:n}}}class fn extends on{constructor(e){super(),this.elements=e}}function mn(e,t){let n=yn(t);for(const r of e.elements)n=n.filter((e=>!Me(e,r)));return{arrayValue:{values:n}}}class pn extends on{constructor(e,t){super(),this.serializer=e,this.Ie=t}}function gn(e){return be(e.integerValue||e.doubleValue)}function yn(e){return ze(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class wn{constructor(e,t){this.version=e,this.transformResults=t}}class vn{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new vn}static exists(e){return new vn(void 0,e)}static updateTime(e){return new vn(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function _n(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class En{}function Tn(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new Rn(e.key,vn.none()):new An(e.key,e.data,vn.none());{const n=e.data,r=He.empty();let s=new ve(q.comparator);for(let e of t.fields)if(!s.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),s=s.add(e)}return new Dn(e.key,r,new Ee(s.toArray()),vn.none())}}function In(e,t,n){e instanceof An?function(e,t,n){const r=e.value.clone(),s=kn(e.fieldTransforms,t,n.transformResults);r.setAll(s),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Dn?function(e,t,n){if(!_n(e.precondition,t))return void t.convertToUnknownDocument(n.version);const r=kn(e.fieldTransforms,t,n.transformResults),s=t.data;s.setAll(Nn(e)),s.setAll(r),t.convertToFoundDocument(n.version,s).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function Cn(e,t,n,r){return e instanceof An?function(e,t,n,r){if(!_n(e.precondition,t))return n;const s=e.value.clone(),i=xn(e.fieldTransforms,r,t);return s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null}(e,t,n,r):e instanceof Dn?function(e,t,n,r){if(!_n(e.precondition,t))return n;const s=xn(e.fieldTransforms,r,t),i=t.data;return i.setAll(Nn(e)),i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=>e.field)))}(e,t,n,r):function(e,t,n){return _n(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function Sn(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),s=cn(r.transform,e||null);null!=s&&(null===n&&(n=He.empty()),n.set(r.field,s))}return n||null}function bn(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return void 0===e&&void 0===t||!(!e||!t)&&V(e,t,((e,t)=>function(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof hn&&t instanceof hn||e instanceof fn&&t instanceof fn?V(e.elements,t.elements,Me):e instanceof pn&&t instanceof pn?Me(e.Ie,t.Ie):e instanceof ln&&t instanceof ln}(e.transform,t.transform)}(e,t)))}(e.fieldTransforms,t.fieldTransforms)&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class An extends En{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class Dn extends En{constructor(e,t,n,r,s=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function Nn(e){const t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}})),t}function kn(e,t,n){const r=new Map;w(e.length===n.length);for(let s=0;s<n.length;s++){const i=e[s],o=i.transform,a=t.data.field(i.field);r.set(i.field,un(o,a,n[s]))}return r}function xn(e,t,n){const r=new Map;for(const s of e){const e=s.transform,i=n.data.field(s.field);r.set(s.field,an(e,i,t))}return r}
2class Rn extends En{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Ln extends En{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class Vn{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let r=0;r<this.mutations.length;r++){const t=this.mutations[r];t.key.isEqual(e.key)&&In(t,e,n[r])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=Cn(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=Cn(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=Ht();return this.mutations.forEach((r=>{const s=e.get(r.key),i=s.overlayedDocument;let o=this.applyToLocalView(i,s.mutatedFields);o=t.has(r.key)?null:o;const a=Tn(i,o);null!==a&&n.set(r.key,a),i.isValidDocument()||i.convertToNoDocument(O.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),Zt())}isEqual(e){return this.batchId===e.batchId&&V(this.mutations,e.mutations,((e,t)=>bn(e,t)))&&V(this.baseMutations,e.baseMutations,((e,t)=>bn(e,t)))}}class Mn{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){w(e.mutations.length===n.length);let r=Jt;const s=e.mutations;for(let i=0;i<s.length;i++)r=r.insert(s[i].key,n[i].version);return new Mn(e,t,n,r)}}class On{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}class Pn{constructor(e,t){this.count=e,this.unchangedNames=t}}var Fn,Un;function qn(e){switch(e){default:return y();case _.CANCELLED:case _.UNKNOWN:case _.DEADLINE_EXCEEDED:case _.RESOURCE_EXHAUSTED:case _.INTERNAL:case _.UNAVAILABLE:case _.UNAUTHENTICATED:return!1;case _.INVALID_ARGUMENT:case _.NOT_FOUND:case _.ALREADY_EXISTS:case _.PERMISSION_DENIED:case _.FAILED_PRECONDITION:case _.ABORTED:case _.OUT_OF_RANGE:case _.UNIMPLEMENTED:case _.DATA_LOSS:return!0}}function Bn(e){if(void 0===e)return m("GRPC error has no .code"),_.UNKNOWN;switch(e){case Fn.OK:return _.OK;case Fn.CANCELLED:return _.CANCELLED;case Fn.UNKNOWN:return _.UNKNOWN;case Fn.DEADLINE_EXCEEDED:return _.DEADLINE_EXCEEDED;case Fn.RESOURCE_EXHAUSTED:return _.RESOURCE_EXHAUSTED;case Fn.INTERNAL:return _.INTERNAL;case Fn.UNAVAILABLE:return _.UNAVAILABLE;case Fn.UNAUTHENTICATED:return _.UNAUTHENTICATED;case Fn.INVALID_ARGUMENT:return _.INVALID_ARGUMENT;case Fn.NOT_FOUND:return _.NOT_FOUND;case Fn.ALREADY_EXISTS:return _.ALREADY_EXISTS;case Fn.PERMISSION_DENIED:return _.PERMISSION_DENIED;case Fn.FAILED_PRECONDITION:return _.FAILED_PRECONDITION;case Fn.ABORTED:return _.ABORTED;case Fn.OUT_OF_RANGE:return _.OUT_OF_RANGE;case Fn.UNIMPLEMENTED:return _.UNIMPLEMENTED;case Fn.DATA_LOSS:return _.DATA_LOSS;default:return y()}}(Un=Fn||(Fn={}))[Un.OK=0]="OK",Un[Un.CANCELLED=1]="CANCELLED",Un[Un.UNKNOWN=2]="UNKNOWN",Un[Un.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Un[Un.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Un[Un.NOT_FOUND=5]="NOT_FOUND",Un[Un.ALREADY_EXISTS=6]="ALREADY_EXISTS",Un[Un.PERMISSION_DENIED=7]="PERMISSION_DENIED",Un[Un.UNAUTHENTICATED=16]="UNAUTHENTICATED",Un[Un.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Un[Un.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Un[Un.ABORTED=10]="ABORTED",Un[Un.OUT_OF_RANGE=11]="OUT_OF_RANGE",Un[Un.UNIMPLEMENTED=12]="UNIMPLEMENTED",Un[Un.INTERNAL=13]="INTERNAL",Un[Un.UNAVAILABLE=14]="UNAVAILABLE",Un[Un.DATA_LOSS=15]="DATA_LOSS";let $n=null;function zn(){return new TextEncoder}const Kn=new a.jz([4294967295,4294967295],0);function Qn(e){const t=zn().encode(e),n=new a.VV;return n.update(t),new Uint8Array(n.digest())}function Gn(e){const t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),s=t.getUint32(8,!0),i=t.getUint32(12,!0);
2return[new a.jz([n,r],0),new a.jz([s,i],0)]}class jn{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Wn(`Invalid padding: ${t}`);if(n<0)throw new Wn(`Invalid hash count: ${n}`);if(e.length>0&&0===this.hashCount)throw new Wn(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new Wn(`Invalid padding when bitmap length is 0: ${t}`);this.Te=8*e.length-t,this.Ee=a.jz.fromNumber(this.Te)}de(e,t,n){let r=e.add(t.multiply(a.jz.fromNumber(n)));return 1===r.compare(Kn)&&(r=new a.jz([r.getBits(0),r.getBits(1)],0)),r.modulo(this.Ee).toNumber()}Ae(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.Te)return!1;const t=Qn(e),[n,r]=Gn(t);for(let s=0;s<this.hashCount;s++){const e=this.de(n,r,s);if(!this.Ae(e))return!1}return!0}static create(e,t,n){const r=e%8==0?0:8-e%8,s=new Uint8Array(Math.ceil(e/8)),i=new jn(s,r,t);return n.forEach((e=>i.insert(e))),i}insert(e){if(0===this.Te)return;const t=Qn(e),[n,r]=Gn(t);for(let s=0;s<this.hashCount;s++){const e=this.de(n,r,s);this.Re(e)}}Re(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}class Wn extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Hn{constructor(e,t,n,r,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,Yn.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Hn(O.min(),r,new ge(L),Kt(),Zt())}}class Yn{constructor(e,t,n,r,s){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new Yn(n,t,Zt(),Zt(),Zt())}}class Jn{constructor(e,t,n,r){this.Ve=e,this.removedTargetIds=t,this.key=n,this.me=r}}class Xn{constructor(e,t){this.targetId=e,this.fe=t}}class Zn{constructor(e,t,n=Ie.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class er{constructor(){this.ge=0,this.pe=rr(),this.ye=Ie.EMPTY_BYTE_STRING,this.we=!1,this.Se=!0}get current(){return this.we}get resumeToken(){return this.ye}get be(){return 0!==this.ge}get De(){return this.Se}Ce(e){e.approximateByteSize()>0&&(this.Se=!0,this.ye=e)}ve(){let e=Zt(),t=Zt(),n=Zt();return this.pe.forEach(((r,s)=>{switch(s){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:y()}})),new Yn(this.ye,this.we,e,t,n)}Fe(){this.Se=!1,this.pe=rr()}Me(e,t){this.Se=!0,this.pe=this.pe.insert(e,t)}xe(e){this.Se=!0,this.pe=this.pe.remove(e)}Oe(){this.ge+=1}Ne(){this.ge-=1,w(this.ge>=0)}Le(){this.Se=!0,this.we=!0}}class tr{constructor(e){this.Be=e,this.ke=new Map,this.qe=Kt(),this.Qe=nr(),this.Ke=new ge(L)}$e(e){for(const t of e.Ve)e.me&&e.me.isFoundDocument()?this.Ue(t,e.me):this.We(t,e.key,e.me);for(const t of e.removedTargetIds)this.We(t,e.key,e.me)}Ge(e){this.forEachTarget(e,(t=>{const n=this.ze(t);switch(e.state){case 0:this.je(t)&&n.Ce(e.resumeToken);break;case 1:n.Ne(),n.be||n.Fe(),n.Ce(e.resumeToken);break;case 2:n.Ne(),n.be||this.removeTarget(t);break;case 3:this.je(t)&&(n.Le(),n.Ce(e.resumeToken));break;case 4:this.je(t)&&(this.He(t),n.Ce(e.resumeToken));break;default:y()}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ke.forEach(((e,n)=>{this.je(n)&&t(n)}))}Je(e){const t=e.targetId,n=e.fe.count,r=this.Ye(t);if(r){const s=r.target;if(Ct(s))if(0===n){const e=new B(s.path);this.We(t,e,Je.newNoDocument(e,O.min()))}else w(1===n);else{const r=this.Ze(t);if(r!==n){const n=this.Xe(e),s=n?this.et(n,e,r):1;if(0!==s){this.He(t);const e=2===s?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ke=this.Ke.insert(t,e)}null==$n||$n.tt(function(e,t,n,r,s){var i,o,a,u,c,l;const h={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},d=t.unchangedNames;return d&&(h.bloomFilter={applied:0===s,hashCount:null!==(i=null==d?void 0:d.hashCount)&&void 0!==i?i:0,bitmapLength:null!==(u=null===(a=null===(o=null==d?void 0:d.bits)||void 0===o?void 0:o.bitmap)||void 0===a?void 0:a.length)&&void 0!==u?u:0,padding:null!==(l=null===(c=null==d?void 0:d.bits)||void 0===c?void 0:c.padding)&&void 0!==l?l:0,mightContain:e=>{var t;return null!==(t=null==r?void 0:r.mightContain(e))&&void 0!==t&&t}}),h}(r,e.fe,this.Be.nt(),n,s))}}}}Xe(e){const t=e.fe.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:r=0},hashCount:s=0}=t;let i,o;try{i=Ae(n).toUint8Array()}catch(e){if(e instanceof Te)return p("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{o=new jn(i,r,s)}catch(e){return p(e instanceof Wn?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===o.Te?null:o}et(e,t,n){return t.fe.count===n-this.rt(e,t.targetId)?0:2}rt(e,t){const n=this.Be.getRemoteKeysForTarget(t);let r=0;
2return n.forEach((n=>{const s=this.Be.nt(),i=`projects/${s.projectId}/databases/${s.database}/documents/${n.path.canonicalString()}`;e.mightContain(i)||(this.We(t,n,null),r++)})),r}it(e){const t=new Map;this.ke.forEach(((n,r)=>{const s=this.Ye(r);if(s){if(n.current&&Ct(s.target)){const t=new B(s.target.path);null!==this.qe.get(t)||this.st(r,t)||this.We(r,t,Je.newNoDocument(t,e))}n.De&&(t.set(r,n.ve()),n.Fe())}}));let n=Zt();this.Qe.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{const t=this.Ye(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)})),r&&(n=n.add(e))})),this.qe.forEach(((t,n)=>n.setReadTime(e)));const r=new Hn(e,t,this.Ke,this.qe,n);return this.qe=Kt(),this.Qe=nr(),this.Ke=new ge(L),r}Ue(e,t){if(!this.je(e))return;const n=this.st(e,t.key)?2:0;this.ze(e).Me(t.key,n),this.qe=this.qe.insert(t.key,t),this.Qe=this.Qe.insert(t.key,this.ot(t.key).add(e))}We(e,t,n){if(!this.je(e))return;const r=this.ze(e);this.st(e,t)?r.Me(t,1):r.xe(t),this.Qe=this.Qe.insert(t,this.ot(t).delete(e)),n&&(this.qe=this.qe.insert(t,n))}removeTarget(e){this.ke.delete(e)}Ze(e){const t=this.ze(e).ve();return this.Be.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Oe(e){this.ze(e).Oe()}ze(e){let t=this.ke.get(e);return t||(t=new er,this.ke.set(e,t)),t}ot(e){let t=this.Qe.get(e);return t||(t=new ve(L),this.Qe=this.Qe.insert(e,t)),t}je(e){const t=null!==this.Ye(e);return t||f("WatchChangeAggregator","Detected inactive target",e),t}Ye(e){const t=this.ke.get(e);return t&&t.be?null:this.Be._t(e)}He(e){this.ke.set(e,new er),this.Be.getRemoteKeysForTarget(e).forEach((t=>{this.We(e,t,null)}))}st(e,t){return this.Be.getRemoteKeysForTarget(e).has(t)}}function nr(){return new ge(B.comparator)}function rr(){return new ge(B.comparator)}const sr={asc:"ASCENDING",desc:"DESCENDING"},ir={"<":"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"},or={and:"AND",or:"OR"};class ar{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function ur(e,t){return e.useProto3Json||ae(t)?t:{value:t}}function cr(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function lr(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function hr(e,t){return cr(e,t.toTimestamp())}function dr(e){return w(!!e),O.fromTimestamp(function(e){const t=Se(e);return new M(t.seconds,t.nanos)}(e))}function fr(e,t){return mr(e,t).canonicalString()}function mr(e,t){const n=function(e){return new F(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===t?n:n.child(t)}function pr(e){const t=F.fromString(e);return w(Mr(t)),t}function gr(e,t){return fr(e.databaseId,t.path)}function yr(e,t){const n=pr(t);if(n.get(1)!==e.databaseId.projectId)throw new E(_.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new E(_.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new B(Er(n))}function wr(e,t){return fr(e.databaseId,t)}function vr(e){const t=pr(e);return 4===t.length?F.emptyPath():Er(t)}function _r(e){return new F(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function Er(e){return w(e.length>4&&"documents"===e.get(4)),e.popFirst(5)}function Tr(e,t,n){return{name:gr(e,t),fields:n.value.mapValue.fields}}function Ir(e,t){let n;if(t instanceof An)n={update:Tr(e,t.key,t.value)};else if(t instanceof Rn)n={delete:gr(e,t.key)};else if(t instanceof Dn)n={update:Tr(e,t.key,t.data),updateMask:Vr(t.fieldMask)};else{if(!(t instanceof Ln))return y();n={verify:gr(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){const n=t.transform;if(n instanceof ln)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof hn)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof fn)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof pn)return{fieldPath:t.field.canonicalString(),increment:n.Ie};throw y()}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:hr(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:y()}(e,t.precondition)),n}function Cr(e,t){return{documents:[wr(e,t.path)]}}function Sr(e,t){const n={structuredQuery:{}},r=t.path;let s;null!==t.collectionGroup?(s=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(s=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=wr(e,s);const i=function(e){if(0!==e.length)return Lr(it.create(e,"and"))}(t.filters);i&&(n.structuredQuery.where=i);const o=function(e){if(0!==e.length)return e.map((e=>function(e){return{field:xr(e.field),direction:Dr(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);const a=ur(e,t.limit);return null!==a&&(n.structuredQuery.limit=a),t.startAt&&(n.structuredQuery.startAt=function(e){return{before:e.inclusive,values:e.position}}(t.startAt)),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),{ut:n,parent:s}}function br(e){let t=vr(e.parent);
2const n=e.structuredQuery,r=n.from?n.from.length:0;let s=null;if(r>0){w(1===r);const e=n.from[0];e.allDescendants?s=e.collectionId:t=t.child(e.collectionId)}let i=[];n.where&&(i=function(e){const t=Ar(e);return t instanceof it&&at(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new tt(Rr(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e)))}(n.orderBy));let a=null;n.limit&&(a=function(e){let t;return t="object"==typeof e?e.value:e,ae(t)?null:t}(n.limit));let u=null;n.startAt&&(u=function(e){const t=!!e.before,n=e.values||[];return new Xe(n,t)}(n.startAt));let c=null;return n.endAt&&(c=function(e){const t=!e.before,n=e.values||[];return new Xe(n,t)}(n.endAt)),bt(t,s,o,i,a,"F",u,c)}function Ar(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=Rr(e.unaryFilter.field);return st.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=Rr(e.unaryFilter.field);return st.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=Rr(e.unaryFilter.field);return st.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const s=Rr(e.unaryFilter.field);return st.create(s,"!=",{nullValue:"NULL_VALUE"});default:return y()}}(e):void 0!==e.fieldFilter?function(e){return st.create(Rr(e.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return y()}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return it.create(e.compositeFilter.filters.map((e=>Ar(e))),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return y()}}(e.compositeFilter.op))}(e):y()}function Dr(e){return sr[e]}function Nr(e){return ir[e]}function kr(e){return or[e]}function xr(e){return{fieldPath:e.canonicalString()}}function Rr(e){return q.fromServerFormat(e.fieldPath)}function Lr(e){return e instanceof st?function(e){if("=="===e.op){if(Qe(e.value))return{unaryFilter:{field:xr(e.field),op:"IS_NAN"}};if(Ke(e.value))return{unaryFilter:{field:xr(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(Qe(e.value))return{unaryFilter:{field:xr(e.field),op:"IS_NOT_NAN"}};if(Ke(e.value))return{unaryFilter:{field:xr(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:xr(e.field),op:Nr(e.op),value:e.value}}}(e):e instanceof it?function(e){const t=e.getFilters().map((e=>Lr(e)));return 1===t.length?t[0]:{compositeFilter:{op:kr(e.op),filters:t}}}(e):y()}function Vr(e){const t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function Mr(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class Or{constructor(e,t,n,r,s=O.min(),i=O.min(),o=Ie.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=i,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new Or(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Or(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Or(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Or(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class Pr{constructor(e){this.ct=e}}function Fr(e){const t=br({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?Vt(t,t.limit,"L"):t}class Ur{constructor(){}Pt(e,t){this.It(e,t),t.Tt()}It(e,t){if("nullValue"in e)this.Et(t,5);else if("booleanValue"in e)this.Et(t,10),t.dt(e.booleanValue?1:0);else if("integerValue"in e)this.Et(t,15),t.dt(be(e.integerValue));else if("doubleValue"in e){const n=be(e.doubleValue);isNaN(n)?this.Et(t,13):(this.Et(t,15),ue(n)?t.dt(0):t.dt(n))}else if("timestampValue"in e){const n=e.timestampValue;this.Et(t,20),"string"==typeof n?t.At(n):(t.At(`${n.seconds||""}`),t.dt(n.nanos||0))}else if("stringValue"in e)this.Rt(e.stringValue,t),this.Vt(t);else if("bytesValue"in e)this.Et(t,30),t.ft(Ae(e.bytesValue)),this.Vt(t);else if("referenceValue"in e)this.gt(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.Et(t,45),t.dt(n.latitude||0),t.dt(n.longitude||0)}else"mapValue"in e?We(e)?this.Et(t,Number.MAX_SAFE_INTEGER):(this.yt(e.mapValue,t),this.Vt(t)):"arrayValue"in e?(this.wt(e.arrayValue,t),this.Vt(t)):y()}Rt(e,t){this.Et(t,25),this.St(e,t)}St(e,t){t.At(e)}yt(e,t){const n=e.fields||{};this.Et(t,55);for(const r of Object.keys(n))this.Rt(r,t),this.It(n[r],t)}wt(e,t){const n=e.values||[];this.Et(t,50);for(const r of n)this.It(r,t)}gt(e,t){this.Et(t,37),B.fromName(e).path.forEach((e=>{this.Et(t,60),this.St(e,t)}))}Et(e,t){e.dt(t)}Vt(e){e.dt(2)}}Ur.bt=new Ur;class qr{constructor(){this._n=new Br}addToCollectionParentIndex(e,t){return this._n.add(t),Y.resolve()}getCollectionParents(e,t){return Y.resolve(this._n.getEntries(t))}addFieldIndex(e,t){return Y.resolve()}deleteFieldIndex(e,t){return Y.resolve()}deleteAllFieldIndexes(e){return Y.resolve()}createTargetIndexes(e,t){return Y.resolve()}getDocumentsMatchingTarget(e,t){return Y.resolve(null)}getIndexType(e,t){return Y.resolve(0)}getFieldIndexes(e,t){return Y.resolve([])}getNextCollectionGroupToUpdate(e){return Y.resolve(null)}getMinOffset(e,t){return Y.resolve(Q.min())}getMinOffsetFromCollectionGroup(e,t){return Y.resolve(Q.min())}updateCollectionGroup(e,t,n){return Y.resolve()}updateIndexEntries(e,t){return Y.resolve()}}class Br{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new ve(F.comparator),s=!r.has(n);return this.index[t]=r.add(n),s}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new ve(F.comparator)).toArray()}}new Uint8Array(0);class $r{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new $r(e,$r.DEFAULT_COLLECTION_PE
vendor: 4,183 bytes, line 2
2RCENTILE,$r.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}$r.DEFAULT_COLLECTION_PERCENTILE=10,$r.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,$r.DEFAULT=new $r(41943040,$r.DEFAULT_COLLECTION_PERCENTILE,$r.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),$r.DISABLED=new $r(-1,0,0);class zr{constructor(e){this.On=e}next(){return this.On+=2,this.On}static Nn(){return new zr(0)}static Ln(){return new zr(-1)}}class Kr{constructor(){this.changes=new $t((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Je.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?Y.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class Qr{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class Gr{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(null!==n&&Cn(n.mutation,e,Ee.empty(),M.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,Zt()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=Zt()){const r=Wt();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Gt();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){const n=Wt();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,Zt())))}populateOverlays(e,t,n){const r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let s=Kt();const i=Yt(),o=Yt();return t.forEach(((e,t)=>{const o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof Dn)?s=s.insert(t.key,t):void 0!==o?(i.set(t.key,o.mutation.getFieldMask()),Cn(o.mutation,t,o.mutation.getFieldMask(),M.now())):i.set(t.key,Ee.empty())})),this.recalculateAndSaveOverlays(e,s).next((e=>(e.forEach(((e,t)=>i.set(e,t))),t.forEach(((e,t)=>{var n;return o.set(e,new Qr(t,null!==(n=i.get(e))&&void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(e,t){const n=Yt();let r=new ge(((e,t)=>e-t)),s=Zt();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(const s of e)s.keys().forEach((e=>{const i=t.get(e);if(null===i)return;let o=n.get(e)||Ee.empty();o=s.applyToLocalView(i,o),n.set(e,o);const a=(r.get(s.batchId)||Zt()).add(e);r=r.insert(s.batchId,a)}))})).next((()=>{const i=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,u=r.value,c=Ht();u.forEach((e=>{if(!s.has(e)){const r=Tn(t.get(e),n.get(e));null!==r&&c.set(e,r),s=s.add(e)}})),i.push(this.documentOverlayCache.saveOverlays(e,a,c))}return Y.waitFor(i)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n,r){return function(e){return B.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Nt(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((s=>{const i=r-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-s.size):Y.resolve(Wt());let o=-1,a=s;return i.next((t=>Y.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),s.get(t)?Y.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{a=a.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,s))).next((()=>this.computeViews(e,a,t,Zt()))).next((e=>({batchId:o,changes:jt(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new B(t)).next((e=>{let t=Gt();
vendor: 12,623 bytes, line 2
2return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){const s=t.collectionGroup;let i=Gt();return this.indexManager.getCollectionParents(e,s).next((o=>Y.forEach(o,(o=>{const a=function(e,t){return new St(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(s));return this.getDocumentsMatchingCollectionQuery(e,a,n,r).next((e=>{e.forEach(((e,t)=>{i=i.insert(e,t)}))}))})).next((()=>i))))}getDocumentsMatchingCollectionQuery(e,t,n,r){let s;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((i=>(s=i,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,s,r)))).next((e=>{s.forEach(((t,n)=>{const r=n.getKey();null===e.get(r)&&(e=e.insert(r,Je.newInvalidDocument(r)))}));let n=Gt();return e.forEach(((e,r)=>{const i=s.get(e);void 0!==i&&Cn(i.mutation,r,Ee.empty(),M.now()),Ft(t,r)&&(n=n.insert(e,r))})),n}))}}class jr{constructor(e){this.serializer=e,this.cr=new Map,this.lr=new Map}getBundleMetadata(e,t){return Y.resolve(this.cr.get(t))}saveBundleMetadata(e,t){return this.cr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:dr(e.createTime)}}(t)),Y.resolve()}getNamedQuery(e,t){return Y.resolve(this.lr.get(t))}saveNamedQuery(e,t){return this.lr.set(t.name,function(e){return{name:e.name,query:Fr(e.bundledQuery),readTime:dr(e.readTime)}}(t)),Y.resolve()}}class Wr{constructor(){this.overlays=new ge(B.comparator),this.hr=new Map}getOverlay(e,t){return Y.resolve(this.overlays.get(t))}getOverlays(e,t){const n=Wt();return Y.forEach(t,(t=>this.getOverlay(e,t).next((e=>{null!==e&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.ht(e,t,r)})),Y.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.hr.get(n);return void 0!==r&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.hr.delete(n)),Y.resolve()}getOverlaysForCollection(e,t,n){const r=Wt(),s=t.length+1,i=new B(t.child("")),o=this.overlays.getIteratorFrom(i);for(;o.hasNext();){const e=o.getNext().value,i=e.getKey();if(!t.isPrefixOf(i.path))break;i.path.length===s&&e.largestBatchId>n&&r.set(e.getKey(),e)}return Y.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let s=new ge(((e,t)=>e-t));const i=this.overlays.getIterator();for(;i.hasNext();){const e=i.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=s.get(e.largestBatchId);null===t&&(t=Wt(),s=s.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=Wt(),a=s.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return Y.resolve(o)}ht(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.hr.get(r.largestBatchId).delete(n.key);this.hr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new On(t,n));let s=this.hr.get(t);void 0===s&&(s=Zt(),this.hr.set(t,s)),this.hr.set(t,s.add(n.key))}}class Hr{constructor(){this.Pr=new ve(Yr.Ir),this.Tr=new ve(Yr.Er)}isEmpty(){return this.Pr.isEmpty()}addReference(e,t){const n=new Yr(e,t);this.Pr=this.Pr.add(n),this.Tr=this.Tr.add(n)}dr(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.Ar(new Yr(e,t))}Rr(e,t){e.forEach((e=>this.removeReference(e,t)))}Vr(e){const t=new B(new F([])),n=new Yr(t,e),r=new Yr(t,e+1),s=[];return this.Tr.forEachInRange([n,r],(e=>{this.Ar(e),s.push(e.key)})),s}mr(){this.Pr.forEach((e=>this.Ar(e)))}Ar(e){this.Pr=this.Pr.delete(e),this.Tr=this.Tr.delete(e)}gr(e){const t=new B(new F([])),n=new Yr(t,e),r=new Yr(t,e+1);let s=Zt();return this.Tr.forEachInRange([n,r],(e=>{s=s.add(e.key)})),s}containsKey(e){const t=new Yr(e,0),n=this.Pr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class Yr{constructor(e,t){this.key=e,this.pr=t}static Ir(e,t){return B.comparator(e.key,t.key)||L(e.pr,t.pr)}static Er(e,t){return L(e.pr,t.pr)||B.comparator(e.key,t.key)}}class Jr{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.yr=1,this.wr=new ve(Yr.Ir)}checkEmpty(e){return Y.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){const s=this.yr;this.yr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const i=new Vn(s,t,n,r);this.mutationQueue.push(i);for(const o of r)this.wr=this.wr.add(new Yr(o.key,s)),this.indexManager.addToCollectionParentIndex(e,o.key.path.popLast());return Y.resolve(i)}lookupMutationBatch(e,t){return Y.resolve(this.Sr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=this.br(n),s=r<0?0:r;return Y.resolve(this.mutationQueue.length>s?this.mutationQueue[s]:null)}getHighestUnacknowledgedBatchId(){return Y.resolve(0===this.mutationQueue.length?-1:this.yr-1)}getAllMutationBatches(e){return Y.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new Yr(t,0),r=new Yr(t,Number.POSITIVE_INFINITY),s=[];return this.wr.forEachInRange([n,r],(e=>{const t=this.Sr(e.pr);s.push(t)})),Y.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new ve(L);return t.forEach((e=>{const t=new Yr(e,0),r=new Yr(e,Number.POSITIVE_INFINITY);this.wr.forEachInRange([t,r],(e=>{n=n.add(e.pr)}))})),Y.resolve(this.Dr(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let s=n;B.isDocumentKey(s)||(s=s.child(""));const i=new Yr(new B(s),0);let o=new ve(L);return this.wr.forEachWhile((e=>{const t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.pr)),!0)}),i),Y.resolve(this.Dr(o))}Dr(e){const t=[];return e.forEach((e=>{const n=this.Sr(e);null!==n&&t.push(n)})),t}removeMutationBatch(e,t){w(0===this.Cr(t.batchId,"removed")),this.mutationQueue.shift();let n=this.wr;return Y.forEach(t.mutations,(r=>{const s=new Yr(r.key,t.batchId);return n=n.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.wr=n}))}Mn(e){}containsKey(e,t){const n=new Yr(t,0),r=this.wr.firstAfterOrEqual(n);return Y.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,Y.resolve()}Cr(e,t){return this.br(e)}br(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Sr(e){const t=this.br(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class Xr{constructor(e){this.vr=e,this.docs=new ge(B.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),s=r?r.size:0,i=this.vr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:i}),this.size+=i-s,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return Y.resolve(n?n.document.mutableCopy():Je.newInvalidDocument(t))}getEntries(e,t){let n=Kt();return t.forEach((e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Je.newInvalidDocument(e))})),Y.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let s=Kt();const i=t.path,o=new B(i.child("")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:e,value:{document:o}}=a.getNext();if(!i.isPrefixOf(e.path))break;e.path.length>i.length+1||G(K(o),n)<=0||(r.has(o.key)||Ft(t,o))&&(s=s.insert(o.key,o.mutableCopy()))}return Y.resolve(s)}getAllFromCollectionGroup(e,t,n,r){y()}Fr(e,t){return Y.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new Zr(this)}getSize(e){return Y.resolve(this.size)}}class Zr extends Kr{constructor(e){super(),this.ar=e}applyChanges(e){const t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.ar.addEntry(e,r)):this.ar.removeEntry(n)})),Y.waitFor(t)}getFromCache(e,t){return this.ar.getEntry(e,t)}getAllFromCache(e,t){return this.ar.getEntries(e,t)}}class es{constructor(e){this.persistence=e,this.Mr=new $t((e=>Tt(e)),It),this.lastRemoteSnapshotVersion=O.min(),this.highestTargetId=0,this.Or=0,this.Nr=new Hr,this.targetCount=0,this.Lr=zr.Nn()}forEachTarget(e,t){return this.Mr.forEach(((e,n)=>t(n))),Y.resolve()}getLastRemoteSnapshotVersion(e){return Y.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return Y.resolve(this.Or)}allocateTargetId(e){return this.highestTargetId=this.Lr.next(),Y.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.Or&&(this.Or=t),Y.resolve()}qn(e){this.Mr.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.Lr=new zr(t),this.highestTargetId=t),e.sequenceNumber>this.Or&&(this.Or=e.sequenceNumber)}addTargetData(e,t){return this.qn(t),this.targetCount+=1,Y.resolve()}updateTargetData(e,t){return this.qn(t),Y.resolve()}removeTargetData(e,t){return this.Mr.delete(t.target),this.Nr.Vr(t.targetId),this.targetCount-=1,Y.resolve()}removeTargets(e,t,n){let r=0;const s=[];return this.Mr.forEach(((i,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.Mr.delete(i),s.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),Y.waitFor(s).next((()=>r))}getTargetCount(e){return Y.resolve(this.targetCount)}getTargetData(e,t){const n=this.Mr.get(t)||null;return Y.resolve(n)}addMatchingKeys(e,t,n){return this.Nr.dr(t,n),Y.resolve()}removeMatchingKeys(e,t,n){this.Nr.Rr(t,n);const r=this.persistence.referenceDelegate,s=[];return r&&t.forEach((t=>{s.push(r.markPotentiallyOrphaned(e,t))})),Y.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.Nr.Vr(t),Y.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Nr.gr(t);return Y.resolve(n)}containsKey(e,t){return Y.resolve(this.Nr.containsKey(t))}}class ts{constructor(e,t){this.Br={},this.overlays={},this.kr=new oe(0),this.qr=!1,this.qr=!0,this.referenceDelegate=e(this),this.Qr=new es(this),this.indexManager=new qr,this.remoteDocumentCache=function(e){return new Xr(e)}((e=>this.referenceDelegate.Kr(e))),this.serializer=new Pr(t),this.$r=new jr(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.qr=!1,Promise.resolve()}get started(){return this.qr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Wr,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Br[e.toKey()];return n||(n=new Jr(t,this.referenceDelegate),this.Br[e.toKey()]=n),n}getTargetCache(){return this.Qr}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.$r}runTransaction(e,t,n){f("MemoryPersistence","Starting transaction:",e);const r=new ns(this.kr.next());return this.referenceDelegate.Ur(),n(r).next((e=>this.referenceDelegate.Wr(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Gr(e,t){return Y.or(Object.values(this.Br).map((n=>()=>n.containsKey(e,t))))}}class ns extends W{constructor(e){super(),this.currentSequenceNumber=e}}class rs{constructor(e){this.persistence=e,this.zr=new Hr,this.jr=null}static Hr(e){return new rs(e)}get Jr(){if(this.jr)return this.jr;throw y()}addReference(e,t,n){return this.zr.addReference(n,t),this.Jr.delete(n.toString()),Y.resolve()}removeReference(e,t,n){return this.zr.removeReference(n,t),this.Jr.add(n.toString()),Y.resolve()}markPotentiallyOrphaned(e,t){return this.Jr.add(t.toString()),Y.resolve()}removeTarget(e,t){this.zr.Vr(t.targetId).forEach((e=>this.Jr.add(e.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.Jr.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}Ur(){this.jr=new Set}Wr(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Y.forEach(this.Jr,(n=>{const r=B.fromPath(n);return this.Yr(e,r).next((e=>{e||t.removeEntry(r,O.min())}))})).next((()=>(this.jr=null,t.apply(e))))}updateLimboDocument(e,t){return this.Yr(e,t).next((e=>{e?this.Jr.delete(t.toString()):this.Jr.add(t.toString())}))}Kr(e){return 0}Yr(e,t){return Y.or([()=>Y.resolve(this.zr.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Gr(e,t)])}}class ss{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.qi=n,this.Qi=r}static Ki(e,t){let n=Zt(),r=Zt();for(const s of t.docChanges)switch(s.type){case 0:n=n.add(s.doc.key);break;case 1:r=r.add(s.doc.key)}return new ss(e,t.fromCache,n,r)}}class is{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class os{constructor(){this.$i=!1,this.Ui=!1,this.Wi=100,this.Gi=(0,o.nr)()?8:X.v((0,o.ZQ)())>0?6:4}initialize(e,t){this.zi=e,this.indexManager=t,this.$i=!0}getDocumentsMatchingQuery(e,t,n,r){const s={result:null};return this.ji(e,t).next((e=>{s.result=e})).next((()=>
2{if(!s.result)return this.Hi(e,t,r,n).next((e=>{s.result=e}))})).next((()=>{if(s.result)return;const n=new is;return this.Ji(e,t,n).next((r=>{if(s.result=r,this.Ui)return this.Yi(e,t,n,r.size)}))})).next((()=>s.result))}Yi(e,t,n,r){return n.documentReadCount<this.Wi?(d()<=i.$b.DEBUG&&f("QueryEngine","SDK will not create cache indexes for query:",Pt(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Wi,"documents"),Y.resolve()):(d()<=i.$b.DEBUG&&f("QueryEngine","Query:",Pt(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.Gi*r?(d()<=i.$b.DEBUG&&f("QueryEngine","The SDK decides to create cache indexes for query:",Pt(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,xt(t))):Y.resolve())}ji(e,t){if(Dt(t))return Y.resolve(null);let n=xt(t);return this.indexManager.getIndexType(e,n).next((r=>0===r?null:(null!==t.limit&&1===r&&(t=Vt(t,null,"F"),n=xt(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{const s=Zt(...r);return this.zi.getDocuments(e,s).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{const i=this.Zi(t,r);return this.Xi(t,i,s,n.readTime)?this.ji(e,Vt(t,null,"F")):this.es(e,i,t,n)}))))})))))}Hi(e,t,n,r){return Dt(t)||r.isEqual(O.min())?Y.resolve(null):this.zi.getDocuments(e,n).next((s=>{const o=this.Zi(t,s);return this.Xi(t,o,n,r)?Y.resolve(null):(d()<=i.$b.DEBUG&&f("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Pt(t)),this.es(e,o,t,z(r,-1)).next((e=>e)))}))}Zi(e,t){let n=new ve(qt(e));return t.forEach(((t,r)=>{Ft(e,r)&&(n=n.add(r))})),n}Xi(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const s="F"===e.limitType?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(r)>0)}Ji(e,t,n){return d()<=i.$b.DEBUG&&f("QueryEngine","Using full collection scan to execute query:",Pt(t)),this.zi.getDocumentsMatchingQuery(e,t,Q.min(),n)}es(e,t,n,r){return this.zi.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}}class as{constructor(e,t,n,r){this.persistence=e,this.ts=t,this.serializer=r,this.ns=new ge(L),this.rs=new $t((e=>Tt(e)),It),this.ss=new Map,this.os=e.getRemoteDocumentCache(),this.Qr=e.getTargetCache(),this.$r=e.getBundleCache(),this._s(n)}_s(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Gr(this.os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.os.setIndexManager(this.indexManager),this.ts.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.ns)))}}function us(e,t,n,r){return new as(e,t,n,r)}async function cs(e,t){const n=v(e);return await n.persistence.runTransaction("Handle user change","readonly",(e=>{let r;
2return n.mutationQueue.getAllMutationBatches(e).next((s=>(r=s,n._s(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{const s=[],i=[];let o=Zt();for(const e of r){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({us:e,removedBatchIds:s,addedBatchIds:i})))}))}))}function ls(e){const t=v(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=>t.Qr.getLastRemoteSnapshotVersion(e)))}function hs(e,t,n){let r=Zt(),s=Zt();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Kt();return n.forEach(((n,i)=>{const o=e.get(n);i.isFoundDocument()!==o.isFoundDocument()&&(s=s.add(n)),i.isNoDocument()&&i.version.isEqual(O.min())?(t.removeEntry(n,i.readTime),r=r.insert(n,i)):!o.isValidDocument()||i.version.compareTo(o.version)>0||0===i.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(i),r=r.insert(n,i)):f("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",i.version)})),{cs:r,ls:s}}))}function ds(e,t){const n=v(e);return n.persistence.runTransaction("Get next mutation batch","readonly",(e=>(void 0===t&&(t=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function fs(e,t){const n=v(e);return n.persistence.runTransaction("Allocate target","readwrite",(e=>{let r;return n.Qr.getTargetData(e,t).next((s=>s?(r=s,Y.resolve(r)):n.Qr.allocateTargetId(e).next((s=>(r=new Or(t,s,"TargetPurposeListen",e.currentSequenceNumber),n.Qr.addTargetData(e,r).next((()=>r)))))))})).then((e=>{const r=n.ns.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.ns=n.ns.insert(e.targetId,e),n.rs.set(t,e.targetId)),e}))}async function ms(e,t,n){const r=v(e),s=r.ns.get(t),i=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",i,(e=>r.persistence.referenceDelegate.removeTarget(e,s)))}catch(e){if(!te(e))throw e;f("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.ns=r.ns.remove(t),r.rs.delete(s.target)}function ps(e,t,n){const r=v(e);let s=O.min(),i=Zt();return r.persistence.runTransaction("Execute query","readwrite",(e=>function(e,t,n){const r=v(e),s=r.rs.get(n);return void 0!==s?Y.resolve(r.ns.get(s)):r.Qr.getTargetData(t,n)}(r,e,xt(t)).next((t=>{if(t)return s=t.lastLimboFreeSnapshotVersion,r.Qr.getMatchingKeysForTargetId(e,t.targetId).next((e=>{i=e}))})).next((()=>r.ts.getDocumentsMatchingQuery(e,t,n?s:O.min(),n?i:Zt()))).next((e=>(gs(r,Ut(t),e),{documents:e,hs:i})))))}function gs(e,t,n){let r=e.ss.get(t)||O.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.ss.set(t,r)}class ys{constructor(){this.activeTargetIds=tn()}As(e){this.activeTargetIds=this.activeTargetIds.add(e)}Rs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}ds(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class ws{constructor(){this.no=new ys,this.ro={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.no.As(e),this.ro[e]||"not-current"}updateQueryState(e,t,n){this.ro[e]=t}removeLocalQueryTarget(e){this.no.Rs(e)}isLocalQueryTarget(e){return this.no.activeTargetIds.has(e)}clearQueryState(e){delete this.ro[e]}getAllActiveQueryTargets(){return this.no.activeTargetIds}isActiveQueryTarget(e){return this.no.activeTargetIds.has(e)}start(){return this.no=new ys,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class vs{io(e){}shutdown(){}}class _s{constructor(){this.so=()=>this.oo(),this._o=()=>this.ao(),this.uo=[],this.co()}io(e){this.uo.push(e)}shutdown(){window.removeEventListener("online",this.so),window.removeEventListener("offline",this._o)}co(){window.addEventListener("online",this.so),window.addEventListener("offline",this._o)}oo(){f("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.uo)e(0)}ao(){f("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.uo)e(1)}static D(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let Es=null;function Ts(){return null===Es?Es=268435456+Math.round(2147483648*Math.random()):Es++,"0x"+Es.toString(16)}const Is={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
2Query:"runAggregationQuery"};class Cs{constructor(e){this.lo=e.lo,this.ho=e.ho}Po(e){this.Io=e}To(e){this.Eo=e}onMessage(e){this.Ao=e}close(){this.ho()}send(e){this.lo(e)}Ro(){this.Io()}Vo(e){this.Eo(e)}mo(e){this.Ao(e)}}const Ss="WebChannelConnection";class bs extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.fo=t+"://"+e.host,this.po=`projects/${n}/databases/${r}`,this.yo="(default)"===this.databaseId.database?`project_id=${n}`:`project_id=${n}&database_id=${r}`}get wo(){return!1}So(e,t,n,r,s){const i=Ts(),o=this.bo(e,t.toUriEncodedString());f("RestConnection",`Sending RPC '${e}' ${i}:`,o,n);const a={"google-cloud-resource-prefix":this.po,"x-goog-request-params":this.yo};return this.Do(a,r,s),this.Co(e,o,a,n).then((t=>(f("RestConnection",`Received RPC '${e}' ${i}: `,t),t)),(t=>{throw p("RestConnection",`RPC '${e}' ${i} failed with error: `,t,"url: ",o,"request:",n),t}))}vo(e,t,n,r,s,i){return this.So(e,t,n,r,s)}Do(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+l,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}bo(e,t){const n=Is[e];return`${this.fo}/v1/${t}:${n}`}terminate(){}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Co(e,t,n,r){const s=Ts();return new Promise(((i,o)=>{const u=new a.ZS;u.setWithCredentials(!0),u.listenOnce(a.Bx.COMPLETE,(()=>{try{switch(u.getLastErrorCode()){case a.O4.NO_ERROR:const t=u.getResponseJson();f(Ss,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(t)),i(t);break;case a.O4.TIMEOUT:f(Ss,`RPC '${e}' ${s} timed out`),o(new E(_.DEADLINE_EXCEEDED,"Request time out"));break;case a.O4.HTTP_ERROR:const n=u.getStatus();if(f(Ss,`RPC '${e}' ${s} failed with status:`,n,"response text:",u.getResponseText()),n>0){let e=u.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(_).indexOf(t)>=0?t:_.UNKNOWN}(t.status);o(new E(e,t.message))}else o(new E(_.UNKNOWN,"Server responded with status "+u.getStatus()))}else o(new E(_.UNAVAILABLE,"Connection failed."));break;default:y()}}finally{f(Ss,`RPC '${e}' ${s} completed.`)}}));const c=JSON.stringify(r);f(Ss,`RPC '${e}' ${s} sending request:`,r),u.send(t,"POST",c,n,15)}))}Fo(e,t,n){const r=Ts(),s=[this.fo,"/","google.firestore.v1.Firestore","/",e,"/channel"],i=(0,a.fF)(),o=(0,a.Ao)(),u={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},c=this.longPollingOptions.timeoutSeconds;void 0!==c&&(u.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(u.useFetchStreams=!0),this.Do(u.initMessageHeaders,t,n),u.encodeInitMessageHeaders=!0;const l=s.join("");f(Ss,`Creating RPC '${e}' stream ${r}: ${l}`,u);const h=i.createWebChannel(l,u);let d=!1,m=!1;const g=new Cs({lo:t=>{m?f(Ss,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(d||(f(Ss,`Opening RPC '${e}' stream ${r} transport.`),h.open(),d=!0),f(Ss,`RPC '${e}' stream ${r} sending:`,t),h.send(t))},ho:()=>h.close()}),y=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))};return y(h,a.iO.EventType.OPEN,(()=>{m||f(Ss,`RPC '${e}' stream ${r} transport opened.`)})),y(h,a.iO.EventType.CLOSE,(()=>{m||(m=!0,f(Ss,`RPC '${e}' stream ${r} transport closed`),g.Vo())})),y(h,a.iO.EventType.ERROR,(t=>{m||(m=!0,p(Ss,`RPC '${e}' stream ${r} transport errored:`,t),g.Vo(new E(_.UNAVAILABLE,"The operation could not be completed")))})),y(h,a.iO.EventType.MESSAGE,(t=>{var n;if(!m){const s=t.data[0];w(!!s);const i=s,o=i.error||(null===(n=i[0])||void 0===n?void 0:n.error);if(o){f(Ss,`RPC '${e}' stream ${r} received error:`,o);const t=o.status;let n=function(e){const t=Fn[e];if(void 0!==t)return Bn(t)}(t),s=o.message;void 0===n&&(n=_.INTERNAL,s="Unknown error status: "+t+" with message "+o.message),m=!0,g.Vo(new E(n,s)),h.close()}else f(Ss,`RPC '${e}' stream ${r}
2 received:`,s),g.mo(s)}})),y(o,a.Jh.STAT_EVENT,(t=>{t.stat===a.ro.PROXY?f(Ss,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===a.ro.NOPROXY&&f(Ss,`RPC '${e}' stream ${r} detected no buffering proxy`)})),setTimeout((()=>{g.Ro()}),0),g}}function As(){return"undefined"!=typeof document?document:null}function Ds(e){return new ar(e,!0)}class Ns{constructor(e,t,n=1e3,r=1.5,s=6e4){this.oi=e,this.timerId=t,this.Mo=n,this.xo=r,this.Oo=s,this.No=0,this.Lo=null,this.Bo=Date.now(),this.reset()}reset(){this.No=0}ko(){this.No=this.Oo}qo(e){this.cancel();const t=Math.floor(this.No+this.Qo()),n=Math.max(0,Date.now()-this.Bo),r=Math.max(0,t-n);r>0&&f("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.No} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Lo=this.oi.enqueueAfterDelay(this.timerId,r,(()=>(this.Bo=Date.now(),e()))),this.No*=this.xo,this.No<this.Mo&&(this.No=this.Mo),this.No>this.Oo&&(this.No=this.Oo)}Ko(){null!==this.Lo&&(this.Lo.skipDelay(),this.Lo=null)}cancel(){null!==this.Lo&&(this.Lo.cancel(),this.Lo=null)}Qo(){return(Math.random()-.5)*this.No}}class ks{constructor(e,t,n,r,s,i,o,a){this.oi=e,this.$o=n,this.Uo=r,this.connection=s,this.authCredentialsProvider=i,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.Wo=0,this.Go=null,this.zo=null,this.stream=null,this.jo=new Ns(e,t)}Ho(){return 1===this.state||5===this.state||this.Jo()}Jo(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Yo()}async stop(){this.Ho()&&await this.close(0)}Zo(){this.state=0,this.jo.reset()}Xo(){this.Jo()&&null===this.Go&&(this.Go=this.oi.enqueueAfterDelay(this.$o,6e4,(()=>this.e_())))}t_(e){this.n_(),this.stream.send(e)}async e_(){if(this.Jo())return this.close(0)}
2n_(){this.Go&&(this.Go.cancel(),this.Go=null)}r_(){this.zo&&(this.zo.cancel(),this.zo=null)}async close(e,t){this.n_(),this.r_(),this.jo.cancel(),this.Wo++,4!==e?this.jo.reset():t&&t.code===_.RESOURCE_EXHAUSTED?(m(t.toString()),m("Using maximum backoff delay to prevent overloading the backend."),this.jo.ko()):t&&t.code===_.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.i_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.To(t)}i_(){}auth(){this.state=1;const e=this.s_(this.Wo),t=this.Wo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.Wo===t&&this.o_(e,n)}),(t=>{e((()=>{const e=new E(_.UNKNOWN,"Fetching auth token failed: "+t.message);return this.__(e)}))}))}o_(e,t){const n=this.s_(this.Wo);this.stream=this.a_(e,t),this.stream.Po((()=>{n((()=>(this.state=2,this.zo=this.oi.enqueueAfterDelay(this.Uo,1e4,(()=>(this.Jo()&&(this.state=3),Promise.resolve()))),this.listener.Po())))})),this.stream.To((e=>{n((()=>this.__(e)))})),this.stream.onMessage((e=>{n((()=>this.onMessage(e)))}))}Yo(){this.state=5,this.jo.qo((async()=>{this.state=0,this.start()}))}__(e){return f("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}s_(e){return t=>{this.oi.enqueueAndForget((()=>this.Wo===e?t():(f("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class xs extends ks{constructor(e,t,n,r,s,i){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,i),this.serializer=s}a_(e,t){return this.connection.Fo("Listen",e,t)}onMessage(e){this.jo.reset();const t=function(e,t){let n;if("targetChange"in t){t.targetChange;const r=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:y()}(t.targetChange.targetChangeType||"NO_CHANGE"),s=t.targetChange.targetIds||[],i=function(e,t){return e.useProto3Json?(w(void 0===t||"string"==typeof t),Ie.fromBase64String(t||"")):(w(void 0===t||t instanceof Uint8Array),Ie.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,a=o&&function(e){const t=void 0===e.code?_.UNKNOWN:Bn(e.code);return new E(t,e.message||"")}(o);n=new Zn(r,s,i,a||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const s=yr(e,r.document.name),i=dr(r.document.updateTime),o=r.document.createTime?dr(r.document.createTime):O.min(),a=new He({mapValue:{fields:r.document.fields}}),u=Je.newFoundDocument(s,i,o,a),c=r.targetIds||[],l=r.removedTargetIds||[];n=new Jn(c,l,u.key,u)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const s=yr(e,r.document),i=r.readTime?dr(r.readTime):O.min(),o=Je.newNoDocument(s,i),a=r.removedTargetIds||[];n=new Jn([],a,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const s=yr(e,r.document),i=r.removedTargetIds||[];n=new Jn([],i,s,null)}else{if(!("filter"in t))return y();{t.filter;const e=t.filter;e.targetId;const{count:r=0,unchangedNames:s}=e,i=new Pn(r,s),o=e.targetId;n=new Xn(o,i)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return O.min();const t=e.targetChange;return t.targetIds&&t.targetIds.length?O.min():t.readTime?dr(t.readTime):O.min()}(e);return this.listener.u_(t,n)}c_(e){const t={};t.database=_r(this.serializer),t.addTarget=function(e,t){let n;const r=t.target;if(n=Ct(r)?{documents:Cr(e,r)}:{query:Sr(e,r).ut},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=lr(e,t.resumeToken);const r=ur(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(O.min())>0){n.readTime=cr(e,t.snapshotVersion.toTimestamp());const r=ur(e,t.expectedCount);null!==r&&(n.expectedCount=r)}return n}(this.serializer,e);const n=function(e,t){const n=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return y()}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.t_(t)}l_(e){const t={};t.database=_r(this.serializer),t.removeTarget=e,this.t_(t)}}class Rs extends ks{constructor(e,t,n,r,s,i){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,i),this.serializer
2=s,this.h_=!1}get P_(){return this.h_}start(){this.h_=!1,this.lastStreamToken=void 0,super.start()}i_(){this.h_&&this.I_([])}a_(e,t){return this.connection.Fo("Write",e,t)}onMessage(e){if(w(!!e.streamToken),this.lastStreamToken=e.streamToken,this.h_){this.jo.reset();const t=function(e,t){return e&&e.length>0?(w(void 0!==t),e.map((e=>function(e,t){let n=e.updateTime?dr(e.updateTime):dr(t);return n.isEqual(O.min())&&(n=dr(t)),new wn(n,e.transformResults||[])}(e,t)))):[]}(e.writeResults,e.commitTime),n=dr(e.commitTime);return this.listener.T_(n,t)}return w(!e.writeResults||0===e.writeResults.length),this.h_=!0,this.listener.E_()}d_(){const e={};e.database=_r(this.serializer),this.t_(e)}I_(e){const t={streamToken:this.lastStreamToken,writes:e.map((e=>Ir(this.serializer,e)))};this.t_(t)}}class Ls extends class{}{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.A_=!1}R_(){if(this.A_)throw new E(_.FAILED_PRECONDITION,"The client has already been terminated.")}So(e,t,n,r){return this.R_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,i])=>this.connection.So(e,mr(t,n),r,s,i))).catch((e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new E(_.UNKNOWN,e.toString())}))}vo(e,t,n,r,s){return this.R_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,o])=>this.connection.vo(e,mr(t,n),r,i,o,s))).catch((e=>{throw"FirebaseError"===e.name?(e.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new E(_.UNKNOWN,e.toString())}))}terminate(){this.A_=!0,this.connection.terminate()}}class Vs{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.m_=0,this.f_=null,this.g_=!0}p_(){0===this.m_&&(this.y_("Unknown"),this.f_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.f_=null,this.w_("Backend didn't respond within 10 seconds."),this.y_("Offline"),Promise.resolve()))))}S_(e){"Online"===this.state?this.y_("Unknown"):(this.m_++,this.m_>=1&&(this.b_(),this.w_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.y_("Offline")))}set(e){this.b_(),this.m_=0,"Online"===e&&(this.g_=!1),this.y_(e)}y_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}w_(e){const t=`Could not reach Cloud Firestore backend. ${e}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.g_?(m(t),this.g_=!1):f("OnlineStateTracker",t)}
2b_(){null!==this.f_&&(this.f_.cancel(),this.f_=null)}}class Ms{constructor(e,t,n,r,s){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.D_=[],this.C_=new Map,this.v_=new Set,this.F_=[],this.M_=s,this.M_.io((e=>{n.enqueueAndForget((async()=>{Ks(this)&&(f("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=v(e);t.v_.add(4),await Ps(t),t.x_.set("Unknown"),t.v_.delete(4),await Os(t)}(this))}))})),this.x_=new Vs(n,r)}}async function Os(e){if(Ks(e))for(const t of e.F_)await t(!0)}async function Ps(e){for(const t of e.F_)await t(!1)}function Fs(e,t){const n=v(e);n.C_.has(t.targetId)||(n.C_.set(t.targetId,t),zs(n)?$s(n):ui(n).Jo()&&qs(n,t))}function Us(e,t){const n=v(e),r=ui(n);n.C_.delete(t),r.Jo()&&Bs(n,t),0===n.C_.size&&(r.Jo()?r.Xo():Ks(n)&&n.x_.set("Unknown"))}function qs(e,t){if(e.O_.Oe(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(O.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}ui(e).c_(t)}function Bs(e,t){e.O_.Oe(t),ui(e).l_(t)}function $s(e){e.O_=new tr({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),_t:t=>e.C_.get(t)||null,nt:()=>e.datastore.serializer.databaseId}),ui(e).start(),e.x_.p_()}function zs(e){return Ks(e)&&!ui(e).Ho()&&e.C_.size>0}function Ks(e){return 0===v(e).v_.size}function Qs(e){e.O_=void 0}async function Gs(e){e.C_.forEach(((t,n)=>{qs(e,t)}))}async function js(e,t){Qs(e),zs(e)?(e.x_.S_(t),$s(e)):e.x_.set("Unknown")}async function Ws(e,t,n){if(e.x_.set("Online"),t instanceof Zn&&2===t.state&&t.cause)try{await async function(e,t){const n=t.cause;for(const r of t.targetIds)e.C_.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.C_.delete(r),e.O_.removeTarget(r))}(e,t)}catch(n){f("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await Hs(e,n)}else if(t instanceof Jn?e.O_.$e(t):t instanceof Xn?e.O_.Je(t):e.O_.Ge(t),!n.isEqual(O.min()))try{const t=await ls(e.localStore);n.compareTo(t)>=0&&await function(e,t){const n=e.O_.it(t);
vendor: 6,012 bytes, line 2
2return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const s=e.C_.get(r);s&&e.C_.set(r,s.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{const r=e.C_.get(t);if(!r)return;e.C_.set(t,r.withResumeToken(Ie.EMPTY_BYTE_STRING,r.snapshotVersion)),Bs(e,t);const s=new Or(r.target,t,n,r.sequenceNumber);qs(e,s)})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){f("RemoteStore","Failed to raise snapshot:",t),await Hs(e,t)}}async function Hs(e,t,n){if(!te(t))throw t;e.v_.add(1),await Ps(e),e.x_.set("Offline"),n||(n=()=>ls(e.localStore)),e.asyncQueue.enqueueRetryable((async()=>{f("RemoteStore","Retrying IndexedDB access"),await n(),e.v_.delete(1),await Os(e)}))}function Ys(e,t){return t().catch((n=>Hs(e,n,t)))}async function Js(e){const t=v(e),n=ci(t);let r=t.D_.length>0?t.D_[t.D_.length-1].batchId:-1;for(;Xs(t);)try{const e=await ds(t.localStore,r);if(null===e){0===t.D_.length&&n.Xo();break}r=e.batchId,Zs(t,e)}catch(e){await Hs(t,e)}ei(t)&&ti(t)}function Xs(e){return Ks(e)&&e.D_.length<10}function Zs(e,t){e.D_.push(t);const n=ci(e);n.Jo()&&n.P_&&n.I_(t.mutations)}function ei(e){return Ks(e)&&!ci(e).Ho()&&e.D_.length>0}function ti(e){ci(e).start()}async function ni(e){ci(e).d_()}async function ri(e){const t=ci(e);for(const n of e.D_)t.I_(n.mutations)}async function si(e,t,n){const r=e.D_.shift(),s=Mn.from(r,t,n);await Ys(e,(()=>e.remoteSyncer.applySuccessfulWrite(s))),await Js(e)}async function ii(e,t){t&&ci(e).P_&&await async function(e,t){if(function(e){return qn(e)&&e!==_.ABORTED}(t.code)){const n=e.D_.shift();ci(e).Zo(),await Ys(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await Js(e)}}(e,t),ei(e)&&ti(e)}async function oi(e,t){const n=v(e);n.asyncQueue.verifyOperationInProgress(),f("RemoteStore","RemoteStore received new credentials");const r=Ks(n);n.v_.add(3),await Ps(n),r&&n.x_.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.v_.delete(3),await Os(n)}async function ai(e,t){const n=v(e);t?(n.v_.delete(2),await Os(n)):t||(n.v_.add(2),await Ps(n),n.x_.set("Unknown"))}function ui(e){return e.N_||(e.N_=function(e,t,n){const r=v(e);return r.R_(),new xs(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Po:Gs.bind(null,e),To:js.bind(null,e),u_:Ws.bind(null,e)}),e.F_.push((async t=>{t?(e.N_.Zo(),zs(e)?$s(e):e.x_.set("Unknown")):(await e.N_.stop(),Qs(e))}))),e.N_}function ci(e){return e.L_||(e.L_=function(e,t,n){const r=v(e);return r.R_(),new Rs(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Po:ni.bind(null,e),To:ii.bind(null,e),E_:ri.bind(null,e),T_:si.bind(null,e)}),e.F_.push((async t=>{t?(e.L_.Zo(),await Js(e)):(await e.L_.stop(),e.D_.length>0&&(f("RemoteStore",`Stopping write stream with ${e.D_.length} pending writes`),e.D_=[]))}))),e.L_}class li{constructor(e,t,n,r,s){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=s,this.deferred=new T,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,r,s){const i=Date.now()+n,o=new li(e,t,i,r,s);return o.start(n),o}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new E(_.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function hi(e,t){if(m("AsyncQueue",`${t}: ${e}`),te(e))return new E(_.UNAVAILABLE,`${t}: ${e}`);throw e}class di{constructor(e){this.comparator=e?(t,n)=>e(t,n)||B.comparator(t.key,n.key):(e,t)=>B.comparator(e.key,t.key),this.keyedMap=Gt(),this.sortedSet=new ge(this.comparator)}static emptySet(e){return new di(e.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,n)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof di))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}copy(e,t){const n=new di;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class fi{constructor(){this.B_=new ge(B.comparator)}track(e){const t=e.doc.key,n=this.B_.get(t);n?0!==e.type&&3===n.type?this.B_=this.B_.insert(t,e):3===e.type&&1!==n.type?this.B_=this.B_.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.B_=this.B_.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.B_=this.B_.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.B_=this.B_.remove(t):1===e.type&&2===n.type?this.B_=this.B_.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.B_=this.B_.insert(t,{type:2,doc:e.doc}):y():this.B_=this.B_.insert(t,e)}k_(){const e=[];return this.B_.inorderTraversal(((t,n)=>{e.push(n)})),e}}class mi{constructor(e,t,n,r,s,i,o,a,u){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=s,this.fromCache=i,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=u}
2static fromInitialDocuments(e,t,n,r,s){const i=[];return t.forEach((e=>{i.push({type:0,doc:e})})),new mi(e,t,di.emptySet(t),i,n,r,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Mt(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r].type!==n[r].type||!t[r].doc.isEqual(n[r].doc))return!1;return!0}}class pi{constructor(){this.q_=void 0,this.Q_=[]}K_(){return this.Q_.some((e=>e.U_()))}}class gi{constructor(){this.queries=new $t((e=>Ot(e)),Mt),this.onlineState="Unknown",this.W_=new Set}}async function yi(e,t){const n=v(e);let r=3;const s=t.query;let i=n.queries.get(s);i?!i.K_()&&t.U_()&&(r=2):(i=new pi,r=t.U_()?0:1);try{switch(r){case 0:i.q_=await n.onListen(s,!0);break;case 1:i.q_=await n.onListen(s,!1);break;case 2:await n.onFirstRemoteStoreListen(s)}}catch(e){const n=hi(e,`Initialization of query '${Pt(t.query)}' failed`);return void t.onError(n)}n.queries.set(s,i),i.Q_.push(t),t.G_(n.onlineState),i.q_&&t.z_(i.q_)&&Ei(n)}async function wi(e,t){const n=v(e),r=t.query;let s=3;const i=n.queries.get(r);if(i){const e=i.Q_.indexOf(t);e>=0&&(i.Q_.splice(e,1),0===i.Q_.length?s=t.U_()?0:1:!i.K_()&&t.U_()&&(s=2))}switch(s){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function vi(e,t){const n=v(e);let r=!1;for(const s of t){const e=s.query,t=n.queries.get(e);if(t){for(const e of t.Q_)e.z_(s)&&(r=!0);t.q_=s}}r&&Ei(n)}function _i(e,t,n){const r=v(e),s=r.queries.get(t);if(s)for(const i of s.Q_)i.onError(n);r.queries.delete(t)}function Ei(e){e.W_.forEach((e=>{e.next()}))}var Ti,Ii;(Ii=Ti||(Ti={})).j_="default",Ii.Cache="cache";class Ci{constructor(e,t,n){this.query=e,this.H_=t,this.J_=!1,this.Y_=null,this.onlineState="Unknown",this.options=n||{}}z_(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new mi(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.J_?this.Z_(e)&&(this.H_.next(e),t=!0):this.X_(e,this.onlineState)&&(this.ea(e),t=!0),this.Y_=e,t}onError(e){this.H_.error(e)}G_(e){this.onlineState=e;let t=!1;return this.Y_&&!this.J_&&this.X_(this.Y_,e)&&(this.ea(this.Y_),t=!0),t}X_(e,t){if(!e.fromCache)return!0;if(!this.U_())return!0;const n="Offline"!==t;return(!this.options.ta||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Z_(e){if(e.docChanges.length>0)return!0;const t=this.Y_&&this.Y_.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ea(e){e=mi.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.J_=!0,this.H_.next(e)}U_(){return this.options.source!==Ti.Cache}}class Si{constructor(e){this.key=e}}class bi{constructor(e){this.key=e}}class Ai{constructor(e,t){this.query=e,this.ua=t,this.ca=null,this.hasCachedResults=!1,this.current=!1,this.la=Zt(),this.mutatedKeys=Zt(),this.ha=qt(e),this.Pa=new di(this.ha)}get Ia(){return this.ua}Ta(e,t){const n=t?t.Ea:new fi,r=t?t.Pa:this.Pa;let s=t?t.mutatedKeys:this.mutatedKeys,i=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,u="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{const c=r.get(e),l=Ft(this.query,t)?t:null,h=!!c&&this.mutatedKeys.has(c.key),d=!!l&&(l.hasLocalMutations||this.mutatedKeys.has(l.key)&&l.hasCommittedMutations);let f=!1;c&&l?c.data.isEqual(l.data)?h!==d&&(n.track({type:3,doc:l}),f=!0):this.da(c,l)||(n.track({type:2,doc:l}),f=!0,(a&&this.ha(l,a)>0||u&&this.ha(l,u)<0)&&(o=!0)):!c&&l?(n.track({type:0,doc:l}),f=!0):c&&!l&&(n.track({type:1,doc:c}),f=!0,(a||u)&&(o=!0)),f&&(l?(i=i.add(l),s=d?s.add(e):s.delete(e)):(i=i.delete(e),s=s.delete(e)))})),null!==this.query.limit)for(;i.size>this.query.limit;
vendor: 3,576 bytes, line 2
2){const e="F"===this.query.limitType?i.last():i.first();i=i.delete(e.key),s=s.delete(e.key),n.track({type:1,doc:e})}return{Pa:i,Ea:n,Xi:o,mutatedKeys:s}}da(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){const s=this.Pa;this.Pa=e.Pa,this.mutatedKeys=e.mutatedKeys;const i=e.Ea.k_();i.sort(((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return y()}};return n(e)-n(t)}(e.type,t.type)||this.ha(e.doc,t.doc))),this.Aa(n),r=null!=r&&r;const o=t&&!r?this.Ra():[],a=0===this.la.size&&this.current&&!r?1:0,u=a!==this.ca;return this.ca=a,0!==i.length||u?{snapshot:new mi(this.query,e.Pa,s,i,e.mutatedKeys,0===a,u,!1,!!n&&n.resumeToken.approximateByteSize()>0),Va:o}:{Va:o}}G_(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({Pa:this.Pa,Ea:new fi,mutatedKeys:this.mutatedKeys,Xi:!1},!1)):{Va:[]}}ma(e){return!this.ua.has(e)&&!!this.Pa.has(e)&&!this.Pa.get(e).hasLocalMutations}Aa(e){e&&(e.addedDocuments.forEach((e=>this.ua=this.ua.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.ua=this.ua.delete(e))),this.current=e.current)}Ra(){if(!this.current)return[];const e=this.la;this.la=Zt(),this.Pa.forEach((e=>{this.ma(e.key)&&(this.la=this.la.add(e.key))}));const t=[];return e.forEach((e=>{this.la.has(e)||t.push(new bi(e))})),this.la.forEach((n=>{e.has(n)||t.push(new Si(n))})),t}fa(e){this.ua=e.hs,this.la=Zt();const t=this.Ta(e.documents);return this.applyChanges(t,!0)}ga(){return mi.fromInitialDocuments(this.query,this.Pa,this.mutatedKeys,0===this.ca,this.hasCachedResults)}}class Di{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Ni{constructor(e){this.key=e,this.pa=!1}}class ki{constructor(e,t,n,r,s,i){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=s,this.maxConcurrentLimboResolutions=i,this.ya={},this.wa=new $t((e=>Ot(e)),Mt),this.Sa=new Map,this.ba=new Set,this.Da=new ge(B.comparator),this.Ca=new Map,this.va=new Hr,this.Fa={},this.Ma=new Map,this.xa=zr.Ln(),this.onlineState="Unknown",this.Oa=void 0}get isPrimaryClient(){return!0===this.Oa}}async function xi(e,t,n=!0){const r=Xi(e);let s;const i=r.wa.get(t);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.ga()):s=await Li(r,t,n,!0),s}async function Ri(e,t){const n=Xi(e);await Li(n,t,!0,!1)}async function Li(e,t,n,r){const s=await fs(e.localStore,xt(t)),i=s.targetId,o=n?e.sharedClientState.addLocalQueryTarget(i):"not-current";let a;return r&&(a=await Vi(e,t,i,"current"===o,s.resumeToken)),e.isPrimaryClient&&n&&Fs(e.remoteStore,s),a}async function Vi(e,t,n,r,s){e.Na=(t,n,r)=>async function(e,t,n,r){let s=t.view.Ta(n);s.Xi&&(s=await ps(e.localStore,t.query,!1).then((({documents:e})=>t.view.Ta(e,s))));const i=r&&r.targetChanges.get(t.targetId),o=r&&null!=r.targetMismatches.get(t.targetId),a=t.view.applyChanges(s,e.isPrimaryClient,i,o);return Gi(e,t.targetId,a.Va),a.snapshot}(e,t,n,r);const i=await ps(e.localStore,t,!0),o=new Ai(t,i.hs),a=o.Ta(i.documents),u=Yn.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,s),c=o.applyChanges(a,e.isPrimaryClient,u);Gi(e,n,c.Va);const l=new Di(t,n,o);return e.wa.set(t,l),e.Sa.has(n)?e.Sa.get(n).push(t):e.Sa.set(n,[t]),c.snapshot}async function Mi(e,t,n){const r=v(e),s=r.wa.get(t),i=r.Sa.get(s.targetId);if(i.length>1)return r.Sa.set(s.targetId,i.filter((e=>!Mt(e,t)))),void r.wa.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedCl
2ientState.isActiveQueryTarget(s.targetId)||await ms(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),n&&Us(r.remoteStore,s.targetId),Ki(r,s.targetId)})).catch(H)):(Ki(r,s.targetId),await ms(r.localStore,s.targetId,!0))}async function Oi(e,t){const n=v(e),r=n.wa.get(t),s=n.Sa.get(r.targetId);n.isPrimaryClient&&1===s.length&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),Us(n.remoteStore,r.targetId))}async function Pi(e,t){const n=v(e);try{const e=await function(e,t){const n=v(e),r=t.snapshotVersion;let s=n.ns;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(e=>{const i=n.os.newChangeBuffer({trackRemovals:!0});s=n.ns;const o=[];t.targetChanges.forEach(((i,a)=>{const u=s.get(a);if(!u)return;o.push(n.Qr.removeMatchingKeys(e,i.removedDocuments,a).next((()=>n.Qr.addMatchingKeys(e,i.addedDocuments,a))));let c=u.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?c=c.withResumeToken(Ie.EMPTY_BYTE_STRING,O.min()).withLastLimboFreeSnapshotVersion(O.min()):i.resumeToken.approximateByteSize()>0&&(c=c.withResumeToken(i.resumeToken,r)),s=s.insert(a,c),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(u,c,i)&&o.push(n.Qr.updateTargetData(e,c))}));let a=Kt(),u=Zt();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(hs(e,i,t.documentUpdates).next((e=>{a=e.cs,u=e.ls}))),!r.isEqual(O.min())){const t=n.Qr.getLastRemoteSnapshotVersion(e).next((t=>n.Qr.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return Y.waitFor(o).next((()=>i.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,a,u))).next((()=>a))})).then((e=>(n.ns=s,e)))}(n.localStore,t);
2t.targetChanges.forEach(((e,t)=>{const r=n.Ca.get(t);r&&(w(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1),e.addedDocuments.size>0?r.pa=!0:e.modifiedDocuments.size>0?w(r.pa):e.removedDocuments.size>0&&(w(r.pa),r.pa=!1))})),await Hi(n,e,t)}catch(e){await H(e)}}function Fi(e,t,n){const r=v(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.wa.forEach(((n,r)=>{const s=r.view.G_(t);s.snapshot&&e.push(s.snapshot)})),function(e,t){const n=v(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(const s of n.Q_)s.G_(t)&&(r=!0)})),r&&Ei(n)}(r.eventManager,t),e.length&&r.ya.u_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function Ui(e,t,n){const r=v(e);r.sharedClientState.updateQueryState(t,"rejected",n);const s=r.Ca.get(t),i=s&&s.key;if(i){let e=new ge(B.comparator);e=e.insert(i,Je.newNoDocument(i,O.min()));const n=Zt().add(i),s=new Hn(O.min(),new Map,new ge(L),e,n);await Pi(r,s),r.Da=r.Da.remove(i),r.Ca.delete(t),Wi(r)}else await ms(r.localStore,t,!1).then((()=>Ki(r,t,n))).catch(H)}async function qi(e,t){const n=v(e),r=t.batch.batchId;try{const e=await function(e,t){const n=v(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(e=>{const r=t.batch.keys(),s=n.os.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){const s=n.batch,i=s.keys();let o=Y.resolve();return i.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{const i=n.docVersions.get(e);w(null!==i),t.version.compareTo(i)<0&&(s.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=>e.mutationQueue.removeMutationBatch(t,s)))}(n,e,t,s).next((()=>s.apply(e))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=Zt();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t)))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(n.localStore,t);zi(n,r,null),$i(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Hi(n,e)}catch(e){await H(e)}}async function Bi(e,t,n){const r=v(e);try{const e=await function(e,t){const n=v(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",(e=>{let r;
vendor: 1,905 bytes, line 2
2return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(w(null!==t),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(r.localStore,t);zi(r,t,n),$i(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await Hi(r,e)}catch(n){await H(n)}}function $i(e,t){(e.Ma.get(t)||[]).forEach((e=>{e.resolve()})),e.Ma.delete(t)}function zi(e,t,n){const r=v(e);let s=r.Fa[r.currentUser.toKey()];if(s){const e=s.get(t);e&&(n?e.reject(n):e.resolve(),s=s.remove(t)),r.Fa[r.currentUser.toKey()]=s}}function Ki(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Sa.get(t))e.wa.delete(r),n&&e.ya.La(r,n);e.Sa.delete(t),e.isPrimaryClient&&e.va.Vr(t).forEach((t=>{e.va.containsKey(t)||Qi(e,t)}))}function Qi(e,t){e.ba.delete(t.path.canonicalString());const n=e.Da.get(t);null!==n&&(Us(e.remoteStore,n),e.Da=e.Da.remove(t),e.Ca.delete(n),Wi(e))}function Gi(e,t,n){for(const r of n)r instanceof Si?(e.va.addReference(r.key,t),ji(e,r)):r instanceof bi?(f("SyncEngine","Document no longer in limbo: "+r.key),e.va.removeReference(r.key,t),e.va.containsKey(r.key)||Qi(e,r.key)):y()}function ji(e,t){const n=t.key,r=n.path.canonicalString();e.Da.get(n)||e.ba.has(r)||(f("SyncEngine","New document in limbo: "+n),e.ba.add(r),Wi(e))}function Wi(e){for(;e.ba.size>0&&e.Da.size<e.maxConcurrentLimboResolutions;){const t=e.ba.values().next().value;e.ba.delete(t);const n=new B(F.fromString(t)),r=e.xa.next();e.Ca.set(r,new Ni(n)),e.Da=e.Da.insert(n,r),Fs(e.remoteStore,new Or(xt(At(n.path)),r,"TargetPurposeLimboResolution",oe._e))}}async function Hi(e,t,n){const r=v(e),s=[],i=[],o=[];r.wa.isEmpty()||(r.wa.forEach(((e,a)=>{o.push(r.Na(a,t,n).then((e=>
2{if((e||n)&&r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,(null==e?void 0:e.fromCache)?"not-current":"current"),e){s.push(e);const t=ss.Ki(a.targetId,e);i.push(t)}})))})),await Promise.all(o),r.ya.u_(s),await async function(e,t){const n=v(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(e=>Y.forEach(t,(t=>Y.forEach(t.qi,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>Y.forEach(t.Qi,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!te(e))throw e;f("LocalStore","Failed to update sequence numbers: "+e)}for(const r of t){const e=r.targetId;if(!r.fromCache){const t=n.ns.get(e),r=t.snapshotVersion,s=t.withLastLimboFreeSnapshotVersion(r);n.ns=n.ns.insert(e,s)}}}(r.localStore,i))}async function Yi(e,t){const n=v(e);if(!n.currentUser.isEqual(t)){f("SyncEngine","User change. New user:",t.toKey());const e=await cs(n.localStore,t);n.currentUser=t,function(e,t){e.Ma.forEach((e=>{e.forEach((e=>{e.reject(new E(_.CANCELLED,t))}))})),e.Ma.clear()}(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Hi(n,e.us)}}function Ji(e,t){const n=v(e),r=n.Ca.get(t);if(r&&r.pa)return Zt().add(r.key);{let e=Zt();const r=n.Sa.get(t);if(!r)return e;for(const t of r){const r=n.wa.get(t);e=e.unionWith(r.view.Ia)}return e}}function Xi(e){const t=v(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Pi.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Ji.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Ui.bind(null,t),t.ya.u_=vi.bind(null,t.eventManager),t.ya.La=_i.bind(null,t.eventManager),t}function Zi(e){const t=v(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=qi.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Bi.bind(null,t),t}class eo{constructor(){this.synchronizeTabs=!1}async initialize(e){this.serializer=Ds(e.databaseInfo.databaseId),this.sharedClientState=this.createSharedClientState(e),this.persistence=this.createPersistence(e),await this.persistence.start(),this.localStore=this.createLocalStore(e),this.gcScheduler=this.createGarbageCollectionScheduler(e,this.localStore),this.indexBackfillerScheduler=this.createIndexBackfillerScheduler(e,this.localStore)}createGarbageCollectionScheduler(e,t){return null}createIndexBackfillerScheduler(e,t){return null}createLocalStore(e){return us(this.persistence,new os,e.initialUser,this.serializer)}createPersistence(e){return new ts(rs.Hr,this.serializer)}createSharedClientState(e){return new ws}async terminate(){var e,t;null===(e=this.gcScheduler)||void 0===e||e.stop(),null===(t=this.indexBackfillerScheduler)||void 0===t||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class to{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>Fi(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Yi.bind(null,this.syncEngine),await ai(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new gi}createDatastore(e){const t=Ds(e.databaseInfo.databaseId),n=function(e){return new bs(e)}(e.databaseInfo);return function(e,t,n,r){return new Ls(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,s){return new Ms(e,t,n,r,s)}(this.localStore,this.datastore,e.asyncQueue,(e=>Fi(this.syncEngine,e,0)),_s.D()?new _s:new vs)}createSyncEngine(e,t){return function(e,t,n,r,s,i,o){const a=new ki(e,t,n,r,s,i);return o&&(a.Oa=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e;await async function(e){const t=v(e);f("RemoteStore","RemoteStore shutting down."),t.v_.add(5),await Ps(t),t.M_.shutdown(),t.x_.set("Unknown")}(this.remoteStore),null===(e=this.datastore)||void 0===e||e.terminate()}}class no{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.qa(this.observer.next,e)}error(e){this.observer.error?this.qa(this.observer.error,e):m("Uncaught Error in snapshot listener:",e.toString())}Qa(){this.muted=!0}
2qa(e,t){this.muted||setTimeout((()=>{this.muted||e(t)}),0)}}class ro{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=c.UNAUTHENTICATED,this.clientId=R.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,(async e=>{f("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(f("FirestoreClient","Received new app check token=",e),this.appCheckCredentialListener(e,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new E(_.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new T;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=hi(t,"Failed to shutdown persistence");e.reject(n)}})),e.promise}}async function so(e,t){e.asyncQueue.verifyOperationInProgress(),f("FirestoreClient","Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await cs(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function io(e,t){e.asyncQueue.verifyOperationInProgress();const n=await ao(e);f("FirestoreClient","Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>oi(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>oi(t.remoteStore,n))),e._onlineComponents=t}function oo(e){return"FirebaseError"===e.name?e.code===_.FAILED_PRECONDITION||e.code===_.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code}async function ao(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){f("FirestoreClient","Using user provided OfflineComponentProvider");try{await so(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!oo(n))throw n;p("Error using user provided cache. Falling back to memory cache: "+n),await so(e,new eo)}}else f("FirestoreClient","Using default OfflineComponentProvider"),await so(e,new eo);return e._offlineComponents}async function uo(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(f("FirestoreClient","Using user provided OnlineComponentProvider"),await io(e,e._uninitializedComponentsProvider._online)):(f("FirestoreClient","Using default OnlineComponentProvider"),await io(e,new to))),e._onlineComponents}function co(e){return uo(e).then((e=>e.syncEngine))}async function lo(e){const t=await uo(e),n=t.eventManager;return n.onListen=xi.bind(null,t.syncEngine),n.onUnlisten=Mi.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=Ri.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Oi.bind(null,t.syncEngine),n}function ho(e,t,n={}){const r=new T;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,s){const i=new no({next:i=>{t.enqueueAndForget((()=>wi(e,o)));const a=i.docs.has(n);!a&&i.fromCache?s.reject(new E(_.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&i.fromCache&&r&&"server"===r.source?s.reject(new E(_.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):s.resolve(i)},error:e=>s.reject(e)}),o=new Ci(At(n.path),i,{includeMetadataChanges:!0,ta:!0});return yi(e,o)}(await lo(e),e.asyncQueue,t,n,r))),r.promise}function fo(e,t,n={}){const r=new T;return e.asyncQueue.enqueueAndForget((async()=>
2function(e,t,n,r,s){const i=new no({next:n=>{t.enqueueAndForget((()=>wi(e,o))),n.fromCache&&"server"===r.source?s.reject(new E(_.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):s.resolve(n)},error:e=>s.reject(e)}),o=new Ci(n,i,{includeMetadataChanges:!0,ta:!0});return yi(e,o)}(await lo(e),e.asyncQueue,t,n,r))),r.promise}function mo(e){const t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}const po=new Map;function go(e,t,n){if(!n)throw new E(_.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function yo(e){if(!B.isDocumentKey(e))throw new E(_.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function wo(e){if(B.isDocumentKey(e))throw new E(_.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function vo(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:"an object"}}return"function"==typeof e?"a function":y()}function _o(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new E(_.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=vo(e);throw new E(_.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}class Eo{constructor(e){var t,n;if(void 0===e.host){if(void 0!==e.ssl)throw new E(_.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new E(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,n,r){if(!0===t&&!0===r)throw new E(_.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)})("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=mo(null!==(n=e.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new E(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new E(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new E(_.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class To{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Eo({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new E(_.FAILED_PRECONDITION,"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(e){if(this._settingsFrozen)throw new E(_.FAILED_PRECONDITION,"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 Eo(e),void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new C;switch(e.type){case"firstParty":return new D(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;
2default:throw new E(_.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.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(e){const t=po.get(e);t&&(f("ComponentProvider","Removing Datastore"),po.delete(e),t.terminate())}(this),Promise.resolve()}}class Io{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new Io(this.firestore,e,this._query)}}class Co{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new So(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Co(this.firestore,e,this._key)}}class So extends Io{constructor(e,t,n){super(e,t,At(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Co(this.firestore,null,new B(e))}withConverter(e){return new So(this.firestore,e,this._path)}}function bo(e,t,...n){if(e=(0,o.Ku)(e),go("collection","path",t),e instanceof To){const r=F.fromString(t,...n);return wo(r),new So(e,null,r)}{if(!(e instanceof Co||e instanceof So))throw new E(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(F.fromString(t,...n));return wo(r),new So(e.firestore,null,r)}}function Ao(e,t,...n){if(e=(0,o.Ku)(e),1===arguments.length&&(t=R.newId()),go("doc","path",t),e instanceof To){const r=F.fromString(t,...n);return yo(r),new Co(e,null,new B(r))}{if(!(e instanceof Co||e instanceof So))throw new E(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(F.fromString(t,...n));return yo(r),new Co(e.firestore,e instanceof So?e.converter:null,new B(r))}}class Do{constructor(){this.nu=Promise.resolve(),this.ru=[],this.iu=!1,this.su=[],this.ou=null,this._u=!1,this.au=!1,this.uu=[],this.jo=new Ns(this,"async_queue_retry"),this.cu=()=>{const e=As();e&&f("AsyncQueue","Visibility state changed to "+e.visibilityState),this.jo.Ko()};const e=As();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.cu)}get isShuttingDown(){return this.iu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.lu(),this.hu(e)}enterRestrictedMode(e){if(!this.iu){this.iu=!0,this.au=e||!1;const t=As();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.cu)}}enqueue(e){if(this.lu(),this.iu)return new Promise((()=>{}));const t=new T;return this.hu((()=>this.iu&&this.au?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.ru.push(e),this.Pu())))}async Pu(){if(0!==this.ru.length){try{await this.ru[0](),this.ru.shift(),this.jo.reset()}catch(e){if(!te(e))throw e;f("AsyncQueue","Operation failed with retryable error: "+e)}this.ru.length>0&&this.jo.qo((()=>this.Pu()))}}hu(e){const t=this.nu.then((()=>(this._u=!0,e().catch((e=>{this.ou=e,this._u=!1;const t=function(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e);throw m("INTERNAL UNHANDLED ERROR: ",t),e})).then((e=>(this._u=!1,e))))));return this.nu=t,t}enqueueAfterDelay(e,t,n){this.lu(),this.uu.indexOf(e)>-1&&(t=0);const r=li.createAndSchedule(this,e,t,n,(e=>this.Iu(e)));return this.su.push(r),r}lu(){this.ou&&y()}verifyOperationInProgress(){}async Tu(){let e;do{e=this.nu,await e}while(e!==this.nu)}Eu(e){for(const t of this.su)if(t.timerId===e)return!0;return!1}du(e){return this.Tu().then((()=>{this.su.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(const t of this.su)if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Tu()}))}Au(e){this.uu.push(e)}Iu(e){const t=this.su.indexOf(e);this.su.splice(t,1)}}function No(e){return function(e,t){if("object"!=typeof e||null===e)return!1;const n=e;for(const r of t)if(r in n&&"function"==typeof n[r])return!0;return!1}(e,["next","error","complete"])}class ko extends To{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new Do,this._persistenceKey=(null==r?void 0:r.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||Lo(this),this._firestoreClient.terminate()}}function xo(e,t){const n="object"==typeof e?e:(0,r.Sx)(),s="string"==typeof e?e:t||"(default)",i=(0,r.j6)(n,"firestore").getImmediate({identifier:s});if(!i._initialized){const e=(0,o.yU)("firestore");e&&function(e,t,n,r={}){var s;const i=(e=_o(e,To))._getSettings(),a=`${t}:${n}`;if("firestore.googleapis.com"!==i.host&&i.host!==a&&p("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),e._setSettings(Object.assign(Object.assign({},i),{host:a,ssl:!1})),r.mockUserToken){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=c.MOCK_USER;else{t=(0,o.Fy)(r.mockUserToken,null===(s=e._app)||void 0===s?void 0:s.options.projectId);const i=r.mockUserToken.sub||r.mockUserToken.user_id;
2if(!i)throw new E(_.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new c(i)}e._authCredentials=new S(new I(t,n))}}(i,...e)}return i}function Ro(e){return e._firestoreClient||Lo(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function Lo(e){var t,n,r;const s=e._freezeSettings(),i=function(e,t,n,r){return new xe(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,mo(r.experimentalLongPollingOptions),r.useFetchStreams)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,s);e._firestoreClient=new ro(e._authCredentials,e._appCheckCredentials,e._queue,i),(null===(n=s.localCache)||void 0===n?void 0:n._offlineComponentProvider)&&(null===(r=s.localCache)||void 0===r?void 0:r._onlineComponentProvider)&&(e._firestoreClient._uninitializedComponentsProvider={_offlineKind:s.localCache.kind,_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider})}class Vo{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Vo(Ie.fromBase64String(e))}catch(e){throw new E(_.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new Vo(Ie.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}class Mo{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new E(_.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new q(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class Oo{constructor(e){this._methodName=e}}class Po{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new E(_.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new E(_.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return L(this._lat,e._lat)||L(this._long,e._long)}}const Fo=/^__.*__$/;class Uo{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Dn(e,this.data,this.fieldMask,t,this.fieldTransforms):new An(e,this.data,t,this.fieldTransforms)}}class qo{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Dn(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Bo(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw y()}}class $o{constructor(e,t,n,r,s,i){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===s&&this.Ru(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get Vu(){return this.settings.Vu}mu(e){return new $o(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}fu(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.mu({path:n,gu:!1});return r.pu(e),r}yu(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.mu({path:n,gu:!1});return r.Ru(),r}wu(e){return this.mu({path:void 0,gu:!0})}Su(e){return ra(e,this.settings.methodName,this.settings.bu||!1,this.path,this.settings.Du)}contains(e){return void 0!==this.fieldMask.find((t=>e.isPrefixOf(t)))||void 0!==this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))}Ru(){if(this.path)for(let e=0;e<this.path.length;e++)this.pu(this.path.get(e))}pu(e){if(0===e.length)throw this.Su("Document fields must not be empty");if(Bo(this.Vu)&&Fo.test(e))throw this.Su('Document fields cannot begin and end with "__"')}}class zo{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer
2=n||Ds(e)}Cu(e,t,n,r=!1){return new $o({Vu:e,methodName:t,Du:n,path:q.emptyPath(),gu:!1,bu:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Ko(e){const t=e._freezeSettings(),n=Ds(e._databaseId);return new zo(e._databaseId,!!t.ignoreUndefinedProperties,n)}function Qo(e,t,n,r,s,i={}){const o=e.Cu(i.merge||i.mergeFields?2:0,t,n,s);Zo("Data must be an object, but it was:",o,r);const a=Jo(r,o);let u,c;if(i.merge)u=new Ee(o.fieldMask),c=o.fieldTransforms;else if(i.mergeFields){const e=[];for(const r of i.mergeFields){const s=ea(t,r,n);if(!o.contains(s))throw new E(_.INVALID_ARGUMENT,`Field '${s}' is specified in your field mask but missing from your input data.`);sa(e,s)||e.push(s)}u=new Ee(e),c=o.fieldTransforms.filter((e=>u.covers(e.field)))}else u=null,c=o.fieldTransforms;return new Uo(new He(a),u,c)}class Go extends Oo{_toFieldTransform(e){if(2!==e.Vu)throw 1===e.Vu?e.Su(`${this._methodName}() can only appear at the top level of your update data`):e.Su(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Go}}function jo(e,t,n,r){const s=e.Cu(1,t,n);Zo("Data must be an object, but it was:",s,r);const i=[],a=He.empty();me(r,((e,r)=>{const u=na(t,e,n);r=(0,o.Ku)(r);const c=s.yu(u);if(r instanceof Go)i.push(u);else{const e=Yo(r,c);null!=e&&(i.push(u),a.set(u,e))}}));const u=new Ee(i);return new qo(a,u,s.fieldTransforms)}function Wo(e,t,n,r,s,i){const a=e.Cu(1,t,n),u=[ea(t,r,n)],c=[s];if(i.length%2!=0)throw new E(_.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let o=0;o<i.length;o+=2)u.push(ea(t,i[o])),c.push(i[o+1]);const l=[],h=He.empty();for(let f=u.length-1;f>=0;--f)if(!sa(l,u[f])){const e=u[f];let t=c[f];t=(0,o.Ku)(t);const n=a.yu(e);if(t instanceof Go)l.push(e);else{const r=Yo(t,n);null!=r&&(l.push(e),h.set(e,r))}}const d=new Ee(l);return new qo(h,d,a.fieldTransforms)}function Ho(e,t,n,r=!1){return Yo(n,e.Cu(r?4:3,t))}function Yo(e,t){if(Xo(e=(0,o.Ku)(e)))return Zo("Unsupported field value:",t,e),Jo(e,t);if(e instanceof Oo)return function(e,t){if(!Bo(t.Vu))throw t.Su(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Su(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.gu&&4!==t.Vu)throw t.Su("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const s of e){let e=Yo(s,t.wu(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=(0,o.Ku)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return sn(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=M.fromDate(e);return{timestampValue:cr(t.serializer,n)}}if(e instanceof M){const n=new M(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:cr(t.serializer,n)}}if(e instanceof Po)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Vo)return{bytesValue:lr(t.serializer,e._byteString)};if(e instanceof Co){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.Su(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:fr(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t.Su(`Unsupported field value: ${vo(e)}`)}(e,t)}function Jo(e,t){const n={};return pe(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):me(e,((e,r)=>{const s=Yo(r,t.fu(e));null!=s&&(n[e]=s)})),{mapValue:{fields:n}}}function Xo(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof M||e instanceof Po||e instanceof Vo||e instanceof Co||e instanceof Oo)}function Zo(e,t,n){if(!Xo(n)||!function(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){const r=vo(n);throw"an object"===r?t.Su(e+" a custom object"):t.Su(e+" "+r)}}function ea(e,t,n){if((t=(0,o.Ku)(t))instanceof Mo)return t._internalPath;if("string"==typeof t)return na(e,t);throw ra("Field path arguments must be of type string or ",e,!1,void 0,n)}const ta=new RegExp("[~\\*/\\[\\]]");function na(e,t,n){if(t.search(ta)>=0)throw ra(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new Mo(...t.split("."))._internalPath}catch(r){throw ra(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}
2function ra(e,t,n,r,s){const i=r&&!r.isEmpty(),o=void 0!==s;let a=`Function ${t}() 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 E(_.INVALID_ARGUMENT,a+e+u)}function sa(e,t){return e.some((e=>e.isEqual(t)))}class ia{constructor(e,t,n,r,s){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new Co(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new oa(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(aa("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class oa extends ia{data(){return super.data()}}function aa(e,t){return"string"==typeof t?na(e,t):t instanceof Mo?t._internalPath:t._delegate._internalPath}function ua(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new E(_.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class ca{}class la extends ca{}function ha(e,t,...n){let r=[];t instanceof ca&&r.push(t),r=r.concat(n),function(e){const t=e.filter((e=>e instanceof fa)).length,n=e.filter((e=>e instanceof da)).length;if(t>1||t>0&&n>0)throw new E(_.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const s of r)e=s._apply(e);return e}class da extends la{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new da(e,t,n)}_apply(e){const t=this._parse(e);return wa(e._query,t),new Io(e.firestore,e.converter,Lt(e._query,t))}_parse(e){const t=Ko(e.firestore),n=function(e,t,n,r,s,i,o){let a;if(s.isKeyField()){if("array-contains"===i||"array-contains-any"===i)throw new E(_.INVALID_ARGUMENT,`Invalid Query. You can't perform '${i}' queries on documentId().`);if("in"===i||"not-in"===i){ya(o,i);const t=[];for(const n of o)t.push(ga(r,e,n));a={arrayValue:{values:t}}}else a=ga(r,e,o)}else"in"!==i&&"not-in"!==i&&"array-contains-any"!==i||ya(o,i),a=Ho(n,t,o,"in"===i||"not-in"===i);return st.create(s,i,a)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value);return n}}class fa extends ca{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new fa(e,t)}_parse(e){const t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return 1===t.length?t[0]:it.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const r=t.getFlattenedFilters();for(const s of r)wa(n,s),n=Lt(n,s)}(e._query,t),new Io(e.firestore,e.converter,Lt(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class ma extends la{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new ma(e,t)}_apply(e){const t=function(e,t,n){if(null!==e.startAt)throw new E(_.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new E(_.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new tt(t,n)}(e._query,this._field,this._direction);return new Io(e.firestore,e.converter,function(e,t){const n=e.explicitOrderBy.concat([t]);return new St(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}function pa(e,t="asc"){const n=t,r=aa("orderBy",e);return ma._create(r,n)}function ga(e,t,n){if("string"==typeof(n=(0,o.Ku)(n))){if(""===n)throw new E(_.INVA
vendor: 4,504 bytes, line 2
2LID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Nt(t)&&-1!==n.indexOf("/"))throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(F.fromString(n));if(!B.isDocumentKey(r))throw new E(_.INVALID_ARGUMENT,`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 Be(e,new B(r))}if(n instanceof Co)return Be(e,n._key);throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${vo(n)}.`)}function ya(e,t){if(!Array.isArray(e)||0===e.length)throw new E(_.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function wa(e,t){const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new E(_.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new E(_.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}class va{convertValue(e,t="none"){switch(Ve(e)){case 0:return null;case 1:return e.booleanValue;case 2:return be(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Ae(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 10:return this.convertObject(e.mapValue,t);default:throw y()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return me(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertGeoPoint(e){return new Po(be(e.latitude),be(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const n=Ne(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(ke(e));default:return null}}convertTimestamp(e){const t=Se(e);return new M(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=F.fromString(e);w(Mr(n));const r=new Re(n.get(1),n.get(3)),s=new B(n.popFirst(5));return r.isEqual(t)||m(`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 (${t.projectId}/${t.database}) instead.`),s}}function _a(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}class Ea{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Ta extends ia{constructor(e,t,n,r,s,i){super(e,t,n,r,i),this._firestore=e,this._firestoreImpl=e,this.metadata=s}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new Ia(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const n=this._document.data.field(aa("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class Ia extends Ta{data(e={}){return super.data(e)}}class Ca{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new Ea(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new Ia(this._firestore,this._userDataWriter,n.key,n,new Ea(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;
2if(t&&this._snapshot.excludesMetadataChanges)throw new E(_.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{const r=new Ia(e._firestore,e._userDataWriter,n.doc.key,n.doc,new Ea(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:"added",doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||3!==e.type)).map((t=>{const r=new Ia(e._firestore,e._userDataWriter,t.doc.key,t.doc,new Ea(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let s=-1,i=-1;return 0!==t.type&&(s=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(n=n.add(t.doc),i=n.indexOf(t.doc.key)),{type:Sa(t.type),doc:r,oldIndex:s,newIndex:i}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function Sa(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return y()}}function ba(e){e=_o(e,Co);const t=_o(e.firestore,ko);return ho(Ro(t),e._key).then((n=>Ma(t,e,n)))}class Aa extends va{constructor(e){super(),this.firestore=e}convertBytes(e){return new Vo(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Co(this.firestore,null,t)}}function Da(e){e=_o(e,Io);const t=_o(e.firestore,ko),n=Ro(t),r=new Aa(t);return ua(e._query),fo(n,e._query).then((n=>new Ca(t,r,e,n)))}function Na(e,t,n){e=_o(e,Co);const r=_o(e.firestore,ko),s=_a(e.converter,t,n);return Va(r,[Qo(Ko(r),"setDoc",e._key,s,null!==e.converter,n).toMutation(e._key,vn.none())])}function ka(e,t,n,...r){e=_o(e,Co);const s=_o(e.firestore,ko),i=Ko(s);let a;return a="string"==typeof(t=(0,o.Ku)(t))||t instanceof Mo?Wo(i,"updateDoc",e._key,t,n,r):jo(i,"updateDoc",e._key,t),Va(s,[a.toMutation(e._key,vn.exists(!0))])}function xa(e){return Va(_o(e.firestore,ko),[new Rn(e._key,vn.none())])}function Ra(e,t){const n=_o(e.firestore,ko),r=Ao(e),s=_a(e.converter,t);return Va(n,[Qo(Ko(e.firestore),"addDoc",r._key,s,null!==e.converter,{}).toMutation(r._key,vn.exists(!1))]).then((()=>r))}function La(e,...t){var n,r,s;e=(0,o.Ku)(e);let i={includeMetadataChanges:!1,source:"default"},a=0;"object"!=typeof t[a]||No(t[a])||(i=t[a],a++);const u={includeMetadataChanges:i.includeMetadataChanges,source:i.source};if(No(t[a])){const e=t[a];t[a]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[a+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[a+2]=null===(s=e.complete)||void 0===s?void 0:s.bind(e)}let c,l,h;if(e instanceof Co)l=_o(e.firestore,ko),h=At(e._key.path),c={next:n=>{t[a]&&t[a](Ma(l,e,n))},error:t[a+1],complete:t[a+2]};else{const n=_o(e,Io);l=_o(n.firestore,ko),h=n._query;const r=new Aa(l);c={next:e=>{t[a]&&t[a](new Ca(l,r,n,e))},error:t[a+1],complete:t[a+2]},ua(e._query)}return function(e,t,n,r){const s=new no(r),i=new Ci(t,s,n);return e.asyncQueue.enqueueAndForget((async()=>yi(await lo(e),i))),()=>{s.Qa(),e.asyncQueue.enqueueAndForget((async()=>wi(await lo(e),i)))}}(Ro(l),h,u,c)}function Va(e,t){return function(e,t){const n=new T;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){const r=Zi(e);try{const e=await function(e,t){const n=v(e),r=M.now(),s=t.reduce(((e,t)=>e.add(t.key)),Zt());let i,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(e=>{let a=Kt(),u=Zt();return n.os.getEntries(e,s).next((e=>{a=e,a.forEach(((e,t)=>{t.isValidDocument()||(u=u.add(e))}))})).next((()=>n.localDocuments.getOverlayedDocuments(e,a))).next((s=>{i=s;const o=[];for(const e of t){const t=Sn(e,i.get(e.key).overlayedDocument);null!=t&&o.push(new Dn(e.key,t,Ye(t.value.mapValue),vn.exists(!0)))}
2return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=>{o=t;const r=t.applyToLocalDocumentSet(i,u);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:jt(i)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Fa[e.currentUser.toKey()];r||(r=new ge(L)),r=r.insert(t,n),e.Fa[e.currentUser.toKey()]=r}(r,e.batchId,n),await Hi(r,e.changes),await Js(r.remoteStore)}catch(e){const t=hi(e,"Failed to persist write");n.reject(t)}}(await co(e),t,n))),n.promise}(Ro(e),t)}function Ma(e,t,n){const r=n.docs.get(t._key),s=new Aa(e);return new Ta(e,s,t._key,r,new Ea(n.hasPendingWrites,n.fromCache),t.converter)}class Oa{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Ko(e)}set(e,t,n){this._verifyNotCommitted();const r=Pa(e,this._firestore),s=_a(r.converter,t,n),i=Qo(this._dataReader,"WriteBatch.set",r._key,s,null!==r.converter,n);return this._mutations.push(i.toMutation(r._key,vn.none())),this}update(e,t,n,...r){this._verifyNotCommitted();const s=Pa(e,this._firestore);let i;return i="string"==typeof(t=(0,o.Ku)(t))||t instanceof Mo?Wo(this._dataReader,"WriteBatch.update",s._key,t,n,r):jo(this._dataReader,"WriteBatch.update",s._key,t),this._mutations.push(i.toMutation(s._key,vn.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=Pa(e,this._firestore);return this._mutations=this._mutations.concat(new Rn(t._key,vn.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 E(_.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function Pa(e,t){if((e=(0,o.Ku)(e)).firestore!==t)throw new E(_.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}function Fa(e){return Ro(e=_o(e,ko)),new Oa(e,(t=>Va(e,t)))}new WeakMap;!function(e,t=!0){!function(e){l=e}(r.MF),(0,r.om)(new s.uA("firestore",((e,{instanceIdentifier:n,options:r})=>{const s=e.getProvider("app").getImmediate(),i=new ko(new b(e.getProvider("auth-internal")),new k(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new E(_.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Re(e.options.projectId,t)}(s,n),s);return r=Object.assign({useFetchStreams:t},r),i._setSettings(r),i}),"PUBLIC").setMultipleInstances(!0)),(0,r.KO)(u,"4.5.0",e),(0,r.KO)(u,"4.5.0","esm2017")}()}}]); 3//# sourceMappingURL=7112840a-dc6ace70c766ea78d1fc.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.