@feedmepos/mf-settings 0.0.49 → 0.0.50-prod

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