@firebase/firestore 3.1.1 → 3.2.0-canary.477bdef13

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 (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/firestore/src/register.d.ts +1 -1
  3. package/dist/firestore/src/remote/persistent_stream.d.ts +5 -1
  4. package/dist/firestore/src/util/async_queue.d.ts +4 -2
  5. package/dist/index.esm2017.js +534 -526
  6. package/dist/index.esm2017.js.map +1 -1
  7. package/dist/index.esm5.js +757 -748
  8. package/dist/index.esm5.js.map +1 -1
  9. package/dist/index.node.cjs.js +7049 -9102
  10. package/dist/index.node.cjs.js.map +1 -1
  11. package/dist/{index.node.cjs.esm2017.js → index.node.mjs} +51 -20
  12. package/dist/index.node.mjs.map +1 -0
  13. package/dist/index.rn.js +534 -526
  14. package/dist/index.rn.js.map +1 -1
  15. package/dist/internal.d.ts +4 -2
  16. package/dist/lite/firestore/src/register.d.ts +1 -1
  17. package/dist/lite/firestore/src/remote/persistent_stream.d.ts +5 -1
  18. package/dist/lite/firestore/src/util/async_queue.d.ts +4 -2
  19. package/dist/lite/index.browser.esm2017.js +2 -2
  20. package/dist/lite/index.browser.esm2017.js.map +1 -1
  21. package/dist/lite/index.browser.esm5.js +2 -2
  22. package/dist/lite/index.browser.esm5.js.map +1 -1
  23. package/dist/lite/index.node.cjs.js +1804 -2261
  24. package/dist/lite/index.node.cjs.js.map +1 -1
  25. package/dist/lite/{index.node.esm2017.js → index.node.mjs} +3 -3
  26. package/dist/lite/index.node.mjs.map +1 -0
  27. package/dist/lite/index.rn.esm2017.js +69 -69
  28. package/dist/lite/index.rn.esm2017.js.map +1 -1
  29. package/dist/lite/internal.d.ts +4 -2
  30. package/dist/lite/packages/firestore/src/register.d.ts +1 -1
  31. package/dist/lite/packages/firestore/src/remote/persistent_stream.d.ts +5 -1
  32. package/dist/lite/packages/firestore/src/util/async_queue.d.ts +4 -2
  33. package/dist/lite/private.d.ts +4 -2
  34. package/dist/packages/firestore/dist/index.esm2017.d.ts +38 -38
  35. package/dist/packages/firestore/src/register.d.ts +1 -1
  36. package/dist/packages/firestore/src/remote/persistent_stream.d.ts +5 -1
  37. package/dist/packages/firestore/src/util/async_queue.d.ts +4 -2
  38. package/dist/private.d.ts +4 -2
  39. package/lite/package.json +1 -1
  40. package/package.json +20 -14
  41. package/dist/index.node.cjs.esm2017.js.map +0 -1
  42. package/dist/lite/firestore/dist/lite/index.node.esm2017.d.ts +0 -1195
  43. package/dist/lite/index.node.esm2017.js.map +0 -1
  44. package/dist/packages/firestore/dist/index.node.cjs.esm2017.d.ts +0 -1844
@@ -66,7 +66,7 @@ D.MOCK_USER = new D("mock-user");
66
66
  * See the License for the specific language governing permissions and
67
67
  * limitations under the License.
68
68
  */
69
- let C = "9.1.3";
69
+ let C = "9.2.0-canary.477bdef13";
70
70
 
71
71
  /**
72
72
  * @license
@@ -11072,15 +11072,15 @@ class Xr {
11072
11072
  * ListenerType: The type of the listener that will be used for callbacks
11073
11073
  */
11074
11074
  class Zr {
11075
- constructor(t, e, n, s, i, r) {
11076
- this.Oe = t, this.er = n, this.nr = s, this.credentialsProvider = i, this.listener = r,
11077
- this.state = 0 /* Initial */ ,
11075
+ constructor(t, e, n, s, i, r, o) {
11076
+ this.Oe = t, this.er = n, this.nr = s, this.sr = i, this.credentialsProvider = r,
11077
+ this.listener = o, this.state = 0 /* Initial */ ,
11078
11078
  /**
11079
11079
  * A close count that's incremented every time the stream is closed; used by
11080
11080
  * getCloseGuardedDispatcher() to invalidate callbacks that happen after
11081
11081
  * close.
11082
11082
  */
11083
- this.sr = 0, this.ir = null, this.stream = null, this.rr = new Xr(t, e);
11083
+ this.ir = 0, this.rr = null, this.ar = null, this.stream = null, this.cr = new Xr(t, e);
11084
11084
  }
11085
11085
  /**
11086
11086
  * Returns true if start() has been called and no error has occurred. True
@@ -11088,14 +11088,14 @@ class Zr {
11088
11088
  * encompasses respecting backoff, getting auth tokens, and starting the
11089
11089
  * actual RPC). Use isOpen() to determine if the stream is open and ready for
11090
11090
  * outbound requests.
11091
- */ ar() {
11092
- return 1 /* Starting */ === this.state || 2 /* Open */ === this.state || 4 /* Backoff */ === this.state;
11091
+ */ ur() {
11092
+ return 1 /* Starting */ === this.state || 5 /* Backoff */ === this.state || this.hr();
11093
11093
  }
11094
11094
  /**
11095
11095
  * Returns true if the underlying RPC is open (the onOpen() listener has been
11096
11096
  * called) and the stream is ready for outbound requests.
11097
- */ cr() {
11098
- return 2 /* Open */ === this.state;
11097
+ */ hr() {
11098
+ return 2 /* Open */ === this.state || 3 /* Healthy */ === this.state;
11099
11099
  }
11100
11100
  /**
11101
11101
  * Starts the RPC. Only allowed if isStarted() returns false. The stream is
@@ -11104,7 +11104,7 @@ class Zr {
11104
11104
  *
11105
11105
  * When start returns, isStarted() will return true.
11106
11106
  */ start() {
11107
- 3 /* Error */ !== this.state ? this.auth() : this.ur();
11107
+ 4 /* Error */ !== this.state ? this.auth() : this.lr();
11108
11108
  }
11109
11109
  /**
11110
11110
  * Stops the RPC. This call is idempotent and allowed regardless of the
@@ -11112,7 +11112,7 @@ class Zr {
11112
11112
  *
11113
11113
  * When stop returns, isStarted() and isOpen() will both return false.
11114
11114
  */ async stop() {
11115
- this.ar() && await this.close(0 /* Initial */);
11115
+ this.ur() && await this.close(0 /* Initial */);
11116
11116
  }
11117
11117
  /**
11118
11118
  * After an error the stream will usually back off on the next attempt to
@@ -11121,8 +11121,8 @@ class Zr {
11121
11121
  *
11122
11122
  * Each error will call the onClose() listener. That function can decide to
11123
11123
  * inhibit backoff if required.
11124
- */ hr() {
11125
- this.state = 0 /* Initial */ , this.rr.reset();
11124
+ */ dr() {
11125
+ this.state = 0 /* Initial */ , this.cr.reset();
11126
11126
  }
11127
11127
  /**
11128
11128
  * Marks this stream as idle. If no further actions are performed on the
@@ -11133,22 +11133,25 @@ class Zr {
11133
11133
  *
11134
11134
  * Only streams that are in state 'Open' can be marked idle, as all other
11135
11135
  * states imply pending network operations.
11136
- */ lr() {
11136
+ */ wr() {
11137
11137
  // Starts the idle time if we are in state 'Open' and are not yet already
11138
11138
  // running a timer (in which case the previous idle timeout still applies).
11139
- this.cr() && null === this.ir && (this.ir = this.Oe.enqueueAfterDelay(this.er, 6e4, (() => this.dr())));
11139
+ this.hr() && null === this.rr && (this.rr = this.Oe.enqueueAfterDelay(this.er, 6e4, (() => this._r())));
11140
11140
  }
11141
- /** Sends a message to the underlying stream. */ wr(t) {
11142
- this._r(), this.stream.send(t);
11141
+ /** Sends a message to the underlying stream. */ mr(t) {
11142
+ this.gr(), this.stream.send(t);
11143
11143
  }
11144
- /** Called by the idle timer when the stream should close due to inactivity. */ async dr() {
11145
- if (this.cr())
11144
+ /** Called by the idle timer when the stream should close due to inactivity. */ async _r() {
11145
+ if (this.hr())
11146
11146
  // When timing out an idle stream there's no reason to force the stream into backoff when
11147
11147
  // it restarts so set the stream state to Initial instead of Error.
11148
11148
  return this.close(0 /* Initial */);
11149
11149
  }
11150
- /** Marks the stream as active again. */ _r() {
11151
- this.ir && (this.ir.cancel(), this.ir = null);
11150
+ /** Marks the stream as active again. */ gr() {
11151
+ this.rr && (this.rr.cancel(), this.rr = null);
11152
+ }
11153
+ /** Cancels the health check delayed operation. */ yr() {
11154
+ this.ar && (this.ar.cancel(), this.ar = null);
11152
11155
  }
11153
11156
  /**
11154
11157
  * Closes the stream and cleans up as necessary:
@@ -11164,20 +11167,24 @@ class Zr {
11164
11167
  * @param error - the error the connection was closed with.
11165
11168
  */ async close(t, e) {
11166
11169
  // Cancel any outstanding timers (they're guaranteed not to execute).
11167
- this._r(), this.rr.cancel(),
11170
+ this.gr(), this.yr(), this.cr.cancel(),
11168
11171
  // Invalidates any stream-related callbacks (e.g. from auth or the
11169
11172
  // underlying stream), guaranteeing they won't execute.
11170
- this.sr++, 3 /* Error */ !== t ?
11173
+ this.ir++, 4 /* Error */ !== t ?
11171
11174
  // If this is an intentional close ensure we don't delay our next connection attempt.
11172
- this.rr.reset() : e && e.code === K.RESOURCE_EXHAUSTED ? (
11175
+ this.cr.reset() : e && e.code === K.RESOURCE_EXHAUSTED ? (
11173
11176
  // Log the error. (Probably either 'quota exceeded' or 'max queue length reached'.)
11174
11177
  O(e.toString()), O("Using maximum backoff delay to prevent overloading the backend."),
11175
- this.rr.Yi()) : e && e.code === K.UNAUTHENTICATED &&
11176
- // "unauthenticated" error means the token was rejected. Try force refreshing it in case it
11177
- // just expired.
11178
+ this.cr.Yi()) : e && e.code === K.UNAUTHENTICATED && 3 /* Healthy */ !== this.state &&
11179
+ // "unauthenticated" error means the token was rejected. This should rarely
11180
+ // happen since both Auth and AppCheck ensure a sufficient TTL when we
11181
+ // request a token. If a user manually resets their system clock this can
11182
+ // fail, however. In this case, we should get a Code.UNAUTHENTICATED error
11183
+ // before we received the first message and we need to invalidate the token
11184
+ // to ensure that we fetch a new token.
11178
11185
  this.credentialsProvider.invalidateToken(),
11179
11186
  // Clean up the underlying stream because we are no longer interested in events.
11180
- null !== this.stream && (this.mr(), this.stream.close(), this.stream = null),
11187
+ null !== this.stream && (this.pr(), this.stream.close(), this.stream = null),
11181
11188
  // This state must be assigned before calling onClose() to allow the callback to
11182
11189
  // inhibit backoff or otherwise manipulate the state in its non-started state.
11183
11190
  this.state = t,
@@ -11187,59 +11194,60 @@ class Zr {
11187
11194
  /**
11188
11195
  * Can be overridden to perform additional cleanup before the stream is closed.
11189
11196
  * Calling super.tearDown() is not required.
11190
- */ mr() {}
11197
+ */ pr() {}
11191
11198
  auth() {
11192
11199
  this.state = 1 /* Starting */;
11193
- const t = this.gr(this.sr), e = this.sr;
11200
+ const t = this.Tr(this.ir), e = this.ir;
11194
11201
  // TODO(mikelehen): Just use dispatchIfNotClosed, but see TODO below.
11195
11202
  this.credentialsProvider.getToken().then((t => {
11196
11203
  // Stream can be stopped while waiting for authentication.
11197
11204
  // TODO(mikelehen): We really should just use dispatchIfNotClosed
11198
11205
  // and let this dispatch onto the queue, but that opened a spec test can
11199
11206
  // of worms that I don't want to deal with in this PR.
11200
- this.sr === e &&
11207
+ this.ir === e &&
11201
11208
  // Normally we'd have to schedule the callback on the AsyncQueue.
11202
11209
  // However, the following calls are safe to be called outside the
11203
11210
  // AsyncQueue since they don't chain asynchronous calls
11204
- this.yr(t);
11211
+ this.Er(t);
11205
11212
  }), (e => {
11206
11213
  t((() => {
11207
11214
  const t = new j(K.UNKNOWN, "Fetching auth token failed: " + e.message);
11208
- return this.pr(t);
11215
+ return this.Ir(t);
11209
11216
  }));
11210
11217
  }));
11211
11218
  }
11212
- yr(t) {
11213
- const e = this.gr(this.sr);
11214
- this.stream = this.Tr(t), this.stream.Si((() => {
11215
- e((() => (this.state = 2 /* Open */ , this.listener.Si())));
11219
+ Er(t) {
11220
+ const e = this.Tr(this.ir);
11221
+ this.stream = this.Ar(t), this.stream.Si((() => {
11222
+ e((() => (this.state = 2 /* Open */ , this.ar = this.Oe.enqueueAfterDelay(this.nr, 1e4, (() => (this.hr() && (this.state = 3 /* Healthy */),
11223
+ Promise.resolve()))), this.listener.Si())));
11216
11224
  })), this.stream.Ci((t => {
11217
- e((() => this.pr(t)));
11225
+ e((() => this.Ir(t)));
11218
11226
  })), this.stream.onMessage((t => {
11219
11227
  e((() => this.onMessage(t)));
11220
11228
  }));
11221
11229
  }
11222
- ur() {
11223
- this.state = 4 /* Backoff */ , this.rr.Xi((async () => {
11230
+ lr() {
11231
+ this.state = 5 /* Backoff */ , this.cr.Xi((async () => {
11224
11232
  this.state = 0 /* Initial */ , this.start();
11225
11233
  }));
11226
11234
  }
11227
11235
  // Visible for tests
11228
- pr(t) {
11236
+ Ir(t) {
11229
11237
  // In theory the stream could close cleanly, however, in our current model
11230
11238
  // we never expect this to happen because if we stop a stream ourselves,
11231
11239
  // this callback will never be called. To prevent cases where we retry
11232
11240
  // without a backoff accidentally, we set the stream to error in all cases.
11233
- return $("PersistentStream", `close with error: ${t}`), this.stream = null, this.close(3 /* Error */ , t);
11241
+ return $("PersistentStream", `close with error: ${t}`), this.stream = null, this.close(4 /* Error */ , t);
11234
11242
  }
11235
11243
  /**
11236
11244
  * Returns a "dispatcher" function that dispatches operations onto the
11237
11245
  * AsyncQueue but only runs them if closeCount remains unchanged. This allows
11238
11246
  * us to turn auth / stream callbacks into no-ops if the stream is closed /
11239
11247
  * re-opened, etc.
11240
- */ gr(t) {
11248
+ */ Tr(t) {
11241
11249
  return e => {
11242
- this.Oe.enqueueAndForget((() => this.sr === t ? e() : ($("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
11250
+ this.Oe.enqueueAndForget((() => this.ir === t ? e() : ($("PersistentStream", "stream callback skipped by getCloseGuardedDispatcher."),
11243
11251
  Promise.resolve())));
11244
11252
  };
11245
11253
  }
@@ -11253,15 +11261,15 @@ class Zr {
11253
11261
  * sent from the server for ListenResponses.
11254
11262
  */ class to extends Zr {
11255
11263
  constructor(t, e, n, s, i) {
11256
- super(t, "listen_stream_connection_backoff" /* ListenStreamConnectionBackoff */ , "listen_stream_idle" /* ListenStreamIdle */ , e, n, i),
11264
+ super(t, "listen_stream_connection_backoff" /* ListenStreamConnectionBackoff */ , "listen_stream_idle" /* ListenStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, i),
11257
11265
  this.N = s;
11258
11266
  }
11259
- Tr(t) {
11260
- return this.nr.ji("Listen", t);
11267
+ Ar(t) {
11268
+ return this.sr.ji("Listen", t);
11261
11269
  }
11262
11270
  onMessage(t) {
11263
11271
  // A successful response means the stream is healthy
11264
- this.rr.reset();
11272
+ this.cr.reset();
11265
11273
  const e = ns(this.N, t), n = function(t) {
11266
11274
  // We have only reached a consistent snapshot for the entire stream if there
11267
11275
  // is a read_time set and it applies to all targets (i.e. the list of
@@ -11270,14 +11278,14 @@ class Zr {
11270
11278
  const e = t.targetChange;
11271
11279
  return e.targetIds && e.targetIds.length ? rt.min() : e.readTime ? jn(e.readTime) : rt.min();
11272
11280
  }(t);
11273
- return this.listener.Er(e, n);
11281
+ return this.listener.Rr(e, n);
11274
11282
  }
11275
11283
  /**
11276
11284
  * Registers interest in the results of the given target. If the target
11277
11285
  * includes a resumeToken it will be included in the request. Results that
11278
11286
  * affect the target will be streamed back as WatchChange messages that
11279
11287
  * reference the targetId.
11280
- */ Ir(t) {
11288
+ */ br(t) {
11281
11289
  const e = {};
11282
11290
  e.database = Yn(this.N), e.addTarget = function(t, e) {
11283
11291
  let n;
@@ -11293,14 +11301,14 @@ class Zr {
11293
11301
  n.readTime = Un(t, e.snapshotVersion.toTimestamp())), n;
11294
11302
  }(this.N, t);
11295
11303
  const n = us(this.N, t);
11296
- n && (e.labels = n), this.wr(e);
11304
+ n && (e.labels = n), this.mr(e);
11297
11305
  }
11298
11306
  /**
11299
11307
  * Unregisters interest in the results of the target associated with the
11300
11308
  * given targetId.
11301
- */ Ar(t) {
11309
+ */ Pr(t) {
11302
11310
  const e = {};
11303
- e.database = Yn(this.N), e.removeTarget = t, this.wr(e);
11311
+ e.database = Yn(this.N), e.removeTarget = t, this.mr(e);
11304
11312
  }
11305
11313
  }
11306
11314
 
@@ -11322,55 +11330,55 @@ class Zr {
11322
11330
  * TODO(b/33271235): Use proto types
11323
11331
  */ class eo extends Zr {
11324
11332
  constructor(t, e, n, s, i) {
11325
- super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , e, n, i),
11326
- this.N = s, this.Rr = !1;
11333
+ super(t, "write_stream_connection_backoff" /* WriteStreamConnectionBackoff */ , "write_stream_idle" /* WriteStreamIdle */ , "health_check_timeout" /* HealthCheckTimeout */ , e, n, i),
11334
+ this.N = s, this.vr = !1;
11327
11335
  }
11328
11336
  /**
11329
11337
  * Tracks whether or not a handshake has been successfully exchanged and
11330
11338
  * the stream is ready to accept mutations.
11331
- */ get br() {
11332
- return this.Rr;
11339
+ */ get Vr() {
11340
+ return this.vr;
11333
11341
  }
11334
11342
  // Override of PersistentStream.start
11335
11343
  start() {
11336
- this.Rr = !1, this.lastStreamToken = void 0, super.start();
11344
+ this.vr = !1, this.lastStreamToken = void 0, super.start();
11337
11345
  }
11338
- mr() {
11339
- this.Rr && this.Pr([]);
11346
+ pr() {
11347
+ this.vr && this.Sr([]);
11340
11348
  }
11341
- Tr(t) {
11342
- return this.nr.ji("Write", t);
11349
+ Ar(t) {
11350
+ return this.sr.ji("Write", t);
11343
11351
  }
11344
11352
  onMessage(t) {
11345
11353
  if (
11346
11354
  // Always capture the last stream token.
11347
- B(!!t.streamToken), this.lastStreamToken = t.streamToken, this.Rr) {
11355
+ B(!!t.streamToken), this.lastStreamToken = t.streamToken, this.vr) {
11348
11356
  // A successful first write response means the stream is healthy,
11349
11357
  // Note, that we could consider a successful handshake healthy, however,
11350
11358
  // the write itself might be causing an error we want to back off from.
11351
- this.rr.reset();
11359
+ this.cr.reset();
11352
11360
  const e = rs(t.writeResults, t.commitTime), n = jn(t.commitTime);
11353
- return this.listener.vr(n, e);
11361
+ return this.listener.Dr(n, e);
11354
11362
  }
11355
11363
  // The first response is always the handshake response
11356
- return B(!t.writeResults || 0 === t.writeResults.length), this.Rr = !0, this.listener.Vr();
11364
+ return B(!t.writeResults || 0 === t.writeResults.length), this.vr = !0, this.listener.Cr();
11357
11365
  }
11358
11366
  /**
11359
11367
  * Sends an initial streamToken to the server, performing the handshake
11360
11368
  * required to make the StreamingWrite RPC work. Subsequent
11361
11369
  * calls should wait until onHandshakeComplete was called.
11362
- */ Sr() {
11370
+ */ Nr() {
11363
11371
  // TODO(dimond): Support stream resumption. We intentionally do not set the
11364
11372
  // stream token on the handshake, ignoring any stream token we might have.
11365
11373
  const t = {};
11366
- t.database = Yn(this.N), this.wr(t);
11374
+ t.database = Yn(this.N), this.mr(t);
11367
11375
  }
11368
- /** Sends a group of mutations to the Firestore backend to apply. */ Pr(t) {
11376
+ /** Sends a group of mutations to the Firestore backend to apply. */ Sr(t) {
11369
11377
  const e = {
11370
11378
  streamToken: this.lastStreamToken,
11371
11379
  writes: t.map((t => ss(this.N, t)))
11372
11380
  };
11373
- this.wr(e);
11381
+ this.mr(e);
11374
11382
  }
11375
11383
  }
11376
11384
 
@@ -11401,25 +11409,25 @@ class Zr {
11401
11409
  */
11402
11410
  class no extends class {} {
11403
11411
  constructor(t, e, n) {
11404
- super(), this.credentials = t, this.nr = e, this.N = n, this.Dr = !1;
11412
+ super(), this.credentials = t, this.sr = e, this.N = n, this.kr = !1;
11405
11413
  }
11406
- Cr() {
11407
- if (this.Dr) throw new j(K.FAILED_PRECONDITION, "The client has already been terminated.");
11414
+ $r() {
11415
+ if (this.kr) throw new j(K.FAILED_PRECONDITION, "The client has already been terminated.");
11408
11416
  }
11409
11417
  /** Gets an auth token and invokes the provided RPC. */ Li(t, e, n) {
11410
- return this.Cr(), this.credentials.getToken().then((s => this.nr.Li(t, e, n, s))).catch((t => {
11418
+ return this.$r(), this.credentials.getToken().then((s => this.sr.Li(t, e, n, s))).catch((t => {
11411
11419
  throw "FirebaseError" === t.name ? (t.code === K.UNAUTHENTICATED && this.credentials.invalidateToken(),
11412
11420
  t) : new j(K.UNKNOWN, t.toString());
11413
11421
  }));
11414
11422
  }
11415
11423
  /** Gets an auth token and invokes the provided RPC with streamed results. */ Ki(t, e, n) {
11416
- return this.Cr(), this.credentials.getToken().then((s => this.nr.Ki(t, e, n, s))).catch((t => {
11424
+ return this.$r(), this.credentials.getToken().then((s => this.sr.Ki(t, e, n, s))).catch((t => {
11417
11425
  throw "FirebaseError" === t.name ? (t.code === K.UNAUTHENTICATED && this.credentials.invalidateToken(),
11418
11426
  t) : new j(K.UNKNOWN, t.toString());
11419
11427
  }));
11420
11428
  }
11421
11429
  terminate() {
11422
- this.Dr = !0;
11430
+ this.kr = !0;
11423
11431
  }
11424
11432
  }
11425
11433
 
@@ -11446,19 +11454,19 @@ class so {
11446
11454
  * maximum defined by MAX_WATCH_STREAM_FAILURES, we'll set the OnlineState to
11447
11455
  * Offline.
11448
11456
  */
11449
- this.Nr = 0,
11457
+ this.Or = 0,
11450
11458
  /**
11451
11459
  * A timer that elapses after ONLINE_STATE_TIMEOUT_MS, at which point we
11452
11460
  * transition from OnlineState.Unknown to OnlineState.Offline without waiting
11453
11461
  * for the stream to actually fail (MAX_WATCH_STREAM_FAILURES times).
11454
11462
  */
11455
- this.kr = null,
11463
+ this.Fr = null,
11456
11464
  /**
11457
11465
  * Whether the client should log a warning message if it fails to connect to
11458
11466
  * the backend (initially true, cleared after a successful stream, or if we've
11459
11467
  * logged the message already).
11460
11468
  */
11461
- this.$r = !0;
11469
+ this.Mr = !0;
11462
11470
  }
11463
11471
  /**
11464
11472
  * Called by RemoteStore when a watch stream is started (including on each
@@ -11466,9 +11474,9 @@ class so {
11466
11474
  *
11467
11475
  * If this is the first attempt, it sets the OnlineState to Unknown and starts
11468
11476
  * the onlineStateTimer.
11469
- */ Or() {
11470
- 0 === this.Nr && (this.Fr("Unknown" /* Unknown */), this.kr = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.kr = null,
11471
- this.Mr("Backend didn't respond within 10 seconds."), this.Fr("Offline" /* Offline */),
11477
+ */ Lr() {
11478
+ 0 === this.Or && (this.Br("Unknown" /* Unknown */), this.Fr = this.asyncQueue.enqueueAfterDelay("online_state_timeout" /* OnlineStateTimeout */ , 1e4, (() => (this.Fr = null,
11479
+ this.Ur("Backend didn't respond within 10 seconds."), this.Br("Offline" /* Offline */),
11472
11480
  Promise.resolve()))));
11473
11481
  }
11474
11482
  /**
@@ -11476,10 +11484,10 @@ class so {
11476
11484
  * failure. The first failure moves us to the 'Unknown' state. We then may
11477
11485
  * allow multiple failures (based on MAX_WATCH_STREAM_FAILURES) before we
11478
11486
  * actually transition to the 'Offline' state.
11479
- */ Lr(t) {
11480
- "Online" /* Online */ === this.state ? this.Fr("Unknown" /* Unknown */) : (this.Nr++,
11481
- this.Nr >= 1 && (this.Br(), this.Mr(`Connection failed 1 times. Most recent error: ${t.toString()}`),
11482
- this.Fr("Offline" /* Offline */)));
11487
+ */ qr(t) {
11488
+ "Online" /* Online */ === this.state ? this.Br("Unknown" /* Unknown */) : (this.Or++,
11489
+ this.Or >= 1 && (this.Kr(), this.Ur(`Connection failed 1 times. Most recent error: ${t.toString()}`),
11490
+ this.Br("Offline" /* Offline */)));
11483
11491
  }
11484
11492
  /**
11485
11493
  * Explicitly sets the OnlineState to the specified state.
@@ -11488,20 +11496,20 @@ class so {
11488
11496
  * Offline heuristics, so must not be used in place of
11489
11497
  * handleWatchStreamStart() and handleWatchStreamFailure().
11490
11498
  */ set(t) {
11491
- this.Br(), this.Nr = 0, "Online" /* Online */ === t && (
11499
+ this.Kr(), this.Or = 0, "Online" /* Online */ === t && (
11492
11500
  // We've connected to watch at least once. Don't warn the developer
11493
11501
  // about being offline going forward.
11494
- this.$r = !1), this.Fr(t);
11502
+ this.Mr = !1), this.Br(t);
11495
11503
  }
11496
- Fr(t) {
11504
+ Br(t) {
11497
11505
  t !== this.state && (this.state = t, this.onlineStateHandler(t));
11498
11506
  }
11499
- Mr(t) {
11507
+ Ur(t) {
11500
11508
  const e = `Could not reach Cloud Firestore backend. ${t}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;
11501
- this.$r ? (O(e), this.$r = !1) : $("OnlineStateTracker", e);
11509
+ this.Mr ? (O(e), this.Mr = !1) : $("OnlineStateTracker", e);
11502
11510
  }
11503
- Br() {
11504
- null !== this.kr && (this.kr.cancel(), this.kr = null);
11511
+ Kr() {
11512
+ null !== this.Fr && (this.Fr.cancel(), this.Fr = null);
11505
11513
  }
11506
11514
  }
11507
11515
 
@@ -11546,7 +11554,7 @@ class so {
11546
11554
  * purely based on order, and so we can just shift() writes from the front of
11547
11555
  * the writePipeline as we receive responses.
11548
11556
  */
11549
- this.Ur = [],
11557
+ this.jr = [],
11550
11558
  /**
11551
11559
  * A mapping of watched targets that the client cares about tracking and the
11552
11560
  * user has explicitly called a 'listen' for this target.
@@ -11556,12 +11564,12 @@ class so {
11556
11564
  * to the server. The targets removed with unlistens are removed eagerly
11557
11565
  * without waiting for confirmation from the listen stream.
11558
11566
  */
11559
- this.qr = new Map,
11567
+ this.Qr = new Map,
11560
11568
  /**
11561
11569
  * A set of reasons for why the RemoteStore may be offline. If empty, the
11562
11570
  * RemoteStore may start its network connections.
11563
11571
  */
11564
- this.Kr = new Set,
11572
+ this.Wr = new Set,
11565
11573
  /**
11566
11574
  * Event handlers that get called when the network is disabled or enabled.
11567
11575
  *
@@ -11569,7 +11577,7 @@ class so {
11569
11577
  * underlying streams (to support tree-shakeable streams). On Android and iOS,
11570
11578
  * the streams are created during construction of RemoteStore.
11571
11579
  */
11572
- this.jr = [], this.Qr = i, this.Qr.Ti((t => {
11580
+ this.Gr = [], this.zr = i, this.zr.Ti((t => {
11573
11581
  n.enqueueAndForget((async () => {
11574
11582
  // Porting Note: Unlike iOS, `restartNetwork()` is called even when the
11575
11583
  // network becomes unreachable as we don't have any other way to tear
@@ -11577,23 +11585,23 @@ class so {
11577
11585
  wo(this) && ($("RemoteStore", "Restarting streams for network reachability change."),
11578
11586
  await async function(t) {
11579
11587
  const e = q(t);
11580
- e.Kr.add(4 /* ConnectivityChange */), await oo(e), e.Wr.set("Unknown" /* Unknown */),
11581
- e.Kr.delete(4 /* ConnectivityChange */), await ro(e);
11588
+ e.Wr.add(4 /* ConnectivityChange */), await oo(e), e.Hr.set("Unknown" /* Unknown */),
11589
+ e.Wr.delete(4 /* ConnectivityChange */), await ro(e);
11582
11590
  }(this));
11583
11591
  }));
11584
- })), this.Wr = new so(n, s);
11592
+ })), this.Hr = new so(n, s);
11585
11593
  }
11586
11594
  }
11587
11595
 
11588
11596
  async function ro(t) {
11589
- if (wo(t)) for (const e of t.jr) await e(/* enabled= */ !0);
11597
+ if (wo(t)) for (const e of t.Gr) await e(/* enabled= */ !0);
11590
11598
  }
11591
11599
 
11592
11600
  /**
11593
11601
  * Temporarily disables the network. The network can be re-enabled using
11594
11602
  * enableNetwork().
11595
11603
  */ async function oo(t) {
11596
- for (const e of t.jr) await e(/* enabled= */ !1);
11604
+ for (const e of t.Gr) await e(/* enabled= */ !1);
11597
11605
  }
11598
11606
 
11599
11607
  /**
@@ -11602,11 +11610,11 @@ async function ro(t) {
11602
11610
  */
11603
11611
  function ao(t, e) {
11604
11612
  const n = q(t);
11605
- n.qr.has(e.targetId) || (
11613
+ n.Qr.has(e.targetId) || (
11606
11614
  // Mark this as something the client is currently listening for.
11607
- n.qr.set(e.targetId, e), fo(n) ?
11615
+ n.Qr.set(e.targetId, e), fo(n) ?
11608
11616
  // The listen will be sent in onWatchStreamOpen
11609
- lo(n) : Co(n).cr() && uo(n, e));
11617
+ lo(n) : Co(n).hr() && uo(n, e));
11610
11618
  }
11611
11619
 
11612
11620
  /**
@@ -11614,18 +11622,18 @@ function ao(t, e) {
11614
11622
  * not being listened to.
11615
11623
  */ function co(t, e) {
11616
11624
  const n = q(t), s = Co(n);
11617
- n.qr.delete(e), s.cr() && ho(n, e), 0 === n.qr.size && (s.cr() ? s.lr() : wo(n) &&
11625
+ n.Qr.delete(e), s.hr() && ho(n, e), 0 === n.Qr.size && (s.hr() ? s.wr() : wo(n) &&
11618
11626
  // Revert to OnlineState.Unknown if the watch stream is not open and we
11619
11627
  // have no listeners, since without any listens to send we cannot
11620
11628
  // confirm if the stream is healthy and upgrade to OnlineState.Online.
11621
- n.Wr.set("Unknown" /* Unknown */));
11629
+ n.Hr.set("Unknown" /* Unknown */));
11622
11630
  }
11623
11631
 
11624
11632
  /**
11625
11633
  * We need to increment the the expected number of pending responses we're due
11626
11634
  * from watch so we wait for the ack to process any messages from this target.
11627
11635
  */ function uo(t, e) {
11628
- t.Gr.Y(e.targetId), Co(t).Ir(e);
11636
+ t.Jr.Y(e.targetId), Co(t).br(e);
11629
11637
  }
11630
11638
 
11631
11639
  /**
@@ -11633,33 +11641,33 @@ function ao(t, e) {
11633
11641
  * from watch so we wait for the removal on the server before we process any
11634
11642
  * messages from this target.
11635
11643
  */ function ho(t, e) {
11636
- t.Gr.Y(e), Co(t).Ar(e);
11644
+ t.Jr.Y(e), Co(t).Pr(e);
11637
11645
  }
11638
11646
 
11639
11647
  function lo(t) {
11640
- t.Gr = new $n({
11648
+ t.Jr = new $n({
11641
11649
  getRemoteKeysForTarget: e => t.remoteSyncer.getRemoteKeysForTarget(e),
11642
- Tt: e => t.qr.get(e) || null
11643
- }), Co(t).start(), t.Wr.Or();
11650
+ Tt: e => t.Qr.get(e) || null
11651
+ }), Co(t).start(), t.Hr.Lr();
11644
11652
  }
11645
11653
 
11646
11654
  /**
11647
11655
  * Returns whether the watch stream should be started because it's necessary
11648
11656
  * and has not yet been started.
11649
11657
  */ function fo(t) {
11650
- return wo(t) && !Co(t).ar() && t.qr.size > 0;
11658
+ return wo(t) && !Co(t).ur() && t.Qr.size > 0;
11651
11659
  }
11652
11660
 
11653
11661
  function wo(t) {
11654
- return 0 === q(t).Kr.size;
11662
+ return 0 === q(t).Wr.size;
11655
11663
  }
11656
11664
 
11657
11665
  function _o(t) {
11658
- t.Gr = void 0;
11666
+ t.Jr = void 0;
11659
11667
  }
11660
11668
 
11661
11669
  async function mo(t) {
11662
- t.qr.forEach(((e, n) => {
11670
+ t.Qr.forEach(((e, n) => {
11663
11671
  uo(t, e);
11664
11672
  }));
11665
11673
  }
@@ -11667,17 +11675,17 @@ async function mo(t) {
11667
11675
  async function go(t, e) {
11668
11676
  _o(t),
11669
11677
  // If we still need the watch stream, retry the connection.
11670
- fo(t) ? (t.Wr.Lr(e), lo(t)) :
11678
+ fo(t) ? (t.Hr.qr(e), lo(t)) :
11671
11679
  // No need to restart watch stream because there are no active targets.
11672
11680
  // The online state is set to unknown because there is no active attempt
11673
11681
  // at establishing a connection
11674
- t.Wr.set("Unknown" /* Unknown */);
11682
+ t.Hr.set("Unknown" /* Unknown */);
11675
11683
  }
11676
11684
 
11677
11685
  async function yo(t, e, n) {
11678
11686
  if (
11679
11687
  // Mark the client as online since we got a message from the server
11680
- t.Wr.set("Online" /* Online */), e instanceof xn && 2 /* Removed */ === e.state && e.cause)
11688
+ t.Hr.set("Online" /* Online */), e instanceof xn && 2 /* Removed */ === e.state && e.cause)
11681
11689
  // There was an error on a target, don't wait for a consistent snapshot
11682
11690
  // to raise events
11683
11691
  try {
@@ -11687,7 +11695,7 @@ async function yo(t, e, n) {
11687
11695
  const n = e.cause;
11688
11696
  for (const s of e.targetIds)
11689
11697
  // A watched target might have been removed already.
11690
- t.qr.has(s) && (await t.remoteSyncer.rejectListen(s, n), t.qr.delete(s), t.Gr.removeTarget(s));
11698
+ t.Qr.has(s) && (await t.remoteSyncer.rejectListen(s, n), t.Qr.delete(s), t.Jr.removeTarget(s));
11691
11699
  }
11692
11700
  /**
11693
11701
  * Attempts to fill our write pipeline with writes from the LocalStore.
@@ -11700,7 +11708,7 @@ async function yo(t, e, n) {
11700
11708
  } catch (n) {
11701
11709
  $("RemoteStore", "Failed to remove targets %s: %s ", e.targetIds.join(","), n),
11702
11710
  await po(t, n);
11703
- } else if (e instanceof Cn ? t.Gr.rt(e) : e instanceof Nn ? t.Gr.ft(e) : t.Gr.ct(e),
11711
+ } else if (e instanceof Cn ? t.Jr.rt(e) : e instanceof Nn ? t.Jr.ft(e) : t.Jr.ct(e),
11704
11712
  !n.isEqual(rt.min())) try {
11705
11713
  const e = await fr(t.localStore);
11706
11714
  n.compareTo(e) >= 0 &&
@@ -11713,26 +11721,26 @@ async function yo(t, e, n) {
11713
11721
  * SyncEngine.
11714
11722
  */
11715
11723
  function(t, e) {
11716
- const n = t.Gr._t(e);
11724
+ const n = t.Jr._t(e);
11717
11725
  // Update in-memory resume tokens. LocalStore will update the
11718
11726
  // persistent view of these when applying the completed RemoteEvent.
11719
11727
  return n.targetChanges.forEach(((n, s) => {
11720
11728
  if (n.resumeToken.approximateByteSize() > 0) {
11721
- const i = t.qr.get(s);
11729
+ const i = t.Qr.get(s);
11722
11730
  // A watched target might have been removed already.
11723
- i && t.qr.set(s, i.withResumeToken(n.resumeToken, e));
11731
+ i && t.Qr.set(s, i.withResumeToken(n.resumeToken, e));
11724
11732
  }
11725
11733
  })),
11726
11734
  // Re-establish listens for the targets that have been invalidated by
11727
11735
  // existence filter mismatches.
11728
11736
  n.targetMismatches.forEach((e => {
11729
- const n = t.qr.get(e);
11737
+ const n = t.Qr.get(e);
11730
11738
  if (!n)
11731
11739
  // A watched target might have been removed already.
11732
11740
  return;
11733
11741
  // Clear the resume token for the target, since we're in a known mismatch
11734
11742
  // state.
11735
- t.qr.set(e, n.withResumeToken(_t.EMPTY_BYTE_STRING, n.snapshotVersion)),
11743
+ t.Qr.set(e, n.withResumeToken(_t.EMPTY_BYTE_STRING, n.snapshotVersion)),
11736
11744
  // Cause a hard reset by unwatching and rewatching immediately, but
11737
11745
  // deliberately don't send a resume token so that we get a full update.
11738
11746
  ho(t, e);
@@ -11759,16 +11767,16 @@ async function yo(t, e, n) {
11759
11767
  * any retry attempt.
11760
11768
  */ async function po(t, e, n) {
11761
11769
  if (!Hs(e)) throw e;
11762
- t.Kr.add(1 /* IndexedDbFailed */),
11770
+ t.Wr.add(1 /* IndexedDbFailed */),
11763
11771
  // Disable network and raise offline snapshots
11764
- await oo(t), t.Wr.set("Offline" /* Offline */), n || (
11772
+ await oo(t), t.Hr.set("Offline" /* Offline */), n || (
11765
11773
  // Use a simple read operation to determine if IndexedDB recovered.
11766
11774
  // Ideally, we would expose a health check directly on SimpleDb, but
11767
11775
  // RemoteStore only has access to persistence through LocalStore.
11768
11776
  n = () => fr(t.localStore)),
11769
11777
  // Probe IndexedDB periodically and re-enable network
11770
11778
  t.asyncQueue.enqueueRetryable((async () => {
11771
- $("RemoteStore", "Retrying IndexedDB access"), await n(), t.Kr.delete(1 /* IndexedDbFailed */),
11779
+ $("RemoteStore", "Retrying IndexedDB access"), await n(), t.Wr.delete(1 /* IndexedDbFailed */),
11772
11780
  await ro(t);
11773
11781
  }));
11774
11782
  }
@@ -11782,11 +11790,11 @@ async function yo(t, e, n) {
11782
11790
 
11783
11791
  async function Eo(t) {
11784
11792
  const e = q(t), n = No(e);
11785
- let s = e.Ur.length > 0 ? e.Ur[e.Ur.length - 1].batchId : -1;
11793
+ let s = e.jr.length > 0 ? e.jr[e.jr.length - 1].batchId : -1;
11786
11794
  for (;Io(e); ) try {
11787
11795
  const t = await _r(e.localStore, s);
11788
11796
  if (null === t) {
11789
- 0 === e.Ur.length && n.lr();
11797
+ 0 === e.jr.length && n.wr();
11790
11798
  break;
11791
11799
  }
11792
11800
  s = t.batchId, Ao(e, t);
@@ -11800,20 +11808,20 @@ async function Eo(t) {
11800
11808
  * Returns true if we can add to the write pipeline (i.e. the network is
11801
11809
  * enabled and the write pipeline is not full).
11802
11810
  */ function Io(t) {
11803
- return wo(t) && t.Ur.length < 10;
11811
+ return wo(t) && t.jr.length < 10;
11804
11812
  }
11805
11813
 
11806
11814
  /**
11807
11815
  * Queues additional writes to be sent to the write stream, sending them
11808
11816
  * immediately if the write stream is established.
11809
11817
  */ function Ao(t, e) {
11810
- t.Ur.push(e);
11818
+ t.jr.push(e);
11811
11819
  const n = No(t);
11812
- n.cr() && n.br && n.Pr(e.mutations);
11820
+ n.hr() && n.Vr && n.Sr(e.mutations);
11813
11821
  }
11814
11822
 
11815
11823
  function Ro(t) {
11816
- return wo(t) && !No(t).ar() && t.Ur.length > 0;
11824
+ return wo(t) && !No(t).ur() && t.jr.length > 0;
11817
11825
  }
11818
11826
 
11819
11827
  function bo(t) {
@@ -11821,17 +11829,17 @@ function bo(t) {
11821
11829
  }
11822
11830
 
11823
11831
  async function Po(t) {
11824
- No(t).Sr();
11832
+ No(t).Nr();
11825
11833
  }
11826
11834
 
11827
11835
  async function vo(t) {
11828
11836
  const e = No(t);
11829
11837
  // Send the write pipeline now that the stream is established.
11830
- for (const n of t.Ur) e.Pr(n.mutations);
11838
+ for (const n of t.jr) e.Sr(n.mutations);
11831
11839
  }
11832
11840
 
11833
11841
  async function Vo(t, e, n) {
11834
- const s = t.Ur.shift(), i = si.from(s, e, n);
11842
+ const s = t.jr.shift(), i = si.from(s, e, n);
11835
11843
  await To(t, (() => t.remoteSyncer.applySuccessfulWrite(i))),
11836
11844
  // It's possible that with the completion of this mutation another
11837
11845
  // slot has freed up.
@@ -11841,7 +11849,7 @@ async function Vo(t, e, n) {
11841
11849
  async function So(t, e) {
11842
11850
  // If the write stream closed after the write handshake completes, a write
11843
11851
  // operation failed and we fail the pending operation.
11844
- e && No(t).br &&
11852
+ e && No(t).Vr &&
11845
11853
  // This error affects the actual write.
11846
11854
  await async function(t, e) {
11847
11855
  // Only handle permanent errors here. If it's transient, just let the retry
@@ -11849,11 +11857,11 @@ async function So(t, e) {
11849
11857
  if (n = e.code, fn(n) && n !== K.ABORTED) {
11850
11858
  // This was a permanent error, the request itself was the problem
11851
11859
  // so it's not going to succeed if we resend it.
11852
- const n = t.Ur.shift();
11860
+ const n = t.jr.shift();
11853
11861
  // In this case it's also unlikely that the server itself is melting
11854
11862
  // down -- this was just a bad request so inhibit backoff on the next
11855
11863
  // restart.
11856
- No(t).hr(), await To(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
11864
+ No(t).dr(), await To(t, (() => t.remoteSyncer.rejectFailedWrite(n.batchId, e))),
11857
11865
  // It's possible that with the completion of this mutation
11858
11866
  // another slot has freed up.
11859
11867
  await Eo(t);
@@ -11870,8 +11878,8 @@ async function So(t, e) {
11870
11878
  */
11871
11879
  async function Do(t, e) {
11872
11880
  const n = q(t);
11873
- e ? (n.Kr.delete(2 /* IsSecondary */), await ro(n)) : e || (n.Kr.add(2 /* IsSecondary */),
11874
- await oo(n), n.Wr.set("Unknown" /* Unknown */));
11881
+ e ? (n.Wr.delete(2 /* IsSecondary */), await ro(n)) : e || (n.Wr.add(2 /* IsSecondary */),
11882
+ await oo(n), n.Hr.set("Unknown" /* Unknown */));
11875
11883
  }
11876
11884
 
11877
11885
  /**
@@ -11882,11 +11890,11 @@ async function Do(t, e) {
11882
11890
  * PORTING NOTE: On iOS and Android, the WatchStream gets registered on startup.
11883
11891
  * This is not done on Web to allow it to be tree-shaken.
11884
11892
  */ function Co(t) {
11885
- return t.zr || (
11893
+ return t.Yr || (
11886
11894
  // Create stream (but note that it is not started yet).
11887
- t.zr = function(t, e, n) {
11895
+ t.Yr = function(t, e, n) {
11888
11896
  const s = q(t);
11889
- return s.Cr(), new to(e, s.nr, s.credentials, s.N, n);
11897
+ return s.$r(), new to(e, s.sr, s.credentials, s.N, n);
11890
11898
  }
11891
11899
  /**
11892
11900
  * @license
@@ -11906,11 +11914,11 @@ async function Do(t, e) {
11906
11914
  */ (t.datastore, t.asyncQueue, {
11907
11915
  Si: mo.bind(null, t),
11908
11916
  Ci: go.bind(null, t),
11909
- Er: yo.bind(null, t)
11910
- }), t.jr.push((async e => {
11911
- e ? (t.zr.hr(), fo(t) ? lo(t) : t.Wr.set("Unknown" /* Unknown */)) : (await t.zr.stop(),
11917
+ Rr: yo.bind(null, t)
11918
+ }), t.Gr.push((async e => {
11919
+ e ? (t.Yr.dr(), fo(t) ? lo(t) : t.Hr.set("Unknown" /* Unknown */)) : (await t.Yr.stop(),
11912
11920
  _o(t));
11913
- }))), t.zr;
11921
+ }))), t.Yr;
11914
11922
  }
11915
11923
 
11916
11924
  /**
@@ -11921,22 +11929,22 @@ async function Do(t, e) {
11921
11929
  * PORTING NOTE: On iOS and Android, the WriteStream gets registered on startup.
11922
11930
  * This is not done on Web to allow it to be tree-shaken.
11923
11931
  */ function No(t) {
11924
- return t.Hr || (
11932
+ return t.Xr || (
11925
11933
  // Create stream (but note that it is not started yet).
11926
- t.Hr = function(t, e, n) {
11934
+ t.Xr = function(t, e, n) {
11927
11935
  const s = q(t);
11928
- return s.Cr(), new eo(e, s.nr, s.credentials, s.N, n);
11936
+ return s.$r(), new eo(e, s.sr, s.credentials, s.N, n);
11929
11937
  }(t.datastore, t.asyncQueue, {
11930
11938
  Si: Po.bind(null, t),
11931
11939
  Ci: So.bind(null, t),
11932
- Vr: vo.bind(null, t),
11933
- vr: Vo.bind(null, t)
11934
- }), t.jr.push((async e => {
11935
- e ? (t.Hr.hr(),
11940
+ Cr: vo.bind(null, t),
11941
+ Dr: Vo.bind(null, t)
11942
+ }), t.Gr.push((async e => {
11943
+ e ? (t.Xr.dr(),
11936
11944
  // This will start the write stream if necessary.
11937
- await Eo(t)) : (await t.Hr.stop(), t.Ur.length > 0 && ($("RemoteStore", `Stopping write stream with ${t.Ur.length} pending writes`),
11938
- t.Ur = []));
11939
- }))), t.Hr;
11945
+ await Eo(t)) : (await t.Xr.stop(), t.jr.length > 0 && ($("RemoteStore", `Stopping write stream with ${t.jr.length} pending writes`),
11946
+ t.jr = []));
11947
+ }))), t.Xr;
11940
11948
  }
11941
11949
 
11942
11950
  /**
@@ -12146,25 +12154,25 @@ class xo {
12146
12154
  * duplicate events for the same doc.
12147
12155
  */ class Oo {
12148
12156
  constructor() {
12149
- this.Jr = new wn(Pt.comparator);
12157
+ this.Zr = new wn(Pt.comparator);
12150
12158
  }
12151
12159
  track(t) {
12152
- const e = t.doc.key, n = this.Jr.get(e);
12160
+ const e = t.doc.key, n = this.Zr.get(e);
12153
12161
  n ?
12154
12162
  // Merge the new change with the existing change.
12155
- 0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.Jr = this.Jr.insert(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.Jr = this.Jr.insert(e, {
12163
+ 0 /* Added */ !== t.type && 3 /* Metadata */ === n.type ? this.Zr = this.Zr.insert(e, t) : 3 /* Metadata */ === t.type && 1 /* Removed */ !== n.type ? this.Zr = this.Zr.insert(e, {
12156
12164
  type: n.type,
12157
12165
  doc: t.doc
12158
- }) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.Jr = this.Jr.insert(e, {
12166
+ }) : 2 /* Modified */ === t.type && 2 /* Modified */ === n.type ? this.Zr = this.Zr.insert(e, {
12159
12167
  type: 2 /* Modified */ ,
12160
12168
  doc: t.doc
12161
- }) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.Jr = this.Jr.insert(e, {
12169
+ }) : 2 /* Modified */ === t.type && 0 /* Added */ === n.type ? this.Zr = this.Zr.insert(e, {
12162
12170
  type: 0 /* Added */ ,
12163
12171
  doc: t.doc
12164
- }) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.Jr = this.Jr.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.Jr = this.Jr.insert(e, {
12172
+ }) : 1 /* Removed */ === t.type && 0 /* Added */ === n.type ? this.Zr = this.Zr.remove(e) : 1 /* Removed */ === t.type && 2 /* Modified */ === n.type ? this.Zr = this.Zr.insert(e, {
12165
12173
  type: 1 /* Removed */ ,
12166
12174
  doc: n.doc
12167
- }) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.Jr = this.Jr.insert(e, {
12175
+ }) : 0 /* Added */ === t.type && 1 /* Removed */ === n.type ? this.Zr = this.Zr.insert(e, {
12168
12176
  type: 2 /* Modified */ ,
12169
12177
  doc: t.doc
12170
12178
  }) :
@@ -12175,11 +12183,11 @@ class xo {
12175
12183
  // Removed->Modified
12176
12184
  // Metadata->Added
12177
12185
  // Removed->Metadata
12178
- L() : this.Jr = this.Jr.insert(e, t);
12186
+ L() : this.Zr = this.Zr.insert(e, t);
12179
12187
  }
12180
- Yr() {
12188
+ eo() {
12181
12189
  const t = [];
12182
- return this.Jr.inorderTraversal(((e, n) => {
12190
+ return this.Zr.inorderTraversal(((e, n) => {
12183
12191
  t.push(n);
12184
12192
  })), t;
12185
12193
  }
@@ -12234,14 +12242,14 @@ class Fo {
12234
12242
  * tracked by EventManager.
12235
12243
  */ class Mo {
12236
12244
  constructor() {
12237
- this.Xr = void 0, this.listeners = [];
12245
+ this.no = void 0, this.listeners = [];
12238
12246
  }
12239
12247
  }
12240
12248
 
12241
12249
  class Lo {
12242
12250
  constructor() {
12243
12251
  this.queries = new ji((t => Re(t)), Ae), this.onlineState = "Unknown" /* Unknown */ ,
12244
- this.Zr = new Set;
12252
+ this.so = new Set;
12245
12253
  }
12246
12254
  }
12247
12255
 
@@ -12249,15 +12257,15 @@ async function Bo(t, e) {
12249
12257
  const n = q(t), s = e.query;
12250
12258
  let i = !1, r = n.queries.get(s);
12251
12259
  if (r || (i = !0, r = new Mo), i) try {
12252
- r.Xr = await n.onListen(s);
12260
+ r.no = await n.onListen(s);
12253
12261
  } catch (t) {
12254
12262
  const n = ko(t, `Initialization of query '${be(e.query)}' failed`);
12255
12263
  return void e.onError(n);
12256
12264
  }
12257
12265
  if (n.queries.set(s, r), r.listeners.push(e),
12258
12266
  // Run global snapshot listeners if a consistent snapshot has been emitted.
12259
- e.eo(n.onlineState), r.Xr) {
12260
- e.no(r.Xr) && jo(n);
12267
+ e.io(n.onlineState), r.no) {
12268
+ e.ro(r.no) && jo(n);
12261
12269
  }
12262
12270
  }
12263
12271
 
@@ -12278,8 +12286,8 @@ function qo(t, e) {
12278
12286
  for (const t of e) {
12279
12287
  const e = t.query, i = n.queries.get(e);
12280
12288
  if (i) {
12281
- for (const e of i.listeners) e.no(t) && (s = !0);
12282
- i.Xr = t;
12289
+ for (const e of i.listeners) e.ro(t) && (s = !0);
12290
+ i.no = t;
12283
12291
  }
12284
12292
  }
12285
12293
  s && jo(n);
@@ -12295,7 +12303,7 @@ function Ko(t, e, n) {
12295
12303
 
12296
12304
  // Call all global snapshot listeners that have been set.
12297
12305
  function jo(t) {
12298
- t.Zr.forEach((t => {
12306
+ t.so.forEach((t => {
12299
12307
  t.next();
12300
12308
  }));
12301
12309
  }
@@ -12307,19 +12315,19 @@ function jo(t) {
12307
12315
  * It uses an Observer to dispatch events.
12308
12316
  */ class Qo {
12309
12317
  constructor(t, e, n) {
12310
- this.query = t, this.so = e,
12318
+ this.query = t, this.oo = e,
12311
12319
  /**
12312
12320
  * Initial snapshots (e.g. from cache) may not be propagated to the wrapped
12313
12321
  * observer. This flag is set to true once we've actually raised an event.
12314
12322
  */
12315
- this.io = !1, this.ro = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
12323
+ this.ao = !1, this.co = null, this.onlineState = "Unknown" /* Unknown */ , this.options = n || {};
12316
12324
  }
12317
12325
  /**
12318
12326
  * Applies the new ViewSnapshot to this listener, raising a user-facing event
12319
12327
  * if applicable (depending on what changed, whether the user has opted into
12320
12328
  * metadata-only changes, etc.). Returns true if a user-facing event was
12321
12329
  * indeed raised.
12322
- */ no(t) {
12330
+ */ ro(t) {
12323
12331
  if (!this.options.includeMetadataChanges) {
12324
12332
  // Remove the metadata only changes.
12325
12333
  const e = [];
@@ -12328,19 +12336,19 @@ function jo(t) {
12328
12336
  /* excludesMetadataChanges= */ !0);
12329
12337
  }
12330
12338
  let e = !1;
12331
- return this.io ? this.oo(t) && (this.so.next(t), e = !0) : this.ao(t, this.onlineState) && (this.co(t),
12332
- e = !0), this.ro = t, e;
12339
+ return this.ao ? this.uo(t) && (this.oo.next(t), e = !0) : this.ho(t, this.onlineState) && (this.lo(t),
12340
+ e = !0), this.co = t, e;
12333
12341
  }
12334
12342
  onError(t) {
12335
- this.so.error(t);
12343
+ this.oo.error(t);
12336
12344
  }
12337
- /** Returns whether a snapshot was raised. */ eo(t) {
12345
+ /** Returns whether a snapshot was raised. */ io(t) {
12338
12346
  this.onlineState = t;
12339
12347
  let e = !1;
12340
- return this.ro && !this.io && this.ao(this.ro, t) && (this.co(this.ro), e = !0),
12348
+ return this.co && !this.ao && this.ho(this.co, t) && (this.lo(this.co), e = !0),
12341
12349
  e;
12342
12350
  }
12343
- ao(t, e) {
12351
+ ho(t, e) {
12344
12352
  // Always raise the first event when we're synced
12345
12353
  if (!t.fromCache) return !0;
12346
12354
  // NOTE: We consider OnlineState.Unknown as online (it should become Offline
@@ -12348,24 +12356,24 @@ function jo(t) {
12348
12356
  const n = "Offline" /* Offline */ !== e;
12349
12357
  // Don't raise the event if we're online, aren't synced yet (checked
12350
12358
  // above) and are waiting for a sync.
12351
- return (!this.options.uo || !n) && (!t.docs.isEmpty() || "Offline" /* Offline */ === e);
12359
+ return (!this.options.fo || !n) && (!t.docs.isEmpty() || "Offline" /* Offline */ === e);
12352
12360
  // Raise data from cache if we have any documents or we are offline
12353
12361
  }
12354
- oo(t) {
12362
+ uo(t) {
12355
12363
  // We don't need to handle includeDocumentMetadataChanges here because
12356
12364
  // the Metadata only changes have already been stripped out if needed.
12357
12365
  // At this point the only changes we will see are the ones we should
12358
12366
  // propagate.
12359
12367
  if (t.docChanges.length > 0) return !0;
12360
- const e = this.ro && this.ro.hasPendingWrites !== t.hasPendingWrites;
12368
+ const e = this.co && this.co.hasPendingWrites !== t.hasPendingWrites;
12361
12369
  return !(!t.syncStateChanged && !e) && !0 === this.options.includeMetadataChanges;
12362
12370
  // Generally we should have hit one of the cases above, but it's possible
12363
12371
  // to get here if there were only metadata docChanges and they got
12364
12372
  // stripped out.
12365
12373
  }
12366
- co(t) {
12367
- t = Fo.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.io = !0,
12368
- this.so.next(t);
12374
+ lo(t) {
12375
+ t = Fo.fromInitialDocuments(t.query, t.docs, t.mutatedKeys, t.fromCache), this.ao = !0,
12376
+ this.oo.next(t);
12369
12377
  }
12370
12378
  }
12371
12379
 
@@ -12394,7 +12402,7 @@ function jo(t) {
12394
12402
  e) {
12395
12403
  this.payload = t, this.byteLength = e;
12396
12404
  }
12397
- ho() {
12405
+ wo() {
12398
12406
  return "metadata" in this.payload;
12399
12407
  }
12400
12408
  }
@@ -12439,7 +12447,7 @@ function jo(t) {
12439
12447
  * storage and provide progress update while loading.
12440
12448
  */ class zo {
12441
12449
  constructor(t, e, n) {
12442
- this.lo = t, this.localStore = e, this.N = n,
12450
+ this._o = t, this.localStore = e, this.N = n,
12443
12451
  /** Batched queries to be saved into storage */
12444
12452
  this.queries = [],
12445
12453
  /** Batched documents to be saved into storage */
@@ -12450,7 +12458,7 @@ function jo(t) {
12450
12458
  *
12451
12459
  * Returns a new progress if adding the element leads to a new progress,
12452
12460
  * otherwise returns null.
12453
- */ fo(t) {
12461
+ */ mo(t) {
12454
12462
  this.progress.bytesLoaded += t.byteLength;
12455
12463
  let e = this.progress.documentsLoaded;
12456
12464
  return t.payload.namedQuery ? this.queries.push(t.payload.namedQuery) : t.payload.documentMetadata ? (this.documents.push({
@@ -12459,7 +12467,7 @@ function jo(t) {
12459
12467
  ++e), e !== this.progress.documentsLoaded ? (this.progress.documentsLoaded = e,
12460
12468
  Object.assign({}, this.progress)) : null;
12461
12469
  }
12462
- wo(t) {
12470
+ yo(t) {
12463
12471
  const e = new Map, n = new Go(this.N);
12464
12472
  for (const s of t) if (s.metadata.queries) {
12465
12473
  const t = n.zn(s.metadata.name);
@@ -12473,7 +12481,7 @@ function jo(t) {
12473
12481
  /**
12474
12482
  * Update the progress to 'Success' and return the updated progress.
12475
12483
  */ async complete() {
12476
- const t = await Ir(this.localStore, new Go(this.N), this.documents, this.lo.id), e = this.wo(this.documents);
12484
+ const t = await Ir(this.localStore, new Go(this.N), this.documents, this._o.id), e = this.yo(this.documents);
12477
12485
  for (const t of this.queries) await Ar(this.localStore, t, e.get(t.name));
12478
12486
  return this.progress.taskState = "Success", new ir(Object.assign({}, this.progress), t);
12479
12487
  }
@@ -12532,7 +12540,7 @@ class Yo {
12532
12540
  constructor(t,
12533
12541
  /** Documents included in the remote target */
12534
12542
  e) {
12535
- this.query = t, this._o = e, this.mo = null,
12543
+ this.query = t, this.po = e, this.To = null,
12536
12544
  /**
12537
12545
  * A flag whether the view is current with the backend. A view is considered
12538
12546
  * current after it has seen the current flag from the backend and did not
@@ -12541,15 +12549,15 @@ class Yo {
12541
12549
  */
12542
12550
  this.current = !1,
12543
12551
  /** Documents in the view but not in the remote target */
12544
- this.yo = Pn(),
12552
+ this.Eo = Pn(),
12545
12553
  /** Document Keys that have local changes */
12546
- this.mutatedKeys = Pn(), this.po = ve(t), this.To = new $o(this.po);
12554
+ this.mutatedKeys = Pn(), this.Io = ve(t), this.Ao = new $o(this.Io);
12547
12555
  }
12548
12556
  /**
12549
12557
  * The set of remote documents that the server has told us belongs to the target associated with
12550
12558
  * this view.
12551
- */ get Eo() {
12552
- return this._o;
12559
+ */ get Ro() {
12560
+ return this.po;
12553
12561
  }
12554
12562
  /**
12555
12563
  * Iterates over a set of doc changes, applies the query limit, and computes
@@ -12560,8 +12568,8 @@ class Yo {
12560
12568
  * @param previousChanges - If this is being called with a refill, then start
12561
12569
  * with this set of docs and changes instead of the current view.
12562
12570
  * @returns a new set of docs, changes, and refill flag.
12563
- */ Io(t, e) {
12564
- const n = e ? e.Ao : new Oo, s = e ? e.To : this.To;
12571
+ */ bo(t, e) {
12572
+ const n = e ? e.Po : new Oo, s = e ? e.Ao : this.Ao;
12565
12573
  let i = e ? e.mutatedKeys : this.mutatedKeys, r = s, o = !1;
12566
12574
  // Track the last doc in a (full) limit. This is necessary, because some
12567
12575
  // update (a delete, or an update moving a doc past the old limit) might
@@ -12584,10 +12592,10 @@ class Yo {
12584
12592
  u.data.isEqual(h.data) ? l !== f && (n.track({
12585
12593
  type: 3 /* Metadata */ ,
12586
12594
  doc: h
12587
- }), d = !0) : this.Ro(u, h) || (n.track({
12595
+ }), d = !0) : this.vo(u, h) || (n.track({
12588
12596
  type: 2 /* Modified */ ,
12589
12597
  doc: h
12590
- }), d = !0, (a && this.po(h, a) > 0 || c && this.po(h, c) < 0) && (
12598
+ }), d = !0, (a && this.Io(h, a) > 0 || c && this.Io(h, c) < 0) && (
12591
12599
  // This doc moved from inside the limit to outside the limit.
12592
12600
  // That means there may be some other doc in the local cache
12593
12601
  // that should be included instead.
@@ -12612,13 +12620,13 @@ class Yo {
12612
12620
  });
12613
12621
  }
12614
12622
  return {
12615
- To: r,
12616
- Ao: n,
12623
+ Ao: r,
12624
+ Po: n,
12617
12625
  Ln: o,
12618
12626
  mutatedKeys: i
12619
12627
  };
12620
12628
  }
12621
- Ro(t, e) {
12629
+ vo(t, e) {
12622
12630
  // We suppress the initial change event for documents that were modified as
12623
12631
  // part of a write acknowledgment (e.g. when the value of a server transform
12624
12632
  // is applied) as Watch will send us the same document again.
@@ -12640,10 +12648,10 @@ class Yo {
12640
12648
  */
12641
12649
  // PORTING NOTE: The iOS/Android clients always compute limbo document changes.
12642
12650
  applyChanges(t, e, n) {
12643
- const s = this.To;
12644
- this.To = t.To, this.mutatedKeys = t.mutatedKeys;
12651
+ const s = this.Ao;
12652
+ this.Ao = t.Ao, this.mutatedKeys = t.mutatedKeys;
12645
12653
  // Sort changes based on type and query comparator
12646
- const i = t.Ao.Yr();
12654
+ const i = t.Po.eo();
12647
12655
  i.sort(((t, e) => function(t, e) {
12648
12656
  const n = t => {
12649
12657
  switch (t) {
@@ -12681,68 +12689,68 @@ class Yo {
12681
12689
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12682
12690
  * See the License for the specific language governing permissions and
12683
12691
  * limitations under the License.
12684
- */ (t.type, e.type) || this.po(t.doc, e.doc))), this.bo(n);
12685
- const r = e ? this.Po() : [], o = 0 === this.yo.size && this.current ? 1 /* Synced */ : 0 /* Local */ , a = o !== this.mo;
12686
- if (this.mo = o, 0 !== i.length || a) {
12692
+ */ (t.type, e.type) || this.Io(t.doc, e.doc))), this.Vo(n);
12693
+ const r = e ? this.So() : [], o = 0 === this.Eo.size && this.current ? 1 /* Synced */ : 0 /* Local */ , a = o !== this.To;
12694
+ if (this.To = o, 0 !== i.length || a) {
12687
12695
  return {
12688
- snapshot: new Fo(this.query, t.To, s, i, t.mutatedKeys, 0 /* Local */ === o, a,
12696
+ snapshot: new Fo(this.query, t.Ao, s, i, t.mutatedKeys, 0 /* Local */ === o, a,
12689
12697
  /* excludesMetadataChanges= */ !1),
12690
- vo: r
12698
+ Do: r
12691
12699
  };
12692
12700
  }
12693
12701
  // no changes
12694
12702
  return {
12695
- vo: r
12703
+ Do: r
12696
12704
  };
12697
12705
  }
12698
12706
  /**
12699
12707
  * Applies an OnlineState change to the view, potentially generating a
12700
12708
  * ViewChange if the view's syncState changes as a result.
12701
- */ eo(t) {
12709
+ */ io(t) {
12702
12710
  return this.current && "Offline" /* Offline */ === t ? (
12703
12711
  // If we're offline, set `current` to false and then call applyChanges()
12704
12712
  // to refresh our syncState and generate a ViewChange as appropriate. We
12705
12713
  // are guaranteed to get a new TargetChange that sets `current` back to
12706
12714
  // true once the client is back online.
12707
12715
  this.current = !1, this.applyChanges({
12708
- To: this.To,
12709
- Ao: new Oo,
12716
+ Ao: this.Ao,
12717
+ Po: new Oo,
12710
12718
  mutatedKeys: this.mutatedKeys,
12711
12719
  Ln: !1
12712
12720
  },
12713
12721
  /* updateLimboDocuments= */ !1)) : {
12714
- vo: []
12722
+ Do: []
12715
12723
  };
12716
12724
  }
12717
12725
  /**
12718
12726
  * Returns whether the doc for the given key should be in limbo.
12719
- */ Vo(t) {
12727
+ */ Co(t) {
12720
12728
  // If the remote end says it's part of this query, it's not in limbo.
12721
- return !this._o.has(t) && (
12729
+ return !this.po.has(t) && (
12722
12730
  // The local store doesn't think it's a result, so it shouldn't be in limbo.
12723
- !!this.To.has(t) && !this.To.get(t).hasLocalMutations);
12731
+ !!this.Ao.has(t) && !this.Ao.get(t).hasLocalMutations);
12724
12732
  }
12725
12733
  /**
12726
12734
  * Updates syncedDocuments, current, and limbo docs based on the given change.
12727
12735
  * Returns the list of changes to which docs are in limbo.
12728
- */ bo(t) {
12729
- t && (t.addedDocuments.forEach((t => this._o = this._o.add(t))), t.modifiedDocuments.forEach((t => {})),
12730
- t.removedDocuments.forEach((t => this._o = this._o.delete(t))), this.current = t.current);
12736
+ */ Vo(t) {
12737
+ t && (t.addedDocuments.forEach((t => this.po = this.po.add(t))), t.modifiedDocuments.forEach((t => {})),
12738
+ t.removedDocuments.forEach((t => this.po = this.po.delete(t))), this.current = t.current);
12731
12739
  }
12732
- Po() {
12740
+ So() {
12733
12741
  // We can only determine limbo documents when we're in-sync with the server.
12734
12742
  if (!this.current) return [];
12735
12743
  // TODO(klimt): Do this incrementally so that it's not quadratic when
12736
12744
  // updating many documents.
12737
- const t = this.yo;
12738
- this.yo = Pn(), this.To.forEach((t => {
12739
- this.Vo(t.key) && (this.yo = this.yo.add(t.key));
12745
+ const t = this.Eo;
12746
+ this.Eo = Pn(), this.Ao.forEach((t => {
12747
+ this.Co(t.key) && (this.Eo = this.Eo.add(t.key));
12740
12748
  }));
12741
12749
  // Diff the new limbo docs with the old limbo docs.
12742
12750
  const e = [];
12743
12751
  return t.forEach((t => {
12744
- this.yo.has(t) || e.push(new Yo(t));
12745
- })), this.yo.forEach((n => {
12752
+ this.Eo.has(t) || e.push(new Yo(t));
12753
+ })), this.Eo.forEach((n => {
12746
12754
  t.has(n) || e.push(new Jo(n));
12747
12755
  })), e;
12748
12756
  }
@@ -12766,9 +12774,9 @@ class Yo {
12766
12774
  * @returns The ViewChange that resulted from this synchronization.
12767
12775
  */
12768
12776
  // PORTING NOTE: Multi-tab only.
12769
- So(t) {
12770
- this._o = t.Gn, this.yo = Pn();
12771
- const e = this.Io(t.documents);
12777
+ No(t) {
12778
+ this.po = t.Gn, this.Eo = Pn();
12779
+ const e = this.bo(t.documents);
12772
12780
  return this.applyChanges(e, /*updateLimboDocuments=*/ !0);
12773
12781
  }
12774
12782
  /**
@@ -12777,8 +12785,8 @@ class Yo {
12777
12785
  * `hasPendingWrites` status of the already established view.
12778
12786
  */
12779
12787
  // PORTING NOTE: Multi-tab only.
12780
- Do() {
12781
- return Fo.fromInitialDocuments(this.query, this.To, this.mutatedKeys, 0 /* Local */ === this.mo);
12788
+ xo() {
12789
+ return Fo.fromInitialDocuments(this.query, this.Ao, this.mutatedKeys, 0 /* Local */ === this.To);
12782
12790
  }
12783
12791
  }
12784
12792
 
@@ -12817,7 +12825,7 @@ class Zo {
12817
12825
  * decide whether it needs to manufacture a delete event for the target once
12818
12826
  * the target is CURRENT.
12819
12827
  */
12820
- this.Co = !1;
12828
+ this.ko = !1;
12821
12829
  }
12822
12830
  }
12823
12831
 
@@ -12838,8 +12846,8 @@ class Zo {
12838
12846
  // PORTING NOTE: Manages state synchronization in multi-tab environments.
12839
12847
  s, i, r) {
12840
12848
  this.localStore = t, this.remoteStore = e, this.eventManager = n, this.sharedClientState = s,
12841
- this.currentUser = i, this.maxConcurrentLimboResolutions = r, this.No = {}, this.xo = new ji((t => Re(t)), Ae),
12842
- this.ko = new Map,
12849
+ this.currentUser = i, this.maxConcurrentLimboResolutions = r, this.$o = {}, this.Oo = new ji((t => Re(t)), Ae),
12850
+ this.Fo = new Map,
12843
12851
  /**
12844
12852
  * The keys of documents that are in limbo for which we haven't yet started a
12845
12853
  * limbo resolution query. The strings in this set are the result of calling
@@ -12849,28 +12857,28 @@ class Zo {
12849
12857
  * of arbitrary elements and it also maintains insertion order, providing the
12850
12858
  * desired queue-like FIFO semantics.
12851
12859
  */
12852
- this.$o = new Set,
12860
+ this.Mo = new Set,
12853
12861
  /**
12854
12862
  * Keeps track of the target ID for each document that is in limbo with an
12855
12863
  * active target.
12856
12864
  */
12857
- this.Oo = new wn(Pt.comparator),
12865
+ this.Lo = new wn(Pt.comparator),
12858
12866
  /**
12859
12867
  * Keeps track of the information about an active limbo resolution for each
12860
12868
  * active target ID that was started for the purpose of limbo resolution.
12861
12869
  */
12862
- this.Fo = new Map, this.Mo = new br,
12870
+ this.Bo = new Map, this.Uo = new br,
12863
12871
  /** Stores user completion handlers, indexed by User and BatchId. */
12864
- this.Lo = {},
12872
+ this.qo = {},
12865
12873
  /** Stores user callbacks waiting for all pending writes to be acknowledged. */
12866
- this.Bo = new Map, this.Uo = Ni.ie(), this.onlineState = "Unknown" /* Unknown */ ,
12874
+ this.Ko = new Map, this.jo = Ni.ie(), this.onlineState = "Unknown" /* Unknown */ ,
12867
12875
  // The primary state is set to `true` or `false` immediately after Firestore
12868
12876
  // startup. In the interim, a client should only be considered primary if
12869
12877
  // `isPrimary` is true.
12870
- this.qo = void 0;
12878
+ this.Qo = void 0;
12871
12879
  }
12872
12880
  get isPrimaryClient() {
12873
- return !0 === this.qo;
12881
+ return !0 === this.Qo;
12874
12882
  }
12875
12883
  }
12876
12884
 
@@ -12882,7 +12890,7 @@ class Zo {
12882
12890
  async function na(t, e) {
12883
12891
  const n = Ca(t);
12884
12892
  let s, i;
12885
- const r = n.xo.get(e);
12893
+ const r = n.Oo.get(e);
12886
12894
  if (r)
12887
12895
  // PORTING NOTE: With Multi-Tab Web, it is possible that a query view
12888
12896
  // already exists when EventManager calls us for the first time. This
@@ -12890,7 +12898,7 @@ async function na(t, e) {
12890
12898
  // behalf of another tab and the user of the primary also starts listening
12891
12899
  // to the query. EventManager will not have an assigned target ID in this
12892
12900
  // case and calls `listen` to obtain this ID.
12893
- s = r.targetId, n.sharedClientState.addLocalQueryTarget(s), i = r.view.Do(); else {
12901
+ s = r.targetId, n.sharedClientState.addLocalQueryTarget(s), i = r.view.xo(); else {
12894
12902
  const t = await mr(n.localStore, Ee(e)), r = n.sharedClientState.addLocalQueryTarget(t.targetId);
12895
12903
  s = t.targetId, i = await sa(n, e, s, "current" === r), n.isPrimaryClient && ao(n.remoteStore, t);
12896
12904
  }
@@ -12904,29 +12912,29 @@ async function na(t, e) {
12904
12912
  // PORTING NOTE: On Web only, we inject the code that registers new Limbo
12905
12913
  // targets based on view changes. This allows us to only depend on Limbo
12906
12914
  // changes when user code includes queries.
12907
- t.Ko = (e, n, s) => async function(t, e, n, s) {
12908
- let i = e.view.Io(n);
12915
+ t.Wo = (e, n, s) => async function(t, e, n, s) {
12916
+ let i = e.view.bo(n);
12909
12917
  i.Ln && (
12910
12918
  // The query has a limit and some docs were removed, so we need
12911
12919
  // to re-run the query against the local store to make sure we
12912
12920
  // didn't lose any good docs that had been past the limit.
12913
12921
  i = await yr(t.localStore, e.query,
12914
- /* usePreviousResults= */ !1).then((({documents: t}) => e.view.Io(t, i))));
12922
+ /* usePreviousResults= */ !1).then((({documents: t}) => e.view.bo(t, i))));
12915
12923
  const r = s && s.targetChanges.get(e.targetId), o = e.view.applyChanges(i,
12916
12924
  /* updateLimboDocuments= */ t.isPrimaryClient, r);
12917
- return ma(t, e.targetId, o.vo), o.snapshot;
12925
+ return ma(t, e.targetId, o.Do), o.snapshot;
12918
12926
  }(t, e, n, s);
12919
12927
  const i = await yr(t.localStore, e,
12920
- /* usePreviousResults= */ !0), r = new Xo(e, i.Gn), o = r.Io(i.documents), a = Dn.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState), c = r.applyChanges(o,
12928
+ /* usePreviousResults= */ !0), r = new Xo(e, i.Gn), o = r.bo(i.documents), a = Dn.createSynthesizedTargetChangeForCurrentChange(n, s && "Offline" /* Offline */ !== t.onlineState), c = r.applyChanges(o,
12921
12929
  /* updateLimboDocuments= */ t.isPrimaryClient, a);
12922
- ma(t, n, c.vo);
12930
+ ma(t, n, c.Do);
12923
12931
  const u = new Zo(e, n, r);
12924
- return t.xo.set(e, u), t.ko.has(n) ? t.ko.get(n).push(e) : t.ko.set(n, [ e ]), c.snapshot;
12932
+ return t.Oo.set(e, u), t.Fo.has(n) ? t.Fo.get(n).push(e) : t.Fo.set(n, [ e ]), c.snapshot;
12925
12933
  }
12926
12934
 
12927
12935
  /** Stops listening to the query. */ async function ia(t, e) {
12928
- const n = q(t), s = n.xo.get(e), i = n.ko.get(s.targetId);
12929
- if (i.length > 1) return n.ko.set(s.targetId, i.filter((t => !Ae(t, e)))), void n.xo.delete(e);
12936
+ const n = q(t), s = n.Oo.get(e), i = n.Fo.get(s.targetId);
12937
+ if (i.length > 1) return n.Fo.set(s.targetId, i.filter((t => !Ae(t, e)))), void n.Oo.delete(e);
12930
12938
  // No other queries are mapped to the target, clean up the query and the target.
12931
12939
  if (n.isPrimaryClient) {
12932
12940
  // We need to remove the local query target first to allow us to verify
@@ -12979,9 +12987,9 @@ async function na(t, e) {
12979
12987
  })));
12980
12988
  }(s.localStore, e);
12981
12989
  s.sharedClientState.addPendingMutation(t.batchId), function(t, e, n) {
12982
- let s = t.Lo[t.currentUser.toKey()];
12990
+ let s = t.qo[t.currentUser.toKey()];
12983
12991
  s || (s = new wn(et));
12984
- s = s.insert(e, n), t.Lo[t.currentUser.toKey()] = s;
12992
+ s = s.insert(e, n), t.qo[t.currentUser.toKey()] = s;
12985
12993
  }
12986
12994
  /**
12987
12995
  * Resolves or rejects the user callback for the given batch and then discards
@@ -13005,13 +13013,13 @@ async function na(t, e) {
13005
13013
  const t = await dr(n.localStore, e);
13006
13014
  // Update `receivedDocument` as appropriate for any limbo targets.
13007
13015
  e.targetChanges.forEach(((t, e) => {
13008
- const s = n.Fo.get(e);
13016
+ const s = n.Bo.get(e);
13009
13017
  s && (
13010
13018
  // Since this is a limbo resolution lookup, it's for a single document
13011
13019
  // and it could be added, modified, or removed, but not a combination.
13012
13020
  B(t.addedDocuments.size + t.modifiedDocuments.size + t.removedDocuments.size <= 1),
13013
- t.addedDocuments.size > 0 ? s.Co = !0 : t.modifiedDocuments.size > 0 ? B(s.Co) : t.removedDocuments.size > 0 && (B(s.Co),
13014
- s.Co = !1));
13021
+ t.addedDocuments.size > 0 ? s.ko = !0 : t.modifiedDocuments.size > 0 ? B(s.ko) : t.removedDocuments.size > 0 && (B(s.ko),
13022
+ s.ko = !1));
13015
13023
  })), await pa(n, t, e);
13016
13024
  } catch (t) {
13017
13025
  await Fi(t);
@@ -13029,8 +13037,8 @@ async function na(t, e) {
13029
13037
  // SharedClientState.
13030
13038
  if (s.isPrimaryClient && 0 /* RemoteStore */ === n || !s.isPrimaryClient && 1 /* SharedClientState */ === n) {
13031
13039
  const t = [];
13032
- s.xo.forEach(((n, s) => {
13033
- const i = s.view.eo(e);
13040
+ s.Oo.forEach(((n, s) => {
13041
+ const i = s.view.io(e);
13034
13042
  i.snapshot && t.push(i.snapshot);
13035
13043
  })), function(t, e) {
13036
13044
  const n = q(t);
@@ -13039,9 +13047,9 @@ async function na(t, e) {
13039
13047
  n.queries.forEach(((t, n) => {
13040
13048
  for (const t of n.listeners)
13041
13049
  // Run global snapshot listeners if a consistent snapshot has been emitted.
13042
- t.eo(e) && (s = !0);
13050
+ t.io(e) && (s = !0);
13043
13051
  })), s && jo(n);
13044
- }(s.eventManager, e), t.length && s.No.Er(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
13052
+ }(s.eventManager, e), t.length && s.$o.Rr(t), s.onlineState = e, s.isPrimaryClient && s.sharedClientState.setOnlineState(e);
13045
13053
  }
13046
13054
  }
13047
13055
 
@@ -13059,7 +13067,7 @@ async function na(t, e) {
13059
13067
  const s = q(t);
13060
13068
  // PORTING NOTE: Multi-tab only.
13061
13069
  s.sharedClientState.updateQueryState(e, "rejected", n);
13062
- const i = s.Fo.get(e), r = i && i.key;
13070
+ const i = s.Bo.get(e), r = i && i.key;
13063
13071
  if (r) {
13064
13072
  // TODO(klimt): We really only should do the following on permission
13065
13073
  // denied errors, but we don't have the cause code here.
@@ -13078,7 +13086,7 @@ async function na(t, e) {
13078
13086
  // RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
13079
13087
  // this query when the RemoteStore restarts the Watch stream, which should
13080
13088
  // re-trigger the target failure.
13081
- s.Oo = s.Oo.remove(r), s.Fo.delete(e), ya(s);
13089
+ s.Lo = s.Lo.remove(r), s.Bo.delete(e), ya(s);
13082
13090
  } else await gr(s.localStore, e,
13083
13091
  /* keepPersistedTargetData */ !1).then((() => wa(s, e, n))).catch(Fi);
13084
13092
  }
@@ -13139,8 +13147,8 @@ async function ha(t, e, n) {
13139
13147
  if (-1 === t)
13140
13148
  // Trigger the callback right away if there is no pending writes at the moment.
13141
13149
  return void e.resolve();
13142
- const s = n.Bo.get(t) || [];
13143
- s.push(e), n.Bo.set(t, s);
13150
+ const s = n.Ko.get(t) || [];
13151
+ s.push(e), n.Ko.set(t, s);
13144
13152
  } catch (t) {
13145
13153
  const n = ko(t, "Initialization of waitForPendingWrites() operation failed");
13146
13154
  e.reject(n);
@@ -13151,28 +13159,28 @@ async function ha(t, e, n) {
13151
13159
  * Triggers the callbacks that are waiting for this batch id to get acknowledged by server,
13152
13160
  * if there are any.
13153
13161
  */ function fa(t, e) {
13154
- (t.Bo.get(e) || []).forEach((t => {
13162
+ (t.Ko.get(e) || []).forEach((t => {
13155
13163
  t.resolve();
13156
- })), t.Bo.delete(e);
13164
+ })), t.Ko.delete(e);
13157
13165
  }
13158
13166
 
13159
13167
  /** Reject all outstanding callbacks waiting for pending writes to complete. */ function da(t, e, n) {
13160
13168
  const s = q(t);
13161
- let i = s.Lo[s.currentUser.toKey()];
13169
+ let i = s.qo[s.currentUser.toKey()];
13162
13170
  // NOTE: Mutations restored from persistence won't have callbacks, so it's
13163
13171
  // okay for there to be no callback for this ID.
13164
13172
  if (i) {
13165
13173
  const t = i.get(e);
13166
- t && (n ? t.reject(n) : t.resolve(), i = i.remove(e)), s.Lo[s.currentUser.toKey()] = i;
13174
+ t && (n ? t.reject(n) : t.resolve(), i = i.remove(e)), s.qo[s.currentUser.toKey()] = i;
13167
13175
  }
13168
13176
  }
13169
13177
 
13170
13178
  function wa(t, e, n = null) {
13171
13179
  t.sharedClientState.removeLocalQueryTarget(e);
13172
- for (const s of t.ko.get(e)) t.xo.delete(s), n && t.No.jo(s, n);
13173
- if (t.ko.delete(e), t.isPrimaryClient) {
13174
- t.Mo.cs(e).forEach((e => {
13175
- t.Mo.containsKey(e) ||
13180
+ for (const s of t.Fo.get(e)) t.Oo.delete(s), n && t.$o.Go(s, n);
13181
+ if (t.Fo.delete(e), t.isPrimaryClient) {
13182
+ t.Uo.cs(e).forEach((e => {
13183
+ t.Uo.containsKey(e) ||
13176
13184
  // We removed the last reference for this key
13177
13185
  _a(t, e);
13178
13186
  }));
@@ -13180,17 +13188,17 @@ function wa(t, e, n = null) {
13180
13188
  }
13181
13189
 
13182
13190
  function _a(t, e) {
13183
- t.$o.delete(e.path.canonicalString());
13191
+ t.Mo.delete(e.path.canonicalString());
13184
13192
  // It's possible that the target already got removed because the query failed. In that case,
13185
13193
  // the key won't exist in `limboTargetsByKey`. Only do the cleanup if we still have the target.
13186
- const n = t.Oo.get(e);
13187
- null !== n && (co(t.remoteStore, n), t.Oo = t.Oo.remove(e), t.Fo.delete(n), ya(t));
13194
+ const n = t.Lo.get(e);
13195
+ null !== n && (co(t.remoteStore, n), t.Lo = t.Lo.remove(e), t.Bo.delete(n), ya(t));
13188
13196
  }
13189
13197
 
13190
13198
  function ma(t, e, n) {
13191
- for (const s of n) if (s instanceof Jo) t.Mo.addReference(s.key, e), ga(t, s); else if (s instanceof Yo) {
13192
- $("SyncEngine", "Document no longer in limbo: " + s.key), t.Mo.removeReference(s.key, e);
13193
- t.Mo.containsKey(s.key) ||
13199
+ for (const s of n) if (s instanceof Jo) t.Uo.addReference(s.key, e), ga(t, s); else if (s instanceof Yo) {
13200
+ $("SyncEngine", "Document no longer in limbo: " + s.key), t.Uo.removeReference(s.key, e);
13201
+ t.Uo.containsKey(s.key) ||
13194
13202
  // We removed the last reference for this key
13195
13203
  _a(t, s.key);
13196
13204
  } else L();
@@ -13198,7 +13206,7 @@ function ma(t, e, n) {
13198
13206
 
13199
13207
  function ga(t, e) {
13200
13208
  const n = e.key, s = n.path.canonicalString();
13201
- t.Oo.get(n) || t.$o.has(s) || ($("SyncEngine", "New document in limbo: " + n), t.$o.add(s),
13209
+ t.Lo.get(n) || t.Mo.has(s) || ($("SyncEngine", "New document in limbo: " + n), t.Mo.add(s),
13202
13210
  ya(t));
13203
13211
  }
13204
13212
 
@@ -13210,18 +13218,18 @@ function ga(t, e) {
13210
13218
  * with "resource exhausted" errors which can lead to pathological client
13211
13219
  * behavior as seen in https://github.com/firebase/firebase-js-sdk/issues/2683.
13212
13220
  */ function ya(t) {
13213
- for (;t.$o.size > 0 && t.Oo.size < t.maxConcurrentLimboResolutions; ) {
13214
- const e = t.$o.values().next().value;
13215
- t.$o.delete(e);
13216
- const n = new Pt(ht.fromString(e)), s = t.Uo.next();
13217
- t.Fo.set(s, new ta(n)), t.Oo = t.Oo.insert(n, s), ao(t.remoteStore, new ii(Ee(we(n.path)), s, 2 /* LimboResolution */ , X.T));
13221
+ for (;t.Mo.size > 0 && t.Lo.size < t.maxConcurrentLimboResolutions; ) {
13222
+ const e = t.Mo.values().next().value;
13223
+ t.Mo.delete(e);
13224
+ const n = new Pt(ht.fromString(e)), s = t.jo.next();
13225
+ t.Bo.set(s, new ta(n)), t.Lo = t.Lo.insert(n, s), ao(t.remoteStore, new ii(Ee(we(n.path)), s, 2 /* LimboResolution */ , X.T));
13218
13226
  }
13219
13227
  }
13220
13228
 
13221
13229
  async function pa(t, e, n) {
13222
13230
  const s = q(t), i = [], r = [], o = [];
13223
- s.xo.isEmpty() || (s.xo.forEach(((t, a) => {
13224
- o.push(s.Ko(a, e, n).then((t => {
13231
+ s.Oo.isEmpty() || (s.Oo.forEach(((t, a) => {
13232
+ o.push(s.Wo(a, e, n).then((t => {
13225
13233
  if (t) {
13226
13234
  s.isPrimaryClient && s.sharedClientState.updateQueryState(a.targetId, t.fromCache ? "not-current" : "current"),
13227
13235
  i.push(t);
@@ -13229,7 +13237,7 @@ async function pa(t, e, n) {
13229
13237
  r.push(e);
13230
13238
  }
13231
13239
  })));
13232
- })), await Promise.all(o), s.No.Er(i), await async function(t, e) {
13240
+ })), await Promise.all(o), s.$o.Rr(i), await async function(t, e) {
13233
13241
  const n = q(t);
13234
13242
  try {
13235
13243
  await n.persistence.runTransaction("notifyLocalViewChanges", "readwrite", (t => js.forEach(e, (e => js.forEach(e.Nn, (s => n.persistence.referenceDelegate.addReference(t, e.targetId, s))).next((() => js.forEach(e.xn, (s => n.persistence.referenceDelegate.removeReference(t, e.targetId, s)))))))));
@@ -13260,11 +13268,11 @@ async function Ta(t, e) {
13260
13268
  n.currentUser = e,
13261
13269
  // Fails tasks waiting for pending writes requested by previous user.
13262
13270
  function(t, e) {
13263
- t.Bo.forEach((t => {
13271
+ t.Ko.forEach((t => {
13264
13272
  t.forEach((t => {
13265
13273
  t.reject(new j(K.CANCELLED, e));
13266
13274
  }));
13267
- })), t.Bo.clear();
13275
+ })), t.Ko.clear();
13268
13276
  }(n, "'waitForPendingWrites' promise is rejected due to a user change."),
13269
13277
  // TODO(b/114226417): Consider calling this only in the primary tab.
13270
13278
  n.sharedClientState.handleUserChange(e, t.removedBatchIds, t.addedBatchIds), await pa(n, t.Wn);
@@ -13272,15 +13280,15 @@ async function Ta(t, e) {
13272
13280
  }
13273
13281
 
13274
13282
  function Ea(t, e) {
13275
- const n = q(t), s = n.Fo.get(e);
13276
- if (s && s.Co) return Pn().add(s.key);
13283
+ const n = q(t), s = n.Bo.get(e);
13284
+ if (s && s.ko) return Pn().add(s.key);
13277
13285
  {
13278
13286
  let t = Pn();
13279
- const s = n.ko.get(e);
13287
+ const s = n.Fo.get(e);
13280
13288
  if (!s) return t;
13281
13289
  for (const e of s) {
13282
- const s = n.xo.get(e);
13283
- t = t.unionWith(s.view.Eo);
13290
+ const s = n.Oo.get(e);
13291
+ t = t.unionWith(s.view.Ro);
13284
13292
  }
13285
13293
  return t;
13286
13294
  }
@@ -13291,8 +13299,8 @@ function Ea(t, e) {
13291
13299
  * from persistence.
13292
13300
  */ async function Ia(t, e) {
13293
13301
  const n = q(t), s = await yr(n.localStore, e.query,
13294
- /* usePreviousResults= */ !0), i = e.view.So(s);
13295
- return n.isPrimaryClient && ma(n, e.targetId, i.vo), i;
13302
+ /* usePreviousResults= */ !0), i = e.view.No(s);
13303
+ return n.isPrimaryClient && ma(n, e.targetId, i.Do), i;
13296
13304
  }
13297
13305
 
13298
13306
  /**
@@ -13340,7 +13348,7 @@ async function Ra(t, e, n, s) {
13340
13348
  // PORTING NOTE: Multi-Tab only.
13341
13349
  async function ba(t, e) {
13342
13350
  const n = q(t);
13343
- if (Ca(n), Na(n), !0 === e && !0 !== n.qo) {
13351
+ if (Ca(n), Na(n), !0 === e && !0 !== n.Qo) {
13344
13352
  // Secondary tabs only maintain Views for their local listeners and the
13345
13353
  // Views internal state may not be 100% populated (in particular
13346
13354
  // secondary tabs don't track syncedDocuments, the set of documents the
@@ -13348,12 +13356,12 @@ async function ba(t, e) {
13348
13356
  // primary, we need to need to make sure that all views for all targets
13349
13357
  // match the state on disk.
13350
13358
  const t = n.sharedClientState.getAllActiveQueryTargets(), e = await Pa(n, t.toArray());
13351
- n.qo = !0, await Do(n.remoteStore, !0);
13359
+ n.Qo = !0, await Do(n.remoteStore, !0);
13352
13360
  for (const t of e) ao(n.remoteStore, t);
13353
- } else if (!1 === e && !1 !== n.qo) {
13361
+ } else if (!1 === e && !1 !== n.Qo) {
13354
13362
  const t = [];
13355
13363
  let e = Promise.resolve();
13356
- n.ko.forEach(((s, i) => {
13364
+ n.Fo.forEach(((s, i) => {
13357
13365
  n.sharedClientState.isLocalQueryTarget(i) ? t.push(i) : e = e.then((() => (wa(n, i),
13358
13366
  gr(n.localStore, i,
13359
13367
  /*keepPersistedTargetData=*/ !0)))), co(n.remoteStore, i);
@@ -13361,9 +13369,9 @@ async function ba(t, e) {
13361
13369
  // PORTING NOTE: Multi-Tab only.
13362
13370
  function(t) {
13363
13371
  const e = q(t);
13364
- e.Fo.forEach(((t, n) => {
13372
+ e.Bo.forEach(((t, n) => {
13365
13373
  co(e.remoteStore, n);
13366
- })), e.Mo.us(), e.Fo = new Map, e.Oo = new wn(Pt.comparator);
13374
+ })), e.Uo.us(), e.Bo = new Map, e.Lo = new wn(Pt.comparator);
13367
13375
  }
13368
13376
  /**
13369
13377
  * Reconcile the query views of the provided query targets with the state from
@@ -13376,7 +13384,7 @@ async function ba(t, e) {
13376
13384
  * tab to a primary tab
13377
13385
  */
13378
13386
  // PORTING NOTE: Multi-Tab only.
13379
- (n), n.qo = !1, await Do(n.remoteStore, !1);
13387
+ (n), n.Qo = !1, await Do(n.remoteStore, !1);
13380
13388
  }
13381
13389
  }
13382
13390
 
@@ -13384,7 +13392,7 @@ async function Pa(t, e, n) {
13384
13392
  const s = q(t), i = [], r = [];
13385
13393
  for (const t of e) {
13386
13394
  let e;
13387
- const n = s.ko.get(t);
13395
+ const n = s.Fo.get(t);
13388
13396
  if (n && 0 !== n.length) {
13389
13397
  // For queries that have a local View, we fetch their current state
13390
13398
  // from LocalStore (as the resume token and the snapshot version
@@ -13392,7 +13400,7 @@ async function Pa(t, e, n) {
13392
13400
  // state (the list of syncedDocuments may have gotten out of sync).
13393
13401
  e = await mr(s.localStore, Ee(n[0]));
13394
13402
  for (const t of n) {
13395
- const e = s.xo.get(t), n = await Ia(s, e);
13403
+ const e = s.Oo.get(t), n = await Ia(s, e);
13396
13404
  n.snapshot && r.push(n.snapshot);
13397
13405
  }
13398
13406
  } else {
@@ -13404,7 +13412,7 @@ async function Pa(t, e, n) {
13404
13412
  }
13405
13413
  i.push(e);
13406
13414
  }
13407
- return s.No.Er(r), i;
13415
+ return s.$o.Rr(r), i;
13408
13416
  }
13409
13417
 
13410
13418
  /**
@@ -13433,10 +13441,10 @@ function Va(t) {
13433
13441
  // PORTING NOTE: Multi-Tab only.
13434
13442
  async function Sa(t, e, n, s) {
13435
13443
  const i = q(t);
13436
- if (i.qo)
13444
+ if (i.Qo)
13437
13445
  // If we receive a target state notification via WebStorage, we are
13438
13446
  // either already secondary or another tab has taken the primary lease.
13439
- $("SyncEngine", "Ignoring unexpected query state notification."); else if (i.ko.has(e)) switch (n) {
13447
+ $("SyncEngine", "Ignoring unexpected query state notification."); else if (i.Fo.has(e)) switch (n) {
13440
13448
  case "current":
13441
13449
  case "not-current":
13442
13450
  {
@@ -13457,9 +13465,9 @@ async function Sa(t, e, n, s) {
13457
13465
 
13458
13466
  /** Adds or removes Watch targets for queries from different tabs. */ async function Da(t, e, n) {
13459
13467
  const s = Ca(t);
13460
- if (s.qo) {
13468
+ if (s.Qo) {
13461
13469
  for (const t of e) {
13462
- if (s.ko.has(t)) {
13470
+ if (s.Fo.has(t)) {
13463
13471
  // A target might have been added in a previous attempt
13464
13472
  $("SyncEngine", "Adding an already active target " + t);
13465
13473
  continue;
@@ -13471,7 +13479,7 @@ async function Sa(t, e, n, s) {
13471
13479
  for (const t of n)
13472
13480
  // Check that the target is still active since the target might have been
13473
13481
  // removed if it has been rejected by the backend.
13474
- s.ko.has(t) &&
13482
+ s.Fo.has(t) &&
13475
13483
  // Release queries that are still active.
13476
13484
  await gr(s.localStore, t,
13477
13485
  /* keepPersistedTargetData */ !1).then((() => {
@@ -13483,8 +13491,8 @@ async function Sa(t, e, n, s) {
13483
13491
  function Ca(t) {
13484
13492
  const e = q(t);
13485
13493
  return e.remoteStore.remoteSyncer.applyRemoteEvent = oa.bind(null, e), e.remoteStore.remoteSyncer.getRemoteKeysForTarget = Ea.bind(null, e),
13486
- e.remoteStore.remoteSyncer.rejectListen = ca.bind(null, e), e.No.Er = qo.bind(null, e.eventManager),
13487
- e.No.jo = Ko.bind(null, e.eventManager), e;
13494
+ e.remoteStore.remoteSyncer.rejectListen = ca.bind(null, e), e.$o.Rr = qo.bind(null, e.eventManager),
13495
+ e.$o.Go = Ko.bind(null, e.eventManager), e;
13488
13496
  }
13489
13497
 
13490
13498
  function Na(t) {
@@ -13523,10 +13531,10 @@ function Na(t) {
13523
13531
  }(s));
13524
13532
  n._updateProgress(Ho(s));
13525
13533
  const i = new zo(s, t.localStore, e.N);
13526
- let r = await e.Qo();
13534
+ let r = await e.zo();
13527
13535
  for (;r; ) {
13528
- const t = await i.fo(r);
13529
- t && n._updateProgress(t), r = await e.Qo();
13536
+ const t = await i.mo(r);
13537
+ t && n._updateProgress(t), r = await e.zo();
13530
13538
  }
13531
13539
  const o = await i.complete();
13532
13540
  // TODO(b/160876443): This currently raises snapshots with
@@ -13576,19 +13584,19 @@ class ka {
13576
13584
  this.synchronizeTabs = !1;
13577
13585
  }
13578
13586
  async initialize(t) {
13579
- this.N = Yr(t.databaseInfo.databaseId), this.sharedClientState = this.Wo(t), this.persistence = this.Go(t),
13580
- await this.persistence.start(), this.gcScheduler = this.zo(t), this.localStore = this.Ho(t);
13587
+ this.N = Yr(t.databaseInfo.databaseId), this.sharedClientState = this.Ho(t), this.persistence = this.Jo(t),
13588
+ await this.persistence.start(), this.gcScheduler = this.Yo(t), this.localStore = this.Xo(t);
13581
13589
  }
13582
- zo(t) {
13590
+ Yo(t) {
13583
13591
  return null;
13584
13592
  }
13585
- Ho(t) {
13593
+ Xo(t) {
13586
13594
  return ur(this.persistence, new ar, t.initialUser, this.N);
13587
13595
  }
13588
- Go(t) {
13596
+ Jo(t) {
13589
13597
  return new Cr(xr.Ns, this.N);
13590
13598
  }
13591
- Wo(t) {
13599
+ Ho(t) {
13592
13600
  return new Kr;
13593
13601
  }
13594
13602
  async terminate() {
@@ -13601,29 +13609,29 @@ class ka {
13601
13609
  * Provides all components needed for Firestore with IndexedDB persistence.
13602
13610
  */ class $a extends ka {
13603
13611
  constructor(t, e, n) {
13604
- super(), this.Jo = t, this.cacheSizeBytes = e, this.forceOwnership = n, this.synchronizeTabs = !1;
13612
+ super(), this.Zo = t, this.cacheSizeBytes = e, this.forceOwnership = n, this.synchronizeTabs = !1;
13605
13613
  }
13606
13614
  async initialize(t) {
13607
- await super.initialize(t), await Er(this.localStore), await this.Jo.initialize(this, t),
13615
+ await super.initialize(t), await Er(this.localStore), await this.Zo.initialize(this, t),
13608
13616
  // Enqueue writes from a previous session
13609
- await Na(this.Jo.syncEngine), await Eo(this.Jo.remoteStore),
13617
+ await Na(this.Zo.syncEngine), await Eo(this.Zo.remoteStore),
13610
13618
  // NOTE: This will immediately call the listener, so we make sure to
13611
13619
  // set it after localStore / remoteStore are started.
13612
13620
  await this.persistence.nn((() => (this.gcScheduler && !this.gcScheduler.started && this.gcScheduler.start(this.localStore),
13613
13621
  Promise.resolve())));
13614
13622
  }
13615
- Ho(t) {
13623
+ Xo(t) {
13616
13624
  return ur(this.persistence, new ar, t.initialUser, this.N);
13617
13625
  }
13618
- zo(t) {
13626
+ Yo(t) {
13619
13627
  const e = this.persistence.referenceDelegate.garbageCollector;
13620
13628
  return new Bi(e, t.asyncQueue);
13621
13629
  }
13622
- Go(t) {
13630
+ Jo(t) {
13623
13631
  const e = sr(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey), n = void 0 !== this.cacheSizeBytes ? Ri.withCacheSize(this.cacheSizeBytes) : Ri.DEFAULT;
13624
13632
  return new tr(this.synchronizeTabs, e, t.clientId, n, t.asyncQueue, Hr(), Jr(), this.N, this.sharedClientState, !!this.forceOwnership);
13625
13633
  }
13626
- Wo(t) {
13634
+ Ho(t) {
13627
13635
  return new Kr;
13628
13636
  }
13629
13637
  }
@@ -13637,11 +13645,11 @@ class ka {
13637
13645
  * `synchronizeTabs` will be enabled.
13638
13646
  */ class Oa extends $a {
13639
13647
  constructor(t, e) {
13640
- super(t, e, /* forceOwnership= */ !1), this.Jo = t, this.cacheSizeBytes = e, this.synchronizeTabs = !0;
13648
+ super(t, e, /* forceOwnership= */ !1), this.Zo = t, this.cacheSizeBytes = e, this.synchronizeTabs = !0;
13641
13649
  }
13642
13650
  async initialize(t) {
13643
13651
  await super.initialize(t);
13644
- const e = this.Jo.syncEngine;
13652
+ const e = this.Zo.syncEngine;
13645
13653
  this.sharedClientState instanceof qr && (this.sharedClientState.syncEngine = {
13646
13654
  _i: Ra.bind(null, e),
13647
13655
  mi: Sa.bind(null, e),
@@ -13652,10 +13660,10 @@ class ka {
13652
13660
  // NOTE: This will immediately call the listener, so we make sure to
13653
13661
  // set it after localStore / remoteStore are started.
13654
13662
  await this.persistence.nn((async t => {
13655
- await ba(this.Jo.syncEngine, t), this.gcScheduler && (t && !this.gcScheduler.started ? this.gcScheduler.start(this.localStore) : t || this.gcScheduler.stop());
13663
+ await ba(this.Zo.syncEngine, t), this.gcScheduler && (t && !this.gcScheduler.started ? this.gcScheduler.start(this.localStore) : t || this.gcScheduler.stop());
13656
13664
  }));
13657
13665
  }
13658
- Wo(t) {
13666
+ Ho(t) {
13659
13667
  const e = Hr();
13660
13668
  if (!qr.bt(e)) throw new j(K.UNIMPLEMENTED, "IndexedDB persistence is only available on platforms that support LocalStorage.");
13661
13669
  const n = sr(t.databaseInfo.databaseId, t.databaseInfo.persistenceKey);
@@ -13695,17 +13703,17 @@ class ka {
13695
13703
  // PORTING NOTE: Manages state synchronization in multi-tab environments.
13696
13704
  s, i, r, o) {
13697
13705
  const a = new ea(t, e, n, s, i, r);
13698
- return o && (a.qo = !0), a;
13706
+ return o && (a.Qo = !0), a;
13699
13707
  }(this.localStore, this.remoteStore, this.eventManager, this.sharedClientState, t.initialUser, t.maxConcurrentLimboResolutions, e);
13700
13708
  }
13701
13709
  terminate() {
13702
13710
  return async function(t) {
13703
13711
  const e = q(t);
13704
- $("RemoteStore", "RemoteStore shutting down."), e.Kr.add(5 /* Shutdown */), await oo(e),
13705
- e.Qr.shutdown(),
13712
+ $("RemoteStore", "RemoteStore shutting down."), e.Wr.add(5 /* Shutdown */), await oo(e),
13713
+ e.zr.shutdown(),
13706
13714
  // Set the OnlineState to Unknown (rather than Offline) to avoid potentially
13707
13715
  // triggering spurious listener events with cached data, etc.
13708
- e.Wr.set("Unknown" /* Unknown */);
13716
+ e.Hr.set("Unknown" /* Unknown */);
13709
13717
  }(this.remoteStore);
13710
13718
  }
13711
13719
  }
@@ -13813,15 +13821,15 @@ class La {
13813
13821
  this.muted = !1;
13814
13822
  }
13815
13823
  next(t) {
13816
- this.observer.next && this.Yo(this.observer.next, t);
13824
+ this.observer.next && this.ta(this.observer.next, t);
13817
13825
  }
13818
13826
  error(t) {
13819
- this.observer.error ? this.Yo(this.observer.error, t) : console.error("Uncaught Error in snapshot listener:", t);
13827
+ this.observer.error ? this.ta(this.observer.error, t) : console.error("Uncaught Error in snapshot listener:", t);
13820
13828
  }
13821
- Xo() {
13829
+ ea() {
13822
13830
  this.muted = !0;
13823
13831
  }
13824
- Yo(t, e) {
13832
+ ta(t, e) {
13825
13833
  this.muted || setTimeout((() => {
13826
13834
  this.muted || t(e);
13827
13835
  }), 0);
@@ -13853,28 +13861,28 @@ class La {
13853
13861
  constructor(
13854
13862
  /** The reader to read from underlying binary bundle data source. */
13855
13863
  t, e) {
13856
- this.Zo = t, this.N = e,
13864
+ this.na = t, this.N = e,
13857
13865
  /** Cached bundle metadata. */
13858
13866
  this.metadata = new Q,
13859
13867
  /**
13860
13868
  * Internal buffer to hold bundle content, accumulating incomplete element
13861
13869
  * content.
13862
13870
  */
13863
- this.buffer = new Uint8Array, this.ta = new TextDecoder("utf-8"),
13871
+ this.buffer = new Uint8Array, this.sa = new TextDecoder("utf-8"),
13864
13872
  // Read the metadata (which is the first element).
13865
- this.ea().then((t => {
13866
- t && t.ho() ? this.metadata.resolve(t.payload.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == t ? void 0 : t.payload)}`));
13873
+ this.ia().then((t => {
13874
+ t && t.wo() ? this.metadata.resolve(t.payload.metadata) : this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(null == t ? void 0 : t.payload)}`));
13867
13875
  }), (t => this.metadata.reject(t)));
13868
13876
  }
13869
13877
  close() {
13870
- return this.Zo.cancel();
13878
+ return this.na.cancel();
13871
13879
  }
13872
13880
  async getMetadata() {
13873
13881
  return this.metadata.promise;
13874
13882
  }
13875
- async Qo() {
13883
+ async zo() {
13876
13884
  // Makes sure metadata is read before proceeding.
13877
- return await this.getMetadata(), this.ea();
13885
+ return await this.getMetadata(), this.ia();
13878
13886
  }
13879
13887
  /**
13880
13888
  * Reads from the head of internal buffer, and pulling more data from
@@ -13885,15 +13893,15 @@ class La {
13885
13893
  *
13886
13894
  * Returns either the bundled element, or null if we have reached the end of
13887
13895
  * the stream.
13888
- */ async ea() {
13889
- const t = await this.na();
13896
+ */ async ia() {
13897
+ const t = await this.ra();
13890
13898
  if (null === t) return null;
13891
- const e = this.ta.decode(t), n = Number(e);
13892
- isNaN(n) && this.sa(`length string (${e}) is not valid number`);
13893
- const s = await this.ia(n);
13899
+ const e = this.sa.decode(t), n = Number(e);
13900
+ isNaN(n) && this.oa(`length string (${e}) is not valid number`);
13901
+ const s = await this.aa(n);
13894
13902
  return new Wo(JSON.parse(s), t.length + n);
13895
13903
  }
13896
- /** First index of '{' from the underlying buffer. */ ra() {
13904
+ /** First index of '{' from the underlying buffer. */ ca() {
13897
13905
  return this.buffer.findIndex((t => t === "{".charCodeAt(0)));
13898
13906
  }
13899
13907
  /**
@@ -13901,17 +13909,17 @@ class La {
13901
13909
  * return the content.
13902
13910
  *
13903
13911
  * If reached end of the stream, returns a null.
13904
- */ async na() {
13905
- for (;this.ra() < 0; ) {
13906
- if (await this.oa()) break;
13912
+ */ async ra() {
13913
+ for (;this.ca() < 0; ) {
13914
+ if (await this.ua()) break;
13907
13915
  }
13908
13916
  // Broke out of the loop because underlying stream is closed, and there
13909
13917
  // happens to be no more data to process.
13910
13918
  if (0 === this.buffer.length) return null;
13911
- const t = this.ra();
13919
+ const t = this.ca();
13912
13920
  // Broke out of the loop because underlying stream is closed, but still
13913
13921
  // cannot find an open bracket.
13914
- t < 0 && this.sa("Reached the end of bundle when a length string is expected.");
13922
+ t < 0 && this.oa("Reached the end of bundle when a length string is expected.");
13915
13923
  const e = this.buffer.slice(0, t);
13916
13924
  // Update the internal buffer to drop the read length.
13917
13925
  return this.buffer = this.buffer.slice(t), e;
@@ -13921,23 +13929,23 @@ class La {
13921
13929
  * number of bytes, pulling more data from the underlying stream if needed.
13922
13930
  *
13923
13931
  * Returns a string decoded from the read bytes.
13924
- */ async ia(t) {
13932
+ */ async aa(t) {
13925
13933
  for (;this.buffer.length < t; ) {
13926
- await this.oa() && this.sa("Reached the end of bundle when more is expected.");
13934
+ await this.ua() && this.oa("Reached the end of bundle when more is expected.");
13927
13935
  }
13928
- const e = this.ta.decode(this.buffer.slice(0, t));
13936
+ const e = this.sa.decode(this.buffer.slice(0, t));
13929
13937
  // Update the internal buffer to drop the read json string.
13930
13938
  return this.buffer = this.buffer.slice(t), e;
13931
13939
  }
13932
- sa(t) {
13940
+ oa(t) {
13933
13941
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
13934
- throw this.Zo.cancel(), new Error(`Invalid bundle format: ${t}`);
13942
+ throw this.na.cancel(), new Error(`Invalid bundle format: ${t}`);
13935
13943
  }
13936
13944
  /**
13937
13945
  * Pulls more data from underlying stream to internal buffer.
13938
13946
  * Returns a boolean indicating whether the stream is finished.
13939
- */ async oa() {
13940
- const t = await this.Zo.read();
13947
+ */ async ua() {
13948
+ const t = await this.na.read();
13941
13949
  if (!t.done) {
13942
13950
  const e = new Uint8Array(this.buffer.length + t.value.length);
13943
13951
  e.set(this.buffer), e.set(t.value, this.buffer.length), this.buffer = e;
@@ -14110,26 +14118,26 @@ class Ua {
14110
14118
  class qa {
14111
14119
  constructor(t, e, n, s) {
14112
14120
  this.asyncQueue = t, this.datastore = e, this.updateFunction = n, this.deferred = s,
14113
- this.aa = 5, this.rr = new Xr(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
14121
+ this.ha = 5, this.cr = new Xr(this.asyncQueue, "transaction_retry" /* TransactionRetry */);
14114
14122
  }
14115
14123
  /** Runs the transaction and sets the result on deferred. */ run() {
14116
- this.aa -= 1, this.ca();
14124
+ this.ha -= 1, this.la();
14117
14125
  }
14118
- ca() {
14119
- this.rr.Xi((async () => {
14120
- const t = new Ua(this.datastore), e = this.ua(t);
14126
+ la() {
14127
+ this.cr.Xi((async () => {
14128
+ const t = new Ua(this.datastore), e = this.fa(t);
14121
14129
  e && e.then((e => {
14122
14130
  this.asyncQueue.enqueueAndForget((() => t.commit().then((() => {
14123
14131
  this.deferred.resolve(e);
14124
14132
  })).catch((t => {
14125
- this.ha(t);
14133
+ this.da(t);
14126
14134
  }))));
14127
14135
  })).catch((t => {
14128
- this.ha(t);
14136
+ this.da(t);
14129
14137
  }));
14130
14138
  }));
14131
14139
  }
14132
- ua(t) {
14140
+ fa(t) {
14133
14141
  try {
14134
14142
  const e = this.updateFunction(t);
14135
14143
  return !At(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
@@ -14139,11 +14147,11 @@ class qa {
14139
14147
  return this.deferred.reject(t), null;
14140
14148
  }
14141
14149
  }
14142
- ha(t) {
14143
- this.aa > 0 && this.la(t) ? (this.aa -= 1, this.asyncQueue.enqueueAndForget((() => (this.ca(),
14150
+ da(t) {
14151
+ this.ha > 0 && this.wa(t) ? (this.ha -= 1, this.asyncQueue.enqueueAndForget((() => (this.la(),
14144
14152
  Promise.resolve())))) : this.deferred.reject(t);
14145
14153
  }
14146
- la(t) {
14154
+ wa(t) {
14147
14155
  if ("FirebaseError" === t.name) {
14148
14156
  // In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
14149
14157
  // non-matching document versions with ABORTED. These errors should be retried.
@@ -14257,10 +14265,10 @@ async function Qa(t, e) {
14257
14265
  // Tear down and re-create our network streams. This will ensure we get a
14258
14266
  // fresh auth token for the new user and re-fill the write pipeline with
14259
14267
  // new mutations from the LocalStore (since mutations are per-user).
14260
- n.Kr.add(3 /* CredentialChange */), await oo(n), s &&
14268
+ n.Wr.add(3 /* CredentialChange */), await oo(n), s &&
14261
14269
  // Don't set the network status to Unknown if we are offline.
14262
- n.Wr.set("Unknown" /* Unknown */), await n.remoteSyncer.handleCredentialChange(e),
14263
- n.Kr.delete(3 /* CredentialChange */), await ro(n);
14270
+ n.Hr.set("Unknown" /* Unknown */), await n.remoteSyncer.handleCredentialChange(e),
14271
+ n.Wr.delete(3 /* CredentialChange */), await ro(n);
14264
14272
  }(e.remoteStore, t))), t.onlineComponents = e;
14265
14273
  }
14266
14274
 
@@ -14301,7 +14309,7 @@ async function Xa(t) {
14301
14309
  const e = await za(t), n = await Ja(t);
14302
14310
  return e.setNetworkEnabled(!0), function(t) {
14303
14311
  const e = q(t);
14304
- return e.Kr.delete(0 /* UserDisabled */), ro(e);
14312
+ return e.Wr.delete(0 /* UserDisabled */), ro(e);
14305
14313
  }(n);
14306
14314
  }));
14307
14315
  }
@@ -14311,9 +14319,9 @@ async function Xa(t) {
14311
14319
  const e = await za(t), n = await Ja(t);
14312
14320
  return e.setNetworkEnabled(!1), async function(t) {
14313
14321
  const e = q(t);
14314
- e.Kr.add(0 /* UserDisabled */), await oo(e),
14322
+ e.Wr.add(0 /* UserDisabled */), await oo(e),
14315
14323
  // Set the OnlineState to Offline so get()s return from cache, etc.
14316
- e.Wr.set("Offline" /* Offline */);
14324
+ e.Hr.set("Offline" /* Offline */);
14317
14325
  }(n);
14318
14326
  }));
14319
14327
  }
@@ -14364,7 +14372,7 @@ function nc(t, e, n = {}) {
14364
14372
  error: t => i.reject(t)
14365
14373
  }), o = new Qo(we(n.path), r, {
14366
14374
  includeMetadataChanges: !0,
14367
- uo: !0
14375
+ fo: !0
14368
14376
  });
14369
14377
  return Bo(t, o);
14370
14378
  }(await Xa(t), t.asyncQueue, e, n, s))), s.promise;
@@ -14375,7 +14383,7 @@ function sc(t, e) {
14375
14383
  return t.asyncQueue.enqueueAndForget((async () => async function(t, e, n) {
14376
14384
  try {
14377
14385
  const s = await yr(t, e,
14378
- /* usePreviousResults= */ !0), i = new Xo(e, s.Gn), r = i.Io(s.documents), o = i.applyChanges(r,
14386
+ /* usePreviousResults= */ !0), i = new Xo(e, s.Gn), r = i.bo(s.documents), o = i.applyChanges(r,
14379
14387
  /* updateLimboDocuments= */ !1);
14380
14388
  n.resolve(o.snapshot);
14381
14389
  } catch (t) {
@@ -14401,7 +14409,7 @@ function ic(t, e, n = {}) {
14401
14409
  error: t => i.reject(t)
14402
14410
  }), o = new Qo(n, r, {
14403
14411
  includeMetadataChanges: !0,
14404
- uo: !0
14412
+ fo: !0
14405
14413
  });
14406
14414
  return Bo(t, o);
14407
14415
  }(await Xa(t), t.asyncQueue, e, n, s))), s.promise;
@@ -14410,13 +14418,13 @@ function ic(t, e, n = {}) {
14410
14418
  function rc(t, e) {
14411
14419
  const n = new La(e);
14412
14420
  return t.asyncQueue.enqueueAndForget((async () => function(t, e) {
14413
- q(t).Zr.add(e),
14421
+ q(t).so.add(e),
14414
14422
  // Immediately fire an initial event, indicating all existing listeners
14415
14423
  // are in-sync.
14416
14424
  e.next();
14417
14425
  }(await Xa(t), n))), () => {
14418
- n.Xo(), t.asyncQueue.enqueueAndForget((async () => function(t, e) {
14419
- q(t).Zr.delete(e);
14426
+ n.ea(), t.asyncQueue.enqueueAndForget((async () => function(t, e) {
14427
+ q(t).so.delete(e);
14420
14428
  }(await Xa(t), n)));
14421
14429
  };
14422
14430
  }
@@ -15021,39 +15029,39 @@ function vc(t, e, ...n) {
15021
15029
  */ class Dc {
15022
15030
  constructor() {
15023
15031
  // The last promise in the queue.
15024
- this.fa = Promise.resolve(),
15032
+ this._a = Promise.resolve(),
15025
15033
  // A list of retryable operations. Retryable operations are run in order and
15026
15034
  // retried with backoff.
15027
- this.da = [],
15035
+ this.ma = [],
15028
15036
  // Is this AsyncQueue being shut down? Once it is set to true, it will not
15029
15037
  // be changed again.
15030
- this.wa = !1,
15038
+ this.ga = !1,
15031
15039
  // Operations scheduled to be queued in the future. Operations are
15032
15040
  // automatically removed after they are run or canceled.
15033
- this._a = [],
15041
+ this.ya = [],
15034
15042
  // visible for testing
15035
- this.ma = null,
15043
+ this.pa = null,
15036
15044
  // Flag set while there's an outstanding AsyncQueue operation, used for
15037
15045
  // assertion sanity-checks.
15038
- this.ga = !1,
15046
+ this.Ta = !1,
15039
15047
  // Enabled during shutdown on Safari to prevent future access to IndexedDB.
15040
- this.ya = !1,
15048
+ this.Ea = !1,
15041
15049
  // List of TimerIds to fast-forward delays for.
15042
- this.pa = [],
15050
+ this.Ia = [],
15043
15051
  // Backoff timer used to schedule retries for retryable operations
15044
- this.rr = new Xr(this, "async_queue_retry" /* AsyncQueueRetry */),
15052
+ this.cr = new Xr(this, "async_queue_retry" /* AsyncQueueRetry */),
15045
15053
  // Visibility handler that triggers an immediate retry of all retryable
15046
15054
  // operations. Meant to speed up recovery when we regain file system access
15047
15055
  // after page comes into foreground.
15048
- this.Ta = () => {
15056
+ this.Aa = () => {
15049
15057
  const t = Jr();
15050
- t && $("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.rr.tr();
15058
+ t && $("AsyncQueue", "Visibility state changed to " + t.visibilityState), this.cr.tr();
15051
15059
  };
15052
15060
  const t = Jr();
15053
- t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Ta);
15061
+ t && "function" == typeof t.addEventListener && t.addEventListener("visibilitychange", this.Aa);
15054
15062
  }
15055
15063
  get isShuttingDown() {
15056
- return this.wa;
15064
+ return this.ga;
15057
15065
  }
15058
15066
  /**
15059
15067
  * Adds a new operation to the queue without waiting for it to complete (i.e.
@@ -15063,44 +15071,44 @@ function vc(t, e, ...n) {
15063
15071
  this.enqueue(t);
15064
15072
  }
15065
15073
  enqueueAndForgetEvenWhileRestricted(t) {
15066
- this.Ea(),
15074
+ this.Ra(),
15067
15075
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
15068
- this.Ia(t);
15076
+ this.ba(t);
15069
15077
  }
15070
15078
  enterRestrictedMode(t) {
15071
- if (!this.wa) {
15072
- this.wa = !0, this.ya = t || !1;
15079
+ if (!this.ga) {
15080
+ this.ga = !0, this.Ea = t || !1;
15073
15081
  const e = Jr();
15074
- e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Ta);
15082
+ e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Aa);
15075
15083
  }
15076
15084
  }
15077
15085
  enqueue(t) {
15078
- if (this.Ea(), this.wa)
15086
+ if (this.Ra(), this.ga)
15079
15087
  // Return a Promise which never resolves.
15080
15088
  return new Promise((() => {}));
15081
15089
  // Create a deferred Promise that we can return to the callee. This
15082
15090
  // allows us to return a "hanging Promise" only to the callee and still
15083
15091
  // advance the queue even when the operation is not run.
15084
15092
  const e = new Q;
15085
- return this.Ia((() => this.wa && this.ya ? Promise.resolve() : (t().then(e.resolve, e.reject),
15093
+ return this.ba((() => this.ga && this.Ea ? Promise.resolve() : (t().then(e.resolve, e.reject),
15086
15094
  e.promise))).then((() => e.promise));
15087
15095
  }
15088
15096
  enqueueRetryable(t) {
15089
- this.enqueueAndForget((() => (this.da.push(t), this.Aa())));
15097
+ this.enqueueAndForget((() => (this.ma.push(t), this.Pa())));
15090
15098
  }
15091
15099
  /**
15092
15100
  * Runs the next operation from the retryable queue. If the operation fails,
15093
15101
  * reschedules with backoff.
15094
- */ async Aa() {
15095
- if (0 !== this.da.length) {
15102
+ */ async Pa() {
15103
+ if (0 !== this.ma.length) {
15096
15104
  try {
15097
- await this.da[0](), this.da.shift(), this.rr.reset();
15105
+ await this.ma[0](), this.ma.shift(), this.cr.reset();
15098
15106
  } catch (t) {
15099
15107
  if (!Hs(t)) throw t;
15100
15108
  // Failure will be handled by AsyncQueue
15101
15109
  $("AsyncQueue", "Operation failed with retryable error: " + t);
15102
15110
  }
15103
- this.da.length > 0 &&
15111
+ this.ma.length > 0 &&
15104
15112
  // If there are additional operations, we re-schedule `retryNextOp()`.
15105
15113
  // This is necessary to run retryable operations that failed during
15106
15114
  // their initial attempt since we don't know whether they are already
@@ -15111,12 +15119,12 @@ function vc(t, e, ...n) {
15111
15119
  // Since `backoffAndRun()` cancels an existing backoff and schedules a
15112
15120
  // new backoff on every call, there is only ever a single additional
15113
15121
  // operation in the queue.
15114
- this.rr.Xi((() => this.Aa()));
15122
+ this.cr.Xi((() => this.Pa()));
15115
15123
  }
15116
15124
  }
15117
- Ia(t) {
15118
- const e = this.fa.then((() => (this.ga = !0, t().catch((t => {
15119
- this.ma = t, this.ga = !1;
15125
+ ba(t) {
15126
+ const e = this._a.then((() => (this.Ta = !0, t().catch((t => {
15127
+ this.pa = t, this.Ta = !1;
15120
15128
  const e =
15121
15129
  /**
15122
15130
  * Chrome includes Error.message in Error.stack. Other browsers do not.
@@ -15148,38 +15156,38 @@ function vc(t, e, ...n) {
15148
15156
  // all further attempts to chain (via .then) will just short-circuit
15149
15157
  // and return the rejected Promise.
15150
15158
  throw O("INTERNAL UNHANDLED ERROR: ", e), t;
15151
- })).then((t => (this.ga = !1, t))))));
15152
- return this.fa = e, e;
15159
+ })).then((t => (this.Ta = !1, t))))));
15160
+ return this._a = e, e;
15153
15161
  }
15154
15162
  enqueueAfterDelay(t, e, n) {
15155
- this.Ea(),
15163
+ this.Ra(),
15156
15164
  // Fast-forward delays for timerIds that have been overriden.
15157
- this.pa.indexOf(t) > -1 && (e = 0);
15158
- const s = xo.createAndSchedule(this, t, e, n, (t => this.Ra(t)));
15159
- return this._a.push(s), s;
15165
+ this.Ia.indexOf(t) > -1 && (e = 0);
15166
+ const s = xo.createAndSchedule(this, t, e, n, (t => this.va(t)));
15167
+ return this.ya.push(s), s;
15160
15168
  }
15161
- Ea() {
15162
- this.ma && L();
15169
+ Ra() {
15170
+ this.pa && L();
15163
15171
  }
15164
15172
  verifyOperationInProgress() {}
15165
15173
  /**
15166
15174
  * Waits until all currently queued tasks are finished executing. Delayed
15167
15175
  * operations are not run.
15168
- */ async ba() {
15176
+ */ async Va() {
15169
15177
  // Operations in the queue prior to draining may have enqueued additional
15170
15178
  // operations. Keep draining the queue until the tail is no longer advanced,
15171
15179
  // which indicates that no more new operations were enqueued and that all
15172
15180
  // operations were executed.
15173
15181
  let t;
15174
15182
  do {
15175
- t = this.fa, await t;
15176
- } while (t !== this.fa);
15183
+ t = this._a, await t;
15184
+ } while (t !== this._a);
15177
15185
  }
15178
15186
  /**
15179
15187
  * For Tests: Determine if a delayed operation with a particular TimerId
15180
15188
  * exists.
15181
- */ Pa(t) {
15182
- for (const e of this._a) if (e.timerId === t) return !0;
15189
+ */ Sa(t) {
15190
+ for (const e of this.ya) if (e.timerId === t) return !0;
15183
15191
  return !1;
15184
15192
  }
15185
15193
  /**
@@ -15188,24 +15196,24 @@ function vc(t, e, ...n) {
15188
15196
  * @param lastTimerId - Delayed operations up to and including this TimerId
15189
15197
  * will be drained. Pass TimerId.All to run all delayed operations.
15190
15198
  * @returns a Promise that resolves once all operations have been run.
15191
- */ va(t) {
15199
+ */ Da(t) {
15192
15200
  // Note that draining may generate more delayed ops, so we do that first.
15193
- return this.ba().then((() => {
15201
+ return this.Va().then((() => {
15194
15202
  // Run ops in the same order they'd run if they ran naturally.
15195
- this._a.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
15196
- for (const e of this._a) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
15197
- return this.ba();
15203
+ this.ya.sort(((t, e) => t.targetTimeMs - e.targetTimeMs));
15204
+ for (const e of this.ya) if (e.skipDelay(), "all" /* All */ !== t && e.timerId === t) break;
15205
+ return this.Va();
15198
15206
  }));
15199
15207
  }
15200
15208
  /**
15201
15209
  * For Tests: Skip all subsequent delays for a timer id.
15202
- */ Va(t) {
15203
- this.pa.push(t);
15210
+ */ Ca(t) {
15211
+ this.Ia.push(t);
15204
15212
  }
15205
- /** Called once a DelayedOperation is run or canceled. */ Ra(t) {
15213
+ /** Called once a DelayedOperation is run or canceled. */ va(t) {
15206
15214
  // NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
15207
- const e = this._a.indexOf(t);
15208
- this._a.splice(e, 1);
15215
+ const e = this.ya.indexOf(t);
15216
+ this.ya.splice(e, 1);
15209
15217
  }
15210
15218
  }
15211
15219
 
@@ -15945,55 +15953,55 @@ function iu(t) {
15945
15953
  this.settings = t, this.databaseId = e, this.N = n, this.ignoreUndefinedProperties = s,
15946
15954
  // Minor hack: If fieldTransforms is undefined, we assume this is an
15947
15955
  // external call and we need to validate the entire path.
15948
- void 0 === i && this.Sa(), this.fieldTransforms = i || [], this.fieldMask = r || [];
15956
+ void 0 === i && this.Na(), this.fieldTransforms = i || [], this.fieldMask = r || [];
15949
15957
  }
15950
15958
  get path() {
15951
15959
  return this.settings.path;
15952
15960
  }
15953
- get Da() {
15954
- return this.settings.Da;
15961
+ get xa() {
15962
+ return this.settings.xa;
15955
15963
  }
15956
- /** Returns a new context with the specified settings overwritten. */ Ca(t) {
15964
+ /** Returns a new context with the specified settings overwritten. */ ka(t) {
15957
15965
  return new ru(Object.assign(Object.assign({}, this.settings), t), this.databaseId, this.N, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
15958
15966
  }
15959
- Na(t) {
15967
+ $a(t) {
15960
15968
  var e;
15961
- const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.Ca({
15969
+ const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.ka({
15962
15970
  path: n,
15963
- xa: !1
15971
+ Oa: !1
15964
15972
  });
15965
- return s.ka(t), s;
15973
+ return s.Fa(t), s;
15966
15974
  }
15967
- $a(t) {
15975
+ Ma(t) {
15968
15976
  var e;
15969
- const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.Ca({
15977
+ const n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), s = this.ka({
15970
15978
  path: n,
15971
- xa: !1
15979
+ Oa: !1
15972
15980
  });
15973
- return s.Sa(), s;
15981
+ return s.Na(), s;
15974
15982
  }
15975
- Oa(t) {
15983
+ La(t) {
15976
15984
  // TODO(b/34871131): We don't support array paths right now; so make path
15977
15985
  // undefined.
15978
- return this.Ca({
15986
+ return this.ka({
15979
15987
  path: void 0,
15980
- xa: !0
15988
+ Oa: !0
15981
15989
  });
15982
15990
  }
15983
- Fa(t) {
15984
- return bu(t, this.settings.methodName, this.settings.Ma || !1, this.path, this.settings.La);
15991
+ Ba(t) {
15992
+ return bu(t, this.settings.methodName, this.settings.Ua || !1, this.path, this.settings.qa);
15985
15993
  }
15986
15994
  /** Returns 'true' if 'fieldPath' was traversed when creating this context. */ contains(t) {
15987
15995
  return void 0 !== this.fieldMask.find((e => t.isPrefixOf(e))) || void 0 !== this.fieldTransforms.find((e => t.isPrefixOf(e.field)));
15988
15996
  }
15989
- Sa() {
15997
+ Na() {
15990
15998
  // TODO(b/34871131): Remove null check once we have proper paths for fields
15991
15999
  // within arrays.
15992
- if (this.path) for (let t = 0; t < this.path.length; t++) this.ka(this.path.get(t));
16000
+ if (this.path) for (let t = 0; t < this.path.length; t++) this.Fa(this.path.get(t));
15993
16001
  }
15994
- ka(t) {
15995
- if (0 === t.length) throw this.Fa("Document fields must not be empty");
15996
- if (iu(this.Da) && eu.test(t)) throw this.Fa('Document fields cannot begin and end with "__"');
16002
+ Fa(t) {
16003
+ if (0 === t.length) throw this.Ba("Document fields must not be empty");
16004
+ if (iu(this.xa) && eu.test(t)) throw this.Ba('Document fields cannot begin and end with "__"');
15997
16005
  }
15998
16006
  }
15999
16007
 
@@ -16004,14 +16012,14 @@ function iu(t) {
16004
16012
  constructor(t, e, n) {
16005
16013
  this.databaseId = t, this.ignoreUndefinedProperties = e, this.N = n || Yr(t);
16006
16014
  }
16007
- /** Creates a new top-level parse context. */ Ba(t, e, n, s = !1) {
16015
+ /** Creates a new top-level parse context. */ Ka(t, e, n, s = !1) {
16008
16016
  return new ru({
16009
- Da: t,
16017
+ xa: t,
16010
16018
  methodName: e,
16011
- La: n,
16019
+ qa: n,
16012
16020
  path: ft.emptyPath(),
16013
- xa: !1,
16014
- Ma: s
16021
+ Oa: !1,
16022
+ Ua: s
16015
16023
  }, this.databaseId, this.N, this.ignoreUndefinedProperties);
16016
16024
  }
16017
16025
  }
@@ -16022,7 +16030,7 @@ function au(t) {
16022
16030
  }
16023
16031
 
16024
16032
  /** Parse document data from a set() call. */ function cu(t, e, n, s, i, r = {}) {
16025
- const o = t.Ba(r.merge || r.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, i);
16033
+ const o = t.Ka(r.merge || r.mergeFields ? 2 /* MergeSet */ : 0 /* Set */ , e, n, i);
16026
16034
  Eu("Data must be an object, but it was:", o, s);
16027
16035
  const a = pu(s, o);
16028
16036
  let c, u;
@@ -16040,7 +16048,7 @@ function au(t) {
16040
16048
 
16041
16049
  class uu extends Zc {
16042
16050
  _toFieldTransform(t) {
16043
- if (2 /* MergeSet */ !== t.Da) throw 1 /* Update */ === t.Da ? t.Fa(`${this._methodName}() can only appear at the top level of your update data`) : t.Fa(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
16051
+ if (2 /* MergeSet */ !== t.xa) throw 1 /* Update */ === t.xa ? t.Ba(`${this._methodName}() can only appear at the top level of your update data`) : t.Ba(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);
16044
16052
  // No transform to add for a delete, but we need to add it to our
16045
16053
  // fieldMask so it gets deleted.
16046
16054
  return t.fieldMask.push(t.path), null;
@@ -16067,10 +16075,10 @@ class uu extends Zc {
16067
16075
  * @param arrayElement - Whether or not the FieldValue has an array.
16068
16076
  */ function hu(t, e, n) {
16069
16077
  return new ru({
16070
- Da: 3 /* Argument */ ,
16071
- La: e.settings.La,
16078
+ xa: 3 /* Argument */ ,
16079
+ qa: e.settings.qa,
16072
16080
  methodName: t._methodName,
16073
- xa: n
16081
+ Oa: n
16074
16082
  }, e.databaseId, e.N, e.ignoreUndefinedProperties);
16075
16083
  }
16076
16084
 
@@ -16085,11 +16093,11 @@ class lu extends Zc {
16085
16093
 
16086
16094
  class fu extends Zc {
16087
16095
  constructor(t, e) {
16088
- super(t), this.Ua = e;
16096
+ super(t), this.ja = e;
16089
16097
  }
16090
16098
  _toFieldTransform(t) {
16091
16099
  const e = hu(this, t,
16092
- /*array=*/ !0), n = this.Ua.map((t => yu(t, e))), s = new Fe(n);
16100
+ /*array=*/ !0), n = this.ja.map((t => yu(t, e))), s = new Fe(n);
16093
16101
  return new je(t.path, s);
16094
16102
  }
16095
16103
  isEqual(t) {
@@ -16100,11 +16108,11 @@ class fu extends Zc {
16100
16108
 
16101
16109
  class du extends Zc {
16102
16110
  constructor(t, e) {
16103
- super(t), this.Ua = e;
16111
+ super(t), this.ja = e;
16104
16112
  }
16105
16113
  _toFieldTransform(t) {
16106
16114
  const e = hu(this, t,
16107
- /*array=*/ !0), n = this.Ua.map((t => yu(t, e))), s = new Le(n);
16115
+ /*array=*/ !0), n = this.ja.map((t => yu(t, e))), s = new Le(n);
16108
16116
  return new je(t.path, s);
16109
16117
  }
16110
16118
  isEqual(t) {
@@ -16115,10 +16123,10 @@ class du extends Zc {
16115
16123
 
16116
16124
  class wu extends Zc {
16117
16125
  constructor(t, e) {
16118
- super(t), this.qa = e;
16126
+ super(t), this.Qa = e;
16119
16127
  }
16120
16128
  _toFieldTransform(t) {
16121
- const e = new Ue(t.N, Ce(t.N, this.qa));
16129
+ const e = new Ue(t.N, Ce(t.N, this.Qa));
16122
16130
  return new je(t.path, e);
16123
16131
  }
16124
16132
  isEqual(t) {
@@ -16128,7 +16136,7 @@ class wu extends Zc {
16128
16136
  }
16129
16137
 
16130
16138
  /** Parse update data from an update() call. */ function _u(t, e, n, s) {
16131
- const i = t.Ba(1 /* Update */ , e, n);
16139
+ const i = t.Ka(1 /* Update */ , e, n);
16132
16140
  Eu("Data must be an object, but it was:", i, s);
16133
16141
  const r = [], o = Ut.empty();
16134
16142
  at(s, ((t, s) => {
@@ -16136,7 +16144,7 @@ class wu extends Zc {
16136
16144
  // For Compat types, we have to "extract" the underlying types before
16137
16145
  // performing validation.
16138
16146
  s = getModularInstance(s);
16139
- const c = i.$a(a);
16147
+ const c = i.Ma(a);
16140
16148
  if (s instanceof uu)
16141
16149
  // Add it to the field mask, but don't add anything to updateData.
16142
16150
  r.push(a); else {
@@ -16149,7 +16157,7 @@ class wu extends Zc {
16149
16157
  }
16150
16158
 
16151
16159
  /** Parse update data from a list of field/value arguments. */ function mu(t, e, n, s, i, r) {
16152
- const o = t.Ba(1 /* Update */ , e, n), a = [ Iu(e, s, n) ], c = [ i ];
16160
+ const o = t.Ka(1 /* Update */ , e, n), a = [ Iu(e, s, n) ], c = [ i ];
16153
16161
  if (r.length % 2 != 0) throw new j(K.INVALID_ARGUMENT, `Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);
16154
16162
  for (let t = 0; t < r.length; t += 2) a.push(Iu(e, r[t])), c.push(r[t + 1]);
16155
16163
  const u = [], h = Ut.empty();
@@ -16161,7 +16169,7 @@ class wu extends Zc {
16161
16169
  // For Compat types, we have to "extract" the underlying types before
16162
16170
  // performing validation.
16163
16171
  n = getModularInstance(n);
16164
- const s = o.$a(e);
16172
+ const s = o.Ma(e);
16165
16173
  if (n instanceof uu)
16166
16174
  // Add it to the field mask, but don't add anything to updateData.
16167
16175
  u.push(e); else {
@@ -16180,7 +16188,7 @@ class wu extends Zc {
16180
16188
  * @param allowArrays - Whether the query value is an array that may directly
16181
16189
  * contain additional arrays (e.g. the operand of an `in` query).
16182
16190
  */ function gu(t, e, n, s = !1) {
16183
- return yu(n, t.Ba(s ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
16191
+ return yu(n, t.Ka(s ? 4 /* ArrayArgument */ : 3 /* Argument */ , e));
16184
16192
  }
16185
16193
 
16186
16194
  /**
@@ -16208,8 +16216,8 @@ class wu extends Zc {
16208
16216
  */
16209
16217
  return function(t, e) {
16210
16218
  // Sentinels are only supported with writes, and not within arrays.
16211
- if (!iu(e.Da)) throw e.Fa(`${t._methodName}() can only be used with update() and set()`);
16212
- if (!e.path) throw e.Fa(`${t._methodName}() is not currently supported inside arrays`);
16219
+ if (!iu(e.xa)) throw e.Ba(`${t._methodName}() can only be used with update() and set()`);
16220
+ if (!e.path) throw e.Ba(`${t._methodName}() is not currently supported inside arrays`);
16213
16221
  const n = t._toFieldTransform(e);
16214
16222
  n && e.fieldTransforms.push(n);
16215
16223
  }
@@ -16233,12 +16241,12 @@ class wu extends Zc {
16233
16241
  // the set of values to be included for the IN query) that may directly
16234
16242
  // contain additional arrays (each representing an individual field
16235
16243
  // value), so we disable this validation.
16236
- if (e.settings.xa && 4 /* ArrayArgument */ !== e.Da) throw e.Fa("Nested arrays are not supported");
16244
+ if (e.settings.Oa && 4 /* ArrayArgument */ !== e.xa) throw e.Ba("Nested arrays are not supported");
16237
16245
  return function(t, e) {
16238
16246
  const n = [];
16239
16247
  let s = 0;
16240
16248
  for (const i of t) {
16241
- let t = yu(i, e.Oa(s));
16249
+ let t = yu(i, e.La(s));
16242
16250
  null == t && (
16243
16251
  // Just include nulls in the array for fields being replaced with a
16244
16252
  // sentinel.
@@ -16290,12 +16298,12 @@ class wu extends Zc {
16290
16298
  };
16291
16299
  if (t instanceof Ic) {
16292
16300
  const n = e.databaseId, s = t.firestore._databaseId;
16293
- if (!s.isEqual(n)) throw e.Fa(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${n.projectId}/${n.database}`);
16301
+ if (!s.isEqual(n)) throw e.Ba(`Document reference is for database ${s.projectId}/${s.database} but should be for database ${n.projectId}/${n.database}`);
16294
16302
  return {
16295
16303
  referenceValue: Qn(t.firestore._databaseId || e.databaseId, t._key.path)
16296
16304
  };
16297
16305
  }
16298
- throw e.Fa(`Unsupported field value: ${mc(t)}`);
16306
+ throw e.Ba(`Unsupported field value: ${mc(t)}`);
16299
16307
  }
16300
16308
  /**
16301
16309
  * Checks whether an object looks like a JSON object that should be converted
@@ -16312,7 +16320,7 @@ function pu(t, e) {
16312
16320
  // If we encounter an empty object, we explicitly add it to the update
16313
16321
  // mask to ensure that the server creates a map entry.
16314
16322
  e.path && e.path.length > 0 && e.fieldMask.push(e.path) : at(t, ((t, s) => {
16315
- const i = yu(s, e.Na(t));
16323
+ const i = yu(s, e.$a(t));
16316
16324
  null != i && (n[t] = i);
16317
16325
  })), {
16318
16326
  mapValue: {
@@ -16330,7 +16338,7 @@ function Eu(t, e, n) {
16330
16338
  return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
16331
16339
  }(n)) {
16332
16340
  const s = mc(n);
16333
- throw "an object" === s ? e.Fa(t + " a custom object") : e.Fa(t + " " + s);
16341
+ throw "an object" === s ? e.Ba(t + " a custom object") : e.Ba(t + " " + s);
16334
16342
  }
16335
16343
  }
16336
16344
 
@@ -16779,7 +16787,7 @@ function ku(t) {
16779
16787
 
16780
16788
  class Lu extends Fu {
16781
16789
  constructor(t, e, n) {
16782
- super(), this.Ka = t, this.ja = e, this.Qa = n, this.type = "where";
16790
+ super(), this.Wa = t, this.Ga = e, this.za = n, this.type = "where";
16783
16791
  }
16784
16792
  _apply(t) {
16785
16793
  const e = au(t.firestore), n = function(t, e, n, s, i, r, o) {
@@ -16848,7 +16856,7 @@ class Lu extends Fu {
16848
16856
  // Special case when it's a duplicate op to give a slightly clearer error message.
16849
16857
  throw n === e.op ? new j(K.INVALID_ARGUMENT, `Invalid query. You cannot use more than one '${e.op.toString()}' filter.`) : new j(K.INVALID_ARGUMENT, `Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`);
16850
16858
  }(t, c), c;
16851
- }(t._query, "where", e, t.firestore._databaseId, this.Ka, this.ja, this.Qa);
16859
+ }(t._query, "where", e, t.firestore._databaseId, this.Wa, this.Ga, this.za);
16852
16860
  return new Ac(t.firestore, t.converter, function(t, e) {
16853
16861
  const n = t.filters.concat([ e ]);
16854
16862
  return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
@@ -16873,7 +16881,7 @@ class Lu extends Fu {
16873
16881
 
16874
16882
  class Uu extends Fu {
16875
16883
  constructor(t, e) {
16876
- super(), this.Ka = t, this.Wa = e, this.type = "orderBy";
16884
+ super(), this.Wa = t, this.Ha = e, this.type = "orderBy";
16877
16885
  }
16878
16886
  _apply(t) {
16879
16887
  const e = function(t, e, n) {
@@ -16898,7 +16906,7 @@ class Uu extends Fu {
16898
16906
  * Will throw if the document does not contain all fields of the order by
16899
16907
  * of the query or if any of the fields in the order by are an uncommitted
16900
16908
  * server timestamp.
16901
- */ (t._query, this.Ka, this.Wa);
16909
+ */ (t._query, this.Wa, this.Ha);
16902
16910
  return new Ac(t.firestore, t.converter, function(t, e) {
16903
16911
  // TODO(dimond): validate that orderBy does not list the same key twice.
16904
16912
  const n = t.explicitOrderBy.concat([ e ]);
@@ -16922,10 +16930,10 @@ class Uu extends Fu {
16922
16930
 
16923
16931
  class Ku extends Fu {
16924
16932
  constructor(t, e, n) {
16925
- super(), this.type = t, this.Ga = e, this.za = n;
16933
+ super(), this.type = t, this.Ja = e, this.Ya = n;
16926
16934
  }
16927
16935
  _apply(t) {
16928
- return new Ac(t.firestore, t.converter, Ie(t._query, this.Ga, this.za));
16936
+ return new Ac(t.firestore, t.converter, Ie(t._query, this.Ja, this.Ya));
16929
16937
  }
16930
16938
  }
16931
16939
 
@@ -16952,10 +16960,10 @@ class Ku extends Fu {
16952
16960
 
16953
16961
  class Wu extends Fu {
16954
16962
  constructor(t, e, n) {
16955
- super(), this.type = t, this.Ha = e, this.Ja = n;
16963
+ super(), this.type = t, this.Xa = e, this.Za = n;
16956
16964
  }
16957
16965
  _apply(t) {
16958
- const e = Xu(t, this.type, this.Ha, this.Ja);
16966
+ const e = Xu(t, this.type, this.Xa, this.Za);
16959
16967
  return new Ac(t.firestore, t.converter, function(t, e) {
16960
16968
  return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
16961
16969
  }(t._query, e));
@@ -16973,10 +16981,10 @@ function zu(...t) {
16973
16981
 
16974
16982
  class Hu extends Fu {
16975
16983
  constructor(t, e, n) {
16976
- super(), this.type = t, this.Ha = e, this.Ja = n;
16984
+ super(), this.type = t, this.Xa = e, this.Za = n;
16977
16985
  }
16978
16986
  _apply(t) {
16979
- const e = Xu(t, this.type, this.Ha, this.Ja);
16987
+ const e = Xu(t, this.type, this.Xa, this.Za);
16980
16988
  return new Ac(t.firestore, t.converter, function(t, e) {
16981
16989
  return new fe(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
16982
16990
  }(t._query, e));
@@ -17511,7 +17519,7 @@ function yh(t, ...e) {
17511
17519
  return function(t, e, n, s) {
17512
17520
  const i = new La(s), r = new Qo(e, i, n);
17513
17521
  return t.asyncQueue.enqueueAndForget((async () => Bo(await Xa(t), r))), () => {
17514
- i.Xo(), t.asyncQueue.enqueueAndForget((async () => Uo(await Xa(t), r)));
17522
+ i.ea(), t.asyncQueue.enqueueAndForget((async () => Uo(await Xa(t), r)));
17515
17523
  };
17516
17524
  }(Fc(u), h, a, c);
17517
17525
  }
@@ -17640,7 +17648,7 @@ function ph(t, e) {
17640
17648
  * `updateFunction `is returned here. Otherwise, if the transaction failed, a
17641
17649
  * rejected promise with the corresponding failure error is returned.
17642
17650
  */ function Ah(t, e) {
17643
- return oc(Fc(t), (n => e(new Ih(t, n))));
17651
+ return oc(Fc(t = gc(t, kc)), (n => e(new Ih(t, n))));
17644
17652
  }
17645
17653
 
17646
17654
  /**
@@ -17762,18 +17770,18 @@ function ph(t, e) {
17762
17770
  * Cloud Firestore
17763
17771
  *
17764
17772
  * @packageDocumentation
17765
- */ var Dh;
17766
-
17767
- !function(t) {
17768
- C = t;
17769
- }(SDK_VERSION), _registerComponent(new Component("firestore", ((t, {options: e}) => {
17770
- const n = t.getProvider("app").getImmediate(), s = new kc(n, new H(t.getProvider("auth-internal")));
17771
- return e = Object.assign({
17772
- useFetchStreams: !0
17773
- }, e), s._setSettings(e), s;
17774
- }), "PUBLIC" /* PUBLIC */)), registerVersion(S, "3.1.1", Dh),
17775
- // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
17776
- registerVersion(S, "3.1.1", "esm2017");
17773
+ */ !function(t, e = !0) {
17774
+ !function(t) {
17775
+ C = t;
17776
+ }(SDK_VERSION), _registerComponent(new Component("firestore", ((t, {options: n}) => {
17777
+ const s = t.getProvider("app").getImmediate(), i = new kc(s, new H(t.getProvider("auth-internal")));
17778
+ return n = Object.assign({
17779
+ useFetchStreams: e
17780
+ }, n), i._setSettings(n), i;
17781
+ }), "PUBLIC" /* PUBLIC */)), registerVersion(S, "3.2.0-canary.477bdef13", t),
17782
+ // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
17783
+ registerVersion(S, "3.2.0-canary.477bdef13", "esm2017");
17784
+ }();
17777
17785
 
17778
17786
  export { nh as AbstractUserDataWriter, Xc as Bytes, xc as CACHE_SIZE_UNLIMITED, Rc as CollectionReference, Ic as DocumentReference, Cu as DocumentSnapshot, Jc as FieldPath, Zc as FieldValue, kc as Firestore, j as FirestoreError, tu as GeoPoint, Nc as LoadBundleTask, Ac as Query, Fu as QueryConstraint, Nu as QueryDocumentSnapshot, xu as QuerySnapshot, Du as SnapshotMetadata, it as Timestamp, Ih as Transaction, rh as WriteBatch, hc as _DatabaseId, Pt as _DocumentKey, G as _EmptyCredentialsProvider, ft as _FieldPath, gc as _cast, U as _debugAssert, wt as _isBase64Available, F as _logWarn, dc as _validateIsNotUsedTogether, gh as addDoc, vh as arrayRemove, Ph as arrayUnion, qc as clearIndexedDbPersistence, bc as collection, Pc as collectionGroup, Ec as connectFirestoreEmulator, mh as deleteDoc, Rh as deleteField, Qc as disableNetwork, vc as doc, Yc as documentId, Lc as enableIndexedDbPersistence, Bc as enableMultiTabIndexedDbPersistence, jc as enableNetwork, Yu as endAt, Ju as endBefore, Fc as ensureFirestoreConfigured, Th as executeWrite, ah as getDoc, uh as getDocFromCache, hh as getDocFromServer, lh as getDocs, fh as getDocsFromCache, dh as getDocsFromServer, Oc as getFirestore, Vh as increment, $c as initializeFirestore, ju as limit, Qu as limitToLast, Gc as loadBundle, zc as namedQuery, yh as onSnapshot, ph as onSnapshotsInSync, qu as orderBy, Mu as query, Sc as queryEqual, Vc as refEqual, Ah as runTransaction, bh as serverTimestamp, wh as setDoc, k as setLogLevel, $u as snapshotEqual, zu as startAfter, Gu as startAt, Wc as terminate, _h as updateDoc, Kc as waitForPendingWrites, Bu as where, Sh as writeBatch };
17779
17787
  //# sourceMappingURL=index.esm2017.js.map