@firebase/database-compat 2.0.2-canary.3aefcc3e1 → 2.0.2-canary.3c1559b7e

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.
@@ -11,9 +11,9 @@ var require$$2$1 = require('url');
11
11
  var require$$0$2 = require('assert');
12
12
  var require$$1$2 = require('net');
13
13
  var require$$2$2 = require('tls');
14
- var require$$1$3 = require('@firebase/util');
15
- var require$$2$3 = require('@firebase/logger');
16
- var require$$3 = require('@firebase/component');
14
+ var require$$2$3 = require('@firebase/util');
15
+ var require$$1$3 = require('@firebase/logger');
16
+ var require$$0$3 = require('@firebase/component');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
19
 
@@ -26,9 +26,24 @@ var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
26
26
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
27
27
  var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
28
28
  var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2);
29
- var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
30
29
  var require$$2__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$2$3);
31
- var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
30
+ var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
31
+ var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
32
+
33
+ function getAugmentedNamespace(n) {
34
+ if (n.__esModule) return n;
35
+ var a = Object.defineProperty({}, '__esModule', {value: true});
36
+ Object.keys(n).forEach(function (k) {
37
+ var d = Object.getOwnPropertyDescriptor(n, k);
38
+ Object.defineProperty(a, k, d.get ? d : {
39
+ enumerable: true,
40
+ get: function () {
41
+ return n[k];
42
+ }
43
+ });
44
+ });
45
+ return a;
46
+ }
32
47
 
33
48
  var index_standalone = {};
34
49
 
@@ -2217,7 +2232,7 @@ var Buffer$4 = safeBuffer.exports.Buffer,
2217
2232
 
2218
2233
  var PORTS = { 'ws:': 80, 'wss:': 443 };
2219
2234
 
2220
- var Proxy$1 = function(client, origin, options) {
2235
+ var Proxy$2 = function(client, origin, options) {
2221
2236
  this._client = client;
2222
2237
  this._http = new HttpParser$2('response');
2223
2238
  this._origin = (typeof client.url === 'object') ? client.url : url$2.parse(client.url);
@@ -2236,7 +2251,7 @@ var Proxy$1 = function(client, origin, options) {
2236
2251
  var auth = this._url.auth && Buffer$4.from(this._url.auth, 'utf8').toString('base64');
2237
2252
  if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);
2238
2253
  };
2239
- util$9.inherits(Proxy$1, Stream$2);
2254
+ util$9.inherits(Proxy$2, Stream$2);
2240
2255
 
2241
2256
  var instance$6 = {
2242
2257
  setHeader: function(name, value) {
@@ -2301,9 +2316,9 @@ var instance$6 = {
2301
2316
  };
2302
2317
 
2303
2318
  for (var key$6 in instance$6)
2304
- Proxy$1.prototype[key$6] = instance$6[key$6];
2319
+ Proxy$2.prototype[key$6] = instance$6[key$6];
2305
2320
 
2306
- var proxy = Proxy$1;
2321
+ var proxy = Proxy$2;
2307
2322
 
2308
2323
  var Buffer$3 = safeBuffer.exports.Buffer,
2309
2324
  crypto$1 = require$$1__default$1["default"],
@@ -2312,7 +2327,7 @@ var Buffer$3 = safeBuffer.exports.Buffer,
2312
2327
  HttpParser$1 = http_parser,
2313
2328
  Base$4 = base,
2314
2329
  Hybi$1 = hybi,
2315
- Proxy = proxy;
2330
+ Proxy$1 = proxy;
2316
2331
 
2317
2332
  var Client$2 = function(_url, options) {
2318
2333
  this.version = 'hybi-' + Hybi$1.VERSION;
@@ -2353,7 +2368,7 @@ var instance$5 = {
2353
2368
  VALID_PROTOCOLS: ['ws:', 'wss:'],
2354
2369
 
2355
2370
  proxy: function(origin, options) {
2356
- return new Proxy(this, origin, options);
2371
+ return new Proxy$1(this, origin, options);
2357
2372
  },
2358
2373
 
2359
2374
  start: function() {
@@ -3345,50 +3360,305 @@ WebSocket$1.EventSource = eventsource;
3345
3360
 
3346
3361
  var websocket = WebSocket$1;
3347
3362
 
3348
- Object.defineProperty(index_standalone, '__esModule', { value: true });
3363
+ var index_cjs = {};
3364
+
3365
+ const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
3366
+
3367
+ let idbProxyableTypes;
3368
+ let cursorAdvanceMethods;
3369
+ // This is a function to prevent it throwing up in node environments.
3370
+ function getIdbProxyableTypes() {
3371
+ return (idbProxyableTypes ||
3372
+ (idbProxyableTypes = [
3373
+ IDBDatabase,
3374
+ IDBObjectStore,
3375
+ IDBIndex,
3376
+ IDBCursor,
3377
+ IDBTransaction,
3378
+ ]));
3379
+ }
3380
+ // This is a function to prevent it throwing up in node environments.
3381
+ function getCursorAdvanceMethods() {
3382
+ return (cursorAdvanceMethods ||
3383
+ (cursorAdvanceMethods = [
3384
+ IDBCursor.prototype.advance,
3385
+ IDBCursor.prototype.continue,
3386
+ IDBCursor.prototype.continuePrimaryKey,
3387
+ ]));
3388
+ }
3389
+ const cursorRequestMap = new WeakMap();
3390
+ const transactionDoneMap = new WeakMap();
3391
+ const transactionStoreNamesMap = new WeakMap();
3392
+ const transformCache = new WeakMap();
3393
+ const reverseTransformCache = new WeakMap();
3394
+ function promisifyRequest(request) {
3395
+ const promise = new Promise((resolve, reject) => {
3396
+ const unlisten = () => {
3397
+ request.removeEventListener('success', success);
3398
+ request.removeEventListener('error', error);
3399
+ };
3400
+ const success = () => {
3401
+ resolve(wrap(request.result));
3402
+ unlisten();
3403
+ };
3404
+ const error = () => {
3405
+ reject(request.error);
3406
+ unlisten();
3407
+ };
3408
+ request.addEventListener('success', success);
3409
+ request.addEventListener('error', error);
3410
+ });
3411
+ promise
3412
+ .then((value) => {
3413
+ // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
3414
+ // (see wrapFunction).
3415
+ if (value instanceof IDBCursor) {
3416
+ cursorRequestMap.set(value, request);
3417
+ }
3418
+ // Catching to avoid "Uncaught Promise exceptions"
3419
+ })
3420
+ .catch(() => { });
3421
+ // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
3422
+ // is because we create many promises from a single IDBRequest.
3423
+ reverseTransformCache.set(promise, request);
3424
+ return promise;
3425
+ }
3426
+ function cacheDonePromiseForTransaction(tx) {
3427
+ // Early bail if we've already created a done promise for this transaction.
3428
+ if (transactionDoneMap.has(tx))
3429
+ return;
3430
+ const done = new Promise((resolve, reject) => {
3431
+ const unlisten = () => {
3432
+ tx.removeEventListener('complete', complete);
3433
+ tx.removeEventListener('error', error);
3434
+ tx.removeEventListener('abort', error);
3435
+ };
3436
+ const complete = () => {
3437
+ resolve();
3438
+ unlisten();
3439
+ };
3440
+ const error = () => {
3441
+ reject(tx.error || new DOMException('AbortError', 'AbortError'));
3442
+ unlisten();
3443
+ };
3444
+ tx.addEventListener('complete', complete);
3445
+ tx.addEventListener('error', error);
3446
+ tx.addEventListener('abort', error);
3447
+ });
3448
+ // Cache it for later retrieval.
3449
+ transactionDoneMap.set(tx, done);
3450
+ }
3451
+ let idbProxyTraps = {
3452
+ get(target, prop, receiver) {
3453
+ if (target instanceof IDBTransaction) {
3454
+ // Special handling for transaction.done.
3455
+ if (prop === 'done')
3456
+ return transactionDoneMap.get(target);
3457
+ // Polyfill for objectStoreNames because of Edge.
3458
+ if (prop === 'objectStoreNames') {
3459
+ return target.objectStoreNames || transactionStoreNamesMap.get(target);
3460
+ }
3461
+ // Make tx.store return the only store in the transaction, or undefined if there are many.
3462
+ if (prop === 'store') {
3463
+ return receiver.objectStoreNames[1]
3464
+ ? undefined
3465
+ : receiver.objectStore(receiver.objectStoreNames[0]);
3466
+ }
3467
+ }
3468
+ // Else transform whatever we get back.
3469
+ return wrap(target[prop]);
3470
+ },
3471
+ set(target, prop, value) {
3472
+ target[prop] = value;
3473
+ return true;
3474
+ },
3475
+ has(target, prop) {
3476
+ if (target instanceof IDBTransaction &&
3477
+ (prop === 'done' || prop === 'store')) {
3478
+ return true;
3479
+ }
3480
+ return prop in target;
3481
+ },
3482
+ };
3483
+ function replaceTraps(callback) {
3484
+ idbProxyTraps = callback(idbProxyTraps);
3485
+ }
3486
+ function wrapFunction(func) {
3487
+ // Due to expected object equality (which is enforced by the caching in `wrap`), we
3488
+ // only create one new func per func.
3489
+ // Edge doesn't support objectStoreNames (booo), so we polyfill it here.
3490
+ if (func === IDBDatabase.prototype.transaction &&
3491
+ !('objectStoreNames' in IDBTransaction.prototype)) {
3492
+ return function (storeNames, ...args) {
3493
+ const tx = func.call(unwrap(this), storeNames, ...args);
3494
+ transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
3495
+ return wrap(tx);
3496
+ };
3497
+ }
3498
+ // Cursor methods are special, as the behaviour is a little more different to standard IDB. In
3499
+ // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
3500
+ // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
3501
+ // with real promises, so each advance methods returns a new promise for the cursor object, or
3502
+ // undefined if the end of the cursor has been reached.
3503
+ if (getCursorAdvanceMethods().includes(func)) {
3504
+ return function (...args) {
3505
+ // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
3506
+ // the original object.
3507
+ func.apply(unwrap(this), args);
3508
+ return wrap(cursorRequestMap.get(this));
3509
+ };
3510
+ }
3511
+ return function (...args) {
3512
+ // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
3513
+ // the original object.
3514
+ return wrap(func.apply(unwrap(this), args));
3515
+ };
3516
+ }
3517
+ function transformCachableValue(value) {
3518
+ if (typeof value === 'function')
3519
+ return wrapFunction(value);
3520
+ // This doesn't return, it just creates a 'done' promise for the transaction,
3521
+ // which is later returned for transaction.done (see idbObjectHandler).
3522
+ if (value instanceof IDBTransaction)
3523
+ cacheDonePromiseForTransaction(value);
3524
+ if (instanceOfAny(value, getIdbProxyableTypes()))
3525
+ return new Proxy(value, idbProxyTraps);
3526
+ // Return the same value back if we're not going to transform it.
3527
+ return value;
3528
+ }
3529
+ function wrap(value) {
3530
+ // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
3531
+ // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
3532
+ if (value instanceof IDBRequest)
3533
+ return promisifyRequest(value);
3534
+ // If we've already transformed this value before, reuse the transformed value.
3535
+ // This is faster, but it also provides object equality.
3536
+ if (transformCache.has(value))
3537
+ return transformCache.get(value);
3538
+ const newValue = transformCachableValue(value);
3539
+ // Not all types are transformed.
3540
+ // These may be primitive types, so they can't be WeakMap keys.
3541
+ if (newValue !== value) {
3542
+ transformCache.set(value, newValue);
3543
+ reverseTransformCache.set(newValue, value);
3544
+ }
3545
+ return newValue;
3546
+ }
3547
+ const unwrap = (value) => reverseTransformCache.get(value);
3548
+
3549
+ /**
3550
+ * Open a database.
3551
+ *
3552
+ * @param name Name of the database.
3553
+ * @param version Schema version.
3554
+ * @param callbacks Additional callbacks.
3555
+ */
3556
+ function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
3557
+ const request = indexedDB.open(name, version);
3558
+ const openPromise = wrap(request);
3559
+ if (upgrade) {
3560
+ request.addEventListener('upgradeneeded', (event) => {
3561
+ upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
3562
+ });
3563
+ }
3564
+ if (blocked) {
3565
+ request.addEventListener('blocked', (event) => blocked(
3566
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
3567
+ event.oldVersion, event.newVersion, event));
3568
+ }
3569
+ openPromise
3570
+ .then((db) => {
3571
+ if (terminated)
3572
+ db.addEventListener('close', () => terminated());
3573
+ if (blocking) {
3574
+ db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
3575
+ }
3576
+ })
3577
+ .catch(() => { });
3578
+ return openPromise;
3579
+ }
3580
+ /**
3581
+ * Delete a database.
3582
+ *
3583
+ * @param name Name of the database.
3584
+ */
3585
+ function deleteDB(name, { blocked } = {}) {
3586
+ const request = indexedDB.deleteDatabase(name);
3587
+ if (blocked) {
3588
+ request.addEventListener('blocked', (event) => blocked(
3589
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
3590
+ event.oldVersion, event));
3591
+ }
3592
+ return wrap(request).then(() => undefined);
3593
+ }
3349
3594
 
3350
- var Websocket = websocket;
3351
- var util = require$$1__default$3["default"];
3352
- var logger$1 = require$$2__default$3["default"];
3353
- var component = require$$3__default["default"];
3595
+ const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
3596
+ const writeMethods = ['put', 'add', 'delete', 'clear'];
3597
+ const cachedMethods = new Map();
3598
+ function getMethod(target, prop) {
3599
+ if (!(target instanceof IDBDatabase &&
3600
+ !(prop in target) &&
3601
+ typeof prop === 'string')) {
3602
+ return;
3603
+ }
3604
+ if (cachedMethods.get(prop))
3605
+ return cachedMethods.get(prop);
3606
+ const targetFuncName = prop.replace(/FromIndex$/, '');
3607
+ const useIndex = prop !== targetFuncName;
3608
+ const isWrite = writeMethods.includes(targetFuncName);
3609
+ if (
3610
+ // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
3611
+ !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
3612
+ !(isWrite || readMethods.includes(targetFuncName))) {
3613
+ return;
3614
+ }
3615
+ const method = async function (storeName, ...args) {
3616
+ // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
3617
+ const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
3618
+ let target = tx.store;
3619
+ if (useIndex)
3620
+ target = target.index(args.shift());
3621
+ // Must reject if op rejects.
3622
+ // If it's a write operation, must reject if tx.done rejects.
3623
+ // Must reject with op rejection first.
3624
+ // Must resolve with op value.
3625
+ // Must handle both promises (no unhandled rejections)
3626
+ return (await Promise.all([
3627
+ target[targetFuncName](...args),
3628
+ isWrite && tx.done,
3629
+ ]))[0];
3630
+ };
3631
+ cachedMethods.set(prop, method);
3632
+ return method;
3633
+ }
3634
+ replaceTraps((oldTraps) => ({
3635
+ ...oldTraps,
3636
+ get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
3637
+ has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
3638
+ }));
3639
+
3640
+ var build = /*#__PURE__*/Object.freeze({
3641
+ __proto__: null,
3642
+ deleteDB: deleteDB,
3643
+ openDB: openDB,
3644
+ unwrap: unwrap,
3645
+ wrap: wrap
3646
+ });
3354
3647
 
3355
- function _interopDefaultLegacy$1 (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
3648
+ var require$$3 = /*@__PURE__*/getAugmentedNamespace(build);
3356
3649
 
3357
- var Websocket__default = /*#__PURE__*/_interopDefaultLegacy$1(Websocket);
3650
+ (function (exports) {
3358
3651
 
3359
- /**
3360
- * @license
3361
- * Copyright 2017 Google LLC
3362
- *
3363
- * Licensed under the Apache License, Version 2.0 (the "License");
3364
- * you may not use this file except in compliance with the License.
3365
- * You may obtain a copy of the License at
3366
- *
3367
- * http://www.apache.org/licenses/LICENSE-2.0
3368
- *
3369
- * Unless required by applicable law or agreed to in writing, software
3370
- * distributed under the License is distributed on an "AS IS" BASIS,
3371
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3372
- * See the License for the specific language governing permissions and
3373
- * limitations under the License.
3374
- */
3375
- const PROTOCOL_VERSION = '5';
3376
- const VERSION_PARAM = 'v';
3377
- const TRANSPORT_SESSION_PARAM = 's';
3378
- const REFERER_PARAM = 'r';
3379
- const FORGE_REF = 'f';
3380
- // Matches console.firebase.google.com, firebase-console-*.corp.google.com and
3381
- // firebase.corp.google.com
3382
- const FORGE_DOMAIN_RE = /(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/;
3383
- const LAST_SESSION_PARAM = 'ls';
3384
- const APPLICATION_ID_PARAM = 'p';
3385
- const APP_CHECK_TOKEN_PARAM = 'ac';
3386
- const WEBSOCKET = 'websocket';
3387
- const LONG_POLLING = 'long_polling';
3652
+ Object.defineProperty(exports, '__esModule', { value: true });
3653
+
3654
+ var component = require$$0__default$3["default"];
3655
+ var logger$1 = require$$1__default$3["default"];
3656
+ var util = require$$2__default$3["default"];
3657
+ var idb = require$$3;
3388
3658
 
3389
3659
  /**
3390
3660
  * @license
3391
- * Copyright 2017 Google LLC
3661
+ * Copyright 2019 Google LLC
3392
3662
  *
3393
3663
  * Licensed under the Apache License, Version 2.0 (the "License");
3394
3664
  * you may not use this file except in compliance with the License.
@@ -3402,62 +3672,49 @@ const LONG_POLLING = 'long_polling';
3402
3672
  * See the License for the specific language governing permissions and
3403
3673
  * limitations under the License.
3404
3674
  */
3675
+ class PlatformLoggerServiceImpl {
3676
+ constructor(container) {
3677
+ this.container = container;
3678
+ }
3679
+ // In initial implementation, this will be called by installations on
3680
+ // auth token refresh, and installations will send this string.
3681
+ getPlatformInfoString() {
3682
+ const providers = this.container.getProviders();
3683
+ // Loop through providers and get library/version pairs from any that are
3684
+ // version components.
3685
+ return providers
3686
+ .map(provider => {
3687
+ if (isVersionServiceProvider(provider)) {
3688
+ const service = provider.getImmediate();
3689
+ return `${service.library}/${service.version}`;
3690
+ }
3691
+ else {
3692
+ return null;
3693
+ }
3694
+ })
3695
+ .filter(logString => logString)
3696
+ .join(' ');
3697
+ }
3698
+ }
3405
3699
  /**
3406
- * Wraps a DOM Storage object and:
3407
- * - automatically encode objects as JSON strings before storing them to allow us to store arbitrary types.
3408
- * - prefixes names with "firebase:" to avoid collisions with app data.
3409
3700
  *
3410
- * We automatically (see storage.js) create two such wrappers, one for sessionStorage,
3411
- * and one for localStorage.
3701
+ * @param provider check if this provider provides a VersionService
3412
3702
  *
3703
+ * NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
3704
+ * provides VersionService. The provider is not necessarily a 'app-version'
3705
+ * provider.
3413
3706
  */
3414
- class DOMStorageWrapper {
3415
- /**
3416
- * @param domStorage_ - The underlying storage object (e.g. localStorage or sessionStorage)
3417
- */
3418
- constructor(domStorage_) {
3419
- this.domStorage_ = domStorage_;
3420
- // Use a prefix to avoid collisions with other stuff saved by the app.
3421
- this.prefix_ = 'firebase:';
3422
- }
3423
- /**
3424
- * @param key - The key to save the value under
3425
- * @param value - The value being stored, or null to remove the key.
3426
- */
3427
- set(key, value) {
3428
- if (value == null) {
3429
- this.domStorage_.removeItem(this.prefixedName_(key));
3430
- }
3431
- else {
3432
- this.domStorage_.setItem(this.prefixedName_(key), util.stringify(value));
3433
- }
3434
- }
3435
- /**
3436
- * @returns The value that was stored under this key, or null
3437
- */
3438
- get(key) {
3439
- const storedVal = this.domStorage_.getItem(this.prefixedName_(key));
3440
- if (storedVal == null) {
3441
- return null;
3442
- }
3443
- else {
3444
- return util.jsonEval(storedVal);
3445
- }
3446
- }
3447
- remove(key) {
3448
- this.domStorage_.removeItem(this.prefixedName_(key));
3449
- }
3450
- prefixedName_(name) {
3451
- return this.prefix_ + name;
3452
- }
3453
- toString() {
3454
- return this.domStorage_.toString();
3455
- }
3707
+ function isVersionServiceProvider(provider) {
3708
+ const component = provider.getComponent();
3709
+ return (component === null || component === void 0 ? void 0 : component.type) === "VERSION" /* ComponentType.VERSION */;
3456
3710
  }
3457
3711
 
3712
+ const name$q = "@firebase/app";
3713
+ const version$1 = "0.10.18-canary.3c1559b7e";
3714
+
3458
3715
  /**
3459
3716
  * @license
3460
- * Copyright 2017 Google LLC
3717
+ * Copyright 2019 Google LLC
3461
3718
  *
3462
3719
  * Licensed under the Apache License, Version 2.0 (the "License");
3463
3720
  * you may not use this file except in compliance with the License.
@@ -3471,37 +3728,64 @@ class DOMStorageWrapper {
3471
3728
  * See the License for the specific language governing permissions and
3472
3729
  * limitations under the License.
3473
3730
  */
3474
- /**
3475
- * An in-memory storage implementation that matches the API of DOMStorageWrapper
3476
- * (TODO: create interface for both to implement).
3477
- */
3478
- class MemoryStorage {
3479
- constructor() {
3480
- this.cache_ = {};
3481
- this.isInMemoryStorage = true;
3482
- }
3483
- set(key, value) {
3484
- if (value == null) {
3485
- delete this.cache_[key];
3486
- }
3487
- else {
3488
- this.cache_[key] = value;
3489
- }
3490
- }
3491
- get(key) {
3492
- if (util.contains(this.cache_, key)) {
3493
- return this.cache_[key];
3494
- }
3495
- return null;
3496
- }
3497
- remove(key) {
3498
- delete this.cache_[key];
3499
- }
3500
- }
3731
+ const logger = new logger$1.Logger('@firebase/app');
3732
+
3733
+ const name$p = "@firebase/app-compat";
3734
+
3735
+ const name$o = "@firebase/analytics-compat";
3736
+
3737
+ const name$n = "@firebase/analytics";
3738
+
3739
+ const name$m = "@firebase/app-check-compat";
3740
+
3741
+ const name$l = "@firebase/app-check";
3742
+
3743
+ const name$k = "@firebase/auth";
3744
+
3745
+ const name$j = "@firebase/auth-compat";
3746
+
3747
+ const name$i = "@firebase/database";
3748
+
3749
+ const name$h = "@firebase/data-connect";
3750
+
3751
+ const name$g = "@firebase/database-compat";
3752
+
3753
+ const name$f = "@firebase/functions";
3754
+
3755
+ const name$e = "@firebase/functions-compat";
3756
+
3757
+ const name$d = "@firebase/installations";
3758
+
3759
+ const name$c = "@firebase/installations-compat";
3760
+
3761
+ const name$b = "@firebase/messaging";
3762
+
3763
+ const name$a = "@firebase/messaging-compat";
3764
+
3765
+ const name$9 = "@firebase/performance";
3766
+
3767
+ const name$8 = "@firebase/performance-compat";
3768
+
3769
+ const name$7 = "@firebase/remote-config";
3770
+
3771
+ const name$6 = "@firebase/remote-config-compat";
3772
+
3773
+ const name$5 = "@firebase/storage";
3774
+
3775
+ const name$4 = "@firebase/storage-compat";
3776
+
3777
+ const name$3 = "@firebase/firestore";
3778
+
3779
+ const name$2 = "@firebase/vertexai";
3780
+
3781
+ const name$1 = "@firebase/firestore-compat";
3782
+
3783
+ const name = "firebase";
3784
+ const version = "11.2.0-canary.3c1559b7e";
3501
3785
 
3502
3786
  /**
3503
3787
  * @license
3504
- * Copyright 2017 Google LLC
3788
+ * Copyright 2019 Google LLC
3505
3789
  *
3506
3790
  * Licensed under the Apache License, Version 2.0 (the "License");
3507
3791
  * you may not use this file except in compliance with the License.
@@ -3516,40 +3800,45 @@ class MemoryStorage {
3516
3800
  * limitations under the License.
3517
3801
  */
3518
3802
  /**
3519
- * Helper to create a DOMStorageWrapper or else fall back to MemoryStorage.
3520
- * TODO: Once MemoryStorage and DOMStorageWrapper have a shared interface this method annotation should change
3521
- * to reflect this type
3803
+ * The default app name
3522
3804
  *
3523
- * @param domStorageName - Name of the underlying storage object
3524
- * (e.g. 'localStorage' or 'sessionStorage').
3525
- * @returns Turning off type information until a common interface is defined.
3805
+ * @internal
3526
3806
  */
3527
- const createStoragefor = function (domStorageName) {
3528
- try {
3529
- // NOTE: just accessing "localStorage" or "window['localStorage']" may throw a security exception,
3530
- // so it must be inside the try/catch.
3531
- if (typeof window !== 'undefined' &&
3532
- typeof window[domStorageName] !== 'undefined') {
3533
- // Need to test cache. Just because it's here doesn't mean it works
3534
- const domStorage = window[domStorageName];
3535
- domStorage.setItem('firebase:sentinel', 'cache');
3536
- domStorage.removeItem('firebase:sentinel');
3537
- return new DOMStorageWrapper(domStorage);
3538
- }
3539
- }
3540
- catch (e) { }
3541
- // Failed to create wrapper. Just return in-memory storage.
3542
- // TODO: log?
3543
- return new MemoryStorage();
3807
+ const DEFAULT_ENTRY_NAME = '[DEFAULT]';
3808
+ const PLATFORM_LOG_STRING = {
3809
+ [name$q]: 'fire-core',
3810
+ [name$p]: 'fire-core-compat',
3811
+ [name$n]: 'fire-analytics',
3812
+ [name$o]: 'fire-analytics-compat',
3813
+ [name$l]: 'fire-app-check',
3814
+ [name$m]: 'fire-app-check-compat',
3815
+ [name$k]: 'fire-auth',
3816
+ [name$j]: 'fire-auth-compat',
3817
+ [name$i]: 'fire-rtdb',
3818
+ [name$h]: 'fire-data-connect',
3819
+ [name$g]: 'fire-rtdb-compat',
3820
+ [name$f]: 'fire-fn',
3821
+ [name$e]: 'fire-fn-compat',
3822
+ [name$d]: 'fire-iid',
3823
+ [name$c]: 'fire-iid-compat',
3824
+ [name$b]: 'fire-fcm',
3825
+ [name$a]: 'fire-fcm-compat',
3826
+ [name$9]: 'fire-perf',
3827
+ [name$8]: 'fire-perf-compat',
3828
+ [name$7]: 'fire-rc',
3829
+ [name$6]: 'fire-rc-compat',
3830
+ [name$5]: 'fire-gcs',
3831
+ [name$4]: 'fire-gcs-compat',
3832
+ [name$3]: 'fire-fst',
3833
+ [name$1]: 'fire-fst-compat',
3834
+ [name$2]: 'fire-vertex',
3835
+ 'fire-js': 'fire-js', // Platform identifier for JS SDK.
3836
+ [name]: 'fire-js-all'
3544
3837
  };
3545
- /** A storage object that lasts across sessions */
3546
- const PersistentStorage = createStoragefor('localStorage');
3547
- /** A storage object that only lasts one session */
3548
- const SessionStorage = createStoragefor('sessionStorage');
3549
3838
 
3550
3839
  /**
3551
3840
  * @license
3552
- * Copyright 2017 Google LLC
3841
+ * Copyright 2019 Google LLC
3553
3842
  *
3554
3843
  * Licensed under the Apache License, Version 2.0 (the "License");
3555
3844
  * you may not use this file except in compliance with the License.
@@ -3563,45 +3852,1275 @@ const SessionStorage = createStoragefor('sessionStorage');
3563
3852
  * See the License for the specific language governing permissions and
3564
3853
  * limitations under the License.
3565
3854
  */
3566
- const logClient$1 = new logger$1.Logger('@firebase/database');
3567
3855
  /**
3568
- * Returns a locally-unique ID (generated by just incrementing up from 0 each time its called).
3856
+ * @internal
3569
3857
  */
3570
- const LUIDGenerator = (function () {
3571
- let id = 1;
3572
- return function () {
3573
- return id++;
3574
- };
3575
- })();
3858
+ const _apps = new Map();
3576
3859
  /**
3577
- * Sha1 hash of the input string
3578
- * @param str - The string to hash
3579
- * @returns {!string} The resulting hash
3860
+ * @internal
3580
3861
  */
3581
- const sha1 = function (str) {
3582
- const utf8Bytes = util.stringToByteArray(str);
3583
- const sha1 = new util.Sha1();
3584
- sha1.update(utf8Bytes);
3585
- const sha1Bytes = sha1.digest();
3586
- return util.base64.encodeByteArray(sha1Bytes);
3587
- };
3588
- const buildLogMessage_ = function (...varArgs) {
3589
- let message = '';
3590
- for (let i = 0; i < varArgs.length; i++) {
3591
- const arg = varArgs[i];
3592
- if (Array.isArray(arg) ||
3593
- (arg &&
3594
- typeof arg === 'object' &&
3595
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3596
- typeof arg.length === 'number')) {
3597
- message += buildLogMessage_.apply(null, arg);
3598
- }
3599
- else if (typeof arg === 'object') {
3600
- message += util.stringify(arg);
3601
- }
3602
- else {
3603
- message += arg;
3604
- }
3862
+ const _serverApps = new Map();
3863
+ /**
3864
+ * Registered components.
3865
+ *
3866
+ * @internal
3867
+ */
3868
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3869
+ const _components = new Map();
3870
+ /**
3871
+ * @param component - the component being added to this app's container
3872
+ *
3873
+ * @internal
3874
+ */
3875
+ function _addComponent(app, component) {
3876
+ try {
3877
+ app.container.addComponent(component);
3878
+ }
3879
+ catch (e) {
3880
+ logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
3881
+ }
3882
+ }
3883
+ /**
3884
+ *
3885
+ * @internal
3886
+ */
3887
+ function _addOrOverwriteComponent(app, component) {
3888
+ app.container.addOrOverwriteComponent(component);
3889
+ }
3890
+ /**
3891
+ *
3892
+ * @param component - the component to register
3893
+ * @returns whether or not the component is registered successfully
3894
+ *
3895
+ * @internal
3896
+ */
3897
+ function _registerComponent(component) {
3898
+ const componentName = component.name;
3899
+ if (_components.has(componentName)) {
3900
+ logger.debug(`There were multiple attempts to register component ${componentName}.`);
3901
+ return false;
3902
+ }
3903
+ _components.set(componentName, component);
3904
+ // add the component to existing app instances
3905
+ for (const app of _apps.values()) {
3906
+ _addComponent(app, component);
3907
+ }
3908
+ for (const serverApp of _serverApps.values()) {
3909
+ _addComponent(serverApp, component);
3910
+ }
3911
+ return true;
3912
+ }
3913
+ /**
3914
+ *
3915
+ * @param app - FirebaseApp instance
3916
+ * @param name - service name
3917
+ *
3918
+ * @returns the provider for the service with the matching name
3919
+ *
3920
+ * @internal
3921
+ */
3922
+ function _getProvider(app, name) {
3923
+ const heartbeatController = app.container
3924
+ .getProvider('heartbeat')
3925
+ .getImmediate({ optional: true });
3926
+ if (heartbeatController) {
3927
+ void heartbeatController.triggerHeartbeat();
3928
+ }
3929
+ return app.container.getProvider(name);
3930
+ }
3931
+ /**
3932
+ *
3933
+ * @param app - FirebaseApp instance
3934
+ * @param name - service name
3935
+ * @param instanceIdentifier - service instance identifier in case the service supports multiple instances
3936
+ *
3937
+ * @internal
3938
+ */
3939
+ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
3940
+ _getProvider(app, name).clearInstance(instanceIdentifier);
3941
+ }
3942
+ /**
3943
+ *
3944
+ * @param obj - an object of type FirebaseApp or FirebaseOptions.
3945
+ *
3946
+ * @returns true if the provide object is of type FirebaseApp.
3947
+ *
3948
+ * @internal
3949
+ */
3950
+ function _isFirebaseApp(obj) {
3951
+ return obj.options !== undefined;
3952
+ }
3953
+ /**
3954
+ *
3955
+ * @param obj - an object of type FirebaseApp.
3956
+ *
3957
+ * @returns true if the provided object is of type FirebaseServerAppImpl.
3958
+ *
3959
+ * @internal
3960
+ */
3961
+ function _isFirebaseServerApp(obj) {
3962
+ if (obj === null || obj === undefined) {
3963
+ return false;
3964
+ }
3965
+ return obj.settings !== undefined;
3966
+ }
3967
+ /**
3968
+ * Test only
3969
+ *
3970
+ * @internal
3971
+ */
3972
+ function _clearComponents() {
3973
+ _components.clear();
3974
+ }
3975
+
3976
+ /**
3977
+ * @license
3978
+ * Copyright 2019 Google LLC
3979
+ *
3980
+ * Licensed under the Apache License, Version 2.0 (the "License");
3981
+ * you may not use this file except in compliance with the License.
3982
+ * You may obtain a copy of the License at
3983
+ *
3984
+ * http://www.apache.org/licenses/LICENSE-2.0
3985
+ *
3986
+ * Unless required by applicable law or agreed to in writing, software
3987
+ * distributed under the License is distributed on an "AS IS" BASIS,
3988
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3989
+ * See the License for the specific language governing permissions and
3990
+ * limitations under the License.
3991
+ */
3992
+ const ERRORS = {
3993
+ ["no-app" /* AppError.NO_APP */]: "No Firebase App '{$appName}' has been created - " +
3994
+ 'call initializeApp() first',
3995
+ ["bad-app-name" /* AppError.BAD_APP_NAME */]: "Illegal App name: '{$appName}'",
3996
+ ["duplicate-app" /* AppError.DUPLICATE_APP */]: "Firebase App named '{$appName}' already exists with different options or config",
3997
+ ["app-deleted" /* AppError.APP_DELETED */]: "Firebase App named '{$appName}' already deleted",
3998
+ ["server-app-deleted" /* AppError.SERVER_APP_DELETED */]: 'Firebase Server App has been deleted',
3999
+ ["no-options" /* AppError.NO_OPTIONS */]: 'Need to provide options, when not being deployed to hosting via source.',
4000
+ ["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' +
4001
+ 'Firebase App instance.',
4002
+ ["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */]: 'First argument to `onLog` must be null or a function.',
4003
+ ["idb-open" /* AppError.IDB_OPEN */]: 'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
4004
+ ["idb-get" /* AppError.IDB_GET */]: 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
4005
+ ["idb-set" /* AppError.IDB_WRITE */]: 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
4006
+ ["idb-delete" /* AppError.IDB_DELETE */]: 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
4007
+ ["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */]: 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
4008
+ ["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */]: 'FirebaseServerApp is not for use in browser environments.'
4009
+ };
4010
+ const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
4011
+
4012
+ /**
4013
+ * @license
4014
+ * Copyright 2019 Google LLC
4015
+ *
4016
+ * Licensed under the Apache License, Version 2.0 (the "License");
4017
+ * you may not use this file except in compliance with the License.
4018
+ * You may obtain a copy of the License at
4019
+ *
4020
+ * http://www.apache.org/licenses/LICENSE-2.0
4021
+ *
4022
+ * Unless required by applicable law or agreed to in writing, software
4023
+ * distributed under the License is distributed on an "AS IS" BASIS,
4024
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4025
+ * See the License for the specific language governing permissions and
4026
+ * limitations under the License.
4027
+ */
4028
+ class FirebaseAppImpl {
4029
+ constructor(options, config, container) {
4030
+ this._isDeleted = false;
4031
+ this._options = Object.assign({}, options);
4032
+ this._config = Object.assign({}, config);
4033
+ this._name = config.name;
4034
+ this._automaticDataCollectionEnabled =
4035
+ config.automaticDataCollectionEnabled;
4036
+ this._container = container;
4037
+ this.container.addComponent(new component.Component('app', () => this, "PUBLIC" /* ComponentType.PUBLIC */));
4038
+ }
4039
+ get automaticDataCollectionEnabled() {
4040
+ this.checkDestroyed();
4041
+ return this._automaticDataCollectionEnabled;
4042
+ }
4043
+ set automaticDataCollectionEnabled(val) {
4044
+ this.checkDestroyed();
4045
+ this._automaticDataCollectionEnabled = val;
4046
+ }
4047
+ get name() {
4048
+ this.checkDestroyed();
4049
+ return this._name;
4050
+ }
4051
+ get options() {
4052
+ this.checkDestroyed();
4053
+ return this._options;
4054
+ }
4055
+ get config() {
4056
+ this.checkDestroyed();
4057
+ return this._config;
4058
+ }
4059
+ get container() {
4060
+ return this._container;
4061
+ }
4062
+ get isDeleted() {
4063
+ return this._isDeleted;
4064
+ }
4065
+ set isDeleted(val) {
4066
+ this._isDeleted = val;
4067
+ }
4068
+ /**
4069
+ * This function will throw an Error if the App has already been deleted -
4070
+ * use before performing API actions on the App.
4071
+ */
4072
+ checkDestroyed() {
4073
+ if (this.isDeleted) {
4074
+ throw ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */, { appName: this._name });
4075
+ }
4076
+ }
4077
+ }
4078
+
4079
+ /**
4080
+ * @license
4081
+ * Copyright 2023 Google LLC
4082
+ *
4083
+ * Licensed under the Apache License, Version 2.0 (the "License");
4084
+ * you may not use this file except in compliance with the License.
4085
+ * You may obtain a copy of the License at
4086
+ *
4087
+ * http://www.apache.org/licenses/LICENSE-2.0
4088
+ *
4089
+ * Unless required by applicable law or agreed to in writing, software
4090
+ * distributed under the License is distributed on an "AS IS" BASIS,
4091
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4092
+ * See the License for the specific language governing permissions and
4093
+ * limitations under the License.
4094
+ */
4095
+ // Parse the token and check to see if the `exp` claim is in the future.
4096
+ // Reports an error to the console if the token or claim could not be parsed, or if `exp` is in
4097
+ // the past.
4098
+ function validateTokenTTL(base64Token, tokenName) {
4099
+ const secondPart = util.base64Decode(base64Token.split('.')[1]);
4100
+ if (secondPart === null) {
4101
+ console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`);
4102
+ return;
4103
+ }
4104
+ const expClaim = JSON.parse(secondPart).exp;
4105
+ if (expClaim === undefined) {
4106
+ console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`);
4107
+ return;
4108
+ }
4109
+ const exp = JSON.parse(secondPart).exp * 1000;
4110
+ const now = new Date().getTime();
4111
+ const diff = exp - now;
4112
+ if (diff <= 0) {
4113
+ console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`);
4114
+ }
4115
+ }
4116
+ class FirebaseServerAppImpl extends FirebaseAppImpl {
4117
+ constructor(options, serverConfig, name, container) {
4118
+ // Build configuration parameters for the FirebaseAppImpl base class.
4119
+ const automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
4120
+ ? serverConfig.automaticDataCollectionEnabled
4121
+ : false;
4122
+ // Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
4123
+ const config = {
4124
+ name,
4125
+ automaticDataCollectionEnabled
4126
+ };
4127
+ if (options.apiKey !== undefined) {
4128
+ // Construct the parent FirebaseAppImp object.
4129
+ super(options, config, container);
4130
+ }
4131
+ else {
4132
+ const appImpl = options;
4133
+ super(appImpl.options, config, container);
4134
+ }
4135
+ // Now construct the data for the FirebaseServerAppImpl.
4136
+ this._serverConfig = Object.assign({ automaticDataCollectionEnabled }, serverConfig);
4137
+ // Ensure that the current time is within the `authIdtoken` window of validity.
4138
+ if (this._serverConfig.authIdToken) {
4139
+ validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
4140
+ }
4141
+ // Ensure that the current time is within the `appCheckToken` window of validity.
4142
+ if (this._serverConfig.appCheckToken) {
4143
+ validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken');
4144
+ }
4145
+ this._finalizationRegistry = null;
4146
+ if (typeof FinalizationRegistry !== 'undefined') {
4147
+ this._finalizationRegistry = new FinalizationRegistry(() => {
4148
+ this.automaticCleanup();
4149
+ });
4150
+ }
4151
+ this._refCount = 0;
4152
+ this.incRefCount(this._serverConfig.releaseOnDeref);
4153
+ // Do not retain a hard reference to the dref object, otherwise the FinalizationRegistry
4154
+ // will never trigger.
4155
+ this._serverConfig.releaseOnDeref = undefined;
4156
+ serverConfig.releaseOnDeref = undefined;
4157
+ registerVersion(name$q, version$1, 'serverapp');
4158
+ }
4159
+ toJSON() {
4160
+ return undefined;
4161
+ }
4162
+ get refCount() {
4163
+ return this._refCount;
4164
+ }
4165
+ // Increment the reference count of this server app. If an object is provided, register it
4166
+ // with the finalization registry.
4167
+ incRefCount(obj) {
4168
+ if (this.isDeleted) {
4169
+ return;
4170
+ }
4171
+ this._refCount++;
4172
+ if (obj !== undefined && this._finalizationRegistry !== null) {
4173
+ this._finalizationRegistry.register(obj, this);
4174
+ }
4175
+ }
4176
+ // Decrement the reference count.
4177
+ decRefCount() {
4178
+ if (this.isDeleted) {
4179
+ return 0;
4180
+ }
4181
+ return --this._refCount;
4182
+ }
4183
+ // Invoked by the FinalizationRegistry callback to note that this app should go through its
4184
+ // reference counts and delete itself if no reference count remain. The coordinating logic that
4185
+ // handles this is in deleteApp(...).
4186
+ automaticCleanup() {
4187
+ void deleteApp(this);
4188
+ }
4189
+ get settings() {
4190
+ this.checkDestroyed();
4191
+ return this._serverConfig;
4192
+ }
4193
+ /**
4194
+ * This function will throw an Error if the App has already been deleted -
4195
+ * use before performing API actions on the App.
4196
+ */
4197
+ checkDestroyed() {
4198
+ if (this.isDeleted) {
4199
+ throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
4200
+ }
4201
+ }
4202
+ }
4203
+
4204
+ /**
4205
+ * @license
4206
+ * Copyright 2019 Google LLC
4207
+ *
4208
+ * Licensed under the Apache License, Version 2.0 (the "License");
4209
+ * you may not use this file except in compliance with the License.
4210
+ * You may obtain a copy of the License at
4211
+ *
4212
+ * http://www.apache.org/licenses/LICENSE-2.0
4213
+ *
4214
+ * Unless required by applicable law or agreed to in writing, software
4215
+ * distributed under the License is distributed on an "AS IS" BASIS,
4216
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4217
+ * See the License for the specific language governing permissions and
4218
+ * limitations under the License.
4219
+ */
4220
+ /**
4221
+ * The current SDK version.
4222
+ *
4223
+ * @public
4224
+ */
4225
+ const SDK_VERSION = version;
4226
+ function initializeApp(_options, rawConfig = {}) {
4227
+ let options = _options;
4228
+ if (typeof rawConfig !== 'object') {
4229
+ const name = rawConfig;
4230
+ rawConfig = { name };
4231
+ }
4232
+ const config = Object.assign({ name: DEFAULT_ENTRY_NAME, automaticDataCollectionEnabled: false }, rawConfig);
4233
+ const name = config.name;
4234
+ if (typeof name !== 'string' || !name) {
4235
+ throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
4236
+ appName: String(name)
4237
+ });
4238
+ }
4239
+ options || (options = util.getDefaultAppConfig());
4240
+ if (!options) {
4241
+ throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
4242
+ }
4243
+ const existingApp = _apps.get(name);
4244
+ if (existingApp) {
4245
+ // return the existing app if options and config deep equal the ones in the existing app.
4246
+ if (util.deepEqual(options, existingApp.options) &&
4247
+ util.deepEqual(config, existingApp.config)) {
4248
+ return existingApp;
4249
+ }
4250
+ else {
4251
+ throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, { appName: name });
4252
+ }
4253
+ }
4254
+ const container = new component.ComponentContainer(name);
4255
+ for (const component of _components.values()) {
4256
+ container.addComponent(component);
4257
+ }
4258
+ const newApp = new FirebaseAppImpl(options, config, container);
4259
+ _apps.set(name, newApp);
4260
+ return newApp;
4261
+ }
4262
+ function initializeServerApp(_options, _serverAppConfig) {
4263
+ if (util.isBrowser() && !util.isWebWorker()) {
4264
+ // FirebaseServerApp isn't designed to be run in browsers.
4265
+ throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
4266
+ }
4267
+ if (_serverAppConfig.automaticDataCollectionEnabled === undefined) {
4268
+ _serverAppConfig.automaticDataCollectionEnabled = false;
4269
+ }
4270
+ let appOptions;
4271
+ if (_isFirebaseApp(_options)) {
4272
+ appOptions = _options.options;
4273
+ }
4274
+ else {
4275
+ appOptions = _options;
4276
+ }
4277
+ // Build an app name based on a hash of the configuration options.
4278
+ const nameObj = Object.assign(Object.assign({}, _serverAppConfig), appOptions);
4279
+ // However, Do not mangle the name based on releaseOnDeref, since it will vary between the
4280
+ // construction of FirebaseServerApp instances. For example, if the object is the request headers.
4281
+ if (nameObj.releaseOnDeref !== undefined) {
4282
+ delete nameObj.releaseOnDeref;
4283
+ }
4284
+ const hashCode = (s) => {
4285
+ return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
4286
+ };
4287
+ if (_serverAppConfig.releaseOnDeref !== undefined) {
4288
+ if (typeof FinalizationRegistry === 'undefined') {
4289
+ throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
4290
+ }
4291
+ }
4292
+ const nameString = '' + hashCode(JSON.stringify(nameObj));
4293
+ const existingApp = _serverApps.get(nameString);
4294
+ if (existingApp) {
4295
+ existingApp.incRefCount(_serverAppConfig.releaseOnDeref);
4296
+ return existingApp;
4297
+ }
4298
+ const container = new component.ComponentContainer(nameString);
4299
+ for (const component of _components.values()) {
4300
+ container.addComponent(component);
4301
+ }
4302
+ const newApp = new FirebaseServerAppImpl(appOptions, _serverAppConfig, nameString, container);
4303
+ _serverApps.set(nameString, newApp);
4304
+ return newApp;
4305
+ }
4306
+ /**
4307
+ * Retrieves a {@link @firebase/app#FirebaseApp} instance.
4308
+ *
4309
+ * When called with no arguments, the default app is returned. When an app name
4310
+ * is provided, the app corresponding to that name is returned.
4311
+ *
4312
+ * An exception is thrown if the app being retrieved has not yet been
4313
+ * initialized.
4314
+ *
4315
+ * @example
4316
+ * ```javascript
4317
+ * // Return the default app
4318
+ * const app = getApp();
4319
+ * ```
4320
+ *
4321
+ * @example
4322
+ * ```javascript
4323
+ * // Return a named app
4324
+ * const otherApp = getApp("otherApp");
4325
+ * ```
4326
+ *
4327
+ * @param name - Optional name of the app to return. If no name is
4328
+ * provided, the default is `"[DEFAULT]"`.
4329
+ *
4330
+ * @returns The app corresponding to the provided app name.
4331
+ * If no app name is provided, the default app is returned.
4332
+ *
4333
+ * @public
4334
+ */
4335
+ function getApp(name = DEFAULT_ENTRY_NAME) {
4336
+ const app = _apps.get(name);
4337
+ if (!app && name === DEFAULT_ENTRY_NAME && util.getDefaultAppConfig()) {
4338
+ return initializeApp();
4339
+ }
4340
+ if (!app) {
4341
+ throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
4342
+ }
4343
+ return app;
4344
+ }
4345
+ /**
4346
+ * A (read-only) array of all initialized apps.
4347
+ * @public
4348
+ */
4349
+ function getApps() {
4350
+ return Array.from(_apps.values());
4351
+ }
4352
+ /**
4353
+ * Renders this app unusable and frees the resources of all associated
4354
+ * services.
4355
+ *
4356
+ * @example
4357
+ * ```javascript
4358
+ * deleteApp(app)
4359
+ * .then(function() {
4360
+ * console.log("App deleted successfully");
4361
+ * })
4362
+ * .catch(function(error) {
4363
+ * console.log("Error deleting app:", error);
4364
+ * });
4365
+ * ```
4366
+ *
4367
+ * @public
4368
+ */
4369
+ async function deleteApp(app) {
4370
+ let cleanupProviders = false;
4371
+ const name = app.name;
4372
+ if (_apps.has(name)) {
4373
+ cleanupProviders = true;
4374
+ _apps.delete(name);
4375
+ }
4376
+ else if (_serverApps.has(name)) {
4377
+ const firebaseServerApp = app;
4378
+ if (firebaseServerApp.decRefCount() <= 0) {
4379
+ _serverApps.delete(name);
4380
+ cleanupProviders = true;
4381
+ }
4382
+ }
4383
+ if (cleanupProviders) {
4384
+ await Promise.all(app.container
4385
+ .getProviders()
4386
+ .map(provider => provider.delete()));
4387
+ app.isDeleted = true;
4388
+ }
4389
+ }
4390
+ /**
4391
+ * Registers a library's name and version for platform logging purposes.
4392
+ * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
4393
+ * @param version - Current version of that library.
4394
+ * @param variant - Bundle variant, e.g., node, rn, etc.
4395
+ *
4396
+ * @public
4397
+ */
4398
+ function registerVersion(libraryKeyOrName, version, variant) {
4399
+ var _a;
4400
+ // TODO: We can use this check to whitelist strings when/if we set up
4401
+ // a good whitelist system.
4402
+ let library = (_a = PLATFORM_LOG_STRING[libraryKeyOrName]) !== null && _a !== void 0 ? _a : libraryKeyOrName;
4403
+ if (variant) {
4404
+ library += `-${variant}`;
4405
+ }
4406
+ const libraryMismatch = library.match(/\s|\//);
4407
+ const versionMismatch = version.match(/\s|\//);
4408
+ if (libraryMismatch || versionMismatch) {
4409
+ const warning = [
4410
+ `Unable to register library "${library}" with version "${version}":`
4411
+ ];
4412
+ if (libraryMismatch) {
4413
+ warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
4414
+ }
4415
+ if (libraryMismatch && versionMismatch) {
4416
+ warning.push('and');
4417
+ }
4418
+ if (versionMismatch) {
4419
+ warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
4420
+ }
4421
+ logger.warn(warning.join(' '));
4422
+ return;
4423
+ }
4424
+ _registerComponent(new component.Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
4425
+ }
4426
+ /**
4427
+ * Sets log handler for all Firebase SDKs.
4428
+ * @param logCallback - An optional custom log handler that executes user code whenever
4429
+ * the Firebase SDK makes a logging call.
4430
+ *
4431
+ * @public
4432
+ */
4433
+ function onLog(logCallback, options) {
4434
+ if (logCallback !== null && typeof logCallback !== 'function') {
4435
+ throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
4436
+ }
4437
+ logger$1.setUserLogHandler(logCallback, options);
4438
+ }
4439
+ /**
4440
+ * Sets log level for all Firebase SDKs.
4441
+ *
4442
+ * All of the log types above the current log level are captured (i.e. if
4443
+ * you set the log level to `info`, errors are logged, but `debug` and
4444
+ * `verbose` logs are not).
4445
+ *
4446
+ * @public
4447
+ */
4448
+ function setLogLevel(logLevel) {
4449
+ logger$1.setLogLevel(logLevel);
4450
+ }
4451
+
4452
+ /**
4453
+ * @license
4454
+ * Copyright 2021 Google LLC
4455
+ *
4456
+ * Licensed under the Apache License, Version 2.0 (the "License");
4457
+ * you may not use this file except in compliance with the License.
4458
+ * You may obtain a copy of the License at
4459
+ *
4460
+ * http://www.apache.org/licenses/LICENSE-2.0
4461
+ *
4462
+ * Unless required by applicable law or agreed to in writing, software
4463
+ * distributed under the License is distributed on an "AS IS" BASIS,
4464
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4465
+ * See the License for the specific language governing permissions and
4466
+ * limitations under the License.
4467
+ */
4468
+ const DB_NAME = 'firebase-heartbeat-database';
4469
+ const DB_VERSION = 1;
4470
+ const STORE_NAME = 'firebase-heartbeat-store';
4471
+ let dbPromise = null;
4472
+ function getDbPromise() {
4473
+ if (!dbPromise) {
4474
+ dbPromise = idb.openDB(DB_NAME, DB_VERSION, {
4475
+ upgrade: (db, oldVersion) => {
4476
+ // We don't use 'break' in this switch statement, the fall-through
4477
+ // behavior is what we want, because if there are multiple versions between
4478
+ // the old version and the current version, we want ALL the migrations
4479
+ // that correspond to those versions to run, not only the last one.
4480
+ // eslint-disable-next-line default-case
4481
+ switch (oldVersion) {
4482
+ case 0:
4483
+ try {
4484
+ db.createObjectStore(STORE_NAME);
4485
+ }
4486
+ catch (e) {
4487
+ // Safari/iOS browsers throw occasional exceptions on
4488
+ // db.createObjectStore() that may be a bug. Avoid blocking
4489
+ // the rest of the app functionality.
4490
+ console.warn(e);
4491
+ }
4492
+ }
4493
+ }
4494
+ }).catch(e => {
4495
+ throw ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */, {
4496
+ originalErrorMessage: e.message
4497
+ });
4498
+ });
4499
+ }
4500
+ return dbPromise;
4501
+ }
4502
+ async function readHeartbeatsFromIndexedDB(app) {
4503
+ try {
4504
+ const db = await getDbPromise();
4505
+ const tx = db.transaction(STORE_NAME);
4506
+ const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
4507
+ // We already have the value but tx.done can throw,
4508
+ // so we need to await it here to catch errors
4509
+ await tx.done;
4510
+ return result;
4511
+ }
4512
+ catch (e) {
4513
+ if (e instanceof util.FirebaseError) {
4514
+ logger.warn(e.message);
4515
+ }
4516
+ else {
4517
+ const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
4518
+ originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
4519
+ });
4520
+ logger.warn(idbGetError.message);
4521
+ }
4522
+ }
4523
+ }
4524
+ async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
4525
+ try {
4526
+ const db = await getDbPromise();
4527
+ const tx = db.transaction(STORE_NAME, 'readwrite');
4528
+ const objectStore = tx.objectStore(STORE_NAME);
4529
+ await objectStore.put(heartbeatObject, computeKey(app));
4530
+ await tx.done;
4531
+ }
4532
+ catch (e) {
4533
+ if (e instanceof util.FirebaseError) {
4534
+ logger.warn(e.message);
4535
+ }
4536
+ else {
4537
+ const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
4538
+ originalErrorMessage: e === null || e === void 0 ? void 0 : e.message
4539
+ });
4540
+ logger.warn(idbGetError.message);
4541
+ }
4542
+ }
4543
+ }
4544
+ function computeKey(app) {
4545
+ return `${app.name}!${app.options.appId}`;
4546
+ }
4547
+
4548
+ /**
4549
+ * @license
4550
+ * Copyright 2021 Google LLC
4551
+ *
4552
+ * Licensed under the Apache License, Version 2.0 (the "License");
4553
+ * you may not use this file except in compliance with the License.
4554
+ * You may obtain a copy of the License at
4555
+ *
4556
+ * http://www.apache.org/licenses/LICENSE-2.0
4557
+ *
4558
+ * Unless required by applicable law or agreed to in writing, software
4559
+ * distributed under the License is distributed on an "AS IS" BASIS,
4560
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4561
+ * See the License for the specific language governing permissions and
4562
+ * limitations under the License.
4563
+ */
4564
+ const MAX_HEADER_BYTES = 1024;
4565
+ // 30 days
4566
+ const STORED_HEARTBEAT_RETENTION_MAX_MILLIS = 30 * 24 * 60 * 60 * 1000;
4567
+ class HeartbeatServiceImpl {
4568
+ constructor(container) {
4569
+ this.container = container;
4570
+ /**
4571
+ * In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
4572
+ * the header string.
4573
+ * Stores one record per date. This will be consolidated into the standard
4574
+ * format of one record per user agent string before being sent as a header.
4575
+ * Populated from indexedDB when the controller is instantiated and should
4576
+ * be kept in sync with indexedDB.
4577
+ * Leave public for easier testing.
4578
+ */
4579
+ this._heartbeatsCache = null;
4580
+ const app = this.container.getProvider('app').getImmediate();
4581
+ this._storage = new HeartbeatStorageImpl(app);
4582
+ this._heartbeatsCachePromise = this._storage.read().then(result => {
4583
+ this._heartbeatsCache = result;
4584
+ return result;
4585
+ });
4586
+ }
4587
+ /**
4588
+ * Called to report a heartbeat. The function will generate
4589
+ * a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
4590
+ * to IndexedDB.
4591
+ * Note that we only store one heartbeat per day. So if a heartbeat for today is
4592
+ * already logged, subsequent calls to this function in the same day will be ignored.
4593
+ */
4594
+ async triggerHeartbeat() {
4595
+ var _a, _b;
4596
+ try {
4597
+ const platformLogger = this.container
4598
+ .getProvider('platform-logger')
4599
+ .getImmediate();
4600
+ // This is the "Firebase user agent" string from the platform logger
4601
+ // service, not the browser user agent.
4602
+ const agent = platformLogger.getPlatformInfoString();
4603
+ const date = getUTCDateString();
4604
+ if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null) {
4605
+ this._heartbeatsCache = await this._heartbeatsCachePromise;
4606
+ // If we failed to construct a heartbeats cache, then return immediately.
4607
+ if (((_b = this._heartbeatsCache) === null || _b === void 0 ? void 0 : _b.heartbeats) == null) {
4608
+ return;
4609
+ }
4610
+ }
4611
+ // Do not store a heartbeat if one is already stored for this day
4612
+ // or if a header has already been sent today.
4613
+ if (this._heartbeatsCache.lastSentHeartbeatDate === date ||
4614
+ this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) {
4615
+ return;
4616
+ }
4617
+ else {
4618
+ // There is no entry for this date. Create one.
4619
+ this._heartbeatsCache.heartbeats.push({ date, agent });
4620
+ }
4621
+ // Remove entries older than 30 days.
4622
+ this._heartbeatsCache.heartbeats =
4623
+ this._heartbeatsCache.heartbeats.filter(singleDateHeartbeat => {
4624
+ const hbTimestamp = new Date(singleDateHeartbeat.date).valueOf();
4625
+ const now = Date.now();
4626
+ return now - hbTimestamp <= STORED_HEARTBEAT_RETENTION_MAX_MILLIS;
4627
+ });
4628
+ return this._storage.overwrite(this._heartbeatsCache);
4629
+ }
4630
+ catch (e) {
4631
+ logger.warn(e);
4632
+ }
4633
+ }
4634
+ /**
4635
+ * Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
4636
+ * It also clears all heartbeats from memory as well as in IndexedDB.
4637
+ *
4638
+ * NOTE: Consuming product SDKs should not send the header if this method
4639
+ * returns an empty string.
4640
+ */
4641
+ async getHeartbeatsHeader() {
4642
+ var _a;
4643
+ try {
4644
+ if (this._heartbeatsCache === null) {
4645
+ await this._heartbeatsCachePromise;
4646
+ }
4647
+ // If it's still null or the array is empty, there is no data to send.
4648
+ if (((_a = this._heartbeatsCache) === null || _a === void 0 ? void 0 : _a.heartbeats) == null ||
4649
+ this._heartbeatsCache.heartbeats.length === 0) {
4650
+ return '';
4651
+ }
4652
+ const date = getUTCDateString();
4653
+ // Extract as many heartbeats from the cache as will fit under the size limit.
4654
+ const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
4655
+ const headerString = util.base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend }));
4656
+ // Store last sent date to prevent another being logged/sent for the same day.
4657
+ this._heartbeatsCache.lastSentHeartbeatDate = date;
4658
+ if (unsentEntries.length > 0) {
4659
+ // Store any unsent entries if they exist.
4660
+ this._heartbeatsCache.heartbeats = unsentEntries;
4661
+ // This seems more likely than emptying the array (below) to lead to some odd state
4662
+ // since the cache isn't empty and this will be called again on the next request,
4663
+ // and is probably safest if we await it.
4664
+ await this._storage.overwrite(this._heartbeatsCache);
4665
+ }
4666
+ else {
4667
+ this._heartbeatsCache.heartbeats = [];
4668
+ // Do not wait for this, to reduce latency.
4669
+ void this._storage.overwrite(this._heartbeatsCache);
4670
+ }
4671
+ return headerString;
4672
+ }
4673
+ catch (e) {
4674
+ logger.warn(e);
4675
+ return '';
4676
+ }
4677
+ }
4678
+ }
4679
+ function getUTCDateString() {
4680
+ const today = new Date();
4681
+ // Returns date format 'YYYY-MM-DD'
4682
+ return today.toISOString().substring(0, 10);
4683
+ }
4684
+ function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
4685
+ // Heartbeats grouped by user agent in the standard format to be sent in
4686
+ // the header.
4687
+ const heartbeatsToSend = [];
4688
+ // Single date format heartbeats that are not sent.
4689
+ let unsentEntries = heartbeatsCache.slice();
4690
+ for (const singleDateHeartbeat of heartbeatsCache) {
4691
+ // Look for an existing entry with the same user agent.
4692
+ const heartbeatEntry = heartbeatsToSend.find(hb => hb.agent === singleDateHeartbeat.agent);
4693
+ if (!heartbeatEntry) {
4694
+ // If no entry for this user agent exists, create one.
4695
+ heartbeatsToSend.push({
4696
+ agent: singleDateHeartbeat.agent,
4697
+ dates: [singleDateHeartbeat.date]
4698
+ });
4699
+ if (countBytes(heartbeatsToSend) > maxSize) {
4700
+ // If the header would exceed max size, remove the added heartbeat
4701
+ // entry and stop adding to the header.
4702
+ heartbeatsToSend.pop();
4703
+ break;
4704
+ }
4705
+ }
4706
+ else {
4707
+ heartbeatEntry.dates.push(singleDateHeartbeat.date);
4708
+ // If the header would exceed max size, remove the added date
4709
+ // and stop adding to the header.
4710
+ if (countBytes(heartbeatsToSend) > maxSize) {
4711
+ heartbeatEntry.dates.pop();
4712
+ break;
4713
+ }
4714
+ }
4715
+ // Pop unsent entry from queue. (Skipped if adding the entry exceeded
4716
+ // quota and the loop breaks early.)
4717
+ unsentEntries = unsentEntries.slice(1);
4718
+ }
4719
+ return {
4720
+ heartbeatsToSend,
4721
+ unsentEntries
4722
+ };
4723
+ }
4724
+ class HeartbeatStorageImpl {
4725
+ constructor(app) {
4726
+ this.app = app;
4727
+ this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
4728
+ }
4729
+ async runIndexedDBEnvironmentCheck() {
4730
+ if (!util.isIndexedDBAvailable()) {
4731
+ return false;
4732
+ }
4733
+ else {
4734
+ return util.validateIndexedDBOpenable()
4735
+ .then(() => true)
4736
+ .catch(() => false);
4737
+ }
4738
+ }
4739
+ /**
4740
+ * Read all heartbeats.
4741
+ */
4742
+ async read() {
4743
+ const canUseIndexedDB = await this._canUseIndexedDBPromise;
4744
+ if (!canUseIndexedDB) {
4745
+ return { heartbeats: [] };
4746
+ }
4747
+ else {
4748
+ const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
4749
+ if (idbHeartbeatObject === null || idbHeartbeatObject === void 0 ? void 0 : idbHeartbeatObject.heartbeats) {
4750
+ return idbHeartbeatObject;
4751
+ }
4752
+ else {
4753
+ return { heartbeats: [] };
4754
+ }
4755
+ }
4756
+ }
4757
+ // overwrite the storage with the provided heartbeats
4758
+ async overwrite(heartbeatsObject) {
4759
+ var _a;
4760
+ const canUseIndexedDB = await this._canUseIndexedDBPromise;
4761
+ if (!canUseIndexedDB) {
4762
+ return;
4763
+ }
4764
+ else {
4765
+ const existingHeartbeatsObject = await this.read();
4766
+ return writeHeartbeatsToIndexedDB(this.app, {
4767
+ lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
4768
+ heartbeats: heartbeatsObject.heartbeats
4769
+ });
4770
+ }
4771
+ }
4772
+ // add heartbeats
4773
+ async add(heartbeatsObject) {
4774
+ var _a;
4775
+ const canUseIndexedDB = await this._canUseIndexedDBPromise;
4776
+ if (!canUseIndexedDB) {
4777
+ return;
4778
+ }
4779
+ else {
4780
+ const existingHeartbeatsObject = await this.read();
4781
+ return writeHeartbeatsToIndexedDB(this.app, {
4782
+ lastSentHeartbeatDate: (_a = heartbeatsObject.lastSentHeartbeatDate) !== null && _a !== void 0 ? _a : existingHeartbeatsObject.lastSentHeartbeatDate,
4783
+ heartbeats: [
4784
+ ...existingHeartbeatsObject.heartbeats,
4785
+ ...heartbeatsObject.heartbeats
4786
+ ]
4787
+ });
4788
+ }
4789
+ }
4790
+ }
4791
+ /**
4792
+ * Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
4793
+ * in a platform logging header JSON object, stringified, and converted
4794
+ * to base 64.
4795
+ */
4796
+ function countBytes(heartbeatsCache) {
4797
+ // base64 has a restricted set of characters, all of which should be 1 byte.
4798
+ return util.base64urlEncodeWithoutPadding(
4799
+ // heartbeatsCache wrapper properties
4800
+ JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
4801
+ }
4802
+
4803
+ /**
4804
+ * @license
4805
+ * Copyright 2019 Google LLC
4806
+ *
4807
+ * Licensed under the Apache License, Version 2.0 (the "License");
4808
+ * you may not use this file except in compliance with the License.
4809
+ * You may obtain a copy of the License at
4810
+ *
4811
+ * http://www.apache.org/licenses/LICENSE-2.0
4812
+ *
4813
+ * Unless required by applicable law or agreed to in writing, software
4814
+ * distributed under the License is distributed on an "AS IS" BASIS,
4815
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4816
+ * See the License for the specific language governing permissions and
4817
+ * limitations under the License.
4818
+ */
4819
+ function registerCoreComponents(variant) {
4820
+ _registerComponent(new component.Component('platform-logger', container => new PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
4821
+ _registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
4822
+ // Register `app` package.
4823
+ registerVersion(name$q, version$1, variant);
4824
+ // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation
4825
+ registerVersion(name$q, version$1, 'cjs2017');
4826
+ // Register platform SDK identifier (no version).
4827
+ registerVersion('fire-js', '');
4828
+ }
4829
+
4830
+ /**
4831
+ * Firebase App
4832
+ *
4833
+ * @remarks This package coordinates the communication between the different Firebase components
4834
+ * @packageDocumentation
4835
+ */
4836
+ registerCoreComponents('node');
4837
+
4838
+ Object.defineProperty(exports, 'FirebaseError', {
4839
+ enumerable: true,
4840
+ get: function () { return util.FirebaseError; }
4841
+ });
4842
+ exports.SDK_VERSION = SDK_VERSION;
4843
+ exports._DEFAULT_ENTRY_NAME = DEFAULT_ENTRY_NAME;
4844
+ exports._addComponent = _addComponent;
4845
+ exports._addOrOverwriteComponent = _addOrOverwriteComponent;
4846
+ exports._apps = _apps;
4847
+ exports._clearComponents = _clearComponents;
4848
+ exports._components = _components;
4849
+ exports._getProvider = _getProvider;
4850
+ exports._isFirebaseApp = _isFirebaseApp;
4851
+ exports._isFirebaseServerApp = _isFirebaseServerApp;
4852
+ exports._registerComponent = _registerComponent;
4853
+ exports._removeServiceInstance = _removeServiceInstance;
4854
+ exports._serverApps = _serverApps;
4855
+ exports.deleteApp = deleteApp;
4856
+ exports.getApp = getApp;
4857
+ exports.getApps = getApps;
4858
+ exports.initializeApp = initializeApp;
4859
+ exports.initializeServerApp = initializeServerApp;
4860
+ exports.onLog = onLog;
4861
+ exports.registerVersion = registerVersion;
4862
+ exports.setLogLevel = setLogLevel;
4863
+
4864
+ }(index_cjs));
4865
+
4866
+ Object.defineProperty(index_standalone, '__esModule', { value: true });
4867
+
4868
+ var Websocket = websocket;
4869
+ var util = require$$2__default$3["default"];
4870
+ var logger$1 = require$$1__default$3["default"];
4871
+ var app = index_cjs;
4872
+ var component = require$$0__default$3["default"];
4873
+
4874
+ function _interopDefaultLegacy$1 (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
4875
+
4876
+ var Websocket__default = /*#__PURE__*/_interopDefaultLegacy$1(Websocket);
4877
+
4878
+ /**
4879
+ * @license
4880
+ * Copyright 2017 Google LLC
4881
+ *
4882
+ * Licensed under the Apache License, Version 2.0 (the "License");
4883
+ * you may not use this file except in compliance with the License.
4884
+ * You may obtain a copy of the License at
4885
+ *
4886
+ * http://www.apache.org/licenses/LICENSE-2.0
4887
+ *
4888
+ * Unless required by applicable law or agreed to in writing, software
4889
+ * distributed under the License is distributed on an "AS IS" BASIS,
4890
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4891
+ * See the License for the specific language governing permissions and
4892
+ * limitations under the License.
4893
+ */
4894
+ const PROTOCOL_VERSION = '5';
4895
+ const VERSION_PARAM = 'v';
4896
+ const TRANSPORT_SESSION_PARAM = 's';
4897
+ const REFERER_PARAM = 'r';
4898
+ const FORGE_REF = 'f';
4899
+ // Matches console.firebase.google.com, firebase-console-*.corp.google.com and
4900
+ // firebase.corp.google.com
4901
+ const FORGE_DOMAIN_RE = /(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/;
4902
+ const LAST_SESSION_PARAM = 'ls';
4903
+ const APPLICATION_ID_PARAM = 'p';
4904
+ const APP_CHECK_TOKEN_PARAM = 'ac';
4905
+ const WEBSOCKET = 'websocket';
4906
+ const LONG_POLLING = 'long_polling';
4907
+
4908
+ /**
4909
+ * @license
4910
+ * Copyright 2017 Google LLC
4911
+ *
4912
+ * Licensed under the Apache License, Version 2.0 (the "License");
4913
+ * you may not use this file except in compliance with the License.
4914
+ * You may obtain a copy of the License at
4915
+ *
4916
+ * http://www.apache.org/licenses/LICENSE-2.0
4917
+ *
4918
+ * Unless required by applicable law or agreed to in writing, software
4919
+ * distributed under the License is distributed on an "AS IS" BASIS,
4920
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4921
+ * See the License for the specific language governing permissions and
4922
+ * limitations under the License.
4923
+ */
4924
+ /**
4925
+ * Wraps a DOM Storage object and:
4926
+ * - automatically encode objects as JSON strings before storing them to allow us to store arbitrary types.
4927
+ * - prefixes names with "firebase:" to avoid collisions with app data.
4928
+ *
4929
+ * We automatically (see storage.js) create two such wrappers, one for sessionStorage,
4930
+ * and one for localStorage.
4931
+ *
4932
+ */
4933
+ class DOMStorageWrapper {
4934
+ /**
4935
+ * @param domStorage_ - The underlying storage object (e.g. localStorage or sessionStorage)
4936
+ */
4937
+ constructor(domStorage_) {
4938
+ this.domStorage_ = domStorage_;
4939
+ // Use a prefix to avoid collisions with other stuff saved by the app.
4940
+ this.prefix_ = 'firebase:';
4941
+ }
4942
+ /**
4943
+ * @param key - The key to save the value under
4944
+ * @param value - The value being stored, or null to remove the key.
4945
+ */
4946
+ set(key, value) {
4947
+ if (value == null) {
4948
+ this.domStorage_.removeItem(this.prefixedName_(key));
4949
+ }
4950
+ else {
4951
+ this.domStorage_.setItem(this.prefixedName_(key), util.stringify(value));
4952
+ }
4953
+ }
4954
+ /**
4955
+ * @returns The value that was stored under this key, or null
4956
+ */
4957
+ get(key) {
4958
+ const storedVal = this.domStorage_.getItem(this.prefixedName_(key));
4959
+ if (storedVal == null) {
4960
+ return null;
4961
+ }
4962
+ else {
4963
+ return util.jsonEval(storedVal);
4964
+ }
4965
+ }
4966
+ remove(key) {
4967
+ this.domStorage_.removeItem(this.prefixedName_(key));
4968
+ }
4969
+ prefixedName_(name) {
4970
+ return this.prefix_ + name;
4971
+ }
4972
+ toString() {
4973
+ return this.domStorage_.toString();
4974
+ }
4975
+ }
4976
+
4977
+ /**
4978
+ * @license
4979
+ * Copyright 2017 Google LLC
4980
+ *
4981
+ * Licensed under the Apache License, Version 2.0 (the "License");
4982
+ * you may not use this file except in compliance with the License.
4983
+ * You may obtain a copy of the License at
4984
+ *
4985
+ * http://www.apache.org/licenses/LICENSE-2.0
4986
+ *
4987
+ * Unless required by applicable law or agreed to in writing, software
4988
+ * distributed under the License is distributed on an "AS IS" BASIS,
4989
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4990
+ * See the License for the specific language governing permissions and
4991
+ * limitations under the License.
4992
+ */
4993
+ /**
4994
+ * An in-memory storage implementation that matches the API of DOMStorageWrapper
4995
+ * (TODO: create interface for both to implement).
4996
+ */
4997
+ class MemoryStorage {
4998
+ constructor() {
4999
+ this.cache_ = {};
5000
+ this.isInMemoryStorage = true;
5001
+ }
5002
+ set(key, value) {
5003
+ if (value == null) {
5004
+ delete this.cache_[key];
5005
+ }
5006
+ else {
5007
+ this.cache_[key] = value;
5008
+ }
5009
+ }
5010
+ get(key) {
5011
+ if (util.contains(this.cache_, key)) {
5012
+ return this.cache_[key];
5013
+ }
5014
+ return null;
5015
+ }
5016
+ remove(key) {
5017
+ delete this.cache_[key];
5018
+ }
5019
+ }
5020
+
5021
+ /**
5022
+ * @license
5023
+ * Copyright 2017 Google LLC
5024
+ *
5025
+ * Licensed under the Apache License, Version 2.0 (the "License");
5026
+ * you may not use this file except in compliance with the License.
5027
+ * You may obtain a copy of the License at
5028
+ *
5029
+ * http://www.apache.org/licenses/LICENSE-2.0
5030
+ *
5031
+ * Unless required by applicable law or agreed to in writing, software
5032
+ * distributed under the License is distributed on an "AS IS" BASIS,
5033
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5034
+ * See the License for the specific language governing permissions and
5035
+ * limitations under the License.
5036
+ */
5037
+ /**
5038
+ * Helper to create a DOMStorageWrapper or else fall back to MemoryStorage.
5039
+ * TODO: Once MemoryStorage and DOMStorageWrapper have a shared interface this method annotation should change
5040
+ * to reflect this type
5041
+ *
5042
+ * @param domStorageName - Name of the underlying storage object
5043
+ * (e.g. 'localStorage' or 'sessionStorage').
5044
+ * @returns Turning off type information until a common interface is defined.
5045
+ */
5046
+ const createStoragefor = function (domStorageName) {
5047
+ try {
5048
+ // NOTE: just accessing "localStorage" or "window['localStorage']" may throw a security exception,
5049
+ // so it must be inside the try/catch.
5050
+ if (typeof window !== 'undefined' &&
5051
+ typeof window[domStorageName] !== 'undefined') {
5052
+ // Need to test cache. Just because it's here doesn't mean it works
5053
+ const domStorage = window[domStorageName];
5054
+ domStorage.setItem('firebase:sentinel', 'cache');
5055
+ domStorage.removeItem('firebase:sentinel');
5056
+ return new DOMStorageWrapper(domStorage);
5057
+ }
5058
+ }
5059
+ catch (e) { }
5060
+ // Failed to create wrapper. Just return in-memory storage.
5061
+ // TODO: log?
5062
+ return new MemoryStorage();
5063
+ };
5064
+ /** A storage object that lasts across sessions */
5065
+ const PersistentStorage = createStoragefor('localStorage');
5066
+ /** A storage object that only lasts one session */
5067
+ const SessionStorage = createStoragefor('sessionStorage');
5068
+
5069
+ /**
5070
+ * @license
5071
+ * Copyright 2017 Google LLC
5072
+ *
5073
+ * Licensed under the Apache License, Version 2.0 (the "License");
5074
+ * you may not use this file except in compliance with the License.
5075
+ * You may obtain a copy of the License at
5076
+ *
5077
+ * http://www.apache.org/licenses/LICENSE-2.0
5078
+ *
5079
+ * Unless required by applicable law or agreed to in writing, software
5080
+ * distributed under the License is distributed on an "AS IS" BASIS,
5081
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5082
+ * See the License for the specific language governing permissions and
5083
+ * limitations under the License.
5084
+ */
5085
+ const logClient$1 = new logger$1.Logger('@firebase/database');
5086
+ /**
5087
+ * Returns a locally-unique ID (generated by just incrementing up from 0 each time its called).
5088
+ */
5089
+ const LUIDGenerator = (function () {
5090
+ let id = 1;
5091
+ return function () {
5092
+ return id++;
5093
+ };
5094
+ })();
5095
+ /**
5096
+ * Sha1 hash of the input string
5097
+ * @param str - The string to hash
5098
+ * @returns {!string} The resulting hash
5099
+ */
5100
+ const sha1 = function (str) {
5101
+ const utf8Bytes = util.stringToByteArray(str);
5102
+ const sha1 = new util.Sha1();
5103
+ sha1.update(utf8Bytes);
5104
+ const sha1Bytes = sha1.digest();
5105
+ return util.base64.encodeByteArray(sha1Bytes);
5106
+ };
5107
+ const buildLogMessage_ = function (...varArgs) {
5108
+ let message = '';
5109
+ for (let i = 0; i < varArgs.length; i++) {
5110
+ const arg = varArgs[i];
5111
+ if (Array.isArray(arg) ||
5112
+ (arg &&
5113
+ typeof arg === 'object' &&
5114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5115
+ typeof arg.length === 'number')) {
5116
+ message += buildLogMessage_.apply(null, arg);
5117
+ }
5118
+ else if (typeof arg === 'object') {
5119
+ message += util.stringify(arg);
5120
+ }
5121
+ else {
5122
+ message += arg;
5123
+ }
3605
5124
  message += ' ';
3606
5125
  }
3607
5126
  return message;
@@ -4622,15 +6141,24 @@ WebSocketConnection.healthyTimeout = 30000;
4622
6141
  * Abstraction around AppCheck's token fetching capabilities.
4623
6142
  */
4624
6143
  class AppCheckTokenProvider {
4625
- constructor(appName_, appCheckProvider) {
4626
- this.appName_ = appName_;
6144
+ constructor(app$1, appCheckProvider) {
4627
6145
  this.appCheckProvider = appCheckProvider;
6146
+ this.appName = app$1.name;
6147
+ if (app._isFirebaseServerApp(app$1) && app$1.settings.appCheckToken) {
6148
+ this.serverAppAppCheckToken = app$1.settings.appCheckToken;
6149
+ }
4628
6150
  this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
4629
6151
  if (!this.appCheck) {
4630
6152
  appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck));
4631
6153
  }
4632
6154
  }
4633
6155
  getToken(forceRefresh) {
6156
+ if (this.serverAppAppCheckToken) {
6157
+ if (forceRefresh) {
6158
+ throw new Error('Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.');
6159
+ }
6160
+ return Promise.resolve({ token: this.serverAppAppCheckToken });
6161
+ }
4634
6162
  if (!this.appCheck) {
4635
6163
  return new Promise((resolve, reject) => {
4636
6164
  // Support delayed initialization of FirebaseAppCheck. This allows our
@@ -4654,7 +6182,7 @@ class AppCheckTokenProvider {
4654
6182
  (_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener));
4655
6183
  }
4656
6184
  notifyForInvalidToken() {
4657
- warn$1(`Provided AppCheck credentials for the app named "${this.appName_}" ` +
6185
+ warn$1(`Provided AppCheck credentials for the app named "${this.appName}" ` +
4658
6186
  'are invalid. This usually indicates your app was not initialized correctly.');
4659
6187
  }
4660
6188
  }
@@ -16876,7 +18404,7 @@ function repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, no
16876
18404
  fatal('Database URL must point to the root of a Firebase Database ' +
16877
18405
  '(not including a child path).');
16878
18406
  }
16879
- const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app.name, appCheckProvider));
18407
+ const repo = repoManagerCreateRepo(repoInfo, app, authTokenProvider, new AppCheckTokenProvider(app, appCheckProvider));
16880
18408
  return new Database$1(repo, app);
16881
18409
  }
16882
18410
  /**
@@ -17362,7 +18890,7 @@ var update_1 = index_standalone.update = update;
17362
18890
  * See the License for the specific language governing permissions and
17363
18891
  * limitations under the License.
17364
18892
  */
17365
- const logClient = new require$$2$3.Logger('@firebase/database-compat');
18893
+ const logClient = new require$$1$3.Logger('@firebase/database-compat');
17366
18894
  const warn = function (msg) {
17367
18895
  const message = 'FIREBASE WARNING: ' + msg;
17368
18896
  logClient.warn(message);
@@ -17389,7 +18917,7 @@ const validateBoolean = function (fnName, argumentName, bool, optional) {
17389
18917
  return;
17390
18918
  }
17391
18919
  if (typeof bool !== 'boolean') {
17392
- throw new Error(require$$1$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
18920
+ throw new Error(require$$2$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
17393
18921
  }
17394
18922
  };
17395
18923
  const validateEventType = function (fnName, eventType, optional) {
@@ -17404,7 +18932,7 @@ const validateEventType = function (fnName, eventType, optional) {
17404
18932
  case 'child_moved':
17405
18933
  break;
17406
18934
  default:
17407
- throw new Error(require$$1$3.errorPrefix(fnName, 'eventType') +
18935
+ throw new Error(require$$2$3.errorPrefix(fnName, 'eventType') +
17408
18936
  'must be a valid event type = "value", "child_added", "child_removed", ' +
17409
18937
  '"child_changed", or "child_moved".');
17410
18938
  }
@@ -17431,8 +18959,8 @@ class OnDisconnect {
17431
18959
  this._delegate = _delegate;
17432
18960
  }
17433
18961
  cancel(onComplete) {
17434
- require$$1$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
17435
- require$$1$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
18962
+ require$$2$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
18963
+ require$$2$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
17436
18964
  const result = this._delegate.cancel();
17437
18965
  if (onComplete) {
17438
18966
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17440,8 +18968,8 @@ class OnDisconnect {
17440
18968
  return result;
17441
18969
  }
17442
18970
  remove(onComplete) {
17443
- require$$1$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
17444
- require$$1$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
18971
+ require$$2$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
18972
+ require$$2$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
17445
18973
  const result = this._delegate.remove();
17446
18974
  if (onComplete) {
17447
18975
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17449,8 +18977,8 @@ class OnDisconnect {
17449
18977
  return result;
17450
18978
  }
17451
18979
  set(value, onComplete) {
17452
- require$$1$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
17453
- require$$1$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
18980
+ require$$2$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
18981
+ require$$2$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
17454
18982
  const result = this._delegate.set(value);
17455
18983
  if (onComplete) {
17456
18984
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17458,8 +18986,8 @@ class OnDisconnect {
17458
18986
  return result;
17459
18987
  }
17460
18988
  setWithPriority(value, priority, onComplete) {
17461
- require$$1$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
17462
- require$$1$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
18989
+ require$$2$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
18990
+ require$$2$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
17463
18991
  const result = this._delegate.setWithPriority(value, priority);
17464
18992
  if (onComplete) {
17465
18993
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17467,7 +18995,7 @@ class OnDisconnect {
17467
18995
  return result;
17468
18996
  }
17469
18997
  update(objectToMerge, onComplete) {
17470
- require$$1$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
18998
+ require$$2$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
17471
18999
  if (Array.isArray(objectToMerge)) {
17472
19000
  const newObjectToMerge = {};
17473
19001
  for (let i = 0; i < objectToMerge.length; ++i) {
@@ -17477,7 +19005,7 @@ class OnDisconnect {
17477
19005
  warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
17478
19006
  'existing data, or an Object with integer keys if you really do want to only update some of the children.');
17479
19007
  }
17480
- require$$1$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
19008
+ require$$2$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
17481
19009
  const result = this._delegate.update(objectToMerge);
17482
19010
  if (onComplete) {
17483
19011
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17513,7 +19041,7 @@ class TransactionResult {
17513
19041
  // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
17514
19042
  // for end-users
17515
19043
  toJSON() {
17516
- require$$1$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
19044
+ require$$2$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
17517
19045
  return { committed: this.committed, snapshot: this.snapshot.toJSON() };
17518
19046
  }
17519
19047
  }
@@ -17550,7 +19078,7 @@ class DataSnapshot {
17550
19078
  * @returns JSON representation of the DataSnapshot contents, or null if empty.
17551
19079
  */
17552
19080
  val() {
17553
- require$$1$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
19081
+ require$$2$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
17554
19082
  return this._delegate.val();
17555
19083
  }
17556
19084
  /**
@@ -17559,14 +19087,14 @@ class DataSnapshot {
17559
19087
  * @returns JSON representation of the DataSnapshot contents, or null if empty.
17560
19088
  */
17561
19089
  exportVal() {
17562
- require$$1$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
19090
+ require$$2$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
17563
19091
  return this._delegate.exportVal();
17564
19092
  }
17565
19093
  // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
17566
19094
  // for end-users
17567
19095
  toJSON() {
17568
19096
  // Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
17569
- require$$1$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
19097
+ require$$2$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
17570
19098
  return this._delegate.toJSON();
17571
19099
  }
17572
19100
  /**
@@ -17575,7 +19103,7 @@ class DataSnapshot {
17575
19103
  * @returns Whether the snapshot contains a non-null value, or is empty.
17576
19104
  */
17577
19105
  exists() {
17578
- require$$1$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
19106
+ require$$2$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
17579
19107
  return this._delegate.exists();
17580
19108
  }
17581
19109
  /**
@@ -17585,7 +19113,7 @@ class DataSnapshot {
17585
19113
  * @returns DataSnapshot for child node.
17586
19114
  */
17587
19115
  child(path) {
17588
- require$$1$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
19116
+ require$$2$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
17589
19117
  // Ensure the childPath is a string (can be a number)
17590
19118
  path = String(path);
17591
19119
  _validatePathString('DataSnapshot.child', 'path', path, false);
@@ -17598,7 +19126,7 @@ class DataSnapshot {
17598
19126
  * @returns Whether the child exists.
17599
19127
  */
17600
19128
  hasChild(path) {
17601
- require$$1$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
19129
+ require$$2$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
17602
19130
  _validatePathString('DataSnapshot.hasChild', 'path', path, false);
17603
19131
  return this._delegate.hasChild(path);
17604
19132
  }
@@ -17608,7 +19136,7 @@ class DataSnapshot {
17608
19136
  * @returns The priority.
17609
19137
  */
17610
19138
  getPriority() {
17611
- require$$1$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
19139
+ require$$2$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
17612
19140
  return this._delegate.priority;
17613
19141
  }
17614
19142
  /**
@@ -17620,8 +19148,8 @@ class DataSnapshot {
17620
19148
  * one of the child nodes.
17621
19149
  */
17622
19150
  forEach(action) {
17623
- require$$1$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
17624
- require$$1$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
19151
+ require$$2$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
19152
+ require$$2$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
17625
19153
  return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
17626
19154
  }
17627
19155
  /**
@@ -17629,7 +19157,7 @@ class DataSnapshot {
17629
19157
  * @returns True if the DataSnapshot contains 1 or more child nodes.
17630
19158
  */
17631
19159
  hasChildren() {
17632
- require$$1$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
19160
+ require$$2$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
17633
19161
  return this._delegate.hasChildren();
17634
19162
  }
17635
19163
  get key() {
@@ -17640,7 +19168,7 @@ class DataSnapshot {
17640
19168
  * @returns The number of children that this DataSnapshot contains.
17641
19169
  */
17642
19170
  numChildren() {
17643
- require$$1$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
19171
+ require$$2$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
17644
19172
  return this._delegate.size;
17645
19173
  }
17646
19174
  /**
@@ -17648,7 +19176,7 @@ class DataSnapshot {
17648
19176
  * from.
17649
19177
  */
17650
19178
  getRef() {
17651
- require$$1$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
19179
+ require$$2$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
17652
19180
  return new Reference(this._database, this._delegate.ref);
17653
19181
  }
17654
19182
  get ref() {
@@ -17668,8 +19196,8 @@ class Query {
17668
19196
  }
17669
19197
  on(eventType, callback, cancelCallbackOrContext, context) {
17670
19198
  var _a;
17671
- require$$1$3.validateArgCount('Query.on', 2, 4, arguments.length);
17672
- require$$1$3.validateCallback('Query.on', 'callback', callback, false);
19199
+ require$$2$3.validateArgCount('Query.on', 2, 4, arguments.length);
19200
+ require$$2$3.validateCallback('Query.on', 'callback', callback, false);
17673
19201
  const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
17674
19202
  const valueCallback = (expSnapshot, previousChildName) => {
17675
19203
  callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
@@ -17694,16 +19222,16 @@ class Query {
17694
19222
  onChildMoved_1(this._delegate, valueCallback, cancelCallback);
17695
19223
  return callback;
17696
19224
  default:
17697
- throw new Error(require$$1$3.errorPrefix('Query.on', 'eventType') +
19225
+ throw new Error(require$$2$3.errorPrefix('Query.on', 'eventType') +
17698
19226
  'must be a valid event type = "value", "child_added", "child_removed", ' +
17699
19227
  '"child_changed", or "child_moved".');
17700
19228
  }
17701
19229
  }
17702
19230
  off(eventType, callback, context) {
17703
- require$$1$3.validateArgCount('Query.off', 0, 3, arguments.length);
19231
+ require$$2$3.validateArgCount('Query.off', 0, 3, arguments.length);
17704
19232
  validateEventType('Query.off', eventType, true);
17705
- require$$1$3.validateCallback('Query.off', 'callback', callback, true);
17706
- require$$1$3.validateContextObject('Query.off', 'context', context, true);
19233
+ require$$2$3.validateCallback('Query.off', 'callback', callback, true);
19234
+ require$$2$3.validateContextObject('Query.off', 'context', context, true);
17707
19235
  if (callback) {
17708
19236
  const valueCallback = () => { };
17709
19237
  valueCallback.userCallback = callback;
@@ -17726,10 +19254,10 @@ class Query {
17726
19254
  * Attaches a listener, waits for the first event, and then removes the listener
17727
19255
  */
17728
19256
  once(eventType, callback, failureCallbackOrContext, context) {
17729
- require$$1$3.validateArgCount('Query.once', 1, 4, arguments.length);
17730
- require$$1$3.validateCallback('Query.once', 'callback', callback, true);
19257
+ require$$2$3.validateArgCount('Query.once', 1, 4, arguments.length);
19258
+ require$$2$3.validateCallback('Query.once', 'callback', callback, true);
17731
19259
  const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
17732
- const deferred = new require$$1$3.Deferred();
19260
+ const deferred = new require$$2$3.Deferred();
17733
19261
  const valueCallback = (expSnapshot, previousChildName) => {
17734
19262
  const result = new DataSnapshot(this.database, expSnapshot);
17735
19263
  if (callback) {
@@ -17772,7 +19300,7 @@ class Query {
17772
19300
  });
17773
19301
  break;
17774
19302
  default:
17775
- throw new Error(require$$1$3.errorPrefix('Query.once', 'eventType') +
19303
+ throw new Error(require$$2$3.errorPrefix('Query.once', 'eventType') +
17776
19304
  'must be a valid event type = "value", "child_added", "child_removed", ' +
17777
19305
  '"child_changed", or "child_moved".');
17778
19306
  }
@@ -17782,58 +19310,58 @@ class Query {
17782
19310
  * Set a limit and anchor it to the start of the window.
17783
19311
  */
17784
19312
  limitToFirst(limit) {
17785
- require$$1$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
19313
+ require$$2$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
17786
19314
  return new Query(this.database, query_1(this._delegate, limitToFirst_1(limit)));
17787
19315
  }
17788
19316
  /**
17789
19317
  * Set a limit and anchor it to the end of the window.
17790
19318
  */
17791
19319
  limitToLast(limit) {
17792
- require$$1$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
19320
+ require$$2$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
17793
19321
  return new Query(this.database, query_1(this._delegate, limitToLast_1(limit)));
17794
19322
  }
17795
19323
  /**
17796
19324
  * Given a child path, return a new query ordered by the specified grandchild path.
17797
19325
  */
17798
19326
  orderByChild(path) {
17799
- require$$1$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
19327
+ require$$2$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
17800
19328
  return new Query(this.database, query_1(this._delegate, orderByChild_1(path)));
17801
19329
  }
17802
19330
  /**
17803
19331
  * Return a new query ordered by the KeyIndex
17804
19332
  */
17805
19333
  orderByKey() {
17806
- require$$1$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
19334
+ require$$2$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
17807
19335
  return new Query(this.database, query_1(this._delegate, orderByKey_1()));
17808
19336
  }
17809
19337
  /**
17810
19338
  * Return a new query ordered by the PriorityIndex
17811
19339
  */
17812
19340
  orderByPriority() {
17813
- require$$1$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
19341
+ require$$2$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
17814
19342
  return new Query(this.database, query_1(this._delegate, orderByPriority_1()));
17815
19343
  }
17816
19344
  /**
17817
19345
  * Return a new query ordered by the ValueIndex
17818
19346
  */
17819
19347
  orderByValue() {
17820
- require$$1$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
19348
+ require$$2$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
17821
19349
  return new Query(this.database, query_1(this._delegate, orderByValue_1()));
17822
19350
  }
17823
19351
  startAt(value = null, name) {
17824
- require$$1$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
19352
+ require$$2$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
17825
19353
  return new Query(this.database, query_1(this._delegate, startAt_1(value, name)));
17826
19354
  }
17827
19355
  startAfter(value = null, name) {
17828
- require$$1$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
19356
+ require$$2$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
17829
19357
  return new Query(this.database, query_1(this._delegate, startAfter_1(value, name)));
17830
19358
  }
17831
19359
  endAt(value = null, name) {
17832
- require$$1$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
19360
+ require$$2$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
17833
19361
  return new Query(this.database, query_1(this._delegate, endAt_1(value, name)));
17834
19362
  }
17835
19363
  endBefore(value = null, name) {
17836
- require$$1$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
19364
+ require$$2$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
17837
19365
  return new Query(this.database, query_1(this._delegate, endBefore_1(value, name)));
17838
19366
  }
17839
19367
  /**
@@ -17841,28 +19369,28 @@ class Query {
17841
19369
  * the specified name.
17842
19370
  */
17843
19371
  equalTo(value, name) {
17844
- require$$1$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
19372
+ require$$2$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
17845
19373
  return new Query(this.database, query_1(this._delegate, equalTo_1(value, name)));
17846
19374
  }
17847
19375
  /**
17848
19376
  * @returns URL for this location.
17849
19377
  */
17850
19378
  toString() {
17851
- require$$1$3.validateArgCount('Query.toString', 0, 0, arguments.length);
19379
+ require$$2$3.validateArgCount('Query.toString', 0, 0, arguments.length);
17852
19380
  return this._delegate.toString();
17853
19381
  }
17854
19382
  // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
17855
19383
  // for end-users.
17856
19384
  toJSON() {
17857
19385
  // An optional spacer argument is unnecessary for a string.
17858
- require$$1$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
19386
+ require$$2$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
17859
19387
  return this._delegate.toJSON();
17860
19388
  }
17861
19389
  /**
17862
19390
  * Return true if this query and the provided query are equivalent; otherwise, return false.
17863
19391
  */
17864
19392
  isEqual(other) {
17865
- require$$1$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
19393
+ require$$2$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
17866
19394
  if (!(other instanceof Query)) {
17867
19395
  const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
17868
19396
  throw new Error(error);
@@ -17878,9 +19406,9 @@ class Query {
17878
19406
  const ret = { cancel: undefined, context: undefined };
17879
19407
  if (cancelOrContext && context) {
17880
19408
  ret.cancel = cancelOrContext;
17881
- require$$1$3.validateCallback(fnName, 'cancel', ret.cancel, true);
19409
+ require$$2$3.validateCallback(fnName, 'cancel', ret.cancel, true);
17882
19410
  ret.context = context;
17883
- require$$1$3.validateContextObject(fnName, 'context', ret.context, true);
19411
+ require$$2$3.validateContextObject(fnName, 'context', ret.context, true);
17884
19412
  }
17885
19413
  else if (cancelOrContext) {
17886
19414
  // we have either a cancel callback or a context.
@@ -17892,7 +19420,7 @@ class Query {
17892
19420
  ret.cancel = cancelOrContext;
17893
19421
  }
17894
19422
  else {
17895
- throw new Error(require$$1$3.errorPrefix(fnName, 'cancelOrContext') +
19423
+ throw new Error(require$$2$3.errorPrefix(fnName, 'cancelOrContext') +
17896
19424
  ' must either be a cancel callback or a context object.');
17897
19425
  }
17898
19426
  }
@@ -17917,11 +19445,11 @@ class Reference extends Query {
17917
19445
  }
17918
19446
  /** @returns {?string} */
17919
19447
  getKey() {
17920
- require$$1$3.validateArgCount('Reference.key', 0, 0, arguments.length);
19448
+ require$$2$3.validateArgCount('Reference.key', 0, 0, arguments.length);
17921
19449
  return this._delegate.key;
17922
19450
  }
17923
19451
  child(pathString) {
17924
- require$$1$3.validateArgCount('Reference.child', 1, 1, arguments.length);
19452
+ require$$2$3.validateArgCount('Reference.child', 1, 1, arguments.length);
17925
19453
  if (typeof pathString === 'number') {
17926
19454
  pathString = String(pathString);
17927
19455
  }
@@ -17929,18 +19457,18 @@ class Reference extends Query {
17929
19457
  }
17930
19458
  /** @returns {?Reference} */
17931
19459
  getParent() {
17932
- require$$1$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
19460
+ require$$2$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
17933
19461
  const parent = this._delegate.parent;
17934
19462
  return parent ? new Reference(this.database, parent) : null;
17935
19463
  }
17936
19464
  /** @returns {!Reference} */
17937
19465
  getRoot() {
17938
- require$$1$3.validateArgCount('Reference.root', 0, 0, arguments.length);
19466
+ require$$2$3.validateArgCount('Reference.root', 0, 0, arguments.length);
17939
19467
  return new Reference(this.database, this._delegate.root);
17940
19468
  }
17941
19469
  set(newVal, onComplete) {
17942
- require$$1$3.validateArgCount('Reference.set', 1, 2, arguments.length);
17943
- require$$1$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
19470
+ require$$2$3.validateArgCount('Reference.set', 1, 2, arguments.length);
19471
+ require$$2$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
17944
19472
  const result = set_1(this._delegate, newVal);
17945
19473
  if (onComplete) {
17946
19474
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17948,7 +19476,7 @@ class Reference extends Query {
17948
19476
  return result;
17949
19477
  }
17950
19478
  update(values, onComplete) {
17951
- require$$1$3.validateArgCount('Reference.update', 1, 2, arguments.length);
19479
+ require$$2$3.validateArgCount('Reference.update', 1, 2, arguments.length);
17952
19480
  if (Array.isArray(values)) {
17953
19481
  const newObjectToMerge = {};
17954
19482
  for (let i = 0; i < values.length; ++i) {
@@ -17961,7 +19489,7 @@ class Reference extends Query {
17961
19489
  'only update some of the children.');
17962
19490
  }
17963
19491
  _validateWritablePath('Reference.update', this._delegate._path);
17964
- require$$1$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
19492
+ require$$2$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
17965
19493
  const result = update_1(this._delegate, values);
17966
19494
  if (onComplete) {
17967
19495
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17969,8 +19497,8 @@ class Reference extends Query {
17969
19497
  return result;
17970
19498
  }
17971
19499
  setWithPriority(newVal, newPriority, onComplete) {
17972
- require$$1$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
17973
- require$$1$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
19500
+ require$$2$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
19501
+ require$$2$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
17974
19502
  const result = setWithPriority_1(this._delegate, newVal, newPriority);
17975
19503
  if (onComplete) {
17976
19504
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17978,8 +19506,8 @@ class Reference extends Query {
17978
19506
  return result;
17979
19507
  }
17980
19508
  remove(onComplete) {
17981
- require$$1$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
17982
- require$$1$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
19509
+ require$$2$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
19510
+ require$$2$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
17983
19511
  const result = remove_1(this._delegate);
17984
19512
  if (onComplete) {
17985
19513
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17987,9 +19515,9 @@ class Reference extends Query {
17987
19515
  return result;
17988
19516
  }
17989
19517
  transaction(transactionUpdate, onComplete, applyLocally) {
17990
- require$$1$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
17991
- require$$1$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
17992
- require$$1$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
19518
+ require$$2$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
19519
+ require$$2$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
19520
+ require$$2$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
17993
19521
  validateBoolean('Reference.transaction', 'applyLocally', applyLocally, true);
17994
19522
  const result = runTransaction_1(this._delegate, transactionUpdate, {
17995
19523
  applyLocally
@@ -18000,8 +19528,8 @@ class Reference extends Query {
18000
19528
  return result;
18001
19529
  }
18002
19530
  setPriority(priority, onComplete) {
18003
- require$$1$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
18004
- require$$1$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
19531
+ require$$2$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
19532
+ require$$2$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
18005
19533
  const result = setPriority_1(this._delegate, priority);
18006
19534
  if (onComplete) {
18007
19535
  result.then(() => onComplete(null), error => onComplete(error));
@@ -18009,8 +19537,8 @@ class Reference extends Query {
18009
19537
  return result;
18010
19538
  }
18011
19539
  push(value, onComplete) {
18012
- require$$1$3.validateArgCount('Reference.push', 0, 2, arguments.length);
18013
- require$$1$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
19540
+ require$$2$3.validateArgCount('Reference.push', 0, 2, arguments.length);
19541
+ require$$2$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
18014
19542
  const expPromise = push_1(this._delegate, value);
18015
19543
  const promise = expPromise.then(expRef => new Reference(this.database, expRef));
18016
19544
  if (onComplete) {
@@ -18081,7 +19609,7 @@ class Database {
18081
19609
  connectDatabaseEmulator_1(this._delegate, host, port, options);
18082
19610
  }
18083
19611
  ref(path) {
18084
- require$$1$3.validateArgCount('database.ref', 0, 1, arguments.length);
19612
+ require$$2$3.validateArgCount('database.ref', 0, 1, arguments.length);
18085
19613
  if (path instanceof Reference) {
18086
19614
  const childRef = refFromURL_1(this._delegate, path.toString());
18087
19615
  return new Reference(this, childRef);
@@ -18099,17 +19627,17 @@ class Database {
18099
19627
  */
18100
19628
  refFromURL(url) {
18101
19629
  const apiName = 'database.refFromURL';
18102
- require$$1$3.validateArgCount(apiName, 1, 1, arguments.length);
19630
+ require$$2$3.validateArgCount(apiName, 1, 1, arguments.length);
18103
19631
  const childRef = refFromURL_1(this._delegate, url);
18104
19632
  return new Reference(this, childRef);
18105
19633
  }
18106
19634
  // Make individual repo go offline.
18107
19635
  goOffline() {
18108
- require$$1$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
19636
+ require$$2$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
18109
19637
  return goOffline_1(this._delegate);
18110
19638
  }
18111
19639
  goOnline() {
18112
- require$$1$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
19640
+ require$$2$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
18113
19641
  return goOnline_1(this._delegate);
18114
19642
  }
18115
19643
  }
@@ -18129,17 +19657,17 @@ Database.ServerValue = {
18129
19657
  */
18130
19658
  function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
18131
19659
  _setSDKVersion(version);
18132
- const container = new require$$3.ComponentContainer('database-standalone');
19660
+ const container = new require$$0$3.ComponentContainer('database-standalone');
18133
19661
  /**
18134
19662
  * ComponentContainer('database-standalone') is just a placeholder that doesn't perform
18135
19663
  * any actual function.
18136
19664
  */
18137
- const authProvider = new require$$3.Provider('auth-internal', container);
18138
- authProvider.setComponent(new require$$3.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
19665
+ const authProvider = new require$$0$3.Provider('auth-internal', container);
19666
+ authProvider.setComponent(new require$$0$3.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
18139
19667
  let appCheckProvider = undefined;
18140
19668
  if (customAppCheckImpl) {
18141
- appCheckProvider = new require$$3.Provider('app-check-internal', container);
18142
- appCheckProvider.setComponent(new require$$3.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
19669
+ appCheckProvider = new require$$0$3.Provider('app-check-internal', container);
19670
+ appCheckProvider.setComponent(new require$$0$3.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
18143
19671
  }
18144
19672
  return {
18145
19673
  instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
@@ -18148,8 +19676,8 @@ function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImp
18148
19676
  }
18149
19677
 
18150
19678
  var INTERNAL = /*#__PURE__*/Object.freeze({
18151
- __proto__: null,
18152
- initStandalone: initStandalone$1
19679
+ __proto__: null,
19680
+ initStandalone: initStandalone$1
18153
19681
  });
18154
19682
 
18155
19683
  /**
@@ -18179,7 +19707,7 @@ const ServerValue = Database.ServerValue;
18179
19707
  * @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
18180
19708
  */
18181
19709
  function initStandalone(app, url, version, nodeAdmin = true) {
18182
- require$$1$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
19710
+ require$$2$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
18183
19711
  return initStandalone$1({
18184
19712
  app,
18185
19713
  url,