PageSourceSearch

https://darkheart.app/_next/static/chunks/b321d78c-0e21ab54c08f77ef.js?dpl=dpl_5amyhtMBixS35stMvDnm3RwptNx5

js darkheart.app collected 2026-10-02 00:25:39 UTC 250,644 bytes, 1,612 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5160],{797:function(e,t,r){r.d(t,{AK:function(){return ay},Bt:function(){return aw},EK:function(){return en},ET:function(){return ah},IO:function(){return sX},JU:function(){return sd},PL:function(){return ao},QT:function(){return as},Xo:function(){return s2},ad:function(){return sy},ar:function(){return sZ},at:function(){return so},b9:function(){return s4},hJ:function(){return sc},i3:function(){return ag},nP:function(){return av},oe:function(){return au},r7:function(){return al}});var n,i,s,a,o=r(3306),l=r(6177),u=r(3861),h=r(4648),c=r(127),d=r(9555);r(5139);var f=r(795).Buffer;let m="@firebase/firestore",p="4.9.0";/**
2 * @license
3 * Copyright 2017 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *   http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */class g{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}}g.UNAUTHENTICATED=new g(null),g.GOOGLE_CREDENTIALS=new g("google-credentials-uid"),g.FIRST_PARTY=new g("first-party-uid"),g.MOCK_USER=new g("mock-user");/**
17 * @license
18 * Copyright 2017 Google LLC
19 *
20 * Licensed under the Apache License, Version 2.0 (the "License");
21 * you may not use this file except in compliance with the License.
22 * You may obtain a copy of the License at
23 *
24 *   http://www.apache.org/licenses/LICENSE-2.0
25 *
26 * Unless required by applicable law or agreed to in writing, software
27 * distributed under the License is distributed on an "AS IS" BASIS,
28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 * See the License for the specific language governing permissions and
30 * limitations under the License.
31 */let y="12.0.0",w=new u.Yd("@firebase/firestore");function v(){return w.logLevel}function _(e,...t){if(w.logLevel<=u.in.DEBUG){let r=t.map(I);w.debug(`Firestore (${y}): ${e}`,...r)}}function E(e,...t){if(w.logLevel<=u.in.ERROR){let r=t.map(I);w.error(`Firestore (${y}): ${e}`,...r)}}function T(e,...t){if(w.logLevel<=u.in.WARN){let r=t.map(I);w.warn(`Firestore (${y}): ${e}`,...r)}}function I(e){if("string"==typeof e)return e;try{/**
32 * @license
33 * Copyright 2020 Google LLC
34 *
35 * Licensed under the Apache License, Version 2.0 (the "License");
36 * you may not use this file except in compliance with the License.
37 * You may obtain a copy of the License at
38 *
39 *   http://www.apache.org/licenses/LICENSE-2.0
40 *
41 * Unless required by applicable law or agreed to in writing, software
42 * distributed under the License is distributed on an "AS IS" BASIS,
43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44 * See the License for the specific language governing permissions and
45 * limitations under the License.
46 */return JSON.stringify(e)}catch(t){return e}}/**
47 * @license
48 * Copyright 2017 Google LLC
49 *
50 * Licensed under the Apache License, Version 2.0 (the "License");
51 * you may not use this file except in compliance with the License.
52 * You may obtain a copy of the License at
53 *
54 *   http://www.apache.org/licenses/LICENSE-2.0
55 *
56 * Unless required by applicable law or agreed to in writing, software
57 * distributed under the License is distributed on an "AS IS" BASIS,
58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59 * See the License for the specific language governing permissions and
60 * limitations under the License.
61 */function S(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,C(e,n,r)}function C(e,t,r){let n=`FIRESTORE (${y}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw E(n),Error(n)}function N(e,t,r,n){let i="Unexpected state";"string"==typeof r?i=r:n=r,e||C(t,i,n)}/**
62 * @license
63 * Copyright 2017 Google LLC
64 *
65 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
67 * You may obtain a copy of the License at
68 *
69 *   http://www.apache.org/licenses/LICENSE-2.0
70 *
71 * Unless required by applicable law or agreed to in writing, software
72 * distributed under the License is distributed on an "AS IS" BASIS,
73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74 * See the License for the specific language governing permissions and
75 * limitations under the License.
76 */let A={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 b extends h.ZR{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
77 * @license
78 * Copyright 2017 Google LLC
79 *
80 * Licensed under the Apache License, Version 2.0 (the "License");
81 * you may not use this file except in compliance with the License.
82 * You may obtain a copy of the License at
83 *
84 *   http://www.apache.org/licenses/LICENSE-2.0
85 *
86 * Unless required by applicable law or agreed to in writing, software
87 * distributed under the License is distributed on an "AS IS" BASIS,
88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89 * See the License for the specific language governing permissions and
90 * limitations under the License.
91 */class D{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/**
92 * @license
93 * Copyright 2017 Google LLC
94 *
95 * Licensed under the Apache License, Version 2.0 (the "License");
96 * you may not use this file except in compliance with the License.
97 * You may obtain a copy of the License at
98 *
99 *   http://www.apache.org/licenses/LICENSE-2.0
100 *
101 * Unless required by applicable law or agreed to in writing, software
102 * distributed under the License is distributed on an "AS IS" BASIS,
103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104 * See the License for the specific language governing permissions and
105 * limitations under the License.
106 */class k{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class R{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(g.UNAUTHENTICATED))}shutdown(){}}class x{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 V{constructor(e){this.t=e,this.currentUser=g.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){N(void 0===this.o,42304);let r=this.i,n=e=>this.i!==r?(r=this.i,t(e)):Promise.resolve(),i=new D;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new D,e.enqueueRetryable(()=>n(this.currentUser))};let s=()=>{let t=i;e.enqueueRetryable(async()=>{await t.promise,await n(this.currentUser)})},a=e=>{_("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?a(e):(_("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new D)}},0),s()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(_("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(N("string"==typeof t.accessToken,31837,{l:t}),new k(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return N(null===e||"string"==typeof e,2055,{h:e}),new g(e)}}class M{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=g.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);let e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class L{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new M(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(g.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class O{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 F{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,(0,o.rh)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){N(void 0===this.o,3512);let r=e=>{null!=e.error&&_("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let r=e.token!==this.m;return this.m=e.token,_("FirebaseAppCheckTokenProvider",`Received ${r?"new":"existing"} token.`),r?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>r(t))};let n=e=>{_("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>n(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?n(e):_("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new O(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(N("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new O(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
107 * @license
108 * Copyright 2017 Google LLC
109 *
110 * Licensed under the Apache License, Version 2.0 (the "License");
111 * you may not use this file except in compliance with the License.
112 * You may obtain a copy of the License at
113 *
114 *   http://www.apache.org/licenses/LICENSE-2.0
115 *
116 * Unless required by applicable law or agreed to in writing, software
117 * distributed under the License is distributed on an "AS IS" BASIS,
118 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119 * See the License for the specific language governing permissions and
120 * limitations under the License.
121 */class P{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let r=/**
122 * @license
123 * Copyright 2020 Google LLC
124 *
125 * Licensed under the Apache License, Version 2.0 (the "License");
126 * you may not use this file except in compliance with the License.
127 * You may obtain a copy of the License at
128 *
129 *   http://www.apache.org/licenses/LICENSE-2.0
130 *
131 * Unless required by applicable law or agreed to in writing, software
132 * distributed under the License is distributed on an "AS IS" BASIS,
133 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134 * See the License for the specific language governing permissions and
135 * limitations under the License.
136 */function(e){let t="undefined"!=typeof self&&(self.crypto||self.msCrypto),r=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(r);else for(let t=0;t<e;t++)r[t]=Math.floor(256*Math.random());return r}(40);for(let n=0;n<r.length;++n)t.length<20&&r[n]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(r[n]%62))}return t}}function U(e,t){return e<t?-1:e>t?1:0}function q(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=e.charAt(n),i=t.charAt(n);if(r!==i)return z(r)===z(i)?U(r,i):z(r)?1:-1}return U(e.length,t.length)}function z(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function B(e,t,r){return e.length===t.length&&e.every((e,n)=>r(e,t[n]))}/**
137 * @license
138 * Copyright 2017 Google LLC
139 *
140 * Licensed under the Apache License, Version 2.0 (the "License");
141 * you may not use this file except in compliance with the License.
142 * You may obtain a copy of the License at
143 *
144 *   http://www.apache.org/licenses/LICENSE-2.0
145 *
146 * Unless required by applicable law or agreed to in writing, software
147 * distributed under the License is distributed on an "AS IS" BASIS,
148 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149 * See the License for the specific language governing permissions and
150 * limitations under the License.
151 */let $="__name__";class G{constructor(e,t,r){void 0===t?t=0:t>e.length&&S(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-t&&S(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return 0===G.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof G?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,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=G.compareSegments(e.get(n),t.get(n));if(0!==r)return r}return U(e.length,t.length)}static compareSegments(e,t){let r=G.isNumericId(e),n=G.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?G.extractNumericId(e).compare(G.extractNumericId(t)):q(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return c.z8.fromString(e.substring(4,e.length-2))}}class j extends G{construct(e,t,r){return new j(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
151toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new b(A.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(e=>e.length>0))}return new j(t)}static emptyPath(){return new j([])}}let K=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Q extends G{construct(e,t,r){return new Q(e,t,r)}static isValidIdentifier(e){return K.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&&this.get(0)===$}static keyField(){return new Q([$])}static fromServerFormat(e){let t=[],r="",n=0,i=()=>{if(0===r.length)throw new b(A.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},s=!1;for(;n<e.length;){let t=e[n];if("\\"===t){if(n+1===e.length)throw new b(A.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[n+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new b(A.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=t,n+=2}else"`"===t?s=!s:"."!==t||s?r+=t:i(),n++}if(i(),s)throw new b(A.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Q(t)}static emptyPath(){return new Q([])}}/**
152 * @license
153 * Copyright 2017 Google LLC
154 *
155 * Licensed under the Apache License, Version 2.0 (the "License");
156 * you may not use this file except in compliance with the License.
157 * You may obtain a copy of the License at
158 *
159 *   http://www.apache.org/licenses/LICENSE-2.0
160 *
161 * Unless required by applicable law or agreed to in writing, software
162 * distributed under the License is distributed on an "AS IS" BASIS,
163 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164 * See the License for the specific language governing permissions and
165 * limitations under the License.
166 */class H{constructor(e){this.path=e}static fromPath(e){return new H(j.fromString(e))}static fromName(e){return new H(j.fromString(e).popFirst(5))}static empty(){return new H(j.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===j.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return j.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new H(new j(e.slice()))}}/**
167 * @license
168 * Copyright 2017 Google LLC
169 *
170 * Licensed under the Apache License, Version 2.0 (the "License");
171 * you may not use this file except in compliance with the License.
172 * You may obtain a copy of the License at
173 *
174 *   http://www.apache.org/licenses/LICENSE-2.0
175 *
176 * Unless required by applicable law or agreed to in writing, software
177 * distributed under the License is distributed on an "AS IS" BASIS,
178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179 * See the License for the specific language governing permissions and
180 * limitations under the License.
181 */function W(e,t,r){if(!r)throw new b(A.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function Y(e){if(!H.isDocumentKey(e))throw new b(A.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function X(e){if(H.isDocumentKey(e))throw new b(A.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function J(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function Z(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";{var t;let r=(t=e).constructor?t.constructor.name:null;return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":S(12329,{type:typeof e})}function ee(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new b(A.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let r=Z(e);throw new b(A.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${r}`)}}return e}/**
182 * @license
183 * Copyright 2025 Google LLC
184 *
185 * Licensed under the Apache License, Version 2.0 (the "License");
186 * you may not use this file except in compliance with the License.
187 * You may obtain a copy of the License at
188 *
189 *   http://www.apache.org/licenses/LICENSE-2.0
190 *
191 * Unless required by applicable law or agreed to in writing, software
192 * distributed under the License is distributed on an "AS IS" BASIS,
193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194 * See the License for the specific language governing permissions and
195 * limitations under the License.
196 */function et(e,t){let r={typeString:e};return t&&(r.value=t),r}function er(e,t){let r;if(!J(e))throw new b(A.INVALID_ARGUMENT,"JSON must be an object");for(let n in t)if(t[n]){let i=t[n].typeString,s="value"in t[n]?{value:t[n].value}:void 0;if(!(n in e)){r=`JSON missing required field: '${n}'`;break}let a=e[n];if(i&&typeof a!==i){r=`JSON field '${n}' must be a ${i}.`;break}if(void 0!==s&&a!==s.value){r=`Expected '${n}' field to equal '${s.value}'`;break}}if(r)throw new b(A.INVALID_ARGUMENT,r);return!0}class en{static now(){return en.fromMillis(Date.now())}static fromDate(e){return en.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3);return new en(t,Math.floor((e-1e3*t)*1e6))}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new b(A.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800||e>=253402300800)throw new b(A.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?U(this.nanoseconds,e.nanoseconds):U(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:en._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(er(e,en._jsonSchema))return new en(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -62135596800).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}en._jsonSchemaVersion="firestore/timestamp/1.0",en._jsonSchema={type:et("string",en._jsonSchemaVersion),seconds:et("number"),nanoseconds:et("number")};/**
197 * @license
198 * Copyright 2017 Google LLC
199 *
200 * Licensed under the Apache License, Version 2.0 (the "License");
201 * you may not use this file except in compliance with the License.
202 * You may obtain a copy of the License at
203 *
204 *   http://www.apache.org/licenses/LICENSE-2.0
205 *
206 * Unless required by applicable law or agreed to in writing, software
207 * distributed under the License is distributed on an "AS IS" BASIS,
208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209 * See the License for the specific language governing permissions and
210 * limitations under the License.
211 */class ei{static fromTimestamp(e){return new ei(e)}static min(){return new ei(new en(0,0))}static max(){return new ei(new en(253402300799,999999999))}constructor(e){this.timestamp=e}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 es{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}es.UNKNOWN_ID=-1;class ea{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new ea(ei.min(),H.empty(),-1)}static max(){return new ea(ei.max(),H.empty(),-1)}}class eo{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
212 * @license
213 * Copyright 2017 Google LLC
214 *
215 * Licensed under the Apache License, Version 2.0 (the "License");
216 * you may not use this file except in compliance with the License.
217 * You may obtain a copy of the License at
218 *
219 *   http://www.apache.org/licenses/LICENSE-2.0
220 *
221 * Unless required by applicable law or agreed to in writing, softw
221are
222 * distributed under the License is distributed on an "AS IS" BASIS,
223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224 * See the License for the specific language governing permissions and
225 * limitations under the License.
226 */async function el(e){if(e.code!==A.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==e.message)throw e;_("LocalStore","Unexpectedly lost primary lease")}/**
227 * @license
228 * Copyright 2017 Google LLC
229 *
230 * Licensed under the Apache License, Version 2.0 (the "License");
231 * you may not use this file except in compliance with the License.
232 * You may obtain a copy of the License at
233 *
234 *   http://www.apache.org/licenses/LICENSE-2.0
235 *
236 * Unless required by applicable law or agreed to in writing, software
237 * distributed under the License is distributed on an "AS IS" BASIS,
238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
239 * See the License for the specific language governing permissions and
240 * limitations under the License.
241 */class eu{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&&S(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new eu((r,n)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(r,n)},this.catchCallback=e=>{this.wrapFailure(t,e).next(r,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof eu?t:eu.resolve(t)}catch(e){return eu.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):eu.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):eu.reject(t)}static resolve(e){return new eu((t,r)=>{t(e)})}static reject(e){return new eu((t,r)=>{r(e)})}static waitFor(e){return new eu((t,r)=>{let n=0,i=0,s=!1;e.forEach(e=>{++n,e.next(()=>{++i,s&&i===n&&t()},e=>r(e))}),s=!0,i===n&&t()})}static or(e){let t=eu.resolve(!1);for(let r of e)t=t.next(e=>e?eu.resolve(e):r());return t}static forEach(e,t){let r=[];return e.forEach((e,n)=>{r.push(t.call(this,e,n))}),this.waitFor(r)}static mapArray(e,t){return new eu((r,n)=>{let i=e.length,s=Array(i),a=0;for(let o=0;o<i;o++){let l=o;t(e[l]).next(e=>{s[l]=e,++a===i&&r(s)},e=>n(e))}})}static doWhile(e,t){return new eu((r,n)=>{let i=()=>{!0===e()?t().next(()=>{i()},n):r()};i()})}}function eh(e){return"IndexedDbTransactionError"===e.name}/**
242 * @license
243 * Copyright 2018 Google LLC
244 *
245 * Licensed under the Apache License, Version 2.0 (the "License");
246 * you may not use this file except in compliance with the License.
247 * You may obtain a copy of the License at
248 *
249 *   http://www.apache.org/licenses/LICENSE-2.0
250 *
251 * Unless required by applicable law or agreed to in writing, software
252 * distributed under the License is distributed on an "AS IS" BASIS,
253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254 * See the License for the specific language governing permissions and
255 * limitations under the License.
256 */class ec{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}}function ed(e){return null==e}function ef(e){return 0===e&&1/e==-1/0}/**
257 * @license
258 * Copyright 2017 Google LLC
259 *
260 * Licensed under the Apache License, Version 2.0 (the "License");
261 * you may not use this file except in compliance with the License.
262 * You may obtain a copy of the License at
263 *
264 *   http://www.apache.org/licenses/LICENSE-2.0
265 *
266 * Unless required by applicable law or agreed to in writing, software
267 * distributed under the License is distributed on an "AS IS" BASIS,
268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
269 * See the License for the specific language governing permissions and
270 * limitations under the License.
271 */function em(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function ep(e,t){for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function eg(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}ec.ce=-1;/**
272 * @license
273 * Copyright 2017 Google LLC
274 *
275 * Licensed under the Apache License, Version 2.0 (the "License");
276 * you may not use this file except in compliance with the License.
277 * You may obtain a copy of the License at
278 *
279 *   http://www.apache.org/licenses/LICENSE-2.0
280 *
281 * Unless required by applicable law or agreed to in writing, software
282 * distributed under the License is distributed on an "AS IS" BASIS,
283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284 * See the License for the specific language governing permissions and
285 * limitations under the License.
286 */class ey{constructor(e,t){this.comparator=e,this.root=t||ev.EMPTY}insert(e,t){return new ey(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,ev.BLACK,null,null))}remove(e){return new ey(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ev.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(0===r)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let n=this.comparator(e,r.key);if(0===n)return t+r.left.size;n<0?r=r.left:(t+=r.left.size+1,r=r.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,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new ew(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new ew(this.root,e,this.comparator,!1)}getReverseIterator(){return new ew(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new ew(this.root,e,this.comparator,!0)}}class ew{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&n&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),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;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class ev{constructor(e,t,r,n,i){this.key=e,this.value=t,this.color=null!=r?r:ev.RED,this.left=null!=n?n:ev.EMPTY,this.right=null!=i?i:ev.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,i){return new ev(null!=e?e:this.key,null!=t?t:this.value,null!=r?r:this.color,null!=n?n:this.left,null!=i?i: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,r){let n=this,i=r(e,n.key);return(n=i<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===i?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp()}removeMin(){if(this.left.isEmpty())return ev.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)).fixUp()}remove(e,t){let r,n=this;if(0>t(e,n.key))n.left.isEmpty()||n.left.isRed()||n.left.left.isRed()||(n=n.moveRedLeft()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed()&&(n=n.rotateRight()),n.right.isEmpty()||n.right.isRed()||n.right.left.isRed()||(n=n.moveRedRight()),0===t(e,n.key)){if(n.right.isEmpty())return ev.EMPTY;r=n.right.min(),n=n.copy(r.key,r.value,null,null,n.right.removeMin())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.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=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,ev.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,ev.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let 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(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw S(43730,{key:this.key,value:this.value});if(this.right.isRed())throw S(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw S(27949);return e+(this.isRed()?0:1)}}
286ev.EMPTY=null,ev.RED=!0,ev.BLACK=!1,ev.EMPTY=new class{constructor(){this.size=0}get key(){throw S(57766)}get value(){throw S(16141)}get color(){throw S(16727)}get left(){throw S(29726)}get right(){throw S(36894)}copy(e,t,r,n,i){return this}insert(e,t,r){return new ev(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}};/**
287 * @license
288 * Copyright 2017 Google LLC
289 *
290 * Licensed under the Apache License, Version 2.0 (the "License");
291 * you may not use this file except in compliance with the License.
292 * You may obtain a copy of the License at
293 *
294 *   http://www.apache.org/licenses/LICENSE-2.0
295 *
296 * Unless required by applicable law or agreed to in writing, software
297 * distributed under the License is distributed on an "AS IS" BASIS,
298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299 * See the License for the specific language governing permissions and
300 * limitations under the License.
301 */class e_{constructor(e){this.comparator=e,this.data=new ey(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,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let n=r.getNext();if(this.comparator(n.key,e[1])>=0)return;t(n.key)}}forEachWhile(e,t){let r;for(r=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new eE(this.data.getIterator())}getIteratorFrom(e){return new eE(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 e_)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(0!==this.comparator(e,n))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new e_(this.comparator);return t.data=e,t}}class eE{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
302 * @license
303 * Copyright 2020 Google LLC
304 *
305 * Licensed under the Apache License, Version 2.0 (the "License");
306 * you may not use this file except in compliance with the License.
307 * You may obtain a copy of the License at
308 *
309 *   http://www.apache.org/licenses/LICENSE-2.0
310 *
311 * Unless required by applicable law or agreed to in writing, software
312 * distributed under the License is distributed on an "AS IS" BASIS,
313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
314 * See the License for the specific language governing permissions and
315 * limitations under the License.
316 */class eT{constructor(e){this.fields=e,e.sort(Q.comparator)}static empty(){return new eT([])}unionWith(e){let t=new e_(Q.comparator);for(let e of this.fields)t=t.add(e);for(let r of e)t=t.add(r);return new eT(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return B(this.fields,e.fields,(e,t)=>e.isEqual(t))}}/**
317 * @license
318 * Copyright 2023 Google LLC
319 *
320 * Licensed under the Apache License, Version 2.0 (the "License");
321 * you may not use this file except in compliance with the License.
322 * You may obtain a copy of the License at
323 *
324 *   http://www.apache.org/licenses/LICENSE-2.0
325 *
326 * Unless required by applicable law or agreed to in writing, software
327 * distributed under the License is distributed on an "AS IS" BASIS,
328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
329 * See the License for the specific language governing permissions and
330 * limitations under the License.
331 */class eI extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
332 * @license
333 * Copyright 2020 Google LLC
334 *
335 * Licensed under the Apache License, Version 2.0 (the "License");
336 * you may not use this file except in compliance with the License.
337 * You may obtain a copy of the License at
338 *
339 *   http://www.apache.org/licenses/LICENSE-2.0
340 *
341 * Unless required by applicable law or agreed to in writing, software
342 * distributed under the License is distributed on an "AS IS" BASIS,
343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344 * See the License for the specific language governing permissions and
345 * limitations under the License.
346 */class eS{constructor(e){this.binaryString=e}static fromBase64String(e){return new eS(function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new eI("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new eS(function(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}(e))}[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 btoa(this.binaryString)}toUint8Array(){return function(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return U(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}eS.EMPTY_BYTE_STRING=new eS("");let eC=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function eN(e){if(N(!!e,39018),"string"==typeof e){let t=0,r=eC.exec(e);if(N(!!r,46558,{timestamp:e}),r[1]){let e=r[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:eA(e.seconds),nanos:eA(e.nanos)}}function eA(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function eb(e){return"string"==typeof e?eS.fromBase64String(e):eS.fromUint8Array(e)}/**
347 * @license
348 * Copyright 2020 Google LLC
349 *
350 * Licensed under the Apache License, Version 2.0 (the "License");
351 * you may not use this file except in compliance with the License.
352 * You may obtain a copy of the License at
353 *
354 *   http://www.apache.org/licenses/LICENSE-2.0
355 *
356 * Unless required by applicable law or agreed to in writing, software
357 * distributed under the License is distributed on an "AS IS" BASIS,
358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
359 * See the License for the specific language governing permissions and
360 * limitations under the License.
361 */let eD="server_timestamp",ek="__type__",eR="__previous_value__",ex="__local_write_time__";function eV(e){return(e?.mapValue?.fields||{})[ek]?.stringValue===eD}function eM(e){let t=e.mapValue.fields[eR];return eV(t)?eM(t):t}function eL(e){let t=eN(e.mapValue.fields[ex].timestampValue);return new en(t.seconds,t.nanos)}/**
362 * @license
363 * Copyright 2017 Google LLC
364 *
365 * Licensed under the Apache License, Version 2.0 (the "License");
366 * you may not use this file except in compliance with the License.
367 * You may obtain a copy of the License at
368 *
369 *   http://www.apache.org/licenses/LICENSE-2.0
370 *
371 * Unless required by applicable law or agreed to in writing, software
372 * distributed under the License is distributed on an "AS IS" BASIS,
373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374 * See the License for the specific language governing permissions and
375 * limitations under the License.
376 */class eO{constructor(e,t,r,n,i,s,a,o,l,u){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u}}let eF="(default)";class eP{constructor(e,t){this.projectId=e,this.database=t||eF}static empty(){return new eP("","")}get isDefaultDatabase(){return this.database===eF}isEqual(e){return e instanceof eP&&e.projectId===this.projectId&&e.database===this.database}}/**
377 * @license
378 * Copyright 2020 Google LLC
379 *
380 * Licensed under the Apache License, Version 2.0 (the "License");
381 * you may not use this file except in compliance with the License.
382 * You may obtain a copy of the License at
383 *
384 *   http://www.apache.org/licenses/LICENSE-2.0
385 *
386 * Unless required by applicable law or agreed to in writing, software
387 * distributed under the License is distributed on an "AS IS" BASIS,
388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
389 * See the License for the specific language governing permissions and
390 * limitations under the License.
391 */let eU="__type__",eq="__max__",ez={mapValue:{fields:{__type__:{stringValue:eq}}}},eB="__vector__",e$="value";function eG(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?eV(e)?4:e9(e)?9007199254740991:e3(e)?10:11:S(28295,{value:e})}function ej(e,t){if(e===t)return!0;let r=eG(e);if(r!==eG(t))return!1;switch(r){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return eL(e).isEqual(eL(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;let r=eN(e.timestampValue),n=eN(t.timestampValue);return r.seconds===n.seconds&&r.nanos===n.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return eb(e.bytesValue).isEqual(eb(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return eA(e.geoPointValue.latitude)===eA(t.geoPointValue.latitude)&&eA(e.geoPointValue.longitude)===eA(t.geoPointValue.longitude);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return eA(e.integerValue)===eA(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let r=eA(e.doubleValue),n=eA(t.doubleValue);return r===n?ef(r)===ef(n):isNaN(r)&&isNaN(n)}return!1}(e,t);case 9:return B(e.arrayValue.values||[],t.arrayValue.values||[],ej);case 10:case 11:return function(e,t){let r=e.mapValue.fields||{},n=t.mapValue.fields||{};if(em(r)!==em(n))return!1;for(let e in r)if(r.hasOwnProperty(e)&&(void 0===n[e]||!ej(r[e],n[e])))return!1;return!0}(e,t);default:return S(52216,{left:e})}}function eK(e,t){return void 0!==(e.values||[]).find(e=>ej(e,t))}function eQ(e,t){if(e===t)return 0;let r=eG(e),n=eG(t);if(r!==n)return U(r,n);switch(r){case 0:case 9007199254740991:return 0;case 1:return U(e.booleanValue,t.booleanValue);case 2:return function(e,t){let r=eA(e.integerValue||e.doubleValue),n=eA(t.integerValue||t.doubleValue);return r<n?-1:r>n?1:r===n?0:isNaN(r)?isNaN(n)?0:-1:1}(e,t);case 3:return eH(e.timestampValue,t.timestampValue);case 4:return eH(eL(e),eL(t));case 5:return q(e.stringValue,t.stringValue);case 6:return function(e,t){let r=eb(e),n=eb(t);return r.compareTo(n)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){let r=e.split("/"),n=t.split("/");for(let e=0;e<r.length&&e<n.length;e++){let t=U(r[e],n[e]);if(0!==t)return t}return U(r.length,n.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let r=U(eA(e.latitude),eA(t.latitude));return 0!==r?r:U(eA(e.longitude),eA(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return eW(e.arrayValue,t.arrayValue);case 10:return function(e,t){let r=e.fields||{},n=t.fields||{},i=r[e$]?.arrayValue,s=n[e$]?.arrayValue,a=U(i?.values?.length||0,s?.values?.length||0);return 0!==a?a:eW(i,s)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===ez.mapValue&&t===ez.mapValue)return 0;if(e===ez.mapValue)return 1;if(t===ez.mapValue)return -1;let r=e.fields||{},n=Object.keys(r),i=t.fields||{},s=Object.keys(i);n.sort(),s.sort();for(let e=0;e<n.length&&e<s.length;++e){let t=q(n[e],s[e]);if(0!==t)return t;let a=eQ(r[n[e]],i[s[e]]);if(0!==a)return a}return U(n.length,s.length)}(e.mapValue,t.mapValue);default:throw S(23264,{he:r})}}function eH(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return U(e,t);let r=eN(e),n=eN(t),i=U(r.seconds,n.seconds);return 0!==i?i:U(r.nanos,n.nanos)}function eW(e,t){let r=e.values||[],n=t.values||[];for(let e=0;e<r.length&&e<n.length;++e){let t=eQ(r[e],n[e]);if(t)return t}return U(r.length,n.length)}function eY(e){var t,r;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){let t=eN(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?eb(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,H.fromName(t).toString()):"geoPointValue"in e?(r=e.geoPointValue,`geo(${r.latitude},${r.longitude})`):"arrayValue"in e?function(e){let t="[",r=!0;for(let n of e.values||[])r?r=!1:t+=",",t+=eY(n);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(let i of t)n?n=!1:r+=",",r+=`${i}:${eY(e.fields[i])}`;return r+"}"}(e.mapValue):S(61005,{value:e})}function eX(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function eJ(e){return!!e&&"integerValue"in e}function eZ(e){return!!e&&"arrayValue"in e}function e0(e){return!!e&&"nullValue"in e}function e1(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function e2(e){return!!e&&"mapValue"in e}function e3(e){return(e?.mapValue?.fields||{})[eU]?.stringValue===eB}function e4(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return ep(e.mapValue.fields,(e,r)=>t.mapValue.fields[e]=e4(r)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let r=0;r<(e.arrayValue.values||[]).length;++r)t.arrayValue.values[r]=e4(e.arrayValue.values[r]);return t}return{...e}}function e9(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===eq}/**
392 * @license
393 * Copyright 2017 Google LLC
394 *
395 * Licensed under the Apache License, Version 2.0 (the "License");
396 * you may not use this file except in compliance with the License.
397 * You may obtain a copy of the License at
398 *
399 *   http://www.apache.org/licenses/LICENSE-2.0
400 *
401 * Unless required by applicable law or agreed to in writing, software
402 * distributed under the License is distributed on an "AS IS" BASIS,
403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
404 * See the License for the specific language governing permissions and
405 * limitations under the License.
406 */class e6{constructor(e){this.value=e}static empty(){return new e6({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(!e2(t=(t.mapValue.fields||{})[e.get(r)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=e4(t)}setAll(e){let t=Q.emptyPath(),r={},n=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,r,n),r={},n=[],t=i.popLast()}e?r[i.lastSegment()]=e4(e):n.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,r,n)}delete(e){let t=this.field(e.popLast());e2(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ej(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let n=t.mapValue.fields[e.get(r)];e2(n)&&n.mapValue.fields||(n={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=n),t=n}return t.mapValue.fields}applyChanges(e,t,r){for(let n of(ep(t,(t,r)=>e[t]=r),r))delete e[n]}clone(){return new e6(e4(this.value))}}/**
407 * @license
408 * Copyright 2017 Google LLC
409 *
410 * Licensed under the Apache License, Version 2.0 (the "License");
411 * you may not use this file except in compliance with the License.
412 * You may obtain a copy of the License at
413 *
414 *   http://www.apache.org/licenses/LICENSE-2.0
415 *
416 * Unless required by applicable law or agreed to in writing, software
417 * distributed under the License is distributed on an "AS IS" BASIS,
418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419 * See the License for the specific language governing permissions and
420 * limitations under the License.
421 */class e5{constructor(e,t,r,n,i,s,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new e5(e,0,ei.min(),ei.min(),ei.min(),e6.empty(),0)}static newFoundDocument(e,t,r,n){return new e5(e,1,t,ei.min(),r,n,0)}static newNoDocument(e,t){return new e5(e,2,t,ei.min(),ei.min(),e6.empty(),0)}static newUnknownDocument(e,t){return new e5(e,3,t,ei.min(),ei.min(),e6.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(ei.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=e6.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=e6.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ei.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 e5&&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 e5(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}})`}}
421/**
422 * @license
423 * Copyright 2022 Google LLC
424 *
425 * Licensed under the Apache License, Version 2.0 (the "License");
426 * you may not use this file except in compliance with the License.
427 * You may obtain a copy of the License at
428 *
429 *   http://www.apache.org/licenses/LICENSE-2.0
430 *
431 * Unless required by applicable law or agreed to in writing, software
432 * distributed under the License is distributed on an "AS IS" BASIS,
433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
434 * See the License for the specific language governing permissions and
435 * limitations under the License.
436 */class e8{constructor(e,t){this.position=e,this.inclusive=t}}function e7(e,t,r){let n=0;for(let i=0;i<e.position.length;i++){let s=t[i],a=e.position[i];if(n=s.field.isKeyField()?H.comparator(H.fromName(a.referenceValue),r.key):eQ(a,r.data.field(s.field)),"desc"===s.dir&&(n*=-1),0!==n)break}return n}function te(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let r=0;r<e.position.length;r++)if(!ej(e.position[r],t.position[r]))return!1;return!0}/**
437 * @license
438 * Copyright 2022 Google LLC
439 *
440 * Licensed under the Apache License, Version 2.0 (the "License");
441 * you may not use this file except in compliance with the License.
442 * You may obtain a copy of the License at
443 *
444 *   http://www.apache.org/licenses/LICENSE-2.0
445 *
446 * Unless required by applicable law or agreed to in writing, software
447 * distributed under the License is distributed on an "AS IS" BASIS,
448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449 * See the License for the specific language governing permissions and
450 * limitations under the License.
451 */class tt{constructor(e,t="asc"){this.field=e,this.dir=t}}/**
452 * @license
453 * Copyright 2022 Google LLC
454 *
455 * Licensed under the Apache License, Version 2.0 (the "License");
456 * you may not use this file except in compliance with the License.
457 * You may obtain a copy of the License at
458 *
459 *   http://www.apache.org/licenses/LICENSE-2.0
460 *
461 * Unless required by applicable law or agreed to in writing, software
462 * distributed under the License is distributed on an "AS IS" BASIS,
463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464 * See the License for the specific language governing permissions and
465 * limitations under the License.
466 */class tr{}class tn extends tr{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new to(e,t,r):"array-contains"===t?new tc(e,r):"in"===t?new td(e,r):"not-in"===t?new tf(e,r):"array-contains-any"===t?new tm(e,r):new tn(e,t,r)}static createKeyFieldInFilter(e,t,r){return"in"===t?new tl(e,r):new tu(e,r)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(eQ(t,this.value)):null!==t&&eG(this.value)===eG(t)&&this.matchesComparison(eQ(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 S(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class ti extends tr{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new ti(e,t)}matches(e){return ts(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Pe||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function ts(e){return"and"===e.op}function ta(e){for(let t of e.filters)if(t instanceof ti)return!1;return!0}class to extends tn{constructor(e,t,r){super(e,t,r),this.key=H.fromName(r.referenceValue)}matches(e){let t=H.comparator(e.key,this.key);return this.matchesComparison(t)}}class tl extends tn{constructor(e,t){super(e,"in",t),this.keys=th("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class tu extends tn{constructor(e,t){super(e,"not-in",t),this.keys=th("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function th(e,t){return(t.arrayValue?.values||[]).map(e=>H.fromName(e.referenceValue))}class tc extends tn{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return eZ(t)&&eK(t.arrayValue,this.value)}}class td extends tn{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&eK(this.value.arrayValue,t)}}class tf extends tn{constructor(e,t){super(e,"not-in",t)}matches(e){if(eK(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!eK(this.value.arrayValue,t)}}class tm extends tn{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!eZ(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>eK(this.value.arrayValue,e))}}/**
467 * @license
468 * Copyright 2019 Google LLC
469 *
470 * Licensed under the Apache License, Version 2.0 (the "License");
471 * you may not use this file except in compliance with the License.
472 * You may obtain a copy of the License at
473 *
474 *   http://www.apache.org/licenses/LICENSE-2.0
475 *
476 * Unless required by applicable law or agreed to in writing, software
477 * distributed under the License is distributed on an "AS IS" BASIS,
478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479 * See the License for the specific language governing permissions and
480 * limitations under the License.
481 */class tp{constructor(e,t=null,r=[],n=[],i=null,s=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=i,this.startAt=s,this.endAt=a,this.Te=null}}function tg(e,t=null,r=[],n=[],i=null,s=null,a=null){return new tp(e,t,r,n,i,s,a)}function ty(e){if(null===e.Te){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:"+e.filters.map(e=>(function e(t){if(t instanceof tn)return t.field.canonicalString()+t.op.toString()+eY(t.value);if(ta(t)&&ts(t))return t.filters.map(t=>e(t)).join(",");{let r=t.filters.map(t=>e(t)).join(",");return`${t.op}(${r})`}})(e)).join(",")+"|ob:"+e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),ed(e.limit)||(t+="|l:"+e.limit),e.startAt&&(t+="|lb:"+(e.startAt.inclusive?"b:":"a:")+e.startAt.position.map(e=>eY(e)).join(",")),e.endAt&&(t+="|ub:"+(e.endAt.inclusive?"a:":"b:")+e.endAt.position.map(e=>eY(e)).join(",")),e.Te=t}return e.Te}function tw(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++){var r,n;if(r=e.orderBy[i],n=t.orderBy[i],!(r.dir===n.dir&&r.field.isEqual(n.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let r=0;r<e.filters.length;r++)if(!function e(t,r){return t instanceof tn?r instanceof tn&&t.op===r.op&&t.field.isEqual(r.field)&&ej(t.value,r.value):t instanceof ti?r instanceof ti&&t.op===r.op&&t.filters.length===r.filters.length&&t.filters.reduce((t,n,i)=>t&&e(n,r.filters[i]),!0):void S(19439)}(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!te(e.startAt,t.startAt)&&te(e.endAt,t.endAt)}function tv(e){return H.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}/**
482 * @license
483 * Copyright 2017 Google LLC
484 *
485 * Licensed under the Apache License, Version 2.0 (the "License");
486 * you may not use this file except in compliance with the License.
487 * You may obtain a copy of the License at
488 *
489 *   http://www.apache.org/licenses/LICENSE-2.0
490 *
491 * Unless required by applicable law or agreed to in writing, software
492 * distributed under the License is distributed on an "AS IS" BASIS,
493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494 * See the License for the specific language governing permissions and
495 * limitations under the License.
496 */class t_{constructor(e,t=null,r=[],n=[],i=null,s="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=i,this.limitType=s,this.startAt=a,this.endAt=o,this.Ie=null,this.Ee=null,this.de=null,this.startAt,this.endAt}}function tE(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 tT(e){return null!==e.collectionGroup}function tI(e){if(null===e.Ie){let t;e.Ie=[];let r=new Set;for(let t of e.explicitOrderBy)e.Ie.push(t),r.add(t.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(t=new e_(Q.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{r.has(t.canonicalString())||t.isKeyField()||e.Ie.push(new tt(t,n))}),r.has(Q.keyField().canonicalString())||e.Ie.push(new tt(Q.keyField(),n))}return e.Ie}function tS(e){return e.Ee||(e.Ee=function(e,t){if("F"===e.limitType)return tg(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new tt(e.field,t)});let r=e.endAt?new e8(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new e8(e.startAt.position,e.startAt.inclusive):null;return tg(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)}}(e,tI(e))),e.Ee}function tC(e,t){let r=e.filters.concat([t]);return new t_(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)}function tN(e,t,r){return new t_(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function tA(e,t){return tw(tS(e),tS(t))&&e.limitType===t.limitType}function tb(e){return`${ty(tS(e))}|lt:${e.limitType}`}function tD(e){var t;let r;return`Query(target=${r=(t=tS(e)).path.canonicalString(),null!==t.collectionGroup&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof tn?`${t.field.canonicalString()} ${t.op} ${eY(t.value)}`:t instanceof ti?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),ed(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(r+=", startAt: "+(t.startAt.inclusive?"b:":"a:")+t.startAt.position.map(e=>eY(e)).join(",")),t.endAt&&(r+=", endAt: "+(t.endAt.inclusive?"a:":"b:")+t.endAt.position.map(e=>eY(e)).join(",")),`Target(${r})`}; limitType=${e.limitType})`}function tk(e,t){return t.isFoundDocument()&&function(e,t){let r=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(r):H.isDocumentKey(e.path)?e.path.isEqual(r):e.path.isImmediateParentOf(r)}(e,t)&&function(e,t){for(let r of tI(e))if(!r.field.isKeyField()&&null===t.data.field(r.field))return!1;return!0}(e,t)&&function(e,t){for(let r of e.filters)if(!r.matches(t))return!1;return!0}(e,t)&&(!e.startAt||!!function(e,t,r){let n=e7(e,t,r);return e.inclusive?n<=0:n<0}(e.startAt,tI(e),t))&&(!e.endAt||!!function(e,t,r){let n=e7(e,t,r);return e.inclusive?n>=0:n>0}(e.endAt,tI(e),t))}function tR(e){return(t,r)=>{let n=!1;for(let i of tI(e)){let e=function(e,t,r){let n=e.field.isKeyField()?H.comparator(t.key,r.key):function(e,t,r){let n=t.data.field(e),i=r.data.field(e);return null!==n&&null!==i?eQ(n,i):S(42886)}(e.field,t,r);switch(e.dir){case"asc":return n;
496case"desc":return -1*n;default:return S(19790,{direction:e.dir})}}(i,t,r);if(0!==e)return e;n=n||i.field.isKeyField()}return 0}}/**
497 * @license
498 * Copyright 2017 Google LLC
499 *
500 * Licensed under the Apache License, Version 2.0 (the "License");
501 * you may not use this file except in compliance with the License.
502 * You may obtain a copy of the License at
503 *
504 *   http://www.apache.org/licenses/LICENSE-2.0
505 *
506 * Unless required by applicable law or agreed to in writing, software
507 * distributed under the License is distributed on an "AS IS" BASIS,
508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509 * See the License for the specific language governing permissions and
510 * limitations under the License.
511 */class tx{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0!==r){for(let[t,n]of r)if(this.equalsFn(t,e))return n}}has(e){return void 0!==this.get(e)}set(e,t){let r=this.mapKeyFn(e),n=this.inner[r];if(void 0===n)return this.inner[r]=[[e,t]],void this.innerSize++;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return void(n[r]=[e,t]);n.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0===r)return!1;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return 1===r.length?delete this.inner[t]:r.splice(n,1),this.innerSize--,!0;return!1}forEach(e){ep(this.inner,(t,r)=>{for(let[t,n]of r)e(t,n)})}isEmpty(){return eg(this.inner)}size(){return this.innerSize}}/**
512 * @license
513 * Copyright 2017 Google LLC
514 *
515 * Licensed under the Apache License, Version 2.0 (the "License");
516 * you may not use this file except in compliance with the License.
517 * You may obtain a copy of the License at
518 *
519 *   http://www.apache.org/licenses/LICENSE-2.0
520 *
521 * Unless required by applicable law or agreed to in writing, software
522 * distributed under the License is distributed on an "AS IS" BASIS,
523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524 * See the License for the specific language governing permissions and
525 * limitations under the License.
526 */let tV=new ey(H.comparator),tM=new ey(H.comparator);function tL(...e){let t=tM;for(let r of e)t=t.insert(r.key,r);return t}function tO(e){let t=tM;return e.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t}function tF(){return new tx(e=>e.toString(),(e,t)=>e.isEqual(t))}let tP=new ey(H.comparator),tU=new e_(H.comparator);function tq(...e){let t=tU;for(let r of e)t=t.add(r);return t}let tz=new e_(U);/**
527 * @license
528 * Copyright 2020 Google LLC
529 *
530 * Licensed under the Apache License, Version 2.0 (the "License");
531 * you may not use this file except in compliance with the License.
532 * You may obtain a copy of the License at
533 *
534 *   http://www.apache.org/licenses/LICENSE-2.0
535 *
536 * Unless required by applicable law or agreed to in writing, software
537 * distributed under the License is distributed on an "AS IS" BASIS,
538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539 * See the License for the specific language governing permissions and
540 * limitations under the License.
541 */function tB(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:ef(t)?"-0":t}}function t$(e){return{integerValue:""+e}}function tG(e,t){return"number"==typeof t&&Number.isInteger(t)&&!ef(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?t$(t):tB(e,t)}/**
542 * @license
543 * Copyright 2018 Google LLC
544 *
545 * Licensed under the Apache License, Version 2.0 (the "License");
546 * you may not use this file except in compliance with the License.
547 * You may obtain a copy of the License at
548 *
549 *   http://www.apache.org/licenses/LICENSE-2.0
550 *
551 * Unless required by applicable law or agreed to in writing, software
552 * distributed under the License is distributed on an "AS IS" BASIS,
553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554 * See the License for the specific language governing permissions and
555 * limitations under the License.
556 */class tj{constructor(){this._=void 0}}function tK(e,t){return e instanceof tJ?eJ(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class tQ extends tj{}class tH extends tj{constructor(e){super(),this.elements=e}}function tW(e,t){let r=t0(t);for(let t of e.elements)r.some(e=>ej(e,t))||r.push(t);return{arrayValue:{values:r}}}class tY extends tj{constructor(e){super(),this.elements=e}}function tX(e,t){let r=t0(t);for(let t of e.elements)r=r.filter(e=>!ej(e,t));return{arrayValue:{values:r}}}
556class tJ extends tj{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function tZ(e){return eA(e.integerValue||e.doubleValue)}function t0(e){return eZ(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}/**
557 * @license
558 * Copyright 2017 Google LLC
559 *
560 * Licensed under the Apache License, Version 2.0 (the "License");
561 * you may not use this file except in compliance with the License.
562 * You may obtain a copy of the License at
563 *
564 *   http://www.apache.org/licenses/LICENSE-2.0
565 *
566 * Unless required by applicable law or agreed to in writing, software
567 * distributed under the License is distributed on an "AS IS" BASIS,
568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
569 * See the License for the specific language governing permissions and
570 * limitations under the License.
571 */class t1{constructor(e,t){this.field=e,this.transform=t}}class t2{constructor(e,t){this.version=e,this.transformResults=t}}class t3{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new t3}static exists(e){return new t3(void 0,e)}static updateTime(e){return new t3(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 t4(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class t9{}function t6(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new ri(e.key,t3.none()):new t7(e.key,e.data,t3.none());{let r=e.data,n=e6.empty(),i=new e_(Q.comparator);for(let e of t.fields)if(!i.has(e)){let t=r.field(e);null===t&&e.length>1&&(e=e.popLast(),t=r.field(e)),null===t?n.delete(e):n.set(e,t),i=i.add(e)}return new re(e.key,n,new eT(i.toArray()),t3.none())}}function t5(e,t,r,n){return e instanceof t7?function(e,t,r,n){if(!t4(e.precondition,t))return r;let i=e.value.clone(),s=rn(e.fieldTransforms,n,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,r,n):e instanceof re?function(e,t,r,n){if(!t4(e.precondition,t))return r;let i=rn(e.fieldTransforms,n,t),s=t.data;return(s.setAll(rt(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===r)?null:r.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,r,n):t4(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):r}function t8(e,t){var r,n;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(r=e.fieldTransforms,n=t.fieldTransforms,!!(void 0===r&&void 0===n||!(!r||!n)&&B(r,n,(e,t)=>{var r,n;return e.field.isEqual(t.field)&&(r=e.transform,n=t.transform,r instanceof tH&&n instanceof tH||r instanceof tY&&n instanceof tY?B(r.elements,n.elements,ej):r instanceof tJ&&n instanceof tJ?ej(r.Ae,n.Ae):r instanceof tQ&&n instanceof tQ)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class t7 extends t9{constructor(e,t,r,n=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=n,this.type=0}getFieldMask(){return null}}class re extends t9{constructor(e,t,r,n,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function rt(e){let t=new Map;return e.fieldMask.fields.forEach(r=>{if(!r.isEmpty()){let n=e.data.field(r);t.set(r,n)}}),t}function rr(e,t,r){let n=new Map;N(e.length===r.length,32656,{Re:r.length,Ve:e.length});for(let s=0;s<r.length;s++){var i;let a=e[s],o=a.transform,l=t.data.field(a.field);n.set(a.field,(i=r[s],o instanceof tH?tW(o,l):o instanceof tY?tX(o,l):i))}return n}function rn(e,t,r){let n=new Map;for(let i of e){let e=i.transform,s=r.data.field(i.field);n.set(i.field,e instanceof tQ?function(e,t){let r={fields:{[ek]:{stringValue:eD},[ex]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&eV(t)&&(t=eM(t)),t&&(r.fields[eR]=t),{mapValue:r}}(t,s):e instanceof tH?tW(e,s):e instanceof tY?tX(e,s):function(e,t){let r=tK(e,t),n=tZ(r)+tZ(e.Ae);return eJ(r)&&eJ(e.Ae)?t$(n):tB(e.serializer,n)}(e,s))}return n}class ri extends t9{constructor(e,t){super(),this.key=e,this.prec
571ondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rs extends t9{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
572 * @license
573 * Copyright 2017 Google LLC
574 *
575 * Licensed under the Apache License, Version 2.0 (the "License");
576 * you may not use this file except in compliance with the License.
577 * You may obtain a copy of the License at
578 *
579 *   http://www.apache.org/licenses/LICENSE-2.0
580 *
581 * Unless required by applicable law or agreed to in writing, software
582 * distributed under the License is distributed on an "AS IS" BASIS,
583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
584 * See the License for the specific language governing permissions and
585 * limitations under the License.
586 */class ra{constructor(e,t,r,n){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=n}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let i=this.mutations[t];if(i.key.isEqual(e.key)){var n;n=r[t],i instanceof t7?function(e,t,r){let n=e.value.clone(),i=rr(e.fieldTransforms,t,r.transformResults);n.setAll(i),t.convertToFoundDocument(r.version,n).setHasCommittedMutations()}(i,e,n):i instanceof re?function(e,t,r){if(!t4(e.precondition,t))return void t.convertToUnknownDocument(r.version);let n=rr(e.fieldTransforms,t,r.transformResults),i=t.data;i.setAll(rt(e)),i.setAll(n),t.convertToFoundDocument(r.version,i).setHasCommittedMutations()}(i,e,n):function(e,t,r){t.convertToNoDocument(r.version).setHasCommittedMutations()}(0,e,n)}}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=t5(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=t5(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=tF();return this.mutations.forEach(n=>{let i=e.get(n.key),s=i.overlayedDocument,a=this.applyToLocalView(s,i.mutatedFields),o=t6(s,a=t.has(n.key)?null:a);null!==o&&r.set(n.key,o),s.isValidDocument()||s.convertToNoDocument(ei.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),tq())}isEqual(e){return this.batchId===e.batchId&&B(this.mutations,e.mutations,(e,t)=>t8(e,t))&&B(this.baseMutations,e.baseMutations,(e,t)=>t8(e,t))}}class ro{constructor(e,t,r,n){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=n}static from(e,t,r){N(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let n=tP,i=e.mutations;for(let e=0;e<i.length;e++)n=n.insert(i[e].key,r[e].version);return new ro(e,t,r,n)}}/**
587 * @license
588 * Copyright 2022 Google LLC
589 *
590 * Licensed under the Apache License, Version 2.0 (the "License");
591 * you may not use this file except in compliance with the License.
592 * You may obtain a copy of the License at
593 *
594 *   http://www.apache.org/licenses/LICENSE-2.0
595 *
596 * Unless required by applicable law or agreed to in writing, software
597 * distributed under the License is distributed on an "AS IS" BASIS,
598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599 * See the License for the specific language governing permissions and
600 * limitations under the License.
601 */class rl{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{
602      largestBatchId: ${this.largestBatchId},
603      mutation: ${this.mutation.toString()}
604    }`}}/**
605 * @license
606 * Copyright 2017 Google LLC
607 *
608 * Licensed under the Apache License, Version 2.0 (the "License");
609 * you may not use this file except in compliance with the License.
610 * You may obtain a copy of the License at
611 *
612 *   http://www.apache.org/licenses/LICENSE-2.0
613 *
614 * Unless required by applicable law or agreed to in writing, software
615 * distributed under the License is distributed on an "AS IS" BASIS,
616 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
617 * See the License for the specific language governing permissions and
618 * limitations under the License.
619 */class ru{constructor(e,t){this.count=e,this.unchangedNames=t}}function rh(e){switch(e){case A.OK:return S(64938);case A.CANCELLED:case A.UNKNOWN:case A.DEADLINE_EXCEEDED:case A.RESOURCE_EXHAUSTED:case A.INTERNAL:case A.UNAVAILABLE:case A.UNAUTHENTICATED:return!1;case A.INVALID_ARGUMENT:case A.NOT_FOUND:case A.ALREADY_EXISTS:case A.PERMISSION_DENIED:case A.FAILED_PRECONDITION:case A.ABORTED:case A.OUT_OF_RANGE:case A.UNIMPLEMENT
619ED:case A.DATA_LOSS:return!0;default:return S(15467,{code:e})}}function rc(e){if(void 0===e)return E("GRPC error has no .code"),A.UNKNOWN;switch(e){case n.OK:return A.OK;case n.CANCELLED:return A.CANCELLED;case n.UNKNOWN:return A.UNKNOWN;case n.DEADLINE_EXCEEDED:return A.DEADLINE_EXCEEDED;case n.RESOURCE_EXHAUSTED:return A.RESOURCE_EXHAUSTED;case n.INTERNAL:return A.INTERNAL;case n.UNAVAILABLE:return A.UNAVAILABLE;case n.UNAUTHENTICATED:return A.UNAUTHENTICATED;case n.INVALID_ARGUMENT:return A.INVALID_ARGUMENT;case n.NOT_FOUND:return A.NOT_FOUND;case n.ALREADY_EXISTS:return A.ALREADY_EXISTS;case n.PERMISSION_DENIED:return A.PERMISSION_DENIED;case n.FAILED_PRECONDITION:return A.FAILED_PRECONDITION;case n.ABORTED:return A.ABORTED;case n.OUT_OF_RANGE:return A.OUT_OF_RANGE;case n.UNIMPLEMENTED:return A.UNIMPLEMENTED;case n.DATA_LOSS:return A.DATA_LOSS;default:return S(39323,{code:e})}}(i=n||(n={}))[i.OK=0]="OK",i[i.CANCELLED=1]="CANCELLED",i[i.UNKNOWN=2]="UNKNOWN",i[i.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",i[i.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",i[i.NOT_FOUND=5]="NOT_FOUND",i[i.ALREADY_EXISTS=6]="ALREADY_EXISTS",i[i.PERMISSION_DENIED=7]="PERMISSION_DENIED",i[i.UNAUTHENTICATED=16]="UNAUTHENTICATED",i[i.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",i[i.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",i[i.ABORTED=10]="ABORTED",i[i.OUT_OF_RANGE=11]="OUT_OF_RANGE",i[i.UNIMPLEMENTED=12]="UNIMPLEMENTED",i[i.INTERNAL=13]="INTERNAL",i[i.UNAVAILABLE=14]="UNAVAILABLE",i[i.DATA_LOSS=15]="DATA_LOSS";/**
620 * @license
621 * Copyright 2022 Google LLC
622 *
623 * Licensed under the Apache License, Version 2.0 (the "License");
624 * you may not use this file except in compliance with the License.
625 * You may obtain a copy of the License at
626 *
627 *   http://www.apache.org/licenses/LICENSE-2.0
628 *
629 * Unless required by applicable law or agreed to in writing, software
630 * distributed under the License is distributed on an "AS IS" BASIS,
631 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
632 * See the License for the specific language governing permissions and
633 * limitations under the License.
634 */let rd=new c.z8([4294967295,4294967295],0);function rf(e){let t=(new TextEncoder).encode(e),r=new c.V8;return r.update(t),new Uint8Array(r.digest())}function rm(e){let t=new DataView(e.buffer),r=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new c.z8([r,n],0),new c.z8([i,s],0)]}class rp{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new rg(`Invalid padding: ${t}`);if(r<0||e.length>0&&0===this.hashCount)throw new rg(`Invalid hash count: ${r}`);if(0===e.length&&0!==t)throw new rg(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=c.z8.fromNumber(this.ge)}ye(e,t,r){let n=e.add(t.multiply(c.z8.fromNumber(r)));return 1===n.compare(rd)&&(n=new c.z8([n.getBits(0),n.getBits(1)],0)),n.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;let[t,r]=rm(rf(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);if(!this.we(n))return!1}return!0}static create(e,t,r){let n=new rp(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);return r.forEach(e=>n.insert(e)),n}insert(e){if(0===this.ge)return;let[t,r]=rm(rf(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);this.Se(n)}}Se(e){this.bitmap[Math.floor(e/8)]|=1<<e%8}}class rg extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
635 * @license
636 * Copyright 2017 Google LLC
637 *
638 * Licensed under the Apache License, Version 2.0 (the "License");
639 * you may not use this file except in compliance with the License.
640 * You may obtain a copy of the License at
641 *
642 *   http://www.apache.org/licenses/LICENSE-2.0
643 *
644 * Unless required by applicable law or agreed to in writing, software
645 * distributed under the License is distributed on an "AS IS" BASIS,
646 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
647 * See the License for the specific language governing permissions and
648 * limitations under the License.
649 */class ry{constructor(e,t,r,n,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let n=new Map;return n.set(e,rw.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new ry(ei.min(),n,new ey(U),tV,tq())}}class rw{constructor(e,t,r,n,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new rw(r,t,tq(),tq(),tq())}}/**
650 * @license
651 * Copyright 2017 Google LLC
652 *
653 * Licensed under the Apache License, Version 2.0 (the "License");
654 * you may not use this file except in compliance with the License.
655 * You may obtain a copy of the License at
656 *
657 *   http://www.apache.org/licenses/LICENSE-2.0
658 *
659 * Unless required by applicable law or agreed to in writing, software
660 * distributed under the License is distributed on an "AS IS" BASIS,
661 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
662 * See the License for the specific language governing permissions and
663 * limitations under the License.
664 */class rv{constructor(e,t,r,n){this.be=e,this.removedTargetIds=t,this.key=r,this.De=n}}class r_{constructor(e,t){this.targetId=e,this.Ce=t}}class rE{constructor(e,t,r=eS.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class rT{constructor(){this.ve=0,this.Fe=rC(),this.Me=eS.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return 0!==this.ve}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=tq(),t=tq(),r=tq();return this.Fe.forEach((n,i)=>{switch(i){case 0:e=e.add(n);break;case 2:t=t.add(n);break;case 1:r=r.add(n);break;default:S(38017,{changeType:i})}}),new rw(this.Me,this.xe,e,t,r)}qe(){this.Oe=!1,this.Fe=rC()}Qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}$e(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}Ue(){this.ve+=1}Ke(){this.ve-=1,N(this.ve>=0,3241,{ve:this.ve})}We(){this.Oe=!0,this.xe=!0}}class rI{constructor(e){this.Ge=e,this.ze=new Map,this.je=tV,this.Je=rS(),this.He=rS(),this.Ye=new ey(U)}Ze(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Xe(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{let r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.Ke(),r.Ne||r.qe(),r.Le(e.resumeToken);break;case 2:r.Ke(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.We(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:S(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((e,r)=>{this.rt(r)&&t(r)})}st(e){let t=e.targetId,r=e.Ce.count,n=this.ot(t);if(n){let i=n.target;
664if(tv(i)){if(0===r){let e=new H(i.path);this.et(t,e,e5.newNoDocument(e,ei.min()))}else N(1===r,20013,{expectedCount:r})}else{let n=this._t(t);if(n!==r){let r=this.ut(e),i=r?this.ct(r,e,n):1;0!==i&&(this.it(t),this.Ye=this.Ye.insert(t,2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch"))}}}}ut(e){let t,r;let n=e.Ce.unchangedNames;if(!n||!n.bits)return null;let{bits:{bitmap:i="",padding:s=0},hashCount:a=0}=n;try{t=eb(i).toUint8Array()}catch(e){if(e instanceof eI)return T("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{r=new rp(t,s,a)}catch(e){return T(e instanceof rg?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===r.ge?null:r}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){let r=this.Ge.getRemoteKeysForTarget(t),n=0;return r.forEach(r=>{let i=this.Ge.ht(),s=`projects/${i.projectId}/databases/${i.database}/documents/${r.path.canonicalString()}`;e.mightContain(s)||(this.et(t,r,null),n++)}),n}Tt(e){let t=new Map;this.ze.forEach((r,n)=>{let i=this.ot(n);if(i){if(r.current&&tv(i.target)){let t=new H(i.target.path);this.It(t).has(n)||this.Et(n,t)||this.et(n,t,e5.newNoDocument(t,e))}r.Be&&(t.set(n,r.ke()),r.qe())}});let r=tq();this.He.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{let t=this.ot(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(n=!1,!1)}),n&&(r=r.add(e))}),this.je.forEach((t,r)=>r.setReadTime(e));let n=new ry(e,t,this.Ye,this.je,r);return this.je=tV,this.Je=rS(),this.He=rS(),this.Ye=new ey(U),n}Xe(e,t){if(!this.rt(e))return;let r=this.Et(e,t.key)?2:0;this.nt(e).Qe(t.key,r),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.He=this.He.insert(t.key,this.dt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;let n=this.nt(e);this.Et(e,t)?n.Qe(t,1):n.$e(t),this.He=this.He.insert(t,this.dt(t).delete(e)),this.He=this.He.insert(t,this.dt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){let t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ue(e){this.nt(e).Ue()}nt(e){let t=this.ze.get(e);return t||(t=new rT,this.ze.set(e,t)),t}dt(e){let t=this.He.get(e);return t||(t=new e_(U),this.He=this.He.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new e_(U),this.Je=this.Je.insert(e,t)),t}rt(e){let t=null!==this.ot(e);return t||_("WatchChangeAggregator","Detected inactive target",e),t}ot(e){let t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new rT),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function rS(){return new ey(H.comparator)}function rC(){return new ey(H.comparator)}let rN={asc:"ASCENDING",desc:"DESCENDING"},rA={"<":"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"},rb={and:"AND",or:"OR"};class rD{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function rk(e,t){return e.useProto3Json||ed(t)?t:{value:t}}function rR(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 rx(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function rV(e){return N(!!e,49232),ei.fromTimestamp(function(e){let t=eN(e);return new en(t.seconds,t.nanos)}(e))}function rM(e,t){return rL(e,t).canonicalString()}function rL(e,t){let r=new j(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function rO(e){let t=j.fromString(e);return N(rK(t),10190,{key:t.toString()}),t}function rF(e,t){return rM(e.databaseId,t.path)}function rP(e,t){let r=rO(t);if(r.get(1)!==e.databaseId.projectId)throw new b(A.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+r.get(1)+" vs "+e.databaseId.projectId);if(r.get(3)!==e.databaseId.database)throw new b(A.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new H(rz(r))}function rU(e,t){return rM(e.databaseId,t)}function rq(e){return new j(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function rz(e){return N(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function rB(e,t,r){return{name:rF(e,t),fields:r.value.mapValue.fields}}function r$(e,t){var r;let n;if(t instanceof t7)n={update:rB(e,t.key,t.value)};else if(t instanceof ri)n={delete:rF(e,t.key)};else if(t instanceof re)n={update:rB(e,t.key,t.data),updateMask:function(e){let t=[];
664return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}(t.fieldMask)};else{if(!(t instanceof rs))return S(16599,{Vt:t.type});n={verify:rF(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(e=>(function(e,t){let r=t.transform;if(r instanceof tQ)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(r instanceof tH)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:r.elements}};if(r instanceof tY)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:r.elements}};if(r instanceof tJ)return{fieldPath:t.field.canonicalString(),increment:r.Ae};throw S(20930,{transform:t.transform})})(0,e))),t.precondition.isNone||(n.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:rR(e,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:S(27497)),n}function rG(e){return{fieldPath:e.canonicalString()}}function rj(e){return Q.fromServerFormat(e.fieldPath)}function rK(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}/**
665 * @license
666 * Copyright 2017 Google LLC
667 *
668 * Licensed under the Apache License, Version 2.0 (the "License");
669 * you may not use this file except in compliance with the License.
670 * You may obtain a copy of the License at
671 *
672 *   http://www.apache.org/licenses/LICENSE-2.0
673 *
674 * Unless required by applicable law or agreed to in writing, software
675 * distributed under the License is distributed on an "AS IS" BASIS,
676 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
677 * See the License for the specific language governing permissions and
678 * limitations under the License.
679 */class rQ{constructor(e,t,r,n,i=ei.min(),s=ei.min(),a=eS.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new rQ(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new rQ(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new rQ(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new rQ(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
680 * @license
681 * Copyright 2017 Google LLC
682 *
683 * Licensed under the Apache License, Version 2.0 (the "License");
684 * you may not use this file except in compliance with the License.
685 * You may obtain a copy of the License at
686 *
687 *   http://www.apache.org/licenses/LICENSE-2.0
688 *
689 * Unless required by applicable law or agreed to in writing, software
690 * distributed under the License is distributed on an "AS IS" BASIS,
691 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
692 * See the License for the specific language governing permissions and
693 * limitations under the License.
694 */class rH{constructor(e){this.yt=e}}/**
695 * @license
696 * Copyright 2021 Google LLC
697 *
698 * Licensed under the Apache License, Version 2.0 (the "License");
699 * you may not use this file except in compliance with the License.
700 * You may obtain a copy of the License at
701 *
702 *   http://www.apache.org/licenses/LICENSE-2.0
703 *
704 * Unless required by applicable law or agreed to in writing, software
705 * distributed under the License is distributed on an "AS IS" BASIS,
706 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
707 * See the License for the specific language governing permissions and
708 * limitations under the License.
709 */class rW{constructor(){}Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if("nullValue"in e)this.Ft(t,5);else if("booleanValue"in e)this.Ft(t,10),t.Mt(e.booleanValue?1:0);else if("integerValue"in e)this.Ft(t,15),t.Mt(eA(e.integerValue));else if("doubleValue"in e){let r=eA(e.doubleValue);isNaN(r)?this.Ft(t,13):(this.Ft(t,15),ef(r)?t.Mt(0):t.Mt(r))}else if("timestampValue"in e){let r=e.timestampValue;this.Ft(t,20),"string"==typeof r&&(r=eN(r)),t.xt(`${r.seconds||""}`),t.Mt(r.nanos||0)}else if("stringValue"in e)this.Ot(e.stringValue,t),this.Nt(t);else if("bytesValue"in e)this.Ft(t,30),t.Bt(eb(e.bytesValue)),this.Nt(t);else if("referenceValue"in e)this.Lt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.Ft(t,45),t.Mt(r.latitude||0),t.Mt(r.longitude||0)}else"mapValue"in e?e9(e)?this.Ft(t,Number.MAX_SAFE_INTEGER):e3(e)?this.kt(e.mapValue,t):(this.qt(e.mapValue,t),this.Nt(t)):"arrayValue"in e?(this.Qt(e.arrayValue,t),this.Nt(t)):S(19022,{$t:e})}Ot(e,t){this.Ft(t,25),this.Ut(e,t)}Ut(e,t){t.xt(e)}qt(e,t){let r=e.fields||{};for(let e of(this.Ft(t,55),Object.keys(r)))this.Ot(e,t),this.Ct(r[e],t)}kt(e,t){let r=e.fields||{};this.Ft(t,53);let n=r[e$].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(eA(n)),this.Ot(e$,t),this.Ct(r[e$],t)}Qt(e,t){let r=e.values||[];for(let e of(this.Ft(t,50),r))this.Ct(e,t)}
vendor: 4,399 bytes, lines 709-773
709Lt(e,t){this.Ft(t,37),H.fromName(e).path.forEach(e=>{this.Ft(t,60),this.Ut(e,t)})}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}}rW.Kt=new rW;/**
710 * @license
711 * Copyright 2019 Google LLC
712 *
713 * Licensed under the Apache License, Version 2.0 (the "License");
714 * you may not use this file except in compliance with the License.
715 * You may obtain a copy of the License at
716 *
717 *   http://www.apache.org/licenses/LICENSE-2.0
718 *
719 * Unless required by applicable law or agreed to in writing, software
720 * distributed under the License is distributed on an "AS IS" BASIS,
721 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
722 * See the License for the specific language governing permissions and
723 * limitations under the License.
724 */class rY{constructor(){this.Cn=new rX}addToCollectionParentIndex(e,t){return this.Cn.add(t),eu.resolve()}getCollectionParents(e,t){return eu.resolve(this.Cn.getEntries(t))}addFieldIndex(e,t){return eu.resolve()}deleteFieldIndex(e,t){return eu.resolve()}deleteAllFieldIndexes(e){return eu.resolve()}createTargetIndexes(e,t){return eu.resolve()}getDocumentsMatchingTarget(e,t){return eu.resolve(null)}getIndexType(e,t){return eu.resolve(0)}getFieldIndexes(e,t){return eu.resolve([])}getNextCollectionGroupToUpdate(e){return eu.resolve(null)}getMinOffset(e,t){return eu.resolve(ea.min())}getMinOffsetFromCollectionGroup(e,t){return eu.resolve(ea.min())}updateCollectionGroup(e,t,r){return eu.resolve()}updateIndexEntries(e,t){return eu.resolve()}}class rX{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new e_(j.comparator),i=!n.has(r);return this.index[t]=n.add(r),i}has(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t];return n&&n.has(r)}getEntries(e){return(this.index[e]||new e_(j.comparator)).toArray()}}new Uint8Array(0);/**
725 * @license
726 * Copyright 2018 Google LLC
727 *
728 * Licensed under the Apache License, Version 2.0 (the "License");
729 * you may not use this file except in compliance with the License.
730 * You may obtain a copy of the License at
731 *
732 *   http://www.apache.org/licenses/LICENSE-2.0
733 *
734 * Unless required by applicable law or agreed to in writing, software
735 * distributed under the License is distributed on an "AS IS" BASIS,
736 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
737 * See the License for the specific language governing permissions and
738 * limitations under the License.
739 */let rJ={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class rZ{static withCacheSize(e){return new rZ(e,rZ.DEFAULT_COLLECTION_PERCENTILE,rZ.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}/**
740 * @license
741 * Copyright 2017 Google LLC
742 *
743 * Licensed under the Apache License, Version 2.0 (the "License");
744 * you may not use this file except in compliance with the License.
745 * You may obtain a copy of the License at
746 *
747 *   http://www.apache.org/licenses/LICENSE-2.0
748 *
749 * Unless required by applicable law or agreed to in writing, software
750 * distributed under the License is distributed on an "AS IS" BASIS,
751 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
752 * See the License for the specific language governing permissions and
753 * limitations under the License.
754 */rZ.DEFAULT_COLLECTION_PERCENTILE=10,rZ.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,rZ.DEFAULT=new rZ(41943040,rZ.DEFAULT_COLLECTION_PERCENTILE,rZ.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),rZ.DISABLED=new rZ(-1,0,0);/**
755 * @license
756 * Copyright 2017 Google LLC
757 *
758 * Licensed under the Apache License, Version 2.0 (the "License");
759 * you may not use this file except in compliance with the License.
760 * You may obtain a copy of the License at
761 *
762 *   http://www.apache.org/licenses/LICENSE-2.0
763 *
764 * Unless required by applicable law or agreed to in writing, software
765 * distributed under the License is distributed on an "AS IS" BASIS,
766 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
767 * See the License for the specific language governing permissions and
768 * limitations under the License.
769 */class r0{constructor(e){this.ar=e}next(){return this.ar+=2,this.ar}static ur(){return new r0(0)}static cr(){return new r0(-1)}}/**
770 * @license
771 * Copyright 2020 Google LLC
772 *
773 * Licensed under the Apache License, Version 2.0 (the "License");
774 * you may not use this file except in compliance with the License.
775 * You may obtain a copy of the License at
776 *
777 *   http://www.apache.org/licenses/LICENSE-2.0
778 *
779 * Unless required by applicable law or agreed to in writing, software
780 * distributed under the License is distributed on an "AS IS" BASIS,
781 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
782 * See the License for the specific language governing permissions and
783 * limitations under the License.
784 */let r1="LruGarbageCollector";function r2([e,t],[r,n]){let i=U(e,r);return 0===i?U(t,n):i}class r3{constructor(e){this.Ir=e,this.buffer=new e_(r2),this.Er=0}dr(){return++this.Er}Ar(e){let t=[e,this.dr()];if(this.buffer.size<this.Ir)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>r2(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class r4{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Vr(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return null!==this.Rr}Vr(e){_(r1,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){eh(e)?_(r1,"Ignoring IndexedDB error during garbage collection: ",e):await el(e)}await this.Vr(3e5)})}}class r9{constructor(e,t){this.mr=e,this.params=t}calculateTargetCount(e,t){return this.mr.gr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return eu.resolve(ec.ce);let r=new r3(t);return this.mr.forEachTarget(e,e=>r.Ar(e.sequenceNumber)).next(()=>this.mr.pr(e,e=>r.Ar(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.mr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.mr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(_("LruGarbageCollector","Garbage collection skipped; disabled"),eu.resolve(rJ)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(_("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),rJ):this.yr(e,t))}getCacheSize(e){return this.mr.getCacheSize(e)}yr(e,t){let r,n,i,s,a,o,l;let h=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(_("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),n=this.params.maximumSequenceNumbersToCollect):n=t,s=Date.now(),this.nthSequenceNumber(e,n))).next(n=>(r=n,a=Date.now(),this.removeTargets(e,r,t))).next(t=>(i=t,o=Date.now(),this.removeOrphanedDocuments(e,r))).next(e=>(l=Date.now(),v()<=u.in.DEBUG&&_("LruGarbageCollector",`LRU Garbage Collection
785	Counted targets in ${s-h}ms
786	Determined least recently used ${n} in `+(a-s)+"ms\n"+`	Removed ${i} targets in `+(o-a)+"ms\n"+`	Removed ${e} documents in `+(l-o)+"ms\n"+`Total Duration: ${l-h}ms`),eu.resolve({didRun:!0,sequenceNumbersCollected:n,targetsRemoved:i,documentsRemoved:e})))}}/**
787 * @license
788 * Copyright 2017 Google LLC
789 *
790 * Licensed under the Apache License, Version 2.0 (the "License");
791 * you may not use this file except in compliance with the License.
792 * You may obtain a copy of the License at
793 *
794 *   http://www.apache.org/licenses/LICENSE-2.0
795 *
796 * Unless required by applicable law or agreed to in writing, software
797 * distributed under the License is distributed on an "AS IS" BASIS,
798 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
799 * See the License for the specific language governing permissions and
800 * limitations under the License.
801 */class r6{constructor(){this.changes=new tx(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,e5.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return void 0!==r?eu.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}
801assertNotApplied(){}}/**
802 * @license
803 * Copyright 2017 Google LLC
804 *
805 * Licensed under the Apache License, Version 2.0 (the "License");
806 * you may not use this file except in compliance with the License.
807 * You may obtain a copy of the License at
808 *
809 *   http://www.apache.org/licenses/LICENSE-2.0
810 *
811 * Unless required by applicable law or agreed to in writing, software
812 * distributed under the License is distributed on an "AS IS" BASIS,
813 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
814 * See the License for the specific language governing permissions and
815 * limitations under the License.
816 *//**
817 * @license
818 * Copyright 2022 Google LLC
819 *
820 * Licensed under the Apache License, Version 2.0 (the "License");
821 * you may not use this file except in compliance with the License.
822 * You may obtain a copy of the License at
823 *
824 *   http://www.apache.org/licenses/LICENSE-2.0
825 *
826 * Unless required by applicable law or agreed to in writing, software
827 * distributed under the License is distributed on an "AS IS" BASIS,
828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
829 * See the License for the specific language governing permissions and
830 * limitations under the License.
831 */class r5{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
832 * @license
833 * Copyright 2017 Google LLC
834 *
835 * Licensed under the Apache License, Version 2.0 (the "License");
836 * you may not use this file except in compliance with the License.
837 * You may obtain a copy of the License at
838 *
839 *   http://www.apache.org/licenses/LICENSE-2.0
840 *
841 * Unless required by applicable law or agreed to in writing, software
842 * distributed under the License is distributed on an "AS IS" BASIS,
843 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
844 * See the License for the specific language governing permissions and
845 * limitations under the License.
846 */class r8{constructor(e,t,r,n){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=n}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(n=>(r=n,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==r&&t5(r.mutation,e,eT.empty(),en.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,tq()).next(()=>t))}getLocalViewOfDocuments(e,t,r=tq()){let n=tF();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let t=tL();return e.forEach((e,r)=>{t=t.insert(e,r.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let r=tF();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,tq()))}populateOverlays(e,t,r){let n=[];return r.forEach(e=>{t.has(e)||n.push(e)}),this.documentOverlayCache.getOverlays(e,n).next(e=>{e.forEach((e,r)=>{t.set(e,r)})})}computeViews(e,t,r,n){let i=tV,s=tF(),a=tF();return t.forEach((e,t)=>{let a=r.get(t.key);n.has(t.key)&&(void 0===a||a.mutation instanceof re)?i=i.insert(t.key,t):void 0!==a?(s.set(t.key,a.mutation.getFieldMask()),t5(a.mutation,t,a.mutation.getFieldMask(),en.now())):s.set(t.key,eT.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>a.set(e,new r5(t,s.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let r=tF(),n=new ey((e,t)=>e-t),i=tq();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let i of e)i.keys().forEach(e=>{let s=t.get(e);if(null===s)return;let a=r.get(e)||eT.empty();a=i.applyToLocalView(s,a),r.set(e,a);let o=(n.get(i.batchId)||tq()).add(e);n=n.insert(i.batchId,o)})}).next(()=>{let s=[],a=n.getReverseIterator();for(;a.hasNext();){let n=a.getNext(),o=n.key,l=n.value,u=tF();l.forEach(e=>{if(!i.has(e)){let n=t6(t.get(e),r.get(e));null!==n&&u.set(e,n),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,o,u))}return eu.waitFor(s)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,r,n){return H.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):tT(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,n):this.getDocumentsMatchingCollectionQuery(e,t,r,n)}getNextDocuments(e,t,r,n){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,n).next(i=>{let s=n-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,n-i.size):eu.resolve(tF()),a=-1,o=i;return s.next(t=>eu.forEach(t,(t,r)=>(a<r.largestBatchId&&(a=r.largestBatchId),i.get(t)?eu.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,o,t,tq())).next(e=>({batchId:a,changes:tO(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new H(t)).next(e=>{let t=tL();
846return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,r,n){let i=t.collectionGroup,s=tL();return this.indexManager.getCollectionParents(e,i).next(a=>eu.forEach(a,a=>{let o=new t_(a.child(i),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,o,r,n).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,r,n){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,n))).next(e=>{i.forEach((t,r)=>{let n=r.getKey();null===e.get(n)&&(e=e.insert(n,e5.newInvalidDocument(n)))});let r=tL();return e.forEach((e,n)=>{let s=i.get(e);void 0!==s&&t5(s.mutation,n,eT.empty(),en.now()),tk(t,n)&&(r=r.insert(e,n))}),r})}}/**
847 * @license
848 * Copyright 2020 Google LLC
849 *
850 * Licensed under the Apache License, Version 2.0 (the "License");
851 * you may not use this file except in compliance with the License.
852 * You may obtain a copy of the License at
853 *
854 *   http://www.apache.org/licenses/LICENSE-2.0
855 *
856 * Unless required by applicable law or agreed to in writing, software
857 * distributed under the License is distributed on an "AS IS" BASIS,
858 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
859 * See the License for the specific language governing permissions and
860 * limitations under the License.
861 */class r7{constructor(e){this.serializer=e,this.Lr=new Map,this.kr=new Map}getBundleMetadata(e,t){return eu.resolve(this.Lr.get(t))}saveBundleMetadata(e,t){return this.Lr.set(t.id,{id:t.id,version:t.version,createTime:rV(t.createTime)}),eu.resolve()}getNamedQuery(e,t){return eu.resolve(this.kr.get(t))}saveNamedQuery(e,t){return this.kr.set(t.name,{name:t.name,query:function(e){let t=function(e){var t;let r,n=function(e){let t=rO(e);return 4===t.length?j.emptyPath():rz(t)}(e.parent),i=e.structuredQuery,s=i.from?i.from.length:0,a=null;if(s>0){N(1===s,65062);let e=i.from[0];e.allDescendants?a=e.collectionId:n=n.child(e.collectionId)}let o=[];i.where&&(o=function(e){var t;let r=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=rj(e.unaryFilter.field);return tn.create(t,"==",{doubleValue:NaN});case"IS_NULL":let r=rj(e.unaryFilter.field);return tn.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let n=rj(e.unaryFilter.field);return tn.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=rj(e.unaryFilter.field);return tn.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return S(61313);default:return S(60726)}}(t):void 0!==t.fieldFilter?tn.create(rj(t.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";case"OPERATOR_UNSPECIFIED":return S(58110);default:return S(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?ti.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return S(1026)}}(t.compositeFilter.op)):S(30097,{filter:t})}(e);return r instanceof ti&&ta(t=r)&&ts(t)?r.getFilters():[r]}(i.where));let l=[];i.orderBy&&(l=i.orderBy.map(e=>new tt(rj(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let u=null;i.limit&&(u=ed(r="object"==typeof(t=i.limit)?t.value:t)?null:r);let h=null;i.startAt&&(h=function(e){let t=!!e.before;return new e8(e.values||[],t)}(i.startAt));let c=null;return i.endAt&&(c=function(e){let t=!e.before;return new e8(e.values||[],t)}(i.endAt)),new t_(n,a,l,o,u,"F",h,c)}({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?tN(t,t.limit,"L"):t}(t.bundledQuery),readTime:rV(t.readTime)}),eu.resolve()}}/**
862 * @license
863 * Copyright 2022 Google LLC
864 *
865 * Licensed under the Apache License, Version 2.0 (the "License");
866 * you may not use this file except in compliance with the License.
867 * You may obtain a copy of the License at
868 *
869 *   http://www.apache.org/licenses/LICENSE-2.0
870 *
871 * Unless required by applicable law or agreed to in writing, software
872 * distributed under the License is distributed on an "AS IS" BASIS,
873 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
874 * See the License for the specific language governing permissions and
875 * limitations under the License.
876 */class ne{constructor(){this.overlays=new ey(H.comparator),this.qr=new Map}getOverlay(e,t){return eu.resolve(this.overlays.get(t))}getOverlays(e,t){let r=tF();return eu.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((r,n)=>{this.St(e,t,n)}),eu.resolve()}removeOverlaysForBatchId(e,t,r){let n=this.qr.get(r);return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.qr.delete(r)),eu.resolve()}getOverlaysForCollection(e,t,r){let n=tF(),i=t.length+1,s=new H(t.child("")),a=this.overlays.getIteratorFrom(s);for(;a.hasNext();){let e=a.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>r&&n.set(e.getKey(),e)}return eu.resolve(n)}getOverlaysForCollectionGroup(e,t,r,n){let i=new ey((e,t)=>e-t),s=this.overlays.getIterator();for(;s.hasNext();){let e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>r){let t=i.get(e.largestBatchId);null===t&&(t=tF(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=tF(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=n)););return eu.resolve(a)}St(e,t,r){let n=this.overlays.get(r.key);if(null!==n){let e=this.qr.get(n.largestBatchId).delete(r.key);this.qr.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new rl(t,r));let i=this.qr.get(t);void 0===i&&(i=tq(),this.qr.set(t,i)),this.qr.set(t,i.add(r.key))}}/**
877 * @license
878 * Copyright 2024 Google LLC
879 *
880 * Licensed under the Apache License, Version 2.0 (the "License");
881 * you may not use this file except in compliance with the License.
882 * You may obtain a copy of the License at
883 *
884 *   http://www.apache.org/licenses/LICENSE-2.0
885 *
886 * Unless required by applicable law or agreed to in writing, software
887 * distributed under the License is distributed on an "AS IS" BASIS,
888 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
889 * See the License for the specific language governing permissions and
890 * limitations under the License.
891 */class nt{constructor(){this.sessionToken=eS.EMPTY_BYTE_STRING}getSessionToken(e){return eu.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,eu.resolve()}}/**
892 * @license
893 * Copyright 2017 Google LLC
894 *
895 * Licensed under the Apache License, Version 2.0 (the "License");
896 * you may not use this file except in compliance with the License.
897 * You may obtain a copy of the License at
898 *
899 *   http://www.apache.org/licenses/LICENSE-2.0
900 *
901 * Unless required by applicable law or agreed to in writing, software
902 * distributed under the License is distributed on an "AS IS" BASIS,
903 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
904 * See the License for the specific language governing permissions and
905 * limitations under the License.
906 */class nr{constructor(){this.Qr=new e_(nn.$r),this.Ur=new e_(nn.Kr)}isEmpty(){return this.Qr.isEmpty()}addReference(e,t){let r=new nn(e,t);this.Qr=this.Qr.add(r),this.Ur=this.Ur.add(r)}Wr(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Gr(new nn(e,t))}zr(e,t){e.forEach(e=>this.removeReference(e,t))}jr(e){let t=new H(new j([])),r=new nn(t,e),n=new nn(t,e+1),i=[];return this.Ur.forEachInRange([r,n],e=>{this.Gr(e),i.push(e.key)}),i}Jr(){this.Qr.forEach(e=>this.Gr(e))}Gr(e){this.Qr=this.Qr.delete(e),this.Ur=this.Ur.delete(e)}Hr(e){let t=new H(new j([])),r=new nn(t,e),n=new nn(t,e+1),i=tq();return this.Ur.forEachInRange([r,n],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new nn(e,0),r=this.Qr.firstAfterOrEqual(t);return null!==r&&e.isEqual(r.key)}}class nn{constructor(e,t){this.key=e,this.Yr=t}static $r(e,t){return H.comparator(e.key,t.key)||U(e.Yr,t.Yr)}static Kr(e,t){return U(e.Yr,t.Yr)||H.comparator(e.key,t.key)}}/**
907 * @license
908 * Copyright 2017 Google LLC
909 *
910 * Licensed under the Apache License, Version 2.0 (the "License");
911 * you may not use this file except in compliance with the License.
912 * You may obtain a copy of the License at
913 *
914 *   http://www.apache.org/licenses/LICENSE-2.0
915 *
916 * Unless required by applicable law or agreed to in writing, software
917 * distributed under the License is distributed on an "AS IS" BASIS,
918 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
919 * See the License for the specific language governing permissions and
920 * limitations under the License.
921 */class ni{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.tr=1,this.Zr=new e_(nn.$r)}checkEmpty(e){return eu.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){let i=this.tr;this.tr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new ra(i,t,r,n);for(let t of(this.mutationQueue.push(s),n))this.Zr=this.Zr.add(new nn(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return eu.resolve(s)}lookupMutationBatch(e,t){return eu.resolve(this.Xr(t))}getNextMutationBatchAfterBatchId(e,t){let r=this.ei(t+1),n=r<0?0:r;return eu.resolve(this.mutationQueue.length>n?this.mutationQueue[n]:null)}getHighestUnacknowledgedBatchId(){return eu.resolve(0===this.mutationQueue.length?-1:this.tr-1)}getAllMutationBatches(e){return eu.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new nn(t,0),n=new nn(t,Number.POSITIVE_INFINITY),i=[];return this.Zr.forEachInRange([r,n],e=>{let t=this.Xr(e.Yr);i.push(t)}),eu.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new e_(U);return t.forEach(e=>{let t=new nn(e,0),n=new nn(e,Number.POSITIVE_INFINITY);this.Zr.forEachInRange([t,n],e=>{r=r.add(e.Yr)})}),eu.resolve(this.ti(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=r;H.isDocumentKey(i)||(i=i.child(""));let s=new nn(new H(i),0),a=new e_(U);return this.Zr.forEachWhile(e=>{let t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.Yr)),!0)},s),eu.resolve(this.ti(a))}ti(e){let t=[];return e.forEach(e=>{let r=this.Xr(e);null!==r&&t.push(r)}),t}removeMutationBatch(e,t){N(0===this.ni(t.batchId,"removed"),55003),this.mutationQueue.shift();let r=this.Zr;return eu.forEach(t.mutations,n=>{let i=new nn(n.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,n.key)}).next(()=>{this.Zr=r})}ir(e){}containsKey(e,t){let r=new nn(t,0),n=this.Zr.firstAfterOrEqual(r);return eu.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.mutationQueue.length,eu.resolve()}ni(e,t){return this.ei(e)}ei(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Xr(e){let t=this.ei(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
922 * @license
923 * Copyright 2017 Google LLC
924 *
925 * Licensed under the Apache License, Version 2.0 (the "License");
926 * you may not use this file except in compliance with the License.
927 * You may obtain a copy of the License at
928 *
929 *   http://www.apache.org/licenses/LICENSE-2.0
930 *
931 * Unless required by applicable law or agreed to in writing, software
932 * distributed under the License is distributed on an "AS IS" BASIS,
933 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
934 * See the License for the specific language governing permissions and
935 * limitations under the License.
936 */class ns{constructor(e){this.ri=e,this.docs=new ey(H.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,n=this.docs.get(r),i=n?n.size:0,s=this.ri(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return eu.resolve(r?r.document.mutableCopy():e5.newInvalidDocument(t))}getEntries(e,t){let r=tV;return t.forEach(e=>{let t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():e5.newInvalidDocument(e))}),eu.resolve(r)}getDocumentsMatchingQuery(e,t,r,n){let i=tV,s=t.path,a=new H(s.child("__id-9223372036854775808__")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:e,value:{document:a}}=o.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||0>=function(e,t){let r=e.readTime.compareTo(t.readTime);return 0!==r?r:0!==(r=H.comparator(e.documentKey,t.documentKey))?r:U(e.largestBatchId,t.largestBatchId)}(new ea(a.readTime,a.key,-1),r)||(n.has(a.key)||tk(t,a))&&(i=i.insert(a.key,a.mutableCopy()))}return eu.resolve(i)}getAllFromCollectionGroup(e,t,r,n){S(9500)}ii(e,t){return eu.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new na(this)}getSize(e){return eu.resolve(this.size)}}class na extends r6{constructor(e){super(),this.Nr=e}applyChanges(e){let t=[];
vendor: 4,907 bytes, lines 936-966
936return this.changes.forEach((r,n)=>{n.isValidDocument()?t.push(this.Nr.addEntry(e,n)):this.Nr.removeEntry(r)}),eu.waitFor(t)}getFromCache(e,t){return this.Nr.getEntry(e,t)}getAllFromCache(e,t){return this.Nr.getEntries(e,t)}}/**
937 * @license
938 * Copyright 2017 Google LLC
939 *
940 * Licensed under the Apache License, Version 2.0 (the "License");
941 * you may not use this file except in compliance with the License.
942 * You may obtain a copy of the License at
943 *
944 *   http://www.apache.org/licenses/LICENSE-2.0
945 *
946 * Unless required by applicable law or agreed to in writing, software
947 * distributed under the License is distributed on an "AS IS" BASIS,
948 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
949 * See the License for the specific language governing permissions and
950 * limitations under the License.
951 */class no{constructor(e){this.persistence=e,this.si=new tx(e=>ty(e),tw),this.lastRemoteSnapshotVersion=ei.min(),this.highestTargetId=0,this.oi=0,this._i=new nr,this.targetCount=0,this.ai=r0.ur()}forEachTarget(e,t){return this.si.forEach((e,r)=>t(r)),eu.resolve()}getLastRemoteSnapshotVersion(e){return eu.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return eu.resolve(this.oi)}allocateTargetId(e){return this.highestTargetId=this.ai.next(),eu.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.oi&&(this.oi=t),eu.resolve()}Pr(e){this.si.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.ai=new r0(t),this.highestTargetId=t),e.sequenceNumber>this.oi&&(this.oi=e.sequenceNumber)}addTargetData(e,t){return this.Pr(t),this.targetCount+=1,eu.resolve()}updateTargetData(e,t){return this.Pr(t),eu.resolve()}removeTargetData(e,t){return this.si.delete(t.target),this._i.jr(t.targetId),this.targetCount-=1,eu.resolve()}removeTargets(e,t,r){let n=0,i=[];return this.si.forEach((s,a)=>{a.sequenceNumber<=t&&null===r.get(a.targetId)&&(this.si.delete(s),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),n++)}),eu.waitFor(i).next(()=>n)}getTargetCount(e){return eu.resolve(this.targetCount)}getTargetData(e,t){let r=this.si.get(t)||null;return eu.resolve(r)}addMatchingKeys(e,t,r){return this._i.Wr(t,r),eu.resolve()}removeMatchingKeys(e,t,r){this._i.zr(t,r);let n=this.persistence.referenceDelegate,i=[];return n&&t.forEach(t=>{i.push(n.markPotentiallyOrphaned(e,t))}),eu.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this._i.jr(t),eu.resolve()}getMatchingKeysForTargetId(e,t){let r=this._i.Hr(t);return eu.resolve(r)}containsKey(e,t){return eu.resolve(this._i.containsKey(t))}}/**
952 * @license
953 * Copyright 2017 Google LLC
954 *
955 * Licensed under the Apache License, Version 2.0 (the "License");
956 * you may not use this file except in compliance with the License.
957 * You may obtain a copy of the License at
958 *
959 *   http://www.apache.org/licenses/LICENSE-2.0
960 *
961 * Unless required by applicable law or agreed to in writing, software
962 * distributed under the License is distributed on an "AS IS" BASIS,
963 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
964 * See the License for the specific language governing permissions and
965 * limitations under the License.
966 */class nl{constructor(e,t){this.ui={},this.overlays={},this.ci=new ec(0),this.li=!1,this.li=!0,this.hi=new nt,this.referenceDelegate=e(this),this.Pi=new no(this),this.indexManager=new rY,this.remoteDocumentCache=new ns(e=>this.referenceDelegate.Ti(e)),this.serializer=new rH(t),this.Ii=new r7(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.li=!1,Promise.resolve()}get started(){return this.li}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new ne,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.ui[e.toKey()];return r||(r=new ni(t,this.referenceDelegate),this.ui[e.toKey()]=r),r}getGlobalsCache(){return this.hi}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ii}runTransaction(e,t,r){_("MemoryPersistence","Starting transaction:",e);let n=new nu(this.ci.next());return this.referenceDelegate.Ei(),r(n).next(e=>this.referenceDelegate.di(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}Ai(e,t){return eu.or(Object.values(this.ui).map(r=>()=>r.containsKey(e,t)))}}class nu extends eo{constructor(e){super(),this.currentSequenceNumber=e}}class nh{constructor(e){this.persistence=e,this.Ri=new nr,this.Vi=null}static mi(e){return new nh(e)}get fi(){if(this.Vi)return this.Vi;throw S(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.fi.delete(r.toString()),eu.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.fi.add(r.toString()),eu.resolve()}markPotentiallyOrphaned(e,t){return this.fi.add(t.toString()),eu.resolve()}
966removeTarget(e,t){this.Ri.jr(t.targetId).forEach(e=>this.fi.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.fi.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}Ei(){this.Vi=new Set}di(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return eu.forEach(this.fi,r=>{let n=H.fromPath(r);return this.gi(e,n).next(e=>{e||t.removeEntry(n,ei.min())})}).next(()=>(this.Vi=null,t.apply(e)))}updateLimboDocument(e,t){return this.gi(e,t).next(e=>{e?this.fi.delete(t.toString()):this.fi.add(t.toString())})}Ti(e){return 0}gi(e,t){return eu.or([()=>eu.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ai(e,t)])}}class nc{constructor(e,t){this.persistence=e,this.pi=new tx(e=>(function(e){let t="";for(let r=0;r<e.length;r++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let r=t,n=e.length;for(let t=0;t<n;t++){let n=e.charAt(t);switch(n){case"\x00":r+="\x01\x10";break;case"\x01":r+="\x01\x11";break;default:r+=n}}return r}(e.get(r),t);return t+"\x01\x01"})(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=new r9(this,t)}static mi(e,t){return new nc(e,t)}Ei(){}di(e){return eu.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}gr(e){let t=this.wr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}wr(e){let t=0;return this.pr(e,e=>{t++}).next(()=>t)}pr(e,t){return eu.forEach(this.pi,(r,n)=>this.br(e,r,n).next(e=>e?eu.resolve():t(n)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0,n=this.persistence.getRemoteDocumentCache(),i=n.newChangeBuffer();return n.ii(e,n=>this.br(e,n,t).next(e=>{e||(r++,i.removeEntry(n,ei.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.pi.set(t,e.currentSequenceNumber),eu.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.pi.set(r,e.currentSequenceNumber),eu.resolve()}removeReference(e,t,r){return this.pi.set(r,e.currentSequenceNumber),eu.resolve()}updateLimboDocument(e,t){return this.pi.set(t,e.currentSequenceNumber),eu.resolve()}Ti(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(eG(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let r=eM(t);return r?16+e(r):16;case 5:return 2*t.stringValue.length;case 6:return eb(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,r)=>t+e(r),0);case 10:case 11:var n;let i;return n=t.mapValue,i=0,ep(n.fields,(t,r)=>{i+=t.length+e(r)}),i;default:throw S(13486,{value:t})}}(e.data.value)),t}br(e,t,r){return eu.or([()=>this.persistence.Ai(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.pi.get(t);return eu.resolve(void 0!==e&&e>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
967 * @license
968 * Copyright 2017 Google LLC
969 *
970 * Licensed under the Apache License, Version 2.0 (the "License");
971 * you may not use this file except in compliance with the License.
972 * You may obtain a copy of the License at
973 *
974 *   http://www.apache.org/licenses/LICENSE-2.0
975 *
976 * Unless required by applicable law or agreed to in writing, software
977 * distributed under the License is distributed on an "AS IS" BASIS,
978 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
979 * See the License for the specific language governing permissions and
980 * limitations under the License.
981 */class nd{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.Es=r,this.ds=n}static As(e,t){let r=tq(),n=tq();for(let e of t.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:n=n.add(e.doc.key)}return new nd(e,t.fromCache,r,n)}}/**
982 * @license
983 * Copyright 2023 Google LLC
984 *
985 * Licensed under the Apache License, Version 2.0 (the "License");
986 * you may not use this file except in compliance with the License.
987 * You may obtain a copy of the License at
988 *
989 *   http://www.apache.org/licenses/LICENSE-2.0
990 *
991 * Unless required by applicable law or agreed to in writing, software
992 * distributed under the License is distributed on an "AS IS" BASIS,
993 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
994 * See the License for the specific language governing permissions and
995 * limitations under the License.
996 */class nf{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
997 * @license
998 * Copyright 2019 Google LLC
999 *
1000 * Licensed under the Apache License, Version 2.0 (the "License");
1001 * you may not use this file except in compliance with the License.
1002 * You may obtain a copy of the License at
1003 *
1004 *   http://www.apache.org/licenses/LICENSE-2.0
1005 *
1006 * Unless required by applicable law or agreed to in writing, software
1007 * distributed under the License is distributed on an "AS IS" BASIS,
1008 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1009 * See the License for the specific language governing permissions and
1010 * limitations under the License.
1011 */class nm{constructor(){this.Rs=!1,this.Vs=!1,this.fs=100,this.gs=(0,h.G6)()?8:function(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}((0,h.z$)())>0?6:4}initialize(e,t){this.ps=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,n){let i={result:null};return this.ys(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ws(e,t,n,r).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let r=new nf;return this.Ss(e,t,r).next(n=>{if(i.result=n,this.Vs)return this.bs(e,t,r,n.size)})}).next(()=>i.result)}bs(e,t,r,n){return r.documentReadCount<this.fs?(v()<=u.in.DEBUG&&_("QueryEngine","SDK will not create cache indexes for query:",tD(t),"since it only creates cache indexes for collection contains","more than or equal to",this.fs,"documents"),eu.resolve()):(v()<=u.in.DEBUG&&_("QueryEngine","Query:",tD(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.gs*n?(v()<=u.in.DEBUG&&_("QueryEngine","The SDK decides to create cache indexes for query:",tD(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,tS(t))):eu.resolve())}ys(e,t){if(tE(t))return eu.resolve(null);let r=tS(t);return this.indexManager.getIndexType(e,r).next(n=>0===n?null:(null!==t.limit&&1===n&&(r=tS(t=tN(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,r).next(n=>{let i=tq(...n);return this.ps.getDocuments(e,i).next(n=>this.indexManager.getMinOffset(e,r).next(r=>{let s=this.Ds(t,n);return this.Cs(t,s,i,r.readTime)?this.ys(e,tN(t,null,"F")):this.vs(e,s,t,r)}))})))}ws(e,t,r,n){return tE(t)||n.isEqual(ei.min())?eu.resolve(null):this.ps.getDocuments(e,r).next(i=>{let s=this.Ds(t,i);return this.Cs(t,s,r,n)?eu.resolve(null):(v()<=u.in.DEBUG&&_("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),tD(t)),this.vs(e,s,t,function(e,t){let r=e.toTimestamp().seconds,n=e.toTimestamp().nanoseconds+1;return new ea(ei.fromTimestamp(1e9===n?new en(r+1,0):new en(r,n)),H.empty(),-1)}(n,0)).next(e=>e))})}Ds(e,t){let r=new e_(tR(e));return t.forEach((t,n)=>{tk(e,n)&&(r=r.add(n))}),r}Cs(e,t,r,n){if(null===e.limit)return!1;if(r.size!==t.size)return!0;let i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(n)>0)}Ss(e,t,r){return v()<=u.in.DEBUG&&_("QueryEngine","Using full collection scan to execute query:",tD(t)),this.ps.getDocumentsMatchingQuery(e,t,ea.min(),r)}vs(e,t,r,n){return this.ps.getDocumentsMatchingQuery(e,r,n).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}/**
1012 * @license
1013 * Copyright 2020 Google LLC
1014 *
1015 * Licensed under the Apache License, Version 2.0 (the "License");
1016 * you may not use this file except in compliance with the License.
1017 * You may obtain a copy of the License at
1018 *
1019 *   http://www.apache.org/licenses/LICENSE-2.0
1020 *
1021 * Unless required by applicable law or agreed to in writing, softw
1021are
1022 * distributed under the License is distributed on an "AS IS" BASIS,
1023 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1024 * See the License for the specific language governing permissions and
1025 * limitations under the License.
1026 */let np="LocalStore";class ng{constructor(e,t,r,n){this.persistence=e,this.Fs=t,this.serializer=n,this.Ms=new ey(U),this.xs=new tx(e=>ty(e),tw),this.Os=new Map,this.Ns=e.getRemoteDocumentCache(),this.Pi=e.getTargetCache(),this.Ii=e.getBundleCache(),this.Bs(r)}Bs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new r8(this.Ns,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ns.setIndexManager(this.indexManager),this.Fs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ms))}}async function ny(e,t){return await e.persistence.runTransaction("Handle user change","readonly",r=>{let n;return e.mutationQueue.getAllMutationBatches(r).next(i=>(n=i,e.Bs(t),e.mutationQueue.getAllMutationBatches(r))).next(t=>{let i=[],s=[],a=tq();for(let e of n)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(r,a).next(e=>({Ls:e,removedBatchIds:i,addedBatchIds:s}))})})}function nw(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Pi.getLastRemoteSnapshotVersion(t))}async function nv(e,t,r){let n=e.Ms.get(t);try{r||await e.persistence.runTransaction("Release target",r?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,n))}catch(e){if(!eh(e))throw e;_(np,`Failed to update sequence numbers for target ${t}: ${e}`)}e.Ms=e.Ms.remove(t),e.xs.delete(n.target)}function n_(e,t,r){let n=ei.min(),i=tq();return e.persistence.runTransaction("Execute query","readwrite",s=>(function(e,t,r){let n=e.xs.get(r);return void 0!==n?eu.resolve(e.Ms.get(n)):e.Pi.getTargetData(t,r)})(e,s,tS(t)).next(t=>{if(t)return n=t.lastLimboFreeSnapshotVersion,e.Pi.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Fs.getDocumentsMatchingQuery(s,t,r?n:ei.min(),r?i:tq())).next(r=>{var n;let s;return n=t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2)),s=e.Os.get(n)||ei.min(),r.forEach((e,t)=>{t.readTime.compareTo(s)>0&&(s=t.readTime)}),e.Os.set(n,s),{documents:r,Qs:i}}))}class nE{constructor(){this.activeTargetIds=tz}zs(e){this.activeTargetIds=this.activeTargetIds.add(e)}js(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Gs(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class nT{constructor(){this.Mo=new nE,this.xo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Mo.zs(e),this.xo[e]||"not-current"}updateQueryState(e,t,r){this.xo[e]=t}removeLocalQueryTarget(e){this.Mo.js(e)}isLocalQueryTarget(e){return this.Mo.activeTargetIds.has(e)}clearQueryState(e){delete this.xo[e]}getAllActiveQueryTargets(){return this.Mo.activeTargetIds}isActiveQueryTarget(e){return this.Mo.activeTargetIds.has(e)}start(){return this.Mo=new nE,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
1027 * @license
1028 * Copyright 2019 Google LLC
1029 *
1030 * Licensed under the Apache License, Version 2.0 (the "License");
1031 * you may not use this file except in compliance with the License.
1032 * You may obtain a copy of the License at
1033 *
1034 *   http://www.apache.org/licenses/LICENSE-2.0
1035 *
1036 * Unless required by applicable law or agreed to in writing, software
1037 * distributed under the License is distributed on an "AS IS" BASIS,
1038 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1039 * See the License for the specific language governing permissions and
1040 * limitations under the License.
1041 */class nI{Oo(e){}shutdown(){}}/**
1042 * @license
1043 * Copyright 2019 Google LLC
1044 *
1045 * Licensed under the Apache License, Version 2.0 (the "License");
1046 * you may not use this file except in compliance with the License.
1047 * You may obtain a copy of the License at
1048 *
1049 *   http://www.apache.org/licenses/LICENSE-2.0
1050 *
1051 * Unless required by applicable law or agreed to in writing, software
1052 * distributed under the License is distributed on an "AS IS" BASIS,
1053 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1054 * See the License for the specific language governing permissions and
1055 * limitations under the License.
1056 */let nS="ConnectivityMonitor";class nC{constructor(){this.No=()=>this.Bo(),this.Lo=()=>this.ko(),this.qo=[],this.Qo()}Oo(e){this.qo.push(e)}shutdown(){window.removeEventListener("online",this.No),window.removeEventListener("offline",this.Lo)}Qo(){window.addEventListener("online",this.No),window.addEventListener("offline",this.Lo)}Bo(){for(let e of(_(nS,"Network connectivity changed: AVAILABLE"),this.qo))e(0)}ko(){for(let e of(_(nS,"Network connectivity changed: UNAVAILABLE"),this.qo))e(1)}static v(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}/**
1057 * @license
1058 * Copyright 2023 Google LLC
1059 *
1060 * Licensed under the Apache License, Version 2.0 (the "License");
1061 * you may not use this file except in compliance with the License.
1062 * You may obtain a copy of the License at
1063 *
1064 *   http://www.apache.org/licenses/LICENSE-2.0
1065 *
1066 * Unless required by applicable law or agreed to in writing, software
1067 * distributed under the License is distributed on an "AS IS" BASIS,
1068 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1069 * See the License for the specific language governing permissions and
1070 * limitations under the License.
1071 */let nN=null;function nA(){return null===nN?nN=268435456+Math.round(2147483648*Math.random()):nN++,"0x"+nN.toString(16)}/**
1072 * @license
1073 * Copyright 2020 Google LLC
1074 *
1075 * Licensed under the Apache License, Version 2.0 (the "License");
1076 * you may not use this file except in compliance with the License.
1077 * You may obtain a copy of the License at
1078 *
1079 *   http://www.apache.org/licenses/LICENSE-2.0
1080 *
1081 * Unless required by applicable law or agreed to in writing, software
1082 * distributed under the License is distributed on an "AS IS" BASIS,
1083 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1084 * See the License for the specific language governing permissions and
1085 * limitations under the License.
1086 */let nb="RestConnection",nD={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class nk{get $o(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.Uo=t+"://"+e.host,this.Ko=`projects/${r}/databases/${n}`,this.Wo=this.databaseId.database===eF?`project_id=${r}`:`project_id=${r}&database_id=${n}`}Go(e,t,r,n,i){let s=nA(),a=this.zo(e,t.toUriEncodedString());_(nb,`Sending RPC '${e}' ${s}:`,a,r);let o={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Wo};this.jo(o,n,i);let{host:l}=new URL(a),u=(0,h.Xx)(l);return this.Jo(e,a,o,r,u).then(t=>(_(nb,`Received RPC '${e}' ${s}: `,t),t),t=>{throw T(nb,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",r),t})}Ho(e,t,r,n,i,s){return this.Go(e,t,r,n,i)}jo(e,t,r){e["X-Goog-Api-Client"]="gl-js/ fire/"+y,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,r)=>e[r]=t),r&&r.headers.forEach((t,r)=>e[r]=t)}zo(e,t){let r=nD[e];return`${this.Uo}/v1/${t}:${r}`}terminate(){}}/**
1087 * @license
1088 * Copyright 2017 Google LLC
1089 *
1090 * Licensed under the Apache License, Version 2.0 (the "License");
1091 * you may not use this file except in compliance with the License.
1092 * You may obtain a copy of the License at
1093 *
1094 *   http://www.apache.org/licenses/LICENSE-2.0
1095 *
1096 * Unless required by applicable law or agreed to in writing, software
1097 * distributed under the License is distributed on an "AS IS" BASIS,
1098 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1099 * See the License for the specific language governing permissions and
1100 * limitations under the License.
1101 */class nR{constructor(e){this.Yo=e.Yo,this.Zo=e.Zo}Xo(e){this.e_=e}t_(e){this.n_=e}r_(e){this.i_=e}onMessage(e){this.s_=e}close(){this.Zo()}send(e){this.Yo(e)}
1101o_(){this.e_()}__(){this.n_()}a_(e){this.i_(e)}u_(e){this.s_(e)}}/**
1102 * @license
1103 * Copyright 2017 Google LLC
1104 *
1105 * Licensed under the Apache License, Version 2.0 (the "License");
1106 * you may not use this file except in compliance with the License.
1107 * You may obtain a copy of the License at
1108 *
1109 *   http://www.apache.org/licenses/LICENSE-2.0
1110 *
1111 * Unless required by applicable law or agreed to in writing, software
1112 * distributed under the License is distributed on an "AS IS" BASIS,
1113 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1114 * See the License for the specific language governing permissions and
1115 * limitations under the License.
1116 */let nx="WebChannelConnection";class nV extends nk{constructor(e){super(e),this.c_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Jo(e,t,r,n,i){let s=nA();return new Promise((i,a)=>{let o=new d.JJ;o.setWithCredentials(!0),o.listenOnce(d.tw.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case d.jK.NO_ERROR:let t=o.getResponseJson();_(nx,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(t)),i(t);break;case d.jK.TIMEOUT:_(nx,`RPC '${e}' ${s} timed out`),a(new b(A.DEADLINE_EXCEEDED,"Request time out"));break;case d.jK.HTTP_ERROR:let r=o.getStatus();if(_(nx,`RPC '${e}' ${s} failed with status:`,r,"response text:",o.getResponseText()),r>0){let e=o.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;if(t&&t.status&&t.message){let e=function(e){let t=e.toLowerCase().replace(/_/g,"-");return Object.values(A).indexOf(t)>=0?t:A.UNKNOWN}(t.status);a(new b(e,t.message))}else a(new b(A.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new b(A.UNAVAILABLE,"Connection failed."));break;default:S(9055,{l_:e,streamId:s,h_:o.getLastErrorCode(),P_:o.getLastError()})}}finally{_(nx,`RPC '${e}' ${s} completed.`)}});let l=JSON.stringify(n);_(nx,`RPC '${e}' ${s} sending request:`,n),o.send(t,"POST",l,r,15)})}T_(e,t,r){let i=nA(),s=[this.Uo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=(0,d.UE)(),o=(0,d.FJ)(),l={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},u=this.longPollingOptions.timeoutSeconds;void 0!==u&&(l.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(l.useFetchStreams=!0),this.jo(l.initMessageHeaders,t,r),l.encodeInitMessageHeaders=!0;let h=s.join("");_(nx,`Creating RPC '${e}' stream ${i}: ${h}`,l);let c=a.createWebChannel(h,l);this.I_(c);let f=!1,m=!1,p=new nR({Yo:t=>{m?_(nx,`Not sending because RPC '${e}' stream ${i} is closed:`,t):(f||(_(nx,`Opening RPC '${e}' stream ${i} transport.`),c.open(),f=!0),_(nx,`RPC '${e}' stream ${i} sending:`,t),c.send(t))},Zo:()=>c.close()}),g=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};return g(c,d.ii.EventType.OPEN,()=>{m||(_(nx,`RPC '${e}' stream ${i} transport opened.`),p.o_())}),g(c,d.ii.EventType.CLOSE,()=>{m||(m=!0,_(nx,`RPC '${e}' stream ${i} transport closed`),p.a_(),this.E_(c))}),g(c,d.ii.EventType.ERROR,t=>{m||(m=!0,T(nx,`RPC '${e}' stream ${i} transport errored. Name:`,t.name,"Message:",t.message),p.a_(new b(A.UNAVAILABLE,"The operation could not be completed")))}),g(c,d.ii.EventType.MESSAGE,t=>{if(!m){let r=t.data[0];N(!!r,16349);let s=r?.error||r[0]?.error;if(s){_(nx,`RPC '${e}' stream ${i} received error:`,s);let t=s.status,r=function(e){let t=n[e];if(void 0!==t)return rc(t)}(t),a=s.message;void 0===r&&(r=A.INTERNAL,a="Unknown error status: "+t+" with message "+s.message),m=!0,p.a_(new b(r,a)),c.close()}else _(nx,`RPC '${e}' stream ${i} received:`,r),p.u_(r)}}),g(o,d.ju.STAT_EVENT,t=>{t.stat===d.kN.PROXY?_(nx,`RPC '${e}' stream ${i} detected buffering proxy`):t.stat===d.kN.NOPROXY&&_(nx,`RPC '${e}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{p.__()},0),p}
vendor: 4,442 bytes, lines 1116-1161
1116terminate(){this.c_.forEach(e=>e.close()),this.c_=[]}I_(e){this.c_.push(e)}E_(e){this.c_=this.c_.filter(t=>t===e)}}function nM(){return"undefined"!=typeof document?document:null}/**
1117 * @license
1118 * Copyright 2020 Google LLC
1119 *
1120 * Licensed under the Apache License, Version 2.0 (the "License");
1121 * you may not use this file except in compliance with the License.
1122 * You may obtain a copy of the License at
1123 *
1124 *   http://www.apache.org/licenses/LICENSE-2.0
1125 *
1126 * Unless required by applicable law or agreed to in writing, software
1127 * distributed under the License is distributed on an "AS IS" BASIS,
1128 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1129 * See the License for the specific language governing permissions and
1130 * limitations under the License.
1131 */function nL(e){return new rD(e,!0)}/**
1132 * @license
1133 * Copyright 2017 Google LLC
1134 *
1135 * Licensed under the Apache License, Version 2.0 (the "License");
1136 * you may not use this file except in compliance with the License.
1137 * You may obtain a copy of the License at
1138 *
1139 *   http://www.apache.org/licenses/LICENSE-2.0
1140 *
1141 * Unless required by applicable law or agreed to in writing, software
1142 * distributed under the License is distributed on an "AS IS" BASIS,
1143 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1144 * See the License for the specific language governing permissions and
1145 * limitations under the License.
1146 */class nO{constructor(e,t,r=1e3,n=1.5,i=6e4){this.Mi=e,this.timerId=t,this.d_=r,this.A_=n,this.R_=i,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(e){this.cancel();let t=Math.floor(this.V_+this.y_()),r=Math.max(0,Date.now()-this.f_),n=Math.max(0,t-r);n>0&&_("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,n,()=>(this.f_=Date.now(),e())),this.V_*=this.A_,this.V_<this.d_&&(this.V_=this.d_),this.V_>this.R_&&(this.V_=this.R_)}w_(){null!==this.m_&&(this.m_.skipDelay(),this.m_=null)}cancel(){null!==this.m_&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.V_}}/**
1147 * @license
1148 * Copyright 2017 Google LLC
1149 *
1150 * Licensed under the Apache License, Version 2.0 (the "License");
1151 * you may not use this file except in compliance with the License.
1152 * You may obtain a copy of the License at
1153 *
1154 *   http://www.apache.org/licenses/LICENSE-2.0
1155 *
1156 * Unless required by applicable law or agreed to in writing, software
1157 * distributed under the License is distributed on an "AS IS" BASIS,
1158 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1159 * See the License for the specific language governing permissions and
1160 * limitations under the License.
1161 */let nF="PersistentStream";class nP{constructor(e,t,r,n,i,s,a,o){this.Mi=e,this.S_=r,this.b_=n,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new nO(e,t)}x_(){return 1===this.state||5===this.state||this.O_()}O_(){return 2===this.state||3===this.state}start(){this.F_=0,4!==this.state?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&null===this.C_&&(this.C_=this.Mi.enqueueAfterDelay(this.S_,6e4,()=>this.k_()))}q_(e){this.Q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}Q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.Q_(),this.U_(),this.M_.cancel(),this.D_++,4!==e?this.M_.reset():t&&t.code===A.RESOURCE_EXHAUSTED?(E(t.toString()),E("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===A.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.K_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.r_(t)}K_(){}auth(){this.state=1;let e=this.W_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,r])=>{this.D_===t&&this.G_(e,r)},t=>{e(()=>{let e=new b(A.UNKNOWN,"Fetching auth token failed: "+t.message);return this.z_(e)})})}G_(e,t){let r=this.W_(this.D_);this.stream=this.j_(e,t),this.stream.Xo(()=>{r(()=>this.listener.Xo())}
1161),this.stream.t_(()=>{r(()=>(this.state=2,this.v_=this.Mi.enqueueAfterDelay(this.b_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.t_()))}),this.stream.r_(e=>{r(()=>this.z_(e))}),this.stream.onMessage(e=>{r(()=>1==++this.F_?this.J_(e):this.onNext(e))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return _(nF,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return t=>{this.Mi.enqueueAndForget(()=>this.D_===e?t():(_(nF,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class nU extends nP{constructor(e,t,r,n,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();let t=function(e,t){let r;if("targetChange"in t){var n,i;t.targetChange;let s="NO_CHANGE"===(n=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===n?1:"REMOVE"===n?2:"CURRENT"===n?3:"RESET"===n?4:S(39313,{state:n}),a=t.targetChange.targetIds||[],o=(i=t.targetChange.resumeToken,e.useProto3Json?(N(void 0===i||"string"==typeof i,58123),eS.fromBase64String(i||"")):(N(void 0===i||i instanceof f||i instanceof Uint8Array,16193),eS.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;r=new rE(s,a,o,l&&new b(void 0===l.code?A.UNKNOWN:rc(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let n=t.documentChange;n.document,n.document.name,n.document.updateTime;let i=rP(e,n.document.name),s=rV(n.document.updateTime),a=n.document.createTime?rV(n.document.createTime):ei.min(),o=new e6({mapValue:{fields:n.document.fields}}),l=e5.newFoundDocument(i,s,a,o);r=new rv(n.targetIds||[],n.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let n=t.documentDelete;n.document;let i=rP(e,n.document),s=n.readTime?rV(n.readTime):ei.min(),a=e5.newNoDocument(i,s);r=new rv([],n.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let n=t.documentRemove;n.document;let i=rP(e,n.document);r=new rv([],n.removedTargetIds||[],i,null)}else{if(!("filter"in t))return S(11601,{Rt:t});{t.filter;let e=t.filter;e.targetId;let{count:n=0,unchangedNames:i}=e,s=new ru(n,i);r=new r_(e.targetId,s)}}return r}(this.serializer,e),r=function(e){if(!("targetChange"in e))return ei.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?ei.min():t.readTime?rV(t.readTime):ei.min()}(e);return this.listener.H_(t,r)}Y_(e){let t={};t.database=rq(this.serializer),t.addTarget=function(e,t){let r;let n=t.target;if((r=tv(n)?{documents:{documents:[rU(e,n.path)]}}:{query:function(e,t){var r,n;let i;let s={structuredQuery:{}},a=t.path;null!==t.collectionGroup?(i=a,s.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=a.popLast(),s.structuredQuery.from=[{collectionId:a.lastSegment()}]),s.parent=rU(e,i);let o=function(e){if(0!==e.length)return function e(t){return t instanceof tn?function(e){if("=="===e.op){if(e1(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NAN"}};if(e0(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(e1(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NOT_NAN"}};if(e0(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:rG(e.field),op:rA[e.op],value:e.value}}}(t):t instanceof ti?function(t){let r=t.getFilters().map(t=>e(t));return 1===r.length?r[0]:{compositeFilter:{op:rb[t.op],filters:r}}}(t):S(54877,{filter:t})}(ti.create(e,"and"))}(t.filters);o&&(s.structuredQuery.where=o);let l=function(e){if(0!==e.length)return e.map(e=>({field:rG(e.field),direction:rN[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=rk(e,t.limit);return null!==u&&(s.structuredQuery.limit=u),t.startAt&&(s.structuredQuery.startAt={before:(r=t.startAt).inclusive,values:r.position}),t.endAt&&(s.structuredQuery.endAt={before:!(n=t.endAt).inclusive,values:n.position}),{ft:s,parent:i}}(e,n).ft}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){r.resumeToken=rx(e,t.resumeToken);let n=rk(e,t.expectedCount);null!==n&&(r.expectedCount=n)}else if(t.snapshotVersion.compareTo(ei.min())>0){r.readTime=rR(e,t.snapshotVersion.toTimestamp());let n=rk(e,t.expectedCount);null!==n&&(r.expectedCount=n)}return r}(this.serializer,e);let r=function(e,t){let r=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 S(28987,{purpose:e})}}(t.purpose);return null==r?null:{"goog-listen-tags":r}}(this.serializer,e);r&&(t.labels=r),this.q_(t)}Z_(e){let t={};t.database=rq(this.serializer),t.removeTarget=e,this.q_(t)}}class nq extends nP{constructor(e,t,r,n,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,n,s),this.serializer
1161=i}get X_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}K_(){this.X_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}J_(e){return N(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,N(!e.writeResults||0===e.writeResults.length,55816),this.listener.ta()}onNext(e){var t,r;N(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let n=(t=e.writeResults,r=e.commitTime,t&&t.length>0?(N(void 0!==r,14353),t.map(e=>{let t;return(t=e.updateTime?rV(e.updateTime):rV(r)).isEqual(ei.min())&&(t=rV(r)),new t2(t,e.transformResults||[])})):[]),i=rV(e.commitTime);return this.listener.na(i,n)}ra(){let e={};e.database=rq(this.serializer),this.q_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>r$(this.serializer,e))};this.q_(t)}}/**
1162 * @license
1163 * Copyright 2017 Google LLC
1164 *
1165 * Licensed under the Apache License, Version 2.0 (the "License");
1166 * you may not use this file except in compliance with the License.
1167 * You may obtain a copy of the License at
1168 *
1169 *   http://www.apache.org/licenses/LICENSE-2.0
1170 *
1171 * Unless required by applicable law or agreed to in writing, software
1172 * distributed under the License is distributed on an "AS IS" BASIS,
1173 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1174 * See the License for the specific language governing permissions and
1175 * limitations under the License.
1176 */class nz{}class nB extends nz{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=n,this.ia=!1}sa(){if(this.ia)throw new b(A.FAILED_PRECONDITION,"The client has already been terminated.")}Go(e,t,r,n){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.Go(e,rL(t,r),n,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===A.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new b(A.UNKNOWN,e.toString())})}Ho(e,t,r,n,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.Ho(e,rL(t,r),n,s,a,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===A.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new b(A.UNKNOWN,e.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}class n${constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){0===this.oa&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){"Online"===this.state?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,"Online"===e&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){let t=`Could not reach Cloud Firestore backend. ${e}
1177This 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.aa?(E(t),this.aa=!1):_("OnlineStateTracker",t)}Pa(){null!==this._a&&(this._a.cancel(),this._a=null)}}/**
1178 * @license
1179 * Copyright 2017 Google LLC
1180 *
1181 * Licensed under the Apache License, Version 2.0 (the "License");
1182 * you may not use this file except in compliance with the License.
1183 * You may obtain a copy of the License at
1184 *
1185 *   http://www.apache.org/licenses/LICENSE-2.0
1186 *
1187 * Unless required by applicable law or agreed to in writing, software
1188 * distributed under the License is distributed on an "AS IS" BASIS,
1189 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1190 * See the License for the specific language governing permissions and
1191 * limitations under the License.
1192 */let nG="RemoteStore";class nj{constructor(e,t,r,n,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.da=[],this.Aa=i,this.Aa.Oo(e=>{r.enqueueAndForget(async()=>
1192{n0(this)&&(_(nG,"Restarting streams for network reachability change."),await async function(e){e.Ea.add(4),await nQ(e),e.Ra.set("Unknown"),e.Ea.delete(4),await nK(e)}(this))})}),this.Ra=new n$(r,n)}}async function nK(e){if(n0(e))for(let t of e.da)await t(!0)}async function nQ(e){for(let t of e.da)await t(!1)}function nH(e,t){e.Ia.has(t.targetId)||(e.Ia.set(t.targetId,t),nZ(e)?nJ(e):io(e).O_()&&nY(e,t))}function nW(e,t){let r=io(e);e.Ia.delete(t),r.O_()&&nX(e,t),0===e.Ia.size&&(r.O_()?r.L_():n0(e)&&e.Ra.set("Unknown"))}function nY(e,t){if(e.Va.Ue(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(ei.min())>0){let r=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(r)}io(e).Y_(t)}function nX(e,t){e.Va.Ue(t),io(e).Z_(t)}function nJ(e){e.Va=new rI({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ia.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),io(e).start(),e.Ra.ua()}function nZ(e){return n0(e)&&!io(e).x_()&&e.Ia.size>0}function n0(e){return 0===e.Ea.size}async function n1(e){e.Ra.set("Online")}async function n2(e){e.Ia.forEach((t,r)=>{nY(e,t)})}async function n3(e,t){e.Va=void 0,nZ(e)?(e.Ra.ha(t),nJ(e)):e.Ra.set("Unknown")}async function n4(e,t,r){if(e.Ra.set("Online"),t instanceof rE&&2===t.state&&t.cause)try{await async function(e,t){let r=t.cause;for(let n of t.targetIds)e.Ia.has(n)&&(await e.remoteSyncer.rejectListen(n,r),e.Ia.delete(n),e.Va.removeTarget(n))}(e,t)}catch(r){_(nG,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await n9(e,r)}else if(t instanceof rv?e.Va.Ze(t):t instanceof r_?e.Va.st(t):e.Va.tt(t),!r.isEqual(ei.min()))try{let t=await nw(e.localStore);r.compareTo(t)>=0&&await function(e,t){let r=e.Va.Tt(t);
1192return r.targetChanges.forEach((r,n)=>{if(r.resumeToken.approximateByteSize()>0){let i=e.Ia.get(n);i&&e.Ia.set(n,i.withResumeToken(r.resumeToken,t))}}),r.targetMismatches.forEach((t,r)=>{let n=e.Ia.get(t);if(!n)return;e.Ia.set(t,n.withResumeToken(eS.EMPTY_BYTE_STRING,n.snapshotVersion)),nX(e,t);let i=new rQ(n.target,t,r,n.sequenceNumber);nY(e,i)}),e.remoteSyncer.applyRemoteEvent(r)}(e,r)}catch(t){_(nG,"Failed to raise snapshot:",t),await n9(e,t)}}async function n9(e,t,r){if(!eh(t))throw t;e.Ea.add(1),await nQ(e),e.Ra.set("Offline"),r||(r=()=>nw(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{_(nG,"Retrying IndexedDB access"),await r(),e.Ea.delete(1),await nK(e)})}function n6(e,t){return t().catch(r=>n9(e,r,t))}async function n5(e){let t=il(e),r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:-1;for(;n0(e)&&e.Ta.length<10;)try{let n=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",r=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(r,t)))}(e.localStore,r);if(null===n){0===e.Ta.length&&t.L_();break}r=n.batchId,function(e,t){e.Ta.push(t);let r=il(e);r.O_()&&r.X_&&r.ea(t.mutations)}(e,n)}catch(t){await n9(e,t)}n8(e)&&n7(e)}function n8(e){return n0(e)&&!il(e).x_()&&e.Ta.length>0}function n7(e){il(e).start()}async function ie(e){il(e).ra()}async function it(e){let t=il(e);for(let r of e.Ta)t.ea(r.mutations)}async function ir(e,t,r){let n=e.Ta.shift(),i=ro.from(n,t,r);await n6(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await n5(e)}async function ii(e,t){t&&il(e).X_&&await async function(e,t){var r;if(rh(r=t.code)&&r!==A.ABORTED){let r=e.Ta.shift();il(e).B_(),await n6(e,()=>e.remoteSyncer.rejectFailedWrite(r.batchId,t)),await n5(e)}}(e,t),n8(e)&&n7(e)}async function is(e,t){e.asyncQueue.verifyOperationInProgress(),_(nG,"RemoteStore received new credentials");let r=n0(e);e.Ea.add(3),await nQ(e),r&&e.Ra.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ea.delete(3),await nK(e)}async function ia(e,t){t?(e.Ea.delete(2),await nK(e)):t||(e.Ea.add(2),await nQ(e),e.Ra.set("Unknown"))}function io(e){var t,r,n;return e.ma||(e.ma=(t=e.datastore,r=e.asyncQueue,n={Xo:n1.bind(null,e),t_:n2.bind(null,e),r_:n3.bind(null,e),H_:n4.bind(null,e)},t.sa(),new nU(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n)),e.da.push(async t=>{t?(e.ma.B_(),nZ(e)?nJ(e):e.Ra.set("Unknown")):(await e.ma.stop(),e.Va=void 0)})),e.ma}function il(e){var t,r,n;return e.fa||(e.fa=(t=e.datastore,r=e.asyncQueue,n={Xo:()=>Promise.resolve(),t_:ie.bind(null,e),r_:ii.bind(null,e),ta:it.bind(null,e),na:ir.bind(null,e)},t.sa(),new nq(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n)),e.da.push(async t=>{t?(e.fa.B_(),await n5(e)):(await e.fa.stop(),e.Ta.length>0&&(_(nG,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))})),e.fa}/**
1193 * @license
1194 * Copyright 2017 Google LLC
1195 *
1196 * Licensed under the Apache License, Version 2.0 (the "License");
1197 * you may not use this file except in compliance with the License.
1198 * You may obtain a copy of the License at
1199 *
1200 *   http://www.apache.org/licenses/LICENSE-2.0
1201 *
1202 * Unless required by applicable law or agreed to in writing, software
1203 * distributed under the License is distributed on an "AS IS" BASIS,
1204 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1205 * See the License for the specific language governing permissions and
1206 * limitations under the License.
1207 */class iu{constructor(e,t,r,n,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=i,this.deferred=new D,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,r,n,i){let s=new iu(e,t,Date.now()+r,n,i);return s.start(r),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new b(A.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 ih(e,t){if(E("AsyncQueue",`${t}: ${e}`),eh(e))return new b(A.UNAVAILABLE,`${t}: ${e}`);throw e}/**
1208 * @license
1209 * Copyright 2017 Google LLC
1210 *
1211 * Licensed under the Apache License, Version 2.0 (the "License");
1212 * you may not use this file except in compliance with the License.
1213 * You may obtain a copy of the License at
1214 *
1215 *   http://www.apache.org/licenses/LICENSE-2.0
1216 *
1217 * Unless required by applicable law or agreed to in writing, software
1218 * distributed under the License is distributed on an "AS IS" BASIS,
1219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1220 * See the License for the specific language governing permissions and
1221 * limitations under the License.
1222 */class ic{static emptySet(e){return new ic(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||H.comparator(t.key,r.key):(e,t)=>H.comparator(e.key,t.key),this.keyedMap=tL(),this.sortedSet=new ey(this.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){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof ic)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(!e.isEqual(n))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){let r=new ic;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
1223 * @license
1224 * Copyright 2017 Google LLC
1225 *
1226 * Licensed under the Apache License, Version 2.0 (the "License");
1227 * you may not use this file except in compliance with the License.
1228 * You may obtain a copy of the License at
1229 *
1230 *   http://www.apache.org/licenses/LICENSE-2.0
1231 *
1232 * Unless required by applicable law or agreed to in writing, software
1233 * distributed under the License is distributed on an "AS IS" BASIS,
1234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1235 * See the License for the specific language governing permissions and
1236 * limitations under the License.
1237 */class id{constructor(){this.ga=new ey(H.comparator)}track(e){let t=e.doc.key,r=this.ga.get(t);r?0!==e.type&&3===r.type?this.ga=this.ga.insert(t,e):3===e.type&&1!==r.type?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.ga=this.ga.remove(t):1===e.type&&2===r.type?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):S(63341,{Rt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal((t,r)=>{e.push(r)}),e}}class im{constructor(e,t,r,n,i,s,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,i){let s=[];return t.forEach(e=>{s.push({type:0,doc:e})}),new im(e,t,ic.emptySet(t),s,r,n,!0,!1,i)}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)&&tA(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==r[e].type||!t[e].doc.isEqual(r[e].doc))return!1;return!0}}/**
1238 * @license
1239 * Copyright 2017 Google LLC
1240 *
1241 * Licensed under the Apache License, Version 2.0 (the "License");
1242 * you may not use this file except in compliance with the License.
1243 * You may obtain a copy of the License at
1244 *
1245 *   http://www.apache.org/licenses/LICENSE-2.0
1246 *
1247 * Unless required by applicable law or agreed to in writing, softw
1247are
1248 * distributed under the License is distributed on an "AS IS" BASIS,
1249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1250 * See the License for the specific language governing permissions and
1251 * limitations under the License.
1252 */class ip{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some(e=>e.Da())}}class ig{constructor(){this.queries=iy(),this.onlineState="Unknown",this.Ca=new Set}terminate(){!function(e,t){let r=e.queries;e.queries=iy(),r.forEach((e,r)=>{for(let e of r.Sa)e.onError(t)})}(this,new b(A.ABORTED,"Firestore shutting down"))}}function iy(){return new tx(e=>tb(e),tA)}async function iw(e,t){let r=3,n=t.query,i=e.queries.get(n);i?!i.ba()&&t.Da()&&(r=2):(i=new ip,r=t.Da()?0:1);try{switch(r){case 0:i.wa=await e.onListen(n,!0);break;case 1:i.wa=await e.onListen(n,!1);break;case 2:await e.onFirstRemoteStoreListen(n)}}catch(r){let e=ih(r,`Initialization of query '${tD(t.query)}' failed`);return void t.onError(e)}e.queries.set(n,i),i.Sa.push(t),t.va(e.onlineState),i.wa&&t.Fa(i.wa)&&iT(e)}async function iv(e,t){let r=t.query,n=3,i=e.queries.get(r);if(i){let e=i.Sa.indexOf(t);e>=0&&(i.Sa.splice(e,1),0===i.Sa.length?n=t.Da()?0:1:!i.ba()&&t.Da()&&(n=2))}switch(n){case 0:return e.queries.delete(r),e.onUnlisten(r,!0);case 1:return e.queries.delete(r),e.onUnlisten(r,!1);case 2:return e.onLastRemoteStoreUnlisten(r);default:return}}function i_(e,t){let r=!1;for(let n of t){let t=n.query,i=e.queries.get(t);if(i){for(let e of i.Sa)e.Fa(n)&&(r=!0);i.wa=n}}r&&iT(e)}function iE(e,t,r){let n=e.queries.get(t);if(n)for(let e of n.Sa)e.onError(r);e.queries.delete(t)}function iT(e){e.Ca.forEach(e=>{e.next()})}(a=s||(s={})).Ma="default",a.Cache="cache";class iI{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){let t=[];for(let r of e.docChanges)3!==r.type&&t.push(r);e=new im(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){return!(e.fromCache&&this.Da())||(!this.options.qa||!("Offline"!==t))&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Ba(e){if(e.docChanges.length>0)return!0;let t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=im.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==s.Cache}}/**
1253 * @license
1254 * Copyright 2017 Google LLC
1255 *
1256 * Licensed under the Apache License, Version 2.0 (the "License");
1257 * you may not use this file except in compliance with the License.
1258 * You may obtain a copy of the License at
1259 *
1260 *   http://www.apache.org/licenses/LICENSE-2.0
1261 *
1262 * Unless required by applicable law or agreed to in writing, software
1263 * distributed under the License is distributed on an "AS IS" BASIS,
1264 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1265 * See the License for the specific language governing permissions and
1266 * limitations under the License.
1267 */class iS{constructor(e){this.key=e}}class iC{constructor(e){this.key=e}}class iN{constructor(e,t){this.query=e,this.Ya=t,this.Za=null,this.hasCachedResults=!1,this.current=!1,this.Xa=tq(),this.mutatedKeys=tq(),this.eu=tR(e),this.tu=new ic(this.eu)}get nu(){return this.Ya}ru(e,t){let r=t?t.iu:new id,n=t?t.tu:this.tu,i=t?t.mutatedKeys:this.mutatedKeys,s=n,a=!1,o="F"===this.query.limitType&&n.size===this.query.limit?n.last():null,l="L"===this.query.limitType&&n.size===this.query.limit?n.first():null;if(e.inorderTraversal((e,t)=>{let u=n.get(e),h=tk(this.query,t)?t:null,c=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations),f=!1;u&&h?u.data.isEqual(h.data)?c!==d&&(r.track({type:3,doc:h}),f=!0):this.su(u,h)||(r.track({type:2,doc:h}),f=!0,(o&&this.eu(h,o)>0||l&&0>this.eu(h,l))&&(a=!0)):!u&&h?(r.track({type:0,doc:h}),f=!0):u&&!h&&(r.track({type:1,doc:u}),f=!0,(o||l)&&(a=!0)),f&&(h?(s=s.add(h),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;
1267){let e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),r.track({type:1,doc:e})}return{tu:s,iu:r,Cs:a,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){let i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;let s=e.iu.ya();s.sort((e,t)=>(function(e,t){let r=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return S(20277,{Rt:e})}};return r(e)-r(t)})(e.type,t.type)||this.eu(e.doc,t.doc)),this.ou(r),n=n??!1;let a=t&&!n?this._u():[],o=0===this.Xa.size&&this.current&&!n?1:0,l=o!==this.Za;return(this.Za=o,0!==s.length||l)?{snapshot:new im(this.query,e.tu,i,s,e.mutatedKeys,0===o,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:a}:{au:a}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({tu:this.tu,iu:new id,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{au:[]}}uu(e){return!this.Ya.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(e=>this.Ya=this.Ya.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ya=this.Ya.delete(e)),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Xa;this.Xa=tq(),this.tu.forEach(e=>{this.uu(e.key)&&(this.Xa=this.Xa.add(e.key))});let t=[];return e.forEach(e=>{this.Xa.has(e)||t.push(new iC(e))}),this.Xa.forEach(r=>{e.has(r)||t.push(new iS(r))}),t}cu(e){this.Ya=e.Qs,this.Xa=tq();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return im.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,0===this.Za,this.hasCachedResults)}}let iA="SyncEngine";class ib{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class iD{constructor(e){this.key=e,this.hu=!1}}class ik{constructor(e,t,r,n,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Pu={},this.Tu=new tx(e=>tb(e),tA),this.Iu=new Map,this.Eu=new Set,this.du=new ey(H.comparator),this.Au=new Map,this.Ru=new nr,this.Vu={},this.mu=new Map,this.fu=r0.cr(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return!0===this.gu}}async function iR(e,t,r=!0){let n;let i=iJ(e),s=i.Tu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),n=s.view.lu()):n=await iV(i,t,r,!0),n}async function ix(e,t){let r=iJ(e);await iV(r,t,!0,!1)}async function iV(e,t,r,n){var i,s;let a;let o=await (i=e.localStore,s=tS(t),i.persistence.runTransaction("Allocate target","readwrite",e=>{let t;return i.Pi.getTargetData(e,s).next(r=>r?(t=r,eu.resolve(t)):i.Pi.allocateTargetId(e).next(r=>(t=new rQ(s,r,"TargetPurposeListen",e.currentSequenceNumber),i.Pi.addTargetData(e,t).next(()=>t))))}).then(e=>{let t=i.Ms.get(e.targetId);return(null===t||e.snapshotVersion.compareTo(t.snapshotVersion)>0)&&(i.Ms=i.Ms.insert(e.targetId,e),i.xs.set(s,e.targetId)),e})),l=o.targetId,u=e.sharedClientState.addLocalQueryTarget(l,r);return n&&(a=await iM(e,t,l,"current"===u,o.resumeToken)),e.isPrimaryClient&&r&&nH(e.remoteStore,o),a}async function iM(e,t,r,n,i){e.pu=(t,r,n)=>(async function(e,t,r,n){let i=t.view.ru(r);i.Cs&&(i=await n_(e.localStore,t.query,!1).then(({documents:e})=>t.view.ru(e,i)));let s=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),o=t.view.applyChanges(i,e.isPrimaryClient,s,a);return iQ(e,t.targetId,o.au),o.snapshot})(e,t,r,n);let s=await n_(e.localStore,t,!0),a=new iN(t,s.Qs),o=a.ru(s.documents),l=rw.createSynthesizedTargetChangeForCurrentChange(r,n&&"Offline"!==e.onlineState,i),u=a.applyChanges(o,e.isPrimaryClient,l);iQ(e,r,u.au);let h=new ib(t,r,a);return e.Tu.set(t,h),e.Iu.has(r)?e.Iu.get(r).push(t):e.Iu.set(r,[t]),u.snapshot}async function iL(e,t,r){let n=e.Tu.get(t),i=e.Iu.get(n.targetId);if(i.length>1)return e.Iu.set(n.targetId,i.filter(e=>!tA(e,t))),void e.Tu.delete(t);e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)||await nv(e.localStore,n.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(n.targetId),r&&nW(e.remoteStore,n.targetId),ij(e,n.targetId)}).catch(el)):(ij(e,n.targetId),await nv(e.localStore,n.targetId,!0))}async function iO(e,t){let r=e.Tu.get(t),n=e.Iu.get(r.targetId);
1267e.isPrimaryClient&&1===n.length&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),nW(e.remoteStore,r.targetId))}async function iF(e,t,r){var n;let i=(e.remoteStore.remoteSyncer.applySuccessfulWrite=iz.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=iB.bind(null,e),e);try{let e;let s=await function(e,t){let r,n;let i=en.now(),s=t.reduce((e,t)=>e.add(t.key),tq());return e.persistence.runTransaction("Locally write mutations","readwrite",a=>{let o=tV,l=tq();return e.Ns.getEntries(a,s).next(e=>{(o=e).forEach((e,t)=>{t.isValidDocument()||(l=l.add(e))})}).next(()=>e.localDocuments.getOverlayedDocuments(a,o)).next(n=>{r=n;let s=[];for(let e of t){let t=function(e,t){let r=null;for(let n of e.fieldTransforms){let e=t.data.field(n.field),i=tK(n.transform,e||null);null!=i&&(null===r&&(r=e6.empty()),r.set(n.field,i))}return r||null}(e,r.get(e.key).overlayedDocument);null!=t&&s.push(new re(e.key,t,function e(t){let r=[];return ep(t.fields,(t,n)=>{let i=new Q([t]);if(e2(n)){let t=e(n.mapValue).fields;if(0===t.length)r.push(i);else for(let e of t)r.push(i.child(e))}else r.push(i)}),new eT(r)}(t.value.mapValue),t3.exists(!0)))}return e.mutationQueue.addMutationBatch(a,i,s,t)}).next(t=>{n=t;let i=t.applyToLocalDocumentSet(r,l);return e.documentOverlayCache.saveOverlays(a,t.batchId,i)})}).then(()=>({batchId:n.batchId,changes:tO(r)}))}(i.localStore,t);i.sharedClientState.addPendingMutation(s.batchId),n=s.batchId,(e=i.Vu[i.currentUser.toKey()])||(e=new ey(U)),e=e.insert(n,r),i.Vu[i.currentUser.toKey()]=e,await iW(i,s.changes),await n5(i.remoteStore)}catch(t){let e=ih(t,"Failed to persist write");r.reject(e)}}async function iP(e,t){try{let r=await function(e,t){let r=t.snapshotVersion,n=e.Ms;return e.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{var s;let a,o;let l=e.Ns.newChangeBuffer({trackRemovals:!0});n=e.Ms;let u=[];
1267t.targetChanges.forEach((s,a)=>{var o;let l=n.get(a);if(!l)return;u.push(e.Pi.removeMatchingKeys(i,s.removedDocuments,a).next(()=>e.Pi.addMatchingKeys(i,s.addedDocuments,a)));let h=l.withSequenceNumber(i.currentSequenceNumber);null!==t.targetMismatches.get(a)?h=h.withResumeToken(eS.EMPTY_BYTE_STRING,ei.min()).withLastLimboFreeSnapshotVersion(ei.min()):s.resumeToken.approximateByteSize()>0&&(h=h.withResumeToken(s.resumeToken,r)),n=n.insert(a,h),o=h,(0===l.resumeToken.approximateByteSize()||o.snapshotVersion.toMicroseconds()-l.snapshotVersion.toMicroseconds()>=3e8||s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size>0)&&u.push(e.Pi.updateTargetData(i,h))});let h=tV,c=tq();if(t.documentUpdates.forEach(r=>{t.resolvedLimboDocuments.has(r)&&u.push(e.persistence.referenceDelegate.updateLimboDocument(i,r))}),u.push((s=t.documentUpdates,a=tq(),o=tq(),s.forEach(e=>a=a.add(e)),l.getEntries(i,a).next(e=>{let t=tV;return s.forEach((r,n)=>{let i=e.get(r);n.isFoundDocument()!==i.isFoundDocument()&&(o=o.add(r)),n.isNoDocument()&&n.version.isEqual(ei.min())?(l.removeEntry(r,n.readTime),t=t.insert(r,n)):!i.isValidDocument()||n.version.compareTo(i.version)>0||0===n.version.compareTo(i.version)&&i.hasPendingWrites?(l.addEntry(n),t=t.insert(r,n)):_(np,"Ignoring outdated watch update for ",r,". Current version:",i.version," Watch version:",n.version)}),{ks:t,qs:o}})).next(e=>{h=e.ks,c=e.qs})),!r.isEqual(ei.min())){let t=e.Pi.getLastRemoteSnapshotVersion(i).next(t=>e.Pi.setTargetsMetadata(i,i.currentSequenceNumber,r));u.push(t)}return eu.waitFor(u).next(()=>l.apply(i)).next(()=>e.localDocuments.getLocalViewOfDocuments(i,h,c)).next(()=>h)}).then(t=>(e.Ms=n,t))}(e.localStore,t);
1267t.targetChanges.forEach((t,r)=>{let n=e.Au.get(r);n&&(N(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?n.hu=!0:t.modifiedDocuments.size>0?N(n.hu,14607):t.removedDocuments.size>0&&(N(n.hu,42227),n.hu=!1))}),await iW(e,r,t)}catch(e){await el(e)}}function iU(e,t,r){var n;if(e.isPrimaryClient&&0===r||!e.isPrimaryClient&&1===r){let r;let i=[];e.Tu.forEach((e,r)=>{let n=r.view.va(t);n.snapshot&&i.push(n.snapshot)}),(n=e.eventManager).onlineState=t,r=!1,n.queries.forEach((e,n)=>{for(let e of n.Sa)e.va(t)&&(r=!0)}),r&&iT(n),i.length&&e.Pu.H_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function iq(e,t,r){e.sharedClientState.updateQueryState(t,"rejected",r);let n=e.Au.get(t),i=n&&n.key;if(i){let r=new ey(H.comparator);r=r.insert(i,e5.newNoDocument(i,ei.min()));let n=tq().add(i),s=new ry(ei.min(),new Map,new ey(U),r,n);await iP(e,s),e.du=e.du.remove(i),e.Au.delete(t),iH(e)}else await nv(e.localStore,t,!1).then(()=>ij(e,t,r)).catch(el)}async function iz(e,t){var r;let n=t.batch.batchId;try{let i=await (r=e.localStore).persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let n=t.batch.keys(),i=r.Ns.newChangeBuffer({trackRemovals:!0});return(function(e,t,r,n){let i=r.batch,s=i.keys(),a=eu.resolve();return s.forEach(e=>{a=a.next(()=>n.getEntry(t,e)).next(t=>{let s=r.docVersions.get(e);N(null!==s,48541),0>t.version.compareTo(s)&&(i.applyToRemoteDocument(t,r),t.isValidDocument()&&(t.setReadTime(r.commitVersion),n.addEntry(t)))})}),a.next(()=>e.mutationQueue.removeMutationBatch(t,i))})(r,e,t,i).next(()=>i.apply(e)).next(()=>r.mutationQueue.performConsistencyCheck(e)).next(()=>r.documentOverlayCache.removeOverlaysForBatchId(e,n,t.batch.batchId)).next(()=>r.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=tq();for(let r=0;r<e.mutationResults.length;++r)e.mutationResults[r].transformResults.length>0&&(t=t.add(e.batch.mutations[r].key));return t}(t))).next(()=>r.localDocuments.getDocuments(e,n))});iG(e,n,null),i$(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await iW(e,i)}catch(e){await el(e)}}async function iB(e,t,r){var n;try{let i=await (n=e.localStore).persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;
1267return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(N(null!==t,37113),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))});iG(e,t,r),i$(e,t),e.sharedClientState.updateMutationState(t,"rejected",r),await iW(e,i)}catch(e){await el(e)}}function i$(e,t){(e.mu.get(t)||[]).forEach(e=>{e.resolve()}),e.mu.delete(t)}function iG(e,t,r){let n=e.Vu[e.currentUser.toKey()];if(n){let i=n.get(t);i&&(r?i.reject(r):i.resolve(),n=n.remove(t)),e.Vu[e.currentUser.toKey()]=n}}function ij(e,t,r=null){for(let n of(e.sharedClientState.removeLocalQueryTarget(t),e.Iu.get(t)))e.Tu.delete(n),r&&e.Pu.yu(n,r);e.Iu.delete(t),e.isPrimaryClient&&e.Ru.jr(t).forEach(t=>{e.Ru.containsKey(t)||iK(e,t)})}function iK(e,t){e.Eu.delete(t.path.canonicalString());let r=e.du.get(t);null!==r&&(nW(e.remoteStore,r),e.du=e.du.remove(t),e.Au.delete(r),iH(e))}function iQ(e,t,r){for(let n of r)n instanceof iS?(e.Ru.addReference(n.key,t),function(e,t){let r=t.key,n=r.path.canonicalString();e.du.get(r)||e.Eu.has(n)||(_(iA,"New document in limbo: "+r),e.Eu.add(n),iH(e))}(e,n)):n instanceof iC?(_(iA,"Document no longer in limbo: "+n.key),e.Ru.removeReference(n.key,t),e.Ru.containsKey(n.key)||iK(e,n.key)):S(19791,{wu:n})}function iH(e){for(;e.Eu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){let t=e.Eu.values().next().value;e.Eu.delete(t);let r=new H(j.fromString(t)),n=e.fu.next();e.Au.set(n,new iD(r)),e.du=e.du.insert(r,n),nH(e.remoteStore,new rQ(tS(new t_(r.path)),n,"TargetPurposeLimboResolution",ec.ce))}}async function iW(e,t,r){let n=[],i=[],s=[];e.Tu.isEmpty()||(e.Tu.forEach((a,o)=>{s.push(e.pu(o,t,r).then(t=>{if((t||r)&&e.isPrimaryClient){let n=t?!t.fromCache:r?.targetChanges.get(o.targetId)?.current;e.sharedClientState.updateQueryState(o.targetId,n?"current":"not-current")}if(t){n.push(t);let e=nd.As(o.targetId,t);i.push(e)}}))}),await Promise.all(s),e.Pu.H_(n),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>eu.forEach(t,t=>eu.forEach(t.Es,n=>e.persistence.referenceDelegate.addReference(r,t.targetId,n)).next(()=>eu.forEach(t.ds,n=>e.persistence.referenceDelegate.removeReference(r,t.targetId,n)))))}catch(e){if(!eh(e))throw e;_(np,"Failed to update sequence numbers: "+e)}for(let r of t){let t=r.targetId;if(!r.fromCache){let r=e.Ms.get(t),n=r.snapshotVersion,i=r.withLastLimboFreeSnapshotVersion(n);e.Ms=e.Ms.insert(t,i)}}}(e.localStore,i))}async function iY(e,t){if(!e.currentUser.isEqual(t)){_(iA,"User change. New user:",t.toKey());let r=await ny(e.localStore,t);e.currentUser=t,e.mu.forEach(e=>{e.forEach(e=>{e.reject(new b(A.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.mu.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await iW(e,r.Ls)}}function iX(e,t){let r=e.Au.get(t);if(r&&r.hu)return tq().add(r.key);{let r=tq(),n=e.Iu.get(t);if(!n)return r;for(let t of n){let n=e.Tu.get(t);r=r.unionWith(n.view.nu)}return r}}function iJ(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=iP.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=iX.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=iq.bind(null,e),e.Pu.H_=i_.bind(null,e.eventManager),e.Pu.yu=iE.bind(null,e.eventManager),e}class iZ{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=nL(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){var t;return t=this.persistence,new ng(t,new nm,e.initialUser,this.serializer)}Cu(e){return new nl(nh.mi,this.serializer)}Du(e){return new nT}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedCl
1267ientState.shutdown(),await this.persistence.shutdown()}}iZ.provider={build:()=>new iZ};class i0 extends iZ{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){return N(this.persistence.referenceDelegate instanceof nc,46915),new r4(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Cu(e){let t=void 0!==this.cacheSizeBytes?rZ.withCacheSize(this.cacheSizeBytes):rZ.DEFAULT;return new nl(e=>nc.mi(e,t),this.serializer)}}class i1{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=>iU(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=iY.bind(null,this.syncEngine),await ia(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ig}createDatastore(e){let t=nL(e.databaseInfo.databaseId),r=new nV(e.databaseInfo);return new nB(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){var t;return t=this.localStore,new nj(t,this.datastore,e.asyncQueue,e=>iU(this.syncEngine,e,0),nC.v()?new nC:new nI)}createSyncEngine(e,t){return function(e,t,r,n,i,s,a){let o=new ik(e,t,r,n,i,s);return a&&(o.gu=!0),o}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){_(nG,"RemoteStore shutting down."),e.Ea.add(5),await nQ(e),e.Aa.shutdown(),e.Ra.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}i1.provider={build:()=>new i1};/**
1268 * @license
1269 * Copyright 2020 Google LLC
1270 *
1271 * Licensed under the Apache License, Version 2.0 (the "License");
1272 * you may not use this file except in compliance with the License.
1273 * You may obtain a copy of the License at
1274 *
1275 *   http://www.apache.org/licenses/LICENSE-2.0
1276 *
1277 * Unless required by applicable law or agreed to in writing, software
1278 * distributed under the License is distributed on an "AS IS" BASIS,
1279 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1280 * See the License for the specific language governing permissions and
1281 * limitations under the License.
1282 *//**
1283 * @license
1284 * Copyright 2017 Google LLC
1285 *
1286 * Licensed under the Apache License, Version 2.0 (the "License");
1287 * you may not use this file except in compliance with the License.
1288 * You may obtain a copy of the License at
1289 *
1290 *   http://www.apache.org/licenses/LICENSE-2.0
1291 *
1292 * Unless required by applicable law or agreed to in writing, software
1293 * distributed under the License is distributed on an "AS IS" BASIS,
1294 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1295 * See the License for the specific language governing permissions and
1296 * limitations under the License.
1297 */class i2{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):E("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}/**
1298 * @license
1299 * Copyright 2017 Google LLC
1300 *
1301 * Licensed under the Apache License, Version 2.0 (the "License");
1302 * you may not use this file except in compliance with the License.
1303 * You may obtain a copy of the License at
1304 *
1305 *   http://www.apache.org/licenses/LICENSE-2.0
1306 *
1307 * Unless required by applicable law or agreed to in writing, software
1308 * distributed under the License is distributed on an "AS IS" BASIS,
1309 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1310 * See the License for the specific language governing permissions and
1311 * limitations under the License.
1312 */class i3{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>
13120)throw this.lastTransactionError=new b(A.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;let t=await async function(e,t){let r={documents:t.map(t=>rF(e.serializer,t))},n=await e.Ho("BatchGetDocuments",e.serializer.databaseId,j.emptyPath(),r,t.length),i=new Map;n.forEach(t=>{var r;let n=(r=e.serializer,"found"in t?function(e,t){N(!!t.found,43571),t.found.name,t.found.updateTime;let r=rP(e,t.found.name),n=rV(t.found.updateTime),i=t.found.createTime?rV(t.found.createTime):ei.min(),s=new e6({mapValue:{fields:t.found.fields}});return e5.newFoundDocument(r,n,i,s)}(r,t):"missing"in t?function(e,t){N(!!t.missing,3894),N(!!t.readTime,22933);let r=rP(e,t.missing),n=rV(t.readTime);return e5.newNoDocument(r,n)}(r,t):S(7234,{result:t}));i.set(n.key.toString(),n)});let s=[];return t.forEach(e=>{let t=i.get(e.toString());N(!!t,55234,{key:e}),s.push(t)}),s}(this.datastore,e);return t.forEach(e=>this.recordVersion(e)),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new ri(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let e=this.readVersions;this.mutations.forEach(t=>{e.delete(t.key.toString())}),e.forEach((e,t)=>{let r=H.fromPath(t);this.mutations.push(new rs(r,this.precondition(r)))}),await async function(e,t){let r={writes:t.map(t=>r$(e.serializer,t))};await e.Go("Commit",e.serializer.databaseId,j.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw S(50498,{Gu:e.constructor.name});t=ei.min()}let r=this.readVersions.get(e.key.toString());if(r){if(!t.isEqual(r))throw new b(A.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){let t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(ei.min())?t3.exists(!1):t3.updateTime(t):t3.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(ei.min()))throw new b(A.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return t3.updateTime(t)}return t3.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}/**
1313 * @license
1314 * Copyright 2019 Google LLC
1315 *
1316 * Licensed under the Apache License, Version 2.0 (the "License");
1317 * you may not use this file except in compliance with the License.
1318 * You may obtain a copy of the License at
1319 *
1320 *   http://www.apache.org/licenses/LICENSE-2.0
1321 *
1322 * Unless required by applicable law or agreed to in writing, software
1323 * distributed under the License is distributed on an "AS IS" BASIS,
1324 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1325 * See the License for the specific language governing permissions and
1326 * limitations under the License.
1327 */class i4{constructor(e,t,r,n,i){this.asyncQueue=e,this.datastore=t,this.options=r,this.updateFunction=n,this.deferred=i,this.zu=r.maxAttempts,this.M_=new nO(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Ju()}Ju(){this.M_.p_(async()=>{let e=new i3(this.datastore),t=this.Hu(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.Yu(e)}))}).catch(e=>{this.Yu(e)})})}Hu(e){try{let t=this.updateFunction(e);return!ed(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}Yu(e){this.zu>0&&this.Zu(e)?(this.zu-=1,this.asyncQueue.enqueueAndForget(()=>(this.Ju(),Promise.resolve()))):this.deferred.reject(e)}Zu(e){if("FirebaseError"===e.name){let t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!rh(t)}return!1}}/**
1328 * @license
1329 * Copyright 2017 Google LLC
1330 *
1331 * Licensed under the Apache License, Version 2.0 (the "License");
1332 * you may not use this file except in compliance with the License.
1333 * You may obtain a copy of the License at
1334 *
1335 *   http://www.apache.org/licenses/LICENSE-2.0
1336 *
1337 * Unless required by applicable law or agreed to in writing, software
1338 * distributed under the License is distributed on an "AS IS" BASIS,
1339 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1340 * See the License for the specific language governing permissions and
1341 * limitations under the License.
1342 */let i9="FirestoreClient";class i6{constructor(e,t,r,n,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=n,this.user=g.UNAUTHENTICATED,this.clientId=P.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async e=>{_(i9,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(_(i9,"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}terminate(){this.asyncQueue.enterRestrictedMode();let e=new D;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(r){let t=ih(r,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function i5(e,t){e.asyncQueue.verifyOperationInProgress(),_(i9,"Initializing OfflineComponentProvider");let r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await ny(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function i8(e,t){e.asyncQueue.verifyOperationInProgress();let r=await i7(e);_(i9,"Initializing OnlineComponentProvider"),await t.initialize(r,e.configuration),e.setCredentialChangeListener(e=>is(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,r)=>is(t.remoteStore,r)),e._onlineComponents=t}async function i7(e){if(!e._offlineComponents){if(e._uninitializedComponentsProvider){_(i9,"Using user provided OfflineComponentProvider");try{await i5(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===A.FAILED_PRECONDITION||t.code===A.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;T("Error using user provided cache. Falling back to memory cache: "+t),await i5(e,new iZ)}}else _(i9,"Using default OfflineComponentProvider"),await i5(e,new i0(void 0))}return e._offlineComponents}async function se(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(_(i9,"Using user provided OnlineComponentProvider"),await i8(e,e._uninitializedComponentsProvider._online)):(_(i9,"Using default OnlineComponentProvider"),await i8(e,new i1))),e._onlineComponents}async function st(e){let t=await se(e),r=t.eventManager;return r.onListen=iR.bind(null,t.syncEngine),r.onUnlisten=iL.bind(null,t.syncEngine),r.onFirstRemoteStoreListen=ix.bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=iO.bind(null,t.syncEngine),r}/**
1343 * @license
1344 * Copyright 2023 Google LLC
1345 *
1346 * Licensed under the Apache License, Version 2.0 (the "License");
1347 * you may not use this file except in compliance with the License.
1348 * You may obtain a copy of the License at
1349 *
1350 *   http://www.apache.org/licenses/LICENSE-2.0
1351 *
1352 * Unless required by applicable law or agreed to in writing, software
1353 * distributed under the License is distributed on an "AS IS" BASIS,
1354 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1355 * See the License for the specific language governing permissions and
1356 * limitations under the License.
1357 */function sr(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}/**
1358 * @license
1359 * Copyright 2020 Google LLC
1360 *
1361 * Licensed under the Apache License, Version 2.0 (the "License");
1362 * you may not use this file except in compliance with the License.
1363 * You may obtain a copy of the License at
1364 *
1365 *   http://www.apache.org/licenses/LICENSE-2.0
1366 *
1367 * Unless required by applicable law or agreed to in writing, software
1368 * distributed under the License is distributed on an "AS IS" BASIS,
1369 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1370 * See the License for the specific language governing permissions and
1371 * limitations under the License.
1372 */let sn=new Map,si="firestore.googleapis.com";class ss{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new b(A.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=si,this.ssl=!0}else this.host=e.host,this.ssl=e.ssl??!0;if(this.isUsingEmulator=void 0!==e.emulatorOptions,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 b(A.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,r,n){if(!0===t&&!0===n)throw new b(A.INVALID_ARGUMENT,`${e} and ${r} 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=sr(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new b(A.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new b(A.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new b(A.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){var t,r;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&&(t=this.experimentalLongPollingOptions,r=e.experimentalLongPollingOptions,t.timeoutSeconds===r.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class sa{constructor(e,t,r,n){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new ss({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new b(A.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"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new b(A.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 ss(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new R;switch(e.type){case"firstParty":return new L(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new b(A.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){let t=sn.get(e);t&&(_("ComponentProvider","Removing Datastore"),sn.delete(e),t.terminate())}(this),Promise.resolve()}}function so(e,t,r,n={}){e=ee(e,sa);let i=(0,h.Xx)(t),s=e._getSettings(),a={...s,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${r}`;i&&((0,h.Uo)(`https://${o}`),(0,h.dp)("Firestore",!0)),s.host!==si&&s.host!==o&&T("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let l={...s,host:o,ssl:i,emulatorOptions:n};if(!(0,h.vZ)(l,a)&&(e._setSettings(l),n.mockUserToken)){let t,r;if("string"==typeof n.mockUserToken)t=n.mockUserToken,r=g.MOCK_USER;else{t=(0,h.Sg)(n.mockUserToken,e._app?.options.projectId);let i=n.mockUserToken.sub||n.mockUserToken.user_id;if(!i)throw new b(A.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new g(i)}e._authCredentials=new x(new k(t,r))}}/**
1373 * @license
1374 * Copyright 2020 Google LLC
1375 *
1376 * Licensed under the Apache License, Version 2.0 (the "License");
1377 * you may not use this file except in compliance with the License.
1378 * You may obtain a copy of the License at
1379 *
1380 *   http://www.apache.org/licenses/LICENSE-2.0
1381 *
1382 * Unless required by applicable law or agreed to in writing, software
1383 * distributed under the License is distributed on an "AS IS" BASIS,
1384 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1385 * See the License for the specific language governing permissions and
1386 * limitations under the License.
1387 */class sl{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new sl(this.firestore,e,this._query)}}class su{constructor(e,t,r){this.converter=t,this._key=r,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 sh(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new su(this.firestore,e,this._key)}toJSON(){return{type:su._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(er(t,su._jsonSchema))return new su(e,r||null,new H(j.fromString(t.referencePath)))}}su._jsonSchemaVersion="firestore/documentReference/1.0",su._jsonSchema={type:et("string",su._jsonSchemaVersion),referencePath:et("string")};class sh extends sl{constructor(e,t,r){super(e,t,new t_(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new su(this.firestore,null,new H(e))}withConverter(e){return new sh(this.firestore,e,this._path)}}function sc(e,t,...r){if(e=(0,h.m9)(e),W("collection","path",t),e instanceof sa){let n=j.fromString(t,...r);return X(n),new sh(e,null,n)}{if(!(e instanceof su||e instanceof sh))throw new b(A.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(j.fromString(t,...r));return X(n),new sh(e.firestore,null,n)}}function sd(e,t,...r){if(e=(0,h.m9)(e),1==arguments.length&&(t=P.newId()),W("doc","path",t),e instanceof sa){let n=j.fromString(t,...r);return Y(n),new su(e,null,new H(n))}{if(!(e instanceof su||e instanceof sh))throw new b(A.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(j.fromString(t,...r));return Y(n),new su(e.firestore,e instanceof sh?e.converter:null,new H(n))}}/**
1388 * @license
1389 * Copyright 2020 Google LLC
1390 *
1391 * Licensed under the Apache License, Version 2.0 (the "License");
1392 * you may not use this file except in compliance with the License.
1393 * You may obtain a copy of the License at
1394 *
1395 *   http://www.apache.org/licenses/LICENSE-2.0
1396 *
1397 * Unless required by applicable law or agreed to in writing, software
1398 * distributed under the License is distributed on an "AS IS" BASIS,
1399 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1400 * See the License for the specific language governing permissions and
1401 * limitations under the License.
1402 */let sf="AsyncQueue";class sm{constructor(e=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new nO(this,"async_queue_retry"),this._c=()=>{let e=nM();e&&_(sf,"Visibility state changed to "+e.visibilityState),this.M_.w_()},this.ac=e;let t=nM();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;let t=nM();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise(()=>{});let t=new D;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Xu.push(e),this.lc()))}async lc(){if(0!==this.Xu.length){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(e){if(!eh(e))throw e;_(sf,"Operation failed with retryable error: "+e)}this.Xu.length>0&&this.M_.p_(()=>this.lc())}}cc(e){let t=this.ac.then(()=>(this.rc=!0,e().catch(e=>{throw this.nc=e,this.rc=!1,E("INTERNAL UNHANDLED ERROR: ",sp(e)),e}).then(e=>(this.rc=!1,e))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);let n=iu.createAndSchedule(this,e,t,r,e=>this.hc(e));return this.tc.push(n),n}uc(){this.nc&&S(47125,{Pc:sp(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(let t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then(()=>{for(let t of(this.tc.sort((e,t)=>
1402e.targetTimeMs-t.targetTimeMs),this.tc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Tc()})}dc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}}function sp(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class sg extends sa{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new sm,this._persistenceKey=n?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new sm(e),this._firestoreClient=void 0,await e}}}function sy(e,t){let r="object"==typeof e?e:(0,o.Mq)(),n=(0,o.qX)(r,"firestore").getImmediate({identifier:"string"==typeof e?e:t||eF});if(!n._initialized){let e=(0,h.P0)("firestore");e&&so(n,...e)}return n}function sw(e){if(e._terminated)throw new b(A.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t;let r=e._freezeSettings(),n=(t=e._databaseId,new eO(t,e._app?.options.appId||"",e._persistenceKey,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,sr(r.experimentalLongPollingOptions),r.useFetchStreams,r.isUsingEmulator));e._componentsProvider||r.localCache?._offlineComponentProvider&&r.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:r.localCache._offlineComponentProvider,_online:r.localCache._onlineComponentProvider}),e._firestoreClient=new i6(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}(e),e._firestoreClient}/**
1403 * @license
1404 * Copyright 2020 Google LLC
1405 *
1406 * Licensed under the Apache License, Version 2.0 (the "License");
1407 * you may not use this file except in compliance with the License.
1408 * You may obtain a copy of the License at
1409 *
1410 *   http://www.apache.org/licenses/LICENSE-2.0
1411 *
1412 * Unless required by applicable law or agreed to in writing, software
1413 * distributed under the License is distributed on an "AS IS" BASIS,
1414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1415 * See the License for the specific language governing permissions and
1416 * limitations under the License.
1417 */class sv{constructor(e){this._byteString=e}static fromBase64String(e){try{return new sv(eS.fromBase64String(e))}catch(e){throw new b(A.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new sv(eS.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)}toJSON(){return{type:sv._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(er(e,sv._jsonSchema))return sv.fromBase64String(e.bytes)}}sv._jsonSchemaVersion="firestore/bytes/1.0",sv._jsonSchema={type:et("string",sv._jsonSchemaVersion),bytes:et("string")};/**
1418 * @license
1419 * Copyright 2020 Google LLC
1420 *
1421 * Licensed under the Apache License, Version 2.0 (the "License");
1422 * you may not use this file except in compliance with the License.
1423 * You may obtain a copy of the License at
1424 *
1425 *   http://www.apache.org/licenses/LICENSE-2.0
1426 *
1427 * Unless required by applicable law or agreed to in writing, software
1428 * distributed under the License is distributed on an "AS IS" BASIS,
1429 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1430 * See the License for the specific language governing permissions and
1431 * limitations under the License.
1432 */class s_{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new b(A.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)}}/**
1433 * @license
1434 * Copyright 2020 Google LLC
1435 *
1436 * Licensed under the Apache License, Version 2.0 (the "License");
1437 * you may not use this file except in compliance with the License.
1438 * You may obtain a copy of the License at
1439 *
1440 *   http://www.apache.org/licenses/LICENSE-2.0
1441 *
1442 * Unless required by applicable law or agreed to in writing, softw
1442are
1443 * distributed under the License is distributed on an "AS IS" BASIS,
1444 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1445 * See the License for the specific language governing permissions and
1446 * limitations under the License.
1447 */class sE{constructor(e){this._methodName=e}}/**
1448 * @license
1449 * Copyright 2017 Google LLC
1450 *
1451 * Licensed under the Apache License, Version 2.0 (the "License");
1452 * you may not use this file except in compliance with the License.
1453 * You may obtain a copy of the License at
1454 *
1455 *   http://www.apache.org/licenses/LICENSE-2.0
1456 *
1457 * Unless required by applicable law or agreed to in writing, software
1458 * distributed under the License is distributed on an "AS IS" BASIS,
1459 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1460 * See the License for the specific language governing permissions and
1461 * limitations under the License.
1462 */class sT{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new b(A.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new b(A.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}_compareTo(e){return U(this._lat,e._lat)||U(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:sT._jsonSchemaVersion}}static fromJSON(e){if(er(e,sT._jsonSchema))return new sT(e.latitude,e.longitude)}}sT._jsonSchemaVersion="firestore/geoPoint/1.0",sT._jsonSchema={type:et("string",sT._jsonSchemaVersion),latitude:et("number"),longitude:et("number")};/**
1463 * @license
1464 * Copyright 2024 Google LLC
1465 *
1466 * Licensed under the Apache License, Version 2.0 (the "License");
1467 * you may not use this file except in compliance with the License.
1468 * You may obtain a copy of the License at
1469 *
1470 *   http://www.apache.org/licenses/LICENSE-2.0
1471 *
1472 * Unless required by applicable law or agreed to in writing, software
1473 * distributed under the License is distributed on an "AS IS" BASIS,
1474 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1475 * See the License for the specific language governing permissions and
1476 * limitations under the License.
1477 */class sI{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(this._values,e._values)}toJSON(){return{type:sI._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(er(e,sI._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new sI(e.vectorValues);throw new b(A.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}sI._jsonSchemaVersion="firestore/vectorValue/1.0",sI._jsonSchema={type:et("string",sI._jsonSchemaVersion),vectorValues:et("object")};/**
1478 * @license
1479 * Copyright 2017 Google LLC
1480 *
1481 * Licensed under the Apache License, Version 2.0 (the "License");
1482 * you may not use this file except in compliance with the License.
1483 * You may obtain a copy of the License at
1484 *
1485 *   http://www.apache.org/licenses/LICENSE-2.0
1486 *
1487 * Unless required by applicable law or agreed to in writing, software
1488 * distributed under the License is distributed on an "AS IS" BASIS,
1489 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1490 * See the License for the specific language governing permissions and
1491 * limitations under the License.
1492 */let sS=/^__.*__$/;class sC{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new re(e,this.data,this.fieldMask,t,this.fieldTransforms):new t7(e,this.data,t,this.fieldTransforms)}}class sN{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new re(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function sA(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw S(40011,{Ac:e})}}class sb{constructor(e,t,r,n,i,s){this.settings=e,this.databaseId=t,this.serializer
1492=r,this.ignoreUndefinedProperties=n,void 0===i&&this.Rc(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get Ac(){return this.settings.Ac}Vc(e){return new sb({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}mc(e){let t=this.path?.child(e),r=this.Vc({path:t,fc:!1});return r.gc(e),r}yc(e){let t=this.path?.child(e),r=this.Vc({path:t,fc:!1});return r.Rc(),r}wc(e){return this.Vc({path:void 0,fc:!0})}Sc(e){return sG(e,this.settings.methodName,this.settings.bc||!1,this.path,this.settings.Dc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Rc(){if(this.path)for(let e=0;e<this.path.length;e++)this.gc(this.path.get(e))}gc(e){if(0===e.length)throw this.Sc("Document fields must not be empty");if(sA(this.Ac)&&sS.test(e))throw this.Sc('Document fields cannot begin and end with "__"')}}class sD{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||nL(e)}Cc(e,t,r,n=!1){return new sb({Ac:e,methodName:t,Dc:r,path:Q.emptyPath(),fc:!1,bc:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function sk(e){let t=e._freezeSettings(),r=nL(e._databaseId);return new sD(e._databaseId,!!t.ignoreUndefinedProperties,r)}function sR(e,t,r,n,i,s={}){let a,o;let l=e.Cc(s.merge||s.mergeFields?2:0,t,r,i);sq("Data must be an object, but it was:",l,n);let u=sP(n,l);if(s.merge)a=new eT(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let n of s.mergeFields){let i=sz(t,n,r);if(!l.contains(i))throw new b(A.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);sj(e,i)||e.push(i)}a=new eT(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new sC(new e6(u),a,o)}class sx extends sE{_toFieldTransform(e){if(2!==e.Ac)throw 1===e.Ac?e.Sc(`${this._methodName}() can only appear at the top level of your update data`):e.Sc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof sx}}class sV extends sE{_toFieldTransform(e){return new t1(e.path,new tQ)}isEqual(e){return e instanceof sV}}class sM extends sE{constructor(e,t){super(e),this.Fc=t}_toFieldTransform(e){let t=new tJ(e.serializer,tG(e.serializer,this.Fc));return new t1(e.path,t)}isEqual(e){return e instanceof sM&&this.Fc===e.Fc}}function sL(e,t,r,n){let i=e.Cc(1,t,r);sq("Data must be an object, but it was:",i,n);let s=[],a=e6.empty();return ep(n,(e,n)=>{let o=s$(t,e,r);n=(0,h.m9)(n);let l=i.yc(o);if(n instanceof sx)s.push(o);else{let e=sF(n,l);null!=e&&(s.push(o),a.set(o,e))}}),new sN(a,new eT(s),i.fieldTransforms)}function sO(e,t,r,n,i,s){let a=e.Cc(1,t,r),o=[sz(t,n,r)],l=[i];if(s.length%2!=0)throw new b(A.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)o.push(sz(t,s[e])),l.push(s[e+1]);let u=[],c=e6.empty();for(let e=o.length-1;e>=0;--e)if(!sj(u,o[e])){let t=o[e],r=l[e];r=(0,h.m9)(r);let n=a.yc(t);if(r instanceof sx)u.push(t);else{let e=sF(r,n);null!=e&&(u.push(t),c.set(t,e))}}return new sN(c,new eT(u),a.fieldTransforms)}function sF(e,t){if(sU(e=(0,h.m9)(e)))return sq("Unsupported field value:",t,e),sP(e,t);if(e instanceof sE)return function(e,t){if(!sA(t.Ac))throw t.Sc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Sc(`${e._methodName}() is not currently supported inside arrays`);let r=e._toFieldTransform(t);r&&t.fieldTransforms.push(r)}(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.fc&&4!==t.Ac)throw t.Sc("Nested arrays are not supported");return function(e,t){let r=[],n=0;for(let i of e){let e=sF(i,t.wc(n));null==e&&(e={nullValue:"NULL_VALUE"}),r.push(e),n++}return{arrayValue:{values:r}}}(e,t)}return function(e,t){if(null===(e=(0,h.m9)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return tG(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){let r=en.fromDate(e);return{timestampValue:rR(t.serializer,r)}}if(e instanceof en){let r=new en(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:rR(t.serializer,r)}}if(e instanceof sT)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof sv)return{bytesValue:rx(t.serializer,e._byteString)};if(e instanceof su){let r=t.databaseId,n=e.firestore._databaseId;if(!n.isEqual(r))throw t.Sc(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:rM(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof sI)return{mapValue:{fields:{[eU]:{stringValue:eB},[e$]:{arrayValue:{values:e.toArray().map(e=>{if("number"!=typeof e)throw t.Sc("VectorValues must only contain numeric values.");return tB(t.serializer,e)})}}}}};throw t.Sc(`Unsupported field value: ${Z(e)}`)}(e,t)}function sP(e,t){let r={};return eg(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):ep(e,(e,n)=>{let i=sF(n,t.mc(e));null!=i&&(r[e]=i)}),{mapValue:{fields:r}}}function sU(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof en||e instanceof sT||e instanceof sv||e instanceof su||e instanceof sE||e instanceof sI)}function sq(e,t,r){if(!sU(r)||!J(r)){let n=Z(r);throw"an object"===n?t.Sc(e+" a custom object"):t.Sc(e+" "+n)}}function sz(e,t,r){if((t=(0,h.m9)(t))instanceof s_)return t._internalPath;if("string"==typeof t)return s$(e,t);throw sG("Field path arguments must be of type string or ",e,!1,void 0,r)}let sB=RegExp("[~\\*/\\[\\]]");function s$(e,t,r){if(t.search(sB)>=0)throw sG(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,r);try{return new s_(...t.split("."))._internalPath}catch(n){throw sG(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,r)}}function sG(e,t,r,n,i){let s=n&&!n.isEmpty(),a=void 0!==i,o=`Function ${t}
1492() called with invalid data`;r&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(s||a)&&(l+=" (found",s&&(l+=` in field ${n}`),a&&(l+=` in document ${i}`),l+=")"),new b(A.INVALID_ARGUMENT,o+e+l)}function sj(e,t){return e.some(e=>e.isEqual(t))}/**
1493 * @license
1494 * Copyright 2020 Google LLC
1495 *
1496 * Licensed under the Apache License, Version 2.0 (the "License");
1497 * you may not use this file except in compliance with the License.
1498 * You may obtain a copy of the License at
1499 *
1500 *   http://www.apache.org/licenses/LICENSE-2.0
1501 *
1502 * Unless required by applicable law or agreed to in writing, software
1503 * distributed under the License is distributed on an "AS IS" BASIS,
1504 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1505 * See the License for the specific language governing permissions and
1506 * limitations under the License.
1507 */class sK{constructor(e,t,r,n,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=n,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new su(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new sQ(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){let t=this._document.data.field(sH("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class sQ extends sK{data(){return super.data()}}function sH(e,t){return"string"==typeof t?s$(e,t):t instanceof s_?t._internalPath:t._delegate._internalPath}class sW{}class sY extends sW{}function sX(e,t,...r){let n=[];for(let i of(t instanceof sW&&n.push(t),function(e){let t=e.filter(e=>e instanceof s0).length,r=e.filter(e=>e instanceof sJ).length;if(t>1||t>0&&r>0)throw new b(A.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(...)))`.")}(n=n.concat(r)),n))e=i._apply(e);return e}class sJ extends sY{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new sJ(e,t,r)}_apply(e){let t=this._parse(e);return s5(e._query,t),new sl(e.firestore,e.converter,tC(e._query,t))}_parse(e){let t=sk(e.firestore);return function(e,t,r,n,i,s,a){let o;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new b(A.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){s6(a,s);let t=[];for(let r of a)t.push(s9(n,e,r));o={arrayValue:{values:t}}}else o=s9(n,e,a)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||s6(a,s),o=function(e,t,r,n=!1){return sF(r,e.Cc(n?4:3,t))}(r,t,a,"in"===s||"not-in"===s);return tn.create(i,s,o)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function sZ(e,t,r){let n=sH("where",e);
1507return sJ._create(n,t,r)}class s0 extends sW{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new s0(e,t)}_parse(e){let t=this._queryConstraints.map(t=>t._parse(e)).filter(e=>e.getFilters().length>0);return 1===t.length?t[0]:ti.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let r=e;for(let e of t.getFlattenedFilters())s5(r,e),r=tC(r,e)}(e._query,t),new sl(e.firestore,e.converter,tC(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class s1 extends sY{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new s1(e,t)}_apply(e){let t=function(e,t,r){if(null!==e.startAt)throw new b(A.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new b(A.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new tt(t,r)}(e._query,this._field,this._direction);return new sl(e.firestore,e.converter,function(e,t){let r=e.explicitOrderBy.concat([t]);return new t_(e.path,e.collectionGroup,r,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}function s2(e,t="asc"){let r=sH("orderBy",e);return s1._create(r,t)}class s3 extends sY{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new s3(e,t,r)}_apply(e){return new sl(e.firestore,e.converter,tN(e._query,this._limit,this._limitType))}}function s4(e){return function(e,t){if(t<=0)throw new b(A.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}("limit",e),s3._create("limit",e,"F")}function s9(e,t,r){if("string"==typeof(r=(0,h.m9)(r))){if(""===r)throw new b(A.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!tT(t)&&-1!==r.indexOf("/"))throw new b(A.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${r}' contains a '/' character.`);let n=t.path.child(j.fromString(r));if(!H.isDocumentKey(n))throw new b(A.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return eX(e,new H(n))}if(r instanceof su)return eX(e,r._key);throw new b(A.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Z(r)}.`)}function s6(e,t){if(!Array.isArray(e)||0===e.length)throw new b(A.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function s5(e,t){let r=function(e,t){for(let r of e)for(let e of r.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!==r)throw r===t.op?new b(A.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new b(A.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${r.toString()}' filters.`)}class s8{convertValue(e,t="none"){switch(eG(e)){case 0:return null;case 1:return e.booleanValue;case 2:return eA(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(eb(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 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw S(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return ep(e,(e,n)=>{r[e]=this.convertValue(n,t)}),r}convertVectorValue(e){return new sI(e.fields?.[e$].arrayValue?.values?.map(e=>eA(e.doubleValue)))}convertGeoPoint(e){return new sT(eA(e.latitude),eA(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=eM(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(eL(e));default:return null}}convertTimestamp(e){let t=eN(e);return new en(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=j.fromString(e);N(rK(r),9688,{name:e});let n=new eP(r.get(1),r.get(3)),i=new H(r.popFirst(5));return n.isEqual(t)||E(`Document ${i} contains a document reference within a different database (${n.projectId}/${n.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}/**
1508 * @license
1509 * Copyright 2020 Google LLC
1510 *
1511 * Licensed under the Apache License, Version 2.0 (the "License");
1512 * you may not use this file except in compliance with the License.
1513 * You may obtain a copy of the License at
1514 *
1515 *   http://www.apache.org/licenses/LICENSE-2.0
1516 *
1517 * Unless required by applicable law or agreed to in writing, software
1518 * distributed under the License is distributed on an "AS IS" BASIS,
1519 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1520 * See the License for the specific language governing permissions and
1521 * limitations under the License.
1522 */function s7(e,t,r){return e?r&&(r.merge||r.mergeFields)?e.toFirestore(t,r):e.toFirestore(t):t}class ae extends s8{constructor(e){super(),this.firestore=e}convertBytes(e){return new sv(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new su(this.firestore,null,t)}}class at{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class ar extends sK{constructor(e,t,r,n,i,s){super(e,t,r,n,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new an(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){let r=this._document.data.field(sH("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new b(A.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e=this._document,t={};return t.type=ar._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()&&(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED")),t}}ar._jsonSchemaVersion="firestore/documentSnapshot/1.0",ar._jsonSchema={type:et("string",ar._jsonSchemaVersion),bundleSource:et("string","DocumentSnapshot"),bundleName:et("string"),bundle:et("string")};class an extends ar{data(e={}){return super.data(e)}}class ai{constructor(e,t,r,n){this._firestore=e,this._userDataWriter=t,this._snapshot=n,this.metadata=new at(n.hasPendingWrites,n.fromCache),this.query=r}get docs(){let 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(r=>{e.call(t,new an(this._firestore,this._userDataWriter,r.key,r,new at(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new b(A.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(r=>{let n=new an(e._firestore,e._userDataWriter,r.doc.key,r.doc,new at(e._snapshot.mutatedKeys.has(r.doc.key),e._snapshot.fromCache),e.query.converter);return r.doc,{type:"added",doc:n,oldIndex:-1,newIndex:t++}})}{let r=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{let n=new an(e._firestore,e._userDataWriter,t.doc.key,t.doc,new at(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,s=-1;return 0!==t.type&&(i=r.indexOf(t.doc.key),r=r.delete(t.doc.key)),1!==t.type&&(s=(r=r.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return S(61501,{type:e})}}(t.type),doc:n,oldIndex:i,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new b(A.FAILED_PRECONDITION,"QuerySnapsh
1522ot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e={};e.type=ai._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=P.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],r=[],n=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),n.push(e.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}/**
1523 * @license
1524 * Copyright 2020 Google LLC
1525 *
1526 * Licensed under the Apache License, Version 2.0 (the "License");
1527 * you may not use this file except in compliance with the License.
1528 * You may obtain a copy of the License at
1529 *
1530 *   http://www.apache.org/licenses/LICENSE-2.0
1531 *
1532 * Unless required by applicable law or agreed to in writing, software
1533 * distributed under the License is distributed on an "AS IS" BASIS,
1534 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1535 * See the License for the specific language governing permissions and
1536 * limitations under the License.
1537 */function as(e){e=ee(e,su);let t=ee(e.firestore,sg);return(function(e,t,r={}){let n=new D;return e.asyncQueue.enqueueAndForget(async()=>(function(e,t,r,n,i){let s=new i2({next:o=>{s.Nu(),t.enqueueAndForget(()=>iv(e,a));let l=o.docs.has(r);!l&&o.fromCache?i.reject(new b(A.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&o.fromCache&&n&&"server"===n.source?i.reject(new b(A.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.)')):i.resolve(o)},error:e=>i.reject(e)}),a=new iI(new t_(r.path),s,{includeMetadataChanges:!0,qa:!0});return iw(e,a)})(await st(e),e.asyncQueue,t,r,n)),n.promise})(sw(t),e._key).then(r=>(function(e,t,r){let n=r.docs.get(t._key),i=new aa(e);return new ar(e,i,t._key,n,new at(r.hasPendingWrites,r.fromCache),t.converter)})(t,e,r))}ai._jsonSchemaVersion="firestore/querySnapshot/1.0",ai._jsonSchema={type:et("string",ai._jsonSchemaVersion),bundleSource:et("string","QuerySnapshot"),bundleName:et("string"),bundle:et("string")};class aa extends s8{constructor(e){super(),this.firestore=e}convertBytes(e){return new sv(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new su(this.firestore,null,t)}}function ao(e){e=ee(e,sl);let t=ee(e.firestore,sg),r=sw(t),n=new aa(t);return(/**
1538 * @license
1539 * Copyright 2020 Google LLC
1540 *
1541 * Licensed under the Apache License, Version 2.0 (the "License");
1542 * you may not use this file except in compliance with the License.
1543 * You may obtain a copy of the License at
1544 *
1545 *   http://www.apache.org/licenses/LICENSE-2.0
1546 *
1547 * Unless required by applicable law or agreed to in writing, software
1548 * distributed under the License is distributed on an "AS IS" BASIS,
1549 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1550 * See the License for the specific language governing permissions and
1551 * limitations under the License.
1552 */function(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new b(A.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}(e._query),(function(e,t,r={}){let n=new D;return e.asyncQueue.enqueueAndForget(async()=>(function(e,t,r,n,i){let s=new i2({next:r=>{s.Nu(),t.enqueueAndForget(()=>iv(e,a)),r.fromCache&&"server"===n.source?i.reject(new b(A.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.)')):i.resolve(r)},error:e=>i.reject(e)}),a=new iI(r,s,{includeMetadataChanges:!0,qa:!0});return iw(e,a)})(await st(e),e.asyncQueue,t,r,n)),n.promise})(r,e._query).then(r=>new ai(t,n,e,r)))}function al(e,t,r,...n){e=ee(e,su);let i=ee(e.firestore,sg),s=sk(i);return ac(i,[("string"==typeof(t=(0,h.m9)(t))||t instanceof s_?sO(s,"updateDoc",e._key,t,r,n):sL(s,"updateDoc",e._key,t)).toMutation(e._key,t3.exists(!0))])}function au(e){return ac(ee(e.firestore,sg),[new ri(e._key,t3.none())])}function ah(e,t){let r=ee(e.firestore,sg),n=sd(e),i=s7(e.converter,t);return ac(r,[sR(sk(e.firestore),"addDoc",n._key,i,null!==e.converter,{}).toMutation(n._key,t3.exists(!1))]).then(()=>n)}function ac(e,t){return function(e,t){let r=new D;return e.asyncQueue.enqueueAndForget(async()=>iF(await se(e).then(e=>e.syncEngine),t,r)),r.promise}(sw(e),t)}/**
1553 * @license
1554 * Copyright 2022 Google LLC
1555 *
1556 * Licensed under the Apache License, Version 2.0 (the "License");
1557 * you may not use this file except in compliance with the License.
1558 * You may obtain a copy of the License at
1559 *
1560 *   http://www.apache.org/licenses/LICENSE-2.0
1561 *
1562 * Unless required by applicable law or agreed to in writing, software
1563 * distributed under the License is distributed on an "AS IS" BASIS,
1564 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1565 * See the License for the specific language governing permissions and
1566 * limitations under the License.
1567 */let ad={maxAttempts:5};function af(e,t){if((e=(0,h.m9)(e)).firestore!==t)throw new b(A.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}/**
1568 * @license
1569 * Copyright 2020 Google LLC
1570 *
1571 * Licensed under the Apache License, Version 2.0 (the "License");
1572 * you may not use this file except in compliance with the License.
1573 * You may obtain a copy of the License at
1574 *
1575 *   http://www.apache.org/licenses/LICENSE-2.0
1576 *
1577 * Unless required by applicable law or agreed to in writing, software
1578 * distributed under the License is distributed on an "AS IS" BASIS,
1579 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1580 * See the License for the specific language governing permissions and
1581 * limitations under the License.
1582 */class am{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=sk(e)}get(e){let t=af(e,this._firestore),r=new ae(this._firestore);return this._transaction.lookup([t._key]).then(e=>{if(!e||1!==e.length)return S(24041);let n=e[0];if(n.isFoundDocument())return new sK(this._firestore,r,n.key,n,t.converter);if(n.isNoDocument())return new sK(this._firestore,r,t._key,null,t.converter);throw S(18433,{doc:n})})}set(e,t,r){let n=af(e,this._firestore),i=s7(n.converter,t,r),s=sR(this._dataReader,"Transaction.set",n._key,i,null!==n.converter,r);return this._transaction.set(n._key,s),this}update(e,t,r,...n){let i;let s=af(e,this._firestore);return i="string"==typeof(t=(0,h.m9)(t))||t instanceof s_?sO(this._dataReader,"Transaction.update",s._key,t,r,n):sL(this._dataReader,"Transaction.update",s._key,t),this._transaction.update(s._key,i),this}delete(e){let t=af(e,this._firestore);return this._transaction.delete(t._key),this}}/**
1583 * @license
1584 * Copyright 2020 Google LLC
1585 *
1586 * Licensed under the Apache License, Version 2.0 (the "License");
1587 * you may not use this file except in compliance with the License.
1588 * You may obtain a copy of the License at
1589 *
1590 *   http://www.apache.org/licenses/LICENSE-2.0
1591 *
1592 * Unless required by applicable law or agreed to in writing, software
1593 * distributed under the License is distributed on an "AS IS" BASIS,
1594 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1595 * See the License for the specific language governing permissions and
1596 * limitations under the License.
1597 */class ap extends am{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=af(e,this._firestore),r=new aa(this._firestore);return super.get(e).then(e=>new ar(this._firestore,r,t._key,e._document,new at(!1,!1),t.converter))}}function ag(e,t,r){e=ee(e,sg);let n={...ad,...r};return!function(e){if(e.maxAttempts<1)throw new b(A.INVALID_ARGUMENT,"Max attempts must be at least 1")}(n),function(e,t,r){let n=new D;return e.asyncQueue.enqueueAndForget(async()=>{let i=await se(e).then(e=>e.datastore);new i4(e.asyncQueue,i,r,t,n).ju()}),n.promise}(sw(e),r=>t(new ap(e,r)),n)}/**
1598 * @license
1599 * Copyright 2020 Google LLC
1600 *
1601 * Licensed under the Apache License, Version 2.0 (the "License");
1602 * you may not use this file except in compliance with the License.
1603 * You may obtain a copy of the License at
1604 *
1605 *   http://www.apache.org/licenses/LICENSE-2.0
1606 *
1607 * Unless required by applicable law or agreed to in writing, software
1608 * distributed under the License is distributed on an "AS IS" BASIS,
1609 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1610 * See the License for the specific language governing permissions and
1611 * limitations under the License.
1612 */function ay(){return new sx("deleteField")}function aw(){return new sV("serverTimestamp")}function av(e){return new sM("increment",e)}
1612new WeakMap,function(e=!0){y=o.Jn,(0,o.Xd)(new l.wA("firestore",(t,{instanceIdentifier:r,options:n})=>{let i=t.getProvider("app").getImmediate(),s=new sg(new V(t.getProvider("auth-internal")),new F(i,t.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new b(A.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new eP(e.options.projectId,t)}(i,r),i);return n={useFetchStreams:e,...n},s._setSettings(n),s},"PUBLIC").setMultipleInstances(!0)),(0,o.KN)(m,p,void 0),(0,o.KN)(m,p,"esm2020")}()}}]);

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.