@firebase/firestore 4.7.7-canary.4d2fc6e82 → 4.7.7-canary.554c7bdc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/firestore/src/global_index.d.ts +7 -0
  2. package/dist/firestore/src/lite-api/database.d.ts +4 -0
  3. package/dist/firestore/src/lite-api/settings.d.ts +4 -0
  4. package/dist/firestore/src/util/misc.d.ts +0 -2
  5. package/dist/firestore/test/integration/util/settings.d.ts +1 -0
  6. package/dist/index.cjs.js +243 -241
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.esm2017.js +244 -242
  9. package/dist/index.esm2017.js.map +1 -1
  10. package/dist/index.node.cjs.js +54 -53
  11. package/dist/index.node.cjs.js.map +1 -1
  12. package/dist/index.node.mjs +55 -54
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/index.rn.js +196 -194
  15. package/dist/index.rn.js.map +1 -1
  16. package/dist/internal.d.ts +7 -0
  17. package/dist/lite/firestore/src/lite-api/database.d.ts +4 -0
  18. package/dist/lite/firestore/src/lite-api/settings.d.ts +4 -0
  19. package/dist/lite/firestore/src/util/misc.d.ts +0 -2
  20. package/dist/lite/firestore/test/integration/util/settings.d.ts +1 -0
  21. package/dist/lite/index.browser.esm2017.js +146 -166
  22. package/dist/lite/index.browser.esm2017.js.map +1 -1
  23. package/dist/lite/index.cjs.js +146 -166
  24. package/dist/lite/index.cjs.js.map +1 -1
  25. package/dist/lite/index.node.cjs.js +110 -128
  26. package/dist/lite/index.node.cjs.js.map +1 -1
  27. package/dist/lite/index.node.mjs +111 -129
  28. package/dist/lite/index.node.mjs.map +1 -1
  29. package/dist/lite/index.rn.esm2017.js +159 -179
  30. package/dist/lite/index.rn.esm2017.js.map +1 -1
  31. package/dist/lite/internal.d.ts +7 -0
  32. package/dist/lite/private.d.ts +4 -0
  33. package/dist/private.d.ts +4 -0
  34. package/package.json +9 -9
@@ -1,11 +1,11 @@
1
1
  import { _registerComponent, registerVersion, _isFirebaseServerApp, _getProvider, getApp, _removeServiceInstance, SDK_VERSION } from '@firebase/app';
2
2
  import { Component } from '@firebase/component';
3
3
  import { Logger, LogLevel } from '@firebase/logger';
4
- import { FirebaseError, createMockUserToken, getModularInstance, deepEqual, getDefaultEmulatorHostnameAndPort, isIndexedDBAvailable, getUA, isSafari } from '@firebase/util';
4
+ import { FirebaseError, deepEqual, createMockUserToken, getModularInstance, getDefaultEmulatorHostnameAndPort, isIndexedDBAvailable, getUA, isSafari } from '@firebase/util';
5
5
  import { Integer, Md5 } from '@firebase/webchannel-wrapper/bloom-blob';
6
6
  import { XhrIo, EventType, ErrorCode, createWebChannelTransport, getStatEventTarget, WebChannel, Event, Stat } from '@firebase/webchannel-wrapper/webchannel-blob';
7
7
 
8
- const S = "@firebase/firestore", b = "4.7.7-canary.4d2fc6e82";
8
+ const b = "@firebase/firestore", S = "4.7.7-canary.554c7bdc1";
9
9
 
10
10
  /**
11
11
  * @license
@@ -67,7 +67,7 @@ User.MOCK_USER = new User("mock-user");
67
67
  * See the License for the specific language governing permissions and
68
68
  * limitations under the License.
69
69
  */
70
- let D = "11.3.0-canary.4d2fc6e82";
70
+ let D = "11.3.0-canary.554c7bdc1";
71
71
 
72
72
  /**
73
73
  * @license
@@ -684,31 +684,6 @@ function __PRIVATE_randomBytes(e) {
684
684
  return n;
685
685
  }
686
686
 
687
- /**
688
- * @license
689
- * Copyright 2023 Google LLC
690
- *
691
- * Licensed under the Apache License, Version 2.0 (the "License");
692
- * you may not use this file except in compliance with the License.
693
- * You may obtain a copy of the License at
694
- *
695
- * http://www.apache.org/licenses/LICENSE-2.0
696
- *
697
- * Unless required by applicable law or agreed to in writing, software
698
- * distributed under the License is distributed on an "AS IS" BASIS,
699
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
700
- * See the License for the specific language governing permissions and
701
- * limitations under the License.
702
- */
703
- /**
704
- * An instance of the Platform's 'TextEncoder' implementation.
705
- */ function __PRIVATE_newTextEncoder() {
706
- return new TextEncoder;
707
- }
708
-
709
- /**
710
- * An instance of the Platform's 'TextDecoder' implementation.
711
- */
712
687
  /**
713
688
  * @license
714
689
  * Copyright 2017 Google LLC
@@ -730,8 +705,7 @@ function __PRIVATE_randomBytes(e) {
730
705
  *
731
706
  * @internal
732
707
  * Exported internally for testing purposes.
733
- */
734
- class __PRIVATE_AutoId {
708
+ */ class __PRIVATE_AutoId {
735
709
  static newId() {
736
710
  // Alphanumeric characters
737
711
  const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = 62 * Math.floor(256 / 62);
@@ -752,16 +726,6 @@ function __PRIVATE_primitiveComparator(e, t) {
752
726
  return e < t ? -1 : e > t ? 1 : 0;
753
727
  }
754
728
 
755
- /** Compare strings in UTF-8 encoded byte order */ function __PRIVATE_compareUtf8Strings(e, t) {
756
- // Convert the string to UTF-8 encoded bytes
757
- const n = __PRIVATE_newTextEncoder().encode(e), r = __PRIVATE_newTextEncoder().encode(t);
758
- for (let e = 0; e < Math.min(n.length, r.length); e++) {
759
- const t = __PRIVATE_primitiveComparator(n[e], r[e]);
760
- if (0 !== t) return t;
761
- }
762
- return __PRIVATE_primitiveComparator(n.length, r.length);
763
- }
764
-
765
729
  /** Helper to compare arrays using isEqual(). */ function __PRIVATE_arrayEquals(e, t, n) {
766
730
  return e.length === t.length && e.every(((e, r) => n(e, t[r])));
767
731
  }
@@ -1052,11 +1016,13 @@ class Timestamp {
1052
1016
  const n = BasePath.compareSegments(e.get(r), t.get(r));
1053
1017
  if (0 !== n) return n;
1054
1018
  }
1055
- return __PRIVATE_primitiveComparator(e.length, t.length);
1019
+ return Math.sign(e.length - t.length);
1056
1020
  }
1057
1021
  static compareSegments(e, t) {
1058
1022
  const n = BasePath.isNumericId(e), r = BasePath.isNumericId(t);
1059
- return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) : __PRIVATE_compareUtf8Strings(e, t);
1023
+ return n && !r ? -1 : !n && r ? 1 : n && r ? BasePath.extractNumericId(e).compare(BasePath.extractNumericId(t)) :
1024
+ // both non-numeric
1025
+ e < t ? -1 : e > t ? 1 : 0;
1060
1026
  }
1061
1027
  // Checks if a segment is a numeric ID (starts with "__id" and ends with "__").
1062
1028
  static isNumericId(e) {
@@ -1844,13 +1810,13 @@ class __PRIVATE_SimpleDbTransaction {
1844
1810
  * within the key range or index.
1845
1811
  */ class __PRIVATE_IterationController {
1846
1812
  constructor(e) {
1847
- this.q = e, this.$ = !1, this.U = null;
1813
+ this.q = e, this.$ = !1, this.K = null;
1848
1814
  }
1849
1815
  get isDone() {
1850
1816
  return this.$;
1851
1817
  }
1852
- get K() {
1853
- return this.U;
1818
+ get U() {
1819
+ return this.K;
1854
1820
  }
1855
1821
  set cursor(e) {
1856
1822
  this.q = e;
@@ -1864,7 +1830,7 @@ class __PRIVATE_SimpleDbTransaction {
1864
1830
  * This function can be called to skip to that next key, which could be
1865
1831
  * an index or a primary key.
1866
1832
  */ W(e) {
1867
- this.U = e;
1833
+ this.K = e;
1868
1834
  }
1869
1835
  /**
1870
1836
  * Delete the current cursor value from the object store.
@@ -2023,7 +1989,7 @@ class __PRIVATE_SimpleDbTransaction {
2023
1989
  const e = o.catch((e => (s.done(), PersistencePromise.reject(e))));
2024
1990
  n.push(e);
2025
1991
  }
2026
- s.isDone ? r() : null === s.K ? i.continue() : i.continue(s.K);
1992
+ s.isDone ? r() : null === s.U ? i.continue() : i.continue(s.U);
2027
1993
  };
2028
1994
  })).next((() => PersistencePromise.waitFor(n)));
2029
1995
  }
@@ -2344,7 +2310,7 @@ function __PRIVATE_encodeResourcePath(e) {
2344
2310
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2345
2311
  * See the License for the specific language governing permissions and
2346
2312
  * limitations under the License.
2347
- */ const U = "remoteDocuments", K = "owner", W = "owner", G = "mutationQueues", z = "userId", j = "mutations", H = "batchId", J = "userMutationsIndex", Y = [ "userId", "batchId" ];
2313
+ */ const K = "remoteDocuments", U = "owner", W = "owner", G = "mutationQueues", z = "userId", j = "mutations", H = "batchId", J = "userMutationsIndex", Y = [ "userId", "batchId" ];
2348
2314
 
2349
2315
  /**
2350
2316
  * @license
@@ -2389,7 +2355,7 @@ function __PRIVATE_newDbDocumentMutationPrefixForPath(e, t) {
2389
2355
  * there is no useful information to store as the value. The raw (unencoded)
2390
2356
  * path cannot be stored because IndexedDb doesn't store prototype
2391
2357
  * information.
2392
- */ const Z = {}, X = "documentMutations", ee = "remoteDocumentsV14", te = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], ne = "documentKeyIndex", re = [ "prefixPath", "collectionGroup", "documentId" ], ie = "collectionGroupIndex", se = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], oe = "remoteDocumentGlobal", _e = "remoteDocumentGlobalKey", ae = "targets", ue = "queryTargetsIndex", ce = [ "canonicalId", "targetId" ], le = "targetDocuments", he = [ "targetId", "path" ], Pe = "documentTargetsIndex", Te = [ "path", "targetId" ], Ie = "targetGlobalKey", Ee = "targetGlobal", de = "collectionParents", Ae = [ "collectionId", "parent" ], Re = "clientMetadata", Ve = "clientId", me = "bundles", fe = "bundleId", ge = "namedQueries", pe = "name", ye = "indexConfiguration", we = "indexId", Se = "collectionGroupIndex", be = "collectionGroup", De = "indexState", ve = [ "indexId", "uid" ], Ce = "sequenceNumberIndex", Fe = [ "uid", "sequenceNumber" ], Me = "indexEntries", xe = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], Oe = "documentKeyIndex", Ne = [ "indexId", "uid", "orderedDocumentKey" ], Be = "documentOverlays", Le = [ "userId", "collectionPath", "documentId" ], ke = "collectionPathOverlayIndex", qe = [ "userId", "collectionPath", "largestBatchId" ], Qe = "collectionGroupOverlayIndex", $e = [ "userId", "collectionGroup", "largestBatchId" ], Ue = "globals", Ke = "name", We = [ ...[ ...[ ...[ ...[ G, j, X, U, ae, K, Ee, le ], Re ], oe ], de ], me, ge ], Ge = [ ...We, Be ], ze = [ G, j, X, ee, ae, K, Ee, le, Re, oe, de, me, ge, Be ], je = ze, He = [ ...je, ye, De, Me ], Je = He, Ye = [ ...He, Ue ];
2358
+ */ const Z = {}, X = "documentMutations", ee = "remoteDocumentsV14", te = [ "prefixPath", "collectionGroup", "readTime", "documentId" ], ne = "documentKeyIndex", re = [ "prefixPath", "collectionGroup", "documentId" ], ie = "collectionGroupIndex", se = [ "collectionGroup", "readTime", "prefixPath", "documentId" ], oe = "remoteDocumentGlobal", _e = "remoteDocumentGlobalKey", ae = "targets", ue = "queryTargetsIndex", ce = [ "canonicalId", "targetId" ], le = "targetDocuments", he = [ "targetId", "path" ], Pe = "documentTargetsIndex", Te = [ "path", "targetId" ], Ie = "targetGlobalKey", Ee = "targetGlobal", de = "collectionParents", Ae = [ "collectionId", "parent" ], Re = "clientMetadata", Ve = "clientId", me = "bundles", fe = "bundleId", ge = "namedQueries", pe = "name", ye = "indexConfiguration", we = "indexId", be = "collectionGroupIndex", Se = "collectionGroup", De = "indexState", ve = [ "indexId", "uid" ], Ce = "sequenceNumberIndex", Fe = [ "uid", "sequenceNumber" ], Me = "indexEntries", xe = [ "indexId", "uid", "arrayValue", "directionalValue", "orderedDocumentKey", "documentKey" ], Oe = "documentKeyIndex", Ne = [ "indexId", "uid", "orderedDocumentKey" ], Be = "documentOverlays", Le = [ "userId", "collectionPath", "documentId" ], ke = "collectionPathOverlayIndex", qe = [ "userId", "collectionPath", "largestBatchId" ], Qe = "collectionGroupOverlayIndex", $e = [ "userId", "collectionGroup", "largestBatchId" ], Ke = "globals", Ue = "name", We = [ ...[ ...[ ...[ ...[ G, j, X, K, ae, U, Ee, le ], Re ], oe ], de ], me, ge ], Ge = [ ...We, Be ], ze = [ G, j, X, ee, ae, U, Ee, le, Re, oe, de, me, ge, Be ], je = ze, He = [ ...je, ye, De, Me ], Je = He, Ye = [ ...He, Ke ];
2393
2359
 
2394
2360
  /**
2395
2361
  * @license
@@ -3451,7 +3417,7 @@ function __PRIVATE_valueCompare(e, t) {
3451
3417
  return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e), __PRIVATE_getLocalWriteTime(t));
3452
3418
 
3453
3419
  case 5 /* TypeOrder.StringValue */ :
3454
- return __PRIVATE_compareUtf8Strings(e.stringValue, t.stringValue);
3420
+ return __PRIVATE_primitiveComparator(e.stringValue, t.stringValue);
3455
3421
 
3456
3422
  case 6 /* TypeOrder.BlobValue */ :
3457
3423
  return function __PRIVATE_compareBlobs(e, t) {
@@ -3499,7 +3465,7 @@ function __PRIVATE_valueCompare(e, t) {
3499
3465
  // canonical IDs are independent of insertion order.
3500
3466
  r.sort(), s.sort();
3501
3467
  for (let e = 0; e < r.length && e < s.length; ++e) {
3502
- const t = __PRIVATE_compareUtf8Strings(r[e], s[e]);
3468
+ const t = __PRIVATE_primitiveComparator(r[e], s[e]);
3503
3469
  if (0 !== t) return t;
3504
3470
  const o = __PRIVATE_valueCompare(n[r[e]], i[s[e]]);
3505
3471
  if (0 !== o) return o;
@@ -5911,6 +5877,32 @@ let At = null;
5911
5877
  * Sets the value of the `testingHooksSpi` object.
5912
5878
  * @param instance the instance to set.
5913
5879
  */
5880
+ /**
5881
+ * @license
5882
+ * Copyright 2023 Google LLC
5883
+ *
5884
+ * Licensed under the Apache License, Version 2.0 (the "License");
5885
+ * you may not use this file except in compliance with the License.
5886
+ * You may obtain a copy of the License at
5887
+ *
5888
+ * http://www.apache.org/licenses/LICENSE-2.0
5889
+ *
5890
+ * Unless required by applicable law or agreed to in writing, software
5891
+ * distributed under the License is distributed on an "AS IS" BASIS,
5892
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5893
+ * See the License for the specific language governing permissions and
5894
+ * limitations under the License.
5895
+ */
5896
+ /**
5897
+ * An instance of the Platform's 'TextEncoder' implementation.
5898
+ */
5899
+ function __PRIVATE_newTextEncoder() {
5900
+ return new TextEncoder;
5901
+ }
5902
+
5903
+ /**
5904
+ * An instance of the Platform's 'TextDecoder' implementation.
5905
+ */
5914
5906
  /**
5915
5907
  * @license
5916
5908
  * Copyright 2022 Google LLC
@@ -6191,13 +6183,13 @@ class __PRIVATE_WatchTargetChange {
6191
6183
  */
6192
6184
  this.ye = __PRIVATE_snapshotChangesMap(),
6193
6185
  /** See public getters for explanations of these fields. */
6194
- this.we = ByteString.EMPTY_BYTE_STRING, this.Se = !1,
6186
+ this.we = ByteString.EMPTY_BYTE_STRING, this.be = !1,
6195
6187
  /**
6196
6188
  * Whether this target state should be included in the next snapshot. We
6197
6189
  * initialize to true so that newly-added targets are included in the next
6198
6190
  * RemoteEvent.
6199
6191
  */
6200
- this.be = !0;
6192
+ this.Se = !0;
6201
6193
  }
6202
6194
  /**
6203
6195
  * Whether this target has been marked 'current'.
@@ -6207,7 +6199,7 @@ class __PRIVATE_WatchTargetChange {
6207
6199
  * was added and that the target is consistent with the rest of the watch
6208
6200
  * stream.
6209
6201
  */ get current() {
6210
- return this.Se;
6202
+ return this.be;
6211
6203
  }
6212
6204
  /** The last resume token sent to us for this target. */ get resumeToken() {
6213
6205
  return this.we;
@@ -6216,13 +6208,13 @@ class __PRIVATE_WatchTargetChange {
6216
6208
  return 0 !== this.pe;
6217
6209
  }
6218
6210
  /** Whether we have modified any state that should trigger a snapshot. */ get ve() {
6219
- return this.be;
6211
+ return this.Se;
6220
6212
  }
6221
6213
  /**
6222
6214
  * Applies the resume token to the TargetChange, but only when it has a new
6223
6215
  * value. Empty resumeTokens are discarded.
6224
6216
  */ Ce(e) {
6225
- e.approximateByteSize() > 0 && (this.be = !0, this.we = e);
6217
+ e.approximateByteSize() > 0 && (this.Se = !0, this.we = e);
6226
6218
  }
6227
6219
  /**
6228
6220
  * Creates a target change from the current set of changes.
@@ -6248,18 +6240,18 @@ class __PRIVATE_WatchTargetChange {
6248
6240
  default:
6249
6241
  fail();
6250
6242
  }
6251
- })), new TargetChange(this.we, this.Se, e, t, n);
6243
+ })), new TargetChange(this.we, this.be, e, t, n);
6252
6244
  }
6253
6245
  /**
6254
6246
  * Resets the document changes and sets `hasPendingChanges` to false.
6255
6247
  */ Me() {
6256
- this.be = !1, this.ye = __PRIVATE_snapshotChangesMap();
6248
+ this.Se = !1, this.ye = __PRIVATE_snapshotChangesMap();
6257
6249
  }
6258
6250
  xe(e, t) {
6259
- this.be = !0, this.ye = this.ye.insert(e, t);
6251
+ this.Se = !0, this.ye = this.ye.insert(e, t);
6260
6252
  }
6261
6253
  Oe(e) {
6262
- this.be = !0, this.ye = this.ye.remove(e);
6254
+ this.Se = !0, this.ye = this.ye.remove(e);
6263
6255
  }
6264
6256
  Ne() {
6265
6257
  this.pe += 1;
@@ -6268,7 +6260,7 @@ class __PRIVATE_WatchTargetChange {
6268
6260
  this.pe -= 1, __PRIVATE_hardAssert(this.pe >= 0);
6269
6261
  }
6270
6262
  Le() {
6271
- this.be = !0, this.Se = !0;
6263
+ this.Se = !0, this.be = !0;
6272
6264
  }
6273
6265
  }
6274
6266
 
@@ -6283,13 +6275,13 @@ class __PRIVATE_WatchChangeAggregator {
6283
6275
  /** Keeps track of the documents to update since the last raised snapshot. */
6284
6276
  this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
6285
6277
  /** A mapping of document keys to their set of target IDs. */
6286
- this.Ue = __PRIVATE_documentTargetMap(),
6278
+ this.Ke = __PRIVATE_documentTargetMap(),
6287
6279
  /**
6288
6280
  * A map of targets with existence filter mismatches. These targets are
6289
6281
  * known to be inconsistent and their listens needs to be re-established by
6290
6282
  * RemoteStore.
6291
6283
  */
6292
- this.Ke = new SortedMap(__PRIVATE_primitiveComparator);
6284
+ this.Ue = new SortedMap(__PRIVATE_primitiveComparator);
6293
6285
  }
6294
6286
  /**
6295
6287
  * Processes and adds the DocumentWatchChange to the current set of changes.
@@ -6378,7 +6370,7 @@ class __PRIVATE_WatchChangeAggregator {
6378
6370
  // trigger re-run of the query.
6379
6371
  this.Ye(t);
6380
6372
  const e = 2 /* BloomFilterApplicationStatus.FalsePositive */ === i ? "TargetPurposeExistenceFilterMismatchBloom" /* TargetPurpose.ExistenceFilterMismatchBloom */ : "TargetPurposeExistenceFilterMismatch" /* TargetPurpose.ExistenceFilterMismatch */;
6381
- this.Ke = this.Ke.insert(t, e);
6373
+ this.Ue = this.Ue.insert(t, e);
6382
6374
  }
6383
6375
  null == At || At.rt(function __PRIVATE_createExistenceFilterMismatchInfoForTestingHooks(e, t, n, r, i) {
6384
6376
  var s, o, _, a, u, c;
@@ -6490,7 +6482,7 @@ class __PRIVATE_WatchChangeAggregator {
6490
6482
 
6491
6483
  // TODO(gsoltis): Expand on this comment once GC is available in the JS
6492
6484
  // client.
6493
- this.Ue.forEach(((e, t) => {
6485
+ this.Ke.forEach(((e, t) => {
6494
6486
  let r = !0;
6495
6487
  t.forEachWhile((e => {
6496
6488
  const t = this.Xe(e);
@@ -6498,9 +6490,9 @@ class __PRIVATE_WatchChangeAggregator {
6498
6490
  !1);
6499
6491
  })), r && (n = n.add(e));
6500
6492
  })), this.Qe.forEach(((t, n) => n.setReadTime(e)));
6501
- const r = new RemoteEvent(e, t, this.Ke, this.Qe, n);
6493
+ const r = new RemoteEvent(e, t, this.Ue, this.Qe, n);
6502
6494
  return this.Qe = __PRIVATE_mutableDocumentMap(), this.$e = __PRIVATE_documentTargetMap(),
6503
- this.Ue = __PRIVATE_documentTargetMap(), this.Ke = new SortedMap(__PRIVATE_primitiveComparator),
6495
+ this.Ke = __PRIVATE_documentTargetMap(), this.Ue = new SortedMap(__PRIVATE_primitiveComparator),
6504
6496
  r;
6505
6497
  }
6506
6498
  /**
@@ -6512,7 +6504,7 @@ class __PRIVATE_WatchChangeAggregator {
6512
6504
  if (!this.Je(e)) return;
6513
6505
  const n = this.ut(e, t.key) ? 2 /* ChangeType.Modified */ : 0 /* ChangeType.Added */;
6514
6506
  this.He(e).xe(t.key, n), this.Qe = this.Qe.insert(t.key, t), this.$e = this.$e.insert(t.key, this._t(t.key).add(e)),
6515
- this.Ue = this.Ue.insert(t.key, this.ct(t.key).add(e));
6507
+ this.Ke = this.Ke.insert(t.key, this.ct(t.key).add(e));
6516
6508
  }
6517
6509
  /**
6518
6510
  * Removes the provided document from the target mapping. If the
@@ -6528,7 +6520,7 @@ class __PRIVATE_WatchChangeAggregator {
6528
6520
  this.ut(e, t) ? r.xe(t, 1 /* ChangeType.Removed */) :
6529
6521
  // The document may have entered and left the target before we raised a
6530
6522
  // snapshot, so we can just ignore the change.
6531
- r.Oe(t), this.Ue = this.Ue.insert(t, this.ct(t).delete(e)), this.Ue = this.Ue.insert(t, this.ct(t).add(e)),
6523
+ r.Oe(t), this.Ke = this.Ke.insert(t, this.ct(t).delete(e)), this.Ke = this.Ke.insert(t, this.ct(t).add(e)),
6532
6524
  n && (this.Qe = this.Qe.insert(t, n));
6533
6525
  }
6534
6526
  removeTarget(e) {
@@ -6553,8 +6545,8 @@ class __PRIVATE_WatchChangeAggregator {
6553
6545
  return t || (t = new __PRIVATE_TargetState, this.qe.set(e, t)), t;
6554
6546
  }
6555
6547
  ct(e) {
6556
- let t = this.Ue.get(e);
6557
- return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.Ue = this.Ue.insert(e, t)),
6548
+ let t = this.Ke.get(e);
6549
+ return t || (t = new SortedSet(__PRIVATE_primitiveComparator), this.Ke = this.Ke.insert(e, t)),
6558
6550
  t;
6559
6551
  }
6560
6552
  _t(e) {
@@ -7737,7 +7729,7 @@ function __PRIVATE_toDbIndexState(e, t, n, r) {
7737
7729
  * limitations under the License.
7738
7730
  */ class __PRIVATE_IndexedDbGlobalsCache {
7739
7731
  dt(e) {
7740
- return __PRIVATE_getStore(e, Ue);
7732
+ return __PRIVATE_getStore(e, Ke);
7741
7733
  }
7742
7734
  getSessionToken(e) {
7743
7735
  return this.dt(e).get("sessionToken").next((e => {
@@ -7798,12 +7790,12 @@ class __PRIVATE_FirestoreIndexValueWriter {
7798
7790
  let n = e.timestampValue;
7799
7791
  this.ft(t, 20), "string" == typeof n && (n = __PRIVATE_normalizeTimestamp(n)), t.yt(`${n.seconds || ""}`),
7800
7792
  t.gt(n.nanos || 0);
7801
- } else if ("stringValue" in e) this.wt(e.stringValue, t), this.St(t); else if ("bytesValue" in e) this.ft(t, 30),
7802
- t.bt(__PRIVATE_normalizeByteString(e.bytesValue)), this.St(t); else if ("referenceValue" in e) this.Dt(e.referenceValue, t); else if ("geoPointValue" in e) {
7793
+ } else if ("stringValue" in e) this.wt(e.stringValue, t), this.bt(t); else if ("bytesValue" in e) this.ft(t, 30),
7794
+ t.St(__PRIVATE_normalizeByteString(e.bytesValue)), this.bt(t); else if ("referenceValue" in e) this.Dt(e.referenceValue, t); else if ("geoPointValue" in e) {
7803
7795
  const n = e.geoPointValue;
7804
7796
  this.ft(t, 45), t.gt(n.latitude || 0), t.gt(n.longitude || 0);
7805
7797
  } else "mapValue" in e ? __PRIVATE_isMaxValue(e) ? this.ft(t, Number.MAX_SAFE_INTEGER) : __PRIVATE_isVectorValue(e) ? this.vt(e.mapValue, t) : (this.Ct(e.mapValue, t),
7806
- this.St(t)) : "arrayValue" in e ? (this.Ft(e.arrayValue, t), this.St(t)) : fail();
7798
+ this.bt(t)) : "arrayValue" in e ? (this.Ft(e.arrayValue, t), this.bt(t)) : fail();
7807
7799
  }
7808
7800
  wt(e, t) {
7809
7801
  this.ft(t, 25), this.Mt(e, t);
@@ -7840,7 +7832,7 @@ class __PRIVATE_FirestoreIndexValueWriter {
7840
7832
  ft(e, t) {
7841
7833
  e.gt(t);
7842
7834
  }
7843
- St(e) {
7835
+ bt(e) {
7844
7836
  // While the SDK does not implement truncation, the truncation marker is
7845
7837
  // used to terminate all variable length values (which are strings, bytes,
7846
7838
  // references, arrays and maps).
@@ -7949,10 +7941,10 @@ function __PRIVATE_unsignedNumLength(e) {
7949
7941
  }
7950
7942
  this.qt();
7951
7943
  }
7952
- Ut(e) {
7944
+ Kt(e) {
7953
7945
  // Values are encoded with a single byte length prefix, followed by the
7954
7946
  // actual value in big-endian format with leading 0 bytes dropped.
7955
- const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
7947
+ const t = this.Ut(e), n = __PRIVATE_unsignedNumLength(t);
7956
7948
  this.Wt(1 + n), this.buffer[this.position++] = 255 & n;
7957
7949
  // Write the length
7958
7950
  for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = 255 & t[e];
@@ -7960,7 +7952,7 @@ function __PRIVATE_unsignedNumLength(e) {
7960
7952
  Gt(e) {
7961
7953
  // Values are encoded with a single byte length prefix, followed by the
7962
7954
  // inverted value in big-endian format with leading 0 bytes dropped.
7963
- const t = this.Kt(e), n = __PRIVATE_unsignedNumLength(t);
7955
+ const t = this.Ut(e), n = __PRIVATE_unsignedNumLength(t);
7964
7956
  this.Wt(1 + n), this.buffer[this.position++] = ~(255 & n);
7965
7957
  // Write the length
7966
7958
  for (let e = t.length - n; e < t.length; ++e) this.buffer[this.position++] = ~(255 & t[e]);
@@ -7995,7 +7987,7 @@ function __PRIVATE_unsignedNumLength(e) {
7995
7987
  * -0.0 < 0.0
7996
7988
  * all non-NaN < NaN
7997
7989
  * NaN = NaN
7998
- */ Kt(e) {
7990
+ */ Ut(e) {
7999
7991
  const t =
8000
7992
  /** Converts a JavaScript number to a byte array (using big endian encoding). */
8001
7993
  function __PRIVATE_doubleToLongBits(e) {
@@ -8047,14 +8039,14 @@ class __PRIVATE_AscendingIndexByteEncoder {
8047
8039
  constructor(e) {
8048
8040
  this.Zt = e;
8049
8041
  }
8050
- bt(e) {
8042
+ St(e) {
8051
8043
  this.Zt.Ot(e);
8052
8044
  }
8053
8045
  yt(e) {
8054
8046
  this.Zt.Qt(e);
8055
8047
  }
8056
8048
  gt(e) {
8057
- this.Zt.Ut(e);
8049
+ this.Zt.Kt(e);
8058
8050
  }
8059
8051
  Vt() {
8060
8052
  this.Zt.zt();
@@ -8065,7 +8057,7 @@ class __PRIVATE_DescendingIndexByteEncoder {
8065
8057
  constructor(e) {
8066
8058
  this.Zt = e;
8067
8059
  }
8068
- bt(e) {
8060
+ St(e) {
8069
8061
  this.Zt.Lt(e);
8070
8062
  }
8071
8063
  yt(e) {
@@ -8895,7 +8887,7 @@ class __PRIVATE_IndexedDbIndexManager {
8895
8887
  let i = 0;
8896
8888
  for (const s of __PRIVATE_fieldIndexGetDirectionalSegments(e)) {
8897
8889
  const e = n[i++];
8898
- for (const n of r) if (this.Sn(t, s.fieldPath) && isArray(e)) r = this.bn(r, s, e); else {
8890
+ for (const n of r) if (this.bn(t, s.fieldPath) && isArray(e)) r = this.Sn(r, s, e); else {
8899
8891
  const t = n.tn(s.kind);
8900
8892
  __PRIVATE_FirestoreIndexValueWriter.xt.At(e, t);
8901
8893
  }
@@ -8919,7 +8911,7 @@ class __PRIVATE_IndexedDbIndexManager {
8919
8911
  * The method appends each value to all existing encoders (e.g. filter("a",
8920
8912
  * "==", "a1").filter("b", "in", ["b1", "b2"]) becomes ["a1,b1", "a1,b2"]). A
8921
8913
  * list of new encoders is returned.
8922
- */ bn(e, t, n) {
8914
+ */ Sn(e, t, n) {
8923
8915
  const r = [ ...e ], i = [];
8924
8916
  for (const e of n.arrayValue.values || []) for (const n of r) {
8925
8917
  const r = new __PRIVATE_IndexByteEncoder;
@@ -8927,12 +8919,12 @@ class __PRIVATE_IndexedDbIndexManager {
8927
8919
  }
8928
8920
  return i;
8929
8921
  }
8930
- Sn(e, t) {
8922
+ bn(e, t) {
8931
8923
  return !!e.filters.find((e => e instanceof FieldFilter && e.field.isEqual(t) && ("in" /* Operator.IN */ === e.op || "not-in" /* Operator.NOT_IN */ === e.op)));
8932
8924
  }
8933
8925
  getFieldIndexes(e, t) {
8934
8926
  const n = __PRIVATE_indexConfigurationStore(e), r = __PRIVATE_indexStateStore(e);
8935
- return (t ? n.G(Se, IDBKeyRange.bound(t, t)) : n.G()).next((e => {
8927
+ return (t ? n.G(be, IDBKeyRange.bound(t, t)) : n.G()).next((e => {
8936
8928
  const t = [];
8937
8929
  return PersistencePromise.forEach(e, (e => r.get([ e.indexId, this.uid ]).next((n => {
8938
8930
  t.push(function __PRIVATE_fromDbIndexConfiguration(e, t) {
@@ -8950,7 +8942,7 @@ class __PRIVATE_IndexedDbIndexManager {
8950
8942
  }
8951
8943
  updateCollectionGroup(e, t, n) {
8952
8944
  const r = __PRIVATE_indexConfigurationStore(e), i = __PRIVATE_indexStateStore(e);
8953
- return this.vn(e).next((e => r.G(Se, IDBKeyRange.bound(t, t)).next((t => PersistencePromise.forEach(t, (t => i.put(__PRIVATE_toDbIndexState(t.indexId, this.uid, e, n))))))));
8945
+ return this.vn(e).next((e => r.G(be, IDBKeyRange.bound(t, t)).next((t => PersistencePromise.forEach(t, (t => i.put(__PRIVATE_toDbIndexState(t.indexId, this.uid, e, n))))))));
8954
8946
  }
8955
8947
  updateIndexEntries(e, t) {
8956
8948
  // Porting Note: `getFieldIndexes()` on Web does not cache index lookups as
@@ -9147,7 +9139,7 @@ function __PRIVATE_getMinOffsetFromFieldIndexes(e) {
9147
9139
  sequenceNumbersCollected: 0,
9148
9140
  targetsRemoved: 0,
9149
9141
  documentsRemoved: 0
9150
- }, St = 41943040;
9142
+ }, bt = 41943040;
9151
9143
 
9152
9144
  class LruParams {
9153
9145
  static withCacheSize(e) {
@@ -9232,7 +9224,7 @@ function removeMutationBatch(e, t, n) {
9232
9224
  * limitations under the License.
9233
9225
  */
9234
9226
  /** A mutation queue for a specific user, backed by IndexedDB. */ LruParams.DEFAULT_COLLECTION_PERCENTILE = 10,
9235
- LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1e3, LruParams.DEFAULT = new LruParams(St, LruParams.DEFAULT_COLLECTION_PERCENTILE, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),
9227
+ LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT = 1e3, LruParams.DEFAULT = new LruParams(bt, LruParams.DEFAULT_COLLECTION_PERCENTILE, LruParams.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),
9236
9228
  LruParams.DISABLED = new LruParams(-1, 0, 0);
9237
9229
 
9238
9230
  class __PRIVATE_IndexedDbMutationQueue {
@@ -9563,14 +9555,14 @@ class __PRIVATE_TargetIdGenerator {
9563
9555
  next() {
9564
9556
  return this.$n += 2, this.$n;
9565
9557
  }
9566
- static Un() {
9558
+ static Kn() {
9567
9559
  // The target cache generator must return '2' in its first call to `next()`
9568
9560
  // as there is no differentiation in the protocol layer between an unset
9569
9561
  // number and the number '0'. If we were to sent a target with target ID
9570
9562
  // '0', the backend would consider it unset and replace it with its own ID.
9571
9563
  return new __PRIVATE_TargetIdGenerator(0);
9572
9564
  }
9573
- static Kn() {
9565
+ static Un() {
9574
9566
  // Sync engine assigns target IDs for limbo document detection.
9575
9567
  return new __PRIVATE_TargetIdGenerator(-1);
9576
9568
  }
@@ -9789,7 +9781,7 @@ class __PRIVATE_TargetIdGenerator {
9789
9781
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9790
9782
  * See the License for the specific language governing permissions and
9791
9783
  * limitations under the License.
9792
- */ const bt = "LruGarbageCollector", Dt = 1048576;
9784
+ */ const St = "LruGarbageCollector", Dt = 1048576;
9793
9785
 
9794
9786
  function __PRIVATE_bufferEntryComparator([e, t], [n, r]) {
9795
9787
  const i = __PRIVATE_primitiveComparator(e, n);
@@ -9842,12 +9834,12 @@ function __PRIVATE_bufferEntryComparator([e, t], [n, r]) {
9842
9834
  return null !== this.Xn;
9843
9835
  }
9844
9836
  er(e) {
9845
- __PRIVATE_logDebug(bt, `Garbage collection scheduled in ${e}ms`), this.Xn = this.asyncQueue.enqueueAfterDelay("lru_garbage_collection" /* TimerId.LruGarbageCollection */ , e, (async () => {
9837
+ __PRIVATE_logDebug(St, `Garbage collection scheduled in ${e}ms`), this.Xn = this.asyncQueue.enqueueAfterDelay("lru_garbage_collection" /* TimerId.LruGarbageCollection */ , e, (async () => {
9846
9838
  this.Xn = null;
9847
9839
  try {
9848
9840
  await this.localStore.collectGarbage(this.garbageCollector);
9849
9841
  } catch (e) {
9850
- __PRIVATE_isIndexedDbTransactionError(e) ? __PRIVATE_logDebug(bt, "Ignoring IndexedDB error during garbage collection: ", e) : await __PRIVATE_ignoreIfPrimaryLeaseLoss(e);
9842
+ __PRIVATE_isIndexedDbTransactionError(e) ? __PRIVATE_logDebug(St, "Ignoring IndexedDB error during garbage collection: ", e) : await __PRIVATE_ignoreIfPrimaryLeaseLoss(e);
9851
9843
  }
9852
9844
  await this.er(3e5);
9853
9845
  }));
@@ -10965,13 +10957,13 @@ class OverlayedDocument {
10965
10957
  */ removeReference(e, t) {
10966
10958
  this.wr(new __PRIVATE_DocReference(e, t));
10967
10959
  }
10968
- Sr(e, t) {
10960
+ br(e, t) {
10969
10961
  e.forEach((e => this.removeReference(e, t)));
10970
10962
  }
10971
10963
  /**
10972
10964
  * Clears all references with a given ID. Calls removeRef() for each key
10973
10965
  * removed.
10974
- */ br(e) {
10966
+ */ Sr(e) {
10975
10967
  const t = new DocumentKey(new ResourcePath([])), n = new __PRIVATE_DocReference(t, e), r = new __PRIVATE_DocReference(t, e + 1), i = [];
10976
10968
  return this.gr.forEachInRange([ n, r ], (e => {
10977
10969
  this.wr(e), i.push(e.key);
@@ -11338,7 +11330,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
11338
11330
  * A ordered bidirectional mapping between documents and the remote target
11339
11331
  * IDs.
11340
11332
  */
11341
- this.Ur = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Kr = __PRIVATE_TargetIdGenerator.Un();
11333
+ this.Kr = new __PRIVATE_ReferenceSet, this.targetCount = 0, this.Ur = __PRIVATE_TargetIdGenerator.Kn();
11342
11334
  }
11343
11335
  forEachTarget(e, t) {
11344
11336
  return this.Qr.forEach(((e, n) => t(n))), PersistencePromise.resolve();
@@ -11350,7 +11342,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
11350
11342
  return PersistencePromise.resolve(this.$r);
11351
11343
  }
11352
11344
  allocateTargetId(e) {
11353
- return this.highestTargetId = this.Kr.next(), PersistencePromise.resolve(this.highestTargetId);
11345
+ return this.highestTargetId = this.Ur.next(), PersistencePromise.resolve(this.highestTargetId);
11354
11346
  }
11355
11347
  setTargetsMetadata(e, t, n) {
11356
11348
  return n && (this.lastRemoteSnapshotVersion = n), t > this.$r && (this.$r = t),
@@ -11359,7 +11351,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
11359
11351
  zn(e) {
11360
11352
  this.Qr.set(e.target, e);
11361
11353
  const t = e.targetId;
11362
- t > this.highestTargetId && (this.Kr = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
11354
+ t > this.highestTargetId && (this.Ur = new __PRIVATE_TargetIdGenerator(t), this.highestTargetId = t),
11363
11355
  e.sequenceNumber > this.$r && (this.$r = e.sequenceNumber);
11364
11356
  }
11365
11357
  addTargetData(e, t) {
@@ -11369,7 +11361,7 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
11369
11361
  return this.zn(t), PersistencePromise.resolve();
11370
11362
  }
11371
11363
  removeTargetData(e, t) {
11372
- return this.Qr.delete(t.target), this.Ur.br(t.targetId), this.targetCount -= 1,
11364
+ return this.Qr.delete(t.target), this.Kr.Sr(t.targetId), this.targetCount -= 1,
11373
11365
  PersistencePromise.resolve();
11374
11366
  }
11375
11367
  removeTargets(e, t, n) {
@@ -11388,24 +11380,24 @@ class __PRIVATE_MemoryRemoteDocumentChangeBuffer extends RemoteDocumentChangeBuf
11388
11380
  return PersistencePromise.resolve(n);
11389
11381
  }
11390
11382
  addMatchingKeys(e, t, n) {
11391
- return this.Ur.yr(t, n), PersistencePromise.resolve();
11383
+ return this.Kr.yr(t, n), PersistencePromise.resolve();
11392
11384
  }
11393
11385
  removeMatchingKeys(e, t, n) {
11394
- this.Ur.Sr(t, n);
11386
+ this.Kr.br(t, n);
11395
11387
  const r = this.persistence.referenceDelegate, i = [];
11396
11388
  return r && t.forEach((t => {
11397
11389
  i.push(r.markPotentiallyOrphaned(e, t));
11398
11390
  })), PersistencePromise.waitFor(i);
11399
11391
  }
11400
11392
  removeMatchingKeysForTargetId(e, t) {
11401
- return this.Ur.br(t), PersistencePromise.resolve();
11393
+ return this.Kr.Sr(t), PersistencePromise.resolve();
11402
11394
  }
11403
11395
  getMatchingKeysForTargetId(e, t) {
11404
- const n = this.Ur.vr(t);
11396
+ const n = this.Kr.vr(t);
11405
11397
  return PersistencePromise.resolve(n);
11406
11398
  }
11407
11399
  containsKey(e, t) {
11408
- return PersistencePromise.resolve(this.Ur.containsKey(t));
11400
+ return PersistencePromise.resolve(this.Kr.containsKey(t));
11409
11401
  }
11410
11402
  }
11411
11403
 
@@ -11533,7 +11525,7 @@ class __PRIVATE_MemoryEagerDelegate {
11533
11525
  return this.ii.add(t.toString()), PersistencePromise.resolve();
11534
11526
  }
11535
11527
  removeTarget(e, t) {
11536
- this.ti.br(t.targetId).forEach((e => this.ii.add(e.toString())));
11528
+ this.ti.Sr(t.targetId).forEach((e => this.ii.add(e.toString())));
11537
11529
  const n = this.persistence.getTargetCache();
11538
11530
  return n.getMatchingKeysForTargetId(e, t.targetId).next((e => {
11539
11531
  e.forEach((e => this.ii.add(e.toString())));
@@ -11666,7 +11658,7 @@ class __PRIVATE_MemoryLruDelegate {
11666
11658
  */ B(e, t, n, r) {
11667
11659
  const i = new __PRIVATE_SimpleDbTransaction("createOrUpgrade", t);
11668
11660
  n < 1 && r >= 1 && (!function __PRIVATE_createPrimaryClientStore(e) {
11669
- e.createObjectStore(K);
11661
+ e.createObjectStore(U);
11670
11662
  }(e), function __PRIVATE_createMutationQueue(e) {
11671
11663
  e.createObjectStore(G, {
11672
11664
  keyPath: z
@@ -11683,7 +11675,7 @@ class __PRIVATE_MemoryLruDelegate {
11683
11675
  * Upgrade function to migrate the 'mutations' store from V1 to V3. Loads
11684
11676
  * and rewrites all data.
11685
11677
  */ (e), __PRIVATE_createQueryCache(e), function __PRIVATE_createLegacyRemoteDocumentCache(e) {
11686
- e.createObjectStore(U);
11678
+ e.createObjectStore(K);
11687
11679
  }(e));
11688
11680
  // Migration 2 to populate the targetGlobal object no longer needed since
11689
11681
  // migration 3 unconditionally clears it.
@@ -11771,13 +11763,13 @@ class __PRIVATE_MemoryLruDelegate {
11771
11763
  keyPath: te
11772
11764
  });
11773
11765
  t.createIndex(ne, re), t.createIndex(ie, se);
11774
- }(e))).next((() => this.hi(e, i))).next((() => e.deleteObjectStore(U)))), n < 14 && r >= 14 && (s = s.next((() => this.Pi(e, i)))),
11766
+ }(e))).next((() => this.hi(e, i))).next((() => e.deleteObjectStore(K)))), n < 14 && r >= 14 && (s = s.next((() => this.Pi(e, i)))),
11775
11767
  n < 15 && r >= 15 && (s = s.next((() => function __PRIVATE_createFieldIndex(e) {
11776
11768
  const t = e.createObjectStore(ye, {
11777
11769
  keyPath: we,
11778
11770
  autoIncrement: !0
11779
11771
  });
11780
- t.createIndex(Se, be, {
11772
+ t.createIndex(be, Se, {
11781
11773
  unique: !1
11782
11774
  });
11783
11775
  const n = e.createObjectStore(De, {
@@ -11800,15 +11792,15 @@ class __PRIVATE_MemoryLruDelegate {
11800
11792
  t.objectStore(Me).clear();
11801
11793
  }))), n < 17 && r >= 17 && (s = s.next((() => {
11802
11794
  !function __PRIVATE_createGlobalsStore(e) {
11803
- e.createObjectStore(Ue, {
11804
- keyPath: Ke
11795
+ e.createObjectStore(Ke, {
11796
+ keyPath: Ue
11805
11797
  });
11806
11798
  }(e);
11807
11799
  }))), s;
11808
11800
  }
11809
11801
  ai(e) {
11810
11802
  let t = 0;
11811
- return e.store(U).Z(((e, n) => {
11803
+ return e.store(K).Z(((e, n) => {
11812
11804
  t += __PRIVATE_dbDocumentSize(n);
11813
11805
  })).next((() => {
11814
11806
  const n = {
@@ -11832,7 +11824,7 @@ class __PRIVATE_MemoryLruDelegate {
11832
11824
  * Ensures that every document in the remote document cache has a corresponding sentinel row
11833
11825
  * with a sequence number. Missing rows are given the most recently used sequence number.
11834
11826
  */ ui(e) {
11835
- const t = e.store(le), n = e.store(U);
11827
+ const t = e.store(le), n = e.store(K);
11836
11828
  return e.store(Ee).get(Ie).next((e => {
11837
11829
  const r = [];
11838
11830
  return n.Z(((n, i) => {
@@ -11863,7 +11855,7 @@ class __PRIVATE_MemoryLruDelegate {
11863
11855
  };
11864
11856
  // Helper to add an index entry iff we haven't already written it.
11865
11857
  // Index existing remote documents.
11866
- return t.store(U).Z({
11858
+ return t.store(K).Z({
11867
11859
  Y: !0
11868
11860
  }, ((e, t) => {
11869
11861
  const n = new ResourcePath(e);
@@ -11883,7 +11875,7 @@ class __PRIVATE_MemoryLruDelegate {
11883
11875
  }));
11884
11876
  }
11885
11877
  hi(e, t) {
11886
- const n = t.store(U), r = [];
11878
+ const n = t.store(K), r = [];
11887
11879
  return n.Z(((e, n) => {
11888
11880
  const i = t.store(ee), s = function __PRIVATE_extractKey(e) {
11889
11881
  return e.document ? new DocumentKey(ResourcePath.fromString(e.document.name).popFirst(5)) : e.noDocument ? DocumentKey.fromSegments(e.noDocument.path) : e.unknownDocument ? DocumentKey.fromSegments(e.unknownDocument.path) : fail();
@@ -12044,7 +12036,7 @@ class __PRIVATE_IndexedDbPersistence {
12044
12036
  // Fail `start()` if `synchronizeTabs` is disabled and we cannot
12045
12037
  // obtain the primary lease.
12046
12038
  throw new FirestoreError(C.FAILED_PRECONDITION, Mt);
12047
- return this.Si(), this.bi(), this.Di(), this.runTransaction("getHighestListenSequenceNumber", "readonly", (e => this.Hr.getHighestSequenceNumber(e)));
12039
+ return this.bi(), this.Si(), this.Di(), this.runTransaction("getHighestListenSequenceNumber", "readonly", (e => this.Hr.getHighestSequenceNumber(e)));
12048
12040
  })).then((e => {
12049
12041
  this.Gr = new __PRIVATE_ListenSequence(e, this.Ii);
12050
12042
  })).then((() => {
@@ -12201,11 +12193,11 @@ class __PRIVATE_IndexedDbPersistence {
12201
12193
  async shutdown() {
12202
12194
  // The shutdown() operations are idempotent and can be called even when
12203
12195
  // start() aborted (e.g. because it couldn't acquire the persistence lease).
12204
- this.zr = !1, this.Ui(), this.Vi && (this.Vi.cancel(), this.Vi = null), this.Ki(),
12196
+ this.zr = !1, this.Ki(), this.Vi && (this.Vi.cancel(), this.Vi = null), this.Ui(),
12205
12197
  this.Wi(),
12206
12198
  // Use `SimpleDb.runTransaction` directly to avoid failing if another tab
12207
12199
  // has obtained the primary lease.
12208
- await this.pi.runTransaction("shutdown", "readwrite", [ K, Re ], (e => {
12200
+ await this.pi.runTransaction("shutdown", "readwrite", [ U, Re ], (e => {
12209
12201
  const t = new __PRIVATE_IndexedDbTransaction(e, __PRIVATE_ListenSequence.ae);
12210
12202
  return this.xi(t).next((() => this.Bi(t)));
12211
12203
  })), this.pi.close(),
@@ -12305,13 +12297,13 @@ class __PRIVATE_IndexedDbPersistence {
12305
12297
  return !(e < n - t) && (!(e > n) || (__PRIVATE_logError(`Detected an update time that is in the future: ${e} > ${n}`),
12306
12298
  !1));
12307
12299
  }
12308
- Si() {
12300
+ bi() {
12309
12301
  null !== this.document && "function" == typeof this.document.addEventListener && (this.Ri = () => {
12310
12302
  this.Ti.enqueueAndForget((() => (this.inForeground = "visible" === this.document.visibilityState,
12311
12303
  this.wi())));
12312
12304
  }, this.document.addEventListener("visibilitychange", this.Ri), this.inForeground = "visible" === this.document.visibilityState);
12313
12305
  }
12314
- Ki() {
12306
+ Ui() {
12315
12307
  this.Ri && (this.document.removeEventListener("visibilitychange", this.Ri), this.Ri = null);
12316
12308
  }
12317
12309
  /**
@@ -12323,13 +12315,13 @@ class __PRIVATE_IndexedDbPersistence {
12323
12315
  * primary lease). LocalStorage is used for this rather than IndexedDb because
12324
12316
  * it is a synchronous API and so can be used reliably from an unload
12325
12317
  * handler.
12326
- */ bi() {
12318
+ */ Si() {
12327
12319
  var e;
12328
12320
  "function" == typeof (null === (e = this.window) || void 0 === e ? void 0 : e.addEventListener) && (this.Ai = () => {
12329
12321
  // Note: In theory, this should be scheduled on the AsyncQueue since it
12330
12322
  // accesses internal state. We execute this code directly during shutdown
12331
12323
  // to make sure it gets a chance to run.
12332
- this.Ui();
12324
+ this.Ki();
12333
12325
  const e = /(?:Version|Mobile)\/1[456]/;
12334
12326
  isSafari() && (navigator.appVersion.match(e) || navigator.userAgent.match(e)) &&
12335
12327
  // On Safari 14, 15, and 16, we do not run any cleanup actions as it might
@@ -12360,7 +12352,7 @@ class __PRIVATE_IndexedDbPersistence {
12360
12352
  /**
12361
12353
  * Record client as zombied (a client that had its tab closed). Zombied
12362
12354
  * clients are ignored during primary tab selection.
12363
- */ Ui() {
12355
+ */ Ki() {
12364
12356
  if (this.yi) try {
12365
12357
  this.yi.setItem(this.Qi(this.clientId), String(Date.now()));
12366
12358
  } catch (e) {
@@ -12383,7 +12375,7 @@ class __PRIVATE_IndexedDbPersistence {
12383
12375
  /**
12384
12376
  * Helper to get a typed SimpleDbStore for the primary client object store.
12385
12377
  */ function __PRIVATE_primaryClientStore(e) {
12386
- return __PRIVATE_getStore(e, K);
12378
+ return __PRIVATE_getStore(e, U);
12387
12379
  }
12388
12380
 
12389
12381
  /**
@@ -13238,14 +13230,14 @@ class __PRIVATE_MutationMetadata {
13238
13230
  /**
13239
13231
  * Parses a MutationMetadata from its JSON representation in WebStorage.
13240
13232
  * Logs a warning and returns null if the format of the data is not valid.
13241
- */ static Ss(e, t, n) {
13233
+ */ static bs(e, t, n) {
13242
13234
  const r = JSON.parse(n);
13243
13235
  let i, s = "object" == typeof r && -1 !== [ "pending", "acknowledged", "rejected" ].indexOf(r.state) && (void 0 === r.error || "object" == typeof r.error);
13244
13236
  return s && r.error && (s = "string" == typeof r.error.message && "string" == typeof r.error.code,
13245
13237
  s && (i = new FirestoreError(r.error.code, r.error.message))), s ? new __PRIVATE_MutationMetadata(e, t, r.state, i) : (__PRIVATE_logError(qt, `Failed to parse mutation state for ID '${t}': ${n}`),
13246
13238
  null);
13247
13239
  }
13248
- bs() {
13240
+ Ss() {
13249
13241
  const e = {
13250
13242
  state: this.state,
13251
13243
  updateTimeMs: Date.now()
@@ -13269,14 +13261,14 @@ class __PRIVATE_QueryTargetMetadata {
13269
13261
  /**
13270
13262
  * Parses a QueryTargetMetadata from its JSON representation in WebStorage.
13271
13263
  * Logs a warning and returns null if the format of the data is not valid.
13272
- */ static Ss(e, t) {
13264
+ */ static bs(e, t) {
13273
13265
  const n = JSON.parse(t);
13274
13266
  let r, i = "object" == typeof n && -1 !== [ "not-current", "current", "rejected" ].indexOf(n.state) && (void 0 === n.error || "object" == typeof n.error);
13275
13267
  return i && n.error && (i = "string" == typeof n.error.message && "string" == typeof n.error.code,
13276
13268
  i && (r = new FirestoreError(n.error.code, n.error.message))), i ? new __PRIVATE_QueryTargetMetadata(e, n.state, r) : (__PRIVATE_logError(qt, `Failed to parse target state for ID '${e}': ${t}`),
13277
13269
  null);
13278
13270
  }
13279
- bs() {
13271
+ Ss() {
13280
13272
  const e = {
13281
13273
  state: this.state,
13282
13274
  updateTimeMs: Date.now()
@@ -13298,7 +13290,7 @@ class __PRIVATE_QueryTargetMetadata {
13298
13290
  /**
13299
13291
  * Parses a RemoteClientState from the JSON representation in WebStorage.
13300
13292
  * Logs a warning and returns null if the format of the data is not valid.
13301
- */ static Ss(e, t) {
13293
+ */ static bs(e, t) {
13302
13294
  const n = JSON.parse(t);
13303
13295
  let r = "object" == typeof n && n.activeTargetIds instanceof Array, i = __PRIVATE_targetIdSet();
13304
13296
  for (let e = 0; r && e < n.activeTargetIds.length; ++e) r = isSafeInteger(n.activeTargetIds[e]),
@@ -13319,7 +13311,7 @@ class __PRIVATE_QueryTargetMetadata {
13319
13311
  /**
13320
13312
  * Parses a SharedOnlineState from its JSON representation in WebStorage.
13321
13313
  * Logs a warning and returns null if the format of the data is not valid.
13322
- */ static Ss(e) {
13314
+ */ static bs(e) {
13323
13315
  const t = JSON.parse(e);
13324
13316
  return "object" == typeof t && -1 !== [ "Unknown", "Online", "Offline" ].indexOf(t.onlineState) && "string" == typeof t.clientId ? new __PRIVATE_SharedOnlineState(t.clientId, t.onlineState) : (__PRIVATE_logError(qt, `Failed to parse online state: ${e}`),
13325
13317
  null);
@@ -13350,7 +13342,7 @@ class __PRIVATE_LocalClientState {
13350
13342
  /**
13351
13343
  * Converts this entry into a JSON-encoded format we can use for WebStorage.
13352
13344
  * Does not encode `clientId` as it is part of the key in WebStorage.
13353
- */ bs() {
13345
+ */ Ss() {
13354
13346
  const e = {
13355
13347
  activeTargetIds: this.activeTargetIds.toArray(),
13356
13348
  updateTimeMs: Date.now()
@@ -13418,16 +13410,16 @@ class __PRIVATE_LocalClientState {
13418
13410
  if (t === this.Cs) continue;
13419
13411
  const e = this.getItem(createWebStorageClientStateKey(this.persistenceKey, t));
13420
13412
  if (e) {
13421
- const n = __PRIVATE_RemoteClientState.Ss(t, e);
13413
+ const n = __PRIVATE_RemoteClientState.bs(t, e);
13422
13414
  n && (this.xs = this.xs.insert(n.clientId, n));
13423
13415
  }
13424
13416
  }
13425
- this.Us();
13417
+ this.Ks();
13426
13418
  // Check if there is an existing online state and call the callback handler
13427
13419
  // if applicable.
13428
13420
  const t = this.storage.getItem(this.Qs);
13429
13421
  if (t) {
13430
- const e = this.Ks(t);
13422
+ const e = this.Us(t);
13431
13423
  e && this.Ws(e);
13432
13424
  }
13433
13425
  for (const e of this.Os) this.Ms(e);
@@ -13465,16 +13457,16 @@ class __PRIVATE_LocalClientState {
13465
13457
  if (this.isActiveQueryTarget(e)) {
13466
13458
  const t = this.storage.getItem(createWebStorageQueryTargetMetadataKey(this.persistenceKey, e));
13467
13459
  if (t) {
13468
- const r = __PRIVATE_QueryTargetMetadata.Ss(e, t);
13460
+ const r = __PRIVATE_QueryTargetMetadata.bs(e, t);
13469
13461
  r && (n = r.state);
13470
13462
  }
13471
13463
  }
13472
13464
  // If the query is listening to cache only, the target ID should not be registered with the
13473
13465
  // local Firestore client as an active watch target.
13474
- return t && this.Hs.Ds(e), this.Us(), n;
13466
+ return t && this.Hs.Ds(e), this.Ks(), n;
13475
13467
  }
13476
13468
  removeLocalQueryTarget(e) {
13477
- this.Hs.vs(e), this.Us();
13469
+ this.Hs.vs(e), this.Ks();
13478
13470
  }
13479
13471
  isLocalQueryTarget(e) {
13480
13472
  return this.Hs.activeTargetIds.has(e);
@@ -13541,7 +13533,7 @@ class __PRIVATE_LocalClientState {
13541
13533
  }
13542
13534
  } else if (t.key === this.Qs) {
13543
13535
  if (null !== t.newValue) {
13544
- const e = this.Ks(t.newValue);
13536
+ const e = this.Us(t.newValue);
13545
13537
  if (e) return this.Ws(e);
13546
13538
  }
13547
13539
  } else if (t.key === this.Bs) {
@@ -13572,12 +13564,12 @@ class __PRIVATE_LocalClientState {
13572
13564
  get Hs() {
13573
13565
  return this.xs.get(this.Cs);
13574
13566
  }
13575
- Us() {
13576
- this.setItem(this.Ns, this.Hs.bs());
13567
+ Ks() {
13568
+ this.setItem(this.Ns, this.Hs.Ss());
13577
13569
  }
13578
13570
  zs(e, t, n) {
13579
13571
  const r = new __PRIVATE_MutationMetadata(this.currentUser, e, t, n), i = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
13580
- this.setItem(i, r.bs());
13572
+ this.setItem(i, r.Ss());
13581
13573
  }
13582
13574
  js(e) {
13583
13575
  const t = createWebStorageMutationBatchKey(this.persistenceKey, this.currentUser, e);
@@ -13592,7 +13584,7 @@ class __PRIVATE_LocalClientState {
13592
13584
  }
13593
13585
  Js(e, t, n) {
13594
13586
  const r = createWebStorageQueryTargetMetadataKey(this.persistenceKey, e), i = new __PRIVATE_QueryTargetMetadata(e, t, n);
13595
- this.setItem(r, i.bs());
13587
+ this.setItem(r, i.Ss());
13596
13588
  }
13597
13589
  Zs(e) {
13598
13590
  const t = JSON.stringify(Array.from(e));
@@ -13610,27 +13602,27 @@ class __PRIVATE_LocalClientState {
13610
13602
  * be parsed.
13611
13603
  */ no(e, t) {
13612
13604
  const n = this.Xs(e);
13613
- return __PRIVATE_RemoteClientState.Ss(n, t);
13605
+ return __PRIVATE_RemoteClientState.bs(n, t);
13614
13606
  }
13615
13607
  /**
13616
13608
  * Parses a mutation batch state in WebStorage. Returns 'null' if the value
13617
13609
  * could not be parsed.
13618
13610
  */ ro(e, t) {
13619
13611
  const n = this.ks.exec(e), r = Number(n[1]), i = void 0 !== n[2] ? n[2] : null;
13620
- return __PRIVATE_MutationMetadata.Ss(new User(i), r, t);
13612
+ return __PRIVATE_MutationMetadata.bs(new User(i), r, t);
13621
13613
  }
13622
13614
  /**
13623
13615
  * Parses a query target state from WebStorage. Returns 'null' if the value
13624
13616
  * could not be parsed.
13625
13617
  */ so(e, t) {
13626
13618
  const n = this.qs.exec(e), r = Number(n[1]);
13627
- return __PRIVATE_QueryTargetMetadata.Ss(r, t);
13619
+ return __PRIVATE_QueryTargetMetadata.bs(r, t);
13628
13620
  }
13629
13621
  /**
13630
13622
  * Parses an online state from WebStorage. Returns 'null' if the value
13631
13623
  * could not be parsed.
13632
- */ Ks(e) {
13633
- return __PRIVATE_SharedOnlineState.Ss(e);
13624
+ */ Us(e) {
13625
+ return __PRIVATE_SharedOnlineState.bs(e);
13634
13626
  }
13635
13627
  _o(e) {
13636
13628
  return JSON.parse(e);
@@ -13854,7 +13846,7 @@ function __PRIVATE_generateUniqueDebugId() {
13854
13846
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13855
13847
  * See the License for the specific language governing permissions and
13856
13848
  * limitations under the License.
13857
- */ const Ut = "RestConnection", Kt = {
13849
+ */ const Kt = "RestConnection", Ut = {
13858
13850
  BatchGetDocuments: "batchGet",
13859
13851
  Commit: "commit",
13860
13852
  RunQuery: "runQuery",
@@ -13881,23 +13873,23 @@ class __PRIVATE_RestConnection {
13881
13873
  const t = e.ssl ? "https" : "http", n = encodeURIComponent(this.databaseId.projectId), r = encodeURIComponent(this.databaseId.database);
13882
13874
  this.po = t + "://" + e.host, this.yo = `projects/${n}/databases/${r}`, this.wo = this.databaseId.database === rt ? `project_id=${n}` : `project_id=${n}&database_id=${r}`;
13883
13875
  }
13884
- So(e, t, n, r, i) {
13885
- const s = __PRIVATE_generateUniqueDebugId(), o = this.bo(e, t.toUriEncodedString());
13886
- __PRIVATE_logDebug(Ut, `Sending RPC '${e}' ${s}:`, o, n);
13876
+ bo(e, t, n, r, i) {
13877
+ const s = __PRIVATE_generateUniqueDebugId(), o = this.So(e, t.toUriEncodedString());
13878
+ __PRIVATE_logDebug(Kt, `Sending RPC '${e}' ${s}:`, o, n);
13887
13879
  const _ = {
13888
13880
  "google-cloud-resource-prefix": this.yo,
13889
13881
  "x-goog-request-params": this.wo
13890
13882
  };
13891
- return this.Do(_, r, i), this.vo(e, o, _, n).then((t => (__PRIVATE_logDebug(Ut, `Received RPC '${e}' ${s}: `, t),
13883
+ return this.Do(_, r, i), this.vo(e, o, _, n).then((t => (__PRIVATE_logDebug(Kt, `Received RPC '${e}' ${s}: `, t),
13892
13884
  t)), (t => {
13893
- throw __PRIVATE_logWarn(Ut, `RPC '${e}' ${s} failed with error: `, t, "url: ", o, "request:", n),
13885
+ throw __PRIVATE_logWarn(Kt, `RPC '${e}' ${s} failed with error: `, t, "url: ", o, "request:", n),
13894
13886
  t;
13895
13887
  }));
13896
13888
  }
13897
13889
  Co(e, t, n, r, i, s) {
13898
13890
  // The REST API automatically aggregates all of the streamed results, so we
13899
13891
  // can just use the normal invoke() method.
13900
- return this.So(e, t, n, r, i);
13892
+ return this.bo(e, t, n, r, i);
13901
13893
  }
13902
13894
  /**
13903
13895
  * Modifies the headers for a request, adding any authorization token if
@@ -13916,8 +13908,8 @@ class __PRIVATE_RestConnection {
13916
13908
  e["Content-Type"] = "text/plain", this.databaseInfo.appId && (e["X-Firebase-GMPID"] = this.databaseInfo.appId),
13917
13909
  t && t.headers.forEach(((t, n) => e[n] = t)), n && n.headers.forEach(((t, n) => e[n] = t));
13918
13910
  }
13919
- bo(e, t) {
13920
- const n = Kt[e];
13911
+ So(e, t) {
13912
+ const n = Ut[e];
13921
13913
  return `${this.po}/v1/${t}:${n}`;
13922
13914
  }
13923
13915
  /**
@@ -13977,10 +13969,10 @@ class __PRIVATE_RestConnection {
13977
13969
  $o() {
13978
13970
  this.Bo();
13979
13971
  }
13980
- Uo(e) {
13972
+ Ko(e) {
13981
13973
  this.ko(e);
13982
13974
  }
13983
- Ko(e) {
13975
+ Uo(e) {
13984
13976
  this.qo(e);
13985
13977
  }
13986
13978
  }
@@ -14132,10 +14124,10 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
14132
14124
  h || (__PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} transport opened.`), P.Qo());
14133
14125
  })), __PRIVATE_unguardedEventListen(c, WebChannel.EventType.CLOSE, (() => {
14134
14126
  h || (h = !0, __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} transport closed`),
14135
- P.Uo());
14127
+ P.Ko());
14136
14128
  })), __PRIVATE_unguardedEventListen(c, WebChannel.EventType.ERROR, (t => {
14137
14129
  h || (h = !0, __PRIVATE_logWarn(Wt, `RPC '${e}' stream ${r} transport errored:`, t),
14138
- P.Uo(new FirestoreError(C.UNAVAILABLE, "The operation could not be completed")));
14130
+ P.Ko(new FirestoreError(C.UNAVAILABLE, "The operation could not be completed")));
14139
14131
  })), __PRIVATE_unguardedEventListen(c, WebChannel.EventType.MESSAGE, (t => {
14140
14132
  var n;
14141
14133
  if (!h) {
@@ -14166,8 +14158,8 @@ class __PRIVATE_WebChannelConnection extends __PRIVATE_RestConnection {
14166
14158
  }(t), i = o.message;
14167
14159
  void 0 === n && (n = C.INTERNAL, i = "Unknown error status: " + t + " with message " + o.message),
14168
14160
  // Mark closed so no further events are propagated
14169
- h = !0, P.Uo(new FirestoreError(n, i)), c.close();
14170
- } else __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} received:`, i), P.Ko(i);
14161
+ h = !0, P.Ko(new FirestoreError(n, i)), c.close();
14162
+ } else __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} received:`, i), P.Uo(i);
14171
14163
  }
14172
14164
  })), __PRIVATE_unguardedEventListen(o, Event.STAT_EVENT, (t => {
14173
14165
  t.stat === Stat.PROXY ? __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} detected buffering proxy`) : t.stat === Stat.NOPROXY && __PRIVATE_logDebug(Wt, `RPC '${e}' stream ${r} detected no buffering proxy`);
@@ -14678,7 +14670,7 @@ class __PRIVATE_PersistentStream {
14678
14670
  /**
14679
14671
  * Tracks whether or not a handshake has been successfully exchanged and
14680
14672
  * the stream is ready to accept mutations.
14681
- */ get S_() {
14673
+ */ get b_() {
14682
14674
  return this.__ > 0;
14683
14675
  }
14684
14676
  // Override of PersistentStream.start
@@ -14686,7 +14678,7 @@ class __PRIVATE_PersistentStream {
14686
14678
  this.lastStreamToken = void 0, super.start();
14687
14679
  }
14688
14680
  A_() {
14689
- this.S_ && this.b_([]);
14681
+ this.b_ && this.S_([]);
14690
14682
  }
14691
14683
  f_(e, t) {
14692
14684
  return this.connection.Wo("Write", e, t);
@@ -14717,7 +14709,7 @@ class __PRIVATE_PersistentStream {
14717
14709
  const e = {};
14718
14710
  e.database = __PRIVATE_getEncodedDatabaseId(this.serializer), this.I_(e);
14719
14711
  }
14720
- /** Sends a group of mutations to the Firestore backend to apply. */ b_(e) {
14712
+ /** Sends a group of mutations to the Firestore backend to apply. */ S_(e) {
14721
14713
  const t = {
14722
14714
  streamToken: this.lastStreamToken,
14723
14715
  writes: e.map((e => toMutation(this.serializer, e)))
@@ -14759,8 +14751,8 @@ class __PRIVATE_PersistentStream {
14759
14751
  M_() {
14760
14752
  if (this.F_) throw new FirestoreError(C.FAILED_PRECONDITION, "The client has already been terminated.");
14761
14753
  }
14762
- /** Invokes the provided RPC with auth and AppCheck tokens. */ So(e, t, n, r) {
14763
- return this.M_(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.So(e, __PRIVATE_toResourcePath(t, n), r, i, s))).catch((e => {
14754
+ /** Invokes the provided RPC with auth and AppCheck tokens. */ bo(e, t, n, r) {
14755
+ return this.M_(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((([i, s]) => this.connection.bo(e, __PRIVATE_toResourcePath(t, n), r, i, s))).catch((e => {
14764
14756
  throw "FirebaseError" === e.name ? (e.code === C.UNAUTHENTICATED && (this.authCredentials.invalidateToken(),
14765
14757
  this.appCheckCredentials.invalidateToken()), e) : new FirestoreError(C.UNKNOWN, e.toString());
14766
14758
  }));
@@ -14902,7 +14894,7 @@ class __PRIVATE_RemoteStoreImpl {
14902
14894
  * purely based on order, and so we can just shift() writes from the front of
14903
14895
  * the writePipeline as we receive responses.
14904
14896
  */
14905
- this.U_ = [],
14897
+ this.K_ = [],
14906
14898
  /**
14907
14899
  * A mapping of watched targets that the client cares about tracking and the
14908
14900
  * user has explicitly called a 'listen' for this target.
@@ -14912,7 +14904,7 @@ class __PRIVATE_RemoteStoreImpl {
14912
14904
  * to the server. The targets removed with unlistens are removed eagerly
14913
14905
  * without waiting for confirmation from the listen stream.
14914
14906
  */
14915
- this.K_ = new Map,
14907
+ this.U_ = new Map,
14916
14908
  /**
14917
14909
  * A set of reasons for why the RemoteStore may be offline. If empty, the
14918
14910
  * RemoteStore may start its network connections.
@@ -14959,9 +14951,9 @@ async function __PRIVATE_enableNetworkInternal(e) {
14959
14951
  */
14960
14952
  function __PRIVATE_remoteStoreListen(e, t) {
14961
14953
  const n = __PRIVATE_debugCast(e);
14962
- n.K_.has(t.targetId) || (
14954
+ n.U_.has(t.targetId) || (
14963
14955
  // Mark this as something the client is currently listening for.
14964
- n.K_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
14956
+ n.U_.set(t.targetId, t), __PRIVATE_shouldStartWatchStream(n) ?
14965
14957
  // The listen will be sent in onWatchStreamOpen
14966
14958
  __PRIVATE_startWatchStream(n) : __PRIVATE_ensureWatchStream(n).c_() && __PRIVATE_sendWatchRequest(n, t));
14967
14959
  }
@@ -14971,7 +14963,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
14971
14963
  * not being listened to.
14972
14964
  */ function __PRIVATE_remoteStoreUnlisten(e, t) {
14973
14965
  const n = __PRIVATE_debugCast(e), r = __PRIVATE_ensureWatchStream(n);
14974
- n.K_.delete(t), r.c_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.K_.size && (r.c_() ? r.P_() : __PRIVATE_canUseNetwork(n) &&
14966
+ n.U_.delete(t), r.c_() && __PRIVATE_sendUnwatchRequest(n, t), 0 === n.U_.size && (r.c_() ? r.P_() : __PRIVATE_canUseNetwork(n) &&
14975
14967
  // Revert to OnlineState.Unknown if the watch stream is not open and we
14976
14968
  // have no listeners, since without any listens to send we cannot
14977
14969
  // confirm if the stream is healthy and upgrade to OnlineState.Online.
@@ -15000,7 +14992,7 @@ function __PRIVATE_remoteStoreListen(e, t) {
15000
14992
  function __PRIVATE_startWatchStream(e) {
15001
14993
  e.H_ = new __PRIVATE_WatchChangeAggregator({
15002
14994
  getRemoteKeysForTarget: t => e.remoteSyncer.getRemoteKeysForTarget(t),
15003
- lt: t => e.K_.get(t) || null,
14995
+ lt: t => e.U_.get(t) || null,
15004
14996
  it: () => e.datastore.serializer.databaseId
15005
14997
  }), __PRIVATE_ensureWatchStream(e).start(), e.j_.B_();
15006
14998
  }
@@ -15009,7 +15001,7 @@ function __PRIVATE_startWatchStream(e) {
15009
15001
  * Returns whether the watch stream should be started because it's necessary
15010
15002
  * and has not yet been started.
15011
15003
  */ function __PRIVATE_shouldStartWatchStream(e) {
15012
- return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.K_.size > 0;
15004
+ return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWatchStream(e).u_() && e.U_.size > 0;
15013
15005
  }
15014
15006
 
15015
15007
  function __PRIVATE_canUseNetwork(e) {
@@ -15026,7 +15018,7 @@ async function __PRIVATE_onWatchStreamConnected(e) {
15026
15018
  }
15027
15019
 
15028
15020
  async function __PRIVATE_onWatchStreamOpen(e) {
15029
- e.K_.forEach(((t, n) => {
15021
+ e.U_.forEach(((t, n) => {
15030
15022
  __PRIVATE_sendWatchRequest(e, t);
15031
15023
  }));
15032
15024
  }
@@ -15053,7 +15045,7 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
15053
15045
  const n = t.cause;
15054
15046
  for (const r of t.targetIds)
15055
15047
  // A watched target might have been removed already.
15056
- e.K_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.K_.delete(r), e.H_.removeTarget(r));
15048
+ e.U_.has(r) && (await e.remoteSyncer.rejectListen(r, n), e.U_.delete(r), e.H_.removeTarget(r));
15057
15049
  }
15058
15050
  /**
15059
15051
  * Attempts to fill our write pipeline with writes from the LocalStore.
@@ -15083,21 +15075,21 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
15083
15075
  // persistent view of these when applying the completed RemoteEvent.
15084
15076
  return n.targetChanges.forEach(((n, r) => {
15085
15077
  if (n.resumeToken.approximateByteSize() > 0) {
15086
- const i = e.K_.get(r);
15078
+ const i = e.U_.get(r);
15087
15079
  // A watched target might have been removed already.
15088
- i && e.K_.set(r, i.withResumeToken(n.resumeToken, t));
15080
+ i && e.U_.set(r, i.withResumeToken(n.resumeToken, t));
15089
15081
  }
15090
15082
  })),
15091
15083
  // Re-establish listens for the targets that have been invalidated by
15092
15084
  // existence filter mismatches.
15093
15085
  n.targetMismatches.forEach(((t, n) => {
15094
- const r = e.K_.get(t);
15086
+ const r = e.U_.get(t);
15095
15087
  if (!r)
15096
15088
  // A watched target might have been removed already.
15097
15089
  return;
15098
15090
  // Clear the resume token for the target, since we're in a known mismatch
15099
15091
  // state.
15100
- e.K_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
15092
+ e.U_.set(t, r.withResumeToken(ByteString.EMPTY_BYTE_STRING, r.snapshotVersion)),
15101
15093
  // Cause a hard reset by unwatching and rewatching immediately, but
15102
15094
  // deliberately don't send a resume token so that we get a full update.
15103
15095
  __PRIVATE_sendUnwatchRequest(e, t);
@@ -15148,11 +15140,11 @@ async function __PRIVATE_onWatchStreamChange(e, t, n) {
15148
15140
 
15149
15141
  async function __PRIVATE_fillWritePipeline(e) {
15150
15142
  const t = __PRIVATE_debugCast(e), n = __PRIVATE_ensureWriteStream(t);
15151
- let r = t.U_.length > 0 ? t.U_[t.U_.length - 1].batchId : Q;
15143
+ let r = t.K_.length > 0 ? t.K_[t.K_.length - 1].batchId : Q;
15152
15144
  for (;__PRIVATE_canAddToWritePipeline(t); ) try {
15153
15145
  const e = await __PRIVATE_localStoreGetNextMutationBatch(t.localStore, r);
15154
15146
  if (null === e) {
15155
- 0 === t.U_.length && n.P_();
15147
+ 0 === t.K_.length && n.P_();
15156
15148
  break;
15157
15149
  }
15158
15150
  r = e.batchId, __PRIVATE_addToWritePipeline(t, e);
@@ -15166,20 +15158,20 @@ async function __PRIVATE_fillWritePipeline(e) {
15166
15158
  * Returns true if we can add to the write pipeline (i.e. the network is
15167
15159
  * enabled and the write pipeline is not full).
15168
15160
  */ function __PRIVATE_canAddToWritePipeline(e) {
15169
- return __PRIVATE_canUseNetwork(e) && e.U_.length < 10;
15161
+ return __PRIVATE_canUseNetwork(e) && e.K_.length < 10;
15170
15162
  }
15171
15163
 
15172
15164
  /**
15173
15165
  * Queues additional writes to be sent to the write stream, sending them
15174
15166
  * immediately if the write stream is established.
15175
15167
  */ function __PRIVATE_addToWritePipeline(e, t) {
15176
- e.U_.push(t);
15168
+ e.K_.push(t);
15177
15169
  const n = __PRIVATE_ensureWriteStream(e);
15178
- n.c_() && n.S_ && n.b_(t.mutations);
15170
+ n.c_() && n.b_ && n.S_(t.mutations);
15179
15171
  }
15180
15172
 
15181
15173
  function __PRIVATE_shouldStartWriteStream(e) {
15182
- return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.U_.length > 0;
15174
+ return __PRIVATE_canUseNetwork(e) && !__PRIVATE_ensureWriteStream(e).u_() && e.K_.length > 0;
15183
15175
  }
15184
15176
 
15185
15177
  function __PRIVATE_startWriteStream(e) {
@@ -15193,11 +15185,11 @@ async function __PRIVATE_onWriteStreamOpen(e) {
15193
15185
  async function __PRIVATE_onWriteHandshakeComplete(e) {
15194
15186
  const t = __PRIVATE_ensureWriteStream(e);
15195
15187
  // Send the write pipeline now that the stream is established.
15196
- for (const n of e.U_) t.b_(n.mutations);
15188
+ for (const n of e.K_) t.S_(n.mutations);
15197
15189
  }
15198
15190
 
15199
15191
  async function __PRIVATE_onMutationResult(e, t, n) {
15200
- const r = e.U_.shift(), i = MutationBatchResult.from(r, t, n);
15192
+ const r = e.K_.shift(), i = MutationBatchResult.from(r, t, n);
15201
15193
  await __PRIVATE_executeWithRecovery(e, (() => e.remoteSyncer.applySuccessfulWrite(i))),
15202
15194
  // It's possible that with the completion of this mutation another
15203
15195
  // slot has freed up.
@@ -15207,7 +15199,7 @@ async function __PRIVATE_onMutationResult(e, t, n) {
15207
15199
  async function __PRIVATE_onWriteStreamClose(e, t) {
15208
15200
  // If the write stream closed after the write handshake completes, a write
15209
15201
  // operation failed and we fail the pending operation.
15210
- t && __PRIVATE_ensureWriteStream(e).S_ &&
15202
+ t && __PRIVATE_ensureWriteStream(e).b_ &&
15211
15203
  // This error affects the actual write.
15212
15204
  await async function __PRIVATE_handleWriteError(e, t) {
15213
15205
  // Only handle permanent errors here. If it's transient, just let the retry
@@ -15217,7 +15209,7 @@ async function __PRIVATE_onWriteStreamClose(e, t) {
15217
15209
  }(t.code)) {
15218
15210
  // This was a permanent error, the request itself was the problem
15219
15211
  // so it's not going to succeed if we resend it.
15220
- const n = e.U_.shift();
15212
+ const n = e.K_.shift();
15221
15213
  // In this case it's also unlikely that the server itself is melting
15222
15214
  // down -- this was just a bad request so inhibit backoff on the next
15223
15215
  // restart.
@@ -15316,8 +15308,8 @@ async function __PRIVATE_remoteStoreHandleCredentialChange(e, t) {
15316
15308
  }), e.G_.push((async t => {
15317
15309
  t ? (e.Y_.h_(),
15318
15310
  // This will start the write stream if necessary.
15319
- await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.U_.length > 0 && (__PRIVATE_logDebug(zt, `Stopping write stream with ${e.U_.length} pending writes`),
15320
- e.U_ = []));
15311
+ await __PRIVATE_fillWritePipeline(e)) : (await e.Y_.stop(), e.K_.length > 0 && (__PRIVATE_logDebug(zt, `Stopping write stream with ${e.K_.length} pending writes`),
15312
+ e.K_ = []));
15321
15313
  }))), e.Y_;
15322
15314
  }
15323
15315
 
@@ -16014,7 +16006,7 @@ class __PRIVATE_RemovedLimboDocument {
16014
16006
  /**
16015
16007
  * The set of remote documents that the server has told us belongs to the target associated with
16016
16008
  * this view.
16017
- */ get Sa() {
16009
+ */ get ba() {
16018
16010
  return this.fa;
16019
16011
  }
16020
16012
  /**
@@ -16026,7 +16018,7 @@ class __PRIVATE_RemovedLimboDocument {
16026
16018
  * @param previousChanges - If this is being called with a refill, then start
16027
16019
  * with this set of docs and changes instead of the current view.
16028
16020
  * @returns a new set of docs, changes, and refill flag.
16029
- */ ba(e, t) {
16021
+ */ Sa(e, t) {
16030
16022
  const n = t ? t.Da : new __PRIVATE_DocumentChangeSet, r = t ? t.wa : this.wa;
16031
16023
  let i = t ? t.mutatedKeys : this.mutatedKeys, s = r, o = !1;
16032
16024
  // Track the last doc in a (full) limit. This is necessary, because some
@@ -16239,7 +16231,7 @@ class __PRIVATE_RemovedLimboDocument {
16239
16231
  // PORTING NOTE: Multi-tab only.
16240
16232
  Oa(e) {
16241
16233
  this.fa = e.gs, this.pa = __PRIVATE_documentKeySet();
16242
- const t = this.ba(e.documents);
16234
+ const t = this.Sa(e.documents);
16243
16235
  return this.applyChanges(t, /* limboResolutionEnabled= */ !0);
16244
16236
  }
16245
16237
  /**
@@ -16331,11 +16323,11 @@ const Jt = "SyncEngine";
16331
16323
  * Keeps track of the information about an active limbo resolution for each
16332
16324
  * active target ID that was started for the purpose of limbo resolution.
16333
16325
  */
16334
- this.Ua = new Map, this.Ka = new __PRIVATE_ReferenceSet,
16326
+ this.Ka = new Map, this.Ua = new __PRIVATE_ReferenceSet,
16335
16327
  /** Stores user completion handlers, indexed by User and BatchId. */
16336
16328
  this.Wa = {},
16337
16329
  /** Stores user callbacks waiting for all pending writes to be acknowledged. */
16338
- this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.Kn(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
16330
+ this.Ga = new Map, this.za = __PRIVATE_TargetIdGenerator.Un(), this.onlineState = "Unknown" /* OnlineState.Unknown */ ,
16339
16331
  // The primary state is set to `true` or `false` immediately after Firestore
16340
16332
  // startup. In the interim, a client should only be considered primary if
16341
16333
  // `isPrimary` is true.
@@ -16388,19 +16380,19 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
16388
16380
  // targets based on view changes. This allows us to only depend on Limbo
16389
16381
  // changes when user code includes queries.
16390
16382
  e.Ha = (t, n, r) => async function __PRIVATE_applyDocChanges(e, t, n, r) {
16391
- let i = t.view.ba(n);
16383
+ let i = t.view.Sa(n);
16392
16384
  i.ls && (
16393
16385
  // The query has a limit and some docs were removed, so we need
16394
16386
  // to re-run the query against the local store to make sure we
16395
16387
  // didn't lose any good docs that had been past the limit.
16396
16388
  i = await __PRIVATE_localStoreExecuteQuery(e.localStore, t.query,
16397
- /* usePreviousResults= */ !1).then((({documents: e}) => t.view.ba(e, i))));
16389
+ /* usePreviousResults= */ !1).then((({documents: e}) => t.view.Sa(e, i))));
16398
16390
  const s = r && r.targetChanges.get(t.targetId), o = r && null != r.targetMismatches.get(t.targetId), _ = t.view.applyChanges(i,
16399
16391
  /* limboResolutionEnabled= */ e.isPrimaryClient, s, o);
16400
16392
  return __PRIVATE_updateTrackedLimbos(e, t.targetId, _.Ma), _.snapshot;
16401
16393
  }(e, t, n, r);
16402
16394
  const s = await __PRIVATE_localStoreExecuteQuery(e.localStore, t,
16403
- /* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.gs), _ = o.ba(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
16395
+ /* usePreviousResults= */ !0), o = new __PRIVATE_View(t, s.gs), _ = o.Sa(s.documents), a = TargetChange.createSynthesizedTargetChangeForCurrentChange(n, r && "Offline" /* OnlineState.Offline */ !== e.onlineState, i), u = o.applyChanges(_,
16404
16396
  /* limboResolutionEnabled= */ e.isPrimaryClient, a);
16405
16397
  __PRIVATE_updateTrackedLimbos(e, n, u.Ma);
16406
16398
  const c = new __PRIVATE_QueryView(t, n, o);
@@ -16515,7 +16507,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
16515
16507
  const e = await __PRIVATE_localStoreApplyRemoteEventToLocalCache(n.localStore, t);
16516
16508
  // Update `receivedDocument` as appropriate for any limbo targets.
16517
16509
  t.targetChanges.forEach(((e, t) => {
16518
- const r = n.Ua.get(t);
16510
+ const r = n.Ka.get(t);
16519
16511
  r && (
16520
16512
  // Since this is a limbo resolution lookup, it's for a single document
16521
16513
  // and it could be added, modified, or removed, but not a combination.
@@ -16569,7 +16561,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
16569
16561
  const r = __PRIVATE_debugCast(e);
16570
16562
  // PORTING NOTE: Multi-tab only.
16571
16563
  r.sharedClientState.updateQueryState(t, "rejected", n);
16572
- const i = r.Ua.get(t), s = i && i.key;
16564
+ const i = r.Ka.get(t), s = i && i.key;
16573
16565
  if (s) {
16574
16566
  // TODO(klimt): We really only should do the following on permission
16575
16567
  // denied errors, but we don't have the cause code here.
@@ -16591,7 +16583,7 @@ async function __PRIVATE_allocateTargetAndMaybeListen(e, t, n, r) {
16591
16583
  // RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
16592
16584
  // this query when the RemoteStore restarts the Watch stream, which should
16593
16585
  // re-trigger the target failure.
16594
- r.$a = r.$a.remove(s), r.Ua.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
16586
+ r.$a = r.$a.remove(s), r.Ka.delete(t), __PRIVATE_pumpEnqueuedLimboResolutions(r);
16595
16587
  } else await __PRIVATE_localStoreReleaseTarget(r.localStore, t,
16596
16588
  /* keepPersistedTargetData */ !1).then((() => __PRIVATE_removeAndCleanupTarget(r, t, n))).catch(__PRIVATE_ignoreIfPrimaryLeaseLoss);
16597
16589
  }
@@ -16685,8 +16677,8 @@ function __PRIVATE_removeAndCleanupTarget(e, t, n = null) {
16685
16677
  e.sharedClientState.removeLocalQueryTarget(t);
16686
16678
  for (const r of e.qa.get(t)) e.ka.delete(r), n && e.La.Ja(r, n);
16687
16679
  if (e.qa.delete(t), e.isPrimaryClient) {
16688
- e.Ka.br(t).forEach((t => {
16689
- e.Ka.containsKey(t) ||
16680
+ e.Ua.Sr(t).forEach((t => {
16681
+ e.Ua.containsKey(t) ||
16690
16682
  // We removed the last reference for this key
16691
16683
  __PRIVATE_removeLimboTarget(e, t);
16692
16684
  }));
@@ -16699,14 +16691,14 @@ function __PRIVATE_removeLimboTarget(e, t) {
16699
16691
  // the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
16700
16692
  const n = e.$a.get(t);
16701
16693
  null !== n && (__PRIVATE_remoteStoreUnlisten(e.remoteStore, n), e.$a = e.$a.remove(t),
16702
- e.Ua.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
16694
+ e.Ka.delete(n), __PRIVATE_pumpEnqueuedLimboResolutions(e));
16703
16695
  }
16704
16696
 
16705
16697
  function __PRIVATE_updateTrackedLimbos(e, t, n) {
16706
- for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.Ka.addReference(r.key, t),
16698
+ for (const r of n) if (r instanceof __PRIVATE_AddedLimboDocument) e.Ua.addReference(r.key, t),
16707
16699
  __PRIVATE_trackLimboChange(e, r); else if (r instanceof __PRIVATE_RemovedLimboDocument) {
16708
- __PRIVATE_logDebug(Jt, "Document no longer in limbo: " + r.key), e.Ka.removeReference(r.key, t);
16709
- e.Ka.containsKey(r.key) ||
16700
+ __PRIVATE_logDebug(Jt, "Document no longer in limbo: " + r.key), e.Ua.removeReference(r.key, t);
16701
+ e.Ua.containsKey(r.key) ||
16710
16702
  // We removed the last reference for this key
16711
16703
  __PRIVATE_removeLimboTarget(e, r.key);
16712
16704
  } else fail();
@@ -16730,7 +16722,7 @@ function __PRIVATE_trackLimboChange(e, t) {
16730
16722
  const t = e.Qa.values().next().value;
16731
16723
  e.Qa.delete(t);
16732
16724
  const n = new DocumentKey(ResourcePath.fromString(t)), r = e.za.next();
16733
- e.Ua.set(r, new LimboResolution(n)), e.$a = e.$a.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence.ae));
16725
+ e.Ka.set(r, new LimboResolution(n)), e.$a = e.$a.insert(n, r), __PRIVATE_remoteStoreListen(e.remoteStore, new TargetData(__PRIVATE_queryToTarget(__PRIVATE_newQueryForPath(n.path)), r, "TargetPurposeLimboResolution" /* TargetPurpose.LimboResolution */ , __PRIVATE_ListenSequence.ae));
16734
16726
  }
16735
16727
  }
16736
16728
 
@@ -16798,7 +16790,7 @@ async function __PRIVATE_syncEngineHandleCredentialChange(e, t) {
16798
16790
  }
16799
16791
 
16800
16792
  function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
16801
- const n = __PRIVATE_debugCast(e), r = n.Ua.get(t);
16793
+ const n = __PRIVATE_debugCast(e), r = n.Ka.get(t);
16802
16794
  if (r && r.Ba) return __PRIVATE_documentKeySet().add(r.key);
16803
16795
  {
16804
16796
  let e = __PRIVATE_documentKeySet();
@@ -16806,7 +16798,7 @@ function __PRIVATE_syncEngineGetRemoteKeysForTarget(e, t) {
16806
16798
  if (!r) return e;
16807
16799
  for (const t of r) {
16808
16800
  const r = n.ka.get(t);
16809
- e = e.unionWith(r.view.Sa);
16801
+ e = e.unionWith(r.view.ba);
16810
16802
  }
16811
16803
  return e;
16812
16804
  }
@@ -16890,9 +16882,9 @@ async function __PRIVATE_syncEngineApplyPrimaryState(e, t) {
16890
16882
  // PORTING NOTE: Multi-Tab only.
16891
16883
  function __PRIVATE_resetLimboDocuments(e) {
16892
16884
  const t = __PRIVATE_debugCast(e);
16893
- t.Ua.forEach(((e, n) => {
16885
+ t.Ka.forEach(((e, n) => {
16894
16886
  __PRIVATE_remoteStoreUnlisten(t.remoteStore, n);
16895
- })), t.Ka.Dr(), t.Ua = new Map, t.$a = new SortedMap(DocumentKey.comparator);
16887
+ })), t.Ua.Dr(), t.Ka = new Map, t.$a = new SortedMap(DocumentKey.comparator);
16896
16888
  }
16897
16889
  /**
16898
16890
  * Reconcile the query views of the provided query targets with the state from
@@ -17592,7 +17584,7 @@ class Transaction$2 {
17592
17584
  const n = __PRIVATE_debugCast(e), r = {
17593
17585
  writes: t.map((e => toMutation(n.serializer, e)))
17594
17586
  };
17595
- await n.So("Commit", n.serializer.databaseId, ResourcePath.emptyPath(), r);
17587
+ await n.bo("Commit", n.serializer.databaseId, ResourcePath.emptyPath(), r);
17596
17588
  }(this.datastore, this.mutations), this.committed = !0;
17597
17589
  }
17598
17590
  recordVersion(e) {
@@ -17954,7 +17946,7 @@ function __PRIVATE_firestoreClientGetDocumentsFromLocalCache(e, t) {
17954
17946
  return e.asyncQueue.enqueueAndForget((async () => async function __PRIVATE_executeQueryFromCache(e, t, n) {
17955
17947
  try {
17956
17948
  const r = await __PRIVATE_localStoreExecuteQuery(e, t,
17957
- /* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.gs), s = i.ba(r.documents), o = i.applyChanges(s,
17949
+ /* usePreviousResults= */ !0), i = new __PRIVATE_View(t, r.gs), s = i.Sa(r.documents), o = i.applyChanges(s,
17958
17950
  /* limboResolutionEnabled= */ !1);
17959
17951
  n.resolve(o.snapshot);
17960
17952
  } catch (e) {
@@ -18327,7 +18319,7 @@ class FirestoreSettingsImpl {
18327
18319
  this.host = Xt, this.ssl = en;
18328
18320
  } else this.host = e.host, this.ssl = null !== (t = e.ssl) && void 0 !== t ? t : en;
18329
18321
  if (this.credentials = e.credentials, this.ignoreUndefinedProperties = !!e.ignoreUndefinedProperties,
18330
- this.localCache = e.localCache, void 0 === e.cacheSizeBytes) this.cacheSizeBytes = St; else {
18322
+ this.localCache = e.localCache, void 0 === e.cacheSizeBytes) this.cacheSizeBytes = bt; else {
18331
18323
  if (-1 !== e.cacheSizeBytes && e.cacheSizeBytes < Dt) throw new FirestoreError(C.INVALID_ARGUMENT, "cacheSizeBytes must be at least 1048576");
18332
18324
  this.cacheSizeBytes = e.cacheSizeBytes;
18333
18325
  }
@@ -18383,7 +18375,7 @@ class Firestore$1 {
18383
18375
  * Whether it's a Firestore or Firestore Lite instance.
18384
18376
  */
18385
18377
  this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new FirestoreSettingsImpl({}),
18386
- this._settingsFrozen = !1,
18378
+ this._settingsFrozen = !1, this._emulatorOptions = {},
18387
18379
  // A task that is assigned when the terminate() is invoked and resolved when
18388
18380
  // all components have shut down. Otherwise, Firestore is not terminated,
18389
18381
  // which can mean either the FirestoreClient is in the process of starting,
@@ -18405,7 +18397,8 @@ class Firestore$1 {
18405
18397
  }
18406
18398
  _setSettings(e) {
18407
18399
  if (this._settingsFrozen) throw new FirestoreError(C.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.");
18408
- this._settings = new FirestoreSettingsImpl(e), void 0 !== e.credentials && (this._authCredentials = function __PRIVATE_makeAuthCredentialsProvider(e) {
18400
+ this._settings = new FirestoreSettingsImpl(e), this._emulatorOptions = e.emulatorOptions || {},
18401
+ void 0 !== e.credentials && (this._authCredentials = function __PRIVATE_makeAuthCredentialsProvider(e) {
18409
18402
  if (!e) return new __PRIVATE_EmptyAuthCredentialsProvider;
18410
18403
  switch (e.type) {
18411
18404
  case "firstParty":
@@ -18422,6 +18415,9 @@ class Firestore$1 {
18422
18415
  _getSettings() {
18423
18416
  return this._settings;
18424
18417
  }
18418
+ _getEmulatorOptions() {
18419
+ return this._emulatorOptions;
18420
+ }
18425
18421
  _freezeSettings() {
18426
18422
  return this._settingsFrozen = !0, this._settings;
18427
18423
  }
@@ -18477,12 +18473,18 @@ class Firestore$1 {
18477
18473
  * Security Rules.
18478
18474
  */ function connectFirestoreEmulator(e, t, n, r = {}) {
18479
18475
  var i;
18480
- const s = (e = __PRIVATE_cast(e, Firestore$1))._getSettings(), o = `${t}:${n}`;
18481
- if (s.host !== Xt && s.host !== o && __PRIVATE_logWarn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),
18482
- e._setSettings(Object.assign(Object.assign({}, s), {
18483
- host: o,
18484
- ssl: !1
18485
- })), r.mockUserToken) {
18476
+ const s = (e = __PRIVATE_cast(e, Firestore$1))._getSettings(), o = Object.assign(Object.assign({}, s), {
18477
+ emulatorOptions: e._getEmulatorOptions()
18478
+ }), _ = `${t}:${n}`;
18479
+ s.host !== Xt && s.host !== _ && __PRIVATE_logWarn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");
18480
+ const a = Object.assign(Object.assign({}, s), {
18481
+ host: _,
18482
+ ssl: !1,
18483
+ emulatorOptions: r
18484
+ });
18485
+ // No-op if the new configuration matches the current configuration. This supports SSR
18486
+ // enviornments which might call `connectFirestoreEmulator` multiple times as a standard practice.
18487
+ if (!deepEqual(a, o) && (e._setSettings(a), r.mockUserToken)) {
18486
18488
  let t, n;
18487
18489
  if ("string" == typeof r.mockUserToken) t = r.mockUserToken, n = User.MOCK_USER; else {
18488
18490
  // Let createMockUserToken validate first (catches common mistakes like
@@ -18719,13 +18721,13 @@ class __PRIVATE_AsyncQueueImpl {
18719
18721
  // Visibility handler that triggers an immediate retry of all retryable
18720
18722
  // operations. Meant to speed up recovery when we regain file system access
18721
18723
  // after page comes into foreground.
18722
- this.Su = () => {
18724
+ this.bu = () => {
18723
18725
  const e = getDocument();
18724
18726
  e && __PRIVATE_logDebug(tn, "Visibility state changed to " + e.visibilityState),
18725
18727
  this.a_.t_();
18726
- }, this.bu = e;
18728
+ }, this.Su = e;
18727
18729
  const t = getDocument();
18728
- t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Su);
18730
+ t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.bu);
18729
18731
  }
18730
18732
  get isShuttingDown() {
18731
18733
  return this.mu;
@@ -18746,7 +18748,7 @@ class __PRIVATE_AsyncQueueImpl {
18746
18748
  if (!this.mu) {
18747
18749
  this.mu = !0, this.yu = e || !1;
18748
18750
  const t = getDocument();
18749
- t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.Su);
18751
+ t && "function" == typeof t.removeEventListener && t.removeEventListener("visibilitychange", this.bu);
18750
18752
  }
18751
18753
  }
18752
18754
  enqueue(e) {
@@ -18790,7 +18792,7 @@ class __PRIVATE_AsyncQueueImpl {
18790
18792
  }
18791
18793
  }
18792
18794
  vu(e) {
18793
- const t = this.bu.then((() => (this.pu = !0, e().catch((e => {
18795
+ const t = this.Su.then((() => (this.pu = !0, e().catch((e => {
18794
18796
  this.gu = e, this.pu = !1;
18795
18797
  const t =
18796
18798
  /**
@@ -18824,7 +18826,7 @@ class __PRIVATE_AsyncQueueImpl {
18824
18826
  // and return the rejected Promise.
18825
18827
  throw __PRIVATE_logError("INTERNAL UNHANDLED ERROR: ", t), e;
18826
18828
  })).then((e => (this.pu = !1, e))))));
18827
- return this.bu = t, t;
18829
+ return this.Su = t, t;
18828
18830
  }
18829
18831
  enqueueAfterDelay(e, t, n) {
18830
18832
  this.Du(),
@@ -18847,8 +18849,8 @@ class __PRIVATE_AsyncQueueImpl {
18847
18849
  // operations were executed.
18848
18850
  let e;
18849
18851
  do {
18850
- e = this.bu, await e;
18851
- } while (e !== this.bu);
18852
+ e = this.Su, await e;
18853
+ } while (e !== this.Su);
18852
18854
  }
18853
18855
  /**
18854
18856
  * For Tests: Determine if a delayed operation with a particular TimerId
@@ -19751,7 +19753,7 @@ function __PRIVATE_isWrite(e) {
19751
19753
  });
19752
19754
  return r.$u(e), r;
19753
19755
  }
19754
- Uu(e) {
19756
+ Ku(e) {
19755
19757
  var t;
19756
19758
  const n = null === (t = this.path) || void 0 === t ? void 0 : t.child(e), r = this.ku({
19757
19759
  path: n,
@@ -19759,7 +19761,7 @@ function __PRIVATE_isWrite(e) {
19759
19761
  });
19760
19762
  return r.Bu(), r;
19761
19763
  }
19762
- Ku(e) {
19764
+ Uu(e) {
19763
19765
  // TODO(b/34871131): We don't support array paths right now; so make path
19764
19766
  // undefined.
19765
19767
  return this.ku({
@@ -19920,7 +19922,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
19920
19922
  // For Compat types, we have to "extract" the underlying types before
19921
19923
  // performing validation.
19922
19924
  r = getModularInstance(r);
19923
- const a = i.Uu(_);
19925
+ const a = i.Ku(_);
19924
19926
  if (r instanceof __PRIVATE_DeleteFieldValueImpl)
19925
19927
  // Add it to the field mask, but don't add anything to updateData.
19926
19928
  s.push(_); else {
@@ -19946,7 +19948,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
19946
19948
  // For Compat types, we have to "extract" the underlying types before
19947
19949
  // performing validation.
19948
19950
  n = getModularInstance(n);
19949
- const r = o.Uu(t);
19951
+ const r = o.Ku(t);
19950
19952
  if (n instanceof __PRIVATE_DeleteFieldValueImpl)
19951
19953
  // Add it to the field mask, but don't add anything to updateData.
19952
19954
  u.push(t); else {
@@ -20024,7 +20026,7 @@ class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue {
20024
20026
  const n = [];
20025
20027
  let r = 0;
20026
20028
  for (const i of e) {
20027
- let e = __PRIVATE_parseData(i, t.Ku(r));
20029
+ let e = __PRIVATE_parseData(i, t.Uu(r));
20028
20030
  null == e && (
20029
20031
  // Just include nulls in the array for fields being replaced with a
20030
20032
  // sentinel.
@@ -22347,9 +22349,9 @@ let an = null;
22347
22349
  return r = Object.assign({
22348
22350
  useFetchStreams: t
22349
22351
  }, r), s._setSettings(r), s;
22350
- }), "PUBLIC").setMultipleInstances(!0)), registerVersion(S, b, e),
22352
+ }), "PUBLIC").setMultipleInstances(!0)), registerVersion(b, S, e),
22351
22353
  // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
22352
- registerVersion(S, b, "esm2017");
22354
+ registerVersion(b, S, "esm2017");
22353
22355
  }();
22354
22356
 
22355
22357
  export { AbstractUserDataWriter, AggregateField, AggregateQuerySnapshot, Bytes, nn as CACHE_SIZE_UNLIMITED, CollectionReference, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Firestore, FirestoreError, GeoPoint, LoadBundleTask, PersistentCacheIndexManager, Query, QueryCompositeFilterConstraint, QueryConstraint, QueryDocumentSnapshot, QueryEndAtConstraint, QueryFieldFilterConstraint, QueryLimitConstraint, QueryOrderByConstraint, QuerySnapshot, QueryStartAtConstraint, SnapshotMetadata, Timestamp, Transaction, VectorValue, WriteBatch, __PRIVATE_AutoId as _AutoId, ByteString as _ByteString, DatabaseId as _DatabaseId, DocumentKey as _DocumentKey, __PRIVATE_EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider, __PRIVATE_EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider, FieldPath$1 as _FieldPath, TestingHooks as _TestingHooks, __PRIVATE_cast as _cast, __PRIVATE_debugAssert as _debugAssert, _internalAggregationQueryToProtoRunAggregationQueryRequest, _internalQueryToProtoQueryTarget, __PRIVATE_isBase64Available as _isBase64Available, __PRIVATE_logWarn as _logWarn, __PRIVATE_validateIsNotUsedTogether as _validateIsNotUsedTogether, addDoc, aggregateFieldEqual, aggregateQuerySnapshotEqual, and, arrayRemove, arrayUnion, average, clearIndexedDbPersistence, collection, collectionGroup, connectFirestoreEmulator, count, deleteAllPersistentCacheIndexes, deleteDoc, deleteField, disableNetwork, disablePersistentCacheIndexAutoCreation, doc, documentId, enableIndexedDbPersistence, enableMultiTabIndexedDbPersistence, enableNetwork, enablePersistentCacheIndexAutoCreation, endAt, endBefore, ensureFirestoreConfigured, executeWrite, getAggregateFromServer, getCountFromServer, getDoc, getDocFromCache, getDocFromServer, getDocs, getDocsFromCache, getDocsFromServer, getFirestore, getPersistentCacheIndexManager, increment, initializeFirestore, limit, limitToLast, loadBundle, memoryEagerGarbageCollector, memoryLocalCache, memoryLruGarbageCollector, namedQuery, onSnapshot, onSnapshotsInSync, or, orderBy, persistentLocalCache, persistentMultipleTabManager, persistentSingleTabManager, query, queryEqual, refEqual, runTransaction, serverTimestamp, setDoc, setIndexConfiguration, setLogLevel, snapshotEqual, startAfter, startAt, sum, terminate, updateDoc, vector, waitForPendingWrites, where, writeBatch };