@feedmepos/mf-settings 0.0.49 → 0.0.50-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/App-22eddb78.js +4352 -0
  2. package/dist/{Business-618e5ec3.js → Business-416835ab.js} +57 -52
  3. package/dist/{CreateBusiness-8f569ca5.js → CreateBusiness-138ac258.js} +21 -22
  4. package/dist/{FoodCourt-b50a5495.js → FoodCourt-561cd7e3.js} +24 -26
  5. package/dist/{ResponsiveFabButton.vue_vue_type_script_setup_true_lang-664bb402.js → ResponsiveFabButton.vue_vue_type_script_setup_true_lang-977372d5.js} +1 -1
  6. package/dist/Tagging-b746a5f3.js +6683 -0
  7. package/dist/actionButton-cc6bcf01.js +66 -0
  8. package/dist/app-abfabbcf.js +782 -0
  9. package/dist/app.js +6 -9
  10. package/dist/apps/mf-settings/src/app.d.ts +1 -2
  11. package/dist/apps/mf-settings/src/components/business/RestaurantForm.vue.d.ts +1 -1
  12. package/dist/apps/mf-settings/src/components/tagging/TaggingForm.vue.d.ts +3 -3
  13. package/dist/apps/mf-settings/src/init.d.ts +1 -0
  14. package/dist/apps/mf-settings/src/store/attributeSettings.d.ts +15 -15
  15. package/dist/apps/mf-settings/tsconfig.app.tsbuildinfo +1 -1
  16. package/dist/business-9a4e5bd7.js +31 -0
  17. package/dist/createForm-681e977a.js +64 -0
  18. package/dist/{index-3dd7fe2c.js → index-1eb3cc0a.js} +1 -1
  19. package/dist/index-f1e5e565.js +10903 -0
  20. package/dist/index.esm2017-c60b1ce5.js +3147 -0
  21. package/dist/loading-84215dce.js +2385 -0
  22. package/dist/packages/shared/src/components/form/ImageDropField.vue.d.ts +1 -1
  23. package/dist/packages/shared/src/components/info/TextChip.vue.d.ts +1 -1
  24. package/dist/packages/shared/src/components/loading/PageLoading.vue.d.ts +2 -0
  25. package/dist/packages/shared/src/components/loading/index.d.ts +1 -0
  26. package/package.json +4 -4
  27. package/dist/App-358f23fc.js +0 -53
  28. package/dist/app-050b47dd.js +0 -34303
@@ -0,0 +1,4352 @@
1
+ import { defineComponent as Ye, computed as Pe, ref as xt, watchEffect as Vt, resolveComponent as Wt, openBlock as Xe, createBlock as Qe, onMounted as Ht, unref as $t } from "vue";
2
+ import { useRouter as jt, RouterView as Bt } from "vue-router";
3
+ import { useI18n as Kt, useCoreStore as Ze, FeedMeAuth as qt } from "@feedmepos/mf-common";
4
+ import { r as Gt } from "./app-abfabbcf.js";
5
+ import { c as zt } from "./index-1eb3cc0a.js";
6
+ import { e as Jt } from "./index-f1e5e565.js";
7
+ import { r as de, g as et, i as Yt, a as Xt, _ as Ne, C as Oe, b as Qt, S as F, c as O, E as pe, d as Zt, e as tt, f as en, h as tn, L as nt, j as f, k as nn, l as rn, F as ge, q as x, m as sn, n as on, o as an, p as cn, s as ln, t as un, u as dn, v as hn } from "./index.esm2017-c60b1ce5.js";
8
+ import "@feedmepos/mf-mdm";
9
+ import "@feedmepos/ui-library";
10
+ import "@feedmepos/mf-e-invoice";
11
+ function me(n, e) {
12
+ var t = {};
13
+ for (var i in n)
14
+ Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
15
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
16
+ for (var r = 0, i = Object.getOwnPropertySymbols(n); r < i.length; r++)
17
+ e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
18
+ return t;
19
+ }
20
+ const fn = /* @__PURE__ */ Ye({
21
+ __name: "NavigationTab",
22
+ emits: ["close-navigation"],
23
+ setup(n, { emit: e }) {
24
+ const t = e, { t: i } = Kt(), r = jt(), s = Ze(), o = Pe(() => s.restaurants.value.some(({ posVersion: l }) => zt.Pos.canUse({ feature: Jt.F_FEATURE.Enum.templateBuilder, posVersion: l ?? "" }))), c = Pe(() => Gt.filter((d) => {
25
+ var h;
26
+ return d.redirect || (h = d.meta) != null && h.hideNavigation ? !1 : !(d.name === "$settings-template-builder" && !o.value);
27
+ }).map((d) => {
28
+ var h;
29
+ return {
30
+ label: i((h = d.meta) == null ? void 0 : h.i18nKey),
31
+ value: d.name,
32
+ action: () => {
33
+ d.name === "$settings-e-invoice" ? r.push({ name: "SUBMISSION" }) : d.name === "$settings-device" ? r.push({ name: "$devices" }) : r.push({ name: d.name }), t("close-navigation");
34
+ }
35
+ };
36
+ })), a = xt();
37
+ return Vt(() => {
38
+ var d;
39
+ const l = (d = r.currentRoute.value) == null ? void 0 : d.name;
40
+ l === "SUBMISSION" ? a.value = "$settings-e-invoice" : l === "$devices" ? a.value = "$settings-device" : a.value = l;
41
+ }), (l, d) => {
42
+ const h = Wt("fm-collapsible-tabs");
43
+ return Xe(), Qe(h, {
44
+ modelValue: a.value,
45
+ "onUpdate:modelValue": d[0] || (d[0] = (p) => a.value = p),
46
+ items: c.value,
47
+ class: "py-16 px-8"
48
+ }, null, 8, ["modelValue", "items"]);
49
+ };
50
+ }
51
+ });
52
+ class M {
53
+ constructor(e = null, t = {}) {
54
+ if (this.apiKey = e, this.options = t, typeof window > "u")
55
+ throw new Error("google-maps is supported only in browser environment");
56
+ }
57
+ load() {
58
+ return typeof this.api < "u" ? Promise.resolve(this.api) : typeof this.loader < "u" ? this.loader : (window[M.CALLBACK_NAME] = () => {
59
+ if (this.api = window.google, typeof this.resolve > "u")
60
+ throw new Error("Should not happen");
61
+ this.resolve(this.api);
62
+ }, window.gm_authFailure = () => {
63
+ if (typeof this.reject > "u")
64
+ throw new Error("Should not happen");
65
+ this.reject(new Error("google-maps: authentication error"));
66
+ }, this.loader = new Promise((e, t) => {
67
+ this.resolve = e, this.reject = t;
68
+ const i = document.createElement("script");
69
+ i.src = this.createUrl(), i.async = !0, i.onerror = (r) => t(r), document.head.appendChild(i);
70
+ }));
71
+ }
72
+ createUrl() {
73
+ const e = [
74
+ `callback=${M.CALLBACK_NAME}`
75
+ ];
76
+ this.apiKey && e.push(`key=${this.apiKey}`);
77
+ for (let t in this.options)
78
+ if (this.options.hasOwnProperty(t)) {
79
+ let i = this.options[t];
80
+ t === "version" && (t = "v"), t === "libraries" && (i = i.join(",")), e.push(`${t}=${i}`);
81
+ }
82
+ return `https://maps.googleapis.com/maps/api/js?${e.join("&")}`;
83
+ }
84
+ }
85
+ M.CALLBACK_NAME = "_dk_google_maps_loader_cb";
86
+ var pn = "firebase", gn = "9.23.0";
87
+ /**
88
+ * @license
89
+ * Copyright 2020 Google LLC
90
+ *
91
+ * Licensed under the Apache License, Version 2.0 (the "License");
92
+ * you may not use this file except in compliance with the License.
93
+ * You may obtain a copy of the License at
94
+ *
95
+ * http://www.apache.org/licenses/LICENSE-2.0
96
+ *
97
+ * Unless required by applicable law or agreed to in writing, software
98
+ * distributed under the License is distributed on an "AS IS" BASIS,
99
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
100
+ * See the License for the specific language governing permissions and
101
+ * limitations under the License.
102
+ */
103
+ de(pn, gn, "app");
104
+ function it() {
105
+ return {
106
+ "dependent-sdk-initialized-before-auth": "Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."
107
+ };
108
+ }
109
+ const mn = it, rt = new pe("auth", "Firebase", it());
110
+ /**
111
+ * @license
112
+ * Copyright 2020 Google LLC
113
+ *
114
+ * Licensed under the Apache License, Version 2.0 (the "License");
115
+ * you may not use this file except in compliance with the License.
116
+ * You may obtain a copy of the License at
117
+ *
118
+ * http://www.apache.org/licenses/LICENSE-2.0
119
+ *
120
+ * Unless required by applicable law or agreed to in writing, software
121
+ * distributed under the License is distributed on an "AS IS" BASIS,
122
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123
+ * See the License for the specific language governing permissions and
124
+ * limitations under the License.
125
+ */
126
+ const X = new rn("@firebase/auth");
127
+ function _n(n, ...e) {
128
+ X.logLevel <= nt.WARN && X.warn(`Auth (${F}): ${n}`, ...e);
129
+ }
130
+ function G(n, ...e) {
131
+ X.logLevel <= nt.ERROR && X.error(`Auth (${F}): ${n}`, ...e);
132
+ }
133
+ /**
134
+ * @license
135
+ * Copyright 2020 Google LLC
136
+ *
137
+ * Licensed under the Apache License, Version 2.0 (the "License");
138
+ * you may not use this file except in compliance with the License.
139
+ * You may obtain a copy of the License at
140
+ *
141
+ * http://www.apache.org/licenses/LICENSE-2.0
142
+ *
143
+ * Unless required by applicable law or agreed to in writing, software
144
+ * distributed under the License is distributed on an "AS IS" BASIS,
145
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
146
+ * See the License for the specific language governing permissions and
147
+ * limitations under the License.
148
+ */
149
+ function I(n, ...e) {
150
+ throw _e(n, ...e);
151
+ }
152
+ function g(n, ...e) {
153
+ return _e(n, ...e);
154
+ }
155
+ function vn(n, e, t) {
156
+ const i = Object.assign(Object.assign({}, mn()), { [e]: t });
157
+ return new pe("auth", "Firebase", i).create(e, {
158
+ appName: n.name
159
+ });
160
+ }
161
+ function _e(n, ...e) {
162
+ if (typeof n != "string") {
163
+ const t = e[0], i = [...e.slice(1)];
164
+ return i[0] && (i[0].appName = n.name), n._errorFactory.create(t, ...i);
165
+ }
166
+ return rt.create(n, ...e);
167
+ }
168
+ function u(n, e, ...t) {
169
+ if (!n)
170
+ throw _e(e, ...t);
171
+ }
172
+ function _(n) {
173
+ const e = "INTERNAL ASSERTION FAILED: " + n;
174
+ throw G(e), new Error(e);
175
+ }
176
+ function y(n, e) {
177
+ n || _(e);
178
+ }
179
+ /**
180
+ * @license
181
+ * Copyright 2020 Google LLC
182
+ *
183
+ * Licensed under the Apache License, Version 2.0 (the "License");
184
+ * you may not use this file except in compliance with the License.
185
+ * You may obtain a copy of the License at
186
+ *
187
+ * http://www.apache.org/licenses/LICENSE-2.0
188
+ *
189
+ * Unless required by applicable law or agreed to in writing, software
190
+ * distributed under the License is distributed on an "AS IS" BASIS,
191
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ * See the License for the specific language governing permissions and
193
+ * limitations under the License.
194
+ */
195
+ function he() {
196
+ var n;
197
+ return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.href) || "";
198
+ }
199
+ function In() {
200
+ return Le() === "http:" || Le() === "https:";
201
+ }
202
+ function Le() {
203
+ var n;
204
+ return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.protocol) || null;
205
+ }
206
+ /**
207
+ * @license
208
+ * Copyright 2020 Google LLC
209
+ *
210
+ * Licensed under the Apache License, Version 2.0 (the "License");
211
+ * you may not use this file except in compliance with the License.
212
+ * You may obtain a copy of the License at
213
+ *
214
+ * http://www.apache.org/licenses/LICENSE-2.0
215
+ *
216
+ * Unless required by applicable law or agreed to in writing, software
217
+ * distributed under the License is distributed on an "AS IS" BASIS,
218
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
219
+ * See the License for the specific language governing permissions and
220
+ * limitations under the License.
221
+ */
222
+ function yn() {
223
+ return typeof navigator < "u" && navigator && "onLine" in navigator && typeof navigator.onLine == "boolean" && // Apply only for traditional web apps and Chrome extensions.
224
+ // This is especially true for Cordova apps which have unreliable
225
+ // navigator.onLine behavior unless cordova-plugin-network-information is
226
+ // installed which overwrites the native navigator.onLine value and
227
+ // defines navigator.connection.
228
+ (In() || Qt() || "connection" in navigator) ? navigator.onLine : !0;
229
+ }
230
+ function Tn() {
231
+ if (typeof navigator > "u")
232
+ return null;
233
+ const n = navigator;
234
+ return (
235
+ // Most reliable, but only supported in Chrome/Firefox.
236
+ n.languages && n.languages[0] || // Supported in most browsers, but returns the language of the browser
237
+ // UI, not the language set in browser settings.
238
+ n.language || // Couldn't determine language.
239
+ null
240
+ );
241
+ }
242
+ /**
243
+ * @license
244
+ * Copyright 2020 Google LLC
245
+ *
246
+ * Licensed under the Apache License, Version 2.0 (the "License");
247
+ * you may not use this file except in compliance with the License.
248
+ * You may obtain a copy of the License at
249
+ *
250
+ * http://www.apache.org/licenses/LICENSE-2.0
251
+ *
252
+ * Unless required by applicable law or agreed to in writing, software
253
+ * distributed under the License is distributed on an "AS IS" BASIS,
254
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
255
+ * See the License for the specific language governing permissions and
256
+ * limitations under the License.
257
+ */
258
+ class V {
259
+ constructor(e, t) {
260
+ this.shortDelay = e, this.longDelay = t, y(t > e, "Short delay should be less than long delay!"), this.isMobile = Yt() || Xt();
261
+ }
262
+ get() {
263
+ return yn() ? this.isMobile ? this.longDelay : this.shortDelay : Math.min(5e3, this.shortDelay);
264
+ }
265
+ }
266
+ /**
267
+ * @license
268
+ * Copyright 2020 Google LLC
269
+ *
270
+ * Licensed under the Apache License, Version 2.0 (the "License");
271
+ * you may not use this file except in compliance with the License.
272
+ * You may obtain a copy of the License at
273
+ *
274
+ * http://www.apache.org/licenses/LICENSE-2.0
275
+ *
276
+ * Unless required by applicable law or agreed to in writing, software
277
+ * distributed under the License is distributed on an "AS IS" BASIS,
278
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
279
+ * See the License for the specific language governing permissions and
280
+ * limitations under the License.
281
+ */
282
+ function ve(n, e) {
283
+ y(n.emulator, "Emulator should always be set here");
284
+ const { url: t } = n.emulator;
285
+ return e ? `${t}${e.startsWith("/") ? e.slice(1) : e}` : t;
286
+ }
287
+ /**
288
+ * @license
289
+ * Copyright 2020 Google LLC
290
+ *
291
+ * Licensed under the Apache License, Version 2.0 (the "License");
292
+ * you may not use this file except in compliance with the License.
293
+ * You may obtain a copy of the License at
294
+ *
295
+ * http://www.apache.org/licenses/LICENSE-2.0
296
+ *
297
+ * Unless required by applicable law or agreed to in writing, software
298
+ * distributed under the License is distributed on an "AS IS" BASIS,
299
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
300
+ * See the License for the specific language governing permissions and
301
+ * limitations under the License.
302
+ */
303
+ class st {
304
+ static initialize(e, t, i) {
305
+ this.fetchImpl = e, t && (this.headersImpl = t), i && (this.responseImpl = i);
306
+ }
307
+ static fetch() {
308
+ if (this.fetchImpl)
309
+ return this.fetchImpl;
310
+ if (typeof self < "u" && "fetch" in self)
311
+ return self.fetch;
312
+ _("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
313
+ }
314
+ static headers() {
315
+ if (this.headersImpl)
316
+ return this.headersImpl;
317
+ if (typeof self < "u" && "Headers" in self)
318
+ return self.Headers;
319
+ _("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
320
+ }
321
+ static response() {
322
+ if (this.responseImpl)
323
+ return this.responseImpl;
324
+ if (typeof self < "u" && "Response" in self)
325
+ return self.Response;
326
+ _("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
327
+ }
328
+ }
329
+ /**
330
+ * @license
331
+ * Copyright 2020 Google LLC
332
+ *
333
+ * Licensed under the Apache License, Version 2.0 (the "License");
334
+ * you may not use this file except in compliance with the License.
335
+ * You may obtain a copy of the License at
336
+ *
337
+ * http://www.apache.org/licenses/LICENSE-2.0
338
+ *
339
+ * Unless required by applicable law or agreed to in writing, software
340
+ * distributed under the License is distributed on an "AS IS" BASIS,
341
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
342
+ * See the License for the specific language governing permissions and
343
+ * limitations under the License.
344
+ */
345
+ const wn = {
346
+ // Custom token errors.
347
+ CREDENTIAL_MISMATCH: "custom-token-mismatch",
348
+ // This can only happen if the SDK sends a bad request.
349
+ MISSING_CUSTOM_TOKEN: "internal-error",
350
+ // Create Auth URI errors.
351
+ INVALID_IDENTIFIER: "invalid-email",
352
+ // This can only happen if the SDK sends a bad request.
353
+ MISSING_CONTINUE_URI: "internal-error",
354
+ // Sign in with email and password errors (some apply to sign up too).
355
+ INVALID_PASSWORD: "wrong-password",
356
+ // This can only happen if the SDK sends a bad request.
357
+ MISSING_PASSWORD: "missing-password",
358
+ // Sign up with email and password errors.
359
+ EMAIL_EXISTS: "email-already-in-use",
360
+ PASSWORD_LOGIN_DISABLED: "operation-not-allowed",
361
+ // Verify assertion for sign in with credential errors:
362
+ INVALID_IDP_RESPONSE: "invalid-credential",
363
+ INVALID_PENDING_TOKEN: "invalid-credential",
364
+ FEDERATED_USER_ID_ALREADY_LINKED: "credential-already-in-use",
365
+ // This can only happen if the SDK sends a bad request.
366
+ MISSING_REQ_TYPE: "internal-error",
367
+ // Send Password reset email errors:
368
+ EMAIL_NOT_FOUND: "user-not-found",
369
+ RESET_PASSWORD_EXCEED_LIMIT: "too-many-requests",
370
+ EXPIRED_OOB_CODE: "expired-action-code",
371
+ INVALID_OOB_CODE: "invalid-action-code",
372
+ // This can only happen if the SDK sends a bad request.
373
+ MISSING_OOB_CODE: "internal-error",
374
+ // Operations that require ID token in request:
375
+ CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "requires-recent-login",
376
+ INVALID_ID_TOKEN: "invalid-user-token",
377
+ TOKEN_EXPIRED: "user-token-expired",
378
+ USER_NOT_FOUND: "user-token-expired",
379
+ // Other errors.
380
+ TOO_MANY_ATTEMPTS_TRY_LATER: "too-many-requests",
381
+ // Phone Auth related errors.
382
+ INVALID_CODE: "invalid-verification-code",
383
+ INVALID_SESSION_INFO: "invalid-verification-id",
384
+ INVALID_TEMPORARY_PROOF: "invalid-credential",
385
+ MISSING_SESSION_INFO: "missing-verification-id",
386
+ SESSION_EXPIRED: "code-expired",
387
+ // Other action code errors when additional settings passed.
388
+ // MISSING_CONTINUE_URI is getting mapped to INTERNAL_ERROR above.
389
+ // This is OK as this error will be caught by client side validation.
390
+ MISSING_ANDROID_PACKAGE_NAME: "missing-android-pkg-name",
391
+ UNAUTHORIZED_DOMAIN: "unauthorized-continue-uri",
392
+ // getProjectConfig errors when clientId is passed.
393
+ INVALID_OAUTH_CLIENT_ID: "invalid-oauth-client-id",
394
+ // User actions (sign-up or deletion) disabled errors.
395
+ ADMIN_ONLY_OPERATION: "admin-restricted-operation",
396
+ // Multi factor related errors.
397
+ INVALID_MFA_PENDING_CREDENTIAL: "invalid-multi-factor-session",
398
+ MFA_ENROLLMENT_NOT_FOUND: "multi-factor-info-not-found",
399
+ MISSING_MFA_ENROLLMENT_ID: "missing-multi-factor-info",
400
+ MISSING_MFA_PENDING_CREDENTIAL: "missing-multi-factor-session",
401
+ SECOND_FACTOR_EXISTS: "second-factor-already-in-use",
402
+ SECOND_FACTOR_LIMIT_EXCEEDED: "maximum-second-factor-count-exceeded",
403
+ // Blocking functions related errors.
404
+ BLOCKING_FUNCTION_ERROR_RESPONSE: "internal-error",
405
+ // Recaptcha related errors.
406
+ RECAPTCHA_NOT_ENABLED: "recaptcha-not-enabled",
407
+ MISSING_RECAPTCHA_TOKEN: "missing-recaptcha-token",
408
+ INVALID_RECAPTCHA_TOKEN: "invalid-recaptcha-token",
409
+ INVALID_RECAPTCHA_ACTION: "invalid-recaptcha-action",
410
+ MISSING_CLIENT_TYPE: "missing-client-type",
411
+ MISSING_RECAPTCHA_VERSION: "missing-recaptcha-version",
412
+ INVALID_RECAPTCHA_VERSION: "invalid-recaptcha-version",
413
+ INVALID_REQ_TYPE: "invalid-req-type"
414
+ /* AuthErrorCode.INVALID_REQ_TYPE */
415
+ };
416
+ /**
417
+ * @license
418
+ * Copyright 2020 Google LLC
419
+ *
420
+ * Licensed under the Apache License, Version 2.0 (the "License");
421
+ * you may not use this file except in compliance with the License.
422
+ * You may obtain a copy of the License at
423
+ *
424
+ * http://www.apache.org/licenses/LICENSE-2.0
425
+ *
426
+ * Unless required by applicable law or agreed to in writing, software
427
+ * distributed under the License is distributed on an "AS IS" BASIS,
428
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
429
+ * See the License for the specific language governing permissions and
430
+ * limitations under the License.
431
+ */
432
+ const En = new V(3e4, 6e4);
433
+ function Ie(n, e) {
434
+ return n.tenantId && !e.tenantId ? Object.assign(Object.assign({}, e), { tenantId: n.tenantId }) : e;
435
+ }
436
+ async function W(n, e, t, i, r = {}) {
437
+ return ot(n, r, async () => {
438
+ let s = {}, o = {};
439
+ i && (e === "GET" ? o = i : s = {
440
+ body: JSON.stringify(i)
441
+ });
442
+ const c = x(Object.assign({ key: n.config.apiKey }, o)).slice(1), a = await n._getAdditionalHeaders();
443
+ return a[
444
+ "Content-Type"
445
+ /* HttpHeader.CONTENT_TYPE */
446
+ ] = "application/json", n.languageCode && (a[
447
+ "X-Firebase-Locale"
448
+ /* HttpHeader.X_FIREBASE_LOCALE */
449
+ ] = n.languageCode), st.fetch()(ct(n, n.config.apiHost, t, c), Object.assign({
450
+ method: e,
451
+ headers: a,
452
+ referrerPolicy: "no-referrer"
453
+ }, s));
454
+ });
455
+ }
456
+ async function ot(n, e, t) {
457
+ n._canInitEmulator = !1;
458
+ const i = Object.assign(Object.assign({}, wn), e);
459
+ try {
460
+ const r = new kn(n), s = await Promise.race([
461
+ t(),
462
+ r.promise
463
+ ]);
464
+ r.clearNetworkTimeout();
465
+ const o = await s.json();
466
+ if ("needConfirmation" in o)
467
+ throw q(n, "account-exists-with-different-credential", o);
468
+ if (s.ok && !("errorMessage" in o))
469
+ return o;
470
+ {
471
+ const c = s.ok ? o.errorMessage : o.error.message, [a, l] = c.split(" : ");
472
+ if (a === "FEDERATED_USER_ID_ALREADY_LINKED")
473
+ throw q(n, "credential-already-in-use", o);
474
+ if (a === "EMAIL_EXISTS")
475
+ throw q(n, "email-already-in-use", o);
476
+ if (a === "USER_DISABLED")
477
+ throw q(n, "user-disabled", o);
478
+ const d = i[a] || a.toLowerCase().replace(/[_\s]+/g, "-");
479
+ if (l)
480
+ throw vn(n, d, l);
481
+ I(n, d);
482
+ }
483
+ } catch (r) {
484
+ if (r instanceof ge)
485
+ throw r;
486
+ I(n, "network-request-failed", { message: String(r) });
487
+ }
488
+ }
489
+ async function at(n, e, t, i, r = {}) {
490
+ const s = await W(n, e, t, i, r);
491
+ return "mfaPendingCredential" in s && I(n, "multi-factor-auth-required", {
492
+ _serverResponse: s
493
+ }), s;
494
+ }
495
+ function ct(n, e, t, i) {
496
+ const r = `${e}${t}?${i}`;
497
+ return n.config.emulator ? ve(n.config, r) : `${n.config.apiScheme}://${r}`;
498
+ }
499
+ class kn {
500
+ constructor(e) {
501
+ this.auth = e, this.timer = null, this.promise = new Promise((t, i) => {
502
+ this.timer = setTimeout(() => i(g(
503
+ this.auth,
504
+ "network-request-failed"
505
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
506
+ )), En.get());
507
+ });
508
+ }
509
+ clearNetworkTimeout() {
510
+ clearTimeout(this.timer);
511
+ }
512
+ }
513
+ function q(n, e, t) {
514
+ const i = {
515
+ appName: n.name
516
+ };
517
+ t.email && (i.email = t.email), t.phoneNumber && (i.phoneNumber = t.phoneNumber);
518
+ const r = g(n, e, i);
519
+ return r.customData._tokenResponse = t, r;
520
+ }
521
+ /**
522
+ * @license
523
+ * Copyright 2020 Google LLC
524
+ *
525
+ * Licensed under the Apache License, Version 2.0 (the "License");
526
+ * you may not use this file except in compliance with the License.
527
+ * You may obtain a copy of the License at
528
+ *
529
+ * http://www.apache.org/licenses/LICENSE-2.0
530
+ *
531
+ * Unless required by applicable law or agreed to in writing, software
532
+ * distributed under the License is distributed on an "AS IS" BASIS,
533
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
534
+ * See the License for the specific language governing permissions and
535
+ * limitations under the License.
536
+ */
537
+ async function Rn(n, e) {
538
+ return W(n, "POST", "/v1/accounts:delete", e);
539
+ }
540
+ async function bn(n, e) {
541
+ return W(n, "POST", "/v1/accounts:lookup", e);
542
+ }
543
+ /**
544
+ * @license
545
+ * Copyright 2020 Google LLC
546
+ *
547
+ * Licensed under the Apache License, Version 2.0 (the "License");
548
+ * you may not use this file except in compliance with the License.
549
+ * You may obtain a copy of the License at
550
+ *
551
+ * http://www.apache.org/licenses/LICENSE-2.0
552
+ *
553
+ * Unless required by applicable law or agreed to in writing, software
554
+ * distributed under the License is distributed on an "AS IS" BASIS,
555
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
556
+ * See the License for the specific language governing permissions and
557
+ * limitations under the License.
558
+ */
559
+ function L(n) {
560
+ if (n)
561
+ try {
562
+ const e = new Date(Number(n));
563
+ if (!isNaN(e.getTime()))
564
+ return e.toUTCString();
565
+ } catch {
566
+ }
567
+ }
568
+ async function Sn(n, e = !1) {
569
+ const t = O(n), i = await t.getIdToken(e), r = ye(i);
570
+ u(
571
+ r && r.exp && r.auth_time && r.iat,
572
+ t.auth,
573
+ "internal-error"
574
+ /* AuthErrorCode.INTERNAL_ERROR */
575
+ );
576
+ const s = typeof r.firebase == "object" ? r.firebase : void 0, o = s == null ? void 0 : s.sign_in_provider;
577
+ return {
578
+ claims: r,
579
+ token: i,
580
+ authTime: L(le(r.auth_time)),
581
+ issuedAtTime: L(le(r.iat)),
582
+ expirationTime: L(le(r.exp)),
583
+ signInProvider: o || null,
584
+ signInSecondFactor: (s == null ? void 0 : s.sign_in_second_factor) || null
585
+ };
586
+ }
587
+ function le(n) {
588
+ return Number(n) * 1e3;
589
+ }
590
+ function ye(n) {
591
+ const [e, t, i] = n.split(".");
592
+ if (e === void 0 || t === void 0 || i === void 0)
593
+ return G("JWT malformed, contained fewer than 3 sections"), null;
594
+ try {
595
+ const r = sn(t);
596
+ return r ? JSON.parse(r) : (G("Failed to decode base64 JWT payload"), null);
597
+ } catch (r) {
598
+ return G("Caught error parsing JWT payload as JSON", r == null ? void 0 : r.toString()), null;
599
+ }
600
+ }
601
+ function An(n) {
602
+ const e = ye(n);
603
+ return u(
604
+ e,
605
+ "internal-error"
606
+ /* AuthErrorCode.INTERNAL_ERROR */
607
+ ), u(
608
+ typeof e.exp < "u",
609
+ "internal-error"
610
+ /* AuthErrorCode.INTERNAL_ERROR */
611
+ ), u(
612
+ typeof e.iat < "u",
613
+ "internal-error"
614
+ /* AuthErrorCode.INTERNAL_ERROR */
615
+ ), Number(e.exp) - Number(e.iat);
616
+ }
617
+ /**
618
+ * @license
619
+ * Copyright 2020 Google LLC
620
+ *
621
+ * Licensed under the Apache License, Version 2.0 (the "License");
622
+ * you may not use this file except in compliance with the License.
623
+ * You may obtain a copy of the License at
624
+ *
625
+ * http://www.apache.org/licenses/LICENSE-2.0
626
+ *
627
+ * Unless required by applicable law or agreed to in writing, software
628
+ * distributed under the License is distributed on an "AS IS" BASIS,
629
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
630
+ * See the License for the specific language governing permissions and
631
+ * limitations under the License.
632
+ */
633
+ async function U(n, e, t = !1) {
634
+ if (t)
635
+ return e;
636
+ try {
637
+ return await e;
638
+ } catch (i) {
639
+ throw i instanceof ge && Cn(i) && n.auth.currentUser === n && await n.auth.signOut(), i;
640
+ }
641
+ }
642
+ function Cn({ code: n }) {
643
+ return n === "auth/user-disabled" || n === "auth/user-token-expired";
644
+ }
645
+ /**
646
+ * @license
647
+ * Copyright 2020 Google LLC
648
+ *
649
+ * Licensed under the Apache License, Version 2.0 (the "License");
650
+ * you may not use this file except in compliance with the License.
651
+ * You may obtain a copy of the License at
652
+ *
653
+ * http://www.apache.org/licenses/LICENSE-2.0
654
+ *
655
+ * Unless required by applicable law or agreed to in writing, software
656
+ * distributed under the License is distributed on an "AS IS" BASIS,
657
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
658
+ * See the License for the specific language governing permissions and
659
+ * limitations under the License.
660
+ */
661
+ class Pn {
662
+ constructor(e) {
663
+ this.user = e, this.isRunning = !1, this.timerId = null, this.errorBackoff = 3e4;
664
+ }
665
+ _start() {
666
+ this.isRunning || (this.isRunning = !0, this.schedule());
667
+ }
668
+ _stop() {
669
+ this.isRunning && (this.isRunning = !1, this.timerId !== null && clearTimeout(this.timerId));
670
+ }
671
+ getInterval(e) {
672
+ var t;
673
+ if (e) {
674
+ const i = this.errorBackoff;
675
+ return this.errorBackoff = Math.min(
676
+ this.errorBackoff * 2,
677
+ 96e4
678
+ /* Duration.RETRY_BACKOFF_MAX */
679
+ ), i;
680
+ } else {
681
+ this.errorBackoff = 3e4;
682
+ const r = ((t = this.user.stsTokenManager.expirationTime) !== null && t !== void 0 ? t : 0) - Date.now() - 3e5;
683
+ return Math.max(0, r);
684
+ }
685
+ }
686
+ schedule(e = !1) {
687
+ if (!this.isRunning)
688
+ return;
689
+ const t = this.getInterval(e);
690
+ this.timerId = setTimeout(async () => {
691
+ await this.iteration();
692
+ }, t);
693
+ }
694
+ async iteration() {
695
+ try {
696
+ await this.user.getIdToken(!0);
697
+ } catch (e) {
698
+ (e == null ? void 0 : e.code) === "auth/network-request-failed" && this.schedule(
699
+ /* wasError */
700
+ !0
701
+ );
702
+ return;
703
+ }
704
+ this.schedule();
705
+ }
706
+ }
707
+ /**
708
+ * @license
709
+ * Copyright 2020 Google LLC
710
+ *
711
+ * Licensed under the Apache License, Version 2.0 (the "License");
712
+ * you may not use this file except in compliance with the License.
713
+ * You may obtain a copy of the License at
714
+ *
715
+ * http://www.apache.org/licenses/LICENSE-2.0
716
+ *
717
+ * Unless required by applicable law or agreed to in writing, software
718
+ * distributed under the License is distributed on an "AS IS" BASIS,
719
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
720
+ * See the License for the specific language governing permissions and
721
+ * limitations under the License.
722
+ */
723
+ class lt {
724
+ constructor(e, t) {
725
+ this.createdAt = e, this.lastLoginAt = t, this._initializeTime();
726
+ }
727
+ _initializeTime() {
728
+ this.lastSignInTime = L(this.lastLoginAt), this.creationTime = L(this.createdAt);
729
+ }
730
+ _copy(e) {
731
+ this.createdAt = e.createdAt, this.lastLoginAt = e.lastLoginAt, this._initializeTime();
732
+ }
733
+ toJSON() {
734
+ return {
735
+ createdAt: this.createdAt,
736
+ lastLoginAt: this.lastLoginAt
737
+ };
738
+ }
739
+ }
740
+ /**
741
+ * @license
742
+ * Copyright 2019 Google LLC
743
+ *
744
+ * Licensed under the Apache License, Version 2.0 (the "License");
745
+ * you may not use this file except in compliance with the License.
746
+ * You may obtain a copy of the License at
747
+ *
748
+ * http://www.apache.org/licenses/LICENSE-2.0
749
+ *
750
+ * Unless required by applicable law or agreed to in writing, software
751
+ * distributed under the License is distributed on an "AS IS" BASIS,
752
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
753
+ * See the License for the specific language governing permissions and
754
+ * limitations under the License.
755
+ */
756
+ async function Q(n) {
757
+ var e;
758
+ const t = n.auth, i = await n.getIdToken(), r = await U(n, bn(t, { idToken: i }));
759
+ u(
760
+ r == null ? void 0 : r.users.length,
761
+ t,
762
+ "internal-error"
763
+ /* AuthErrorCode.INTERNAL_ERROR */
764
+ );
765
+ const s = r.users[0];
766
+ n._notifyReloadListener(s);
767
+ const o = !((e = s.providerUserInfo) === null || e === void 0) && e.length ? Ln(s.providerUserInfo) : [], c = On(n.providerData, o), a = n.isAnonymous, l = !(n.email && s.passwordHash) && !(c != null && c.length), d = a ? l : !1, h = {
768
+ uid: s.localId,
769
+ displayName: s.displayName || null,
770
+ photoURL: s.photoUrl || null,
771
+ email: s.email || null,
772
+ emailVerified: s.emailVerified || !1,
773
+ phoneNumber: s.phoneNumber || null,
774
+ tenantId: s.tenantId || null,
775
+ providerData: c,
776
+ metadata: new lt(s.createdAt, s.lastLoginAt),
777
+ isAnonymous: d
778
+ };
779
+ Object.assign(n, h);
780
+ }
781
+ async function Nn(n) {
782
+ const e = O(n);
783
+ await Q(e), await e.auth._persistUserIfCurrent(e), e.auth._notifyListenersIfCurrent(e);
784
+ }
785
+ function On(n, e) {
786
+ return [...n.filter((i) => !e.some((r) => r.providerId === i.providerId)), ...e];
787
+ }
788
+ function Ln(n) {
789
+ return n.map((e) => {
790
+ var { providerId: t } = e, i = me(e, ["providerId"]);
791
+ return {
792
+ providerId: t,
793
+ uid: i.rawId || "",
794
+ displayName: i.displayName || null,
795
+ email: i.email || null,
796
+ phoneNumber: i.phoneNumber || null,
797
+ photoURL: i.photoUrl || null
798
+ };
799
+ });
800
+ }
801
+ /**
802
+ * @license
803
+ * Copyright 2020 Google LLC
804
+ *
805
+ * Licensed under the Apache License, Version 2.0 (the "License");
806
+ * you may not use this file except in compliance with the License.
807
+ * You may obtain a copy of the License at
808
+ *
809
+ * http://www.apache.org/licenses/LICENSE-2.0
810
+ *
811
+ * Unless required by applicable law or agreed to in writing, software
812
+ * distributed under the License is distributed on an "AS IS" BASIS,
813
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
814
+ * See the License for the specific language governing permissions and
815
+ * limitations under the License.
816
+ */
817
+ async function Mn(n, e) {
818
+ const t = await ot(n, {}, async () => {
819
+ const i = x({
820
+ grant_type: "refresh_token",
821
+ refresh_token: e
822
+ }).slice(1), { tokenApiHost: r, apiKey: s } = n.config, o = ct(n, r, "/v1/token", `key=${s}`), c = await n._getAdditionalHeaders();
823
+ return c[
824
+ "Content-Type"
825
+ /* HttpHeader.CONTENT_TYPE */
826
+ ] = "application/x-www-form-urlencoded", st.fetch()(o, {
827
+ method: "POST",
828
+ headers: c,
829
+ body: i
830
+ });
831
+ });
832
+ return {
833
+ accessToken: t.access_token,
834
+ expiresIn: t.expires_in,
835
+ refreshToken: t.refresh_token
836
+ };
837
+ }
838
+ /**
839
+ * @license
840
+ * Copyright 2020 Google LLC
841
+ *
842
+ * Licensed under the Apache License, Version 2.0 (the "License");
843
+ * you may not use this file except in compliance with the License.
844
+ * You may obtain a copy of the License at
845
+ *
846
+ * http://www.apache.org/licenses/LICENSE-2.0
847
+ *
848
+ * Unless required by applicable law or agreed to in writing, software
849
+ * distributed under the License is distributed on an "AS IS" BASIS,
850
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
851
+ * See the License for the specific language governing permissions and
852
+ * limitations under the License.
853
+ */
854
+ class D {
855
+ constructor() {
856
+ this.refreshToken = null, this.accessToken = null, this.expirationTime = null;
857
+ }
858
+ get isExpired() {
859
+ return !this.expirationTime || Date.now() > this.expirationTime - 3e4;
860
+ }
861
+ updateFromServerResponse(e) {
862
+ u(
863
+ e.idToken,
864
+ "internal-error"
865
+ /* AuthErrorCode.INTERNAL_ERROR */
866
+ ), u(
867
+ typeof e.idToken < "u",
868
+ "internal-error"
869
+ /* AuthErrorCode.INTERNAL_ERROR */
870
+ ), u(
871
+ typeof e.refreshToken < "u",
872
+ "internal-error"
873
+ /* AuthErrorCode.INTERNAL_ERROR */
874
+ );
875
+ const t = "expiresIn" in e && typeof e.expiresIn < "u" ? Number(e.expiresIn) : An(e.idToken);
876
+ this.updateTokensAndExpiration(e.idToken, e.refreshToken, t);
877
+ }
878
+ async getToken(e, t = !1) {
879
+ return u(
880
+ !this.accessToken || this.refreshToken,
881
+ e,
882
+ "user-token-expired"
883
+ /* AuthErrorCode.TOKEN_EXPIRED */
884
+ ), !t && this.accessToken && !this.isExpired ? this.accessToken : this.refreshToken ? (await this.refresh(e, this.refreshToken), this.accessToken) : null;
885
+ }
886
+ clearRefreshToken() {
887
+ this.refreshToken = null;
888
+ }
889
+ async refresh(e, t) {
890
+ const { accessToken: i, refreshToken: r, expiresIn: s } = await Mn(e, t);
891
+ this.updateTokensAndExpiration(i, r, Number(s));
892
+ }
893
+ updateTokensAndExpiration(e, t, i) {
894
+ this.refreshToken = t || null, this.accessToken = e || null, this.expirationTime = Date.now() + i * 1e3;
895
+ }
896
+ static fromJSON(e, t) {
897
+ const { refreshToken: i, accessToken: r, expirationTime: s } = t, o = new D();
898
+ return i && (u(typeof i == "string", "internal-error", {
899
+ appName: e
900
+ }), o.refreshToken = i), r && (u(typeof r == "string", "internal-error", {
901
+ appName: e
902
+ }), o.accessToken = r), s && (u(typeof s == "number", "internal-error", {
903
+ appName: e
904
+ }), o.expirationTime = s), o;
905
+ }
906
+ toJSON() {
907
+ return {
908
+ refreshToken: this.refreshToken,
909
+ accessToken: this.accessToken,
910
+ expirationTime: this.expirationTime
911
+ };
912
+ }
913
+ _assign(e) {
914
+ this.accessToken = e.accessToken, this.refreshToken = e.refreshToken, this.expirationTime = e.expirationTime;
915
+ }
916
+ _clone() {
917
+ return Object.assign(new D(), this.toJSON());
918
+ }
919
+ _performRefresh() {
920
+ return _("not implemented");
921
+ }
922
+ }
923
+ /**
924
+ * @license
925
+ * Copyright 2020 Google LLC
926
+ *
927
+ * Licensed under the Apache License, Version 2.0 (the "License");
928
+ * you may not use this file except in compliance with the License.
929
+ * You may obtain a copy of the License at
930
+ *
931
+ * http://www.apache.org/licenses/LICENSE-2.0
932
+ *
933
+ * Unless required by applicable law or agreed to in writing, software
934
+ * distributed under the License is distributed on an "AS IS" BASIS,
935
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
936
+ * See the License for the specific language governing permissions and
937
+ * limitations under the License.
938
+ */
939
+ function T(n, e) {
940
+ u(typeof n == "string" || typeof n > "u", "internal-error", { appName: e });
941
+ }
942
+ class b {
943
+ constructor(e) {
944
+ var { uid: t, auth: i, stsTokenManager: r } = e, s = me(e, ["uid", "auth", "stsTokenManager"]);
945
+ this.providerId = "firebase", this.proactiveRefresh = new Pn(this), this.reloadUserInfo = null, this.reloadListener = null, this.uid = t, this.auth = i, this.stsTokenManager = r, this.accessToken = r.accessToken, this.displayName = s.displayName || null, this.email = s.email || null, this.emailVerified = s.emailVerified || !1, this.phoneNumber = s.phoneNumber || null, this.photoURL = s.photoURL || null, this.isAnonymous = s.isAnonymous || !1, this.tenantId = s.tenantId || null, this.providerData = s.providerData ? [...s.providerData] : [], this.metadata = new lt(s.createdAt || void 0, s.lastLoginAt || void 0);
946
+ }
947
+ async getIdToken(e) {
948
+ const t = await U(this, this.stsTokenManager.getToken(this.auth, e));
949
+ return u(
950
+ t,
951
+ this.auth,
952
+ "internal-error"
953
+ /* AuthErrorCode.INTERNAL_ERROR */
954
+ ), this.accessToken !== t && (this.accessToken = t, await this.auth._persistUserIfCurrent(this), this.auth._notifyListenersIfCurrent(this)), t;
955
+ }
956
+ getIdTokenResult(e) {
957
+ return Sn(this, e);
958
+ }
959
+ reload() {
960
+ return Nn(this);
961
+ }
962
+ _assign(e) {
963
+ this !== e && (u(
964
+ this.uid === e.uid,
965
+ this.auth,
966
+ "internal-error"
967
+ /* AuthErrorCode.INTERNAL_ERROR */
968
+ ), this.displayName = e.displayName, this.photoURL = e.photoURL, this.email = e.email, this.emailVerified = e.emailVerified, this.phoneNumber = e.phoneNumber, this.isAnonymous = e.isAnonymous, this.tenantId = e.tenantId, this.providerData = e.providerData.map((t) => Object.assign({}, t)), this.metadata._copy(e.metadata), this.stsTokenManager._assign(e.stsTokenManager));
969
+ }
970
+ _clone(e) {
971
+ const t = new b(Object.assign(Object.assign({}, this), { auth: e, stsTokenManager: this.stsTokenManager._clone() }));
972
+ return t.metadata._copy(this.metadata), t;
973
+ }
974
+ _onReload(e) {
975
+ u(
976
+ !this.reloadListener,
977
+ this.auth,
978
+ "internal-error"
979
+ /* AuthErrorCode.INTERNAL_ERROR */
980
+ ), this.reloadListener = e, this.reloadUserInfo && (this._notifyReloadListener(this.reloadUserInfo), this.reloadUserInfo = null);
981
+ }
982
+ _notifyReloadListener(e) {
983
+ this.reloadListener ? this.reloadListener(e) : this.reloadUserInfo = e;
984
+ }
985
+ _startProactiveRefresh() {
986
+ this.proactiveRefresh._start();
987
+ }
988
+ _stopProactiveRefresh() {
989
+ this.proactiveRefresh._stop();
990
+ }
991
+ async _updateTokensIfNecessary(e, t = !1) {
992
+ let i = !1;
993
+ e.idToken && e.idToken !== this.stsTokenManager.accessToken && (this.stsTokenManager.updateFromServerResponse(e), i = !0), t && await Q(this), await this.auth._persistUserIfCurrent(this), i && this.auth._notifyListenersIfCurrent(this);
994
+ }
995
+ async delete() {
996
+ const e = await this.getIdToken();
997
+ return await U(this, Rn(this.auth, { idToken: e })), this.stsTokenManager.clearRefreshToken(), this.auth.signOut();
998
+ }
999
+ toJSON() {
1000
+ return Object.assign(Object.assign({
1001
+ uid: this.uid,
1002
+ email: this.email || void 0,
1003
+ emailVerified: this.emailVerified,
1004
+ displayName: this.displayName || void 0,
1005
+ isAnonymous: this.isAnonymous,
1006
+ photoURL: this.photoURL || void 0,
1007
+ phoneNumber: this.phoneNumber || void 0,
1008
+ tenantId: this.tenantId || void 0,
1009
+ providerData: this.providerData.map((e) => Object.assign({}, e)),
1010
+ stsTokenManager: this.stsTokenManager.toJSON(),
1011
+ // Redirect event ID must be maintained in case there is a pending
1012
+ // redirect event.
1013
+ _redirectEventId: this._redirectEventId
1014
+ }, this.metadata.toJSON()), {
1015
+ // Required for compatibility with the legacy SDK (go/firebase-auth-sdk-persistence-parsing):
1016
+ apiKey: this.auth.config.apiKey,
1017
+ appName: this.auth.name
1018
+ });
1019
+ }
1020
+ get refreshToken() {
1021
+ return this.stsTokenManager.refreshToken || "";
1022
+ }
1023
+ static _fromJSON(e, t) {
1024
+ var i, r, s, o, c, a, l, d;
1025
+ const h = (i = t.displayName) !== null && i !== void 0 ? i : void 0, p = (r = t.email) !== null && r !== void 0 ? r : void 0, B = (s = t.phoneNumber) !== null && s !== void 0 ? s : void 0, K = (o = t.photoURL) !== null && o !== void 0 ? o : void 0, ke = (c = t.tenantId) !== null && c !== void 0 ? c : void 0, se = (a = t._redirectEventId) !== null && a !== void 0 ? a : void 0, Re = (l = t.createdAt) !== null && l !== void 0 ? l : void 0, be = (d = t.lastLoginAt) !== null && d !== void 0 ? d : void 0, { uid: oe, emailVerified: Se, isAnonymous: Ae, providerData: ae, stsTokenManager: Ce } = t;
1026
+ u(
1027
+ oe && Ce,
1028
+ e,
1029
+ "internal-error"
1030
+ /* AuthErrorCode.INTERNAL_ERROR */
1031
+ );
1032
+ const Dt = D.fromJSON(this.name, Ce);
1033
+ u(
1034
+ typeof oe == "string",
1035
+ e,
1036
+ "internal-error"
1037
+ /* AuthErrorCode.INTERNAL_ERROR */
1038
+ ), T(h, e.name), T(p, e.name), u(
1039
+ typeof Se == "boolean",
1040
+ e,
1041
+ "internal-error"
1042
+ /* AuthErrorCode.INTERNAL_ERROR */
1043
+ ), u(
1044
+ typeof Ae == "boolean",
1045
+ e,
1046
+ "internal-error"
1047
+ /* AuthErrorCode.INTERNAL_ERROR */
1048
+ ), T(B, e.name), T(K, e.name), T(ke, e.name), T(se, e.name), T(Re, e.name), T(be, e.name);
1049
+ const ce = new b({
1050
+ uid: oe,
1051
+ auth: e,
1052
+ email: p,
1053
+ emailVerified: Se,
1054
+ displayName: h,
1055
+ isAnonymous: Ae,
1056
+ photoURL: K,
1057
+ phoneNumber: B,
1058
+ tenantId: ke,
1059
+ stsTokenManager: Dt,
1060
+ createdAt: Re,
1061
+ lastLoginAt: be
1062
+ });
1063
+ return ae && Array.isArray(ae) && (ce.providerData = ae.map((Ft) => Object.assign({}, Ft))), se && (ce._redirectEventId = se), ce;
1064
+ }
1065
+ /**
1066
+ * Initialize a User from an idToken server response
1067
+ * @param auth
1068
+ * @param idTokenResponse
1069
+ */
1070
+ static async _fromIdTokenResponse(e, t, i = !1) {
1071
+ const r = new D();
1072
+ r.updateFromServerResponse(t);
1073
+ const s = new b({
1074
+ uid: t.localId,
1075
+ auth: e,
1076
+ stsTokenManager: r,
1077
+ isAnonymous: i
1078
+ });
1079
+ return await Q(s), s;
1080
+ }
1081
+ }
1082
+ /**
1083
+ * @license
1084
+ * Copyright 2020 Google LLC
1085
+ *
1086
+ * Licensed under the Apache License, Version 2.0 (the "License");
1087
+ * you may not use this file except in compliance with the License.
1088
+ * You may obtain a copy of the License at
1089
+ *
1090
+ * http://www.apache.org/licenses/LICENSE-2.0
1091
+ *
1092
+ * Unless required by applicable law or agreed to in writing, software
1093
+ * distributed under the License is distributed on an "AS IS" BASIS,
1094
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1095
+ * See the License for the specific language governing permissions and
1096
+ * limitations under the License.
1097
+ */
1098
+ const Me = /* @__PURE__ */ new Map();
1099
+ function v(n) {
1100
+ y(n instanceof Function, "Expected a class definition");
1101
+ let e = Me.get(n);
1102
+ return e ? (y(e instanceof n, "Instance stored in cache mismatched with class"), e) : (e = new n(), Me.set(n, e), e);
1103
+ }
1104
+ /**
1105
+ * @license
1106
+ * Copyright 2019 Google LLC
1107
+ *
1108
+ * Licensed under the Apache License, Version 2.0 (the "License");
1109
+ * you may not use this file except in compliance with the License.
1110
+ * You may obtain a copy of the License at
1111
+ *
1112
+ * http://www.apache.org/licenses/LICENSE-2.0
1113
+ *
1114
+ * Unless required by applicable law or agreed to in writing, software
1115
+ * distributed under the License is distributed on an "AS IS" BASIS,
1116
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1117
+ * See the License for the specific language governing permissions and
1118
+ * limitations under the License.
1119
+ */
1120
+ class ut {
1121
+ constructor() {
1122
+ this.type = "NONE", this.storage = {};
1123
+ }
1124
+ async _isAvailable() {
1125
+ return !0;
1126
+ }
1127
+ async _set(e, t) {
1128
+ this.storage[e] = t;
1129
+ }
1130
+ async _get(e) {
1131
+ const t = this.storage[e];
1132
+ return t === void 0 ? null : t;
1133
+ }
1134
+ async _remove(e) {
1135
+ delete this.storage[e];
1136
+ }
1137
+ _addListener(e, t) {
1138
+ }
1139
+ _removeListener(e, t) {
1140
+ }
1141
+ }
1142
+ ut.type = "NONE";
1143
+ const Ue = ut;
1144
+ /**
1145
+ * @license
1146
+ * Copyright 2019 Google LLC
1147
+ *
1148
+ * Licensed under the Apache License, Version 2.0 (the "License");
1149
+ * you may not use this file except in compliance with the License.
1150
+ * You may obtain a copy of the License at
1151
+ *
1152
+ * http://www.apache.org/licenses/LICENSE-2.0
1153
+ *
1154
+ * Unless required by applicable law or agreed to in writing, software
1155
+ * distributed under the License is distributed on an "AS IS" BASIS,
1156
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1157
+ * See the License for the specific language governing permissions and
1158
+ * limitations under the License.
1159
+ */
1160
+ function z(n, e, t) {
1161
+ return `firebase:${n}:${e}:${t}`;
1162
+ }
1163
+ class P {
1164
+ constructor(e, t, i) {
1165
+ this.persistence = e, this.auth = t, this.userKey = i;
1166
+ const { config: r, name: s } = this.auth;
1167
+ this.fullUserKey = z(this.userKey, r.apiKey, s), this.fullPersistenceKey = z("persistence", r.apiKey, s), this.boundEventHandler = t._onStorageEvent.bind(t), this.persistence._addListener(this.fullUserKey, this.boundEventHandler);
1168
+ }
1169
+ setCurrentUser(e) {
1170
+ return this.persistence._set(this.fullUserKey, e.toJSON());
1171
+ }
1172
+ async getCurrentUser() {
1173
+ const e = await this.persistence._get(this.fullUserKey);
1174
+ return e ? b._fromJSON(this.auth, e) : null;
1175
+ }
1176
+ removeCurrentUser() {
1177
+ return this.persistence._remove(this.fullUserKey);
1178
+ }
1179
+ savePersistenceForRedirect() {
1180
+ return this.persistence._set(this.fullPersistenceKey, this.persistence.type);
1181
+ }
1182
+ async setPersistence(e) {
1183
+ if (this.persistence === e)
1184
+ return;
1185
+ const t = await this.getCurrentUser();
1186
+ if (await this.removeCurrentUser(), this.persistence = e, t)
1187
+ return this.setCurrentUser(t);
1188
+ }
1189
+ delete() {
1190
+ this.persistence._removeListener(this.fullUserKey, this.boundEventHandler);
1191
+ }
1192
+ static async create(e, t, i = "authUser") {
1193
+ if (!t.length)
1194
+ return new P(v(Ue), e, i);
1195
+ const r = (await Promise.all(t.map(async (l) => {
1196
+ if (await l._isAvailable())
1197
+ return l;
1198
+ }))).filter((l) => l);
1199
+ let s = r[0] || v(Ue);
1200
+ const o = z(i, e.config.apiKey, e.name);
1201
+ let c = null;
1202
+ for (const l of t)
1203
+ try {
1204
+ const d = await l._get(o);
1205
+ if (d) {
1206
+ const h = b._fromJSON(e, d);
1207
+ l !== s && (c = h), s = l;
1208
+ break;
1209
+ }
1210
+ } catch {
1211
+ }
1212
+ const a = r.filter((l) => l._shouldAllowMigration);
1213
+ return !s._shouldAllowMigration || !a.length ? new P(s, e, i) : (s = a[0], c && await s._set(o, c.toJSON()), await Promise.all(t.map(async (l) => {
1214
+ if (l !== s)
1215
+ try {
1216
+ await l._remove(o);
1217
+ } catch {
1218
+ }
1219
+ })), new P(s, e, i));
1220
+ }
1221
+ }
1222
+ /**
1223
+ * @license
1224
+ * Copyright 2020 Google LLC
1225
+ *
1226
+ * Licensed under the Apache License, Version 2.0 (the "License");
1227
+ * you may not use this file except in compliance with the License.
1228
+ * You may obtain a copy of the License at
1229
+ *
1230
+ * http://www.apache.org/licenses/LICENSE-2.0
1231
+ *
1232
+ * Unless required by applicable law or agreed to in writing, software
1233
+ * distributed under the License is distributed on an "AS IS" BASIS,
1234
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1235
+ * See the License for the specific language governing permissions and
1236
+ * limitations under the License.
1237
+ */
1238
+ function De(n) {
1239
+ const e = n.toLowerCase();
1240
+ if (e.includes("opera/") || e.includes("opr/") || e.includes("opios/"))
1241
+ return "Opera";
1242
+ if (ft(e))
1243
+ return "IEMobile";
1244
+ if (e.includes("msie") || e.includes("trident/"))
1245
+ return "IE";
1246
+ if (e.includes("edge/"))
1247
+ return "Edge";
1248
+ if (dt(e))
1249
+ return "Firefox";
1250
+ if (e.includes("silk/"))
1251
+ return "Silk";
1252
+ if (gt(e))
1253
+ return "Blackberry";
1254
+ if (mt(e))
1255
+ return "Webos";
1256
+ if (Te(e))
1257
+ return "Safari";
1258
+ if ((e.includes("chrome/") || ht(e)) && !e.includes("edge/"))
1259
+ return "Chrome";
1260
+ if (pt(e))
1261
+ return "Android";
1262
+ {
1263
+ const t = /([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/, i = n.match(t);
1264
+ if ((i == null ? void 0 : i.length) === 2)
1265
+ return i[1];
1266
+ }
1267
+ return "Other";
1268
+ }
1269
+ function dt(n = f()) {
1270
+ return /firefox\//i.test(n);
1271
+ }
1272
+ function Te(n = f()) {
1273
+ const e = n.toLowerCase();
1274
+ return e.includes("safari/") && !e.includes("chrome/") && !e.includes("crios/") && !e.includes("android");
1275
+ }
1276
+ function ht(n = f()) {
1277
+ return /crios\//i.test(n);
1278
+ }
1279
+ function ft(n = f()) {
1280
+ return /iemobile/i.test(n);
1281
+ }
1282
+ function pt(n = f()) {
1283
+ return /android/i.test(n);
1284
+ }
1285
+ function gt(n = f()) {
1286
+ return /blackberry/i.test(n);
1287
+ }
1288
+ function mt(n = f()) {
1289
+ return /webos/i.test(n);
1290
+ }
1291
+ function ne(n = f()) {
1292
+ return /iphone|ipad|ipod/i.test(n) || /macintosh/i.test(n) && /mobile/i.test(n);
1293
+ }
1294
+ function Un(n = f()) {
1295
+ var e;
1296
+ return ne(n) && !!(!((e = window.navigator) === null || e === void 0) && e.standalone);
1297
+ }
1298
+ function Dn() {
1299
+ return on() && document.documentMode === 10;
1300
+ }
1301
+ function _t(n = f()) {
1302
+ return ne(n) || pt(n) || mt(n) || gt(n) || /windows phone/i.test(n) || ft(n);
1303
+ }
1304
+ function Fn() {
1305
+ try {
1306
+ return !!(window && window !== window.top);
1307
+ } catch {
1308
+ return !1;
1309
+ }
1310
+ }
1311
+ /**
1312
+ * @license
1313
+ * Copyright 2020 Google LLC
1314
+ *
1315
+ * Licensed under the Apache License, Version 2.0 (the "License");
1316
+ * you may not use this file except in compliance with the License.
1317
+ * You may obtain a copy of the License at
1318
+ *
1319
+ * http://www.apache.org/licenses/LICENSE-2.0
1320
+ *
1321
+ * Unless required by applicable law or agreed to in writing, software
1322
+ * distributed under the License is distributed on an "AS IS" BASIS,
1323
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1324
+ * See the License for the specific language governing permissions and
1325
+ * limitations under the License.
1326
+ */
1327
+ function vt(n, e = []) {
1328
+ let t;
1329
+ switch (n) {
1330
+ case "Browser":
1331
+ t = De(f());
1332
+ break;
1333
+ case "Worker":
1334
+ t = `${De(f())}-${n}`;
1335
+ break;
1336
+ default:
1337
+ t = n;
1338
+ }
1339
+ const i = e.length ? e.join(",") : "FirebaseCore-web";
1340
+ return `${t}/JsCore/${F}/${i}`;
1341
+ }
1342
+ async function It(n, e) {
1343
+ return W(n, "GET", "/v2/recaptchaConfig", Ie(n, e));
1344
+ }
1345
+ function Fe(n) {
1346
+ return n !== void 0 && n.enterprise !== void 0;
1347
+ }
1348
+ class yt {
1349
+ constructor(e) {
1350
+ if (this.siteKey = "", this.emailPasswordEnabled = !1, e.recaptchaKey === void 0)
1351
+ throw new Error("recaptchaKey undefined");
1352
+ this.siteKey = e.recaptchaKey.split("/")[3], this.emailPasswordEnabled = e.recaptchaEnforcementState.some((t) => t.provider === "EMAIL_PASSWORD_PROVIDER" && t.enforcementState !== "OFF");
1353
+ }
1354
+ }
1355
+ /**
1356
+ * @license
1357
+ * Copyright 2020 Google LLC
1358
+ *
1359
+ * Licensed under the Apache License, Version 2.0 (the "License");
1360
+ * you may not use this file except in compliance with the License.
1361
+ * You may obtain a copy of the License at
1362
+ *
1363
+ * http://www.apache.org/licenses/LICENSE-2.0
1364
+ *
1365
+ * Unless required by applicable law or agreed to in writing, software
1366
+ * distributed under the License is distributed on an "AS IS" BASIS,
1367
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1368
+ * See the License for the specific language governing permissions and
1369
+ * limitations under the License.
1370
+ */
1371
+ function xn() {
1372
+ var n, e;
1373
+ return (e = (n = document.getElementsByTagName("head")) === null || n === void 0 ? void 0 : n[0]) !== null && e !== void 0 ? e : document;
1374
+ }
1375
+ function Tt(n) {
1376
+ return new Promise((e, t) => {
1377
+ const i = document.createElement("script");
1378
+ i.setAttribute("src", n), i.onload = e, i.onerror = (r) => {
1379
+ const s = g(
1380
+ "internal-error"
1381
+ /* AuthErrorCode.INTERNAL_ERROR */
1382
+ );
1383
+ s.customData = r, t(s);
1384
+ }, i.type = "text/javascript", i.charset = "UTF-8", xn().appendChild(i);
1385
+ });
1386
+ }
1387
+ function Vn(n) {
1388
+ return `__${n}${Math.floor(Math.random() * 1e6)}`;
1389
+ }
1390
+ const Wn = "https://www.google.com/recaptcha/enterprise.js?render=", Hn = "recaptcha-enterprise", $n = "NO_RECAPTCHA";
1391
+ class jn {
1392
+ /**
1393
+ *
1394
+ * @param authExtern - The corresponding Firebase {@link Auth} instance.
1395
+ *
1396
+ */
1397
+ constructor(e) {
1398
+ this.type = Hn, this.auth = H(e);
1399
+ }
1400
+ /**
1401
+ * Executes the verification process.
1402
+ *
1403
+ * @returns A Promise for a token that can be used to assert the validity of a request.
1404
+ */
1405
+ async verify(e = "verify", t = !1) {
1406
+ async function i(s) {
1407
+ if (!t) {
1408
+ if (s.tenantId == null && s._agentRecaptchaConfig != null)
1409
+ return s._agentRecaptchaConfig.siteKey;
1410
+ if (s.tenantId != null && s._tenantRecaptchaConfigs[s.tenantId] !== void 0)
1411
+ return s._tenantRecaptchaConfigs[s.tenantId].siteKey;
1412
+ }
1413
+ return new Promise(async (o, c) => {
1414
+ It(s, {
1415
+ clientType: "CLIENT_TYPE_WEB",
1416
+ version: "RECAPTCHA_ENTERPRISE"
1417
+ /* RecaptchaVersion.ENTERPRISE */
1418
+ }).then((a) => {
1419
+ if (a.recaptchaKey === void 0)
1420
+ c(new Error("recaptcha Enterprise site key undefined"));
1421
+ else {
1422
+ const l = new yt(a);
1423
+ return s.tenantId == null ? s._agentRecaptchaConfig = l : s._tenantRecaptchaConfigs[s.tenantId] = l, o(l.siteKey);
1424
+ }
1425
+ }).catch((a) => {
1426
+ c(a);
1427
+ });
1428
+ });
1429
+ }
1430
+ function r(s, o, c) {
1431
+ const a = window.grecaptcha;
1432
+ Fe(a) ? a.enterprise.ready(() => {
1433
+ a.enterprise.execute(s, { action: e }).then((l) => {
1434
+ o(l);
1435
+ }).catch(() => {
1436
+ o($n);
1437
+ });
1438
+ }) : c(Error("No reCAPTCHA enterprise script loaded."));
1439
+ }
1440
+ return new Promise((s, o) => {
1441
+ i(this.auth).then((c) => {
1442
+ if (!t && Fe(window.grecaptcha))
1443
+ r(c, s, o);
1444
+ else {
1445
+ if (typeof window > "u") {
1446
+ o(new Error("RecaptchaVerifier is only supported in browser"));
1447
+ return;
1448
+ }
1449
+ Tt(Wn + c).then(() => {
1450
+ r(c, s, o);
1451
+ }).catch((a) => {
1452
+ o(a);
1453
+ });
1454
+ }
1455
+ }).catch((c) => {
1456
+ o(c);
1457
+ });
1458
+ });
1459
+ }
1460
+ }
1461
+ /**
1462
+ * @license
1463
+ * Copyright 2022 Google LLC
1464
+ *
1465
+ * Licensed under the Apache License, Version 2.0 (the "License");
1466
+ * you may not use this file except in compliance with the License.
1467
+ * You may obtain a copy of the License at
1468
+ *
1469
+ * http://www.apache.org/licenses/LICENSE-2.0
1470
+ *
1471
+ * Unless required by applicable law or agreed to in writing, software
1472
+ * distributed under the License is distributed on an "AS IS" BASIS,
1473
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1474
+ * See the License for the specific language governing permissions and
1475
+ * limitations under the License.
1476
+ */
1477
+ class Bn {
1478
+ constructor(e) {
1479
+ this.auth = e, this.queue = [];
1480
+ }
1481
+ pushCallback(e, t) {
1482
+ const i = (s) => new Promise((o, c) => {
1483
+ try {
1484
+ const a = e(s);
1485
+ o(a);
1486
+ } catch (a) {
1487
+ c(a);
1488
+ }
1489
+ });
1490
+ i.onAbort = t, this.queue.push(i);
1491
+ const r = this.queue.length - 1;
1492
+ return () => {
1493
+ this.queue[r] = () => Promise.resolve();
1494
+ };
1495
+ }
1496
+ async runMiddleware(e) {
1497
+ if (this.auth.currentUser === e)
1498
+ return;
1499
+ const t = [];
1500
+ try {
1501
+ for (const i of this.queue)
1502
+ await i(e), i.onAbort && t.push(i.onAbort);
1503
+ } catch (i) {
1504
+ t.reverse();
1505
+ for (const r of t)
1506
+ try {
1507
+ r();
1508
+ } catch {
1509
+ }
1510
+ throw this.auth._errorFactory.create("login-blocked", {
1511
+ originalMessage: i == null ? void 0 : i.message
1512
+ });
1513
+ }
1514
+ }
1515
+ }
1516
+ /**
1517
+ * @license
1518
+ * Copyright 2020 Google LLC
1519
+ *
1520
+ * Licensed under the Apache License, Version 2.0 (the "License");
1521
+ * you may not use this file except in compliance with the License.
1522
+ * You may obtain a copy of the License at
1523
+ *
1524
+ * http://www.apache.org/licenses/LICENSE-2.0
1525
+ *
1526
+ * Unless required by applicable law or agreed to in writing, software
1527
+ * distributed under the License is distributed on an "AS IS" BASIS,
1528
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1529
+ * See the License for the specific language governing permissions and
1530
+ * limitations under the License.
1531
+ */
1532
+ class Kn {
1533
+ constructor(e, t, i, r) {
1534
+ this.app = e, this.heartbeatServiceProvider = t, this.appCheckServiceProvider = i, this.config = r, this.currentUser = null, this.emulatorConfig = null, this.operations = Promise.resolve(), this.authStateSubscription = new xe(this), this.idTokenSubscription = new xe(this), this.beforeStateQueue = new Bn(this), this.redirectUser = null, this.isProactiveRefreshEnabled = !1, this._canInitEmulator = !0, this._isInitialized = !1, this._deleted = !1, this._initializationPromise = null, this._popupRedirectResolver = null, this._errorFactory = rt, this._agentRecaptchaConfig = null, this._tenantRecaptchaConfigs = {}, this.lastNotifiedUid = void 0, this.languageCode = null, this.tenantId = null, this.settings = { appVerificationDisabledForTesting: !1 }, this.frameworks = [], this.name = e.name, this.clientVersion = r.sdkClientVersion;
1535
+ }
1536
+ _initializeWithPersistence(e, t) {
1537
+ return t && (this._popupRedirectResolver = v(t)), this._initializationPromise = this.queue(async () => {
1538
+ var i, r;
1539
+ if (!this._deleted && (this.persistenceManager = await P.create(this, e), !this._deleted)) {
1540
+ if (!((i = this._popupRedirectResolver) === null || i === void 0) && i._shouldInitProactively)
1541
+ try {
1542
+ await this._popupRedirectResolver._initialize(this);
1543
+ } catch {
1544
+ }
1545
+ await this.initializeCurrentUser(t), this.lastNotifiedUid = ((r = this.currentUser) === null || r === void 0 ? void 0 : r.uid) || null, !this._deleted && (this._isInitialized = !0);
1546
+ }
1547
+ }), this._initializationPromise;
1548
+ }
1549
+ /**
1550
+ * If the persistence is changed in another window, the user manager will let us know
1551
+ */
1552
+ async _onStorageEvent() {
1553
+ if (this._deleted)
1554
+ return;
1555
+ const e = await this.assertedPersistence.getCurrentUser();
1556
+ if (!(!this.currentUser && !e)) {
1557
+ if (this.currentUser && e && this.currentUser.uid === e.uid) {
1558
+ this._currentUser._assign(e), await this.currentUser.getIdToken();
1559
+ return;
1560
+ }
1561
+ await this._updateCurrentUser(
1562
+ e,
1563
+ /* skipBeforeStateCallbacks */
1564
+ !0
1565
+ );
1566
+ }
1567
+ }
1568
+ async initializeCurrentUser(e) {
1569
+ var t;
1570
+ const i = await this.assertedPersistence.getCurrentUser();
1571
+ let r = i, s = !1;
1572
+ if (e && this.config.authDomain) {
1573
+ await this.getOrInitRedirectPersistenceManager();
1574
+ const o = (t = this.redirectUser) === null || t === void 0 ? void 0 : t._redirectEventId, c = r == null ? void 0 : r._redirectEventId, a = await this.tryRedirectSignIn(e);
1575
+ (!o || o === c) && (a != null && a.user) && (r = a.user, s = !0);
1576
+ }
1577
+ if (!r)
1578
+ return this.directlySetCurrentUser(null);
1579
+ if (!r._redirectEventId) {
1580
+ if (s)
1581
+ try {
1582
+ await this.beforeStateQueue.runMiddleware(r);
1583
+ } catch (o) {
1584
+ r = i, this._popupRedirectResolver._overrideRedirectResult(this, () => Promise.reject(o));
1585
+ }
1586
+ return r ? this.reloadAndSetCurrentUserOrClear(r) : this.directlySetCurrentUser(null);
1587
+ }
1588
+ return u(
1589
+ this._popupRedirectResolver,
1590
+ this,
1591
+ "argument-error"
1592
+ /* AuthErrorCode.ARGUMENT_ERROR */
1593
+ ), await this.getOrInitRedirectPersistenceManager(), this.redirectUser && this.redirectUser._redirectEventId === r._redirectEventId ? this.directlySetCurrentUser(r) : this.reloadAndSetCurrentUserOrClear(r);
1594
+ }
1595
+ async tryRedirectSignIn(e) {
1596
+ let t = null;
1597
+ try {
1598
+ t = await this._popupRedirectResolver._completeRedirectFn(this, e, !0);
1599
+ } catch {
1600
+ await this._setRedirectUser(null);
1601
+ }
1602
+ return t;
1603
+ }
1604
+ async reloadAndSetCurrentUserOrClear(e) {
1605
+ try {
1606
+ await Q(e);
1607
+ } catch (t) {
1608
+ if ((t == null ? void 0 : t.code) !== "auth/network-request-failed")
1609
+ return this.directlySetCurrentUser(null);
1610
+ }
1611
+ return this.directlySetCurrentUser(e);
1612
+ }
1613
+ useDeviceLanguage() {
1614
+ this.languageCode = Tn();
1615
+ }
1616
+ async _delete() {
1617
+ this._deleted = !0;
1618
+ }
1619
+ async updateCurrentUser(e) {
1620
+ const t = e ? O(e) : null;
1621
+ return t && u(
1622
+ t.auth.config.apiKey === this.config.apiKey,
1623
+ this,
1624
+ "invalid-user-token"
1625
+ /* AuthErrorCode.INVALID_AUTH */
1626
+ ), this._updateCurrentUser(t && t._clone(this));
1627
+ }
1628
+ async _updateCurrentUser(e, t = !1) {
1629
+ if (!this._deleted)
1630
+ return e && u(
1631
+ this.tenantId === e.tenantId,
1632
+ this,
1633
+ "tenant-id-mismatch"
1634
+ /* AuthErrorCode.TENANT_ID_MISMATCH */
1635
+ ), t || await this.beforeStateQueue.runMiddleware(e), this.queue(async () => {
1636
+ await this.directlySetCurrentUser(e), this.notifyAuthListeners();
1637
+ });
1638
+ }
1639
+ async signOut() {
1640
+ return await this.beforeStateQueue.runMiddleware(null), (this.redirectPersistenceManager || this._popupRedirectResolver) && await this._setRedirectUser(null), this._updateCurrentUser(
1641
+ null,
1642
+ /* skipBeforeStateCallbacks */
1643
+ !0
1644
+ );
1645
+ }
1646
+ setPersistence(e) {
1647
+ return this.queue(async () => {
1648
+ await this.assertedPersistence.setPersistence(v(e));
1649
+ });
1650
+ }
1651
+ async initializeRecaptchaConfig() {
1652
+ const e = await It(this, {
1653
+ clientType: "CLIENT_TYPE_WEB",
1654
+ version: "RECAPTCHA_ENTERPRISE"
1655
+ /* RecaptchaVersion.ENTERPRISE */
1656
+ }), t = new yt(e);
1657
+ this.tenantId == null ? this._agentRecaptchaConfig = t : this._tenantRecaptchaConfigs[this.tenantId] = t, t.emailPasswordEnabled && new jn(this).verify();
1658
+ }
1659
+ _getRecaptchaConfig() {
1660
+ return this.tenantId == null ? this._agentRecaptchaConfig : this._tenantRecaptchaConfigs[this.tenantId];
1661
+ }
1662
+ _getPersistence() {
1663
+ return this.assertedPersistence.persistence.type;
1664
+ }
1665
+ _updateErrorMap(e) {
1666
+ this._errorFactory = new pe("auth", "Firebase", e());
1667
+ }
1668
+ onAuthStateChanged(e, t, i) {
1669
+ return this.registerStateListener(this.authStateSubscription, e, t, i);
1670
+ }
1671
+ beforeAuthStateChanged(e, t) {
1672
+ return this.beforeStateQueue.pushCallback(e, t);
1673
+ }
1674
+ onIdTokenChanged(e, t, i) {
1675
+ return this.registerStateListener(this.idTokenSubscription, e, t, i);
1676
+ }
1677
+ toJSON() {
1678
+ var e;
1679
+ return {
1680
+ apiKey: this.config.apiKey,
1681
+ authDomain: this.config.authDomain,
1682
+ appName: this.name,
1683
+ currentUser: (e = this._currentUser) === null || e === void 0 ? void 0 : e.toJSON()
1684
+ };
1685
+ }
1686
+ async _setRedirectUser(e, t) {
1687
+ const i = await this.getOrInitRedirectPersistenceManager(t);
1688
+ return e === null ? i.removeCurrentUser() : i.setCurrentUser(e);
1689
+ }
1690
+ async getOrInitRedirectPersistenceManager(e) {
1691
+ if (!this.redirectPersistenceManager) {
1692
+ const t = e && v(e) || this._popupRedirectResolver;
1693
+ u(
1694
+ t,
1695
+ this,
1696
+ "argument-error"
1697
+ /* AuthErrorCode.ARGUMENT_ERROR */
1698
+ ), this.redirectPersistenceManager = await P.create(
1699
+ this,
1700
+ [v(t._redirectPersistence)],
1701
+ "redirectUser"
1702
+ /* KeyName.REDIRECT_USER */
1703
+ ), this.redirectUser = await this.redirectPersistenceManager.getCurrentUser();
1704
+ }
1705
+ return this.redirectPersistenceManager;
1706
+ }
1707
+ async _redirectUserForId(e) {
1708
+ var t, i;
1709
+ return this._isInitialized && await this.queue(async () => {
1710
+ }), ((t = this._currentUser) === null || t === void 0 ? void 0 : t._redirectEventId) === e ? this._currentUser : ((i = this.redirectUser) === null || i === void 0 ? void 0 : i._redirectEventId) === e ? this.redirectUser : null;
1711
+ }
1712
+ async _persistUserIfCurrent(e) {
1713
+ if (e === this.currentUser)
1714
+ return this.queue(async () => this.directlySetCurrentUser(e));
1715
+ }
1716
+ /** Notifies listeners only if the user is current */
1717
+ _notifyListenersIfCurrent(e) {
1718
+ e === this.currentUser && this.notifyAuthListeners();
1719
+ }
1720
+ _key() {
1721
+ return `${this.config.authDomain}:${this.config.apiKey}:${this.name}`;
1722
+ }
1723
+ _startProactiveRefresh() {
1724
+ this.isProactiveRefreshEnabled = !0, this.currentUser && this._currentUser._startProactiveRefresh();
1725
+ }
1726
+ _stopProactiveRefresh() {
1727
+ this.isProactiveRefreshEnabled = !1, this.currentUser && this._currentUser._stopProactiveRefresh();
1728
+ }
1729
+ /** Returns the current user cast as the internal type */
1730
+ get _currentUser() {
1731
+ return this.currentUser;
1732
+ }
1733
+ notifyAuthListeners() {
1734
+ var e, t;
1735
+ if (!this._isInitialized)
1736
+ return;
1737
+ this.idTokenSubscription.next(this.currentUser);
1738
+ const i = (t = (e = this.currentUser) === null || e === void 0 ? void 0 : e.uid) !== null && t !== void 0 ? t : null;
1739
+ this.lastNotifiedUid !== i && (this.lastNotifiedUid = i, this.authStateSubscription.next(this.currentUser));
1740
+ }
1741
+ registerStateListener(e, t, i, r) {
1742
+ if (this._deleted)
1743
+ return () => {
1744
+ };
1745
+ const s = typeof t == "function" ? t : t.next.bind(t), o = this._isInitialized ? Promise.resolve() : this._initializationPromise;
1746
+ return u(
1747
+ o,
1748
+ this,
1749
+ "internal-error"
1750
+ /* AuthErrorCode.INTERNAL_ERROR */
1751
+ ), o.then(() => s(this.currentUser)), typeof t == "function" ? e.addObserver(t, i, r) : e.addObserver(t);
1752
+ }
1753
+ /**
1754
+ * Unprotected (from race conditions) method to set the current user. This
1755
+ * should only be called from within a queued callback. This is necessary
1756
+ * because the queue shouldn't rely on another queued callback.
1757
+ */
1758
+ async directlySetCurrentUser(e) {
1759
+ this.currentUser && this.currentUser !== e && this._currentUser._stopProactiveRefresh(), e && this.isProactiveRefreshEnabled && e._startProactiveRefresh(), this.currentUser = e, e ? await this.assertedPersistence.setCurrentUser(e) : await this.assertedPersistence.removeCurrentUser();
1760
+ }
1761
+ queue(e) {
1762
+ return this.operations = this.operations.then(e, e), this.operations;
1763
+ }
1764
+ get assertedPersistence() {
1765
+ return u(
1766
+ this.persistenceManager,
1767
+ this,
1768
+ "internal-error"
1769
+ /* AuthErrorCode.INTERNAL_ERROR */
1770
+ ), this.persistenceManager;
1771
+ }
1772
+ _logFramework(e) {
1773
+ !e || this.frameworks.includes(e) || (this.frameworks.push(e), this.frameworks.sort(), this.clientVersion = vt(this.config.clientPlatform, this._getFrameworks()));
1774
+ }
1775
+ _getFrameworks() {
1776
+ return this.frameworks;
1777
+ }
1778
+ async _getAdditionalHeaders() {
1779
+ var e;
1780
+ const t = {
1781
+ "X-Client-Version": this.clientVersion
1782
+ };
1783
+ this.app.options.appId && (t[
1784
+ "X-Firebase-gmpid"
1785
+ /* HttpHeader.X_FIREBASE_GMPID */
1786
+ ] = this.app.options.appId);
1787
+ const i = await ((e = this.heartbeatServiceProvider.getImmediate({
1788
+ optional: !0
1789
+ })) === null || e === void 0 ? void 0 : e.getHeartbeatsHeader());
1790
+ i && (t[
1791
+ "X-Firebase-Client"
1792
+ /* HttpHeader.X_FIREBASE_CLIENT */
1793
+ ] = i);
1794
+ const r = await this._getAppCheckToken();
1795
+ return r && (t[
1796
+ "X-Firebase-AppCheck"
1797
+ /* HttpHeader.X_FIREBASE_APP_CHECK */
1798
+ ] = r), t;
1799
+ }
1800
+ async _getAppCheckToken() {
1801
+ var e;
1802
+ const t = await ((e = this.appCheckServiceProvider.getImmediate({ optional: !0 })) === null || e === void 0 ? void 0 : e.getToken());
1803
+ return t != null && t.error && _n(`Error while retrieving App Check token: ${t.error}`), t == null ? void 0 : t.token;
1804
+ }
1805
+ }
1806
+ function H(n) {
1807
+ return O(n);
1808
+ }
1809
+ class xe {
1810
+ constructor(e) {
1811
+ this.auth = e, this.observer = null, this.addObserver = Zt((t) => this.observer = t);
1812
+ }
1813
+ get next() {
1814
+ return u(
1815
+ this.observer,
1816
+ this.auth,
1817
+ "internal-error"
1818
+ /* AuthErrorCode.INTERNAL_ERROR */
1819
+ ), this.observer.next.bind(this.observer);
1820
+ }
1821
+ }
1822
+ /**
1823
+ * @license
1824
+ * Copyright 2020 Google LLC
1825
+ *
1826
+ * Licensed under the Apache License, Version 2.0 (the "License");
1827
+ * you may not use this file except in compliance with the License.
1828
+ * You may obtain a copy of the License at
1829
+ *
1830
+ * http://www.apache.org/licenses/LICENSE-2.0
1831
+ *
1832
+ * Unless required by applicable law or agreed to in writing, software
1833
+ * distributed under the License is distributed on an "AS IS" BASIS,
1834
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1835
+ * See the License for the specific language governing permissions and
1836
+ * limitations under the License.
1837
+ */
1838
+ function qn(n, e) {
1839
+ const t = tt(n, "auth");
1840
+ if (t.isInitialized()) {
1841
+ const r = t.getImmediate(), s = t.getOptions();
1842
+ if (nn(s, e ?? {}))
1843
+ return r;
1844
+ I(
1845
+ r,
1846
+ "already-initialized"
1847
+ /* AuthErrorCode.ALREADY_INITIALIZED */
1848
+ );
1849
+ }
1850
+ return t.initialize({ options: e });
1851
+ }
1852
+ function Gn(n, e) {
1853
+ const t = (e == null ? void 0 : e.persistence) || [], i = (Array.isArray(t) ? t : [t]).map(v);
1854
+ e != null && e.errorMap && n._updateErrorMap(e.errorMap), n._initializeWithPersistence(i, e == null ? void 0 : e.popupRedirectResolver);
1855
+ }
1856
+ function zn(n, e, t) {
1857
+ const i = H(n);
1858
+ u(
1859
+ i._canInitEmulator,
1860
+ i,
1861
+ "emulator-config-failed"
1862
+ /* AuthErrorCode.EMULATOR_CONFIG_FAILED */
1863
+ ), u(
1864
+ /^https?:\/\//.test(e),
1865
+ i,
1866
+ "invalid-emulator-scheme"
1867
+ /* AuthErrorCode.INVALID_EMULATOR_SCHEME */
1868
+ );
1869
+ const r = !!(t != null && t.disableWarnings), s = wt(e), { host: o, port: c } = Jn(e), a = c === null ? "" : `:${c}`;
1870
+ i.config.emulator = { url: `${s}//${o}${a}/` }, i.settings.appVerificationDisabledForTesting = !0, i.emulatorConfig = Object.freeze({
1871
+ host: o,
1872
+ port: c,
1873
+ protocol: s.replace(":", ""),
1874
+ options: Object.freeze({ disableWarnings: r })
1875
+ }), r || Yn();
1876
+ }
1877
+ function wt(n) {
1878
+ const e = n.indexOf(":");
1879
+ return e < 0 ? "" : n.substr(0, e + 1);
1880
+ }
1881
+ function Jn(n) {
1882
+ const e = wt(n), t = /(\/\/)?([^?#/]+)/.exec(n.substr(e.length));
1883
+ if (!t)
1884
+ return { host: "", port: null };
1885
+ const i = t[2].split("@").pop() || "", r = /^(\[[^\]]+\])(:|$)/.exec(i);
1886
+ if (r) {
1887
+ const s = r[1];
1888
+ return { host: s, port: Ve(i.substr(s.length + 1)) };
1889
+ } else {
1890
+ const [s, o] = i.split(":");
1891
+ return { host: s, port: Ve(o) };
1892
+ }
1893
+ }
1894
+ function Ve(n) {
1895
+ if (!n)
1896
+ return null;
1897
+ const e = Number(n);
1898
+ return isNaN(e) ? null : e;
1899
+ }
1900
+ function Yn() {
1901
+ function n() {
1902
+ const e = document.createElement("p"), t = e.style;
1903
+ e.innerText = "Running in emulator mode. Do not use with production credentials.", t.position = "fixed", t.width = "100%", t.backgroundColor = "#ffffff", t.border = ".1em solid #000000", t.color = "#b50000", t.bottom = "0px", t.left = "0px", t.margin = "0px", t.zIndex = "10000", t.textAlign = "center", e.classList.add("firebase-emulator-warning"), document.body.appendChild(e);
1904
+ }
1905
+ typeof console < "u" && typeof console.info == "function" && console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."), typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", n) : n());
1906
+ }
1907
+ /**
1908
+ * @license
1909
+ * Copyright 2020 Google LLC
1910
+ *
1911
+ * Licensed under the Apache License, Version 2.0 (the "License");
1912
+ * you may not use this file except in compliance with the License.
1913
+ * You may obtain a copy of the License at
1914
+ *
1915
+ * http://www.apache.org/licenses/LICENSE-2.0
1916
+ *
1917
+ * Unless required by applicable law or agreed to in writing, software
1918
+ * distributed under the License is distributed on an "AS IS" BASIS,
1919
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1920
+ * See the License for the specific language governing permissions and
1921
+ * limitations under the License.
1922
+ */
1923
+ class Et {
1924
+ /** @internal */
1925
+ constructor(e, t) {
1926
+ this.providerId = e, this.signInMethod = t;
1927
+ }
1928
+ /**
1929
+ * Returns a JSON-serializable representation of this object.
1930
+ *
1931
+ * @returns a JSON-serializable representation of this object.
1932
+ */
1933
+ toJSON() {
1934
+ return _("not implemented");
1935
+ }
1936
+ /** @internal */
1937
+ _getIdTokenResponse(e) {
1938
+ return _("not implemented");
1939
+ }
1940
+ /** @internal */
1941
+ _linkToIdToken(e, t) {
1942
+ return _("not implemented");
1943
+ }
1944
+ /** @internal */
1945
+ _getReauthenticationResolver(e) {
1946
+ return _("not implemented");
1947
+ }
1948
+ }
1949
+ /**
1950
+ * @license
1951
+ * Copyright 2020 Google LLC
1952
+ *
1953
+ * Licensed under the Apache License, Version 2.0 (the "License");
1954
+ * you may not use this file except in compliance with the License.
1955
+ * You may obtain a copy of the License at
1956
+ *
1957
+ * http://www.apache.org/licenses/LICENSE-2.0
1958
+ *
1959
+ * Unless required by applicable law or agreed to in writing, software
1960
+ * distributed under the License is distributed on an "AS IS" BASIS,
1961
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1962
+ * See the License for the specific language governing permissions and
1963
+ * limitations under the License.
1964
+ */
1965
+ async function N(n, e) {
1966
+ return at(n, "POST", "/v1/accounts:signInWithIdp", Ie(n, e));
1967
+ }
1968
+ /**
1969
+ * @license
1970
+ * Copyright 2020 Google LLC
1971
+ *
1972
+ * Licensed under the Apache License, Version 2.0 (the "License");
1973
+ * you may not use this file except in compliance with the License.
1974
+ * You may obtain a copy of the License at
1975
+ *
1976
+ * http://www.apache.org/licenses/LICENSE-2.0
1977
+ *
1978
+ * Unless required by applicable law or agreed to in writing, software
1979
+ * distributed under the License is distributed on an "AS IS" BASIS,
1980
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1981
+ * See the License for the specific language governing permissions and
1982
+ * limitations under the License.
1983
+ */
1984
+ const Xn = "http://localhost";
1985
+ class S extends Et {
1986
+ constructor() {
1987
+ super(...arguments), this.pendingToken = null;
1988
+ }
1989
+ /** @internal */
1990
+ static _fromParams(e) {
1991
+ const t = new S(e.providerId, e.signInMethod);
1992
+ return e.idToken || e.accessToken ? (e.idToken && (t.idToken = e.idToken), e.accessToken && (t.accessToken = e.accessToken), e.nonce && !e.pendingToken && (t.nonce = e.nonce), e.pendingToken && (t.pendingToken = e.pendingToken)) : e.oauthToken && e.oauthTokenSecret ? (t.accessToken = e.oauthToken, t.secret = e.oauthTokenSecret) : I(
1993
+ "argument-error"
1994
+ /* AuthErrorCode.ARGUMENT_ERROR */
1995
+ ), t;
1996
+ }
1997
+ /** {@inheritdoc AuthCredential.toJSON} */
1998
+ toJSON() {
1999
+ return {
2000
+ idToken: this.idToken,
2001
+ accessToken: this.accessToken,
2002
+ secret: this.secret,
2003
+ nonce: this.nonce,
2004
+ pendingToken: this.pendingToken,
2005
+ providerId: this.providerId,
2006
+ signInMethod: this.signInMethod
2007
+ };
2008
+ }
2009
+ /**
2010
+ * Static method to deserialize a JSON representation of an object into an
2011
+ * {@link AuthCredential}.
2012
+ *
2013
+ * @param json - Input can be either Object or the stringified representation of the object.
2014
+ * When string is provided, JSON.parse would be called first.
2015
+ *
2016
+ * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
2017
+ */
2018
+ static fromJSON(e) {
2019
+ const t = typeof e == "string" ? JSON.parse(e) : e, { providerId: i, signInMethod: r } = t, s = me(t, ["providerId", "signInMethod"]);
2020
+ if (!i || !r)
2021
+ return null;
2022
+ const o = new S(i, r);
2023
+ return o.idToken = s.idToken || void 0, o.accessToken = s.accessToken || void 0, o.secret = s.secret, o.nonce = s.nonce, o.pendingToken = s.pendingToken || null, o;
2024
+ }
2025
+ /** @internal */
2026
+ _getIdTokenResponse(e) {
2027
+ const t = this.buildRequest();
2028
+ return N(e, t);
2029
+ }
2030
+ /** @internal */
2031
+ _linkToIdToken(e, t) {
2032
+ const i = this.buildRequest();
2033
+ return i.idToken = t, N(e, i);
2034
+ }
2035
+ /** @internal */
2036
+ _getReauthenticationResolver(e) {
2037
+ const t = this.buildRequest();
2038
+ return t.autoCreate = !1, N(e, t);
2039
+ }
2040
+ buildRequest() {
2041
+ const e = {
2042
+ requestUri: Xn,
2043
+ returnSecureToken: !0
2044
+ };
2045
+ if (this.pendingToken)
2046
+ e.pendingToken = this.pendingToken;
2047
+ else {
2048
+ const t = {};
2049
+ this.idToken && (t.id_token = this.idToken), this.accessToken && (t.access_token = this.accessToken), this.secret && (t.oauth_token_secret = this.secret), t.providerId = this.providerId, this.nonce && !this.pendingToken && (t.nonce = this.nonce), e.postBody = x(t);
2050
+ }
2051
+ return e;
2052
+ }
2053
+ }
2054
+ /**
2055
+ * @license
2056
+ * Copyright 2020 Google LLC
2057
+ *
2058
+ * Licensed under the Apache License, Version 2.0 (the "License");
2059
+ * you may not use this file except in compliance with the License.
2060
+ * You may obtain a copy of the License at
2061
+ *
2062
+ * http://www.apache.org/licenses/LICENSE-2.0
2063
+ *
2064
+ * Unless required by applicable law or agreed to in writing, software
2065
+ * distributed under the License is distributed on an "AS IS" BASIS,
2066
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2067
+ * See the License for the specific language governing permissions and
2068
+ * limitations under the License.
2069
+ */
2070
+ class kt {
2071
+ /**
2072
+ * Constructor for generic OAuth providers.
2073
+ *
2074
+ * @param providerId - Provider for which credentials should be generated.
2075
+ */
2076
+ constructor(e) {
2077
+ this.providerId = e, this.defaultLanguageCode = null, this.customParameters = {};
2078
+ }
2079
+ /**
2080
+ * Set the language gode.
2081
+ *
2082
+ * @param languageCode - language code
2083
+ */
2084
+ setDefaultLanguage(e) {
2085
+ this.defaultLanguageCode = e;
2086
+ }
2087
+ /**
2088
+ * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
2089
+ * operations.
2090
+ *
2091
+ * @remarks
2092
+ * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
2093
+ * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
2094
+ *
2095
+ * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
2096
+ */
2097
+ setCustomParameters(e) {
2098
+ return this.customParameters = e, this;
2099
+ }
2100
+ /**
2101
+ * Retrieve the current list of {@link CustomParameters}.
2102
+ */
2103
+ getCustomParameters() {
2104
+ return this.customParameters;
2105
+ }
2106
+ }
2107
+ /**
2108
+ * @license
2109
+ * Copyright 2019 Google LLC
2110
+ *
2111
+ * Licensed under the Apache License, Version 2.0 (the "License");
2112
+ * you may not use this file except in compliance with the License.
2113
+ * You may obtain a copy of the License at
2114
+ *
2115
+ * http://www.apache.org/licenses/LICENSE-2.0
2116
+ *
2117
+ * Unless required by applicable law or agreed to in writing, software
2118
+ * distributed under the License is distributed on an "AS IS" BASIS,
2119
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2120
+ * See the License for the specific language governing permissions and
2121
+ * limitations under the License.
2122
+ */
2123
+ class $ extends kt {
2124
+ constructor() {
2125
+ super(...arguments), this.scopes = [];
2126
+ }
2127
+ /**
2128
+ * Add an OAuth scope to the credential.
2129
+ *
2130
+ * @param scope - Provider OAuth scope to add.
2131
+ */
2132
+ addScope(e) {
2133
+ return this.scopes.includes(e) || this.scopes.push(e), this;
2134
+ }
2135
+ /**
2136
+ * Retrieve the current list of OAuth scopes.
2137
+ */
2138
+ getScopes() {
2139
+ return [...this.scopes];
2140
+ }
2141
+ }
2142
+ /**
2143
+ * @license
2144
+ * Copyright 2020 Google LLC
2145
+ *
2146
+ * Licensed under the Apache License, Version 2.0 (the "License");
2147
+ * you may not use this file except in compliance with the License.
2148
+ * You may obtain a copy of the License at
2149
+ *
2150
+ * http://www.apache.org/licenses/LICENSE-2.0
2151
+ *
2152
+ * Unless required by applicable law or agreed to in writing, software
2153
+ * distributed under the License is distributed on an "AS IS" BASIS,
2154
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2155
+ * See the License for the specific language governing permissions and
2156
+ * limitations under the License.
2157
+ */
2158
+ class w extends $ {
2159
+ constructor() {
2160
+ super(
2161
+ "facebook.com"
2162
+ /* ProviderId.FACEBOOK */
2163
+ );
2164
+ }
2165
+ /**
2166
+ * Creates a credential for Facebook.
2167
+ *
2168
+ * @example
2169
+ * ```javascript
2170
+ * // `event` from the Facebook auth.authResponseChange callback.
2171
+ * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
2172
+ * const result = await signInWithCredential(credential);
2173
+ * ```
2174
+ *
2175
+ * @param accessToken - Facebook access token.
2176
+ */
2177
+ static credential(e) {
2178
+ return S._fromParams({
2179
+ providerId: w.PROVIDER_ID,
2180
+ signInMethod: w.FACEBOOK_SIGN_IN_METHOD,
2181
+ accessToken: e
2182
+ });
2183
+ }
2184
+ /**
2185
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2186
+ *
2187
+ * @param userCredential - The user credential.
2188
+ */
2189
+ static credentialFromResult(e) {
2190
+ return w.credentialFromTaggedObject(e);
2191
+ }
2192
+ /**
2193
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2194
+ * thrown during a sign-in, link, or reauthenticate operation.
2195
+ *
2196
+ * @param userCredential - The user credential.
2197
+ */
2198
+ static credentialFromError(e) {
2199
+ return w.credentialFromTaggedObject(e.customData || {});
2200
+ }
2201
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2202
+ if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
2203
+ return null;
2204
+ try {
2205
+ return w.credential(e.oauthAccessToken);
2206
+ } catch {
2207
+ return null;
2208
+ }
2209
+ }
2210
+ }
2211
+ w.FACEBOOK_SIGN_IN_METHOD = "facebook.com";
2212
+ w.PROVIDER_ID = "facebook.com";
2213
+ /**
2214
+ * @license
2215
+ * Copyright 2020 Google LLC
2216
+ *
2217
+ * Licensed under the Apache License, Version 2.0 (the "License");
2218
+ * you may not use this file except in compliance with the License.
2219
+ * You may obtain a copy of the License at
2220
+ *
2221
+ * http://www.apache.org/licenses/LICENSE-2.0
2222
+ *
2223
+ * Unless required by applicable law or agreed to in writing, software
2224
+ * distributed under the License is distributed on an "AS IS" BASIS,
2225
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2226
+ * See the License for the specific language governing permissions and
2227
+ * limitations under the License.
2228
+ */
2229
+ class E extends $ {
2230
+ constructor() {
2231
+ super(
2232
+ "google.com"
2233
+ /* ProviderId.GOOGLE */
2234
+ ), this.addScope("profile");
2235
+ }
2236
+ /**
2237
+ * Creates a credential for Google. At least one of ID token and access token is required.
2238
+ *
2239
+ * @example
2240
+ * ```javascript
2241
+ * // \`googleUser\` from the onsuccess Google Sign In callback.
2242
+ * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
2243
+ * const result = await signInWithCredential(credential);
2244
+ * ```
2245
+ *
2246
+ * @param idToken - Google ID token.
2247
+ * @param accessToken - Google access token.
2248
+ */
2249
+ static credential(e, t) {
2250
+ return S._fromParams({
2251
+ providerId: E.PROVIDER_ID,
2252
+ signInMethod: E.GOOGLE_SIGN_IN_METHOD,
2253
+ idToken: e,
2254
+ accessToken: t
2255
+ });
2256
+ }
2257
+ /**
2258
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2259
+ *
2260
+ * @param userCredential - The user credential.
2261
+ */
2262
+ static credentialFromResult(e) {
2263
+ return E.credentialFromTaggedObject(e);
2264
+ }
2265
+ /**
2266
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2267
+ * thrown during a sign-in, link, or reauthenticate operation.
2268
+ *
2269
+ * @param userCredential - The user credential.
2270
+ */
2271
+ static credentialFromError(e) {
2272
+ return E.credentialFromTaggedObject(e.customData || {});
2273
+ }
2274
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2275
+ if (!e)
2276
+ return null;
2277
+ const { oauthIdToken: t, oauthAccessToken: i } = e;
2278
+ if (!t && !i)
2279
+ return null;
2280
+ try {
2281
+ return E.credential(t, i);
2282
+ } catch {
2283
+ return null;
2284
+ }
2285
+ }
2286
+ }
2287
+ E.GOOGLE_SIGN_IN_METHOD = "google.com";
2288
+ E.PROVIDER_ID = "google.com";
2289
+ /**
2290
+ * @license
2291
+ * Copyright 2020 Google LLC
2292
+ *
2293
+ * Licensed under the Apache License, Version 2.0 (the "License");
2294
+ * you may not use this file except in compliance with the License.
2295
+ * You may obtain a copy of the License at
2296
+ *
2297
+ * http://www.apache.org/licenses/LICENSE-2.0
2298
+ *
2299
+ * Unless required by applicable law or agreed to in writing, software
2300
+ * distributed under the License is distributed on an "AS IS" BASIS,
2301
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2302
+ * See the License for the specific language governing permissions and
2303
+ * limitations under the License.
2304
+ */
2305
+ class k extends $ {
2306
+ constructor() {
2307
+ super(
2308
+ "github.com"
2309
+ /* ProviderId.GITHUB */
2310
+ );
2311
+ }
2312
+ /**
2313
+ * Creates a credential for Github.
2314
+ *
2315
+ * @param accessToken - Github access token.
2316
+ */
2317
+ static credential(e) {
2318
+ return S._fromParams({
2319
+ providerId: k.PROVIDER_ID,
2320
+ signInMethod: k.GITHUB_SIGN_IN_METHOD,
2321
+ accessToken: e
2322
+ });
2323
+ }
2324
+ /**
2325
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2326
+ *
2327
+ * @param userCredential - The user credential.
2328
+ */
2329
+ static credentialFromResult(e) {
2330
+ return k.credentialFromTaggedObject(e);
2331
+ }
2332
+ /**
2333
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2334
+ * thrown during a sign-in, link, or reauthenticate operation.
2335
+ *
2336
+ * @param userCredential - The user credential.
2337
+ */
2338
+ static credentialFromError(e) {
2339
+ return k.credentialFromTaggedObject(e.customData || {});
2340
+ }
2341
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2342
+ if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
2343
+ return null;
2344
+ try {
2345
+ return k.credential(e.oauthAccessToken);
2346
+ } catch {
2347
+ return null;
2348
+ }
2349
+ }
2350
+ }
2351
+ k.GITHUB_SIGN_IN_METHOD = "github.com";
2352
+ k.PROVIDER_ID = "github.com";
2353
+ /**
2354
+ * @license
2355
+ * Copyright 2020 Google LLC
2356
+ *
2357
+ * Licensed under the Apache License, Version 2.0 (the "License");
2358
+ * you may not use this file except in compliance with the License.
2359
+ * You may obtain a copy of the License at
2360
+ *
2361
+ * http://www.apache.org/licenses/LICENSE-2.0
2362
+ *
2363
+ * Unless required by applicable law or agreed to in writing, software
2364
+ * distributed under the License is distributed on an "AS IS" BASIS,
2365
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2366
+ * See the License for the specific language governing permissions and
2367
+ * limitations under the License.
2368
+ */
2369
+ class R extends $ {
2370
+ constructor() {
2371
+ super(
2372
+ "twitter.com"
2373
+ /* ProviderId.TWITTER */
2374
+ );
2375
+ }
2376
+ /**
2377
+ * Creates a credential for Twitter.
2378
+ *
2379
+ * @param token - Twitter access token.
2380
+ * @param secret - Twitter secret.
2381
+ */
2382
+ static credential(e, t) {
2383
+ return S._fromParams({
2384
+ providerId: R.PROVIDER_ID,
2385
+ signInMethod: R.TWITTER_SIGN_IN_METHOD,
2386
+ oauthToken: e,
2387
+ oauthTokenSecret: t
2388
+ });
2389
+ }
2390
+ /**
2391
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2392
+ *
2393
+ * @param userCredential - The user credential.
2394
+ */
2395
+ static credentialFromResult(e) {
2396
+ return R.credentialFromTaggedObject(e);
2397
+ }
2398
+ /**
2399
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2400
+ * thrown during a sign-in, link, or reauthenticate operation.
2401
+ *
2402
+ * @param userCredential - The user credential.
2403
+ */
2404
+ static credentialFromError(e) {
2405
+ return R.credentialFromTaggedObject(e.customData || {});
2406
+ }
2407
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
2408
+ if (!e)
2409
+ return null;
2410
+ const { oauthAccessToken: t, oauthTokenSecret: i } = e;
2411
+ if (!t || !i)
2412
+ return null;
2413
+ try {
2414
+ return R.credential(t, i);
2415
+ } catch {
2416
+ return null;
2417
+ }
2418
+ }
2419
+ }
2420
+ R.TWITTER_SIGN_IN_METHOD = "twitter.com";
2421
+ R.PROVIDER_ID = "twitter.com";
2422
+ /**
2423
+ * @license
2424
+ * Copyright 2020 Google LLC
2425
+ *
2426
+ * Licensed under the Apache License, Version 2.0 (the "License");
2427
+ * you may not use this file except in compliance with the License.
2428
+ * You may obtain a copy of the License at
2429
+ *
2430
+ * http://www.apache.org/licenses/LICENSE-2.0
2431
+ *
2432
+ * Unless required by applicable law or agreed to in writing, software
2433
+ * distributed under the License is distributed on an "AS IS" BASIS,
2434
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2435
+ * See the License for the specific language governing permissions and
2436
+ * limitations under the License.
2437
+ */
2438
+ class A {
2439
+ constructor(e) {
2440
+ this.user = e.user, this.providerId = e.providerId, this._tokenResponse = e._tokenResponse, this.operationType = e.operationType;
2441
+ }
2442
+ static async _fromIdTokenResponse(e, t, i, r = !1) {
2443
+ const s = await b._fromIdTokenResponse(e, i, r), o = We(i);
2444
+ return new A({
2445
+ user: s,
2446
+ providerId: o,
2447
+ _tokenResponse: i,
2448
+ operationType: t
2449
+ });
2450
+ }
2451
+ static async _forOperation(e, t, i) {
2452
+ await e._updateTokensIfNecessary(
2453
+ i,
2454
+ /* reload */
2455
+ !0
2456
+ );
2457
+ const r = We(i);
2458
+ return new A({
2459
+ user: e,
2460
+ providerId: r,
2461
+ _tokenResponse: i,
2462
+ operationType: t
2463
+ });
2464
+ }
2465
+ }
2466
+ function We(n) {
2467
+ return n.providerId ? n.providerId : "phoneNumber" in n ? "phone" : null;
2468
+ }
2469
+ /**
2470
+ * @license
2471
+ * Copyright 2020 Google LLC
2472
+ *
2473
+ * Licensed under the Apache License, Version 2.0 (the "License");
2474
+ * you may not use this file except in compliance with the License.
2475
+ * You may obtain a copy of the License at
2476
+ *
2477
+ * http://www.apache.org/licenses/LICENSE-2.0
2478
+ *
2479
+ * Unless required by applicable law or agreed to in writing, software
2480
+ * distributed under the License is distributed on an "AS IS" BASIS,
2481
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2482
+ * See the License for the specific language governing permissions and
2483
+ * limitations under the License.
2484
+ */
2485
+ class Z extends ge {
2486
+ constructor(e, t, i, r) {
2487
+ var s;
2488
+ super(t.code, t.message), this.operationType = i, this.user = r, Object.setPrototypeOf(this, Z.prototype), this.customData = {
2489
+ appName: e.name,
2490
+ tenantId: (s = e.tenantId) !== null && s !== void 0 ? s : void 0,
2491
+ _serverResponse: t.customData._serverResponse,
2492
+ operationType: i
2493
+ };
2494
+ }
2495
+ static _fromErrorAndOperation(e, t, i, r) {
2496
+ return new Z(e, t, i, r);
2497
+ }
2498
+ }
2499
+ function Rt(n, e, t, i) {
2500
+ return (e === "reauthenticate" ? t._getReauthenticationResolver(n) : t._getIdTokenResponse(n)).catch((s) => {
2501
+ throw s.code === "auth/multi-factor-auth-required" ? Z._fromErrorAndOperation(n, s, e, i) : s;
2502
+ });
2503
+ }
2504
+ async function Qn(n, e, t = !1) {
2505
+ const i = await U(n, e._linkToIdToken(n.auth, await n.getIdToken()), t);
2506
+ return A._forOperation(n, "link", i);
2507
+ }
2508
+ /**
2509
+ * @license
2510
+ * Copyright 2019 Google LLC
2511
+ *
2512
+ * Licensed under the Apache License, Version 2.0 (the "License");
2513
+ * you may not use this file except in compliance with the License.
2514
+ * You may obtain a copy of the License at
2515
+ *
2516
+ * http://www.apache.org/licenses/LICENSE-2.0
2517
+ *
2518
+ * Unless required by applicable law or agreed to in writing, software
2519
+ * distributed under the License is distributed on an "AS IS" BASIS,
2520
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2521
+ * See the License for the specific language governing permissions and
2522
+ * limitations under the License.
2523
+ */
2524
+ async function Zn(n, e, t = !1) {
2525
+ const { auth: i } = n, r = "reauthenticate";
2526
+ try {
2527
+ const s = await U(n, Rt(i, r, e, n), t);
2528
+ u(
2529
+ s.idToken,
2530
+ i,
2531
+ "internal-error"
2532
+ /* AuthErrorCode.INTERNAL_ERROR */
2533
+ );
2534
+ const o = ye(s.idToken);
2535
+ u(
2536
+ o,
2537
+ i,
2538
+ "internal-error"
2539
+ /* AuthErrorCode.INTERNAL_ERROR */
2540
+ );
2541
+ const { sub: c } = o;
2542
+ return u(
2543
+ n.uid === c,
2544
+ i,
2545
+ "user-mismatch"
2546
+ /* AuthErrorCode.USER_MISMATCH */
2547
+ ), A._forOperation(n, r, s);
2548
+ } catch (s) {
2549
+ throw (s == null ? void 0 : s.code) === "auth/user-not-found" && I(
2550
+ i,
2551
+ "user-mismatch"
2552
+ /* AuthErrorCode.USER_MISMATCH */
2553
+ ), s;
2554
+ }
2555
+ }
2556
+ /**
2557
+ * @license
2558
+ * Copyright 2020 Google LLC
2559
+ *
2560
+ * Licensed under the Apache License, Version 2.0 (the "License");
2561
+ * you may not use this file except in compliance with the License.
2562
+ * You may obtain a copy of the License at
2563
+ *
2564
+ * http://www.apache.org/licenses/LICENSE-2.0
2565
+ *
2566
+ * Unless required by applicable law or agreed to in writing, software
2567
+ * distributed under the License is distributed on an "AS IS" BASIS,
2568
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2569
+ * See the License for the specific language governing permissions and
2570
+ * limitations under the License.
2571
+ */
2572
+ async function ei(n, e, t = !1) {
2573
+ const i = "signIn", r = await Rt(n, i, e), s = await A._fromIdTokenResponse(n, i, r);
2574
+ return t || await n._updateCurrentUser(s.user), s;
2575
+ }
2576
+ /**
2577
+ * @license
2578
+ * Copyright 2020 Google LLC
2579
+ *
2580
+ * Licensed under the Apache License, Version 2.0 (the "License");
2581
+ * you may not use this file except in compliance with the License.
2582
+ * You may obtain a copy of the License at
2583
+ *
2584
+ * http://www.apache.org/licenses/LICENSE-2.0
2585
+ *
2586
+ * Unless required by applicable law or agreed to in writing, software
2587
+ * distributed under the License is distributed on an "AS IS" BASIS,
2588
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2589
+ * See the License for the specific language governing permissions and
2590
+ * limitations under the License.
2591
+ */
2592
+ async function ti(n, e) {
2593
+ return at(n, "POST", "/v1/accounts:signInWithCustomToken", Ie(n, e));
2594
+ }
2595
+ /**
2596
+ * @license
2597
+ * Copyright 2020 Google LLC
2598
+ *
2599
+ * Licensed under the Apache License, Version 2.0 (the "License");
2600
+ * you may not use this file except in compliance with the License.
2601
+ * You may obtain a copy of the License at
2602
+ *
2603
+ * http://www.apache.org/licenses/LICENSE-2.0
2604
+ *
2605
+ * Unless required by applicable law or agreed to in writing, software
2606
+ * distributed under the License is distributed on an "AS IS" BASIS,
2607
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2608
+ * See the License for the specific language governing permissions and
2609
+ * limitations under the License.
2610
+ */
2611
+ async function ni(n, e) {
2612
+ const t = H(n), i = await ti(t, {
2613
+ token: e,
2614
+ returnSecureToken: !0
2615
+ }), r = await A._fromIdTokenResponse(t, "signIn", i);
2616
+ return await t._updateCurrentUser(r.user), r;
2617
+ }
2618
+ function ii(n, e, t, i) {
2619
+ return O(n).onIdTokenChanged(e, t, i);
2620
+ }
2621
+ function ri(n, e, t) {
2622
+ return O(n).beforeAuthStateChanged(e, t);
2623
+ }
2624
+ const ee = "__sak";
2625
+ /**
2626
+ * @license
2627
+ * Copyright 2019 Google LLC
2628
+ *
2629
+ * Licensed under the Apache License, Version 2.0 (the "License");
2630
+ * you may not use this file except in compliance with the License.
2631
+ * You may obtain a copy of the License at
2632
+ *
2633
+ * http://www.apache.org/licenses/LICENSE-2.0
2634
+ *
2635
+ * Unless required by applicable law or agreed to in writing, software
2636
+ * distributed under the License is distributed on an "AS IS" BASIS,
2637
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2638
+ * See the License for the specific language governing permissions and
2639
+ * limitations under the License.
2640
+ */
2641
+ class bt {
2642
+ constructor(e, t) {
2643
+ this.storageRetriever = e, this.type = t;
2644
+ }
2645
+ _isAvailable() {
2646
+ try {
2647
+ return this.storage ? (this.storage.setItem(ee, "1"), this.storage.removeItem(ee), Promise.resolve(!0)) : Promise.resolve(!1);
2648
+ } catch {
2649
+ return Promise.resolve(!1);
2650
+ }
2651
+ }
2652
+ _set(e, t) {
2653
+ return this.storage.setItem(e, JSON.stringify(t)), Promise.resolve();
2654
+ }
2655
+ _get(e) {
2656
+ const t = this.storage.getItem(e);
2657
+ return Promise.resolve(t ? JSON.parse(t) : null);
2658
+ }
2659
+ _remove(e) {
2660
+ return this.storage.removeItem(e), Promise.resolve();
2661
+ }
2662
+ get storage() {
2663
+ return this.storageRetriever();
2664
+ }
2665
+ }
2666
+ /**
2667
+ * @license
2668
+ * Copyright 2020 Google LLC
2669
+ *
2670
+ * Licensed under the Apache License, Version 2.0 (the "License");
2671
+ * you may not use this file except in compliance with the License.
2672
+ * You may obtain a copy of the License at
2673
+ *
2674
+ * http://www.apache.org/licenses/LICENSE-2.0
2675
+ *
2676
+ * Unless required by applicable law or agreed to in writing, software
2677
+ * distributed under the License is distributed on an "AS IS" BASIS,
2678
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2679
+ * See the License for the specific language governing permissions and
2680
+ * limitations under the License.
2681
+ */
2682
+ function si() {
2683
+ const n = f();
2684
+ return Te(n) || ne(n);
2685
+ }
2686
+ const oi = 1e3, ai = 10;
2687
+ class St extends bt {
2688
+ constructor() {
2689
+ super(
2690
+ () => window.localStorage,
2691
+ "LOCAL"
2692
+ /* PersistenceType.LOCAL */
2693
+ ), this.boundEventHandler = (e, t) => this.onStorageEvent(e, t), this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.safariLocalStorageNotSynced = si() && Fn(), this.fallbackToPolling = _t(), this._shouldAllowMigration = !0;
2694
+ }
2695
+ forAllChangedKeys(e) {
2696
+ for (const t of Object.keys(this.listeners)) {
2697
+ const i = this.storage.getItem(t), r = this.localCache[t];
2698
+ i !== r && e(t, r, i);
2699
+ }
2700
+ }
2701
+ onStorageEvent(e, t = !1) {
2702
+ if (!e.key) {
2703
+ this.forAllChangedKeys((o, c, a) => {
2704
+ this.notifyListeners(o, a);
2705
+ });
2706
+ return;
2707
+ }
2708
+ const i = e.key;
2709
+ if (t ? this.detachListener() : this.stopPolling(), this.safariLocalStorageNotSynced) {
2710
+ const o = this.storage.getItem(i);
2711
+ if (e.newValue !== o)
2712
+ e.newValue !== null ? this.storage.setItem(i, e.newValue) : this.storage.removeItem(i);
2713
+ else if (this.localCache[i] === e.newValue && !t)
2714
+ return;
2715
+ }
2716
+ const r = () => {
2717
+ const o = this.storage.getItem(i);
2718
+ !t && this.localCache[i] === o || this.notifyListeners(i, o);
2719
+ }, s = this.storage.getItem(i);
2720
+ Dn() && s !== e.newValue && e.newValue !== e.oldValue ? setTimeout(r, ai) : r();
2721
+ }
2722
+ notifyListeners(e, t) {
2723
+ this.localCache[e] = t;
2724
+ const i = this.listeners[e];
2725
+ if (i)
2726
+ for (const r of Array.from(i))
2727
+ r(t && JSON.parse(t));
2728
+ }
2729
+ startPolling() {
2730
+ this.stopPolling(), this.pollTimer = setInterval(() => {
2731
+ this.forAllChangedKeys((e, t, i) => {
2732
+ this.onStorageEvent(
2733
+ new StorageEvent("storage", {
2734
+ key: e,
2735
+ oldValue: t,
2736
+ newValue: i
2737
+ }),
2738
+ /* poll */
2739
+ !0
2740
+ );
2741
+ });
2742
+ }, oi);
2743
+ }
2744
+ stopPolling() {
2745
+ this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
2746
+ }
2747
+ attachListener() {
2748
+ window.addEventListener("storage", this.boundEventHandler);
2749
+ }
2750
+ detachListener() {
2751
+ window.removeEventListener("storage", this.boundEventHandler);
2752
+ }
2753
+ _addListener(e, t) {
2754
+ Object.keys(this.listeners).length === 0 && (this.fallbackToPolling ? this.startPolling() : this.attachListener()), this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set(), this.localCache[e] = this.storage.getItem(e)), this.listeners[e].add(t);
2755
+ }
2756
+ _removeListener(e, t) {
2757
+ this.listeners[e] && (this.listeners[e].delete(t), this.listeners[e].size === 0 && delete this.listeners[e]), Object.keys(this.listeners).length === 0 && (this.detachListener(), this.stopPolling());
2758
+ }
2759
+ // Update local cache on base operations:
2760
+ async _set(e, t) {
2761
+ await super._set(e, t), this.localCache[e] = JSON.stringify(t);
2762
+ }
2763
+ async _get(e) {
2764
+ const t = await super._get(e);
2765
+ return this.localCache[e] = JSON.stringify(t), t;
2766
+ }
2767
+ async _remove(e) {
2768
+ await super._remove(e), delete this.localCache[e];
2769
+ }
2770
+ }
2771
+ St.type = "LOCAL";
2772
+ const ci = St;
2773
+ /**
2774
+ * @license
2775
+ * Copyright 2020 Google LLC
2776
+ *
2777
+ * Licensed under the Apache License, Version 2.0 (the "License");
2778
+ * you may not use this file except in compliance with the License.
2779
+ * You may obtain a copy of the License at
2780
+ *
2781
+ * http://www.apache.org/licenses/LICENSE-2.0
2782
+ *
2783
+ * Unless required by applicable law or agreed to in writing, software
2784
+ * distributed under the License is distributed on an "AS IS" BASIS,
2785
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2786
+ * See the License for the specific language governing permissions and
2787
+ * limitations under the License.
2788
+ */
2789
+ class At extends bt {
2790
+ constructor() {
2791
+ super(
2792
+ () => window.sessionStorage,
2793
+ "SESSION"
2794
+ /* PersistenceType.SESSION */
2795
+ );
2796
+ }
2797
+ _addListener(e, t) {
2798
+ }
2799
+ _removeListener(e, t) {
2800
+ }
2801
+ }
2802
+ At.type = "SESSION";
2803
+ const Ct = At;
2804
+ /**
2805
+ * @license
2806
+ * Copyright 2019 Google LLC
2807
+ *
2808
+ * Licensed under the Apache License, Version 2.0 (the "License");
2809
+ * you may not use this file except in compliance with the License.
2810
+ * You may obtain a copy of the License at
2811
+ *
2812
+ * http://www.apache.org/licenses/LICENSE-2.0
2813
+ *
2814
+ * Unless required by applicable law or agreed to in writing, software
2815
+ * distributed under the License is distributed on an "AS IS" BASIS,
2816
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2817
+ * See the License for the specific language governing permissions and
2818
+ * limitations under the License.
2819
+ */
2820
+ function li(n) {
2821
+ return Promise.all(n.map(async (e) => {
2822
+ try {
2823
+ return {
2824
+ fulfilled: !0,
2825
+ value: await e
2826
+ };
2827
+ } catch (t) {
2828
+ return {
2829
+ fulfilled: !1,
2830
+ reason: t
2831
+ };
2832
+ }
2833
+ }));
2834
+ }
2835
+ /**
2836
+ * @license
2837
+ * Copyright 2019 Google LLC
2838
+ *
2839
+ * Licensed under the Apache License, Version 2.0 (the "License");
2840
+ * you may not use this file except in compliance with the License.
2841
+ * You may obtain a copy of the License at
2842
+ *
2843
+ * http://www.apache.org/licenses/LICENSE-2.0
2844
+ *
2845
+ * Unless required by applicable law or agreed to in writing, software
2846
+ * distributed under the License is distributed on an "AS IS" BASIS,
2847
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2848
+ * See the License for the specific language governing permissions and
2849
+ * limitations under the License.
2850
+ */
2851
+ class ie {
2852
+ constructor(e) {
2853
+ this.eventTarget = e, this.handlersMap = {}, this.boundEventHandler = this.handleEvent.bind(this);
2854
+ }
2855
+ /**
2856
+ * Obtain an instance of a Receiver for a given event target, if none exists it will be created.
2857
+ *
2858
+ * @param eventTarget - An event target (such as window or self) through which the underlying
2859
+ * messages will be received.
2860
+ */
2861
+ static _getInstance(e) {
2862
+ const t = this.receivers.find((r) => r.isListeningto(e));
2863
+ if (t)
2864
+ return t;
2865
+ const i = new ie(e);
2866
+ return this.receivers.push(i), i;
2867
+ }
2868
+ isListeningto(e) {
2869
+ return this.eventTarget === e;
2870
+ }
2871
+ /**
2872
+ * Fans out a MessageEvent to the appropriate listeners.
2873
+ *
2874
+ * @remarks
2875
+ * Sends an {@link Status.ACK} upon receipt and a {@link Status.DONE} once all handlers have
2876
+ * finished processing.
2877
+ *
2878
+ * @param event - The MessageEvent.
2879
+ *
2880
+ */
2881
+ async handleEvent(e) {
2882
+ const t = e, { eventId: i, eventType: r, data: s } = t.data, o = this.handlersMap[r];
2883
+ if (!(o != null && o.size))
2884
+ return;
2885
+ t.ports[0].postMessage({
2886
+ status: "ack",
2887
+ eventId: i,
2888
+ eventType: r
2889
+ });
2890
+ const c = Array.from(o).map(async (l) => l(t.origin, s)), a = await li(c);
2891
+ t.ports[0].postMessage({
2892
+ status: "done",
2893
+ eventId: i,
2894
+ eventType: r,
2895
+ response: a
2896
+ });
2897
+ }
2898
+ /**
2899
+ * Subscribe an event handler for a particular event.
2900
+ *
2901
+ * @param eventType - Event name to subscribe to.
2902
+ * @param eventHandler - The event handler which should receive the events.
2903
+ *
2904
+ */
2905
+ _subscribe(e, t) {
2906
+ Object.keys(this.handlersMap).length === 0 && this.eventTarget.addEventListener("message", this.boundEventHandler), this.handlersMap[e] || (this.handlersMap[e] = /* @__PURE__ */ new Set()), this.handlersMap[e].add(t);
2907
+ }
2908
+ /**
2909
+ * Unsubscribe an event handler from a particular event.
2910
+ *
2911
+ * @param eventType - Event name to unsubscribe from.
2912
+ * @param eventHandler - Optinoal event handler, if none provided, unsubscribe all handlers on this event.
2913
+ *
2914
+ */
2915
+ _unsubscribe(e, t) {
2916
+ this.handlersMap[e] && t && this.handlersMap[e].delete(t), (!t || this.handlersMap[e].size === 0) && delete this.handlersMap[e], Object.keys(this.handlersMap).length === 0 && this.eventTarget.removeEventListener("message", this.boundEventHandler);
2917
+ }
2918
+ }
2919
+ ie.receivers = [];
2920
+ /**
2921
+ * @license
2922
+ * Copyright 2020 Google LLC
2923
+ *
2924
+ * Licensed under the Apache License, Version 2.0 (the "License");
2925
+ * you may not use this file except in compliance with the License.
2926
+ * You may obtain a copy of the License at
2927
+ *
2928
+ * http://www.apache.org/licenses/LICENSE-2.0
2929
+ *
2930
+ * Unless required by applicable law or agreed to in writing, software
2931
+ * distributed under the License is distributed on an "AS IS" BASIS,
2932
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2933
+ * See the License for the specific language governing permissions and
2934
+ * limitations under the License.
2935
+ */
2936
+ function we(n = "", e = 10) {
2937
+ let t = "";
2938
+ for (let i = 0; i < e; i++)
2939
+ t += Math.floor(Math.random() * 10);
2940
+ return n + t;
2941
+ }
2942
+ /**
2943
+ * @license
2944
+ * Copyright 2019 Google LLC
2945
+ *
2946
+ * Licensed under the Apache License, Version 2.0 (the "License");
2947
+ * you may not use this file except in compliance with the License.
2948
+ * You may obtain a copy of the License at
2949
+ *
2950
+ * http://www.apache.org/licenses/LICENSE-2.0
2951
+ *
2952
+ * Unless required by applicable law or agreed to in writing, software
2953
+ * distributed under the License is distributed on an "AS IS" BASIS,
2954
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2955
+ * See the License for the specific language governing permissions and
2956
+ * limitations under the License.
2957
+ */
2958
+ class ui {
2959
+ constructor(e) {
2960
+ this.target = e, this.handlers = /* @__PURE__ */ new Set();
2961
+ }
2962
+ /**
2963
+ * Unsubscribe the handler and remove it from our tracking Set.
2964
+ *
2965
+ * @param handler - The handler to unsubscribe.
2966
+ */
2967
+ removeMessageHandler(e) {
2968
+ e.messageChannel && (e.messageChannel.port1.removeEventListener("message", e.onMessage), e.messageChannel.port1.close()), this.handlers.delete(e);
2969
+ }
2970
+ /**
2971
+ * Send a message to the Receiver located at {@link target}.
2972
+ *
2973
+ * @remarks
2974
+ * We'll first wait a bit for an ACK , if we get one we will wait significantly longer until the
2975
+ * receiver has had a chance to fully process the event.
2976
+ *
2977
+ * @param eventType - Type of event to send.
2978
+ * @param data - The payload of the event.
2979
+ * @param timeout - Timeout for waiting on an ACK from the receiver.
2980
+ *
2981
+ * @returns An array of settled promises from all the handlers that were listening on the receiver.
2982
+ */
2983
+ async _send(e, t, i = 50) {
2984
+ const r = typeof MessageChannel < "u" ? new MessageChannel() : null;
2985
+ if (!r)
2986
+ throw new Error(
2987
+ "connection_unavailable"
2988
+ /* _MessageError.CONNECTION_UNAVAILABLE */
2989
+ );
2990
+ let s, o;
2991
+ return new Promise((c, a) => {
2992
+ const l = we("", 20);
2993
+ r.port1.start();
2994
+ const d = setTimeout(() => {
2995
+ a(new Error(
2996
+ "unsupported_event"
2997
+ /* _MessageError.UNSUPPORTED_EVENT */
2998
+ ));
2999
+ }, i);
3000
+ o = {
3001
+ messageChannel: r,
3002
+ onMessage(h) {
3003
+ const p = h;
3004
+ if (p.data.eventId === l)
3005
+ switch (p.data.status) {
3006
+ case "ack":
3007
+ clearTimeout(d), s = setTimeout(
3008
+ () => {
3009
+ a(new Error(
3010
+ "timeout"
3011
+ /* _MessageError.TIMEOUT */
3012
+ ));
3013
+ },
3014
+ 3e3
3015
+ /* _TimeoutDuration.COMPLETION */
3016
+ );
3017
+ break;
3018
+ case "done":
3019
+ clearTimeout(s), c(p.data.response);
3020
+ break;
3021
+ default:
3022
+ clearTimeout(d), clearTimeout(s), a(new Error(
3023
+ "invalid_response"
3024
+ /* _MessageError.INVALID_RESPONSE */
3025
+ ));
3026
+ break;
3027
+ }
3028
+ }
3029
+ }, this.handlers.add(o), r.port1.addEventListener("message", o.onMessage), this.target.postMessage({
3030
+ eventType: e,
3031
+ eventId: l,
3032
+ data: t
3033
+ }, [r.port2]);
3034
+ }).finally(() => {
3035
+ o && this.removeMessageHandler(o);
3036
+ });
3037
+ }
3038
+ }
3039
+ /**
3040
+ * @license
3041
+ * Copyright 2020 Google LLC
3042
+ *
3043
+ * Licensed under the Apache License, Version 2.0 (the "License");
3044
+ * you may not use this file except in compliance with the License.
3045
+ * You may obtain a copy of the License at
3046
+ *
3047
+ * http://www.apache.org/licenses/LICENSE-2.0
3048
+ *
3049
+ * Unless required by applicable law or agreed to in writing, software
3050
+ * distributed under the License is distributed on an "AS IS" BASIS,
3051
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3052
+ * See the License for the specific language governing permissions and
3053
+ * limitations under the License.
3054
+ */
3055
+ function m() {
3056
+ return window;
3057
+ }
3058
+ function di(n) {
3059
+ m().location.href = n;
3060
+ }
3061
+ /**
3062
+ * @license
3063
+ * Copyright 2020 Google LLC.
3064
+ *
3065
+ * Licensed under the Apache License, Version 2.0 (the "License");
3066
+ * you may not use this file except in compliance with the License.
3067
+ * You may obtain a copy of the License at
3068
+ *
3069
+ * http://www.apache.org/licenses/LICENSE-2.0
3070
+ *
3071
+ * Unless required by applicable law or agreed to in writing, software
3072
+ * distributed under the License is distributed on an "AS IS" BASIS,
3073
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3074
+ * See the License for the specific language governing permissions and
3075
+ * limitations under the License.
3076
+ */
3077
+ function Pt() {
3078
+ return typeof m().WorkerGlobalScope < "u" && typeof m().importScripts == "function";
3079
+ }
3080
+ async function hi() {
3081
+ if (!(navigator != null && navigator.serviceWorker))
3082
+ return null;
3083
+ try {
3084
+ return (await navigator.serviceWorker.ready).active;
3085
+ } catch {
3086
+ return null;
3087
+ }
3088
+ }
3089
+ function fi() {
3090
+ var n;
3091
+ return ((n = navigator == null ? void 0 : navigator.serviceWorker) === null || n === void 0 ? void 0 : n.controller) || null;
3092
+ }
3093
+ function pi() {
3094
+ return Pt() ? self : null;
3095
+ }
3096
+ /**
3097
+ * @license
3098
+ * Copyright 2019 Google LLC
3099
+ *
3100
+ * Licensed under the Apache License, Version 2.0 (the "License");
3101
+ * you may not use this file except in compliance with the License.
3102
+ * You may obtain a copy of the License at
3103
+ *
3104
+ * http://www.apache.org/licenses/LICENSE-2.0
3105
+ *
3106
+ * Unless required by applicable law or agreed to in writing, software
3107
+ * distributed under the License is distributed on an "AS IS" BASIS,
3108
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3109
+ * See the License for the specific language governing permissions and
3110
+ * limitations under the License.
3111
+ */
3112
+ const Nt = "firebaseLocalStorageDb", gi = 1, te = "firebaseLocalStorage", Ot = "fbase_key";
3113
+ class j {
3114
+ constructor(e) {
3115
+ this.request = e;
3116
+ }
3117
+ toPromise() {
3118
+ return new Promise((e, t) => {
3119
+ this.request.addEventListener("success", () => {
3120
+ e(this.request.result);
3121
+ }), this.request.addEventListener("error", () => {
3122
+ t(this.request.error);
3123
+ });
3124
+ });
3125
+ }
3126
+ }
3127
+ function re(n, e) {
3128
+ return n.transaction([te], e ? "readwrite" : "readonly").objectStore(te);
3129
+ }
3130
+ function mi() {
3131
+ const n = indexedDB.deleteDatabase(Nt);
3132
+ return new j(n).toPromise();
3133
+ }
3134
+ function fe() {
3135
+ const n = indexedDB.open(Nt, gi);
3136
+ return new Promise((e, t) => {
3137
+ n.addEventListener("error", () => {
3138
+ t(n.error);
3139
+ }), n.addEventListener("upgradeneeded", () => {
3140
+ const i = n.result;
3141
+ try {
3142
+ i.createObjectStore(te, { keyPath: Ot });
3143
+ } catch (r) {
3144
+ t(r);
3145
+ }
3146
+ }), n.addEventListener("success", async () => {
3147
+ const i = n.result;
3148
+ i.objectStoreNames.contains(te) ? e(i) : (i.close(), await mi(), e(await fe()));
3149
+ });
3150
+ });
3151
+ }
3152
+ async function He(n, e, t) {
3153
+ const i = re(n, !0).put({
3154
+ [Ot]: e,
3155
+ value: t
3156
+ });
3157
+ return new j(i).toPromise();
3158
+ }
3159
+ async function _i(n, e) {
3160
+ const t = re(n, !1).get(e), i = await new j(t).toPromise();
3161
+ return i === void 0 ? null : i.value;
3162
+ }
3163
+ function $e(n, e) {
3164
+ const t = re(n, !0).delete(e);
3165
+ return new j(t).toPromise();
3166
+ }
3167
+ const vi = 800, Ii = 3;
3168
+ class Lt {
3169
+ constructor() {
3170
+ this.type = "LOCAL", this._shouldAllowMigration = !0, this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.pendingWrites = 0, this.receiver = null, this.sender = null, this.serviceWorkerReceiverAvailable = !1, this.activeServiceWorker = null, this._workerInitializationPromise = this.initializeServiceWorkerMessaging().then(() => {
3171
+ }, () => {
3172
+ });
3173
+ }
3174
+ async _openDb() {
3175
+ return this.db ? this.db : (this.db = await fe(), this.db);
3176
+ }
3177
+ async _withRetries(e) {
3178
+ let t = 0;
3179
+ for (; ; )
3180
+ try {
3181
+ const i = await this._openDb();
3182
+ return await e(i);
3183
+ } catch (i) {
3184
+ if (t++ > Ii)
3185
+ throw i;
3186
+ this.db && (this.db.close(), this.db = void 0);
3187
+ }
3188
+ }
3189
+ /**
3190
+ * IndexedDB events do not propagate from the main window to the worker context. We rely on a
3191
+ * postMessage interface to send these events to the worker ourselves.
3192
+ */
3193
+ async initializeServiceWorkerMessaging() {
3194
+ return Pt() ? this.initializeReceiver() : this.initializeSender();
3195
+ }
3196
+ /**
3197
+ * As the worker we should listen to events from the main window.
3198
+ */
3199
+ async initializeReceiver() {
3200
+ this.receiver = ie._getInstance(pi()), this.receiver._subscribe("keyChanged", async (e, t) => ({
3201
+ keyProcessed: (await this._poll()).includes(t.key)
3202
+ })), this.receiver._subscribe("ping", async (e, t) => [
3203
+ "keyChanged"
3204
+ /* _EventType.KEY_CHANGED */
3205
+ ]);
3206
+ }
3207
+ /**
3208
+ * As the main window, we should let the worker know when keys change (set and remove).
3209
+ *
3210
+ * @remarks
3211
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/ready | ServiceWorkerContainer.ready}
3212
+ * may not resolve.
3213
+ */
3214
+ async initializeSender() {
3215
+ var e, t;
3216
+ if (this.activeServiceWorker = await hi(), !this.activeServiceWorker)
3217
+ return;
3218
+ this.sender = new ui(this.activeServiceWorker);
3219
+ const i = await this.sender._send(
3220
+ "ping",
3221
+ {},
3222
+ 800
3223
+ /* _TimeoutDuration.LONG_ACK */
3224
+ );
3225
+ i && !((e = i[0]) === null || e === void 0) && e.fulfilled && !((t = i[0]) === null || t === void 0) && t.value.includes(
3226
+ "keyChanged"
3227
+ /* _EventType.KEY_CHANGED */
3228
+ ) && (this.serviceWorkerReceiverAvailable = !0);
3229
+ }
3230
+ /**
3231
+ * Let the worker know about a changed key, the exact key doesn't technically matter since the
3232
+ * worker will just trigger a full sync anyway.
3233
+ *
3234
+ * @remarks
3235
+ * For now, we only support one service worker per page.
3236
+ *
3237
+ * @param key - Storage key which changed.
3238
+ */
3239
+ async notifyServiceWorker(e) {
3240
+ if (!(!this.sender || !this.activeServiceWorker || fi() !== this.activeServiceWorker))
3241
+ try {
3242
+ await this.sender._send(
3243
+ "keyChanged",
3244
+ { key: e },
3245
+ // Use long timeout if receiver has previously responded to a ping from us.
3246
+ this.serviceWorkerReceiverAvailable ? 800 : 50
3247
+ /* _TimeoutDuration.ACK */
3248
+ );
3249
+ } catch {
3250
+ }
3251
+ }
3252
+ async _isAvailable() {
3253
+ try {
3254
+ if (!indexedDB)
3255
+ return !1;
3256
+ const e = await fe();
3257
+ return await He(e, ee, "1"), await $e(e, ee), !0;
3258
+ } catch {
3259
+ }
3260
+ return !1;
3261
+ }
3262
+ async _withPendingWrite(e) {
3263
+ this.pendingWrites++;
3264
+ try {
3265
+ await e();
3266
+ } finally {
3267
+ this.pendingWrites--;
3268
+ }
3269
+ }
3270
+ async _set(e, t) {
3271
+ return this._withPendingWrite(async () => (await this._withRetries((i) => He(i, e, t)), this.localCache[e] = t, this.notifyServiceWorker(e)));
3272
+ }
3273
+ async _get(e) {
3274
+ const t = await this._withRetries((i) => _i(i, e));
3275
+ return this.localCache[e] = t, t;
3276
+ }
3277
+ async _remove(e) {
3278
+ return this._withPendingWrite(async () => (await this._withRetries((t) => $e(t, e)), delete this.localCache[e], this.notifyServiceWorker(e)));
3279
+ }
3280
+ async _poll() {
3281
+ const e = await this._withRetries((r) => {
3282
+ const s = re(r, !1).getAll();
3283
+ return new j(s).toPromise();
3284
+ });
3285
+ if (!e)
3286
+ return [];
3287
+ if (this.pendingWrites !== 0)
3288
+ return [];
3289
+ const t = [], i = /* @__PURE__ */ new Set();
3290
+ for (const { fbase_key: r, value: s } of e)
3291
+ i.add(r), JSON.stringify(this.localCache[r]) !== JSON.stringify(s) && (this.notifyListeners(r, s), t.push(r));
3292
+ for (const r of Object.keys(this.localCache))
3293
+ this.localCache[r] && !i.has(r) && (this.notifyListeners(r, null), t.push(r));
3294
+ return t;
3295
+ }
3296
+ notifyListeners(e, t) {
3297
+ this.localCache[e] = t;
3298
+ const i = this.listeners[e];
3299
+ if (i)
3300
+ for (const r of Array.from(i))
3301
+ r(t);
3302
+ }
3303
+ startPolling() {
3304
+ this.stopPolling(), this.pollTimer = setInterval(async () => this._poll(), vi);
3305
+ }
3306
+ stopPolling() {
3307
+ this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
3308
+ }
3309
+ _addListener(e, t) {
3310
+ Object.keys(this.listeners).length === 0 && this.startPolling(), this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set(), this._get(e)), this.listeners[e].add(t);
3311
+ }
3312
+ _removeListener(e, t) {
3313
+ this.listeners[e] && (this.listeners[e].delete(t), this.listeners[e].size === 0 && delete this.listeners[e]), Object.keys(this.listeners).length === 0 && this.stopPolling();
3314
+ }
3315
+ }
3316
+ Lt.type = "LOCAL";
3317
+ const yi = Lt;
3318
+ new V(3e4, 6e4);
3319
+ /**
3320
+ * @license
3321
+ * Copyright 2021 Google LLC
3322
+ *
3323
+ * Licensed under the Apache License, Version 2.0 (the "License");
3324
+ * you may not use this file except in compliance with the License.
3325
+ * You may obtain a copy of the License at
3326
+ *
3327
+ * http://www.apache.org/licenses/LICENSE-2.0
3328
+ *
3329
+ * Unless required by applicable law or agreed to in writing, software
3330
+ * distributed under the License is distributed on an "AS IS" BASIS,
3331
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3332
+ * See the License for the specific language governing permissions and
3333
+ * limitations under the License.
3334
+ */
3335
+ function Ti(n, e) {
3336
+ return e ? v(e) : (u(
3337
+ n._popupRedirectResolver,
3338
+ n,
3339
+ "argument-error"
3340
+ /* AuthErrorCode.ARGUMENT_ERROR */
3341
+ ), n._popupRedirectResolver);
3342
+ }
3343
+ /**
3344
+ * @license
3345
+ * Copyright 2019 Google LLC
3346
+ *
3347
+ * Licensed under the Apache License, Version 2.0 (the "License");
3348
+ * you may not use this file except in compliance with the License.
3349
+ * You may obtain a copy of the License at
3350
+ *
3351
+ * http://www.apache.org/licenses/LICENSE-2.0
3352
+ *
3353
+ * Unless required by applicable law or agreed to in writing, software
3354
+ * distributed under the License is distributed on an "AS IS" BASIS,
3355
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3356
+ * See the License for the specific language governing permissions and
3357
+ * limitations under the License.
3358
+ */
3359
+ class Ee extends Et {
3360
+ constructor(e) {
3361
+ super(
3362
+ "custom",
3363
+ "custom"
3364
+ /* ProviderId.CUSTOM */
3365
+ ), this.params = e;
3366
+ }
3367
+ _getIdTokenResponse(e) {
3368
+ return N(e, this._buildIdpRequest());
3369
+ }
3370
+ _linkToIdToken(e, t) {
3371
+ return N(e, this._buildIdpRequest(t));
3372
+ }
3373
+ _getReauthenticationResolver(e) {
3374
+ return N(e, this._buildIdpRequest());
3375
+ }
3376
+ _buildIdpRequest(e) {
3377
+ const t = {
3378
+ requestUri: this.params.requestUri,
3379
+ sessionId: this.params.sessionId,
3380
+ postBody: this.params.postBody,
3381
+ tenantId: this.params.tenantId,
3382
+ pendingToken: this.params.pendingToken,
3383
+ returnSecureToken: !0,
3384
+ returnIdpCredential: !0
3385
+ };
3386
+ return e && (t.idToken = e), t;
3387
+ }
3388
+ }
3389
+ function wi(n) {
3390
+ return ei(n.auth, new Ee(n), n.bypassAuthState);
3391
+ }
3392
+ function Ei(n) {
3393
+ const { auth: e, user: t } = n;
3394
+ return u(
3395
+ t,
3396
+ e,
3397
+ "internal-error"
3398
+ /* AuthErrorCode.INTERNAL_ERROR */
3399
+ ), Zn(t, new Ee(n), n.bypassAuthState);
3400
+ }
3401
+ async function ki(n) {
3402
+ const { auth: e, user: t } = n;
3403
+ return u(
3404
+ t,
3405
+ e,
3406
+ "internal-error"
3407
+ /* AuthErrorCode.INTERNAL_ERROR */
3408
+ ), Qn(t, new Ee(n), n.bypassAuthState);
3409
+ }
3410
+ /**
3411
+ * @license
3412
+ * Copyright 2020 Google LLC
3413
+ *
3414
+ * Licensed under the Apache License, Version 2.0 (the "License");
3415
+ * you may not use this file except in compliance with the License.
3416
+ * You may obtain a copy of the License at
3417
+ *
3418
+ * http://www.apache.org/licenses/LICENSE-2.0
3419
+ *
3420
+ * Unless required by applicable law or agreed to in writing, software
3421
+ * distributed under the License is distributed on an "AS IS" BASIS,
3422
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3423
+ * See the License for the specific language governing permissions and
3424
+ * limitations under the License.
3425
+ */
3426
+ class Mt {
3427
+ constructor(e, t, i, r, s = !1) {
3428
+ this.auth = e, this.resolver = i, this.user = r, this.bypassAuthState = s, this.pendingPromise = null, this.eventManager = null, this.filter = Array.isArray(t) ? t : [t];
3429
+ }
3430
+ execute() {
3431
+ return new Promise(async (e, t) => {
3432
+ this.pendingPromise = { resolve: e, reject: t };
3433
+ try {
3434
+ this.eventManager = await this.resolver._initialize(this.auth), await this.onExecution(), this.eventManager.registerConsumer(this);
3435
+ } catch (i) {
3436
+ this.reject(i);
3437
+ }
3438
+ });
3439
+ }
3440
+ async onAuthEvent(e) {
3441
+ const { urlResponse: t, sessionId: i, postBody: r, tenantId: s, error: o, type: c } = e;
3442
+ if (o) {
3443
+ this.reject(o);
3444
+ return;
3445
+ }
3446
+ const a = {
3447
+ auth: this.auth,
3448
+ requestUri: t,
3449
+ sessionId: i,
3450
+ tenantId: s || void 0,
3451
+ postBody: r || void 0,
3452
+ user: this.user,
3453
+ bypassAuthState: this.bypassAuthState
3454
+ };
3455
+ try {
3456
+ this.resolve(await this.getIdpTask(c)(a));
3457
+ } catch (l) {
3458
+ this.reject(l);
3459
+ }
3460
+ }
3461
+ onError(e) {
3462
+ this.reject(e);
3463
+ }
3464
+ getIdpTask(e) {
3465
+ switch (e) {
3466
+ case "signInViaPopup":
3467
+ case "signInViaRedirect":
3468
+ return wi;
3469
+ case "linkViaPopup":
3470
+ case "linkViaRedirect":
3471
+ return ki;
3472
+ case "reauthViaPopup":
3473
+ case "reauthViaRedirect":
3474
+ return Ei;
3475
+ default:
3476
+ I(
3477
+ this.auth,
3478
+ "internal-error"
3479
+ /* AuthErrorCode.INTERNAL_ERROR */
3480
+ );
3481
+ }
3482
+ }
3483
+ resolve(e) {
3484
+ y(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.resolve(e), this.unregisterAndCleanUp();
3485
+ }
3486
+ reject(e) {
3487
+ y(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.reject(e), this.unregisterAndCleanUp();
3488
+ }
3489
+ unregisterAndCleanUp() {
3490
+ this.eventManager && this.eventManager.unregisterConsumer(this), this.pendingPromise = null, this.cleanUp();
3491
+ }
3492
+ }
3493
+ /**
3494
+ * @license
3495
+ * Copyright 2020 Google LLC
3496
+ *
3497
+ * Licensed under the Apache License, Version 2.0 (the "License");
3498
+ * you may not use this file except in compliance with the License.
3499
+ * You may obtain a copy of the License at
3500
+ *
3501
+ * http://www.apache.org/licenses/LICENSE-2.0
3502
+ *
3503
+ * Unless required by applicable law or agreed to in writing, software
3504
+ * distributed under the License is distributed on an "AS IS" BASIS,
3505
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3506
+ * See the License for the specific language governing permissions and
3507
+ * limitations under the License.
3508
+ */
3509
+ const Ri = new V(2e3, 1e4);
3510
+ class C extends Mt {
3511
+ constructor(e, t, i, r, s) {
3512
+ super(e, t, r, s), this.provider = i, this.authWindow = null, this.pollId = null, C.currentPopupAction && C.currentPopupAction.cancel(), C.currentPopupAction = this;
3513
+ }
3514
+ async executeNotNull() {
3515
+ const e = await this.execute();
3516
+ return u(
3517
+ e,
3518
+ this.auth,
3519
+ "internal-error"
3520
+ /* AuthErrorCode.INTERNAL_ERROR */
3521
+ ), e;
3522
+ }
3523
+ async onExecution() {
3524
+ y(this.filter.length === 1, "Popup operations only handle one event");
3525
+ const e = we();
3526
+ this.authWindow = await this.resolver._openPopup(
3527
+ this.auth,
3528
+ this.provider,
3529
+ this.filter[0],
3530
+ // There's always one, see constructor
3531
+ e
3532
+ ), this.authWindow.associatedEvent = e, this.resolver._originValidation(this.auth).catch((t) => {
3533
+ this.reject(t);
3534
+ }), this.resolver._isIframeWebStorageSupported(this.auth, (t) => {
3535
+ t || this.reject(g(
3536
+ this.auth,
3537
+ "web-storage-unsupported"
3538
+ /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */
3539
+ ));
3540
+ }), this.pollUserCancellation();
3541
+ }
3542
+ get eventId() {
3543
+ var e;
3544
+ return ((e = this.authWindow) === null || e === void 0 ? void 0 : e.associatedEvent) || null;
3545
+ }
3546
+ cancel() {
3547
+ this.reject(g(
3548
+ this.auth,
3549
+ "cancelled-popup-request"
3550
+ /* AuthErrorCode.EXPIRED_POPUP_REQUEST */
3551
+ ));
3552
+ }
3553
+ cleanUp() {
3554
+ this.authWindow && this.authWindow.close(), this.pollId && window.clearTimeout(this.pollId), this.authWindow = null, this.pollId = null, C.currentPopupAction = null;
3555
+ }
3556
+ pollUserCancellation() {
3557
+ const e = () => {
3558
+ var t, i;
3559
+ if (!((i = (t = this.authWindow) === null || t === void 0 ? void 0 : t.window) === null || i === void 0) && i.closed) {
3560
+ this.pollId = window.setTimeout(
3561
+ () => {
3562
+ this.pollId = null, this.reject(g(
3563
+ this.auth,
3564
+ "popup-closed-by-user"
3565
+ /* AuthErrorCode.POPUP_CLOSED_BY_USER */
3566
+ ));
3567
+ },
3568
+ 8e3
3569
+ /* _Timeout.AUTH_EVENT */
3570
+ );
3571
+ return;
3572
+ }
3573
+ this.pollId = window.setTimeout(e, Ri.get());
3574
+ };
3575
+ e();
3576
+ }
3577
+ }
3578
+ C.currentPopupAction = null;
3579
+ /**
3580
+ * @license
3581
+ * Copyright 2020 Google LLC
3582
+ *
3583
+ * Licensed under the Apache License, Version 2.0 (the "License");
3584
+ * you may not use this file except in compliance with the License.
3585
+ * You may obtain a copy of the License at
3586
+ *
3587
+ * http://www.apache.org/licenses/LICENSE-2.0
3588
+ *
3589
+ * Unless required by applicable law or agreed to in writing, software
3590
+ * distributed under the License is distributed on an "AS IS" BASIS,
3591
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3592
+ * See the License for the specific language governing permissions and
3593
+ * limitations under the License.
3594
+ */
3595
+ const bi = "pendingRedirect", J = /* @__PURE__ */ new Map();
3596
+ class Si extends Mt {
3597
+ constructor(e, t, i = !1) {
3598
+ super(e, [
3599
+ "signInViaRedirect",
3600
+ "linkViaRedirect",
3601
+ "reauthViaRedirect",
3602
+ "unknown"
3603
+ /* AuthEventType.UNKNOWN */
3604
+ ], t, void 0, i), this.eventId = null;
3605
+ }
3606
+ /**
3607
+ * Override the execute function; if we already have a redirect result, then
3608
+ * just return it.
3609
+ */
3610
+ async execute() {
3611
+ let e = J.get(this.auth._key());
3612
+ if (!e) {
3613
+ try {
3614
+ const i = await Ai(this.resolver, this.auth) ? await super.execute() : null;
3615
+ e = () => Promise.resolve(i);
3616
+ } catch (t) {
3617
+ e = () => Promise.reject(t);
3618
+ }
3619
+ J.set(this.auth._key(), e);
3620
+ }
3621
+ return this.bypassAuthState || J.set(this.auth._key(), () => Promise.resolve(null)), e();
3622
+ }
3623
+ async onAuthEvent(e) {
3624
+ if (e.type === "signInViaRedirect")
3625
+ return super.onAuthEvent(e);
3626
+ if (e.type === "unknown") {
3627
+ this.resolve(null);
3628
+ return;
3629
+ }
3630
+ if (e.eventId) {
3631
+ const t = await this.auth._redirectUserForId(e.eventId);
3632
+ if (t)
3633
+ return this.user = t, super.onAuthEvent(e);
3634
+ this.resolve(null);
3635
+ }
3636
+ }
3637
+ async onExecution() {
3638
+ }
3639
+ cleanUp() {
3640
+ }
3641
+ }
3642
+ async function Ai(n, e) {
3643
+ const t = Ni(e), i = Pi(n);
3644
+ if (!await i._isAvailable())
3645
+ return !1;
3646
+ const r = await i._get(t) === "true";
3647
+ return await i._remove(t), r;
3648
+ }
3649
+ function Ci(n, e) {
3650
+ J.set(n._key(), e);
3651
+ }
3652
+ function Pi(n) {
3653
+ return v(n._redirectPersistence);
3654
+ }
3655
+ function Ni(n) {
3656
+ return z(bi, n.config.apiKey, n.name);
3657
+ }
3658
+ async function Oi(n, e, t = !1) {
3659
+ const i = H(n), r = Ti(i, e), o = await new Si(i, r, t).execute();
3660
+ return o && !t && (delete o.user._redirectEventId, await i._persistUserIfCurrent(o.user), await i._setRedirectUser(null, e)), o;
3661
+ }
3662
+ /**
3663
+ * @license
3664
+ * Copyright 2020 Google LLC
3665
+ *
3666
+ * Licensed under the Apache License, Version 2.0 (the "License");
3667
+ * you may not use this file except in compliance with the License.
3668
+ * You may obtain a copy of the License at
3669
+ *
3670
+ * http://www.apache.org/licenses/LICENSE-2.0
3671
+ *
3672
+ * Unless required by applicable law or agreed to in writing, software
3673
+ * distributed under the License is distributed on an "AS IS" BASIS,
3674
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3675
+ * See the License for the specific language governing permissions and
3676
+ * limitations under the License.
3677
+ */
3678
+ const Li = 10 * 60 * 1e3;
3679
+ class Mi {
3680
+ constructor(e) {
3681
+ this.auth = e, this.cachedEventUids = /* @__PURE__ */ new Set(), this.consumers = /* @__PURE__ */ new Set(), this.queuedRedirectEvent = null, this.hasHandledPotentialRedirect = !1, this.lastProcessedEventTime = Date.now();
3682
+ }
3683
+ registerConsumer(e) {
3684
+ this.consumers.add(e), this.queuedRedirectEvent && this.isEventForConsumer(this.queuedRedirectEvent, e) && (this.sendToConsumer(this.queuedRedirectEvent, e), this.saveEventToCache(this.queuedRedirectEvent), this.queuedRedirectEvent = null);
3685
+ }
3686
+ unregisterConsumer(e) {
3687
+ this.consumers.delete(e);
3688
+ }
3689
+ onEvent(e) {
3690
+ if (this.hasEventBeenHandled(e))
3691
+ return !1;
3692
+ let t = !1;
3693
+ return this.consumers.forEach((i) => {
3694
+ this.isEventForConsumer(e, i) && (t = !0, this.sendToConsumer(e, i), this.saveEventToCache(e));
3695
+ }), this.hasHandledPotentialRedirect || !Ui(e) || (this.hasHandledPotentialRedirect = !0, t || (this.queuedRedirectEvent = e, t = !0)), t;
3696
+ }
3697
+ sendToConsumer(e, t) {
3698
+ var i;
3699
+ if (e.error && !Ut(e)) {
3700
+ const r = ((i = e.error.code) === null || i === void 0 ? void 0 : i.split("auth/")[1]) || "internal-error";
3701
+ t.onError(g(this.auth, r));
3702
+ } else
3703
+ t.onAuthEvent(e);
3704
+ }
3705
+ isEventForConsumer(e, t) {
3706
+ const i = t.eventId === null || !!e.eventId && e.eventId === t.eventId;
3707
+ return t.filter.includes(e.type) && i;
3708
+ }
3709
+ hasEventBeenHandled(e) {
3710
+ return Date.now() - this.lastProcessedEventTime >= Li && this.cachedEventUids.clear(), this.cachedEventUids.has(je(e));
3711
+ }
3712
+ saveEventToCache(e) {
3713
+ this.cachedEventUids.add(je(e)), this.lastProcessedEventTime = Date.now();
3714
+ }
3715
+ }
3716
+ function je(n) {
3717
+ return [n.type, n.eventId, n.sessionId, n.tenantId].filter((e) => e).join("-");
3718
+ }
3719
+ function Ut({ type: n, error: e }) {
3720
+ return n === "unknown" && (e == null ? void 0 : e.code) === "auth/no-auth-event";
3721
+ }
3722
+ function Ui(n) {
3723
+ switch (n.type) {
3724
+ case "signInViaRedirect":
3725
+ case "linkViaRedirect":
3726
+ case "reauthViaRedirect":
3727
+ return !0;
3728
+ case "unknown":
3729
+ return Ut(n);
3730
+ default:
3731
+ return !1;
3732
+ }
3733
+ }
3734
+ /**
3735
+ * @license
3736
+ * Copyright 2020 Google LLC
3737
+ *
3738
+ * Licensed under the Apache License, Version 2.0 (the "License");
3739
+ * you may not use this file except in compliance with the License.
3740
+ * You may obtain a copy of the License at
3741
+ *
3742
+ * http://www.apache.org/licenses/LICENSE-2.0
3743
+ *
3744
+ * Unless required by applicable law or agreed to in writing, software
3745
+ * distributed under the License is distributed on an "AS IS" BASIS,
3746
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3747
+ * See the License for the specific language governing permissions and
3748
+ * limitations under the License.
3749
+ */
3750
+ async function Di(n, e = {}) {
3751
+ return W(n, "GET", "/v1/projects", e);
3752
+ }
3753
+ /**
3754
+ * @license
3755
+ * Copyright 2020 Google LLC
3756
+ *
3757
+ * Licensed under the Apache License, Version 2.0 (the "License");
3758
+ * you may not use this file except in compliance with the License.
3759
+ * You may obtain a copy of the License at
3760
+ *
3761
+ * http://www.apache.org/licenses/LICENSE-2.0
3762
+ *
3763
+ * Unless required by applicable law or agreed to in writing, software
3764
+ * distributed under the License is distributed on an "AS IS" BASIS,
3765
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3766
+ * See the License for the specific language governing permissions and
3767
+ * limitations under the License.
3768
+ */
3769
+ const Fi = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, xi = /^https?/;
3770
+ async function Vi(n) {
3771
+ if (n.config.emulator)
3772
+ return;
3773
+ const { authorizedDomains: e } = await Di(n);
3774
+ for (const t of e)
3775
+ try {
3776
+ if (Wi(t))
3777
+ return;
3778
+ } catch {
3779
+ }
3780
+ I(
3781
+ n,
3782
+ "unauthorized-domain"
3783
+ /* AuthErrorCode.INVALID_ORIGIN */
3784
+ );
3785
+ }
3786
+ function Wi(n) {
3787
+ const e = he(), { protocol: t, hostname: i } = new URL(e);
3788
+ if (n.startsWith("chrome-extension://")) {
3789
+ const o = new URL(n);
3790
+ return o.hostname === "" && i === "" ? t === "chrome-extension:" && n.replace("chrome-extension://", "") === e.replace("chrome-extension://", "") : t === "chrome-extension:" && o.hostname === i;
3791
+ }
3792
+ if (!xi.test(t))
3793
+ return !1;
3794
+ if (Fi.test(n))
3795
+ return i === n;
3796
+ const r = n.replace(/\./g, "\\.");
3797
+ return new RegExp("^(.+\\." + r + "|" + r + ")$", "i").test(i);
3798
+ }
3799
+ /**
3800
+ * @license
3801
+ * Copyright 2020 Google LLC.
3802
+ *
3803
+ * Licensed under the Apache License, Version 2.0 (the "License");
3804
+ * you may not use this file except in compliance with the License.
3805
+ * You may obtain a copy of the License at
3806
+ *
3807
+ * http://www.apache.org/licenses/LICENSE-2.0
3808
+ *
3809
+ * Unless required by applicable law or agreed to in writing, software
3810
+ * distributed under the License is distributed on an "AS IS" BASIS,
3811
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3812
+ * See the License for the specific language governing permissions and
3813
+ * limitations under the License.
3814
+ */
3815
+ const Hi = new V(3e4, 6e4);
3816
+ function Be() {
3817
+ const n = m().___jsl;
3818
+ if (n != null && n.H) {
3819
+ for (const e of Object.keys(n.H))
3820
+ if (n.H[e].r = n.H[e].r || [], n.H[e].L = n.H[e].L || [], n.H[e].r = [...n.H[e].L], n.CP)
3821
+ for (let t = 0; t < n.CP.length; t++)
3822
+ n.CP[t] = null;
3823
+ }
3824
+ }
3825
+ function $i(n) {
3826
+ return new Promise((e, t) => {
3827
+ var i, r, s;
3828
+ function o() {
3829
+ Be(), gapi.load("gapi.iframes", {
3830
+ callback: () => {
3831
+ e(gapi.iframes.getContext());
3832
+ },
3833
+ ontimeout: () => {
3834
+ Be(), t(g(
3835
+ n,
3836
+ "network-request-failed"
3837
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3838
+ ));
3839
+ },
3840
+ timeout: Hi.get()
3841
+ });
3842
+ }
3843
+ if (!((r = (i = m().gapi) === null || i === void 0 ? void 0 : i.iframes) === null || r === void 0) && r.Iframe)
3844
+ e(gapi.iframes.getContext());
3845
+ else if (!((s = m().gapi) === null || s === void 0) && s.load)
3846
+ o();
3847
+ else {
3848
+ const c = Vn("iframefcb");
3849
+ return m()[c] = () => {
3850
+ gapi.load ? o() : t(g(
3851
+ n,
3852
+ "network-request-failed"
3853
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3854
+ ));
3855
+ }, Tt(`https://apis.google.com/js/api.js?onload=${c}`).catch((a) => t(a));
3856
+ }
3857
+ }).catch((e) => {
3858
+ throw Y = null, e;
3859
+ });
3860
+ }
3861
+ let Y = null;
3862
+ function ji(n) {
3863
+ return Y = Y || $i(n), Y;
3864
+ }
3865
+ /**
3866
+ * @license
3867
+ * Copyright 2020 Google LLC.
3868
+ *
3869
+ * Licensed under the Apache License, Version 2.0 (the "License");
3870
+ * you may not use this file except in compliance with the License.
3871
+ * You may obtain a copy of the License at
3872
+ *
3873
+ * http://www.apache.org/licenses/LICENSE-2.0
3874
+ *
3875
+ * Unless required by applicable law or agreed to in writing, software
3876
+ * distributed under the License is distributed on an "AS IS" BASIS,
3877
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3878
+ * See the License for the specific language governing permissions and
3879
+ * limitations under the License.
3880
+ */
3881
+ const Bi = new V(5e3, 15e3), Ki = "__/auth/iframe", qi = "emulator/auth/iframe", Gi = {
3882
+ style: {
3883
+ position: "absolute",
3884
+ top: "-100px",
3885
+ width: "1px",
3886
+ height: "1px"
3887
+ },
3888
+ "aria-hidden": "true",
3889
+ tabindex: "-1"
3890
+ }, zi = /* @__PURE__ */ new Map([
3891
+ ["identitytoolkit.googleapis.com", "p"],
3892
+ ["staging-identitytoolkit.sandbox.googleapis.com", "s"],
3893
+ ["test-identitytoolkit.sandbox.googleapis.com", "t"]
3894
+ // test
3895
+ ]);
3896
+ function Ji(n) {
3897
+ const e = n.config;
3898
+ u(
3899
+ e.authDomain,
3900
+ n,
3901
+ "auth-domain-config-required"
3902
+ /* AuthErrorCode.MISSING_AUTH_DOMAIN */
3903
+ );
3904
+ const t = e.emulator ? ve(e, qi) : `https://${n.config.authDomain}/${Ki}`, i = {
3905
+ apiKey: e.apiKey,
3906
+ appName: n.name,
3907
+ v: F
3908
+ }, r = zi.get(n.config.apiHost);
3909
+ r && (i.eid = r);
3910
+ const s = n._getFrameworks();
3911
+ return s.length && (i.fw = s.join(",")), `${t}?${x(i).slice(1)}`;
3912
+ }
3913
+ async function Yi(n) {
3914
+ const e = await ji(n), t = m().gapi;
3915
+ return u(
3916
+ t,
3917
+ n,
3918
+ "internal-error"
3919
+ /* AuthErrorCode.INTERNAL_ERROR */
3920
+ ), e.open({
3921
+ where: document.body,
3922
+ url: Ji(n),
3923
+ messageHandlersFilter: t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
3924
+ attributes: Gi,
3925
+ dontclear: !0
3926
+ }, (i) => new Promise(async (r, s) => {
3927
+ await i.restyle({
3928
+ // Prevent iframe from closing on mouse out.
3929
+ setHideOnLeave: !1
3930
+ });
3931
+ const o = g(
3932
+ n,
3933
+ "network-request-failed"
3934
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3935
+ ), c = m().setTimeout(() => {
3936
+ s(o);
3937
+ }, Bi.get());
3938
+ function a() {
3939
+ m().clearTimeout(c), r(i);
3940
+ }
3941
+ i.ping(a).then(a, () => {
3942
+ s(o);
3943
+ });
3944
+ }));
3945
+ }
3946
+ /**
3947
+ * @license
3948
+ * Copyright 2020 Google LLC.
3949
+ *
3950
+ * Licensed under the Apache License, Version 2.0 (the "License");
3951
+ * you may not use this file except in compliance with the License.
3952
+ * You may obtain a copy of the License at
3953
+ *
3954
+ * http://www.apache.org/licenses/LICENSE-2.0
3955
+ *
3956
+ * Unless required by applicable law or agreed to in writing, software
3957
+ * distributed under the License is distributed on an "AS IS" BASIS,
3958
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3959
+ * See the License for the specific language governing permissions and
3960
+ * limitations under the License.
3961
+ */
3962
+ const Xi = {
3963
+ location: "yes",
3964
+ resizable: "yes",
3965
+ statusbar: "yes",
3966
+ toolbar: "no"
3967
+ }, Qi = 500, Zi = 600, er = "_blank", tr = "http://localhost";
3968
+ class Ke {
3969
+ constructor(e) {
3970
+ this.window = e, this.associatedEvent = null;
3971
+ }
3972
+ close() {
3973
+ if (this.window)
3974
+ try {
3975
+ this.window.close();
3976
+ } catch {
3977
+ }
3978
+ }
3979
+ }
3980
+ function nr(n, e, t, i = Qi, r = Zi) {
3981
+ const s = Math.max((window.screen.availHeight - r) / 2, 0).toString(), o = Math.max((window.screen.availWidth - i) / 2, 0).toString();
3982
+ let c = "";
3983
+ const a = Object.assign(Object.assign({}, Xi), {
3984
+ width: i.toString(),
3985
+ height: r.toString(),
3986
+ top: s,
3987
+ left: o
3988
+ }), l = f().toLowerCase();
3989
+ t && (c = ht(l) ? er : t), dt(l) && (e = e || tr, a.scrollbars = "yes");
3990
+ const d = Object.entries(a).reduce((p, [B, K]) => `${p}${B}=${K},`, "");
3991
+ if (Un(l) && c !== "_self")
3992
+ return ir(e || "", c), new Ke(null);
3993
+ const h = window.open(e || "", c, d);
3994
+ u(
3995
+ h,
3996
+ n,
3997
+ "popup-blocked"
3998
+ /* AuthErrorCode.POPUP_BLOCKED */
3999
+ );
4000
+ try {
4001
+ h.focus();
4002
+ } catch {
4003
+ }
4004
+ return new Ke(h);
4005
+ }
4006
+ function ir(n, e) {
4007
+ const t = document.createElement("a");
4008
+ t.href = n, t.target = e;
4009
+ const i = document.createEvent("MouseEvent");
4010
+ i.initMouseEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 1, null), t.dispatchEvent(i);
4011
+ }
4012
+ /**
4013
+ * @license
4014
+ * Copyright 2021 Google LLC
4015
+ *
4016
+ * Licensed under the Apache License, Version 2.0 (the "License");
4017
+ * you may not use this file except in compliance with the License.
4018
+ * You may obtain a copy of the License at
4019
+ *
4020
+ * http://www.apache.org/licenses/LICENSE-2.0
4021
+ *
4022
+ * Unless required by applicable law or agreed to in writing, software
4023
+ * distributed under the License is distributed on an "AS IS" BASIS,
4024
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4025
+ * See the License for the specific language governing permissions and
4026
+ * limitations under the License.
4027
+ */
4028
+ const rr = "__/auth/handler", sr = "emulator/auth/handler", or = encodeURIComponent("fac");
4029
+ async function qe(n, e, t, i, r, s) {
4030
+ u(
4031
+ n.config.authDomain,
4032
+ n,
4033
+ "auth-domain-config-required"
4034
+ /* AuthErrorCode.MISSING_AUTH_DOMAIN */
4035
+ ), u(
4036
+ n.config.apiKey,
4037
+ n,
4038
+ "invalid-api-key"
4039
+ /* AuthErrorCode.INVALID_API_KEY */
4040
+ );
4041
+ const o = {
4042
+ apiKey: n.config.apiKey,
4043
+ appName: n.name,
4044
+ authType: t,
4045
+ redirectUrl: i,
4046
+ v: F,
4047
+ eventId: r
4048
+ };
4049
+ if (e instanceof kt) {
4050
+ e.setDefaultLanguage(n.languageCode), o.providerId = e.providerId || "", an(e.getCustomParameters()) || (o.customParameters = JSON.stringify(e.getCustomParameters()));
4051
+ for (const [d, h] of Object.entries(s || {}))
4052
+ o[d] = h;
4053
+ }
4054
+ if (e instanceof $) {
4055
+ const d = e.getScopes().filter((h) => h !== "");
4056
+ d.length > 0 && (o.scopes = d.join(","));
4057
+ }
4058
+ n.tenantId && (o.tid = n.tenantId);
4059
+ const c = o;
4060
+ for (const d of Object.keys(c))
4061
+ c[d] === void 0 && delete c[d];
4062
+ const a = await n._getAppCheckToken(), l = a ? `#${or}=${encodeURIComponent(a)}` : "";
4063
+ return `${ar(n)}?${x(c).slice(1)}${l}`;
4064
+ }
4065
+ function ar({ config: n }) {
4066
+ return n.emulator ? ve(n, sr) : `https://${n.authDomain}/${rr}`;
4067
+ }
4068
+ /**
4069
+ * @license
4070
+ * Copyright 2020 Google LLC
4071
+ *
4072
+ * Licensed under the Apache License, Version 2.0 (the "License");
4073
+ * you may not use this file except in compliance with the License.
4074
+ * You may obtain a copy of the License at
4075
+ *
4076
+ * http://www.apache.org/licenses/LICENSE-2.0
4077
+ *
4078
+ * Unless required by applicable law or agreed to in writing, software
4079
+ * distributed under the License is distributed on an "AS IS" BASIS,
4080
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4081
+ * See the License for the specific language governing permissions and
4082
+ * limitations under the License.
4083
+ */
4084
+ const ue = "webStorageSupport";
4085
+ class cr {
4086
+ constructor() {
4087
+ this.eventManagers = {}, this.iframes = {}, this.originValidationPromises = {}, this._redirectPersistence = Ct, this._completeRedirectFn = Oi, this._overrideRedirectResult = Ci;
4088
+ }
4089
+ // Wrapping in async even though we don't await anywhere in order
4090
+ // to make sure errors are raised as promise rejections
4091
+ async _openPopup(e, t, i, r) {
4092
+ var s;
4093
+ y((s = this.eventManagers[e._key()]) === null || s === void 0 ? void 0 : s.manager, "_initialize() not called before _openPopup()");
4094
+ const o = await qe(e, t, i, he(), r);
4095
+ return nr(e, o, we());
4096
+ }
4097
+ async _openRedirect(e, t, i, r) {
4098
+ await this._originValidation(e);
4099
+ const s = await qe(e, t, i, he(), r);
4100
+ return di(s), new Promise(() => {
4101
+ });
4102
+ }
4103
+ _initialize(e) {
4104
+ const t = e._key();
4105
+ if (this.eventManagers[t]) {
4106
+ const { manager: r, promise: s } = this.eventManagers[t];
4107
+ return r ? Promise.resolve(r) : (y(s, "If manager is not set, promise should be"), s);
4108
+ }
4109
+ const i = this.initAndGetManager(e);
4110
+ return this.eventManagers[t] = { promise: i }, i.catch(() => {
4111
+ delete this.eventManagers[t];
4112
+ }), i;
4113
+ }
4114
+ async initAndGetManager(e) {
4115
+ const t = await Yi(e), i = new Mi(e);
4116
+ return t.register("authEvent", (r) => (u(
4117
+ r == null ? void 0 : r.authEvent,
4118
+ e,
4119
+ "invalid-auth-event"
4120
+ /* AuthErrorCode.INVALID_AUTH_EVENT */
4121
+ ), {
4122
+ status: i.onEvent(r.authEvent) ? "ACK" : "ERROR"
4123
+ /* GapiOutcome.ERROR */
4124
+ }), gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER), this.eventManagers[e._key()] = { manager: i }, this.iframes[e._key()] = t, i;
4125
+ }
4126
+ _isIframeWebStorageSupported(e, t) {
4127
+ this.iframes[e._key()].send(ue, { type: ue }, (r) => {
4128
+ var s;
4129
+ const o = (s = r == null ? void 0 : r[0]) === null || s === void 0 ? void 0 : s[ue];
4130
+ o !== void 0 && t(!!o), I(
4131
+ e,
4132
+ "internal-error"
4133
+ /* AuthErrorCode.INTERNAL_ERROR */
4134
+ );
4135
+ }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
4136
+ }
4137
+ _originValidation(e) {
4138
+ const t = e._key();
4139
+ return this.originValidationPromises[t] || (this.originValidationPromises[t] = Vi(e)), this.originValidationPromises[t];
4140
+ }
4141
+ get _shouldInitProactively() {
4142
+ return _t() || Te() || ne();
4143
+ }
4144
+ }
4145
+ const lr = cr;
4146
+ var Ge = "@firebase/auth", ze = "0.23.2";
4147
+ /**
4148
+ * @license
4149
+ * Copyright 2020 Google LLC
4150
+ *
4151
+ * Licensed under the Apache License, Version 2.0 (the "License");
4152
+ * you may not use this file except in compliance with the License.
4153
+ * You may obtain a copy of the License at
4154
+ *
4155
+ * http://www.apache.org/licenses/LICENSE-2.0
4156
+ *
4157
+ * Unless required by applicable law or agreed to in writing, software
4158
+ * distributed under the License is distributed on an "AS IS" BASIS,
4159
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4160
+ * See the License for the specific language governing permissions and
4161
+ * limitations under the License.
4162
+ */
4163
+ class ur {
4164
+ constructor(e) {
4165
+ this.auth = e, this.internalListeners = /* @__PURE__ */ new Map();
4166
+ }
4167
+ getUid() {
4168
+ var e;
4169
+ return this.assertAuthConfigured(), ((e = this.auth.currentUser) === null || e === void 0 ? void 0 : e.uid) || null;
4170
+ }
4171
+ async getToken(e) {
4172
+ return this.assertAuthConfigured(), await this.auth._initializationPromise, this.auth.currentUser ? { accessToken: await this.auth.currentUser.getIdToken(e) } : null;
4173
+ }
4174
+ addAuthTokenListener(e) {
4175
+ if (this.assertAuthConfigured(), this.internalListeners.has(e))
4176
+ return;
4177
+ const t = this.auth.onIdTokenChanged((i) => {
4178
+ e((i == null ? void 0 : i.stsTokenManager.accessToken) || null);
4179
+ });
4180
+ this.internalListeners.set(e, t), this.updateProactiveRefresh();
4181
+ }
4182
+ removeAuthTokenListener(e) {
4183
+ this.assertAuthConfigured();
4184
+ const t = this.internalListeners.get(e);
4185
+ t && (this.internalListeners.delete(e), t(), this.updateProactiveRefresh());
4186
+ }
4187
+ assertAuthConfigured() {
4188
+ u(
4189
+ this.auth._initializationPromise,
4190
+ "dependent-sdk-initialized-before-auth"
4191
+ /* AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH */
4192
+ );
4193
+ }
4194
+ updateProactiveRefresh() {
4195
+ this.internalListeners.size > 0 ? this.auth._startProactiveRefresh() : this.auth._stopProactiveRefresh();
4196
+ }
4197
+ }
4198
+ /**
4199
+ * @license
4200
+ * Copyright 2020 Google LLC
4201
+ *
4202
+ * Licensed under the Apache License, Version 2.0 (the "License");
4203
+ * you may not use this file except in compliance with the License.
4204
+ * You may obtain a copy of the License at
4205
+ *
4206
+ * http://www.apache.org/licenses/LICENSE-2.0
4207
+ *
4208
+ * Unless required by applicable law or agreed to in writing, software
4209
+ * distributed under the License is distributed on an "AS IS" BASIS,
4210
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4211
+ * See the License for the specific language governing permissions and
4212
+ * limitations under the License.
4213
+ */
4214
+ function dr(n) {
4215
+ switch (n) {
4216
+ case "Node":
4217
+ return "node";
4218
+ case "ReactNative":
4219
+ return "rn";
4220
+ case "Worker":
4221
+ return "webworker";
4222
+ case "Cordova":
4223
+ return "cordova";
4224
+ default:
4225
+ return;
4226
+ }
4227
+ }
4228
+ function hr(n) {
4229
+ Ne(new Oe(
4230
+ "auth",
4231
+ (e, { options: t }) => {
4232
+ const i = e.getProvider("app").getImmediate(), r = e.getProvider("heartbeat"), s = e.getProvider("app-check-internal"), { apiKey: o, authDomain: c } = i.options;
4233
+ u(o && !o.includes(":"), "invalid-api-key", { appName: i.name });
4234
+ const a = {
4235
+ apiKey: o,
4236
+ authDomain: c,
4237
+ clientPlatform: n,
4238
+ apiHost: "identitytoolkit.googleapis.com",
4239
+ tokenApiHost: "securetoken.googleapis.com",
4240
+ apiScheme: "https",
4241
+ sdkClientVersion: vt(n)
4242
+ }, l = new Kn(i, r, s, a);
4243
+ return Gn(l, t), l;
4244
+ },
4245
+ "PUBLIC"
4246
+ /* ComponentType.PUBLIC */
4247
+ ).setInstantiationMode(
4248
+ "EXPLICIT"
4249
+ /* InstantiationMode.EXPLICIT */
4250
+ ).setInstanceCreatedCallback((e, t, i) => {
4251
+ e.getProvider(
4252
+ "auth-internal"
4253
+ /* _ComponentName.AUTH_INTERNAL */
4254
+ ).initialize();
4255
+ })), Ne(new Oe(
4256
+ "auth-internal",
4257
+ (e) => {
4258
+ const t = H(e.getProvider(
4259
+ "auth"
4260
+ /* _ComponentName.AUTH */
4261
+ ).getImmediate());
4262
+ return ((i) => new ur(i))(t);
4263
+ },
4264
+ "PRIVATE"
4265
+ /* ComponentType.PRIVATE */
4266
+ ).setInstantiationMode(
4267
+ "EXPLICIT"
4268
+ /* InstantiationMode.EXPLICIT */
4269
+ )), de(Ge, ze, dr(n)), de(Ge, ze, "esm2017");
4270
+ }
4271
+ /**
4272
+ * @license
4273
+ * Copyright 2021 Google LLC
4274
+ *
4275
+ * Licensed under the Apache License, Version 2.0 (the "License");
4276
+ * you may not use this file except in compliance with the License.
4277
+ * You may obtain a copy of the License at
4278
+ *
4279
+ * http://www.apache.org/licenses/LICENSE-2.0
4280
+ *
4281
+ * Unless required by applicable law or agreed to in writing, software
4282
+ * distributed under the License is distributed on an "AS IS" BASIS,
4283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4284
+ * See the License for the specific language governing permissions and
4285
+ * limitations under the License.
4286
+ */
4287
+ const fr = 5 * 60, pr = et("authIdTokenMaxAge") || fr;
4288
+ let Je = null;
4289
+ const gr = (n) => async (e) => {
4290
+ const t = e && await e.getIdTokenResult(), i = t && ((/* @__PURE__ */ new Date()).getTime() - Date.parse(t.issuedAtTime)) / 1e3;
4291
+ if (i && i > pr)
4292
+ return;
4293
+ const r = t == null ? void 0 : t.token;
4294
+ Je !== r && (Je = r, await fetch(n, {
4295
+ method: r ? "POST" : "DELETE",
4296
+ headers: r ? {
4297
+ Authorization: `Bearer ${r}`
4298
+ } : {}
4299
+ }));
4300
+ };
4301
+ function mr(n = tn()) {
4302
+ const e = tt(n, "auth");
4303
+ if (e.isInitialized())
4304
+ return e.getImmediate();
4305
+ const t = qn(n, {
4306
+ popupRedirectResolver: lr,
4307
+ persistence: [
4308
+ yi,
4309
+ ci,
4310
+ Ct
4311
+ ]
4312
+ }), i = et("authTokenSyncURL");
4313
+ if (i) {
4314
+ const s = gr(i);
4315
+ ri(t, s, () => s(t.currentUser)), ii(t, (o) => s(o));
4316
+ }
4317
+ const r = en("auth");
4318
+ return r && zn(t, `http://${r}`), t;
4319
+ }
4320
+ hr(
4321
+ "Browser"
4322
+ /* ClientPlatform.BROWSER */
4323
+ );
4324
+ async function _r() {
4325
+ if (cn().length)
4326
+ return;
4327
+ const n = ln({ apiKey: "AIzaSyAj8JdCHtP0Vc5vZobCfgoLzWxPIn0WUG4", authDomain: "feedme-dev-4c3ef.firebaseapp.com", databaseURL: "https://feedme-dev-4c3ef.firebaseio.com", projectId: "feedme-dev-4c3ef", storageBucket: "feedme-dev-4c3ef.appspot.com", messagingSenderId: "458797803788", appId: "1:458797803788:web:37f2af2926a84288f0c129", measurementId: "G-J2QG09D2Q7" }), e = await qt.getCustomToken(), t = mr();
4328
+ await ni(t, e), un(n);
4329
+ }
4330
+ async function vr() {
4331
+ if (dn())
4332
+ return;
4333
+ const e = await new M("AIzaSyA_isPR1-9bX7UmRiJIhsIRNNwdn6DdmW4", {
4334
+ libraries: ["places"]
4335
+ }).load();
4336
+ hn(e);
4337
+ }
4338
+ async function Ir() {
4339
+ await _r(), await vr();
4340
+ }
4341
+ const Pr = /* @__PURE__ */ Ye({
4342
+ __name: "App",
4343
+ setup(n) {
4344
+ const e = Ze();
4345
+ return Ht(() => {
4346
+ e.registerSidebarComponent(fn), Ir();
4347
+ }), (t, i) => (Xe(), Qe($t(Bt)));
4348
+ }
4349
+ });
4350
+ export {
4351
+ Pr as default
4352
+ };