@firebase/database-compat 2.1.5-20260728185501 → 2.1.5-eap-crashlytics.64ada57eb

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.
@@ -10,10 +10,24 @@ var require$$1$1 = require('crypto');
10
10
  var require$$2$1 = require('url');
11
11
  var require$$1$2 = require('net');
12
12
  var require$$2$2 = require('tls');
13
- var require$$1$3 = require('@firebase/util');
14
- var require$$2$3 = require('@firebase/logger');
15
- var require$$3 = require('@firebase/app');
16
- var require$$4 = require('@firebase/component');
13
+ var require$$2$3 = require('@firebase/util');
14
+ var require$$1$3 = require('@firebase/logger');
15
+ var require$$0$2 = require('@firebase/component');
16
+
17
+ function getAugmentedNamespace(n) {
18
+ if (n.__esModule) return n;
19
+ var a = Object.defineProperty({}, '__esModule', {value: true});
20
+ Object.keys(n).forEach(function (k) {
21
+ var d = Object.getOwnPropertyDescriptor(n, k);
22
+ Object.defineProperty(a, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () {
25
+ return n[k];
26
+ }
27
+ });
28
+ });
29
+ return a;
30
+ }
17
31
 
18
32
  var index_standalone = {};
19
33
 
@@ -2216,7 +2230,7 @@ var Buffer$4 = safeBuffer.exports.Buffer,
2216
2230
 
2217
2231
  var PORTS = { 'ws:': 80, 'wss:': 443 };
2218
2232
 
2219
- var Proxy$1 = function(client, origin, options) {
2233
+ var Proxy$2 = function(client, origin, options) {
2220
2234
  this._client = client;
2221
2235
  this._http = new HttpParser$2('response');
2222
2236
  this._origin = (typeof client.url === 'object') ? client.url : url$2.parse(client.url);
@@ -2235,7 +2249,7 @@ var Proxy$1 = function(client, origin, options) {
2235
2249
  var auth = this._url.auth && Buffer$4.from(this._url.auth, 'utf8').toString('base64');
2236
2250
  if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);
2237
2251
  };
2238
- util$9.inherits(Proxy$1, Stream$2);
2252
+ util$9.inherits(Proxy$2, Stream$2);
2239
2253
 
2240
2254
  var instance$6 = {
2241
2255
  setHeader: function(name, value) {
@@ -2300,9 +2314,9 @@ var instance$6 = {
2300
2314
  };
2301
2315
 
2302
2316
  for (var key$6 in instance$6)
2303
- Proxy$1.prototype[key$6] = instance$6[key$6];
2317
+ Proxy$2.prototype[key$6] = instance$6[key$6];
2304
2318
 
2305
- var proxy = Proxy$1;
2319
+ var proxy = Proxy$2;
2306
2320
 
2307
2321
  var Buffer$3 = safeBuffer.exports.Buffer,
2308
2322
  crypto$1 = require$$1$1,
@@ -2311,7 +2325,7 @@ var Buffer$3 = safeBuffer.exports.Buffer,
2311
2325
  HttpParser$1 = http_parser,
2312
2326
  Base$4 = base,
2313
2327
  Hybi$1 = hybi,
2314
- Proxy = proxy;
2328
+ Proxy$1 = proxy;
2315
2329
 
2316
2330
  var Client$2 = function(_url, options) {
2317
2331
  this.version = 'hybi-' + Hybi$1.VERSION;
@@ -2352,7 +2366,7 @@ var instance$5 = {
2352
2366
  VALID_PROTOCOLS: ['ws:', 'wss:'],
2353
2367
 
2354
2368
  proxy: function(origin, options) {
2355
- return new Proxy(this, origin, options);
2369
+ return new Proxy$1(this, origin, options);
2356
2370
  },
2357
2371
 
2358
2372
  start: function() {
@@ -3345,13 +3359,1599 @@ WebSocket$1.EventSource = eventsource;
3345
3359
 
3346
3360
  var websocket = WebSocket$1;
3347
3361
 
3362
+ var index_cjs = {};
3363
+
3364
+ const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
3365
+
3366
+ let idbProxyableTypes;
3367
+ let cursorAdvanceMethods;
3368
+ // This is a function to prevent it throwing up in node environments.
3369
+ function getIdbProxyableTypes() {
3370
+ return (idbProxyableTypes ||
3371
+ (idbProxyableTypes = [
3372
+ IDBDatabase,
3373
+ IDBObjectStore,
3374
+ IDBIndex,
3375
+ IDBCursor,
3376
+ IDBTransaction,
3377
+ ]));
3378
+ }
3379
+ // This is a function to prevent it throwing up in node environments.
3380
+ function getCursorAdvanceMethods() {
3381
+ return (cursorAdvanceMethods ||
3382
+ (cursorAdvanceMethods = [
3383
+ IDBCursor.prototype.advance,
3384
+ IDBCursor.prototype.continue,
3385
+ IDBCursor.prototype.continuePrimaryKey,
3386
+ ]));
3387
+ }
3388
+ const cursorRequestMap = new WeakMap();
3389
+ const transactionDoneMap = new WeakMap();
3390
+ const transactionStoreNamesMap = new WeakMap();
3391
+ const transformCache = new WeakMap();
3392
+ const reverseTransformCache = new WeakMap();
3393
+ function promisifyRequest(request) {
3394
+ const promise = new Promise((resolve, reject) => {
3395
+ const unlisten = () => {
3396
+ request.removeEventListener('success', success);
3397
+ request.removeEventListener('error', error);
3398
+ };
3399
+ const success = () => {
3400
+ resolve(wrap(request.result));
3401
+ unlisten();
3402
+ };
3403
+ const error = () => {
3404
+ reject(request.error);
3405
+ unlisten();
3406
+ };
3407
+ request.addEventListener('success', success);
3408
+ request.addEventListener('error', error);
3409
+ });
3410
+ promise
3411
+ .then((value) => {
3412
+ // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval
3413
+ // (see wrapFunction).
3414
+ if (value instanceof IDBCursor) {
3415
+ cursorRequestMap.set(value, request);
3416
+ }
3417
+ // Catching to avoid "Uncaught Promise exceptions"
3418
+ })
3419
+ .catch(() => { });
3420
+ // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
3421
+ // is because we create many promises from a single IDBRequest.
3422
+ reverseTransformCache.set(promise, request);
3423
+ return promise;
3424
+ }
3425
+ function cacheDonePromiseForTransaction(tx) {
3426
+ // Early bail if we've already created a done promise for this transaction.
3427
+ if (transactionDoneMap.has(tx))
3428
+ return;
3429
+ const done = new Promise((resolve, reject) => {
3430
+ const unlisten = () => {
3431
+ tx.removeEventListener('complete', complete);
3432
+ tx.removeEventListener('error', error);
3433
+ tx.removeEventListener('abort', error);
3434
+ };
3435
+ const complete = () => {
3436
+ resolve();
3437
+ unlisten();
3438
+ };
3439
+ const error = () => {
3440
+ reject(tx.error || new DOMException('AbortError', 'AbortError'));
3441
+ unlisten();
3442
+ };
3443
+ tx.addEventListener('complete', complete);
3444
+ tx.addEventListener('error', error);
3445
+ tx.addEventListener('abort', error);
3446
+ });
3447
+ // Cache it for later retrieval.
3448
+ transactionDoneMap.set(tx, done);
3449
+ }
3450
+ let idbProxyTraps = {
3451
+ get(target, prop, receiver) {
3452
+ if (target instanceof IDBTransaction) {
3453
+ // Special handling for transaction.done.
3454
+ if (prop === 'done')
3455
+ return transactionDoneMap.get(target);
3456
+ // Polyfill for objectStoreNames because of Edge.
3457
+ if (prop === 'objectStoreNames') {
3458
+ return target.objectStoreNames || transactionStoreNamesMap.get(target);
3459
+ }
3460
+ // Make tx.store return the only store in the transaction, or undefined if there are many.
3461
+ if (prop === 'store') {
3462
+ return receiver.objectStoreNames[1]
3463
+ ? undefined
3464
+ : receiver.objectStore(receiver.objectStoreNames[0]);
3465
+ }
3466
+ }
3467
+ // Else transform whatever we get back.
3468
+ return wrap(target[prop]);
3469
+ },
3470
+ set(target, prop, value) {
3471
+ target[prop] = value;
3472
+ return true;
3473
+ },
3474
+ has(target, prop) {
3475
+ if (target instanceof IDBTransaction &&
3476
+ (prop === 'done' || prop === 'store')) {
3477
+ return true;
3478
+ }
3479
+ return prop in target;
3480
+ },
3481
+ };
3482
+ function replaceTraps(callback) {
3483
+ idbProxyTraps = callback(idbProxyTraps);
3484
+ }
3485
+ function wrapFunction(func) {
3486
+ // Due to expected object equality (which is enforced by the caching in `wrap`), we
3487
+ // only create one new func per func.
3488
+ // Edge doesn't support objectStoreNames (booo), so we polyfill it here.
3489
+ if (func === IDBDatabase.prototype.transaction &&
3490
+ !('objectStoreNames' in IDBTransaction.prototype)) {
3491
+ return function (storeNames, ...args) {
3492
+ const tx = func.call(unwrap(this), storeNames, ...args);
3493
+ transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);
3494
+ return wrap(tx);
3495
+ };
3496
+ }
3497
+ // Cursor methods are special, as the behaviour is a little more different to standard IDB. In
3498
+ // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
3499
+ // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
3500
+ // with real promises, so each advance methods returns a new promise for the cursor object, or
3501
+ // undefined if the end of the cursor has been reached.
3502
+ if (getCursorAdvanceMethods().includes(func)) {
3503
+ return function (...args) {
3504
+ // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
3505
+ // the original object.
3506
+ func.apply(unwrap(this), args);
3507
+ return wrap(cursorRequestMap.get(this));
3508
+ };
3509
+ }
3510
+ return function (...args) {
3511
+ // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
3512
+ // the original object.
3513
+ return wrap(func.apply(unwrap(this), args));
3514
+ };
3515
+ }
3516
+ function transformCachableValue(value) {
3517
+ if (typeof value === 'function')
3518
+ return wrapFunction(value);
3519
+ // This doesn't return, it just creates a 'done' promise for the transaction,
3520
+ // which is later returned for transaction.done (see idbObjectHandler).
3521
+ if (value instanceof IDBTransaction)
3522
+ cacheDonePromiseForTransaction(value);
3523
+ if (instanceOfAny(value, getIdbProxyableTypes()))
3524
+ return new Proxy(value, idbProxyTraps);
3525
+ // Return the same value back if we're not going to transform it.
3526
+ return value;
3527
+ }
3528
+ function wrap(value) {
3529
+ // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
3530
+ // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
3531
+ if (value instanceof IDBRequest)
3532
+ return promisifyRequest(value);
3533
+ // If we've already transformed this value before, reuse the transformed value.
3534
+ // This is faster, but it also provides object equality.
3535
+ if (transformCache.has(value))
3536
+ return transformCache.get(value);
3537
+ const newValue = transformCachableValue(value);
3538
+ // Not all types are transformed.
3539
+ // These may be primitive types, so they can't be WeakMap keys.
3540
+ if (newValue !== value) {
3541
+ transformCache.set(value, newValue);
3542
+ reverseTransformCache.set(newValue, value);
3543
+ }
3544
+ return newValue;
3545
+ }
3546
+ const unwrap = (value) => reverseTransformCache.get(value);
3547
+
3548
+ /**
3549
+ * Open a database.
3550
+ *
3551
+ * @param name Name of the database.
3552
+ * @param version Schema version.
3553
+ * @param callbacks Additional callbacks.
3554
+ */
3555
+ function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
3556
+ const request = indexedDB.open(name, version);
3557
+ const openPromise = wrap(request);
3558
+ if (upgrade) {
3559
+ request.addEventListener('upgradeneeded', (event) => {
3560
+ upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
3561
+ });
3562
+ }
3563
+ if (blocked) {
3564
+ request.addEventListener('blocked', (event) => blocked(
3565
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
3566
+ event.oldVersion, event.newVersion, event));
3567
+ }
3568
+ openPromise
3569
+ .then((db) => {
3570
+ if (terminated)
3571
+ db.addEventListener('close', () => terminated());
3572
+ if (blocking) {
3573
+ db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
3574
+ }
3575
+ })
3576
+ .catch(() => { });
3577
+ return openPromise;
3578
+ }
3579
+ /**
3580
+ * Delete a database.
3581
+ *
3582
+ * @param name Name of the database.
3583
+ */
3584
+ function deleteDB(name, { blocked } = {}) {
3585
+ const request = indexedDB.deleteDatabase(name);
3586
+ if (blocked) {
3587
+ request.addEventListener('blocked', (event) => blocked(
3588
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
3589
+ event.oldVersion, event));
3590
+ }
3591
+ return wrap(request).then(() => undefined);
3592
+ }
3593
+
3594
+ const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
3595
+ const writeMethods = ['put', 'add', 'delete', 'clear'];
3596
+ const cachedMethods = new Map();
3597
+ function getMethod(target, prop) {
3598
+ if (!(target instanceof IDBDatabase &&
3599
+ !(prop in target) &&
3600
+ typeof prop === 'string')) {
3601
+ return;
3602
+ }
3603
+ if (cachedMethods.get(prop))
3604
+ return cachedMethods.get(prop);
3605
+ const targetFuncName = prop.replace(/FromIndex$/, '');
3606
+ const useIndex = prop !== targetFuncName;
3607
+ const isWrite = writeMethods.includes(targetFuncName);
3608
+ if (
3609
+ // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
3610
+ !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
3611
+ !(isWrite || readMethods.includes(targetFuncName))) {
3612
+ return;
3613
+ }
3614
+ const method = async function (storeName, ...args) {
3615
+ // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
3616
+ const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
3617
+ let target = tx.store;
3618
+ if (useIndex)
3619
+ target = target.index(args.shift());
3620
+ // Must reject if op rejects.
3621
+ // If it's a write operation, must reject if tx.done rejects.
3622
+ // Must reject with op rejection first.
3623
+ // Must resolve with op value.
3624
+ // Must handle both promises (no unhandled rejections)
3625
+ return (await Promise.all([
3626
+ target[targetFuncName](...args),
3627
+ isWrite && tx.done,
3628
+ ]))[0];
3629
+ };
3630
+ cachedMethods.set(prop, method);
3631
+ return method;
3632
+ }
3633
+ replaceTraps((oldTraps) => ({
3634
+ ...oldTraps,
3635
+ get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
3636
+ has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
3637
+ }));
3638
+
3639
+ var build = /*#__PURE__*/Object.freeze({
3640
+ __proto__: null,
3641
+ deleteDB: deleteDB,
3642
+ openDB: openDB,
3643
+ unwrap: unwrap,
3644
+ wrap: wrap
3645
+ });
3646
+
3647
+ var require$$3 = /*@__PURE__*/getAugmentedNamespace(build);
3648
+
3649
+ (function (exports) {
3650
+
3651
+ Object.defineProperty(exports, '__esModule', { value: true });
3652
+
3653
+ var component = require$$0$2;
3654
+ var logger$1 = require$$1$3;
3655
+ var util = require$$2$3;
3656
+ var idb = require$$3;
3657
+
3658
+ /**
3659
+ * @license
3660
+ * Copyright 2019 Google LLC
3661
+ *
3662
+ * Licensed under the Apache License, Version 2.0 (the "License");
3663
+ * you may not use this file except in compliance with the License.
3664
+ * You may obtain a copy of the License at
3665
+ *
3666
+ * http://www.apache.org/licenses/LICENSE-2.0
3667
+ *
3668
+ * Unless required by applicable law or agreed to in writing, software
3669
+ * distributed under the License is distributed on an "AS IS" BASIS,
3670
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3671
+ * See the License for the specific language governing permissions and
3672
+ * limitations under the License.
3673
+ */
3674
+ class PlatformLoggerServiceImpl {
3675
+ constructor(container) {
3676
+ this.container = container;
3677
+ }
3678
+ // In initial implementation, this will be called by installations on
3679
+ // auth token refresh, and installations will send this string.
3680
+ getPlatformInfoString() {
3681
+ const providers = this.container.getProviders();
3682
+ // Loop through providers and get library/version pairs from any that are
3683
+ // version components.
3684
+ return providers
3685
+ .map(provider => {
3686
+ if (isVersionServiceProvider(provider)) {
3687
+ const service = provider.getImmediate();
3688
+ return `${service.library}/${service.version}`;
3689
+ }
3690
+ else {
3691
+ return null;
3692
+ }
3693
+ })
3694
+ .filter(logString => logString)
3695
+ .join(' ');
3696
+ }
3697
+ }
3698
+ /**
3699
+ *
3700
+ * @param provider check if this provider provides a VersionService
3701
+ *
3702
+ * NOTE: Using Provider<'app-version'> is a hack to indicate that the provider
3703
+ * provides VersionService. The provider is not necessarily a 'app-version'
3704
+ * provider.
3705
+ */
3706
+ function isVersionServiceProvider(provider) {
3707
+ const component = provider.getComponent();
3708
+ return component?.type === "VERSION" /* ComponentType.VERSION */;
3709
+ }
3710
+
3711
+ const name$r = "@firebase/app";
3712
+ const version$1 = "0.16.0-eap-crashlytics.64ada57eb";
3713
+
3714
+ /**
3715
+ * @license
3716
+ * Copyright 2019 Google LLC
3717
+ *
3718
+ * Licensed under the Apache License, Version 2.0 (the "License");
3719
+ * you may not use this file except in compliance with the License.
3720
+ * You may obtain a copy of the License at
3721
+ *
3722
+ * http://www.apache.org/licenses/LICENSE-2.0
3723
+ *
3724
+ * Unless required by applicable law or agreed to in writing, software
3725
+ * distributed under the License is distributed on an "AS IS" BASIS,
3726
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3727
+ * See the License for the specific language governing permissions and
3728
+ * limitations under the License.
3729
+ */
3730
+ const logger = new logger$1.Logger('@firebase/app');
3731
+
3732
+ const name$q = "@firebase/app-compat";
3733
+
3734
+ const name$p = "@firebase/analytics-compat";
3735
+
3736
+ const name$o = "@firebase/analytics";
3737
+
3738
+ const name$n = "@firebase/app-check-compat";
3739
+
3740
+ const name$m = "@firebase/app-check";
3741
+
3742
+ const name$l = "@firebase/auth";
3743
+
3744
+ const name$k = "@firebase/auth-compat";
3745
+
3746
+ const name$j = "@firebase/crashlytics";
3747
+
3748
+ const name$i = "@firebase/database";
3749
+
3750
+ const name$h = "@firebase/data-connect";
3751
+
3752
+ const name$g = "@firebase/database-compat";
3753
+
3754
+ const name$f = "@firebase/functions";
3755
+
3756
+ const name$e = "@firebase/functions-compat";
3757
+
3758
+ const name$d = "@firebase/installations";
3759
+
3760
+ const name$c = "@firebase/installations-compat";
3761
+
3762
+ const name$b = "@firebase/messaging";
3763
+
3764
+ const name$a = "@firebase/messaging-compat";
3765
+
3766
+ const name$9 = "@firebase/performance";
3767
+
3768
+ const name$8 = "@firebase/performance-compat";
3769
+
3770
+ const name$7 = "@firebase/remote-config";
3771
+
3772
+ const name$6 = "@firebase/remote-config-compat";
3773
+
3774
+ const name$5 = "@firebase/storage";
3775
+
3776
+ const name$4 = "@firebase/storage-compat";
3777
+
3778
+ const name$3 = "@firebase/firestore";
3779
+
3780
+ const name$2 = "@firebase/ai";
3781
+
3782
+ const name$1 = "@firebase/firestore-compat";
3783
+
3784
+ const name = "firebase";
3785
+ const version = "12.17.0-eap-crashlytics.64ada57eb";
3786
+
3787
+ /**
3788
+ * @license
3789
+ * Copyright 2019 Google LLC
3790
+ *
3791
+ * Licensed under the Apache License, Version 2.0 (the "License");
3792
+ * you may not use this file except in compliance with the License.
3793
+ * You may obtain a copy of the License at
3794
+ *
3795
+ * http://www.apache.org/licenses/LICENSE-2.0
3796
+ *
3797
+ * Unless required by applicable law or agreed to in writing, software
3798
+ * distributed under the License is distributed on an "AS IS" BASIS,
3799
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3800
+ * See the License for the specific language governing permissions and
3801
+ * limitations under the License.
3802
+ */
3803
+ /**
3804
+ * The default app name
3805
+ *
3806
+ * @internal
3807
+ */
3808
+ const DEFAULT_ENTRY_NAME = '[DEFAULT]';
3809
+ const PLATFORM_LOG_STRING = {
3810
+ [name$r]: 'fire-core',
3811
+ [name$q]: 'fire-core-compat',
3812
+ [name$o]: 'fire-analytics',
3813
+ [name$p]: 'fire-analytics-compat',
3814
+ [name$m]: 'fire-app-check',
3815
+ [name$n]: 'fire-app-check-compat',
3816
+ [name$l]: 'fire-auth',
3817
+ [name$k]: 'fire-auth-compat',
3818
+ [name$j]: 'fire-cls',
3819
+ [name$i]: 'fire-rtdb',
3820
+ [name$h]: 'fire-data-connect',
3821
+ [name$g]: 'fire-rtdb-compat',
3822
+ [name$f]: 'fire-fn',
3823
+ [name$e]: 'fire-fn-compat',
3824
+ [name$d]: 'fire-iid',
3825
+ [name$c]: 'fire-iid-compat',
3826
+ [name$b]: 'fire-fcm',
3827
+ [name$a]: 'fire-fcm-compat',
3828
+ [name$9]: 'fire-perf',
3829
+ [name$8]: 'fire-perf-compat',
3830
+ [name$7]: 'fire-rc',
3831
+ [name$6]: 'fire-rc-compat',
3832
+ [name$5]: 'fire-gcs',
3833
+ [name$4]: 'fire-gcs-compat',
3834
+ [name$3]: 'fire-fst',
3835
+ [name$1]: 'fire-fst-compat',
3836
+ [name$2]: 'fire-vertex',
3837
+ 'fire-js': 'fire-js', // Platform identifier for JS SDK.
3838
+ [name]: 'fire-js-all'
3839
+ };
3840
+
3841
+ /**
3842
+ * @license
3843
+ * Copyright 2019 Google LLC
3844
+ *
3845
+ * Licensed under the Apache License, Version 2.0 (the "License");
3846
+ * you may not use this file except in compliance with the License.
3847
+ * You may obtain a copy of the License at
3848
+ *
3849
+ * http://www.apache.org/licenses/LICENSE-2.0
3850
+ *
3851
+ * Unless required by applicable law or agreed to in writing, software
3852
+ * distributed under the License is distributed on an "AS IS" BASIS,
3853
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3854
+ * See the License for the specific language governing permissions and
3855
+ * limitations under the License.
3856
+ */
3857
+ /**
3858
+ * @internal
3859
+ */
3860
+ const _apps = new Map();
3861
+ /**
3862
+ * @internal
3863
+ */
3864
+ const _serverApps = new Map();
3865
+ /**
3866
+ * Registered components.
3867
+ *
3868
+ * @internal
3869
+ */
3870
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3871
+ const _components = new Map();
3872
+ /**
3873
+ * @param component - the component being added to this app's container
3874
+ *
3875
+ * @internal
3876
+ */
3877
+ function _addComponent(app, component) {
3878
+ try {
3879
+ app.container.addComponent(component);
3880
+ }
3881
+ catch (e) {
3882
+ logger.debug(`Component ${component.name} failed to register with FirebaseApp ${app.name}`, e);
3883
+ }
3884
+ }
3885
+ /**
3886
+ *
3887
+ * @internal
3888
+ */
3889
+ function _addOrOverwriteComponent(app, component) {
3890
+ app.container.addOrOverwriteComponent(component);
3891
+ }
3892
+ /**
3893
+ *
3894
+ * @param component - the component to register
3895
+ * @returns whether or not the component is registered successfully
3896
+ *
3897
+ * @internal
3898
+ */
3899
+ function _registerComponent(component) {
3900
+ const componentName = component.name;
3901
+ if (_components.has(componentName)) {
3902
+ logger.debug(`There were multiple attempts to register component ${componentName}.`);
3903
+ return false;
3904
+ }
3905
+ _components.set(componentName, component);
3906
+ // add the component to existing app instances
3907
+ for (const app of _apps.values()) {
3908
+ _addComponent(app, component);
3909
+ }
3910
+ for (const serverApp of _serverApps.values()) {
3911
+ _addComponent(serverApp, component);
3912
+ }
3913
+ return true;
3914
+ }
3915
+ /**
3916
+ *
3917
+ * @param app - FirebaseApp instance
3918
+ * @param name - service name
3919
+ *
3920
+ * @returns the provider for the service with the matching name
3921
+ *
3922
+ * @internal
3923
+ */
3924
+ function _getProvider(app, name) {
3925
+ const heartbeatController = app.container
3926
+ .getProvider('heartbeat')
3927
+ .getImmediate({ optional: true });
3928
+ if (heartbeatController) {
3929
+ void heartbeatController.triggerHeartbeat();
3930
+ }
3931
+ return app.container.getProvider(name);
3932
+ }
3933
+ /**
3934
+ *
3935
+ * @param app - FirebaseApp instance
3936
+ * @param name - service name
3937
+ * @param instanceIdentifier - service instance identifier in case the service supports multiple instances
3938
+ *
3939
+ * @internal
3940
+ */
3941
+ function _removeServiceInstance(app, name, instanceIdentifier = DEFAULT_ENTRY_NAME) {
3942
+ _getProvider(app, name).clearInstance(instanceIdentifier);
3943
+ }
3944
+ /**
3945
+ *
3946
+ * @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
3947
+ *
3948
+ * @returns true if the provide object is of type FirebaseApp.
3949
+ *
3950
+ * @internal
3951
+ */
3952
+ function _isFirebaseApp(obj) {
3953
+ return obj.options !== undefined;
3954
+ }
3955
+ /**
3956
+ *
3957
+ * @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
3958
+ *
3959
+ * @returns true if the provided object is of type FirebaseServerAppImpl.
3960
+ *
3961
+ * @internal
3962
+ */
3963
+ function _isFirebaseServerAppSettings(obj) {
3964
+ if (_isFirebaseApp(obj)) {
3965
+ return false;
3966
+ }
3967
+ return ('authIdToken' in obj ||
3968
+ 'appCheckToken' in obj ||
3969
+ 'releaseOnDeref' in obj ||
3970
+ 'automaticDataCollectionEnabled' in obj);
3971
+ }
3972
+ /**
3973
+ *
3974
+ * @param obj - an object of type FirebaseApp.
3975
+ *
3976
+ * @returns true if the provided object is of type FirebaseServerAppImpl.
3977
+ *
3978
+ * @internal
3979
+ */
3980
+ function _isFirebaseServerApp(obj) {
3981
+ if (obj === null || obj === undefined) {
3982
+ return false;
3983
+ }
3984
+ return obj.settings !== undefined;
3985
+ }
3986
+ /**
3987
+ * Test only
3988
+ *
3989
+ * @internal
3990
+ */
3991
+ function _clearComponents() {
3992
+ _components.clear();
3993
+ }
3994
+
3995
+ /**
3996
+ * @license
3997
+ * Copyright 2019 Google LLC
3998
+ *
3999
+ * Licensed under the Apache License, Version 2.0 (the "License");
4000
+ * you may not use this file except in compliance with the License.
4001
+ * You may obtain a copy of the License at
4002
+ *
4003
+ * http://www.apache.org/licenses/LICENSE-2.0
4004
+ *
4005
+ * Unless required by applicable law or agreed to in writing, software
4006
+ * distributed under the License is distributed on an "AS IS" BASIS,
4007
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4008
+ * See the License for the specific language governing permissions and
4009
+ * limitations under the License.
4010
+ */
4011
+ const ERRORS = {
4012
+ ["no-app" /* AppError.NO_APP */]: "No Firebase App '{$appName}' has been created - " +
4013
+ 'call initializeApp() first',
4014
+ ["bad-app-name" /* AppError.BAD_APP_NAME */]: "Illegal App name: '{$appName}'",
4015
+ ["duplicate-app" /* AppError.DUPLICATE_APP */]: "Firebase App named '{$appName}' already exists with different {$mismatchedParam}." +
4016
+ " Existing: '{$oldValue}'. New: '{$newValue}'.",
4017
+ ["app-deleted" /* AppError.APP_DELETED */]: "Firebase App named '{$appName}' already deleted",
4018
+ ["server-app-deleted" /* AppError.SERVER_APP_DELETED */]: 'Firebase Server App has been deleted',
4019
+ ["no-options" /* AppError.NO_OPTIONS */]: 'Need to provide options, when not being deployed to hosting via source.',
4020
+ ["invalid-app-argument" /* AppError.INVALID_APP_ARGUMENT */]: 'firebase.{$appName}() takes either no argument or a ' +
4021
+ 'Firebase App instance.',
4022
+ ["invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */]: 'First argument to `onLog` must be null or a function.',
4023
+ ["idb-open" /* AppError.IDB_OPEN */]: 'Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.',
4024
+ ["idb-get" /* AppError.IDB_GET */]: 'Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.',
4025
+ ["idb-set" /* AppError.IDB_WRITE */]: 'Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.',
4026
+ ["idb-delete" /* AppError.IDB_DELETE */]: 'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.',
4027
+ ["finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */]: 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.',
4028
+ ["invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */]: 'FirebaseServerApp is not for use in browser environments.'
4029
+ };
4030
+ const ERROR_FACTORY = new util.ErrorFactory('app', 'Firebase', ERRORS);
4031
+
4032
+ /**
4033
+ * @license
4034
+ * Copyright 2019 Google LLC
4035
+ *
4036
+ * Licensed under the Apache License, Version 2.0 (the "License");
4037
+ * you may not use this file except in compliance with the License.
4038
+ * You may obtain a copy of the License at
4039
+ *
4040
+ * http://www.apache.org/licenses/LICENSE-2.0
4041
+ *
4042
+ * Unless required by applicable law or agreed to in writing, software
4043
+ * distributed under the License is distributed on an "AS IS" BASIS,
4044
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4045
+ * See the License for the specific language governing permissions and
4046
+ * limitations under the License.
4047
+ */
4048
+ class FirebaseAppImpl {
4049
+ constructor(options, config, container) {
4050
+ this._isDeleted = false;
4051
+ this._options = { ...options };
4052
+ this._config = { ...config };
4053
+ this._name = config.name;
4054
+ this._automaticDataCollectionEnabled =
4055
+ config.automaticDataCollectionEnabled;
4056
+ this._container = container;
4057
+ this.container.addComponent(new component.Component('app', () => this, "PUBLIC" /* ComponentType.PUBLIC */));
4058
+ }
4059
+ get automaticDataCollectionEnabled() {
4060
+ this.checkDestroyed();
4061
+ return this._automaticDataCollectionEnabled;
4062
+ }
4063
+ set automaticDataCollectionEnabled(val) {
4064
+ this.checkDestroyed();
4065
+ this._automaticDataCollectionEnabled = val;
4066
+ }
4067
+ get name() {
4068
+ this.checkDestroyed();
4069
+ return this._name;
4070
+ }
4071
+ get options() {
4072
+ this.checkDestroyed();
4073
+ return this._options;
4074
+ }
4075
+ get config() {
4076
+ this.checkDestroyed();
4077
+ return this._config;
4078
+ }
4079
+ get container() {
4080
+ return this._container;
4081
+ }
4082
+ get isDeleted() {
4083
+ return this._isDeleted;
4084
+ }
4085
+ set isDeleted(val) {
4086
+ this._isDeleted = val;
4087
+ }
4088
+ /**
4089
+ * This function will throw an Error if the App has already been deleted -
4090
+ * use before performing API actions on the App.
4091
+ */
4092
+ checkDestroyed() {
4093
+ if (this.isDeleted) {
4094
+ throw ERROR_FACTORY.create("app-deleted" /* AppError.APP_DELETED */, { appName: this._name });
4095
+ }
4096
+ }
4097
+ }
4098
+
4099
+ /**
4100
+ * @license
4101
+ * Copyright 2023 Google LLC
4102
+ *
4103
+ * Licensed under the Apache License, Version 2.0 (the "License");
4104
+ * you may not use this file except in compliance with the License.
4105
+ * You may obtain a copy of the License at
4106
+ *
4107
+ * http://www.apache.org/licenses/LICENSE-2.0
4108
+ *
4109
+ * Unless required by applicable law or agreed to in writing, software
4110
+ * distributed under the License is distributed on an "AS IS" BASIS,
4111
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4112
+ * See the License for the specific language governing permissions and
4113
+ * limitations under the License.
4114
+ */
4115
+ // Parse the token and check to see if the `exp` claim is in the future.
4116
+ // Reports an error to the console if the token or claim could not be parsed, or if `exp` is in
4117
+ // the past.
4118
+ function validateTokenTTL(base64Token, tokenName) {
4119
+ const secondPart = util.base64Decode(base64Token.split('.')[1]);
4120
+ if (secondPart === null) {
4121
+ console.error(`FirebaseServerApp ${tokenName} is invalid: second part could not be parsed.`);
4122
+ return;
4123
+ }
4124
+ const expClaim = JSON.parse(secondPart).exp;
4125
+ if (expClaim === undefined) {
4126
+ console.error(`FirebaseServerApp ${tokenName} is invalid: expiration claim could not be parsed`);
4127
+ return;
4128
+ }
4129
+ const exp = JSON.parse(secondPart).exp * 1000;
4130
+ const now = new Date().getTime();
4131
+ const diff = exp - now;
4132
+ if (diff <= 0) {
4133
+ console.error(`FirebaseServerApp ${tokenName} is invalid: the token has expired.`);
4134
+ }
4135
+ }
4136
+ class FirebaseServerAppImpl extends FirebaseAppImpl {
4137
+ constructor(options, serverConfig, name, container) {
4138
+ // Build configuration parameters for the FirebaseAppImpl base class.
4139
+ const automaticDataCollectionEnabled = serverConfig.automaticDataCollectionEnabled !== undefined
4140
+ ? serverConfig.automaticDataCollectionEnabled
4141
+ : true;
4142
+ // Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
4143
+ const config = {
4144
+ name,
4145
+ automaticDataCollectionEnabled
4146
+ };
4147
+ if (options.apiKey !== undefined) {
4148
+ // Construct the parent FirebaseAppImp object.
4149
+ super(options, config, container);
4150
+ }
4151
+ else {
4152
+ const appImpl = options;
4153
+ super(appImpl.options, config, container);
4154
+ }
4155
+ // Now construct the data for the FirebaseServerAppImpl.
4156
+ this._serverConfig = {
4157
+ automaticDataCollectionEnabled,
4158
+ ...serverConfig
4159
+ };
4160
+ // Ensure that the current time is within the `authIdtoken` window of validity.
4161
+ if (this._serverConfig.authIdToken) {
4162
+ validateTokenTTL(this._serverConfig.authIdToken, 'authIdToken');
4163
+ }
4164
+ // Ensure that the current time is within the `appCheckToken` window of validity.
4165
+ if (this._serverConfig.appCheckToken) {
4166
+ validateTokenTTL(this._serverConfig.appCheckToken, 'appCheckToken');
4167
+ }
4168
+ this._finalizationRegistry = null;
4169
+ if (typeof FinalizationRegistry !== 'undefined') {
4170
+ this._finalizationRegistry = new FinalizationRegistry(() => {
4171
+ this.automaticCleanup();
4172
+ });
4173
+ }
4174
+ this._refCount = 0;
4175
+ this.incRefCount(this._serverConfig.releaseOnDeref);
4176
+ // Do not retain a hard reference to the dref object, otherwise the FinalizationRegistry
4177
+ // will never trigger.
4178
+ this._serverConfig.releaseOnDeref = undefined;
4179
+ serverConfig.releaseOnDeref = undefined;
4180
+ registerVersion(name$r, version$1, 'serverapp');
4181
+ }
4182
+ toJSON() {
4183
+ return undefined;
4184
+ }
4185
+ get refCount() {
4186
+ return this._refCount;
4187
+ }
4188
+ // Increment the reference count of this server app. If an object is provided, register it
4189
+ // with the finalization registry.
4190
+ incRefCount(obj) {
4191
+ if (this.isDeleted) {
4192
+ return;
4193
+ }
4194
+ this._refCount++;
4195
+ if (obj !== undefined && this._finalizationRegistry !== null) {
4196
+ this._finalizationRegistry.register(obj, this);
4197
+ }
4198
+ }
4199
+ // Decrement the reference count.
4200
+ decRefCount() {
4201
+ if (this.isDeleted) {
4202
+ return 0;
4203
+ }
4204
+ return --this._refCount;
4205
+ }
4206
+ // Invoked by the FinalizationRegistry callback to note that this app should go through its
4207
+ // reference counts and delete itself if no reference count remain. The coordinating logic that
4208
+ // handles this is in deleteApp(...).
4209
+ automaticCleanup() {
4210
+ void deleteApp(this);
4211
+ }
4212
+ get settings() {
4213
+ this.checkDestroyed();
4214
+ return this._serverConfig;
4215
+ }
4216
+ /**
4217
+ * This function will throw an Error if the App has already been deleted -
4218
+ * use before performing API actions on the App.
4219
+ */
4220
+ checkDestroyed() {
4221
+ if (this.isDeleted) {
4222
+ throw ERROR_FACTORY.create("server-app-deleted" /* AppError.SERVER_APP_DELETED */);
4223
+ }
4224
+ }
4225
+ }
4226
+
4227
+ /**
4228
+ * @license
4229
+ * Copyright 2019 Google LLC
4230
+ *
4231
+ * Licensed under the Apache License, Version 2.0 (the "License");
4232
+ * you may not use this file except in compliance with the License.
4233
+ * You may obtain a copy of the License at
4234
+ *
4235
+ * http://www.apache.org/licenses/LICENSE-2.0
4236
+ *
4237
+ * Unless required by applicable law or agreed to in writing, software
4238
+ * distributed under the License is distributed on an "AS IS" BASIS,
4239
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4240
+ * See the License for the specific language governing permissions and
4241
+ * limitations under the License.
4242
+ */
4243
+ /**
4244
+ * The current SDK version.
4245
+ *
4246
+ * @public
4247
+ */
4248
+ const SDK_VERSION = version;
4249
+ function initializeApp(_options, rawConfig = {}) {
4250
+ let options = _options;
4251
+ if (typeof rawConfig !== 'object') {
4252
+ const name = rawConfig;
4253
+ rawConfig = { name };
4254
+ }
4255
+ const config = {
4256
+ name: DEFAULT_ENTRY_NAME,
4257
+ automaticDataCollectionEnabled: true,
4258
+ ...rawConfig
4259
+ };
4260
+ const name = config.name;
4261
+ if (typeof name !== 'string' || !name) {
4262
+ throw ERROR_FACTORY.create("bad-app-name" /* AppError.BAD_APP_NAME */, {
4263
+ appName: String(name)
4264
+ });
4265
+ }
4266
+ options || (options = util.getDefaultAppConfig());
4267
+ if (!options) {
4268
+ throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
4269
+ }
4270
+ const existingApp = _apps.get(name);
4271
+ if (existingApp) {
4272
+ // return the existing app if options and config deep equal the ones in the existing app.
4273
+ if (!util.deepEqual(options, existingApp.options)) {
4274
+ throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, {
4275
+ appName: name,
4276
+ mismatchedParam: 'options',
4277
+ oldValue: JSON.stringify(existingApp.options),
4278
+ newValue: JSON.stringify(options)
4279
+ });
4280
+ }
4281
+ else if (!util.deepEqual(config, existingApp.config)) {
4282
+ throw ERROR_FACTORY.create("duplicate-app" /* AppError.DUPLICATE_APP */, {
4283
+ appName: name,
4284
+ mismatchedParam: 'config',
4285
+ oldValue: JSON.stringify(existingApp.config),
4286
+ newValue: JSON.stringify(config)
4287
+ });
4288
+ }
4289
+ else {
4290
+ return existingApp;
4291
+ }
4292
+ }
4293
+ const container = new component.ComponentContainer(name);
4294
+ for (const component of _components.values()) {
4295
+ container.addComponent(component);
4296
+ }
4297
+ const newApp = new FirebaseAppImpl(options, config, container);
4298
+ _apps.set(name, newApp);
4299
+ return newApp;
4300
+ }
4301
+ function initializeServerApp(_options, _serverAppConfig = {}) {
4302
+ if (util.isBrowser() && !util.isWebWorker()) {
4303
+ // FirebaseServerApp isn't designed to be run in browsers.
4304
+ throw ERROR_FACTORY.create("invalid-server-app-environment" /* AppError.INVALID_SERVER_APP_ENVIRONMENT */);
4305
+ }
4306
+ let firebaseOptions;
4307
+ let serverAppSettings = _serverAppConfig || {};
4308
+ if (_options) {
4309
+ if (_isFirebaseApp(_options)) {
4310
+ firebaseOptions = _options.options;
4311
+ }
4312
+ else if (_isFirebaseServerAppSettings(_options)) {
4313
+ serverAppSettings = _options;
4314
+ }
4315
+ else {
4316
+ firebaseOptions = _options;
4317
+ }
4318
+ }
4319
+ if (serverAppSettings.automaticDataCollectionEnabled === undefined) {
4320
+ serverAppSettings.automaticDataCollectionEnabled = true;
4321
+ }
4322
+ firebaseOptions || (firebaseOptions = util.getDefaultAppConfig());
4323
+ if (!firebaseOptions) {
4324
+ throw ERROR_FACTORY.create("no-options" /* AppError.NO_OPTIONS */);
4325
+ }
4326
+ // Build an app name based on a hash of the configuration options.
4327
+ const nameObj = {
4328
+ ...serverAppSettings,
4329
+ ...firebaseOptions
4330
+ };
4331
+ // However, Do not mangle the name based on releaseOnDeref, since it will vary between the
4332
+ // construction of FirebaseServerApp instances. For example, if the object is the request headers.
4333
+ if (nameObj.releaseOnDeref !== undefined) {
4334
+ delete nameObj.releaseOnDeref;
4335
+ }
4336
+ const hashCode = (s) => {
4337
+ return [...s].reduce((hash, c) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0, 0);
4338
+ };
4339
+ if (serverAppSettings.releaseOnDeref !== undefined) {
4340
+ if (typeof FinalizationRegistry === 'undefined') {
4341
+ throw ERROR_FACTORY.create("finalization-registry-not-supported" /* AppError.FINALIZATION_REGISTRY_NOT_SUPPORTED */, {});
4342
+ }
4343
+ }
4344
+ const nameString = '' + hashCode(JSON.stringify(nameObj));
4345
+ const existingApp = _serverApps.get(nameString);
4346
+ if (existingApp) {
4347
+ existingApp.incRefCount(serverAppSettings.releaseOnDeref);
4348
+ return existingApp;
4349
+ }
4350
+ const container = new component.ComponentContainer(nameString);
4351
+ for (const component of _components.values()) {
4352
+ container.addComponent(component);
4353
+ }
4354
+ const newApp = new FirebaseServerAppImpl(firebaseOptions, serverAppSettings, nameString, container);
4355
+ _serverApps.set(nameString, newApp);
4356
+ return newApp;
4357
+ }
4358
+ /**
4359
+ * Retrieves a {@link @firebase/app#FirebaseApp} instance.
4360
+ *
4361
+ * When called with no arguments, the default app is returned. When an app name
4362
+ * is provided, the app corresponding to that name is returned.
4363
+ *
4364
+ * An exception is thrown if the app being retrieved has not yet been
4365
+ * initialized.
4366
+ *
4367
+ * @example
4368
+ * ```javascript
4369
+ * // Return the default app
4370
+ * const app = getApp();
4371
+ * ```
4372
+ *
4373
+ * @example
4374
+ * ```javascript
4375
+ * // Return a named app
4376
+ * const otherApp = getApp("otherApp");
4377
+ * ```
4378
+ *
4379
+ * @param name - Optional name of the app to return. If no name is
4380
+ * provided, the default is `"[DEFAULT]"`.
4381
+ *
4382
+ * @returns The app corresponding to the provided app name.
4383
+ * If no app name is provided, the default app is returned.
4384
+ *
4385
+ * @public
4386
+ */
4387
+ function getApp(name = DEFAULT_ENTRY_NAME) {
4388
+ const app = _apps.get(name);
4389
+ if (!app && name === DEFAULT_ENTRY_NAME && util.getDefaultAppConfig()) {
4390
+ return initializeApp();
4391
+ }
4392
+ if (!app) {
4393
+ throw ERROR_FACTORY.create("no-app" /* AppError.NO_APP */, { appName: name });
4394
+ }
4395
+ return app;
4396
+ }
4397
+ /**
4398
+ * A (read-only) array of all initialized apps.
4399
+ * @public
4400
+ */
4401
+ function getApps() {
4402
+ return Array.from(_apps.values());
4403
+ }
4404
+ /**
4405
+ * Renders this app unusable and frees the resources of all associated
4406
+ * services.
4407
+ *
4408
+ * @example
4409
+ * ```javascript
4410
+ * deleteApp(app)
4411
+ * .then(function() {
4412
+ * console.log("App deleted successfully");
4413
+ * })
4414
+ * .catch(function(error) {
4415
+ * console.log("Error deleting app:", error);
4416
+ * });
4417
+ * ```
4418
+ *
4419
+ * @public
4420
+ */
4421
+ async function deleteApp(app) {
4422
+ let cleanupProviders = false;
4423
+ const name = app.name;
4424
+ if (_apps.has(name)) {
4425
+ cleanupProviders = true;
4426
+ _apps.delete(name);
4427
+ }
4428
+ else if (_serverApps.has(name)) {
4429
+ const firebaseServerApp = app;
4430
+ if (firebaseServerApp.decRefCount() <= 0) {
4431
+ _serverApps.delete(name);
4432
+ cleanupProviders = true;
4433
+ }
4434
+ }
4435
+ if (cleanupProviders) {
4436
+ await Promise.all(app.container
4437
+ .getProviders()
4438
+ .map(provider => provider.delete()));
4439
+ app.isDeleted = true;
4440
+ }
4441
+ }
4442
+ /**
4443
+ * Registers a library's name and version for platform logging purposes.
4444
+ * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
4445
+ * @param version - Current version of that library.
4446
+ * @param variant - Bundle variant, e.g., node, rn, etc.
4447
+ *
4448
+ * @public
4449
+ */
4450
+ function registerVersion(libraryKeyOrName, version, variant) {
4451
+ // TODO: We can use this check to whitelist strings when/if we set up
4452
+ // a good whitelist system.
4453
+ let library = PLATFORM_LOG_STRING[libraryKeyOrName] ?? libraryKeyOrName;
4454
+ if (variant) {
4455
+ library += `-${variant}`;
4456
+ }
4457
+ const libraryMismatch = library.match(/\s|\//);
4458
+ const versionMismatch = version.match(/\s|\//);
4459
+ if (libraryMismatch || versionMismatch) {
4460
+ const warning = [
4461
+ `Unable to register library "${library}" with version "${version}":`
4462
+ ];
4463
+ if (libraryMismatch) {
4464
+ warning.push(`library name "${library}" contains illegal characters (whitespace or "/")`);
4465
+ }
4466
+ if (libraryMismatch && versionMismatch) {
4467
+ warning.push('and');
4468
+ }
4469
+ if (versionMismatch) {
4470
+ warning.push(`version name "${version}" contains illegal characters (whitespace or "/")`);
4471
+ }
4472
+ logger.warn(warning.join(' '));
4473
+ return;
4474
+ }
4475
+ _registerComponent(new component.Component(`${library}-version`, () => ({ library, version }), "VERSION" /* ComponentType.VERSION */));
4476
+ }
4477
+ /**
4478
+ * Sets log handler for all Firebase SDKs.
4479
+ * @param logCallback - An optional custom log handler that executes user code whenever
4480
+ * the Firebase SDK makes a logging call.
4481
+ *
4482
+ * @public
4483
+ */
4484
+ function onLog(logCallback, options) {
4485
+ if (logCallback !== null && typeof logCallback !== 'function') {
4486
+ throw ERROR_FACTORY.create("invalid-log-argument" /* AppError.INVALID_LOG_ARGUMENT */);
4487
+ }
4488
+ logger$1.setUserLogHandler(logCallback, options);
4489
+ }
4490
+ /**
4491
+ * Sets log level for all Firebase SDKs.
4492
+ *
4493
+ * All of the log types above the current log level are captured (i.e. if
4494
+ * you set the log level to `info`, errors are logged, but `debug` and
4495
+ * `verbose` logs are not).
4496
+ *
4497
+ * @public
4498
+ */
4499
+ function setLogLevel(logLevel) {
4500
+ logger$1.setLogLevel(logLevel);
4501
+ }
4502
+
4503
+ /**
4504
+ * @license
4505
+ * Copyright 2021 Google LLC
4506
+ *
4507
+ * Licensed under the Apache License, Version 2.0 (the "License");
4508
+ * you may not use this file except in compliance with the License.
4509
+ * You may obtain a copy of the License at
4510
+ *
4511
+ * http://www.apache.org/licenses/LICENSE-2.0
4512
+ *
4513
+ * Unless required by applicable law or agreed to in writing, software
4514
+ * distributed under the License is distributed on an "AS IS" BASIS,
4515
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4516
+ * See the License for the specific language governing permissions and
4517
+ * limitations under the License.
4518
+ */
4519
+ const DB_NAME = 'firebase-heartbeat-database';
4520
+ const DB_VERSION = 1;
4521
+ const STORE_NAME = 'firebase-heartbeat-store';
4522
+ let dbPromise = null;
4523
+ function getDbPromise() {
4524
+ if (!dbPromise) {
4525
+ dbPromise = idb.openDB(DB_NAME, DB_VERSION, {
4526
+ upgrade: (db, oldVersion) => {
4527
+ // We don't use 'break' in this switch statement, the fall-through
4528
+ // behavior is what we want, because if there are multiple versions between
4529
+ // the old version and the current version, we want ALL the migrations
4530
+ // that correspond to those versions to run, not only the last one.
4531
+ // eslint-disable-next-line default-case
4532
+ switch (oldVersion) {
4533
+ case 0:
4534
+ try {
4535
+ db.createObjectStore(STORE_NAME);
4536
+ }
4537
+ catch (e) {
4538
+ // Safari/iOS browsers throw occasional exceptions on
4539
+ // db.createObjectStore() that may be a bug. Avoid blocking
4540
+ // the rest of the app functionality.
4541
+ console.warn(e);
4542
+ }
4543
+ }
4544
+ }
4545
+ }).catch(e => {
4546
+ throw ERROR_FACTORY.create("idb-open" /* AppError.IDB_OPEN */, {
4547
+ originalErrorMessage: e.message
4548
+ });
4549
+ });
4550
+ }
4551
+ return dbPromise;
4552
+ }
4553
+ async function readHeartbeatsFromIndexedDB(app) {
4554
+ try {
4555
+ const db = await getDbPromise();
4556
+ const tx = db.transaction(STORE_NAME);
4557
+ const result = await tx.objectStore(STORE_NAME).get(computeKey(app));
4558
+ // We already have the value but tx.done can throw,
4559
+ // so we need to await it here to catch errors
4560
+ await tx.done;
4561
+ return result;
4562
+ }
4563
+ catch (e) {
4564
+ if (e instanceof util.FirebaseError) {
4565
+ logger.warn(e.message);
4566
+ }
4567
+ else {
4568
+ const idbGetError = ERROR_FACTORY.create("idb-get" /* AppError.IDB_GET */, {
4569
+ originalErrorMessage: e?.message
4570
+ });
4571
+ logger.warn(idbGetError.message);
4572
+ }
4573
+ }
4574
+ }
4575
+ async function writeHeartbeatsToIndexedDB(app, heartbeatObject) {
4576
+ try {
4577
+ const db = await getDbPromise();
4578
+ const tx = db.transaction(STORE_NAME, 'readwrite');
4579
+ const objectStore = tx.objectStore(STORE_NAME);
4580
+ await objectStore.put(heartbeatObject, computeKey(app));
4581
+ await tx.done;
4582
+ }
4583
+ catch (e) {
4584
+ if (e instanceof util.FirebaseError) {
4585
+ logger.warn(e.message);
4586
+ }
4587
+ else {
4588
+ const idbGetError = ERROR_FACTORY.create("idb-set" /* AppError.IDB_WRITE */, {
4589
+ originalErrorMessage: e?.message
4590
+ });
4591
+ logger.warn(idbGetError.message);
4592
+ }
4593
+ }
4594
+ }
4595
+ function computeKey(app) {
4596
+ return `${app.name}!${app.options.appId}`;
4597
+ }
4598
+
4599
+ /**
4600
+ * @license
4601
+ * Copyright 2021 Google LLC
4602
+ *
4603
+ * Licensed under the Apache License, Version 2.0 (the "License");
4604
+ * you may not use this file except in compliance with the License.
4605
+ * You may obtain a copy of the License at
4606
+ *
4607
+ * http://www.apache.org/licenses/LICENSE-2.0
4608
+ *
4609
+ * Unless required by applicable law or agreed to in writing, software
4610
+ * distributed under the License is distributed on an "AS IS" BASIS,
4611
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4612
+ * See the License for the specific language governing permissions and
4613
+ * limitations under the License.
4614
+ */
4615
+ const MAX_HEADER_BYTES = 1024;
4616
+ const MAX_NUM_STORED_HEARTBEATS = 30;
4617
+ class HeartbeatServiceImpl {
4618
+ constructor(container) {
4619
+ this.container = container;
4620
+ /**
4621
+ * In-memory cache for heartbeats, used by getHeartbeatsHeader() to generate
4622
+ * the header string.
4623
+ * Stores one record per date. This will be consolidated into the standard
4624
+ * format of one record per user agent string before being sent as a header.
4625
+ * Populated from indexedDB when the controller is instantiated and should
4626
+ * be kept in sync with indexedDB.
4627
+ * Leave public for easier testing.
4628
+ */
4629
+ this._heartbeatsCache = null;
4630
+ const app = this.container.getProvider('app').getImmediate();
4631
+ this._storage = new HeartbeatStorageImpl(app);
4632
+ this._heartbeatsCachePromise = this._storage.read().then(result => {
4633
+ this._heartbeatsCache = result;
4634
+ return result;
4635
+ });
4636
+ }
4637
+ /**
4638
+ * Called to report a heartbeat. The function will generate
4639
+ * a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
4640
+ * to IndexedDB.
4641
+ * Note that we only store one heartbeat per day. So if a heartbeat for today is
4642
+ * already logged, subsequent calls to this function in the same day will be ignored.
4643
+ */
4644
+ async triggerHeartbeat() {
4645
+ try {
4646
+ const platformLogger = this.container
4647
+ .getProvider('platform-logger')
4648
+ .getImmediate();
4649
+ // This is the "Firebase user agent" string from the platform logger
4650
+ // service, not the browser user agent.
4651
+ const agent = platformLogger.getPlatformInfoString();
4652
+ const date = getUTCDateString();
4653
+ if (this._heartbeatsCache?.heartbeats == null) {
4654
+ this._heartbeatsCache = await this._heartbeatsCachePromise;
4655
+ // If we failed to construct a heartbeats cache, then return immediately.
4656
+ if (this._heartbeatsCache?.heartbeats == null) {
4657
+ return;
4658
+ }
4659
+ }
4660
+ // Do not store a heartbeat if one is already stored for this day
4661
+ // or if a header has already been sent today.
4662
+ if (this._heartbeatsCache.lastSentHeartbeatDate === date ||
4663
+ this._heartbeatsCache.heartbeats.some(singleDateHeartbeat => singleDateHeartbeat.date === date)) {
4664
+ return;
4665
+ }
4666
+ else {
4667
+ // There is no entry for this date. Create one.
4668
+ this._heartbeatsCache.heartbeats.push({ date, agent });
4669
+ // If the number of stored heartbeats exceeds the maximum number of stored heartbeats, remove the heartbeat with the earliest date.
4670
+ // Since this is executed each time a heartbeat is pushed, the limit can only be exceeded by one, so only one needs to be removed.
4671
+ if (this._heartbeatsCache.heartbeats.length > MAX_NUM_STORED_HEARTBEATS) {
4672
+ const earliestHeartbeatIdx = getEarliestHeartbeatIdx(this._heartbeatsCache.heartbeats);
4673
+ this._heartbeatsCache.heartbeats.splice(earliestHeartbeatIdx, 1);
4674
+ }
4675
+ }
4676
+ return this._storage.overwrite(this._heartbeatsCache);
4677
+ }
4678
+ catch (e) {
4679
+ logger.warn(e);
4680
+ }
4681
+ }
4682
+ /**
4683
+ * Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
4684
+ * It also clears all heartbeats from memory as well as in IndexedDB.
4685
+ *
4686
+ * NOTE: Consuming product SDKs should not send the header if this method
4687
+ * returns an empty string.
4688
+ */
4689
+ async getHeartbeatsHeader() {
4690
+ try {
4691
+ if (this._heartbeatsCache === null) {
4692
+ await this._heartbeatsCachePromise;
4693
+ }
4694
+ // If it's still null or the array is empty, there is no data to send.
4695
+ if (this._heartbeatsCache?.heartbeats == null ||
4696
+ this._heartbeatsCache.heartbeats.length === 0) {
4697
+ return '';
4698
+ }
4699
+ const date = getUTCDateString();
4700
+ // Extract as many heartbeats from the cache as will fit under the size limit.
4701
+ const { heartbeatsToSend, unsentEntries } = extractHeartbeatsForHeader(this._heartbeatsCache.heartbeats);
4702
+ const headerString = util.base64urlEncodeWithoutPadding(JSON.stringify({ version: 2, heartbeats: heartbeatsToSend }));
4703
+ // Store last sent date to prevent another being logged/sent for the same day.
4704
+ this._heartbeatsCache.lastSentHeartbeatDate = date;
4705
+ if (unsentEntries.length > 0) {
4706
+ // Store any unsent entries if they exist.
4707
+ this._heartbeatsCache.heartbeats = unsentEntries;
4708
+ // This seems more likely than emptying the array (below) to lead to some odd state
4709
+ // since the cache isn't empty and this will be called again on the next request,
4710
+ // and is probably safest if we await it.
4711
+ await this._storage.overwrite(this._heartbeatsCache);
4712
+ }
4713
+ else {
4714
+ this._heartbeatsCache.heartbeats = [];
4715
+ // Do not wait for this, to reduce latency.
4716
+ void this._storage.overwrite(this._heartbeatsCache);
4717
+ }
4718
+ return headerString;
4719
+ }
4720
+ catch (e) {
4721
+ logger.warn(e);
4722
+ return '';
4723
+ }
4724
+ }
4725
+ }
4726
+ function getUTCDateString() {
4727
+ const today = new Date();
4728
+ // Returns date format 'YYYY-MM-DD'
4729
+ return today.toISOString().substring(0, 10);
4730
+ }
4731
+ function extractHeartbeatsForHeader(heartbeatsCache, maxSize = MAX_HEADER_BYTES) {
4732
+ // Heartbeats grouped by user agent in the standard format to be sent in
4733
+ // the header.
4734
+ const heartbeatsToSend = [];
4735
+ // Single date format heartbeats that are not sent.
4736
+ let unsentEntries = heartbeatsCache.slice();
4737
+ for (const singleDateHeartbeat of heartbeatsCache) {
4738
+ // Look for an existing entry with the same user agent.
4739
+ const heartbeatEntry = heartbeatsToSend.find(hb => hb.agent === singleDateHeartbeat.agent);
4740
+ if (!heartbeatEntry) {
4741
+ // If no entry for this user agent exists, create one.
4742
+ heartbeatsToSend.push({
4743
+ agent: singleDateHeartbeat.agent,
4744
+ dates: [singleDateHeartbeat.date]
4745
+ });
4746
+ if (countBytes(heartbeatsToSend) > maxSize) {
4747
+ // If the header would exceed max size, remove the added heartbeat
4748
+ // entry and stop adding to the header.
4749
+ heartbeatsToSend.pop();
4750
+ break;
4751
+ }
4752
+ }
4753
+ else {
4754
+ heartbeatEntry.dates.push(singleDateHeartbeat.date);
4755
+ // If the header would exceed max size, remove the added date
4756
+ // and stop adding to the header.
4757
+ if (countBytes(heartbeatsToSend) > maxSize) {
4758
+ heartbeatEntry.dates.pop();
4759
+ break;
4760
+ }
4761
+ }
4762
+ // Pop unsent entry from queue. (Skipped if adding the entry exceeded
4763
+ // quota and the loop breaks early.)
4764
+ unsentEntries = unsentEntries.slice(1);
4765
+ }
4766
+ return {
4767
+ heartbeatsToSend,
4768
+ unsentEntries
4769
+ };
4770
+ }
4771
+ class HeartbeatStorageImpl {
4772
+ constructor(app) {
4773
+ this.app = app;
4774
+ this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
4775
+ }
4776
+ async runIndexedDBEnvironmentCheck() {
4777
+ if (!util.isIndexedDBAvailable()) {
4778
+ return false;
4779
+ }
4780
+ else {
4781
+ return util.validateIndexedDBOpenable()
4782
+ .then(() => true)
4783
+ .catch(() => false);
4784
+ }
4785
+ }
4786
+ /**
4787
+ * Read all heartbeats.
4788
+ */
4789
+ async read() {
4790
+ const canUseIndexedDB = await this._canUseIndexedDBPromise;
4791
+ if (!canUseIndexedDB) {
4792
+ return { heartbeats: [] };
4793
+ }
4794
+ else {
4795
+ const idbHeartbeatObject = await readHeartbeatsFromIndexedDB(this.app);
4796
+ if (idbHeartbeatObject?.heartbeats) {
4797
+ return idbHeartbeatObject;
4798
+ }
4799
+ else {
4800
+ return { heartbeats: [] };
4801
+ }
4802
+ }
4803
+ }
4804
+ // overwrite the storage with the provided heartbeats
4805
+ async overwrite(heartbeatsObject) {
4806
+ const canUseIndexedDB = await this._canUseIndexedDBPromise;
4807
+ if (!canUseIndexedDB) {
4808
+ return;
4809
+ }
4810
+ else {
4811
+ const existingHeartbeatsObject = await this.read();
4812
+ return writeHeartbeatsToIndexedDB(this.app, {
4813
+ lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
4814
+ existingHeartbeatsObject.lastSentHeartbeatDate,
4815
+ heartbeats: heartbeatsObject.heartbeats
4816
+ });
4817
+ }
4818
+ }
4819
+ // add heartbeats
4820
+ async add(heartbeatsObject) {
4821
+ const canUseIndexedDB = await this._canUseIndexedDBPromise;
4822
+ if (!canUseIndexedDB) {
4823
+ return;
4824
+ }
4825
+ else {
4826
+ const existingHeartbeatsObject = await this.read();
4827
+ return writeHeartbeatsToIndexedDB(this.app, {
4828
+ lastSentHeartbeatDate: heartbeatsObject.lastSentHeartbeatDate ??
4829
+ existingHeartbeatsObject.lastSentHeartbeatDate,
4830
+ heartbeats: [
4831
+ ...existingHeartbeatsObject.heartbeats,
4832
+ ...heartbeatsObject.heartbeats
4833
+ ]
4834
+ });
4835
+ }
4836
+ }
4837
+ }
4838
+ /**
4839
+ * Calculate bytes of a HeartbeatsByUserAgent array after being wrapped
4840
+ * in a platform logging header JSON object, stringified, and converted
4841
+ * to base 64.
4842
+ */
4843
+ function countBytes(heartbeatsCache) {
4844
+ // base64 has a restricted set of characters, all of which should be 1 byte.
4845
+ return util.base64urlEncodeWithoutPadding(
4846
+ // heartbeatsCache wrapper properties
4847
+ JSON.stringify({ version: 2, heartbeats: heartbeatsCache })).length;
4848
+ }
4849
+ /**
4850
+ * Returns the index of the heartbeat with the earliest date.
4851
+ * If the heartbeats array is empty, -1 is returned.
4852
+ */
4853
+ function getEarliestHeartbeatIdx(heartbeats) {
4854
+ if (heartbeats.length === 0) {
4855
+ return -1;
4856
+ }
4857
+ let earliestHeartbeatIdx = 0;
4858
+ let earliestHeartbeatDate = heartbeats[0].date;
4859
+ for (let i = 1; i < heartbeats.length; i++) {
4860
+ if (heartbeats[i].date < earliestHeartbeatDate) {
4861
+ earliestHeartbeatDate = heartbeats[i].date;
4862
+ earliestHeartbeatIdx = i;
4863
+ }
4864
+ }
4865
+ return earliestHeartbeatIdx;
4866
+ }
4867
+
4868
+ /**
4869
+ * @license
4870
+ * Copyright 2019 Google LLC
4871
+ *
4872
+ * Licensed under the Apache License, Version 2.0 (the "License");
4873
+ * you may not use this file except in compliance with the License.
4874
+ * You may obtain a copy of the License at
4875
+ *
4876
+ * http://www.apache.org/licenses/LICENSE-2.0
4877
+ *
4878
+ * Unless required by applicable law or agreed to in writing, software
4879
+ * distributed under the License is distributed on an "AS IS" BASIS,
4880
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4881
+ * See the License for the specific language governing permissions and
4882
+ * limitations under the License.
4883
+ */
4884
+ function registerCoreComponents(variant) {
4885
+ _registerComponent(new component.Component('platform-logger', container => new PlatformLoggerServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
4886
+ _registerComponent(new component.Component('heartbeat', container => new HeartbeatServiceImpl(container), "PRIVATE" /* ComponentType.PRIVATE */));
4887
+ // Register `app` package.
4888
+ registerVersion(name$r, version$1, variant);
4889
+ // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
4890
+ registerVersion(name$r, version$1, 'cjs2020');
4891
+ // Register platform SDK identifier (no version).
4892
+ registerVersion('fire-js', '');
4893
+ }
4894
+
4895
+ /**
4896
+ * Firebase App
4897
+ *
4898
+ * @remarks This package coordinates the communication between the different Firebase components
4899
+ * @packageDocumentation
4900
+ */
4901
+ /**
4902
+ * @license
4903
+ * Copyright 2019 Google LLC
4904
+ *
4905
+ * Licensed under the Apache License, Version 2.0 (the "License");
4906
+ * you may not use this file except in compliance with the License.
4907
+ * You may obtain a copy of the License at
4908
+ *
4909
+ * http://www.apache.org/licenses/LICENSE-2.0
4910
+ *
4911
+ * Unless required by applicable law or agreed to in writing, software
4912
+ * distributed under the License is distributed on an "AS IS" BASIS,
4913
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4914
+ * See the License for the specific language governing permissions and
4915
+ * limitations under the License.
4916
+ */
4917
+ registerCoreComponents('node');
4918
+
4919
+ Object.defineProperty(exports, "FirebaseError", {
4920
+ enumerable: true,
4921
+ get: function () { return util.FirebaseError; }
4922
+ });
4923
+ exports.SDK_VERSION = SDK_VERSION;
4924
+ exports._DEFAULT_ENTRY_NAME = DEFAULT_ENTRY_NAME;
4925
+ exports._addComponent = _addComponent;
4926
+ exports._addOrOverwriteComponent = _addOrOverwriteComponent;
4927
+ exports._apps = _apps;
4928
+ exports._clearComponents = _clearComponents;
4929
+ exports._components = _components;
4930
+ exports._getProvider = _getProvider;
4931
+ exports._isFirebaseApp = _isFirebaseApp;
4932
+ exports._isFirebaseServerApp = _isFirebaseServerApp;
4933
+ exports._isFirebaseServerAppSettings = _isFirebaseServerAppSettings;
4934
+ exports._registerComponent = _registerComponent;
4935
+ exports._removeServiceInstance = _removeServiceInstance;
4936
+ exports._serverApps = _serverApps;
4937
+ exports.deleteApp = deleteApp;
4938
+ exports.getApp = getApp;
4939
+ exports.getApps = getApps;
4940
+ exports.initializeApp = initializeApp;
4941
+ exports.initializeServerApp = initializeServerApp;
4942
+ exports.onLog = onLog;
4943
+ exports.registerVersion = registerVersion;
4944
+ exports.setLogLevel = setLogLevel;
4945
+
4946
+ }(index_cjs));
4947
+
3348
4948
  Object.defineProperty(index_standalone, '__esModule', { value: true });
3349
4949
 
3350
4950
  var Websocket = websocket;
3351
- var util = require$$1$3;
3352
- var logger$1 = require$$2$3;
3353
- var app = require$$3;
3354
- var component = require$$4;
4951
+ var util = require$$2$3;
4952
+ var logger$1 = require$$1$3;
4953
+ var app = index_cjs;
4954
+ var component = require$$0$2;
3355
4955
 
3356
4956
  /**
3357
4957
  * @license
@@ -17394,7 +18994,7 @@ var update_1 = index_standalone.update = update;
17394
18994
  * See the License for the specific language governing permissions and
17395
18995
  * limitations under the License.
17396
18996
  */
17397
- const logClient = new require$$2$3.Logger('@firebase/database-compat');
18997
+ const logClient = new require$$1$3.Logger('@firebase/database-compat');
17398
18998
  const warn = function (msg) {
17399
18999
  const message = 'FIREBASE WARNING: ' + msg;
17400
19000
  logClient.warn(message);
@@ -17421,7 +19021,7 @@ const validateBoolean = function (fnName, argumentName, bool, optional) {
17421
19021
  return;
17422
19022
  }
17423
19023
  if (typeof bool !== 'boolean') {
17424
- throw new Error(require$$1$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
19024
+ throw new Error(require$$2$3.errorPrefix(fnName, argumentName) + 'must be a boolean.');
17425
19025
  }
17426
19026
  };
17427
19027
  const validateEventType = function (fnName, eventType, optional) {
@@ -17436,7 +19036,7 @@ const validateEventType = function (fnName, eventType, optional) {
17436
19036
  case 'child_moved':
17437
19037
  break;
17438
19038
  default:
17439
- throw new Error(require$$1$3.errorPrefix(fnName, 'eventType') +
19039
+ throw new Error(require$$2$3.errorPrefix(fnName, 'eventType') +
17440
19040
  'must be a valid event type = "value", "child_added", "child_removed", ' +
17441
19041
  '"child_changed", or "child_moved".');
17442
19042
  }
@@ -17463,8 +19063,8 @@ class OnDisconnect {
17463
19063
  this._delegate = _delegate;
17464
19064
  }
17465
19065
  cancel(onComplete) {
17466
- require$$1$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
17467
- require$$1$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
19066
+ require$$2$3.validateArgCount('OnDisconnect.cancel', 0, 1, arguments.length);
19067
+ require$$2$3.validateCallback('OnDisconnect.cancel', 'onComplete', onComplete, true);
17468
19068
  const result = this._delegate.cancel();
17469
19069
  if (onComplete) {
17470
19070
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17472,8 +19072,8 @@ class OnDisconnect {
17472
19072
  return result;
17473
19073
  }
17474
19074
  remove(onComplete) {
17475
- require$$1$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
17476
- require$$1$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
19075
+ require$$2$3.validateArgCount('OnDisconnect.remove', 0, 1, arguments.length);
19076
+ require$$2$3.validateCallback('OnDisconnect.remove', 'onComplete', onComplete, true);
17477
19077
  const result = this._delegate.remove();
17478
19078
  if (onComplete) {
17479
19079
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17481,8 +19081,8 @@ class OnDisconnect {
17481
19081
  return result;
17482
19082
  }
17483
19083
  set(value, onComplete) {
17484
- require$$1$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
17485
- require$$1$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
19084
+ require$$2$3.validateArgCount('OnDisconnect.set', 1, 2, arguments.length);
19085
+ require$$2$3.validateCallback('OnDisconnect.set', 'onComplete', onComplete, true);
17486
19086
  const result = this._delegate.set(value);
17487
19087
  if (onComplete) {
17488
19088
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17490,8 +19090,8 @@ class OnDisconnect {
17490
19090
  return result;
17491
19091
  }
17492
19092
  setWithPriority(value, priority, onComplete) {
17493
- require$$1$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
17494
- require$$1$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
19093
+ require$$2$3.validateArgCount('OnDisconnect.setWithPriority', 2, 3, arguments.length);
19094
+ require$$2$3.validateCallback('OnDisconnect.setWithPriority', 'onComplete', onComplete, true);
17495
19095
  const result = this._delegate.setWithPriority(value, priority);
17496
19096
  if (onComplete) {
17497
19097
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17499,7 +19099,7 @@ class OnDisconnect {
17499
19099
  return result;
17500
19100
  }
17501
19101
  update(objectToMerge, onComplete) {
17502
- require$$1$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
19102
+ require$$2$3.validateArgCount('OnDisconnect.update', 1, 2, arguments.length);
17503
19103
  if (Array.isArray(objectToMerge)) {
17504
19104
  const newObjectToMerge = {};
17505
19105
  for (let i = 0; i < objectToMerge.length; ++i) {
@@ -17509,7 +19109,7 @@ class OnDisconnect {
17509
19109
  warn('Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the ' +
17510
19110
  'existing data, or an Object with integer keys if you really do want to only update some of the children.');
17511
19111
  }
17512
- require$$1$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
19112
+ require$$2$3.validateCallback('OnDisconnect.update', 'onComplete', onComplete, true);
17513
19113
  const result = this._delegate.update(objectToMerge);
17514
19114
  if (onComplete) {
17515
19115
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17545,7 +19145,7 @@ class TransactionResult {
17545
19145
  // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
17546
19146
  // for end-users
17547
19147
  toJSON() {
17548
- require$$1$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
19148
+ require$$2$3.validateArgCount('TransactionResult.toJSON', 0, 1, arguments.length);
17549
19149
  return { committed: this.committed, snapshot: this.snapshot.toJSON() };
17550
19150
  }
17551
19151
  }
@@ -17582,7 +19182,7 @@ class DataSnapshot {
17582
19182
  * @returns JSON representation of the DataSnapshot contents, or null if empty.
17583
19183
  */
17584
19184
  val() {
17585
- require$$1$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
19185
+ require$$2$3.validateArgCount('DataSnapshot.val', 0, 0, arguments.length);
17586
19186
  return this._delegate.val();
17587
19187
  }
17588
19188
  /**
@@ -17591,14 +19191,14 @@ class DataSnapshot {
17591
19191
  * @returns JSON representation of the DataSnapshot contents, or null if empty.
17592
19192
  */
17593
19193
  exportVal() {
17594
- require$$1$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
19194
+ require$$2$3.validateArgCount('DataSnapshot.exportVal', 0, 0, arguments.length);
17595
19195
  return this._delegate.exportVal();
17596
19196
  }
17597
19197
  // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
17598
19198
  // for end-users
17599
19199
  toJSON() {
17600
19200
  // Optional spacer argument is unnecessary because we're depending on recursion rather than stringifying the content
17601
- require$$1$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
19201
+ require$$2$3.validateArgCount('DataSnapshot.toJSON', 0, 1, arguments.length);
17602
19202
  return this._delegate.toJSON();
17603
19203
  }
17604
19204
  /**
@@ -17607,7 +19207,7 @@ class DataSnapshot {
17607
19207
  * @returns Whether the snapshot contains a non-null value, or is empty.
17608
19208
  */
17609
19209
  exists() {
17610
- require$$1$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
19210
+ require$$2$3.validateArgCount('DataSnapshot.exists', 0, 0, arguments.length);
17611
19211
  return this._delegate.exists();
17612
19212
  }
17613
19213
  /**
@@ -17617,7 +19217,7 @@ class DataSnapshot {
17617
19217
  * @returns DataSnapshot for child node.
17618
19218
  */
17619
19219
  child(path) {
17620
- require$$1$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
19220
+ require$$2$3.validateArgCount('DataSnapshot.child', 0, 1, arguments.length);
17621
19221
  // Ensure the childPath is a string (can be a number)
17622
19222
  path = String(path);
17623
19223
  _validatePathString('DataSnapshot.child', 'path', path, false);
@@ -17630,7 +19230,7 @@ class DataSnapshot {
17630
19230
  * @returns Whether the child exists.
17631
19231
  */
17632
19232
  hasChild(path) {
17633
- require$$1$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
19233
+ require$$2$3.validateArgCount('DataSnapshot.hasChild', 1, 1, arguments.length);
17634
19234
  _validatePathString('DataSnapshot.hasChild', 'path', path, false);
17635
19235
  return this._delegate.hasChild(path);
17636
19236
  }
@@ -17640,7 +19240,7 @@ class DataSnapshot {
17640
19240
  * @returns The priority.
17641
19241
  */
17642
19242
  getPriority() {
17643
- require$$1$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
19243
+ require$$2$3.validateArgCount('DataSnapshot.getPriority', 0, 0, arguments.length);
17644
19244
  return this._delegate.priority;
17645
19245
  }
17646
19246
  /**
@@ -17652,8 +19252,8 @@ class DataSnapshot {
17652
19252
  * one of the child nodes.
17653
19253
  */
17654
19254
  forEach(action) {
17655
- require$$1$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
17656
- require$$1$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
19255
+ require$$2$3.validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
19256
+ require$$2$3.validateCallback('DataSnapshot.forEach', 'action', action, false);
17657
19257
  return this._delegate.forEach(expDataSnapshot => action(new DataSnapshot(this._database, expDataSnapshot)));
17658
19258
  }
17659
19259
  /**
@@ -17661,7 +19261,7 @@ class DataSnapshot {
17661
19261
  * @returns True if the DataSnapshot contains 1 or more child nodes.
17662
19262
  */
17663
19263
  hasChildren() {
17664
- require$$1$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
19264
+ require$$2$3.validateArgCount('DataSnapshot.hasChildren', 0, 0, arguments.length);
17665
19265
  return this._delegate.hasChildren();
17666
19266
  }
17667
19267
  get key() {
@@ -17672,7 +19272,7 @@ class DataSnapshot {
17672
19272
  * @returns The number of children that this DataSnapshot contains.
17673
19273
  */
17674
19274
  numChildren() {
17675
- require$$1$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
19275
+ require$$2$3.validateArgCount('DataSnapshot.numChildren', 0, 0, arguments.length);
17676
19276
  return this._delegate.size;
17677
19277
  }
17678
19278
  /**
@@ -17680,7 +19280,7 @@ class DataSnapshot {
17680
19280
  * from.
17681
19281
  */
17682
19282
  getRef() {
17683
- require$$1$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
19283
+ require$$2$3.validateArgCount('DataSnapshot.ref', 0, 0, arguments.length);
17684
19284
  return new Reference(this._database, this._delegate.ref);
17685
19285
  }
17686
19286
  get ref() {
@@ -17699,8 +19299,8 @@ class Query {
17699
19299
  this._delegate = _delegate;
17700
19300
  }
17701
19301
  on(eventType, callback, cancelCallbackOrContext, context) {
17702
- require$$1$3.validateArgCount('Query.on', 2, 4, arguments.length);
17703
- require$$1$3.validateCallback('Query.on', 'callback', callback, false);
19302
+ require$$2$3.validateArgCount('Query.on', 2, 4, arguments.length);
19303
+ require$$2$3.validateCallback('Query.on', 'callback', callback, false);
17704
19304
  const ret = Query.getCancelAndContextArgs_('Query.on', cancelCallbackOrContext, context);
17705
19305
  const valueCallback = (expSnapshot, previousChildName) => {
17706
19306
  callback.call(ret.context, new DataSnapshot(this.database, expSnapshot), previousChildName);
@@ -17725,16 +19325,16 @@ class Query {
17725
19325
  onChildMoved_1(this._delegate, valueCallback, cancelCallback);
17726
19326
  return callback;
17727
19327
  default:
17728
- throw new Error(require$$1$3.errorPrefix('Query.on', 'eventType') +
19328
+ throw new Error(require$$2$3.errorPrefix('Query.on', 'eventType') +
17729
19329
  'must be a valid event type = "value", "child_added", "child_removed", ' +
17730
19330
  '"child_changed", or "child_moved".');
17731
19331
  }
17732
19332
  }
17733
19333
  off(eventType, callback, context) {
17734
- require$$1$3.validateArgCount('Query.off', 0, 3, arguments.length);
19334
+ require$$2$3.validateArgCount('Query.off', 0, 3, arguments.length);
17735
19335
  validateEventType('Query.off', eventType);
17736
- require$$1$3.validateCallback('Query.off', 'callback', callback, true);
17737
- require$$1$3.validateContextObject('Query.off', 'context', context, true);
19336
+ require$$2$3.validateCallback('Query.off', 'callback', callback, true);
19337
+ require$$2$3.validateContextObject('Query.off', 'context', context, true);
17738
19338
  if (callback) {
17739
19339
  const valueCallback = () => { };
17740
19340
  valueCallback.userCallback = callback;
@@ -17757,10 +19357,10 @@ class Query {
17757
19357
  * Attaches a listener, waits for the first event, and then removes the listener
17758
19358
  */
17759
19359
  once(eventType, callback, failureCallbackOrContext, context) {
17760
- require$$1$3.validateArgCount('Query.once', 1, 4, arguments.length);
17761
- require$$1$3.validateCallback('Query.once', 'callback', callback, true);
19360
+ require$$2$3.validateArgCount('Query.once', 1, 4, arguments.length);
19361
+ require$$2$3.validateCallback('Query.once', 'callback', callback, true);
17762
19362
  const ret = Query.getCancelAndContextArgs_('Query.once', failureCallbackOrContext, context);
17763
- const deferred = new require$$1$3.Deferred();
19363
+ const deferred = new require$$2$3.Deferred();
17764
19364
  const valueCallback = (expSnapshot, previousChildName) => {
17765
19365
  const result = new DataSnapshot(this.database, expSnapshot);
17766
19366
  if (callback) {
@@ -17803,7 +19403,7 @@ class Query {
17803
19403
  });
17804
19404
  break;
17805
19405
  default:
17806
- throw new Error(require$$1$3.errorPrefix('Query.once', 'eventType') +
19406
+ throw new Error(require$$2$3.errorPrefix('Query.once', 'eventType') +
17807
19407
  'must be a valid event type = "value", "child_added", "child_removed", ' +
17808
19408
  '"child_changed", or "child_moved".');
17809
19409
  }
@@ -17813,58 +19413,58 @@ class Query {
17813
19413
  * Set a limit and anchor it to the start of the window.
17814
19414
  */
17815
19415
  limitToFirst(limit) {
17816
- require$$1$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
19416
+ require$$2$3.validateArgCount('Query.limitToFirst', 1, 1, arguments.length);
17817
19417
  return new Query(this.database, query_1(this._delegate, limitToFirst_1(limit)));
17818
19418
  }
17819
19419
  /**
17820
19420
  * Set a limit and anchor it to the end of the window.
17821
19421
  */
17822
19422
  limitToLast(limit) {
17823
- require$$1$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
19423
+ require$$2$3.validateArgCount('Query.limitToLast', 1, 1, arguments.length);
17824
19424
  return new Query(this.database, query_1(this._delegate, limitToLast_1(limit)));
17825
19425
  }
17826
19426
  /**
17827
19427
  * Given a child path, return a new query ordered by the specified grandchild path.
17828
19428
  */
17829
19429
  orderByChild(path) {
17830
- require$$1$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
19430
+ require$$2$3.validateArgCount('Query.orderByChild', 1, 1, arguments.length);
17831
19431
  return new Query(this.database, query_1(this._delegate, orderByChild_1(path)));
17832
19432
  }
17833
19433
  /**
17834
19434
  * Return a new query ordered by the KeyIndex
17835
19435
  */
17836
19436
  orderByKey() {
17837
- require$$1$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
19437
+ require$$2$3.validateArgCount('Query.orderByKey', 0, 0, arguments.length);
17838
19438
  return new Query(this.database, query_1(this._delegate, orderByKey_1()));
17839
19439
  }
17840
19440
  /**
17841
19441
  * Return a new query ordered by the PriorityIndex
17842
19442
  */
17843
19443
  orderByPriority() {
17844
- require$$1$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
19444
+ require$$2$3.validateArgCount('Query.orderByPriority', 0, 0, arguments.length);
17845
19445
  return new Query(this.database, query_1(this._delegate, orderByPriority_1()));
17846
19446
  }
17847
19447
  /**
17848
19448
  * Return a new query ordered by the ValueIndex
17849
19449
  */
17850
19450
  orderByValue() {
17851
- require$$1$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
19451
+ require$$2$3.validateArgCount('Query.orderByValue', 0, 0, arguments.length);
17852
19452
  return new Query(this.database, query_1(this._delegate, orderByValue_1()));
17853
19453
  }
17854
19454
  startAt(value = null, name) {
17855
- require$$1$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
19455
+ require$$2$3.validateArgCount('Query.startAt', 0, 2, arguments.length);
17856
19456
  return new Query(this.database, query_1(this._delegate, startAt_1(value, name)));
17857
19457
  }
17858
19458
  startAfter(value = null, name) {
17859
- require$$1$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
19459
+ require$$2$3.validateArgCount('Query.startAfter', 0, 2, arguments.length);
17860
19460
  return new Query(this.database, query_1(this._delegate, startAfter_1(value, name)));
17861
19461
  }
17862
19462
  endAt(value = null, name) {
17863
- require$$1$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
19463
+ require$$2$3.validateArgCount('Query.endAt', 0, 2, arguments.length);
17864
19464
  return new Query(this.database, query_1(this._delegate, endAt_1(value, name)));
17865
19465
  }
17866
19466
  endBefore(value = null, name) {
17867
- require$$1$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
19467
+ require$$2$3.validateArgCount('Query.endBefore', 0, 2, arguments.length);
17868
19468
  return new Query(this.database, query_1(this._delegate, endBefore_1(value, name)));
17869
19469
  }
17870
19470
  /**
@@ -17872,28 +19472,28 @@ class Query {
17872
19472
  * the specified name.
17873
19473
  */
17874
19474
  equalTo(value, name) {
17875
- require$$1$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
19475
+ require$$2$3.validateArgCount('Query.equalTo', 1, 2, arguments.length);
17876
19476
  return new Query(this.database, query_1(this._delegate, equalTo_1(value, name)));
17877
19477
  }
17878
19478
  /**
17879
19479
  * @returns URL for this location.
17880
19480
  */
17881
19481
  toString() {
17882
- require$$1$3.validateArgCount('Query.toString', 0, 0, arguments.length);
19482
+ require$$2$3.validateArgCount('Query.toString', 0, 0, arguments.length);
17883
19483
  return this._delegate.toString();
17884
19484
  }
17885
19485
  // Do not create public documentation. This is intended to make JSON serialization work but is otherwise unnecessary
17886
19486
  // for end-users.
17887
19487
  toJSON() {
17888
19488
  // An optional spacer argument is unnecessary for a string.
17889
- require$$1$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
19489
+ require$$2$3.validateArgCount('Query.toJSON', 0, 1, arguments.length);
17890
19490
  return this._delegate.toJSON();
17891
19491
  }
17892
19492
  /**
17893
19493
  * Return true if this query and the provided query are equivalent; otherwise, return false.
17894
19494
  */
17895
19495
  isEqual(other) {
17896
- require$$1$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
19496
+ require$$2$3.validateArgCount('Query.isEqual', 1, 1, arguments.length);
17897
19497
  if (!(other instanceof Query)) {
17898
19498
  const error = 'Query.isEqual failed: First argument must be an instance of firebase.database.Query.';
17899
19499
  throw new Error(error);
@@ -17909,9 +19509,9 @@ class Query {
17909
19509
  const ret = { cancel: undefined, context: undefined };
17910
19510
  if (cancelOrContext && context) {
17911
19511
  ret.cancel = cancelOrContext;
17912
- require$$1$3.validateCallback(fnName, 'cancel', ret.cancel, true);
19512
+ require$$2$3.validateCallback(fnName, 'cancel', ret.cancel, true);
17913
19513
  ret.context = context;
17914
- require$$1$3.validateContextObject(fnName, 'context', ret.context, true);
19514
+ require$$2$3.validateContextObject(fnName, 'context', ret.context, true);
17915
19515
  }
17916
19516
  else if (cancelOrContext) {
17917
19517
  // we have either a cancel callback or a context.
@@ -17923,7 +19523,7 @@ class Query {
17923
19523
  ret.cancel = cancelOrContext;
17924
19524
  }
17925
19525
  else {
17926
- throw new Error(require$$1$3.errorPrefix(fnName, 'cancelOrContext') +
19526
+ throw new Error(require$$2$3.errorPrefix(fnName, 'cancelOrContext') +
17927
19527
  ' must either be a cancel callback or a context object.');
17928
19528
  }
17929
19529
  }
@@ -17948,11 +19548,11 @@ class Reference extends Query {
17948
19548
  }
17949
19549
  /** @returns {?string} */
17950
19550
  getKey() {
17951
- require$$1$3.validateArgCount('Reference.key', 0, 0, arguments.length);
19551
+ require$$2$3.validateArgCount('Reference.key', 0, 0, arguments.length);
17952
19552
  return this._delegate.key;
17953
19553
  }
17954
19554
  child(pathString) {
17955
- require$$1$3.validateArgCount('Reference.child', 1, 1, arguments.length);
19555
+ require$$2$3.validateArgCount('Reference.child', 1, 1, arguments.length);
17956
19556
  if (typeof pathString === 'number') {
17957
19557
  pathString = String(pathString);
17958
19558
  }
@@ -17960,18 +19560,18 @@ class Reference extends Query {
17960
19560
  }
17961
19561
  /** @returns {?Reference} */
17962
19562
  getParent() {
17963
- require$$1$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
19563
+ require$$2$3.validateArgCount('Reference.parent', 0, 0, arguments.length);
17964
19564
  const parent = this._delegate.parent;
17965
19565
  return parent ? new Reference(this.database, parent) : null;
17966
19566
  }
17967
19567
  /** @returns {!Reference} */
17968
19568
  getRoot() {
17969
- require$$1$3.validateArgCount('Reference.root', 0, 0, arguments.length);
19569
+ require$$2$3.validateArgCount('Reference.root', 0, 0, arguments.length);
17970
19570
  return new Reference(this.database, this._delegate.root);
17971
19571
  }
17972
19572
  set(newVal, onComplete) {
17973
- require$$1$3.validateArgCount('Reference.set', 1, 2, arguments.length);
17974
- require$$1$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
19573
+ require$$2$3.validateArgCount('Reference.set', 1, 2, arguments.length);
19574
+ require$$2$3.validateCallback('Reference.set', 'onComplete', onComplete, true);
17975
19575
  const result = set_1(this._delegate, newVal);
17976
19576
  if (onComplete) {
17977
19577
  result.then(() => onComplete(null), error => onComplete(error));
@@ -17979,7 +19579,7 @@ class Reference extends Query {
17979
19579
  return result;
17980
19580
  }
17981
19581
  update(values, onComplete) {
17982
- require$$1$3.validateArgCount('Reference.update', 1, 2, arguments.length);
19582
+ require$$2$3.validateArgCount('Reference.update', 1, 2, arguments.length);
17983
19583
  if (Array.isArray(values)) {
17984
19584
  const newObjectToMerge = {};
17985
19585
  for (let i = 0; i < values.length; ++i) {
@@ -17992,7 +19592,7 @@ class Reference extends Query {
17992
19592
  'only update some of the children.');
17993
19593
  }
17994
19594
  _validateWritablePath('Reference.update', this._delegate._path);
17995
- require$$1$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
19595
+ require$$2$3.validateCallback('Reference.update', 'onComplete', onComplete, true);
17996
19596
  const result = update_1(this._delegate, values);
17997
19597
  if (onComplete) {
17998
19598
  result.then(() => onComplete(null), error => onComplete(error));
@@ -18000,8 +19600,8 @@ class Reference extends Query {
18000
19600
  return result;
18001
19601
  }
18002
19602
  setWithPriority(newVal, newPriority, onComplete) {
18003
- require$$1$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
18004
- require$$1$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
19603
+ require$$2$3.validateArgCount('Reference.setWithPriority', 2, 3, arguments.length);
19604
+ require$$2$3.validateCallback('Reference.setWithPriority', 'onComplete', onComplete, true);
18005
19605
  const result = setWithPriority_1(this._delegate, newVal, newPriority);
18006
19606
  if (onComplete) {
18007
19607
  result.then(() => onComplete(null), error => onComplete(error));
@@ -18009,8 +19609,8 @@ class Reference extends Query {
18009
19609
  return result;
18010
19610
  }
18011
19611
  remove(onComplete) {
18012
- require$$1$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
18013
- require$$1$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
19612
+ require$$2$3.validateArgCount('Reference.remove', 0, 1, arguments.length);
19613
+ require$$2$3.validateCallback('Reference.remove', 'onComplete', onComplete, true);
18014
19614
  const result = remove_1(this._delegate);
18015
19615
  if (onComplete) {
18016
19616
  result.then(() => onComplete(null), error => onComplete(error));
@@ -18018,9 +19618,9 @@ class Reference extends Query {
18018
19618
  return result;
18019
19619
  }
18020
19620
  transaction(transactionUpdate, onComplete, applyLocally) {
18021
- require$$1$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
18022
- require$$1$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
18023
- require$$1$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
19621
+ require$$2$3.validateArgCount('Reference.transaction', 1, 3, arguments.length);
19622
+ require$$2$3.validateCallback('Reference.transaction', 'transactionUpdate', transactionUpdate, false);
19623
+ require$$2$3.validateCallback('Reference.transaction', 'onComplete', onComplete, true);
18024
19624
  validateBoolean('Reference.transaction', 'applyLocally', applyLocally);
18025
19625
  const result = runTransaction_1(this._delegate, transactionUpdate, {
18026
19626
  applyLocally
@@ -18031,8 +19631,8 @@ class Reference extends Query {
18031
19631
  return result;
18032
19632
  }
18033
19633
  setPriority(priority, onComplete) {
18034
- require$$1$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
18035
- require$$1$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
19634
+ require$$2$3.validateArgCount('Reference.setPriority', 1, 2, arguments.length);
19635
+ require$$2$3.validateCallback('Reference.setPriority', 'onComplete', onComplete, true);
18036
19636
  const result = setPriority_1(this._delegate, priority);
18037
19637
  if (onComplete) {
18038
19638
  result.then(() => onComplete(null), error => onComplete(error));
@@ -18040,8 +19640,8 @@ class Reference extends Query {
18040
19640
  return result;
18041
19641
  }
18042
19642
  push(value, onComplete) {
18043
- require$$1$3.validateArgCount('Reference.push', 0, 2, arguments.length);
18044
- require$$1$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
19643
+ require$$2$3.validateArgCount('Reference.push', 0, 2, arguments.length);
19644
+ require$$2$3.validateCallback('Reference.push', 'onComplete', onComplete, true);
18045
19645
  const expPromise = push_1(this._delegate, value);
18046
19646
  const promise = expPromise.then(expRef => new Reference(this.database, expRef));
18047
19647
  if (onComplete) {
@@ -18113,7 +19713,7 @@ class Database {
18113
19713
  connectDatabaseEmulator_1(this._delegate, host, port, options);
18114
19714
  }
18115
19715
  ref(path) {
18116
- require$$1$3.validateArgCount('database.ref', 0, 1, arguments.length);
19716
+ require$$2$3.validateArgCount('database.ref', 0, 1, arguments.length);
18117
19717
  if (path instanceof Reference) {
18118
19718
  const childRef = refFromURL_1(this._delegate, path.toString());
18119
19719
  return new Reference(this, childRef);
@@ -18131,17 +19731,17 @@ class Database {
18131
19731
  */
18132
19732
  refFromURL(url) {
18133
19733
  const apiName = 'database.refFromURL';
18134
- require$$1$3.validateArgCount(apiName, 1, 1, arguments.length);
19734
+ require$$2$3.validateArgCount(apiName, 1, 1, arguments.length);
18135
19735
  const childRef = refFromURL_1(this._delegate, url);
18136
19736
  return new Reference(this, childRef);
18137
19737
  }
18138
19738
  // Make individual repo go offline.
18139
19739
  goOffline() {
18140
- require$$1$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
19740
+ require$$2$3.validateArgCount('database.goOffline', 0, 0, arguments.length);
18141
19741
  return goOffline_1(this._delegate);
18142
19742
  }
18143
19743
  goOnline() {
18144
- require$$1$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
19744
+ require$$2$3.validateArgCount('database.goOnline', 0, 0, arguments.length);
18145
19745
  return goOnline_1(this._delegate);
18146
19746
  }
18147
19747
  }
@@ -18161,17 +19761,17 @@ Database.ServerValue = {
18161
19761
  */
18162
19762
  function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImpl, namespace, nodeAdmin = false }) {
18163
19763
  _setSDKVersion(version);
18164
- const container = new require$$4.ComponentContainer('database-standalone');
19764
+ const container = new require$$0$2.ComponentContainer('database-standalone');
18165
19765
  /**
18166
19766
  * ComponentContainer('database-standalone') is just a placeholder that doesn't perform
18167
19767
  * any actual function.
18168
19768
  */
18169
- const authProvider = new require$$4.Provider('auth-internal', container);
18170
- authProvider.setComponent(new require$$4.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
19769
+ const authProvider = new require$$0$2.Provider('auth-internal', container);
19770
+ authProvider.setComponent(new require$$0$2.Component('auth-internal', () => customAuthImpl, "PRIVATE" /* ComponentType.PRIVATE */));
18171
19771
  let appCheckProvider = undefined;
18172
19772
  if (customAppCheckImpl) {
18173
- appCheckProvider = new require$$4.Provider('app-check-internal', container);
18174
- appCheckProvider.setComponent(new require$$4.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
19773
+ appCheckProvider = new require$$0$2.Provider('app-check-internal', container);
19774
+ appCheckProvider.setComponent(new require$$0$2.Component('app-check-internal', () => customAppCheckImpl, "PRIVATE" /* ComponentType.PRIVATE */));
18175
19775
  }
18176
19776
  return {
18177
19777
  instance: new Database(_repoManagerDatabaseFromApp(app, authProvider, appCheckProvider, url, nodeAdmin), app),
@@ -18180,8 +19780,8 @@ function initStandalone$1({ app, url, version, customAuthImpl, customAppCheckImp
18180
19780
  }
18181
19781
 
18182
19782
  var INTERNAL = /*#__PURE__*/Object.freeze({
18183
- __proto__: null,
18184
- initStandalone: initStandalone$1
19783
+ __proto__: null,
19784
+ initStandalone: initStandalone$1
18185
19785
  });
18186
19786
 
18187
19787
  /**
@@ -18211,7 +19811,7 @@ const ServerValue = Database.ServerValue;
18211
19811
  * @param nodeAdmin - true if the SDK is being initialized from Firebase Admin.
18212
19812
  */
18213
19813
  function initStandalone(app, url, version, nodeAdmin = true) {
18214
- require$$1$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
19814
+ require$$2$3.CONSTANTS.NODE_ADMIN = nodeAdmin;
18215
19815
  return initStandalone$1({
18216
19816
  app,
18217
19817
  url,