@lystech/sections 0.2.0 → 0.4.0

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.
@@ -0,0 +1,1541 @@
1
+ const ue = () => {
2
+ };
3
+ const X = function(t) {
4
+ const e = [];
5
+ let n = 0;
6
+ for (let r = 0; r < t.length; r++) {
7
+ let s = t.charCodeAt(r);
8
+ s < 128 ? e[n++] = s : s < 2048 ? (e[n++] = s >> 6 | 192, e[n++] = s & 63 | 128) : (s & 64512) === 55296 && r + 1 < t.length && (t.charCodeAt(r + 1) & 64512) === 56320 ? (s = 65536 + ((s & 1023) << 10) + (t.charCodeAt(++r) & 1023), e[n++] = s >> 18 | 240, e[n++] = s >> 12 & 63 | 128, e[n++] = s >> 6 & 63 | 128, e[n++] = s & 63 | 128) : (e[n++] = s >> 12 | 224, e[n++] = s >> 6 & 63 | 128, e[n++] = s & 63 | 128);
9
+ }
10
+ return e;
11
+ }, pe = function(t) {
12
+ const e = [];
13
+ let n = 0, r = 0;
14
+ for (; n < t.length; ) {
15
+ const s = t[n++];
16
+ if (s < 128)
17
+ e[r++] = String.fromCharCode(s);
18
+ else if (s > 191 && s < 224) {
19
+ const i = t[n++];
20
+ e[r++] = String.fromCharCode((s & 31) << 6 | i & 63);
21
+ } else if (s > 239 && s < 365) {
22
+ const i = t[n++], o = t[n++], c = t[n++], a = ((s & 7) << 18 | (i & 63) << 12 | (o & 63) << 6 | c & 63) - 65536;
23
+ e[r++] = String.fromCharCode(55296 + (a >> 10)), e[r++] = String.fromCharCode(56320 + (a & 1023));
24
+ } else {
25
+ const i = t[n++], o = t[n++];
26
+ e[r++] = String.fromCharCode((s & 15) << 12 | (i & 63) << 6 | o & 63);
27
+ }
28
+ }
29
+ return e.join("");
30
+ }, Q = {
31
+ /**
32
+ * Maps bytes to characters.
33
+ */
34
+ byteToCharMap_: null,
35
+ /**
36
+ * Maps characters to bytes.
37
+ */
38
+ charToByteMap_: null,
39
+ /**
40
+ * Maps bytes to websafe characters.
41
+ * @private
42
+ */
43
+ byteToCharMapWebSafe_: null,
44
+ /**
45
+ * Maps websafe characters to bytes.
46
+ * @private
47
+ */
48
+ charToByteMapWebSafe_: null,
49
+ /**
50
+ * Our default alphabet, shared between
51
+ * ENCODED_VALS and ENCODED_VALS_WEBSAFE
52
+ */
53
+ ENCODED_VALS_BASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
54
+ /**
55
+ * Our default alphabet. Value 64 (=) is special; it means "nothing."
56
+ */
57
+ get ENCODED_VALS() {
58
+ return this.ENCODED_VALS_BASE + "+/=";
59
+ },
60
+ /**
61
+ * Our websafe alphabet.
62
+ */
63
+ get ENCODED_VALS_WEBSAFE() {
64
+ return this.ENCODED_VALS_BASE + "-_.";
65
+ },
66
+ /**
67
+ * Whether this browser supports the atob and btoa functions. This extension
68
+ * started at Mozilla but is now implemented by many browsers. We use the
69
+ * ASSUME_* variables to avoid pulling in the full useragent detection library
70
+ * but still allowing the standard per-browser compilations.
71
+ *
72
+ */
73
+ HAS_NATIVE_SUPPORT: typeof atob == "function",
74
+ /**
75
+ * Base64-encode an array of bytes.
76
+ *
77
+ * @param input An array of bytes (numbers with
78
+ * value in [0, 255]) to encode.
79
+ * @param webSafe Boolean indicating we should use the
80
+ * alternative alphabet.
81
+ * @return The base64 encoded string.
82
+ */
83
+ encodeByteArray(t, e) {
84
+ if (!Array.isArray(t))
85
+ throw Error("encodeByteArray takes an array as a parameter");
86
+ this.init_();
87
+ const n = e ? this.byteToCharMapWebSafe_ : this.byteToCharMap_, r = [];
88
+ for (let s = 0; s < t.length; s += 3) {
89
+ const i = t[s], o = s + 1 < t.length, c = o ? t[s + 1] : 0, a = s + 2 < t.length, f = a ? t[s + 2] : 0, b = i >> 2, p = (i & 3) << 4 | c >> 4;
90
+ let y = (c & 15) << 2 | f >> 6, C = f & 63;
91
+ a || (C = 64, o || (y = 64)), r.push(n[b], n[p], n[y], n[C]);
92
+ }
93
+ return r.join("");
94
+ },
95
+ /**
96
+ * Base64-encode a string.
97
+ *
98
+ * @param input A string to encode.
99
+ * @param webSafe If true, we should use the
100
+ * alternative alphabet.
101
+ * @return The base64 encoded string.
102
+ */
103
+ encodeString(t, e) {
104
+ return this.HAS_NATIVE_SUPPORT && !e ? btoa(t) : this.encodeByteArray(X(t), e);
105
+ },
106
+ /**
107
+ * Base64-decode a string.
108
+ *
109
+ * @param input to decode.
110
+ * @param webSafe True if we should use the
111
+ * alternative alphabet.
112
+ * @return string representing the decoded value.
113
+ */
114
+ decodeString(t, e) {
115
+ return this.HAS_NATIVE_SUPPORT && !e ? atob(t) : pe(this.decodeStringToByteArray(t, e));
116
+ },
117
+ /**
118
+ * Base64-decode a string.
119
+ *
120
+ * In base-64 decoding, groups of four characters are converted into three
121
+ * bytes. If the encoder did not apply padding, the input length may not
122
+ * be a multiple of 4.
123
+ *
124
+ * In this case, the last group will have fewer than 4 characters, and
125
+ * padding will be inferred. If the group has one or two characters, it decodes
126
+ * to one byte. If the group has three characters, it decodes to two bytes.
127
+ *
128
+ * @param input Input to decode.
129
+ * @param webSafe True if we should use the web-safe alphabet.
130
+ * @return bytes representing the decoded value.
131
+ */
132
+ decodeStringToByteArray(t, e) {
133
+ this.init_();
134
+ const n = e ? this.charToByteMapWebSafe_ : this.charToByteMap_, r = [];
135
+ for (let s = 0; s < t.length; ) {
136
+ const i = n[t.charAt(s++)], c = s < t.length ? n[t.charAt(s)] : 0;
137
+ ++s;
138
+ const f = s < t.length ? n[t.charAt(s)] : 64;
139
+ ++s;
140
+ const p = s < t.length ? n[t.charAt(s)] : 64;
141
+ if (++s, i == null || c == null || f == null || p == null)
142
+ throw new me();
143
+ const y = i << 2 | c >> 4;
144
+ if (r.push(y), f !== 64) {
145
+ const C = c << 4 & 240 | f >> 2;
146
+ if (r.push(C), p !== 64) {
147
+ const de = f << 6 & 192 | p;
148
+ r.push(de);
149
+ }
150
+ }
151
+ }
152
+ return r;
153
+ },
154
+ /**
155
+ * Lazy static initialization function. Called before
156
+ * accessing any of the static map variables.
157
+ * @private
158
+ */
159
+ init_() {
160
+ if (!this.byteToCharMap_) {
161
+ this.byteToCharMap_ = {}, this.charToByteMap_ = {}, this.byteToCharMapWebSafe_ = {}, this.charToByteMapWebSafe_ = {};
162
+ for (let t = 0; t < this.ENCODED_VALS.length; t++)
163
+ this.byteToCharMap_[t] = this.ENCODED_VALS.charAt(t), this.charToByteMap_[this.byteToCharMap_[t]] = t, this.byteToCharMapWebSafe_[t] = this.ENCODED_VALS_WEBSAFE.charAt(t), this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]] = t, t >= this.ENCODED_VALS_BASE.length && (this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)] = t, this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)] = t);
164
+ }
165
+ }
166
+ };
167
+ class me extends Error {
168
+ constructor() {
169
+ super(...arguments), this.name = "DecodeBase64StringError";
170
+ }
171
+ }
172
+ const ge = function(t) {
173
+ const e = X(t);
174
+ return Q.encodeByteArray(e, !0);
175
+ }, Z = function(t) {
176
+ return ge(t).replace(/\./g, "");
177
+ }, ee = function(t) {
178
+ try {
179
+ return Q.decodeString(t, !0);
180
+ } catch (e) {
181
+ console.error("base64Decode failed: ", e);
182
+ }
183
+ return null;
184
+ };
185
+ function be() {
186
+ if (typeof self < "u")
187
+ return self;
188
+ if (typeof window < "u")
189
+ return window;
190
+ if (typeof global < "u")
191
+ return global;
192
+ throw new Error("Unable to locate global object.");
193
+ }
194
+ const ye = () => be().__FIREBASE_DEFAULTS__, Ee = () => {
195
+ if (typeof process > "u" || typeof process.env > "u")
196
+ return;
197
+ const t = process.env.__FIREBASE_DEFAULTS__;
198
+ if (t)
199
+ return JSON.parse(t);
200
+ }, _e = () => {
201
+ if (typeof document > "u")
202
+ return;
203
+ let t;
204
+ try {
205
+ t = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);
206
+ } catch {
207
+ return;
208
+ }
209
+ const e = t && ee(t[1]);
210
+ return e && JSON.parse(e);
211
+ }, P = () => {
212
+ try {
213
+ return ue() || ye() || Ee() || _e();
214
+ } catch (t) {
215
+ console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);
216
+ return;
217
+ }
218
+ }, zt = (t) => P()?.emulatorHosts?.[t], H = () => P()?.config, Vt = (t) => P()?.[`_${t}`];
219
+ class ve {
220
+ constructor() {
221
+ this.reject = () => {
222
+ }, this.resolve = () => {
223
+ }, this.promise = new Promise((e, n) => {
224
+ this.resolve = e, this.reject = n;
225
+ });
226
+ }
227
+ /**
228
+ * Our API internals are not promisified and cannot because our callback APIs have subtle expectations around
229
+ * invoking promises inline, which Promises are forbidden to do. This method accepts an optional node-style callback
230
+ * and returns a node-style callback which will resolve or reject the Deferred's promise.
231
+ */
232
+ wrapCallback(e) {
233
+ return (n, r) => {
234
+ n ? this.reject(n) : this.resolve(r), typeof e == "function" && (this.promise.catch(() => {
235
+ }), e.length === 1 ? e(n) : e(n, r));
236
+ };
237
+ }
238
+ }
239
+ function te() {
240
+ return typeof navigator < "u" && typeof navigator.userAgent == "string" ? navigator.userAgent : "";
241
+ }
242
+ function Ut() {
243
+ return typeof window < "u" && // @ts-ignore Setting up an broadly applicable index signature for Window
244
+ // just to deal with this case would probably be a bad idea.
245
+ !!(window.cordova || window.phonegap || window.PhoneGap) && /ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(te());
246
+ }
247
+ function we() {
248
+ return typeof window < "u" || ne();
249
+ }
250
+ function ne() {
251
+ return typeof WorkerGlobalScope < "u" && typeof self < "u" && self instanceof WorkerGlobalScope;
252
+ }
253
+ function Wt() {
254
+ return typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers";
255
+ }
256
+ function jt() {
257
+ const t = typeof chrome == "object" ? chrome.runtime : typeof browser == "object" ? browser.runtime : void 0;
258
+ return typeof t == "object" && t.id !== void 0;
259
+ }
260
+ function Gt() {
261
+ return typeof navigator == "object" && navigator.product === "ReactNative";
262
+ }
263
+ function Jt() {
264
+ const t = te();
265
+ return t.indexOf("MSIE ") >= 0 || t.indexOf("Trident/") >= 0;
266
+ }
267
+ function Ce() {
268
+ try {
269
+ return typeof indexedDB == "object";
270
+ } catch {
271
+ return !1;
272
+ }
273
+ }
274
+ function De() {
275
+ return new Promise((t, e) => {
276
+ try {
277
+ let n = !0;
278
+ const r = "validate-browser-context-for-indexeddb-analytics-module", s = self.indexedDB.open(r);
279
+ s.onsuccess = () => {
280
+ s.result.close(), n || self.indexedDB.deleteDatabase(r), t(!0);
281
+ }, s.onupgradeneeded = () => {
282
+ n = !1;
283
+ }, s.onerror = () => {
284
+ e(s.error?.message || "");
285
+ };
286
+ } catch (n) {
287
+ e(n);
288
+ }
289
+ });
290
+ }
291
+ const Ie = "FirebaseError";
292
+ class w extends Error {
293
+ constructor(e, n, r) {
294
+ super(n), this.code = e, this.customData = r, this.name = Ie, Object.setPrototypeOf(this, w.prototype), Error.captureStackTrace && Error.captureStackTrace(this, re.prototype.create);
295
+ }
296
+ }
297
+ class re {
298
+ constructor(e, n, r) {
299
+ this.service = e, this.serviceName = n, this.errors = r;
300
+ }
301
+ create(e, ...n) {
302
+ const r = n[0] || {}, s = `${this.service}/${e}`, i = this.errors[e], o = i ? Se(i, r) : "Error", c = `${this.serviceName}: ${o} (${s}).`;
303
+ return new w(s, c, r);
304
+ }
305
+ }
306
+ function Se(t, e) {
307
+ try {
308
+ let n = 0, r = "";
309
+ for (; n < t.length; ) {
310
+ const s = t.indexOf("{$", n);
311
+ if (s === -1) {
312
+ r += t.substring(n);
313
+ break;
314
+ }
315
+ const i = t.indexOf("}", s + 2);
316
+ if (i === -1) {
317
+ r += t.substring(n);
318
+ break;
319
+ }
320
+ const o = t.substring(s + 2, i), c = e[o];
321
+ r += t.substring(n, s) + (c != null ? String(c) : `<${o}?>`), n = i + 1;
322
+ }
323
+ return r;
324
+ } catch {
325
+ return t;
326
+ }
327
+ }
328
+ function Kt(t) {
329
+ for (const e in t)
330
+ if (Object.prototype.hasOwnProperty.call(t, e))
331
+ return !1;
332
+ return !0;
333
+ }
334
+ function N(t, e) {
335
+ if (t === e)
336
+ return !0;
337
+ const n = Object.keys(t), r = Object.keys(e);
338
+ for (const s of n) {
339
+ if (!r.includes(s))
340
+ return !1;
341
+ const i = t[s], o = e[s];
342
+ if (V(i) && V(o)) {
343
+ if (!N(i, o))
344
+ return !1;
345
+ } else if (i !== o)
346
+ return !1;
347
+ }
348
+ for (const s of r)
349
+ if (!n.includes(s))
350
+ return !1;
351
+ return !0;
352
+ }
353
+ function V(t) {
354
+ return t !== null && typeof t == "object";
355
+ }
356
+ function Yt(t) {
357
+ const e = [];
358
+ for (const [n, r] of Object.entries(t))
359
+ Array.isArray(r) ? r.forEach((s) => {
360
+ e.push(encodeURIComponent(n) + "=" + encodeURIComponent(s));
361
+ }) : e.push(encodeURIComponent(n) + "=" + encodeURIComponent(r));
362
+ return e.length ? "&" + e.join("&") : "";
363
+ }
364
+ function qt(t) {
365
+ const e = {};
366
+ return t.replace(/^\?/, "").split("&").forEach((r) => {
367
+ if (r) {
368
+ const [s, i] = r.split("=");
369
+ e[decodeURIComponent(s)] = decodeURIComponent(i);
370
+ }
371
+ }), e;
372
+ }
373
+ function Xt(t) {
374
+ const e = t.indexOf("?");
375
+ if (!e)
376
+ return "";
377
+ const n = t.indexOf("#", e);
378
+ return t.substring(e, n > 0 ? n : void 0);
379
+ }
380
+ function Qt(t, e) {
381
+ const n = new Ae(t, e);
382
+ return n.subscribe.bind(n);
383
+ }
384
+ class Ae {
385
+ /**
386
+ * @param executor Function which can make calls to a single Observer
387
+ * as a proxy.
388
+ * @param onNoObservers Callback when count of Observers goes to zero.
389
+ */
390
+ constructor(e, n) {
391
+ this.observers = [], this.unsubscribes = [], this.observerCount = 0, this.task = Promise.resolve(), this.finalized = !1, this.onNoObservers = n, this.task.then(() => {
392
+ e(this);
393
+ }).catch((r) => {
394
+ this.error(r);
395
+ });
396
+ }
397
+ next(e) {
398
+ this.forEachObserver((n) => {
399
+ n.next(e);
400
+ });
401
+ }
402
+ error(e) {
403
+ this.forEachObserver((n) => {
404
+ n.error(e);
405
+ }), this.close(e);
406
+ }
407
+ complete() {
408
+ this.forEachObserver((e) => {
409
+ e.complete();
410
+ }), this.close();
411
+ }
412
+ /**
413
+ * Subscribe function that can be used to add an Observer to the fan-out list.
414
+ *
415
+ * - We require that no event is sent to a subscriber synchronously to their
416
+ * call to subscribe().
417
+ */
418
+ subscribe(e, n, r) {
419
+ let s;
420
+ if (e === void 0 && n === void 0 && r === void 0)
421
+ throw new Error("Missing Observer.");
422
+ Oe(e, [
423
+ "next",
424
+ "error",
425
+ "complete"
426
+ ]) ? s = e : s = {
427
+ next: e,
428
+ error: n,
429
+ complete: r
430
+ }, s.next === void 0 && (s.next = O), s.error === void 0 && (s.error = O), s.complete === void 0 && (s.complete = O);
431
+ const i = this.unsubscribeOne.bind(this, this.observers.length);
432
+ return this.finalized && this.task.then(() => {
433
+ try {
434
+ this.finalError ? s.error(this.finalError) : s.complete();
435
+ } catch {
436
+ }
437
+ }), this.observers.push(s), i;
438
+ }
439
+ // Unsubscribe is synchronous - we guarantee that no events are sent to
440
+ // any unsubscribed Observer.
441
+ unsubscribeOne(e) {
442
+ this.observers === void 0 || this.observers[e] === void 0 || (delete this.observers[e], this.observerCount -= 1, this.observerCount === 0 && this.onNoObservers !== void 0 && this.onNoObservers(this));
443
+ }
444
+ forEachObserver(e) {
445
+ if (!this.finalized)
446
+ for (let n = 0; n < this.observers.length; n++)
447
+ this.sendOne(n, e);
448
+ }
449
+ // Call the Observer via one of it's callback function. We are careful to
450
+ // confirm that the observe has not been unsubscribed since this asynchronous
451
+ // function had been queued.
452
+ sendOne(e, n) {
453
+ this.task.then(() => {
454
+ if (this.observers !== void 0 && this.observers[e] !== void 0)
455
+ try {
456
+ n(this.observers[e]);
457
+ } catch (r) {
458
+ typeof console < "u" && console.error && console.error(r);
459
+ }
460
+ });
461
+ }
462
+ close(e) {
463
+ this.finalized || (this.finalized = !0, e !== void 0 && (this.finalError = e), this.task.then(() => {
464
+ this.observers = void 0, this.onNoObservers = void 0;
465
+ }));
466
+ }
467
+ }
468
+ function Oe(t, e) {
469
+ if (typeof t != "object" || t === null)
470
+ return !1;
471
+ for (const n of e)
472
+ if (n in t && typeof t[n] == "function")
473
+ return !0;
474
+ return !1;
475
+ }
476
+ function O() {
477
+ }
478
+ function Zt(t) {
479
+ return t && t._delegate ? t._delegate : t;
480
+ }
481
+ function en(t) {
482
+ try {
483
+ return (t.startsWith("http://") || t.startsWith("https://") ? new URL(t).hostname : t).endsWith(".cloudworkstations.dev");
484
+ } catch {
485
+ return !1;
486
+ }
487
+ }
488
+ async function tn(t) {
489
+ return (await fetch(t, {
490
+ credentials: "include"
491
+ })).ok;
492
+ }
493
+ class I {
494
+ /**
495
+ *
496
+ * @param name The public service name, e.g. app, auth, firestore, database
497
+ * @param instanceFactory Service factory responsible for creating the public interface
498
+ * @param type whether the service provided by the component is public or private
499
+ */
500
+ constructor(e, n, r) {
501
+ this.name = e, this.instanceFactory = n, this.type = r, this.multipleInstances = !1, this.serviceProps = {}, this.instantiationMode = "LAZY", this.onInstanceCreated = null;
502
+ }
503
+ setInstantiationMode(e) {
504
+ return this.instantiationMode = e, this;
505
+ }
506
+ setMultipleInstances(e) {
507
+ return this.multipleInstances = e, this;
508
+ }
509
+ setServiceProps(e) {
510
+ return this.serviceProps = e, this;
511
+ }
512
+ setInstanceCreatedCallback(e) {
513
+ return this.onInstanceCreated = e, this;
514
+ }
515
+ }
516
+ const m = "[DEFAULT]";
517
+ class Be {
518
+ constructor(e, n) {
519
+ this.name = e, this.container = n, this.component = null, this.instances = /* @__PURE__ */ new Map(), this.instancesDeferred = /* @__PURE__ */ new Map(), this.instancesOptions = /* @__PURE__ */ new Map(), this.onInitCallbacks = /* @__PURE__ */ new Map();
520
+ }
521
+ /**
522
+ * @param identifier A provider can provide multiple instances of a service
523
+ * if this.component.multipleInstances is true.
524
+ */
525
+ get(e) {
526
+ const n = this.normalizeInstanceIdentifier(e);
527
+ if (!this.instancesDeferred.has(n)) {
528
+ const r = new ve();
529
+ if (this.instancesDeferred.set(n, r), this.isInitialized(n) || this.shouldAutoInitialize())
530
+ try {
531
+ const s = this.getOrInitializeService({
532
+ instanceIdentifier: n
533
+ });
534
+ s && r.resolve(s);
535
+ } catch {
536
+ }
537
+ }
538
+ return this.instancesDeferred.get(n).promise;
539
+ }
540
+ getImmediate(e) {
541
+ const n = this.normalizeInstanceIdentifier(e?.identifier), r = e?.optional ?? !1;
542
+ if (this.isInitialized(n) || this.shouldAutoInitialize())
543
+ try {
544
+ return this.getOrInitializeService({
545
+ instanceIdentifier: n
546
+ });
547
+ } catch (s) {
548
+ if (r)
549
+ return null;
550
+ throw s;
551
+ }
552
+ else {
553
+ if (r)
554
+ return null;
555
+ throw Error(`Service ${this.name} is not available`);
556
+ }
557
+ }
558
+ getComponent() {
559
+ return this.component;
560
+ }
561
+ setComponent(e) {
562
+ if (e.name !== this.name)
563
+ throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);
564
+ if (this.component)
565
+ throw Error(`Component for ${this.name} has already been provided`);
566
+ if (this.component = e, !!this.shouldAutoInitialize()) {
567
+ if (Re(e))
568
+ try {
569
+ this.getOrInitializeService({ instanceIdentifier: m });
570
+ } catch {
571
+ }
572
+ for (const [n, r] of this.instancesDeferred.entries()) {
573
+ const s = this.normalizeInstanceIdentifier(n);
574
+ try {
575
+ const i = this.getOrInitializeService({
576
+ instanceIdentifier: s
577
+ });
578
+ r.resolve(i);
579
+ } catch {
580
+ }
581
+ }
582
+ }
583
+ }
584
+ clearInstance(e = m) {
585
+ this.instancesDeferred.delete(e), this.instancesOptions.delete(e), this.instances.delete(e);
586
+ }
587
+ // app.delete() will call this method on every provider to delete the services
588
+ // TODO: should we mark the provider as deleted?
589
+ async delete() {
590
+ const e = Array.from(this.instances.values());
591
+ await Promise.all([
592
+ ...e.filter((n) => "INTERNAL" in n).map((n) => n.INTERNAL.delete()),
593
+ ...e.filter((n) => "_delete" in n).map((n) => n._delete())
594
+ ]);
595
+ }
596
+ isComponentSet() {
597
+ return this.component != null;
598
+ }
599
+ isInitialized(e = m) {
600
+ return this.instances.has(e);
601
+ }
602
+ getOptions(e = m) {
603
+ return this.instancesOptions.get(e) || {};
604
+ }
605
+ initialize(e = {}) {
606
+ const { options: n = {} } = e, r = this.normalizeInstanceIdentifier(e.instanceIdentifier);
607
+ if (this.isInitialized(r))
608
+ throw Error(`${this.name}(${r}) has already been initialized`);
609
+ if (!this.isComponentSet())
610
+ throw Error(`Component ${this.name} has not been registered yet`);
611
+ const s = this.getOrInitializeService({
612
+ instanceIdentifier: r,
613
+ options: n
614
+ });
615
+ for (const [i, o] of this.instancesDeferred.entries()) {
616
+ const c = this.normalizeInstanceIdentifier(i);
617
+ r === c && o.resolve(s);
618
+ }
619
+ return s;
620
+ }
621
+ /**
622
+ *
623
+ * @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
624
+ * The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
625
+ *
626
+ * @param identifier An optional instance identifier
627
+ * @returns a function to unregister the callback
628
+ */
629
+ onInit(e, n) {
630
+ const r = this.normalizeInstanceIdentifier(n), s = this.onInitCallbacks.get(r) ?? /* @__PURE__ */ new Set();
631
+ s.add(e), this.onInitCallbacks.set(r, s);
632
+ const i = this.instances.get(r);
633
+ return i && e(i, r), () => {
634
+ s.delete(e);
635
+ };
636
+ }
637
+ /**
638
+ * Invoke onInit callbacks synchronously
639
+ * @param instance the service instance`
640
+ */
641
+ invokeOnInitCallbacks(e, n) {
642
+ const r = this.onInitCallbacks.get(n);
643
+ if (r)
644
+ for (const s of r)
645
+ try {
646
+ s(e, n);
647
+ } catch {
648
+ }
649
+ }
650
+ getOrInitializeService({ instanceIdentifier: e, options: n = {} }) {
651
+ let r = this.instances.get(e);
652
+ if (!r && this.component && (r = this.component.instanceFactory(this.container, {
653
+ instanceIdentifier: Te(e),
654
+ options: n
655
+ }), this.instances.set(e, r), this.instancesOptions.set(e, n), this.invokeOnInitCallbacks(r, e), this.component.onInstanceCreated))
656
+ try {
657
+ this.component.onInstanceCreated(this.container, e, r);
658
+ } catch {
659
+ }
660
+ return r || null;
661
+ }
662
+ normalizeInstanceIdentifier(e = m) {
663
+ return this.component ? this.component.multipleInstances ? e : m : e;
664
+ }
665
+ shouldAutoInitialize() {
666
+ return !!this.component && this.component.instantiationMode !== "EXPLICIT";
667
+ }
668
+ }
669
+ function Te(t) {
670
+ return t === m ? void 0 : t;
671
+ }
672
+ function Re(t) {
673
+ return t.instantiationMode === "EAGER";
674
+ }
675
+ class se {
676
+ constructor(e) {
677
+ this.name = e, this.providers = /* @__PURE__ */ new Map();
678
+ }
679
+ /**
680
+ *
681
+ * @param component Component being added
682
+ * @param overwrite When a component with the same name has already been registered,
683
+ * if overwrite is true: overwrite the existing component with the new component and create a new
684
+ * provider with the new component. It can be useful in tests where you want to use different mocks
685
+ * for different tests.
686
+ * if overwrite is false: throw an exception
687
+ */
688
+ addComponent(e) {
689
+ const n = this.getProvider(e.name);
690
+ if (n.isComponentSet())
691
+ throw new Error(`Component ${e.name} has already been registered with ${this.name}`);
692
+ n.setComponent(e);
693
+ }
694
+ addOrOverwriteComponent(e) {
695
+ this.getProvider(e.name).isComponentSet() && this.providers.delete(e.name), this.addComponent(e);
696
+ }
697
+ /**
698
+ * getProvider provides a type safe interface where it can only be called with a field name
699
+ * present in NameServiceMapping interface.
700
+ *
701
+ * Firebase SDKs providing services should extend NameServiceMapping interface to register
702
+ * themselves.
703
+ */
704
+ getProvider(e) {
705
+ if (this.providers.has(e))
706
+ return this.providers.get(e);
707
+ const n = new Be(e, this);
708
+ return this.providers.set(e, n), n;
709
+ }
710
+ getProviders() {
711
+ return Array.from(this.providers.values());
712
+ }
713
+ }
714
+ const F = [];
715
+ var l;
716
+ (function(t) {
717
+ t[t.DEBUG = 0] = "DEBUG", t[t.VERBOSE = 1] = "VERBOSE", t[t.INFO = 2] = "INFO", t[t.WARN = 3] = "WARN", t[t.ERROR = 4] = "ERROR", t[t.SILENT = 5] = "SILENT";
718
+ })(l || (l = {}));
719
+ const ie = {
720
+ debug: l.DEBUG,
721
+ verbose: l.VERBOSE,
722
+ info: l.INFO,
723
+ warn: l.WARN,
724
+ error: l.ERROR,
725
+ silent: l.SILENT
726
+ }, xe = l.INFO, Ne = {
727
+ [l.DEBUG]: "log",
728
+ [l.VERBOSE]: "log",
729
+ [l.INFO]: "info",
730
+ [l.WARN]: "warn",
731
+ [l.ERROR]: "error"
732
+ }, Me = (t, e, ...n) => {
733
+ if (e < t.logLevel)
734
+ return;
735
+ const r = (/* @__PURE__ */ new Date()).toISOString(), s = Ne[e];
736
+ if (s)
737
+ console[s](`[${r}] ${t.name}:`, ...n);
738
+ else
739
+ throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);
740
+ };
741
+ class $e {
742
+ /**
743
+ * Gives you an instance of a Logger to capture messages according to
744
+ * Firebase's logging scheme.
745
+ *
746
+ * @param name The name that the logs will be associated with
747
+ */
748
+ constructor(e) {
749
+ this.name = e, this._logLevel = xe, this._logHandler = Me, this._userLogHandler = null, F.push(this);
750
+ }
751
+ get logLevel() {
752
+ return this._logLevel;
753
+ }
754
+ set logLevel(e) {
755
+ if (!(e in l))
756
+ throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);
757
+ this._logLevel = e;
758
+ }
759
+ // Workaround for setter/getter having to be the same type.
760
+ setLogLevel(e) {
761
+ this._logLevel = typeof e == "string" ? ie[e] : e;
762
+ }
763
+ get logHandler() {
764
+ return this._logHandler;
765
+ }
766
+ set logHandler(e) {
767
+ if (typeof e != "function")
768
+ throw new TypeError("Value assigned to `logHandler` must be a function");
769
+ this._logHandler = e;
770
+ }
771
+ get userLogHandler() {
772
+ return this._userLogHandler;
773
+ }
774
+ set userLogHandler(e) {
775
+ this._userLogHandler = e;
776
+ }
777
+ /**
778
+ * The functions below are all based on the `console` interface
779
+ */
780
+ debug(...e) {
781
+ this._userLogHandler && this._userLogHandler(this, l.DEBUG, ...e), this._logHandler(this, l.DEBUG, ...e);
782
+ }
783
+ log(...e) {
784
+ this._userLogHandler && this._userLogHandler(this, l.VERBOSE, ...e), this._logHandler(this, l.VERBOSE, ...e);
785
+ }
786
+ info(...e) {
787
+ this._userLogHandler && this._userLogHandler(this, l.INFO, ...e), this._logHandler(this, l.INFO, ...e);
788
+ }
789
+ warn(...e) {
790
+ this._userLogHandler && this._userLogHandler(this, l.WARN, ...e), this._logHandler(this, l.WARN, ...e);
791
+ }
792
+ error(...e) {
793
+ this._userLogHandler && this._userLogHandler(this, l.ERROR, ...e), this._logHandler(this, l.ERROR, ...e);
794
+ }
795
+ }
796
+ function Le(t) {
797
+ F.forEach((e) => {
798
+ e.setLogLevel(t);
799
+ });
800
+ }
801
+ function ke(t, e) {
802
+ for (const n of F) {
803
+ let r = null;
804
+ e && e.level && (r = ie[e.level]), t === null ? n.userLogHandler = null : n.userLogHandler = (s, i, ...o) => {
805
+ const c = o.map((a) => {
806
+ if (a == null)
807
+ return null;
808
+ if (typeof a == "string")
809
+ return a;
810
+ if (typeof a == "number" || typeof a == "boolean")
811
+ return a.toString();
812
+ if (a instanceof Error)
813
+ return a.message;
814
+ try {
815
+ return JSON.stringify(a);
816
+ } catch {
817
+ return null;
818
+ }
819
+ }).filter((a) => a).join(" ");
820
+ i >= (r ?? s.logLevel) && t({
821
+ level: l[i].toLowerCase(),
822
+ message: c,
823
+ args: o,
824
+ type: s.name
825
+ });
826
+ };
827
+ }
828
+ }
829
+ const Pe = (t, e) => e.some((n) => t instanceof n);
830
+ let U, W;
831
+ function He() {
832
+ return U || (U = [
833
+ IDBDatabase,
834
+ IDBObjectStore,
835
+ IDBIndex,
836
+ IDBCursor,
837
+ IDBTransaction
838
+ ]);
839
+ }
840
+ function Fe() {
841
+ return W || (W = [
842
+ IDBCursor.prototype.advance,
843
+ IDBCursor.prototype.continue,
844
+ IDBCursor.prototype.continuePrimaryKey
845
+ ]);
846
+ }
847
+ const oe = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap();
848
+ function ze(t) {
849
+ const e = new Promise((n, r) => {
850
+ const s = () => {
851
+ t.removeEventListener("success", i), t.removeEventListener("error", o);
852
+ }, i = () => {
853
+ n(u(t.result)), s();
854
+ }, o = () => {
855
+ r(t.error), s();
856
+ };
857
+ t.addEventListener("success", i), t.addEventListener("error", o);
858
+ });
859
+ return e.then((n) => {
860
+ n instanceof IDBCursor && oe.set(n, t);
861
+ }).catch(() => {
862
+ }), z.set(e, t), e;
863
+ }
864
+ function Ve(t) {
865
+ if (M.has(t))
866
+ return;
867
+ const e = new Promise((n, r) => {
868
+ const s = () => {
869
+ t.removeEventListener("complete", i), t.removeEventListener("error", o), t.removeEventListener("abort", o);
870
+ }, i = () => {
871
+ n(), s();
872
+ }, o = () => {
873
+ r(t.error || new DOMException("AbortError", "AbortError")), s();
874
+ };
875
+ t.addEventListener("complete", i), t.addEventListener("error", o), t.addEventListener("abort", o);
876
+ });
877
+ M.set(t, e);
878
+ }
879
+ let $ = {
880
+ get(t, e, n) {
881
+ if (t instanceof IDBTransaction) {
882
+ if (e === "done")
883
+ return M.get(t);
884
+ if (e === "objectStoreNames")
885
+ return t.objectStoreNames || ae.get(t);
886
+ if (e === "store")
887
+ return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0]);
888
+ }
889
+ return u(t[e]);
890
+ },
891
+ set(t, e, n) {
892
+ return t[e] = n, !0;
893
+ },
894
+ has(t, e) {
895
+ return t instanceof IDBTransaction && (e === "done" || e === "store") ? !0 : e in t;
896
+ }
897
+ };
898
+ function Ue(t) {
899
+ $ = t($);
900
+ }
901
+ function We(t) {
902
+ return t === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(e, ...n) {
903
+ const r = t.call(T(this), e, ...n);
904
+ return ae.set(r, e.sort ? e.sort() : [e]), u(r);
905
+ } : Fe().includes(t) ? function(...e) {
906
+ return t.apply(T(this), e), u(oe.get(this));
907
+ } : function(...e) {
908
+ return u(t.apply(T(this), e));
909
+ };
910
+ }
911
+ function je(t) {
912
+ return typeof t == "function" ? We(t) : (t instanceof IDBTransaction && Ve(t), Pe(t, He()) ? new Proxy(t, $) : t);
913
+ }
914
+ function u(t) {
915
+ if (t instanceof IDBRequest)
916
+ return ze(t);
917
+ if (B.has(t))
918
+ return B.get(t);
919
+ const e = je(t);
920
+ return e !== t && (B.set(t, e), z.set(e, t)), e;
921
+ }
922
+ const T = (t) => z.get(t);
923
+ function Ge(t, e, { blocked: n, upgrade: r, blocking: s, terminated: i } = {}) {
924
+ const o = indexedDB.open(t, e), c = u(o);
925
+ return r && o.addEventListener("upgradeneeded", (a) => {
926
+ r(u(o.result), a.oldVersion, a.newVersion, u(o.transaction), a);
927
+ }), n && o.addEventListener("blocked", (a) => n(
928
+ // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
929
+ a.oldVersion,
930
+ a.newVersion,
931
+ a
932
+ )), c.then((a) => {
933
+ i && a.addEventListener("close", () => i()), s && a.addEventListener("versionchange", (f) => s(f.oldVersion, f.newVersion, f));
934
+ }).catch(() => {
935
+ }), c;
936
+ }
937
+ const Je = ["get", "getKey", "getAll", "getAllKeys", "count"], Ke = ["put", "add", "delete", "clear"], R = /* @__PURE__ */ new Map();
938
+ function j(t, e) {
939
+ if (!(t instanceof IDBDatabase && !(e in t) && typeof e == "string"))
940
+ return;
941
+ if (R.get(e))
942
+ return R.get(e);
943
+ const n = e.replace(/FromIndex$/, ""), r = e !== n, s = Ke.includes(n);
944
+ if (
945
+ // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
946
+ !(n in (r ? IDBIndex : IDBObjectStore).prototype) || !(s || Je.includes(n))
947
+ )
948
+ return;
949
+ const i = async function(o, ...c) {
950
+ const a = this.transaction(o, s ? "readwrite" : "readonly");
951
+ let f = a.store;
952
+ return r && (f = f.index(c.shift())), (await Promise.all([
953
+ f[n](...c),
954
+ s && a.done
955
+ ]))[0];
956
+ };
957
+ return R.set(e, i), i;
958
+ }
959
+ Ue((t) => ({
960
+ ...t,
961
+ get: (e, n, r) => j(e, n) || t.get(e, n, r),
962
+ has: (e, n) => !!j(e, n) || t.has(e, n)
963
+ }));
964
+ class Ye {
965
+ constructor(e) {
966
+ this.container = e;
967
+ }
968
+ // In initial implementation, this will be called by installations on
969
+ // auth token refresh, and installations will send this string.
970
+ getPlatformInfoString() {
971
+ return this.container.getProviders().map((n) => {
972
+ if (qe(n)) {
973
+ const r = n.getImmediate();
974
+ return `${r.library}/${r.version}`;
975
+ } else
976
+ return null;
977
+ }).filter((n) => n).join(" ");
978
+ }
979
+ }
980
+ function qe(t) {
981
+ return t.getComponent()?.type === "VERSION";
982
+ }
983
+ const S = "@firebase/app", L = "0.16.2";
984
+ const d = new $e("@firebase/app"), Xe = "@firebase/app-compat", Qe = "@firebase/analytics-compat", Ze = "@firebase/analytics", et = "@firebase/app-check-compat", tt = "@firebase/app-check", nt = "@firebase/auth", rt = "@firebase/auth-compat", st = "@firebase/database", it = "@firebase/data-connect", ot = "@firebase/database-compat", at = "@firebase/functions", ct = "@firebase/functions-compat", lt = "@firebase/installations", ft = "@firebase/installations-compat", ht = "@firebase/messaging", dt = "@firebase/messaging-compat", ut = "@firebase/performance", pt = "@firebase/performance-compat", mt = "@firebase/remote-config", gt = "@firebase/remote-config-compat", bt = "@firebase/storage", yt = "@firebase/storage-compat", Et = "@firebase/firestore", _t = "@firebase/ai", vt = "@firebase/firestore-compat", wt = "firebase", Ct = "12.19.0";
985
+ const A = "[DEFAULT]", Dt = {
986
+ [S]: "fire-core",
987
+ [Xe]: "fire-core-compat",
988
+ [Ze]: "fire-analytics",
989
+ [Qe]: "fire-analytics-compat",
990
+ [tt]: "fire-app-check",
991
+ [et]: "fire-app-check-compat",
992
+ [nt]: "fire-auth",
993
+ [rt]: "fire-auth-compat",
994
+ [st]: "fire-rtdb",
995
+ [it]: "fire-data-connect",
996
+ [ot]: "fire-rtdb-compat",
997
+ [at]: "fire-fn",
998
+ [ct]: "fire-fn-compat",
999
+ [lt]: "fire-iid",
1000
+ [ft]: "fire-iid-compat",
1001
+ [ht]: "fire-fcm",
1002
+ [dt]: "fire-fcm-compat",
1003
+ [ut]: "fire-perf",
1004
+ [pt]: "fire-perf-compat",
1005
+ [mt]: "fire-rc",
1006
+ [gt]: "fire-rc-compat",
1007
+ [bt]: "fire-gcs",
1008
+ [yt]: "fire-gcs-compat",
1009
+ [Et]: "fire-fst",
1010
+ [vt]: "fire-fst-compat",
1011
+ [_t]: "fire-vertex",
1012
+ "fire-js": "fire-js",
1013
+ // Platform identifier for JS SDK.
1014
+ [wt]: "fire-js-all"
1015
+ };
1016
+ const g = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
1017
+ function G(t, e) {
1018
+ try {
1019
+ t.container.addComponent(e);
1020
+ } catch (n) {
1021
+ d.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`, n);
1022
+ }
1023
+ }
1024
+ function nn(t, e) {
1025
+ t.container.addOrOverwriteComponent(e);
1026
+ }
1027
+ function k(t) {
1028
+ const e = t.name;
1029
+ if (_.has(e))
1030
+ return d.debug(`There were multiple attempts to register component ${e}.`), !1;
1031
+ _.set(e, t);
1032
+ for (const n of g.values())
1033
+ G(n, t);
1034
+ for (const n of E.values())
1035
+ G(n, t);
1036
+ return !0;
1037
+ }
1038
+ function It(t, e) {
1039
+ const n = t.container.getProvider("heartbeat").getImmediate({ optional: !0 });
1040
+ return n && n.triggerHeartbeat(), t.container.getProvider(e);
1041
+ }
1042
+ function rn(t, e, n = A) {
1043
+ It(t, e).clearInstance(n);
1044
+ }
1045
+ function ce(t) {
1046
+ return t.options !== void 0;
1047
+ }
1048
+ function St(t) {
1049
+ return ce(t) ? !1 : "authIdToken" in t || "appCheckToken" in t || "releaseOnDeref" in t || "automaticDataCollectionEnabled" in t;
1050
+ }
1051
+ function sn(t) {
1052
+ return t == null ? !1 : t.settings !== void 0;
1053
+ }
1054
+ function on() {
1055
+ _.clear();
1056
+ }
1057
+ const At = {
1058
+ "no-app": "No Firebase App '{$appName}' has been created - call initializeApp() first",
1059
+ "bad-app-name": "Illegal App name: '{$appName}'",
1060
+ "duplicate-app": "Firebase App named '{$appName}' already exists with different {$mismatchedParam}. Existing: '{$oldValue}'. New: '{$newValue}'.",
1061
+ "app-deleted": "Firebase App named '{$appName}' already deleted",
1062
+ "server-app-deleted": "Firebase Server App has been deleted",
1063
+ "no-options": "Need to provide options, when not being deployed to hosting via source.",
1064
+ "invalid-app-argument": "firebase.{$appName}() takes either no argument or a Firebase App instance.",
1065
+ "invalid-log-argument": "First argument to `onLog` must be null or a function.",
1066
+ "idb-open": "Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",
1067
+ "idb-get": "Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",
1068
+ "idb-set": "Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",
1069
+ "idb-delete": "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",
1070
+ "finalization-registry-not-supported": "FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",
1071
+ "invalid-server-app-environment": "FirebaseServerApp is not for use in browser environments."
1072
+ }, h = new re("app", "Firebase", At);
1073
+ class le {
1074
+ constructor(e, n, r) {
1075
+ this._isDeleted = !1, this._options = { ...e }, this._config = { ...n }, this._name = n.name, this._automaticDataCollectionEnabled = n.automaticDataCollectionEnabled, this._container = r, this.container.addComponent(new I(
1076
+ "app",
1077
+ () => this,
1078
+ "PUBLIC"
1079
+ /* ComponentType.PUBLIC */
1080
+ ));
1081
+ }
1082
+ get automaticDataCollectionEnabled() {
1083
+ return this.checkDestroyed(), this._automaticDataCollectionEnabled;
1084
+ }
1085
+ set automaticDataCollectionEnabled(e) {
1086
+ this.checkDestroyed(), this._automaticDataCollectionEnabled = e;
1087
+ }
1088
+ get name() {
1089
+ return this.checkDestroyed(), this._name;
1090
+ }
1091
+ get options() {
1092
+ return this.checkDestroyed(), this._options;
1093
+ }
1094
+ get config() {
1095
+ return this.checkDestroyed(), this._config;
1096
+ }
1097
+ get container() {
1098
+ return this._container;
1099
+ }
1100
+ get isDeleted() {
1101
+ return this._isDeleted;
1102
+ }
1103
+ set isDeleted(e) {
1104
+ this._isDeleted = e;
1105
+ }
1106
+ /**
1107
+ * This function will throw an Error if the App has already been deleted -
1108
+ * use before performing API actions on the App.
1109
+ */
1110
+ checkDestroyed() {
1111
+ if (this.isDeleted)
1112
+ throw h.create("app-deleted", { appName: this._name });
1113
+ }
1114
+ }
1115
+ function J(t, e) {
1116
+ const n = ee(t.split(".")[1]);
1117
+ if (n === null) {
1118
+ console.error(`FirebaseServerApp ${e} is invalid: second part could not be parsed.`);
1119
+ return;
1120
+ }
1121
+ if (JSON.parse(n).exp === void 0) {
1122
+ console.error(`FirebaseServerApp ${e} is invalid: expiration claim could not be parsed`);
1123
+ return;
1124
+ }
1125
+ const s = JSON.parse(n).exp * 1e3, i = (/* @__PURE__ */ new Date()).getTime();
1126
+ s - i <= 0 && console.error(`FirebaseServerApp ${e} is invalid: the token has expired.`);
1127
+ }
1128
+ class Ot extends le {
1129
+ constructor(e, n, r, s) {
1130
+ const i = n.automaticDataCollectionEnabled !== void 0 ? n.automaticDataCollectionEnabled : !0, o = {
1131
+ name: r,
1132
+ automaticDataCollectionEnabled: i
1133
+ };
1134
+ if (e.apiKey !== void 0)
1135
+ super(e, o, s);
1136
+ else {
1137
+ const c = e;
1138
+ super(c.options, o, s);
1139
+ }
1140
+ this._serverConfig = {
1141
+ automaticDataCollectionEnabled: i,
1142
+ ...n
1143
+ }, this._serverConfig.authIdToken && J(this._serverConfig.authIdToken, "authIdToken"), this._serverConfig.appCheckToken && J(this._serverConfig.appCheckToken, "appCheckToken"), this._finalizationRegistry = null, typeof FinalizationRegistry < "u" && (this._finalizationRegistry = new FinalizationRegistry(() => {
1144
+ this.automaticCleanup();
1145
+ })), this._refCount = 0, this.incRefCount(this._serverConfig.releaseOnDeref), this._serverConfig.releaseOnDeref = void 0, n.releaseOnDeref = void 0, D(S, L, "serverapp");
1146
+ }
1147
+ toJSON() {
1148
+ }
1149
+ get refCount() {
1150
+ return this._refCount;
1151
+ }
1152
+ // Increment the reference count of this server app. If an object is provided, register it
1153
+ // with the finalization registry.
1154
+ incRefCount(e) {
1155
+ this.isDeleted || (this._refCount++, e !== void 0 && this._finalizationRegistry !== null && this._finalizationRegistry.register(e, this));
1156
+ }
1157
+ // Decrement the reference count.
1158
+ decRefCount() {
1159
+ return this.isDeleted ? 0 : --this._refCount;
1160
+ }
1161
+ // Invoked by the FinalizationRegistry callback to note that this app should go through its
1162
+ // reference counts and delete itself if no reference count remain. The coordinating logic that
1163
+ // handles this is in deleteApp(...).
1164
+ automaticCleanup() {
1165
+ Tt(this);
1166
+ }
1167
+ get settings() {
1168
+ return this.checkDestroyed(), this._serverConfig;
1169
+ }
1170
+ /**
1171
+ * This function will throw an Error if the App has already been deleted -
1172
+ * use before performing API actions on the App.
1173
+ */
1174
+ checkDestroyed() {
1175
+ if (this.isDeleted)
1176
+ throw h.create(
1177
+ "server-app-deleted"
1178
+ /* AppError.SERVER_APP_DELETED */
1179
+ );
1180
+ }
1181
+ }
1182
+ const an = Ct;
1183
+ function Bt(t, e = {}) {
1184
+ let n = t;
1185
+ typeof e != "object" && (e = { name: e });
1186
+ const r = {
1187
+ name: A,
1188
+ automaticDataCollectionEnabled: !0,
1189
+ ...e
1190
+ }, s = r.name;
1191
+ if (typeof s != "string" || !s)
1192
+ throw h.create("bad-app-name", {
1193
+ appName: String(s)
1194
+ });
1195
+ if (n || (n = H()), !n)
1196
+ throw h.create(
1197
+ "no-options"
1198
+ /* AppError.NO_OPTIONS */
1199
+ );
1200
+ const i = g.get(s);
1201
+ if (i)
1202
+ if (N(n, i.options)) {
1203
+ if (N(r, i.config))
1204
+ return i;
1205
+ throw h.create("duplicate-app", {
1206
+ appName: s,
1207
+ mismatchedParam: "config",
1208
+ oldValue: JSON.stringify(i.config),
1209
+ newValue: JSON.stringify(r)
1210
+ });
1211
+ } else throw h.create("duplicate-app", {
1212
+ appName: s,
1213
+ mismatchedParam: "options",
1214
+ oldValue: JSON.stringify(i.options),
1215
+ newValue: JSON.stringify(n)
1216
+ });
1217
+ const o = new se(s);
1218
+ for (const a of _.values())
1219
+ o.addComponent(a);
1220
+ const c = new le(n, r, o);
1221
+ return g.set(s, c), c;
1222
+ }
1223
+ function cn(t, e = {}) {
1224
+ if (we() && !ne())
1225
+ throw h.create(
1226
+ "invalid-server-app-environment"
1227
+ /* AppError.INVALID_SERVER_APP_ENVIRONMENT */
1228
+ );
1229
+ let n, r = e || {};
1230
+ if (t && (ce(t) ? n = t.options : St(t) ? r = t : n = t), r.automaticDataCollectionEnabled === void 0 && (r.automaticDataCollectionEnabled = !0), n || (n = H()), !n)
1231
+ throw h.create(
1232
+ "no-options"
1233
+ /* AppError.NO_OPTIONS */
1234
+ );
1235
+ const s = {
1236
+ ...r,
1237
+ ...n
1238
+ };
1239
+ s.releaseOnDeref !== void 0 && delete s.releaseOnDeref;
1240
+ const i = (b) => [...b].reduce((p, y) => Math.imul(31, p) + y.charCodeAt(0) | 0, 0);
1241
+ if (r.releaseOnDeref !== void 0 && typeof FinalizationRegistry > "u")
1242
+ throw h.create("finalization-registry-not-supported", {});
1243
+ const o = "" + i(JSON.stringify(s)), c = E.get(o);
1244
+ if (c)
1245
+ return c.incRefCount(r.releaseOnDeref), c;
1246
+ const a = new se(o);
1247
+ for (const b of _.values())
1248
+ a.addComponent(b);
1249
+ const f = new Ot(n, r, o, a);
1250
+ return E.set(o, f), f;
1251
+ }
1252
+ function ln(t = A) {
1253
+ const e = g.get(t);
1254
+ if (!e && t === A && H())
1255
+ return Bt();
1256
+ if (!e)
1257
+ throw h.create("no-app", { appName: t });
1258
+ return e;
1259
+ }
1260
+ function fn() {
1261
+ return Array.from(g.values());
1262
+ }
1263
+ async function Tt(t) {
1264
+ let e = !1;
1265
+ const n = t.name;
1266
+ g.has(n) ? (e = !0, g.delete(n)) : E.has(n) && t.decRefCount() <= 0 && (E.delete(n), e = !0), e && (await Promise.all(t.container.getProviders().map((r) => r.delete())), t.isDeleted = !0);
1267
+ }
1268
+ function D(t, e, n) {
1269
+ let r = Dt[t] ?? t;
1270
+ n && (r += `-${n}`);
1271
+ const s = r.match(/\s|\//), i = e.match(/\s|\//);
1272
+ if (s || i) {
1273
+ const o = [
1274
+ `Unable to register library "${r}" with version "${e}":`
1275
+ ];
1276
+ s && o.push(`library name "${r}" contains illegal characters (whitespace or "/")`), s && i && o.push("and"), i && o.push(`version name "${e}" contains illegal characters (whitespace or "/")`), d.warn(o.join(" "));
1277
+ return;
1278
+ }
1279
+ k(new I(
1280
+ `${r}-version`,
1281
+ () => ({ library: r, version: e }),
1282
+ "VERSION"
1283
+ /* ComponentType.VERSION */
1284
+ ));
1285
+ }
1286
+ function hn(t, e) {
1287
+ if (t !== null && typeof t != "function")
1288
+ throw h.create(
1289
+ "invalid-log-argument"
1290
+ /* AppError.INVALID_LOG_ARGUMENT */
1291
+ );
1292
+ ke(t, e);
1293
+ }
1294
+ function dn(t) {
1295
+ Le(t);
1296
+ }
1297
+ const Rt = "firebase-heartbeat-database", xt = 1, v = "firebase-heartbeat-store";
1298
+ let x = null;
1299
+ function fe() {
1300
+ return x || (x = Ge(Rt, xt, {
1301
+ upgrade: (t, e) => {
1302
+ switch (e) {
1303
+ case 0:
1304
+ try {
1305
+ t.createObjectStore(v);
1306
+ } catch (n) {
1307
+ console.warn(n);
1308
+ }
1309
+ }
1310
+ }
1311
+ }).catch((t) => {
1312
+ throw h.create("idb-open", {
1313
+ originalErrorMessage: t.message
1314
+ });
1315
+ })), x;
1316
+ }
1317
+ async function Nt(t) {
1318
+ try {
1319
+ const n = (await fe()).transaction(v), r = await n.objectStore(v).get(he(t));
1320
+ return await n.done, r;
1321
+ } catch (e) {
1322
+ if (e instanceof w)
1323
+ d.warn(e.message);
1324
+ else {
1325
+ const n = h.create("idb-get", {
1326
+ originalErrorMessage: e?.message
1327
+ });
1328
+ d.warn(n.message);
1329
+ }
1330
+ }
1331
+ }
1332
+ async function K(t, e) {
1333
+ try {
1334
+ const r = (await fe()).transaction(v, "readwrite");
1335
+ await r.objectStore(v).put(e, he(t)), await r.done;
1336
+ } catch (n) {
1337
+ if (n instanceof w)
1338
+ d.warn(n.message);
1339
+ else {
1340
+ const r = h.create("idb-set", {
1341
+ originalErrorMessage: n?.message
1342
+ });
1343
+ d.warn(r.message);
1344
+ }
1345
+ }
1346
+ }
1347
+ function he(t) {
1348
+ return `${t.name}!${t.options.appId}`;
1349
+ }
1350
+ const Mt = 1024, $t = 30;
1351
+ class Lt {
1352
+ constructor(e) {
1353
+ this.container = e, this._heartbeatsCache = null;
1354
+ const n = this.container.getProvider("app").getImmediate();
1355
+ this._storage = new Pt(n), this._heartbeatsCachePromise = this._storage.read().then((r) => (this._heartbeatsCache = r, r));
1356
+ }
1357
+ /**
1358
+ * Called to report a heartbeat. The function will generate
1359
+ * a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
1360
+ * to IndexedDB.
1361
+ * Note that we only store one heartbeat per day. So if a heartbeat for today is
1362
+ * already logged, subsequent calls to this function in the same day will be ignored.
1363
+ */
1364
+ async triggerHeartbeat() {
1365
+ try {
1366
+ const n = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(), r = Y();
1367
+ if (this._heartbeatsCache?.heartbeats == null && (this._heartbeatsCache = await this._heartbeatsCachePromise, this._heartbeatsCache?.heartbeats == null) || this._heartbeatsCache.lastSentHeartbeatDate === r || this._heartbeatsCache.heartbeats.some((s) => s.date === r))
1368
+ return;
1369
+ if (this._heartbeatsCache.heartbeats.push({ date: r, agent: n }), this._heartbeatsCache.heartbeats.length > $t) {
1370
+ const s = Ht(this._heartbeatsCache.heartbeats);
1371
+ this._heartbeatsCache.heartbeats.splice(s, 1);
1372
+ }
1373
+ return this._storage.overwrite(this._heartbeatsCache);
1374
+ } catch (e) {
1375
+ d.warn(e);
1376
+ }
1377
+ }
1378
+ /**
1379
+ * Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
1380
+ * It also clears all heartbeats from memory as well as in IndexedDB.
1381
+ *
1382
+ * NOTE: Consuming product SDKs should not send the header if this method
1383
+ * returns an empty string.
1384
+ */
1385
+ async getHeartbeatsHeader() {
1386
+ try {
1387
+ if (this._heartbeatsCache === null && await this._heartbeatsCachePromise, this._heartbeatsCache?.heartbeats == null || this._heartbeatsCache.heartbeats.length === 0)
1388
+ return "";
1389
+ const e = Y(), { heartbeatsToSend: n, unsentEntries: r } = kt(this._heartbeatsCache.heartbeats), s = Z(JSON.stringify({ version: 2, heartbeats: n }));
1390
+ return this._heartbeatsCache.lastSentHeartbeatDate = e, r.length > 0 ? (this._heartbeatsCache.heartbeats = r, await this._storage.overwrite(this._heartbeatsCache)) : (this._heartbeatsCache.heartbeats = [], this._storage.overwrite(this._heartbeatsCache)), s;
1391
+ } catch (e) {
1392
+ return d.warn(e), "";
1393
+ }
1394
+ }
1395
+ }
1396
+ function Y() {
1397
+ return (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
1398
+ }
1399
+ function kt(t, e = Mt) {
1400
+ const n = [];
1401
+ let r = t.slice();
1402
+ for (const s of t) {
1403
+ const i = n.find((o) => o.agent === s.agent);
1404
+ if (i) {
1405
+ if (i.dates.push(s.date), q(n) > e) {
1406
+ i.dates.pop();
1407
+ break;
1408
+ }
1409
+ } else if (n.push({
1410
+ agent: s.agent,
1411
+ dates: [s.date]
1412
+ }), q(n) > e) {
1413
+ n.pop();
1414
+ break;
1415
+ }
1416
+ r = r.slice(1);
1417
+ }
1418
+ return {
1419
+ heartbeatsToSend: n,
1420
+ unsentEntries: r
1421
+ };
1422
+ }
1423
+ class Pt {
1424
+ constructor(e) {
1425
+ this.app = e, this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck();
1426
+ }
1427
+ async runIndexedDBEnvironmentCheck() {
1428
+ return Ce() ? De().then(() => !0).catch(() => !1) : !1;
1429
+ }
1430
+ /**
1431
+ * Read all heartbeats.
1432
+ */
1433
+ async read() {
1434
+ if (await this._canUseIndexedDBPromise) {
1435
+ const n = await Nt(this.app);
1436
+ return n?.heartbeats ? n : { heartbeats: [] };
1437
+ } else
1438
+ return { heartbeats: [] };
1439
+ }
1440
+ // overwrite the storage with the provided heartbeats
1441
+ async overwrite(e) {
1442
+ if (await this._canUseIndexedDBPromise) {
1443
+ const r = await this.read();
1444
+ return K(this.app, {
1445
+ lastSentHeartbeatDate: e.lastSentHeartbeatDate ?? r.lastSentHeartbeatDate,
1446
+ heartbeats: e.heartbeats
1447
+ });
1448
+ } else
1449
+ return;
1450
+ }
1451
+ // add heartbeats
1452
+ async add(e) {
1453
+ if (await this._canUseIndexedDBPromise) {
1454
+ const r = await this.read();
1455
+ return K(this.app, {
1456
+ lastSentHeartbeatDate: e.lastSentHeartbeatDate ?? r.lastSentHeartbeatDate,
1457
+ heartbeats: [
1458
+ ...r.heartbeats,
1459
+ ...e.heartbeats
1460
+ ]
1461
+ });
1462
+ } else
1463
+ return;
1464
+ }
1465
+ }
1466
+ function q(t) {
1467
+ return Z(
1468
+ // heartbeatsCache wrapper properties
1469
+ JSON.stringify({ version: 2, heartbeats: t })
1470
+ ).length;
1471
+ }
1472
+ function Ht(t) {
1473
+ if (t.length === 0)
1474
+ return -1;
1475
+ let e = 0, n = t[0].date;
1476
+ for (let r = 1; r < t.length; r++)
1477
+ t[r].date < n && (n = t[r].date, e = r);
1478
+ return e;
1479
+ }
1480
+ function Ft(t) {
1481
+ k(new I(
1482
+ "platform-logger",
1483
+ (e) => new Ye(e),
1484
+ "PRIVATE"
1485
+ /* ComponentType.PRIVATE */
1486
+ )), k(new I(
1487
+ "heartbeat",
1488
+ (e) => new Lt(e),
1489
+ "PRIVATE"
1490
+ /* ComponentType.PRIVATE */
1491
+ )), D(S, L, t), D(S, L, "esm2020"), D("fire-js", "");
1492
+ }
1493
+ Ft("");
1494
+ export {
1495
+ Vt as A,
1496
+ zt as B,
1497
+ te as C,
1498
+ A as D,
1499
+ Jt as E,
1500
+ w as F,
1501
+ Kt as G,
1502
+ ee as H,
1503
+ l as I,
1504
+ re as J,
1505
+ Ut as K,
1506
+ $e as L,
1507
+ Gt as M,
1508
+ ve as N,
1509
+ jt as O,
1510
+ Wt as P,
1511
+ I as Q,
1512
+ Qt as R,
1513
+ an as S,
1514
+ G as _,
1515
+ nn as a,
1516
+ g as b,
1517
+ on as c,
1518
+ _ as d,
1519
+ It as e,
1520
+ ce as f,
1521
+ sn as g,
1522
+ St as h,
1523
+ k as i,
1524
+ rn as j,
1525
+ E as k,
1526
+ Tt as l,
1527
+ ln as m,
1528
+ fn as n,
1529
+ Bt as o,
1530
+ cn as p,
1531
+ hn as q,
1532
+ D as r,
1533
+ dn as s,
1534
+ qt as t,
1535
+ Xt as u,
1536
+ Yt as v,
1537
+ Zt as w,
1538
+ N as x,
1539
+ en as y,
1540
+ tn as z
1541
+ };