@ethora/chat-component 26.7.4 → 26.7.6

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 (152) hide show
  1. package/README.md +72 -16
  2. package/dist/ChatProfileModal-hxsWI8cx.js +2139 -0
  3. package/dist/FilePreviewModal-CwWnHsB1.js +736 -0
  4. package/dist/ManageDataModal-CDPXcC93.js +159 -0
  5. package/dist/MarkdownBody-DBJGraWM.js +16874 -0
  6. package/dist/SideDrawer-Dr_lkaOW.js +226 -0
  7. package/dist/UserProfileModal-Q_jhXpsX.js +568 -0
  8. package/dist/UserSettingsModal-OcAJao-d.js +50 -0
  9. package/dist/{VideoCallOverlay-BUfKp87t.js → VideoCallOverlay-CC4sShdK.js} +9 -10
  10. package/dist/VisibilityModal-DkMhx_2k.js +132 -0
  11. package/dist/assets/icons.d.ts +30 -0
  12. package/dist/components/ContextMenu/ContextMenuComponents.d.ts +1 -3
  13. package/dist/components/EmojiPicker/LazyEmojiPicker.d.ts +3 -0
  14. package/dist/components/ExampleComponents/CustomMessage.d.ts +3 -3
  15. package/dist/components/Files/FilesList.d.ts +12 -0
  16. package/dist/components/Files/FilesPanel.d.ts +3 -0
  17. package/dist/components/Files/fileCategory.d.ts +13 -0
  18. package/dist/components/InputComponents/AttachmentPreview.d.ts +17 -0
  19. package/dist/components/InputComponents/MentionDropdown.d.ts +13 -0
  20. package/dist/components/InputComponents/MentionPickerModal.d.ts +19 -0
  21. package/dist/components/MainComponents/AttachmentList.d.ts +7 -0
  22. package/dist/components/MainComponents/ChatErrorBoundary.d.ts +53 -0
  23. package/dist/components/MainComponents/ChatErrorScreen.d.ts +24 -0
  24. package/dist/components/MainComponents/HeaderLogo.d.ts +18 -0
  25. package/dist/components/MainComponents/MediaMessage.d.ts +5 -0
  26. package/dist/components/MainComponents/MessageContainer.d.ts +2 -2
  27. package/dist/components/MainComponents/ReduxWrapper.d.ts +1 -2
  28. package/dist/components/MainComponents/SystemMessage.d.ts +1 -2
  29. package/dist/components/MenuRoom/MenuRoom.d.ts +1 -0
  30. package/dist/components/MessageBubble/CustomDivider.d.ts +3 -3
  31. package/dist/components/MessageBubble/Message.d.ts +2 -2
  32. package/dist/components/MessageBubble/MessageTranslate.d.ts +28 -10
  33. package/dist/components/MessageBubble/QuickReplies.d.ts +19 -0
  34. package/dist/components/Modals/ChatProfileModal/ChatProfileMemberRow.d.ts +18 -0
  35. package/dist/components/Modals/FilePreviewModal/FilePreviewModal.d.ts +17 -0
  36. package/dist/components/Modals/FilePreviewModal/ImageLightbox.d.ts +35 -0
  37. package/dist/components/Modals/FilePreviewModal/PdfView.d.ts +14 -3
  38. package/dist/components/Modals/NewChatModal/styledNewChatComponents.d.ts +12 -0
  39. package/dist/components/Modals/SettingsModals/Visibility/StyledComponents.d.ts +1 -1
  40. package/dist/components/Modals/SideDrawer/DrawerProfileParts.d.ts +13 -0
  41. package/dist/components/Modals/SideDrawer/SideDrawer.d.ts +44 -0
  42. package/dist/components/Modals/modalComponents.d.ts +6 -0
  43. package/dist/components/Modals/styledModalComponents.d.ts +14 -3
  44. package/dist/components/RoomComponents/ChatRoomItem.d.ts +0 -1
  45. package/dist/components/RoomComponents/OnlineUsersPopover.d.ts +0 -1
  46. package/dist/components/UsersList/StyledComponents.d.ts +5 -1
  47. package/dist/components/UsersList/UsersList.d.ts +23 -0
  48. package/dist/components/styled/Button.d.ts +11 -1
  49. package/dist/components/styled/ChatWrapperBox.d.ts +3 -1
  50. package/dist/components/styled/PdfMessage.d.ts +13 -0
  51. package/dist/components/styled/RoomListComponents/index.d.ts +22 -1
  52. package/dist/components/styled/SendInput.d.ts +19 -5
  53. package/dist/components/styled/StyledComponents.d.ts +1 -1
  54. package/dist/components/styled/StyledInputComponents/MediaComponents.d.ts +18 -0
  55. package/dist/components/styled/StyledInputComponents/StyledInputComponents.d.ts +21 -0
  56. package/dist/components/styled/TreadLabel.d.ts +2 -2
  57. package/dist/components/styled/UnsupportedType.d.ts +1 -1
  58. package/dist/examples/quiz/QuizDemo.d.ts +3 -0
  59. package/dist/examples/quiz/quizScript.d.ts +38 -0
  60. package/dist/examples/quiz/useDemoSession.d.ts +42 -0
  61. package/dist/examples/quiz/useQuizFlow.d.ts +47 -0
  62. package/dist/firebase-config.d.ts +2 -4
  63. package/dist/handleCopyClick-CpmPa6VI.js +32 -0
  64. package/dist/helpers/MarkdownBody.d.ts +7 -0
  65. package/dist/helpers/attachments.d.ts +33 -0
  66. package/dist/helpers/botMarkup.d.ts +30 -0
  67. package/dist/helpers/constants/MODAL_TYPES.d.ts +11 -7
  68. package/dist/helpers/ethoraLogger.d.ts +8 -0
  69. package/dist/helpers/fileKind.d.ts +17 -0
  70. package/dist/helpers/hiddenRooms.d.ts +1 -1
  71. package/dist/helpers/historyPreloadScheduler.d.ts +1 -0
  72. package/dist/helpers/lazyEmoji.d.ts +3 -0
  73. package/dist/helpers/localStorageUser.d.ts +1 -1
  74. package/dist/helpers/markdownSanitizeSchema.d.ts +3 -0
  75. package/dist/helpers/mentions.d.ts +63 -0
  76. package/dist/helpers/parseMessageBody.d.ts +12 -2
  77. package/dist/helpers/pdf/loadPdfjs.d.ts +64 -0
  78. package/dist/helpers/quickReplies.d.ts +31 -0
  79. package/dist/helpers/remarkLineBreaks.d.ts +42 -0
  80. package/dist/helpers/resolveMessageTranslation.d.ts +34 -0
  81. package/dist/helpers/roomImageGallery.d.ts +53 -0
  82. package/dist/helpers/secureFileUrl.d.ts +8 -0
  83. package/dist/helpers/sendFailureWatchdog.d.ts +62 -0
  84. package/dist/helpers/transformTranslatations.d.ts +1 -2
  85. package/dist/hooks/pushSubscriptionSweep.d.ts +41 -0
  86. package/dist/hooks/useChatWrapperInit.d.ts +1 -0
  87. package/dist/hooks/useFilesEndpointSupport.d.ts +9 -0
  88. package/dist/hooks/useInView.d.ts +17 -0
  89. package/dist/hooks/useMentionComposer.d.ts +45 -0
  90. package/dist/hooks/useMessageHeapState.d.ts +1 -1
  91. package/dist/hooks/useMessageTranslation.d.ts +4 -3
  92. package/dist/hooks/useModalDismiss.d.ts +27 -0
  93. package/dist/hooks/useMyFiles.d.ts +16 -0
  94. package/dist/hooks/usePdfThumbnail.d.ts +22 -0
  95. package/dist/hooks/useRoomMute.d.ts +19 -0
  96. package/dist/hooks/useRoomState.d.ts +1 -1
  97. package/dist/hooks/useSendMessage.d.ts +4 -3
  98. package/dist/hooks/useTypography.d.ts +1 -1
  99. package/dist/hooks/useUnreadMessagesCounter.d.ts +11 -2
  100. package/dist/index.esm-B-3fyDHY.js +28 -0
  101. package/dist/index.esm-CRM4VCRa.js +943 -0
  102. package/dist/index.esm-msbp26WN.js +3352 -0
  103. package/dist/index.esm2017-CL0mvq6y.js +1578 -0
  104. package/dist/main-B-8IhwaP.js +31837 -0
  105. package/dist/main.css +1 -1
  106. package/dist/main.d.ts +16 -0
  107. package/dist/main.js +19 -18
  108. package/dist/module-DGXkb0R_.js +2960 -0
  109. package/dist/native-CDi4YD_s.js +13 -0
  110. package/dist/networking/api-requests/files.api.d.ts +19 -0
  111. package/dist/networking/api-requests/rooms.api.d.ts +10 -2
  112. package/dist/networking/api-requests/translate.api.d.ts +15 -0
  113. package/dist/networking/api-requests/user.api.d.ts +2 -0
  114. package/dist/networking/sharedRequest.d.ts +4 -0
  115. package/dist/networking/xmpp/allRoomPresences.xmpp.d.ts +3 -1
  116. package/dist/networking/xmpp/createTimeoutPromise.xmpp.d.ts +14 -0
  117. package/dist/networking/xmpp/sendTextMessage.xmpp.d.ts +2 -1
  118. package/dist/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.d.ts +2 -1
  119. package/dist/networking/xmppClient.d.ts +12 -3
  120. package/dist/pdf-B5b7qHu6.js +17130 -0
  121. package/dist/pdf.worker.min-COYn-gId.js +24385 -0
  122. package/dist/roomStore/index.d.ts +20 -0
  123. package/dist/roomStore/persistEncryption.d.ts +51 -0
  124. package/dist/roomStore/roomsSlice.d.ts +49 -6
  125. package/dist/styles/classNames.d.ts +35 -0
  126. package/dist/styles/motion.d.ts +44 -0
  127. package/dist/styles/tokens.d.ts +27 -0
  128. package/dist/testIds.d.ts +1 -1
  129. package/dist/types/models/attachment.model.d.ts +33 -0
  130. package/dist/types/models/config.model.d.ts +179 -19
  131. package/dist/types/models/file.model.d.ts +20 -0
  132. package/dist/types/models/message.model.d.ts +16 -6
  133. package/dist/types/models/room.model.d.ts +12 -2
  134. package/dist/types/types.d.ts +3 -1
  135. package/dist/utils/resendMessage.d.ts +22 -1
  136. package/dist/utils/translateModePolicy.d.ts +1 -0
  137. package/dist/wavesurfer.esm-D_a19qBW.js +952 -0
  138. package/package.json +22 -2
  139. package/dist/VideoCallOverlay-BUfKp87t.js.map +0 -1
  140. package/dist/components/MainComponents/VirtualList.d.ts +0 -10
  141. package/dist/components/Modals/SettingsModals/BlockedUsers/BlockedUsersModal.d.ts +0 -6
  142. package/dist/components/Modals/SettingsModals/DocumentShares/DocumentSharesModal.d.ts +0 -6
  143. package/dist/components/Modals/SettingsModals/ManageDataModal/StyledComponents.d.ts +0 -0
  144. package/dist/components/Modals/SettingsModals/ProfileShares/ProfileShares.d.ts +0 -6
  145. package/dist/components/Modals/SettingsModals/Referrals/Referrals.d.ts +0 -6
  146. package/dist/hooks/useMessageQueue.d.ts +0 -4
  147. package/dist/main-DFqqDiy-.js +0 -55707
  148. package/dist/main-DFqqDiy-.js.map +0 -1
  149. package/dist/main.js.map +0 -1
  150. package/dist/networking/xmpp/getHistory.xmpp.d.ts +0 -3
  151. package/dist/networking/xmpp/listenerManager.d.ts +0 -17
  152. package/dist/utils/xmppMemoryMonitor.d.ts +0 -16
@@ -0,0 +1,3352 @@
1
+ import { e as _, a as nt, f as it, h as xt, b as Ft, g as M, j as he, k as me, p as Vt, u as Wt, q as V, E as _e, l as jt, m as Ht, n as f, s as $t, t as qt, S as W, w as zt, L as Gt, x as rt, F as ve, y as Bt, z as Kt, _ as De, C as xe, r as Fe, A as Jt } from "./index.esm2017-CL0mvq6y.js";
2
+ function Ie(n, e) {
3
+ var t = {};
4
+ for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
5
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
6
+ for (var r = 0, i = Object.getOwnPropertySymbols(n); r < i.length; r++)
7
+ e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, i[r]) && (t[i[r]] = n[i[r]]);
8
+ return t;
9
+ }
10
+ function st() {
11
+ return {
12
+ "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."
13
+ };
14
+ }
15
+ const Xt = st, ot = new _e("auth", "Firebase", st());
16
+ const Y = new Gt("@firebase/auth");
17
+ function Yt(n, ...e) {
18
+ Y.logLevel <= rt.WARN && Y.warn(`Auth (${W}): ${n}`, ...e);
19
+ }
20
+ function B(n, ...e) {
21
+ Y.logLevel <= rt.ERROR && Y.error(`Auth (${W}): ${n}`, ...e);
22
+ }
23
+ function I(n, ...e) {
24
+ throw ye(n, ...e);
25
+ }
26
+ function m(n, ...e) {
27
+ return ye(n, ...e);
28
+ }
29
+ function we(n, e, t) {
30
+ const i = Object.assign(Object.assign({}, Xt()), { [e]: t });
31
+ return new _e("auth", "Firebase", i).create(e, {
32
+ appName: n.name
33
+ });
34
+ }
35
+ function A(n) {
36
+ return we(n, "operation-not-supported-in-this-environment", "Operations that alter the current user are not supported in conjunction with FirebaseServerApp");
37
+ }
38
+ function Qt(n, e, t) {
39
+ const i = t;
40
+ if (!(e instanceof i))
41
+ throw i.name !== e.constructor.name && I(
42
+ n,
43
+ "argument-error"
44
+ /* AuthErrorCode.ARGUMENT_ERROR */
45
+ ), we(n, "argument-error", `Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`);
46
+ }
47
+ function ye(n, ...e) {
48
+ if (typeof n != "string") {
49
+ const t = e[0], i = [...e.slice(1)];
50
+ return i[0] && (i[0].appName = n.name), n._errorFactory.create(t, ...i);
51
+ }
52
+ return ot.create(n, ...e);
53
+ }
54
+ function u(n, e, ...t) {
55
+ if (!n)
56
+ throw ye(e, ...t);
57
+ }
58
+ function w(n) {
59
+ const e = "INTERNAL ASSERTION FAILED: " + n;
60
+ throw B(e), new Error(e);
61
+ }
62
+ function T(n, e) {
63
+ n || w(e);
64
+ }
65
+ function fe() {
66
+ var n;
67
+ return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.href) || "";
68
+ }
69
+ function Zt() {
70
+ return Ve() === "http:" || Ve() === "https:";
71
+ }
72
+ function Ve() {
73
+ var n;
74
+ return typeof self < "u" && ((n = self.location) === null || n === void 0 ? void 0 : n.protocol) || null;
75
+ }
76
+ function en() {
77
+ return typeof navigator < "u" && navigator && "onLine" in navigator && typeof navigator.onLine == "boolean" && // Apply only for traditional web apps and Chrome extensions.
78
+ // This is especially true for Cordova apps which have unreliable
79
+ // navigator.onLine behavior unless cordova-plugin-network-information is
80
+ // installed which overwrites the native navigator.onLine value and
81
+ // defines navigator.connection.
82
+ (Zt() || zt() || "connection" in navigator) ? navigator.onLine : !0;
83
+ }
84
+ function tn() {
85
+ if (typeof navigator > "u")
86
+ return null;
87
+ const n = navigator;
88
+ return (
89
+ // Most reliable, but only supported in Chrome/Firefox.
90
+ n.languages && n.languages[0] || // Supported in most browsers, but returns the language of the browser
91
+ // UI, not the language set in browser settings.
92
+ n.language || // Couldn't determine language.
93
+ null
94
+ );
95
+ }
96
+ class j {
97
+ constructor(e, t) {
98
+ this.shortDelay = e, this.longDelay = t, T(t > e, "Short delay should be less than long delay!"), this.isMobile = jt() || Ht();
99
+ }
100
+ get() {
101
+ return en() ? this.isMobile ? this.longDelay : this.shortDelay : Math.min(5e3, this.shortDelay);
102
+ }
103
+ }
104
+ function Te(n, e) {
105
+ T(n.emulator, "Emulator should always be set here");
106
+ const { url: t } = n.emulator;
107
+ return e ? `${t}${e.startsWith("/") ? e.slice(1) : e}` : t;
108
+ }
109
+ class at {
110
+ static initialize(e, t, i) {
111
+ this.fetchImpl = e, t && (this.headersImpl = t), i && (this.responseImpl = i);
112
+ }
113
+ static fetch() {
114
+ if (this.fetchImpl)
115
+ return this.fetchImpl;
116
+ if (typeof self < "u" && "fetch" in self)
117
+ return self.fetch;
118
+ if (typeof globalThis < "u" && globalThis.fetch)
119
+ return globalThis.fetch;
120
+ if (typeof fetch < "u")
121
+ return fetch;
122
+ w("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
123
+ }
124
+ static headers() {
125
+ if (this.headersImpl)
126
+ return this.headersImpl;
127
+ if (typeof self < "u" && "Headers" in self)
128
+ return self.Headers;
129
+ if (typeof globalThis < "u" && globalThis.Headers)
130
+ return globalThis.Headers;
131
+ if (typeof Headers < "u")
132
+ return Headers;
133
+ w("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
134
+ }
135
+ static response() {
136
+ if (this.responseImpl)
137
+ return this.responseImpl;
138
+ if (typeof self < "u" && "Response" in self)
139
+ return self.Response;
140
+ if (typeof globalThis < "u" && globalThis.Response)
141
+ return globalThis.Response;
142
+ if (typeof Response < "u")
143
+ return Response;
144
+ w("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill");
145
+ }
146
+ }
147
+ const nn = {
148
+ // Custom token errors.
149
+ CREDENTIAL_MISMATCH: "custom-token-mismatch",
150
+ // This can only happen if the SDK sends a bad request.
151
+ MISSING_CUSTOM_TOKEN: "internal-error",
152
+ // Create Auth URI errors.
153
+ INVALID_IDENTIFIER: "invalid-email",
154
+ // This can only happen if the SDK sends a bad request.
155
+ MISSING_CONTINUE_URI: "internal-error",
156
+ // Sign in with email and password errors (some apply to sign up too).
157
+ INVALID_PASSWORD: "wrong-password",
158
+ // This can only happen if the SDK sends a bad request.
159
+ MISSING_PASSWORD: "missing-password",
160
+ // Thrown if Email Enumeration Protection is enabled in the project and the email or password is
161
+ // invalid.
162
+ INVALID_LOGIN_CREDENTIALS: "invalid-credential",
163
+ // Sign up with email and password errors.
164
+ EMAIL_EXISTS: "email-already-in-use",
165
+ PASSWORD_LOGIN_DISABLED: "operation-not-allowed",
166
+ // Verify assertion for sign in with credential errors:
167
+ INVALID_IDP_RESPONSE: "invalid-credential",
168
+ INVALID_PENDING_TOKEN: "invalid-credential",
169
+ FEDERATED_USER_ID_ALREADY_LINKED: "credential-already-in-use",
170
+ // This can only happen if the SDK sends a bad request.
171
+ MISSING_REQ_TYPE: "internal-error",
172
+ // Send Password reset email errors:
173
+ EMAIL_NOT_FOUND: "user-not-found",
174
+ RESET_PASSWORD_EXCEED_LIMIT: "too-many-requests",
175
+ EXPIRED_OOB_CODE: "expired-action-code",
176
+ INVALID_OOB_CODE: "invalid-action-code",
177
+ // This can only happen if the SDK sends a bad request.
178
+ MISSING_OOB_CODE: "internal-error",
179
+ // Operations that require ID token in request:
180
+ CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "requires-recent-login",
181
+ INVALID_ID_TOKEN: "invalid-user-token",
182
+ TOKEN_EXPIRED: "user-token-expired",
183
+ USER_NOT_FOUND: "user-token-expired",
184
+ // Other errors.
185
+ TOO_MANY_ATTEMPTS_TRY_LATER: "too-many-requests",
186
+ PASSWORD_DOES_NOT_MEET_REQUIREMENTS: "password-does-not-meet-requirements",
187
+ // Phone Auth related errors.
188
+ INVALID_CODE: "invalid-verification-code",
189
+ INVALID_SESSION_INFO: "invalid-verification-id",
190
+ INVALID_TEMPORARY_PROOF: "invalid-credential",
191
+ MISSING_SESSION_INFO: "missing-verification-id",
192
+ SESSION_EXPIRED: "code-expired",
193
+ // Other action code errors when additional settings passed.
194
+ // MISSING_CONTINUE_URI is getting mapped to INTERNAL_ERROR above.
195
+ // This is OK as this error will be caught by client side validation.
196
+ MISSING_ANDROID_PACKAGE_NAME: "missing-android-pkg-name",
197
+ UNAUTHORIZED_DOMAIN: "unauthorized-continue-uri",
198
+ // getProjectConfig errors when clientId is passed.
199
+ INVALID_OAUTH_CLIENT_ID: "invalid-oauth-client-id",
200
+ // User actions (sign-up or deletion) disabled errors.
201
+ ADMIN_ONLY_OPERATION: "admin-restricted-operation",
202
+ // Multi factor related errors.
203
+ INVALID_MFA_PENDING_CREDENTIAL: "invalid-multi-factor-session",
204
+ MFA_ENROLLMENT_NOT_FOUND: "multi-factor-info-not-found",
205
+ MISSING_MFA_ENROLLMENT_ID: "missing-multi-factor-info",
206
+ MISSING_MFA_PENDING_CREDENTIAL: "missing-multi-factor-session",
207
+ SECOND_FACTOR_EXISTS: "second-factor-already-in-use",
208
+ SECOND_FACTOR_LIMIT_EXCEEDED: "maximum-second-factor-count-exceeded",
209
+ // Blocking functions related errors.
210
+ BLOCKING_FUNCTION_ERROR_RESPONSE: "internal-error",
211
+ // Recaptcha related errors.
212
+ RECAPTCHA_NOT_ENABLED: "recaptcha-not-enabled",
213
+ MISSING_RECAPTCHA_TOKEN: "missing-recaptcha-token",
214
+ INVALID_RECAPTCHA_TOKEN: "invalid-recaptcha-token",
215
+ INVALID_RECAPTCHA_ACTION: "invalid-recaptcha-action",
216
+ MISSING_CLIENT_TYPE: "missing-client-type",
217
+ MISSING_RECAPTCHA_VERSION: "missing-recaptcha-version",
218
+ INVALID_RECAPTCHA_VERSION: "invalid-recaptcha-version",
219
+ INVALID_REQ_TYPE: "invalid-req-type"
220
+ /* AuthErrorCode.INVALID_REQ_TYPE */
221
+ };
222
+ const rn = [
223
+ "/v1/accounts:signInWithCustomToken",
224
+ "/v1/accounts:signInWithEmailLink",
225
+ "/v1/accounts:signInWithIdp",
226
+ "/v1/accounts:signInWithPassword",
227
+ "/v1/accounts:signInWithPhoneNumber",
228
+ "/v1/token"
229
+ /* Endpoint.TOKEN */
230
+ ], sn = new j(3e4, 6e4);
231
+ function Ee(n, e) {
232
+ return n.tenantId && !e.tenantId ? Object.assign(Object.assign({}, e), { tenantId: n.tenantId }) : e;
233
+ }
234
+ async function D(n, e, t, i, r = {}) {
235
+ return ct(n, r, async () => {
236
+ let s = {}, o = {};
237
+ i && (e === "GET" ? o = i : s = {
238
+ body: JSON.stringify(i)
239
+ });
240
+ const c = V(Object.assign({ key: n.config.apiKey }, o)).slice(1), a = await n._getAdditionalHeaders();
241
+ a[
242
+ "Content-Type"
243
+ /* HttpHeader.CONTENT_TYPE */
244
+ ] = "application/json", n.languageCode && (a[
245
+ "X-Firebase-Locale"
246
+ /* HttpHeader.X_FIREBASE_LOCALE */
247
+ ] = n.languageCode);
248
+ const l = Object.assign({
249
+ method: e,
250
+ headers: a
251
+ }, s);
252
+ return Kt() || (l.referrerPolicy = "no-referrer"), n.emulatorConfig && me(n.emulatorConfig.host) && (l.credentials = "include"), at.fetch()(await lt(n, n.config.apiHost, t, c), l);
253
+ });
254
+ }
255
+ async function ct(n, e, t) {
256
+ n._canInitEmulator = !1;
257
+ const i = Object.assign(Object.assign({}, nn), e);
258
+ try {
259
+ const r = new an(n), s = await Promise.race([
260
+ t(),
261
+ r.promise
262
+ ]);
263
+ r.clearNetworkTimeout();
264
+ const o = await s.json();
265
+ if ("needConfirmation" in o)
266
+ throw G(n, "account-exists-with-different-credential", o);
267
+ if (s.ok && !("errorMessage" in o))
268
+ return o;
269
+ {
270
+ const c = s.ok ? o.errorMessage : o.error.message, [a, l] = c.split(" : ");
271
+ if (a === "FEDERATED_USER_ID_ALREADY_LINKED")
272
+ throw G(n, "credential-already-in-use", o);
273
+ if (a === "EMAIL_EXISTS")
274
+ throw G(n, "email-already-in-use", o);
275
+ if (a === "USER_DISABLED")
276
+ throw G(n, "user-disabled", o);
277
+ const d = i[a] || a.toLowerCase().replace(/[_\s]+/g, "-");
278
+ if (l)
279
+ throw we(n, d, l);
280
+ I(n, d);
281
+ }
282
+ } catch (r) {
283
+ if (r instanceof ve)
284
+ throw r;
285
+ I(n, "network-request-failed", { message: String(r) });
286
+ }
287
+ }
288
+ async function on(n, e, t, i, r = {}) {
289
+ const s = await D(n, e, t, i, r);
290
+ return "mfaPendingCredential" in s && I(n, "multi-factor-auth-required", {
291
+ _serverResponse: s
292
+ }), s;
293
+ }
294
+ async function lt(n, e, t, i) {
295
+ const r = `${e}${t}?${i}`, s = n, o = s.config.emulator ? Te(n.config, r) : `${n.config.apiScheme}://${r}`;
296
+ return rn.includes(t) && (await s._persistenceManagerAvailable, s._getPersistenceType() === "COOKIE") ? s._getPersistence()._getFinalTarget(o).toString() : o;
297
+ }
298
+ class an {
299
+ clearNetworkTimeout() {
300
+ clearTimeout(this.timer);
301
+ }
302
+ constructor(e) {
303
+ this.auth = e, this.timer = null, this.promise = new Promise((t, i) => {
304
+ this.timer = setTimeout(() => i(m(
305
+ this.auth,
306
+ "network-request-failed"
307
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
308
+ )), sn.get());
309
+ });
310
+ }
311
+ }
312
+ function G(n, e, t) {
313
+ const i = {
314
+ appName: n.name
315
+ };
316
+ t.email && (i.email = t.email), t.phoneNumber && (i.phoneNumber = t.phoneNumber);
317
+ const r = m(n, e, i);
318
+ return r.customData._tokenResponse = t, r;
319
+ }
320
+ async function cn(n, e) {
321
+ return D(n, "POST", "/v1/accounts:delete", e);
322
+ }
323
+ async function Q(n, e) {
324
+ return D(n, "POST", "/v1/accounts:lookup", e);
325
+ }
326
+ function x(n) {
327
+ if (n)
328
+ try {
329
+ const e = new Date(Number(n));
330
+ if (!isNaN(e.getTime()))
331
+ return e.toUTCString();
332
+ } catch {
333
+ }
334
+ }
335
+ async function ln(n, e = !1) {
336
+ const t = M(n), i = await t.getIdToken(e), r = ke(i);
337
+ u(
338
+ r && r.exp && r.auth_time && r.iat,
339
+ t.auth,
340
+ "internal-error"
341
+ /* AuthErrorCode.INTERNAL_ERROR */
342
+ );
343
+ const s = typeof r.firebase == "object" ? r.firebase : void 0, o = s?.sign_in_provider;
344
+ return {
345
+ claims: r,
346
+ token: i,
347
+ authTime: x(ue(r.auth_time)),
348
+ issuedAtTime: x(ue(r.iat)),
349
+ expirationTime: x(ue(r.exp)),
350
+ signInProvider: o || null,
351
+ signInSecondFactor: s?.sign_in_second_factor || null
352
+ };
353
+ }
354
+ function ue(n) {
355
+ return Number(n) * 1e3;
356
+ }
357
+ function ke(n) {
358
+ const [e, t, i] = n.split(".");
359
+ if (e === void 0 || t === void 0 || i === void 0)
360
+ return B("JWT malformed, contained fewer than 3 sections"), null;
361
+ try {
362
+ const r = Bt(t);
363
+ return r ? JSON.parse(r) : (B("Failed to decode base64 JWT payload"), null);
364
+ } catch (r) {
365
+ return B("Caught error parsing JWT payload as JSON", r?.toString()), null;
366
+ }
367
+ }
368
+ function We(n) {
369
+ const e = ke(n);
370
+ return u(
371
+ e,
372
+ "internal-error"
373
+ /* AuthErrorCode.INTERNAL_ERROR */
374
+ ), u(
375
+ typeof e.exp < "u",
376
+ "internal-error"
377
+ /* AuthErrorCode.INTERNAL_ERROR */
378
+ ), u(
379
+ typeof e.iat < "u",
380
+ "internal-error"
381
+ /* AuthErrorCode.INTERNAL_ERROR */
382
+ ), Number(e.exp) - Number(e.iat);
383
+ }
384
+ async function F(n, e, t = !1) {
385
+ if (t)
386
+ return e;
387
+ try {
388
+ return await e;
389
+ } catch (i) {
390
+ throw i instanceof ve && un(i) && n.auth.currentUser === n && await n.auth.signOut(), i;
391
+ }
392
+ }
393
+ function un({ code: n }) {
394
+ return n === "auth/user-disabled" || n === "auth/user-token-expired";
395
+ }
396
+ class dn {
397
+ constructor(e) {
398
+ this.user = e, this.isRunning = !1, this.timerId = null, this.errorBackoff = 3e4;
399
+ }
400
+ _start() {
401
+ this.isRunning || (this.isRunning = !0, this.schedule());
402
+ }
403
+ _stop() {
404
+ this.isRunning && (this.isRunning = !1, this.timerId !== null && clearTimeout(this.timerId));
405
+ }
406
+ getInterval(e) {
407
+ var t;
408
+ if (e) {
409
+ const i = this.errorBackoff;
410
+ return this.errorBackoff = Math.min(
411
+ this.errorBackoff * 2,
412
+ 96e4
413
+ /* Duration.RETRY_BACKOFF_MAX */
414
+ ), i;
415
+ } else {
416
+ this.errorBackoff = 3e4;
417
+ const r = ((t = this.user.stsTokenManager.expirationTime) !== null && t !== void 0 ? t : 0) - Date.now() - 3e5;
418
+ return Math.max(0, r);
419
+ }
420
+ }
421
+ schedule(e = !1) {
422
+ if (!this.isRunning)
423
+ return;
424
+ const t = this.getInterval(e);
425
+ this.timerId = setTimeout(async () => {
426
+ await this.iteration();
427
+ }, t);
428
+ }
429
+ async iteration() {
430
+ try {
431
+ await this.user.getIdToken(!0);
432
+ } catch (e) {
433
+ e?.code === "auth/network-request-failed" && this.schedule(
434
+ /* wasError */
435
+ !0
436
+ );
437
+ return;
438
+ }
439
+ this.schedule();
440
+ }
441
+ }
442
+ class pe {
443
+ constructor(e, t) {
444
+ this.createdAt = e, this.lastLoginAt = t, this._initializeTime();
445
+ }
446
+ _initializeTime() {
447
+ this.lastSignInTime = x(this.lastLoginAt), this.creationTime = x(this.createdAt);
448
+ }
449
+ _copy(e) {
450
+ this.createdAt = e.createdAt, this.lastLoginAt = e.lastLoginAt, this._initializeTime();
451
+ }
452
+ toJSON() {
453
+ return {
454
+ createdAt: this.createdAt,
455
+ lastLoginAt: this.lastLoginAt
456
+ };
457
+ }
458
+ }
459
+ async function Z(n) {
460
+ var e;
461
+ const t = n.auth, i = await n.getIdToken(), r = await F(n, Q(t, { idToken: i }));
462
+ u(
463
+ r?.users.length,
464
+ t,
465
+ "internal-error"
466
+ /* AuthErrorCode.INTERNAL_ERROR */
467
+ );
468
+ const s = r.users[0];
469
+ n._notifyReloadListener(s);
470
+ const o = !((e = s.providerUserInfo) === null || e === void 0) && e.length ? ut(s.providerUserInfo) : [], c = fn(n.providerData, o), a = n.isAnonymous, l = !(n.email && s.passwordHash) && !c?.length, d = a ? l : !1, h = {
471
+ uid: s.localId,
472
+ displayName: s.displayName || null,
473
+ photoURL: s.photoUrl || null,
474
+ email: s.email || null,
475
+ emailVerified: s.emailVerified || !1,
476
+ phoneNumber: s.phoneNumber || null,
477
+ tenantId: s.tenantId || null,
478
+ providerData: c,
479
+ metadata: new pe(s.createdAt, s.lastLoginAt),
480
+ isAnonymous: d
481
+ };
482
+ Object.assign(n, h);
483
+ }
484
+ async function hn(n) {
485
+ const e = M(n);
486
+ await Z(e), await e.auth._persistUserIfCurrent(e), e.auth._notifyListenersIfCurrent(e);
487
+ }
488
+ function fn(n, e) {
489
+ return [...n.filter((i) => !e.some((r) => r.providerId === i.providerId)), ...e];
490
+ }
491
+ function ut(n) {
492
+ return n.map((e) => {
493
+ var { providerId: t } = e, i = Ie(e, ["providerId"]);
494
+ return {
495
+ providerId: t,
496
+ uid: i.rawId || "",
497
+ displayName: i.displayName || null,
498
+ email: i.email || null,
499
+ phoneNumber: i.phoneNumber || null,
500
+ photoURL: i.photoUrl || null
501
+ };
502
+ });
503
+ }
504
+ async function pn(n, e) {
505
+ const t = await ct(n, {}, async () => {
506
+ const i = V({
507
+ grant_type: "refresh_token",
508
+ refresh_token: e
509
+ }).slice(1), { tokenApiHost: r, apiKey: s } = n.config, o = await lt(n, r, "/v1/token", `key=${s}`), c = await n._getAdditionalHeaders();
510
+ c[
511
+ "Content-Type"
512
+ /* HttpHeader.CONTENT_TYPE */
513
+ ] = "application/x-www-form-urlencoded";
514
+ const a = {
515
+ method: "POST",
516
+ headers: c,
517
+ body: i
518
+ };
519
+ return n.emulatorConfig && me(n.emulatorConfig.host) && (a.credentials = "include"), at.fetch()(o, a);
520
+ });
521
+ return {
522
+ accessToken: t.access_token,
523
+ expiresIn: t.expires_in,
524
+ refreshToken: t.refresh_token
525
+ };
526
+ }
527
+ async function gn(n, e) {
528
+ return D(n, "POST", "/v2/accounts:revokeToken", Ee(n, e));
529
+ }
530
+ class O {
531
+ constructor() {
532
+ this.refreshToken = null, this.accessToken = null, this.expirationTime = null;
533
+ }
534
+ get isExpired() {
535
+ return !this.expirationTime || Date.now() > this.expirationTime - 3e4;
536
+ }
537
+ updateFromServerResponse(e) {
538
+ u(
539
+ e.idToken,
540
+ "internal-error"
541
+ /* AuthErrorCode.INTERNAL_ERROR */
542
+ ), u(
543
+ typeof e.idToken < "u",
544
+ "internal-error"
545
+ /* AuthErrorCode.INTERNAL_ERROR */
546
+ ), u(
547
+ typeof e.refreshToken < "u",
548
+ "internal-error"
549
+ /* AuthErrorCode.INTERNAL_ERROR */
550
+ );
551
+ const t = "expiresIn" in e && typeof e.expiresIn < "u" ? Number(e.expiresIn) : We(e.idToken);
552
+ this.updateTokensAndExpiration(e.idToken, e.refreshToken, t);
553
+ }
554
+ updateFromIdToken(e) {
555
+ u(
556
+ e.length !== 0,
557
+ "internal-error"
558
+ /* AuthErrorCode.INTERNAL_ERROR */
559
+ );
560
+ const t = We(e);
561
+ this.updateTokensAndExpiration(e, null, t);
562
+ }
563
+ async getToken(e, t = !1) {
564
+ return !t && this.accessToken && !this.isExpired ? this.accessToken : (u(
565
+ this.refreshToken,
566
+ e,
567
+ "user-token-expired"
568
+ /* AuthErrorCode.TOKEN_EXPIRED */
569
+ ), this.refreshToken ? (await this.refresh(e, this.refreshToken), this.accessToken) : null);
570
+ }
571
+ clearRefreshToken() {
572
+ this.refreshToken = null;
573
+ }
574
+ async refresh(e, t) {
575
+ const { accessToken: i, refreshToken: r, expiresIn: s } = await pn(e, t);
576
+ this.updateTokensAndExpiration(i, r, Number(s));
577
+ }
578
+ updateTokensAndExpiration(e, t, i) {
579
+ this.refreshToken = t || null, this.accessToken = e || null, this.expirationTime = Date.now() + i * 1e3;
580
+ }
581
+ static fromJSON(e, t) {
582
+ const { refreshToken: i, accessToken: r, expirationTime: s } = t, o = new O();
583
+ return i && (u(typeof i == "string", "internal-error", {
584
+ appName: e
585
+ }), o.refreshToken = i), r && (u(typeof r == "string", "internal-error", {
586
+ appName: e
587
+ }), o.accessToken = r), s && (u(typeof s == "number", "internal-error", {
588
+ appName: e
589
+ }), o.expirationTime = s), o;
590
+ }
591
+ toJSON() {
592
+ return {
593
+ refreshToken: this.refreshToken,
594
+ accessToken: this.accessToken,
595
+ expirationTime: this.expirationTime
596
+ };
597
+ }
598
+ _assign(e) {
599
+ this.accessToken = e.accessToken, this.refreshToken = e.refreshToken, this.expirationTime = e.expirationTime;
600
+ }
601
+ _clone() {
602
+ return Object.assign(new O(), this.toJSON());
603
+ }
604
+ _performRefresh() {
605
+ return w("not implemented");
606
+ }
607
+ }
608
+ function E(n, e) {
609
+ u(typeof n == "string" || typeof n > "u", "internal-error", { appName: e });
610
+ }
611
+ class g {
612
+ constructor(e) {
613
+ var { uid: t, auth: i, stsTokenManager: r } = e, s = Ie(e, ["uid", "auth", "stsTokenManager"]);
614
+ this.providerId = "firebase", this.proactiveRefresh = new dn(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 pe(s.createdAt || void 0, s.lastLoginAt || void 0);
615
+ }
616
+ async getIdToken(e) {
617
+ const t = await F(this, this.stsTokenManager.getToken(this.auth, e));
618
+ return u(
619
+ t,
620
+ this.auth,
621
+ "internal-error"
622
+ /* AuthErrorCode.INTERNAL_ERROR */
623
+ ), this.accessToken !== t && (this.accessToken = t, await this.auth._persistUserIfCurrent(this), this.auth._notifyListenersIfCurrent(this)), t;
624
+ }
625
+ getIdTokenResult(e) {
626
+ return ln(this, e);
627
+ }
628
+ reload() {
629
+ return hn(this);
630
+ }
631
+ _assign(e) {
632
+ this !== e && (u(
633
+ this.uid === e.uid,
634
+ this.auth,
635
+ "internal-error"
636
+ /* AuthErrorCode.INTERNAL_ERROR */
637
+ ), 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));
638
+ }
639
+ _clone(e) {
640
+ const t = new g(Object.assign(Object.assign({}, this), { auth: e, stsTokenManager: this.stsTokenManager._clone() }));
641
+ return t.metadata._copy(this.metadata), t;
642
+ }
643
+ _onReload(e) {
644
+ u(
645
+ !this.reloadListener,
646
+ this.auth,
647
+ "internal-error"
648
+ /* AuthErrorCode.INTERNAL_ERROR */
649
+ ), this.reloadListener = e, this.reloadUserInfo && (this._notifyReloadListener(this.reloadUserInfo), this.reloadUserInfo = null);
650
+ }
651
+ _notifyReloadListener(e) {
652
+ this.reloadListener ? this.reloadListener(e) : this.reloadUserInfo = e;
653
+ }
654
+ _startProactiveRefresh() {
655
+ this.proactiveRefresh._start();
656
+ }
657
+ _stopProactiveRefresh() {
658
+ this.proactiveRefresh._stop();
659
+ }
660
+ async _updateTokensIfNecessary(e, t = !1) {
661
+ let i = !1;
662
+ e.idToken && e.idToken !== this.stsTokenManager.accessToken && (this.stsTokenManager.updateFromServerResponse(e), i = !0), t && await Z(this), await this.auth._persistUserIfCurrent(this), i && this.auth._notifyListenersIfCurrent(this);
663
+ }
664
+ async delete() {
665
+ if (_(this.auth.app))
666
+ return Promise.reject(A(this.auth));
667
+ const e = await this.getIdToken();
668
+ return await F(this, cn(this.auth, { idToken: e })), this.stsTokenManager.clearRefreshToken(), this.auth.signOut();
669
+ }
670
+ toJSON() {
671
+ return Object.assign(Object.assign({
672
+ uid: this.uid,
673
+ email: this.email || void 0,
674
+ emailVerified: this.emailVerified,
675
+ displayName: this.displayName || void 0,
676
+ isAnonymous: this.isAnonymous,
677
+ photoURL: this.photoURL || void 0,
678
+ phoneNumber: this.phoneNumber || void 0,
679
+ tenantId: this.tenantId || void 0,
680
+ providerData: this.providerData.map((e) => Object.assign({}, e)),
681
+ stsTokenManager: this.stsTokenManager.toJSON(),
682
+ // Redirect event ID must be maintained in case there is a pending
683
+ // redirect event.
684
+ _redirectEventId: this._redirectEventId
685
+ }, this.metadata.toJSON()), {
686
+ // Required for compatibility with the legacy SDK (go/firebase-auth-sdk-persistence-parsing):
687
+ apiKey: this.auth.config.apiKey,
688
+ appName: this.auth.name
689
+ });
690
+ }
691
+ get refreshToken() {
692
+ return this.stsTokenManager.refreshToken || "";
693
+ }
694
+ static _fromJSON(e, t) {
695
+ var i, r, s, o, c, a, l, d;
696
+ const h = (i = t.displayName) !== null && i !== void 0 ? i : void 0, p = (r = t.email) !== null && r !== void 0 ? r : void 0, q = (s = t.phoneNumber) !== null && s !== void 0 ? s : void 0, z = (o = t.photoURL) !== null && o !== void 0 ? o : void 0, Ce = (c = t.tenantId) !== null && c !== void 0 ? c : void 0, oe = (a = t._redirectEventId) !== null && a !== void 0 ? a : void 0, Oe = (l = t.createdAt) !== null && l !== void 0 ? l : void 0, Ne = (d = t.lastLoginAt) !== null && d !== void 0 ? d : void 0, { uid: ae, emailVerified: Le, isAnonymous: Ue, providerData: ce, stsTokenManager: Me } = t;
697
+ u(
698
+ ae && Me,
699
+ e,
700
+ "internal-error"
701
+ /* AuthErrorCode.INTERNAL_ERROR */
702
+ );
703
+ const Mt = O.fromJSON(this.name, Me);
704
+ u(
705
+ typeof ae == "string",
706
+ e,
707
+ "internal-error"
708
+ /* AuthErrorCode.INTERNAL_ERROR */
709
+ ), E(h, e.name), E(p, e.name), u(
710
+ typeof Le == "boolean",
711
+ e,
712
+ "internal-error"
713
+ /* AuthErrorCode.INTERNAL_ERROR */
714
+ ), u(
715
+ typeof Ue == "boolean",
716
+ e,
717
+ "internal-error"
718
+ /* AuthErrorCode.INTERNAL_ERROR */
719
+ ), E(q, e.name), E(z, e.name), E(Ce, e.name), E(oe, e.name), E(Oe, e.name), E(Ne, e.name);
720
+ const le = new g({
721
+ uid: ae,
722
+ auth: e,
723
+ email: p,
724
+ emailVerified: Le,
725
+ displayName: h,
726
+ isAnonymous: Ue,
727
+ photoURL: z,
728
+ phoneNumber: q,
729
+ tenantId: Ce,
730
+ stsTokenManager: Mt,
731
+ createdAt: Oe,
732
+ lastLoginAt: Ne
733
+ });
734
+ return ce && Array.isArray(ce) && (le.providerData = ce.map((Dt) => Object.assign({}, Dt))), oe && (le._redirectEventId = oe), le;
735
+ }
736
+ /**
737
+ * Initialize a User from an idToken server response
738
+ * @param auth
739
+ * @param idTokenResponse
740
+ */
741
+ static async _fromIdTokenResponse(e, t, i = !1) {
742
+ const r = new O();
743
+ r.updateFromServerResponse(t);
744
+ const s = new g({
745
+ uid: t.localId,
746
+ auth: e,
747
+ stsTokenManager: r,
748
+ isAnonymous: i
749
+ });
750
+ return await Z(s), s;
751
+ }
752
+ /**
753
+ * Initialize a User from an idToken server response
754
+ * @param auth
755
+ * @param idTokenResponse
756
+ */
757
+ static async _fromGetAccountInfoResponse(e, t, i) {
758
+ const r = t.users[0];
759
+ u(
760
+ r.localId !== void 0,
761
+ "internal-error"
762
+ /* AuthErrorCode.INTERNAL_ERROR */
763
+ );
764
+ const s = r.providerUserInfo !== void 0 ? ut(r.providerUserInfo) : [], o = !(r.email && r.passwordHash) && !s?.length, c = new O();
765
+ c.updateFromIdToken(i);
766
+ const a = new g({
767
+ uid: r.localId,
768
+ auth: e,
769
+ stsTokenManager: c,
770
+ isAnonymous: o
771
+ }), l = {
772
+ uid: r.localId,
773
+ displayName: r.displayName || null,
774
+ photoURL: r.photoUrl || null,
775
+ email: r.email || null,
776
+ emailVerified: r.emailVerified || !1,
777
+ phoneNumber: r.phoneNumber || null,
778
+ tenantId: r.tenantId || null,
779
+ providerData: s,
780
+ metadata: new pe(r.createdAt, r.lastLoginAt),
781
+ isAnonymous: !(r.email && r.passwordHash) && !s?.length
782
+ };
783
+ return Object.assign(a, l), a;
784
+ }
785
+ }
786
+ const je = /* @__PURE__ */ new Map();
787
+ function y(n) {
788
+ T(n instanceof Function, "Expected a class definition");
789
+ let e = je.get(n);
790
+ return e ? (T(e instanceof n, "Instance stored in cache mismatched with class"), e) : (e = new n(), je.set(n, e), e);
791
+ }
792
+ class dt {
793
+ constructor() {
794
+ this.type = "NONE", this.storage = {};
795
+ }
796
+ async _isAvailable() {
797
+ return !0;
798
+ }
799
+ async _set(e, t) {
800
+ this.storage[e] = t;
801
+ }
802
+ async _get(e) {
803
+ const t = this.storage[e];
804
+ return t === void 0 ? null : t;
805
+ }
806
+ async _remove(e) {
807
+ delete this.storage[e];
808
+ }
809
+ _addListener(e, t) {
810
+ }
811
+ _removeListener(e, t) {
812
+ }
813
+ }
814
+ dt.type = "NONE";
815
+ const He = dt;
816
+ function K(n, e, t) {
817
+ return `firebase:${n}:${e}:${t}`;
818
+ }
819
+ class N {
820
+ constructor(e, t, i) {
821
+ this.persistence = e, this.auth = t, this.userKey = i;
822
+ const { config: r, name: s } = this.auth;
823
+ this.fullUserKey = K(this.userKey, r.apiKey, s), this.fullPersistenceKey = K("persistence", r.apiKey, s), this.boundEventHandler = t._onStorageEvent.bind(t), this.persistence._addListener(this.fullUserKey, this.boundEventHandler);
824
+ }
825
+ setCurrentUser(e) {
826
+ return this.persistence._set(this.fullUserKey, e.toJSON());
827
+ }
828
+ async getCurrentUser() {
829
+ const e = await this.persistence._get(this.fullUserKey);
830
+ if (!e)
831
+ return null;
832
+ if (typeof e == "string") {
833
+ const t = await Q(this.auth, { idToken: e }).catch(() => {
834
+ });
835
+ return t ? g._fromGetAccountInfoResponse(this.auth, t, e) : null;
836
+ }
837
+ return g._fromJSON(this.auth, e);
838
+ }
839
+ removeCurrentUser() {
840
+ return this.persistence._remove(this.fullUserKey);
841
+ }
842
+ savePersistenceForRedirect() {
843
+ return this.persistence._set(this.fullPersistenceKey, this.persistence.type);
844
+ }
845
+ async setPersistence(e) {
846
+ if (this.persistence === e)
847
+ return;
848
+ const t = await this.getCurrentUser();
849
+ if (await this.removeCurrentUser(), this.persistence = e, t)
850
+ return this.setCurrentUser(t);
851
+ }
852
+ delete() {
853
+ this.persistence._removeListener(this.fullUserKey, this.boundEventHandler);
854
+ }
855
+ static async create(e, t, i = "authUser") {
856
+ if (!t.length)
857
+ return new N(y(He), e, i);
858
+ const r = (await Promise.all(t.map(async (l) => {
859
+ if (await l._isAvailable())
860
+ return l;
861
+ }))).filter((l) => l);
862
+ let s = r[0] || y(He);
863
+ const o = K(i, e.config.apiKey, e.name);
864
+ let c = null;
865
+ for (const l of t)
866
+ try {
867
+ const d = await l._get(o);
868
+ if (d) {
869
+ let h;
870
+ if (typeof d == "string") {
871
+ const p = await Q(e, {
872
+ idToken: d
873
+ }).catch(() => {
874
+ });
875
+ if (!p)
876
+ break;
877
+ h = await g._fromGetAccountInfoResponse(e, p, d);
878
+ } else
879
+ h = g._fromJSON(e, d);
880
+ l !== s && (c = h), s = l;
881
+ break;
882
+ }
883
+ } catch {
884
+ }
885
+ const a = r.filter((l) => l._shouldAllowMigration);
886
+ return !s._shouldAllowMigration || !a.length ? new N(s, e, i) : (s = a[0], c && await s._set(o, c.toJSON()), await Promise.all(t.map(async (l) => {
887
+ if (l !== s)
888
+ try {
889
+ await l._remove(o);
890
+ } catch {
891
+ }
892
+ })), new N(s, e, i));
893
+ }
894
+ }
895
+ function $e(n) {
896
+ const e = n.toLowerCase();
897
+ if (e.includes("opera/") || e.includes("opr/") || e.includes("opios/"))
898
+ return "Opera";
899
+ if (gt(e))
900
+ return "IEMobile";
901
+ if (e.includes("msie") || e.includes("trident/"))
902
+ return "IE";
903
+ if (e.includes("edge/"))
904
+ return "Edge";
905
+ if (ht(e))
906
+ return "Firefox";
907
+ if (e.includes("silk/"))
908
+ return "Silk";
909
+ if (_t(e))
910
+ return "Blackberry";
911
+ if (vt(e))
912
+ return "Webos";
913
+ if (ft(e))
914
+ return "Safari";
915
+ if ((e.includes("chrome/") || pt(e)) && !e.includes("edge/"))
916
+ return "Chrome";
917
+ if (mt(e))
918
+ return "Android";
919
+ {
920
+ const t = /([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/, i = n.match(t);
921
+ if (i?.length === 2)
922
+ return i[1];
923
+ }
924
+ return "Other";
925
+ }
926
+ function ht(n = f()) {
927
+ return /firefox\//i.test(n);
928
+ }
929
+ function ft(n = f()) {
930
+ const e = n.toLowerCase();
931
+ return e.includes("safari/") && !e.includes("chrome/") && !e.includes("crios/") && !e.includes("android");
932
+ }
933
+ function pt(n = f()) {
934
+ return /crios\//i.test(n);
935
+ }
936
+ function gt(n = f()) {
937
+ return /iemobile/i.test(n);
938
+ }
939
+ function mt(n = f()) {
940
+ return /android/i.test(n);
941
+ }
942
+ function _t(n = f()) {
943
+ return /blackberry/i.test(n);
944
+ }
945
+ function vt(n = f()) {
946
+ return /webos/i.test(n);
947
+ }
948
+ function Se(n = f()) {
949
+ return /iphone|ipad|ipod/i.test(n) || /macintosh/i.test(n) && /mobile/i.test(n);
950
+ }
951
+ function mn(n = f()) {
952
+ var e;
953
+ return Se(n) && !!(!((e = window.navigator) === null || e === void 0) && e.standalone);
954
+ }
955
+ function _n() {
956
+ return $t() && document.documentMode === 10;
957
+ }
958
+ function It(n = f()) {
959
+ return Se(n) || mt(n) || vt(n) || _t(n) || /windows phone/i.test(n) || gt(n);
960
+ }
961
+ function wt(n, e = []) {
962
+ let t;
963
+ switch (n) {
964
+ case "Browser":
965
+ t = $e(f());
966
+ break;
967
+ case "Worker":
968
+ t = `${$e(f())}-${n}`;
969
+ break;
970
+ default:
971
+ t = n;
972
+ }
973
+ const i = e.length ? e.join(",") : "FirebaseCore-web";
974
+ return `${t}/JsCore/${W}/${i}`;
975
+ }
976
+ class vn {
977
+ constructor(e) {
978
+ this.auth = e, this.queue = [];
979
+ }
980
+ pushCallback(e, t) {
981
+ const i = (s) => new Promise((o, c) => {
982
+ try {
983
+ const a = e(s);
984
+ o(a);
985
+ } catch (a) {
986
+ c(a);
987
+ }
988
+ });
989
+ i.onAbort = t, this.queue.push(i);
990
+ const r = this.queue.length - 1;
991
+ return () => {
992
+ this.queue[r] = () => Promise.resolve();
993
+ };
994
+ }
995
+ async runMiddleware(e) {
996
+ if (this.auth.currentUser === e)
997
+ return;
998
+ const t = [];
999
+ try {
1000
+ for (const i of this.queue)
1001
+ await i(e), i.onAbort && t.push(i.onAbort);
1002
+ } catch (i) {
1003
+ t.reverse();
1004
+ for (const r of t)
1005
+ try {
1006
+ r();
1007
+ } catch {
1008
+ }
1009
+ throw this.auth._errorFactory.create("login-blocked", {
1010
+ originalMessage: i?.message
1011
+ });
1012
+ }
1013
+ }
1014
+ }
1015
+ async function In(n, e = {}) {
1016
+ return D(n, "GET", "/v2/passwordPolicy", Ee(n, e));
1017
+ }
1018
+ const wn = 6;
1019
+ class yn {
1020
+ constructor(e) {
1021
+ var t, i, r, s;
1022
+ const o = e.customStrengthOptions;
1023
+ this.customStrengthOptions = {}, this.customStrengthOptions.minPasswordLength = (t = o.minPasswordLength) !== null && t !== void 0 ? t : wn, o.maxPasswordLength && (this.customStrengthOptions.maxPasswordLength = o.maxPasswordLength), o.containsLowercaseCharacter !== void 0 && (this.customStrengthOptions.containsLowercaseLetter = o.containsLowercaseCharacter), o.containsUppercaseCharacter !== void 0 && (this.customStrengthOptions.containsUppercaseLetter = o.containsUppercaseCharacter), o.containsNumericCharacter !== void 0 && (this.customStrengthOptions.containsNumericCharacter = o.containsNumericCharacter), o.containsNonAlphanumericCharacter !== void 0 && (this.customStrengthOptions.containsNonAlphanumericCharacter = o.containsNonAlphanumericCharacter), this.enforcementState = e.enforcementState, this.enforcementState === "ENFORCEMENT_STATE_UNSPECIFIED" && (this.enforcementState = "OFF"), this.allowedNonAlphanumericCharacters = (r = (i = e.allowedNonAlphanumericCharacters) === null || i === void 0 ? void 0 : i.join("")) !== null && r !== void 0 ? r : "", this.forceUpgradeOnSignin = (s = e.forceUpgradeOnSignin) !== null && s !== void 0 ? s : !1, this.schemaVersion = e.schemaVersion;
1024
+ }
1025
+ validatePassword(e) {
1026
+ var t, i, r, s, o, c;
1027
+ const a = {
1028
+ isValid: !0,
1029
+ passwordPolicy: this
1030
+ };
1031
+ return this.validatePasswordLengthOptions(e, a), this.validatePasswordCharacterOptions(e, a), a.isValid && (a.isValid = (t = a.meetsMinPasswordLength) !== null && t !== void 0 ? t : !0), a.isValid && (a.isValid = (i = a.meetsMaxPasswordLength) !== null && i !== void 0 ? i : !0), a.isValid && (a.isValid = (r = a.containsLowercaseLetter) !== null && r !== void 0 ? r : !0), a.isValid && (a.isValid = (s = a.containsUppercaseLetter) !== null && s !== void 0 ? s : !0), a.isValid && (a.isValid = (o = a.containsNumericCharacter) !== null && o !== void 0 ? o : !0), a.isValid && (a.isValid = (c = a.containsNonAlphanumericCharacter) !== null && c !== void 0 ? c : !0), a;
1032
+ }
1033
+ /**
1034
+ * Validates that the password meets the length options for the policy.
1035
+ *
1036
+ * @param password Password to validate.
1037
+ * @param status Validation status.
1038
+ */
1039
+ validatePasswordLengthOptions(e, t) {
1040
+ const i = this.customStrengthOptions.minPasswordLength, r = this.customStrengthOptions.maxPasswordLength;
1041
+ i && (t.meetsMinPasswordLength = e.length >= i), r && (t.meetsMaxPasswordLength = e.length <= r);
1042
+ }
1043
+ /**
1044
+ * Validates that the password meets the character options for the policy.
1045
+ *
1046
+ * @param password Password to validate.
1047
+ * @param status Validation status.
1048
+ */
1049
+ validatePasswordCharacterOptions(e, t) {
1050
+ this.updatePasswordCharacterOptionsStatuses(
1051
+ t,
1052
+ /* containsLowercaseCharacter= */
1053
+ !1,
1054
+ /* containsUppercaseCharacter= */
1055
+ !1,
1056
+ /* containsNumericCharacter= */
1057
+ !1,
1058
+ /* containsNonAlphanumericCharacter= */
1059
+ !1
1060
+ );
1061
+ let i;
1062
+ for (let r = 0; r < e.length; r++)
1063
+ i = e.charAt(r), this.updatePasswordCharacterOptionsStatuses(
1064
+ t,
1065
+ /* containsLowercaseCharacter= */
1066
+ i >= "a" && i <= "z",
1067
+ /* containsUppercaseCharacter= */
1068
+ i >= "A" && i <= "Z",
1069
+ /* containsNumericCharacter= */
1070
+ i >= "0" && i <= "9",
1071
+ /* containsNonAlphanumericCharacter= */
1072
+ this.allowedNonAlphanumericCharacters.includes(i)
1073
+ );
1074
+ }
1075
+ /**
1076
+ * Updates the running validation status with the statuses for the character options.
1077
+ * Expected to be called each time a character is processed to update each option status
1078
+ * based on the current character.
1079
+ *
1080
+ * @param status Validation status.
1081
+ * @param containsLowercaseCharacter Whether the character is a lowercase letter.
1082
+ * @param containsUppercaseCharacter Whether the character is an uppercase letter.
1083
+ * @param containsNumericCharacter Whether the character is a numeric character.
1084
+ * @param containsNonAlphanumericCharacter Whether the character is a non-alphanumeric character.
1085
+ */
1086
+ updatePasswordCharacterOptionsStatuses(e, t, i, r, s) {
1087
+ this.customStrengthOptions.containsLowercaseLetter && (e.containsLowercaseLetter || (e.containsLowercaseLetter = t)), this.customStrengthOptions.containsUppercaseLetter && (e.containsUppercaseLetter || (e.containsUppercaseLetter = i)), this.customStrengthOptions.containsNumericCharacter && (e.containsNumericCharacter || (e.containsNumericCharacter = r)), this.customStrengthOptions.containsNonAlphanumericCharacter && (e.containsNonAlphanumericCharacter || (e.containsNonAlphanumericCharacter = s));
1088
+ }
1089
+ }
1090
+ class Tn {
1091
+ constructor(e, t, i, r) {
1092
+ 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 qe(this), this.idTokenSubscription = new qe(this), this.beforeStateQueue = new vn(this), this.redirectUser = null, this.isProactiveRefreshEnabled = !1, this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION = 1, this._canInitEmulator = !0, this._isInitialized = !1, this._deleted = !1, this._initializationPromise = null, this._popupRedirectResolver = null, this._errorFactory = ot, this._agentRecaptchaConfig = null, this._tenantRecaptchaConfigs = {}, this._projectPasswordPolicy = null, this._tenantPasswordPolicies = {}, this._resolvePersistenceManagerAvailable = void 0, this.lastNotifiedUid = void 0, this.languageCode = null, this.tenantId = null, this.settings = { appVerificationDisabledForTesting: !1 }, this.frameworks = [], this.name = e.name, this.clientVersion = r.sdkClientVersion, this._persistenceManagerAvailable = new Promise((s) => this._resolvePersistenceManagerAvailable = s);
1093
+ }
1094
+ _initializeWithPersistence(e, t) {
1095
+ return t && (this._popupRedirectResolver = y(t)), this._initializationPromise = this.queue(async () => {
1096
+ var i, r, s;
1097
+ if (!this._deleted && (this.persistenceManager = await N.create(this, e), (i = this._resolvePersistenceManagerAvailable) === null || i === void 0 || i.call(this), !this._deleted)) {
1098
+ if (!((r = this._popupRedirectResolver) === null || r === void 0) && r._shouldInitProactively)
1099
+ try {
1100
+ await this._popupRedirectResolver._initialize(this);
1101
+ } catch {
1102
+ }
1103
+ await this.initializeCurrentUser(t), this.lastNotifiedUid = ((s = this.currentUser) === null || s === void 0 ? void 0 : s.uid) || null, !this._deleted && (this._isInitialized = !0);
1104
+ }
1105
+ }), this._initializationPromise;
1106
+ }
1107
+ /**
1108
+ * If the persistence is changed in another window, the user manager will let us know
1109
+ */
1110
+ async _onStorageEvent() {
1111
+ if (this._deleted)
1112
+ return;
1113
+ const e = await this.assertedPersistence.getCurrentUser();
1114
+ if (!(!this.currentUser && !e)) {
1115
+ if (this.currentUser && e && this.currentUser.uid === e.uid) {
1116
+ this._currentUser._assign(e), await this.currentUser.getIdToken();
1117
+ return;
1118
+ }
1119
+ await this._updateCurrentUser(
1120
+ e,
1121
+ /* skipBeforeStateCallbacks */
1122
+ !0
1123
+ );
1124
+ }
1125
+ }
1126
+ async initializeCurrentUserFromIdToken(e) {
1127
+ try {
1128
+ const t = await Q(this, { idToken: e }), i = await g._fromGetAccountInfoResponse(this, t, e);
1129
+ await this.directlySetCurrentUser(i);
1130
+ } catch (t) {
1131
+ console.warn("FirebaseServerApp could not login user with provided authIdToken: ", t), await this.directlySetCurrentUser(null);
1132
+ }
1133
+ }
1134
+ async initializeCurrentUser(e) {
1135
+ var t;
1136
+ if (_(this.app)) {
1137
+ const o = this.app.settings.authIdToken;
1138
+ return o ? new Promise((c) => {
1139
+ setTimeout(() => this.initializeCurrentUserFromIdToken(o).then(c, c));
1140
+ }) : this.directlySetCurrentUser(null);
1141
+ }
1142
+ const i = await this.assertedPersistence.getCurrentUser();
1143
+ let r = i, s = !1;
1144
+ if (e && this.config.authDomain) {
1145
+ await this.getOrInitRedirectPersistenceManager();
1146
+ const o = (t = this.redirectUser) === null || t === void 0 ? void 0 : t._redirectEventId, c = r?._redirectEventId, a = await this.tryRedirectSignIn(e);
1147
+ (!o || o === c) && a?.user && (r = a.user, s = !0);
1148
+ }
1149
+ if (!r)
1150
+ return this.directlySetCurrentUser(null);
1151
+ if (!r._redirectEventId) {
1152
+ if (s)
1153
+ try {
1154
+ await this.beforeStateQueue.runMiddleware(r);
1155
+ } catch (o) {
1156
+ r = i, this._popupRedirectResolver._overrideRedirectResult(this, () => Promise.reject(o));
1157
+ }
1158
+ return r ? this.reloadAndSetCurrentUserOrClear(r) : this.directlySetCurrentUser(null);
1159
+ }
1160
+ return u(
1161
+ this._popupRedirectResolver,
1162
+ this,
1163
+ "argument-error"
1164
+ /* AuthErrorCode.ARGUMENT_ERROR */
1165
+ ), await this.getOrInitRedirectPersistenceManager(), this.redirectUser && this.redirectUser._redirectEventId === r._redirectEventId ? this.directlySetCurrentUser(r) : this.reloadAndSetCurrentUserOrClear(r);
1166
+ }
1167
+ async tryRedirectSignIn(e) {
1168
+ let t = null;
1169
+ try {
1170
+ t = await this._popupRedirectResolver._completeRedirectFn(this, e, !0);
1171
+ } catch {
1172
+ await this._setRedirectUser(null);
1173
+ }
1174
+ return t;
1175
+ }
1176
+ async reloadAndSetCurrentUserOrClear(e) {
1177
+ try {
1178
+ await Z(e);
1179
+ } catch (t) {
1180
+ if (t?.code !== "auth/network-request-failed")
1181
+ return this.directlySetCurrentUser(null);
1182
+ }
1183
+ return this.directlySetCurrentUser(e);
1184
+ }
1185
+ useDeviceLanguage() {
1186
+ this.languageCode = tn();
1187
+ }
1188
+ async _delete() {
1189
+ this._deleted = !0;
1190
+ }
1191
+ async updateCurrentUser(e) {
1192
+ if (_(this.app))
1193
+ return Promise.reject(A(this));
1194
+ const t = e ? M(e) : null;
1195
+ return t && u(
1196
+ t.auth.config.apiKey === this.config.apiKey,
1197
+ this,
1198
+ "invalid-user-token"
1199
+ /* AuthErrorCode.INVALID_AUTH */
1200
+ ), this._updateCurrentUser(t && t._clone(this));
1201
+ }
1202
+ async _updateCurrentUser(e, t = !1) {
1203
+ if (!this._deleted)
1204
+ return e && u(
1205
+ this.tenantId === e.tenantId,
1206
+ this,
1207
+ "tenant-id-mismatch"
1208
+ /* AuthErrorCode.TENANT_ID_MISMATCH */
1209
+ ), t || await this.beforeStateQueue.runMiddleware(e), this.queue(async () => {
1210
+ await this.directlySetCurrentUser(e), this.notifyAuthListeners();
1211
+ });
1212
+ }
1213
+ async signOut() {
1214
+ return _(this.app) ? Promise.reject(A(this)) : (await this.beforeStateQueue.runMiddleware(null), (this.redirectPersistenceManager || this._popupRedirectResolver) && await this._setRedirectUser(null), this._updateCurrentUser(
1215
+ null,
1216
+ /* skipBeforeStateCallbacks */
1217
+ !0
1218
+ ));
1219
+ }
1220
+ setPersistence(e) {
1221
+ return _(this.app) ? Promise.reject(A(this)) : this.queue(async () => {
1222
+ await this.assertedPersistence.setPersistence(y(e));
1223
+ });
1224
+ }
1225
+ _getRecaptchaConfig() {
1226
+ return this.tenantId == null ? this._agentRecaptchaConfig : this._tenantRecaptchaConfigs[this.tenantId];
1227
+ }
1228
+ async validatePassword(e) {
1229
+ this._getPasswordPolicyInternal() || await this._updatePasswordPolicy();
1230
+ const t = this._getPasswordPolicyInternal();
1231
+ return t.schemaVersion !== this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION ? Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version", {})) : t.validatePassword(e);
1232
+ }
1233
+ _getPasswordPolicyInternal() {
1234
+ return this.tenantId === null ? this._projectPasswordPolicy : this._tenantPasswordPolicies[this.tenantId];
1235
+ }
1236
+ async _updatePasswordPolicy() {
1237
+ const e = await In(this), t = new yn(e);
1238
+ this.tenantId === null ? this._projectPasswordPolicy = t : this._tenantPasswordPolicies[this.tenantId] = t;
1239
+ }
1240
+ _getPersistenceType() {
1241
+ return this.assertedPersistence.persistence.type;
1242
+ }
1243
+ _getPersistence() {
1244
+ return this.assertedPersistence.persistence;
1245
+ }
1246
+ _updateErrorMap(e) {
1247
+ this._errorFactory = new _e("auth", "Firebase", e());
1248
+ }
1249
+ onAuthStateChanged(e, t, i) {
1250
+ return this.registerStateListener(this.authStateSubscription, e, t, i);
1251
+ }
1252
+ beforeAuthStateChanged(e, t) {
1253
+ return this.beforeStateQueue.pushCallback(e, t);
1254
+ }
1255
+ onIdTokenChanged(e, t, i) {
1256
+ return this.registerStateListener(this.idTokenSubscription, e, t, i);
1257
+ }
1258
+ authStateReady() {
1259
+ return new Promise((e, t) => {
1260
+ if (this.currentUser)
1261
+ e();
1262
+ else {
1263
+ const i = this.onAuthStateChanged(() => {
1264
+ i(), e();
1265
+ }, t);
1266
+ }
1267
+ });
1268
+ }
1269
+ /**
1270
+ * Revokes the given access token. Currently only supports Apple OAuth access tokens.
1271
+ */
1272
+ async revokeAccessToken(e) {
1273
+ if (this.currentUser) {
1274
+ const t = await this.currentUser.getIdToken(), i = {
1275
+ providerId: "apple.com",
1276
+ tokenType: "ACCESS_TOKEN",
1277
+ token: e,
1278
+ idToken: t
1279
+ };
1280
+ this.tenantId != null && (i.tenantId = this.tenantId), await gn(this, i);
1281
+ }
1282
+ }
1283
+ toJSON() {
1284
+ var e;
1285
+ return {
1286
+ apiKey: this.config.apiKey,
1287
+ authDomain: this.config.authDomain,
1288
+ appName: this.name,
1289
+ currentUser: (e = this._currentUser) === null || e === void 0 ? void 0 : e.toJSON()
1290
+ };
1291
+ }
1292
+ async _setRedirectUser(e, t) {
1293
+ const i = await this.getOrInitRedirectPersistenceManager(t);
1294
+ return e === null ? i.removeCurrentUser() : i.setCurrentUser(e);
1295
+ }
1296
+ async getOrInitRedirectPersistenceManager(e) {
1297
+ if (!this.redirectPersistenceManager) {
1298
+ const t = e && y(e) || this._popupRedirectResolver;
1299
+ u(
1300
+ t,
1301
+ this,
1302
+ "argument-error"
1303
+ /* AuthErrorCode.ARGUMENT_ERROR */
1304
+ ), this.redirectPersistenceManager = await N.create(
1305
+ this,
1306
+ [y(t._redirectPersistence)],
1307
+ "redirectUser"
1308
+ /* KeyName.REDIRECT_USER */
1309
+ ), this.redirectUser = await this.redirectPersistenceManager.getCurrentUser();
1310
+ }
1311
+ return this.redirectPersistenceManager;
1312
+ }
1313
+ async _redirectUserForId(e) {
1314
+ var t, i;
1315
+ return this._isInitialized && await this.queue(async () => {
1316
+ }), ((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;
1317
+ }
1318
+ async _persistUserIfCurrent(e) {
1319
+ if (e === this.currentUser)
1320
+ return this.queue(async () => this.directlySetCurrentUser(e));
1321
+ }
1322
+ /** Notifies listeners only if the user is current */
1323
+ _notifyListenersIfCurrent(e) {
1324
+ e === this.currentUser && this.notifyAuthListeners();
1325
+ }
1326
+ _key() {
1327
+ return `${this.config.authDomain}:${this.config.apiKey}:${this.name}`;
1328
+ }
1329
+ _startProactiveRefresh() {
1330
+ this.isProactiveRefreshEnabled = !0, this.currentUser && this._currentUser._startProactiveRefresh();
1331
+ }
1332
+ _stopProactiveRefresh() {
1333
+ this.isProactiveRefreshEnabled = !1, this.currentUser && this._currentUser._stopProactiveRefresh();
1334
+ }
1335
+ /** Returns the current user cast as the internal type */
1336
+ get _currentUser() {
1337
+ return this.currentUser;
1338
+ }
1339
+ notifyAuthListeners() {
1340
+ var e, t;
1341
+ if (!this._isInitialized)
1342
+ return;
1343
+ this.idTokenSubscription.next(this.currentUser);
1344
+ const i = (t = (e = this.currentUser) === null || e === void 0 ? void 0 : e.uid) !== null && t !== void 0 ? t : null;
1345
+ this.lastNotifiedUid !== i && (this.lastNotifiedUid = i, this.authStateSubscription.next(this.currentUser));
1346
+ }
1347
+ registerStateListener(e, t, i, r) {
1348
+ if (this._deleted)
1349
+ return () => {
1350
+ };
1351
+ const s = typeof t == "function" ? t : t.next.bind(t);
1352
+ let o = !1;
1353
+ const c = this._isInitialized ? Promise.resolve() : this._initializationPromise;
1354
+ if (u(
1355
+ c,
1356
+ this,
1357
+ "internal-error"
1358
+ /* AuthErrorCode.INTERNAL_ERROR */
1359
+ ), c.then(() => {
1360
+ o || s(this.currentUser);
1361
+ }), typeof t == "function") {
1362
+ const a = e.addObserver(t, i, r);
1363
+ return () => {
1364
+ o = !0, a();
1365
+ };
1366
+ } else {
1367
+ const a = e.addObserver(t);
1368
+ return () => {
1369
+ o = !0, a();
1370
+ };
1371
+ }
1372
+ }
1373
+ /**
1374
+ * Unprotected (from race conditions) method to set the current user. This
1375
+ * should only be called from within a queued callback. This is necessary
1376
+ * because the queue shouldn't rely on another queued callback.
1377
+ */
1378
+ async directlySetCurrentUser(e) {
1379
+ 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();
1380
+ }
1381
+ queue(e) {
1382
+ return this.operations = this.operations.then(e, e), this.operations;
1383
+ }
1384
+ get assertedPersistence() {
1385
+ return u(
1386
+ this.persistenceManager,
1387
+ this,
1388
+ "internal-error"
1389
+ /* AuthErrorCode.INTERNAL_ERROR */
1390
+ ), this.persistenceManager;
1391
+ }
1392
+ _logFramework(e) {
1393
+ !e || this.frameworks.includes(e) || (this.frameworks.push(e), this.frameworks.sort(), this.clientVersion = wt(this.config.clientPlatform, this._getFrameworks()));
1394
+ }
1395
+ _getFrameworks() {
1396
+ return this.frameworks;
1397
+ }
1398
+ async _getAdditionalHeaders() {
1399
+ var e;
1400
+ const t = {
1401
+ "X-Client-Version": this.clientVersion
1402
+ };
1403
+ this.app.options.appId && (t[
1404
+ "X-Firebase-gmpid"
1405
+ /* HttpHeader.X_FIREBASE_GMPID */
1406
+ ] = this.app.options.appId);
1407
+ const i = await ((e = this.heartbeatServiceProvider.getImmediate({
1408
+ optional: !0
1409
+ })) === null || e === void 0 ? void 0 : e.getHeartbeatsHeader());
1410
+ i && (t[
1411
+ "X-Firebase-Client"
1412
+ /* HttpHeader.X_FIREBASE_CLIENT */
1413
+ ] = i);
1414
+ const r = await this._getAppCheckToken();
1415
+ return r && (t[
1416
+ "X-Firebase-AppCheck"
1417
+ /* HttpHeader.X_FIREBASE_APP_CHECK */
1418
+ ] = r), t;
1419
+ }
1420
+ async _getAppCheckToken() {
1421
+ var e;
1422
+ if (_(this.app) && this.app.settings.appCheckToken)
1423
+ return this.app.settings.appCheckToken;
1424
+ const t = await ((e = this.appCheckServiceProvider.getImmediate({ optional: !0 })) === null || e === void 0 ? void 0 : e.getToken());
1425
+ return t?.error && Yt(`Error while retrieving App Check token: ${t.error}`), t?.token;
1426
+ }
1427
+ }
1428
+ function ie(n) {
1429
+ return M(n);
1430
+ }
1431
+ class qe {
1432
+ constructor(e) {
1433
+ this.auth = e, this.observer = null, this.addObserver = Jt((t) => this.observer = t);
1434
+ }
1435
+ get next() {
1436
+ return u(
1437
+ this.observer,
1438
+ this.auth,
1439
+ "internal-error"
1440
+ /* AuthErrorCode.INTERNAL_ERROR */
1441
+ ), this.observer.next.bind(this.observer);
1442
+ }
1443
+ }
1444
+ let Pe = {
1445
+ async loadJS() {
1446
+ throw new Error("Unable to load external scripts");
1447
+ },
1448
+ recaptchaV2Script: "",
1449
+ recaptchaEnterpriseScript: "",
1450
+ gapiScript: ""
1451
+ };
1452
+ function En(n) {
1453
+ Pe = n;
1454
+ }
1455
+ function kn(n) {
1456
+ return Pe.loadJS(n);
1457
+ }
1458
+ function Sn() {
1459
+ return Pe.gapiScript;
1460
+ }
1461
+ function Pn(n) {
1462
+ return `__${n}${Math.floor(Math.random() * 1e6)}`;
1463
+ }
1464
+ function Rn(n, e) {
1465
+ const t = nt(n, "auth");
1466
+ if (t.isInitialized()) {
1467
+ const r = t.getImmediate(), s = t.getOptions();
1468
+ if (he(s, e ?? {}))
1469
+ return r;
1470
+ I(
1471
+ r,
1472
+ "already-initialized"
1473
+ /* AuthErrorCode.ALREADY_INITIALIZED */
1474
+ );
1475
+ }
1476
+ return t.initialize({ options: e });
1477
+ }
1478
+ function bn(n, e) {
1479
+ const t = e?.persistence || [], i = (Array.isArray(t) ? t : [t]).map(y);
1480
+ e?.errorMap && n._updateErrorMap(e.errorMap), n._initializeWithPersistence(i, e?.popupRedirectResolver);
1481
+ }
1482
+ function An(n, e, t) {
1483
+ const i = ie(n);
1484
+ u(
1485
+ /^https?:\/\//.test(e),
1486
+ i,
1487
+ "invalid-emulator-scheme"
1488
+ /* AuthErrorCode.INVALID_EMULATOR_SCHEME */
1489
+ );
1490
+ const r = !1, s = yt(e), { host: o, port: c } = Cn(e), a = c === null ? "" : `:${c}`, l = { url: `${s}//${o}${a}/` }, d = Object.freeze({
1491
+ host: o,
1492
+ port: c,
1493
+ protocol: s.replace(":", ""),
1494
+ options: Object.freeze({ disableWarnings: r })
1495
+ });
1496
+ if (!i._canInitEmulator) {
1497
+ u(
1498
+ i.config.emulator && i.emulatorConfig,
1499
+ i,
1500
+ "emulator-config-failed"
1501
+ /* AuthErrorCode.EMULATOR_CONFIG_FAILED */
1502
+ ), u(
1503
+ he(l, i.config.emulator) && he(d, i.emulatorConfig),
1504
+ i,
1505
+ "emulator-config-failed"
1506
+ /* AuthErrorCode.EMULATOR_CONFIG_FAILED */
1507
+ );
1508
+ return;
1509
+ }
1510
+ i.config.emulator = l, i.emulatorConfig = d, i.settings.appVerificationDisabledForTesting = !0, me(o) ? (Vt(`${s}//${o}${a}`), Wt("Auth", !0)) : On();
1511
+ }
1512
+ function yt(n) {
1513
+ const e = n.indexOf(":");
1514
+ return e < 0 ? "" : n.substr(0, e + 1);
1515
+ }
1516
+ function Cn(n) {
1517
+ const e = yt(n), t = /(\/\/)?([^?#/]+)/.exec(n.substr(e.length));
1518
+ if (!t)
1519
+ return { host: "", port: null };
1520
+ const i = t[2].split("@").pop() || "", r = /^(\[[^\]]+\])(:|$)/.exec(i);
1521
+ if (r) {
1522
+ const s = r[1];
1523
+ return { host: s, port: ze(i.substr(s.length + 1)) };
1524
+ } else {
1525
+ const [s, o] = i.split(":");
1526
+ return { host: s, port: ze(o) };
1527
+ }
1528
+ }
1529
+ function ze(n) {
1530
+ if (!n)
1531
+ return null;
1532
+ const e = Number(n);
1533
+ return isNaN(e) ? null : e;
1534
+ }
1535
+ function On() {
1536
+ function n() {
1537
+ const e = document.createElement("p"), t = e.style;
1538
+ 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);
1539
+ }
1540
+ 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());
1541
+ }
1542
+ class Tt {
1543
+ /** @internal */
1544
+ constructor(e, t) {
1545
+ this.providerId = e, this.signInMethod = t;
1546
+ }
1547
+ /**
1548
+ * Returns a JSON-serializable representation of this object.
1549
+ *
1550
+ * @returns a JSON-serializable representation of this object.
1551
+ */
1552
+ toJSON() {
1553
+ return w("not implemented");
1554
+ }
1555
+ /** @internal */
1556
+ _getIdTokenResponse(e) {
1557
+ return w("not implemented");
1558
+ }
1559
+ /** @internal */
1560
+ _linkToIdToken(e, t) {
1561
+ return w("not implemented");
1562
+ }
1563
+ /** @internal */
1564
+ _getReauthenticationResolver(e) {
1565
+ return w("not implemented");
1566
+ }
1567
+ }
1568
+ async function L(n, e) {
1569
+ return on(n, "POST", "/v1/accounts:signInWithIdp", Ee(n, e));
1570
+ }
1571
+ const Nn = "http://localhost";
1572
+ class C extends Tt {
1573
+ constructor() {
1574
+ super(...arguments), this.pendingToken = null;
1575
+ }
1576
+ /** @internal */
1577
+ static _fromParams(e) {
1578
+ const t = new C(e.providerId, e.signInMethod);
1579
+ 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(
1580
+ "argument-error"
1581
+ /* AuthErrorCode.ARGUMENT_ERROR */
1582
+ ), t;
1583
+ }
1584
+ /** {@inheritdoc AuthCredential.toJSON} */
1585
+ toJSON() {
1586
+ return {
1587
+ idToken: this.idToken,
1588
+ accessToken: this.accessToken,
1589
+ secret: this.secret,
1590
+ nonce: this.nonce,
1591
+ pendingToken: this.pendingToken,
1592
+ providerId: this.providerId,
1593
+ signInMethod: this.signInMethod
1594
+ };
1595
+ }
1596
+ /**
1597
+ * Static method to deserialize a JSON representation of an object into an
1598
+ * {@link AuthCredential}.
1599
+ *
1600
+ * @param json - Input can be either Object or the stringified representation of the object.
1601
+ * When string is provided, JSON.parse would be called first.
1602
+ *
1603
+ * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
1604
+ */
1605
+ static fromJSON(e) {
1606
+ const t = typeof e == "string" ? JSON.parse(e) : e, { providerId: i, signInMethod: r } = t, s = Ie(t, ["providerId", "signInMethod"]);
1607
+ if (!i || !r)
1608
+ return null;
1609
+ const o = new C(i, r);
1610
+ 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;
1611
+ }
1612
+ /** @internal */
1613
+ _getIdTokenResponse(e) {
1614
+ const t = this.buildRequest();
1615
+ return L(e, t);
1616
+ }
1617
+ /** @internal */
1618
+ _linkToIdToken(e, t) {
1619
+ const i = this.buildRequest();
1620
+ return i.idToken = t, L(e, i);
1621
+ }
1622
+ /** @internal */
1623
+ _getReauthenticationResolver(e) {
1624
+ const t = this.buildRequest();
1625
+ return t.autoCreate = !1, L(e, t);
1626
+ }
1627
+ buildRequest() {
1628
+ const e = {
1629
+ requestUri: Nn,
1630
+ returnSecureToken: !0
1631
+ };
1632
+ if (this.pendingToken)
1633
+ e.pendingToken = this.pendingToken;
1634
+ else {
1635
+ const t = {};
1636
+ 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 = V(t);
1637
+ }
1638
+ return e;
1639
+ }
1640
+ }
1641
+ class Re {
1642
+ /**
1643
+ * Constructor for generic OAuth providers.
1644
+ *
1645
+ * @param providerId - Provider for which credentials should be generated.
1646
+ */
1647
+ constructor(e) {
1648
+ this.providerId = e, this.defaultLanguageCode = null, this.customParameters = {};
1649
+ }
1650
+ /**
1651
+ * Set the language gode.
1652
+ *
1653
+ * @param languageCode - language code
1654
+ */
1655
+ setDefaultLanguage(e) {
1656
+ this.defaultLanguageCode = e;
1657
+ }
1658
+ /**
1659
+ * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
1660
+ * operations.
1661
+ *
1662
+ * @remarks
1663
+ * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
1664
+ * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
1665
+ *
1666
+ * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
1667
+ */
1668
+ setCustomParameters(e) {
1669
+ return this.customParameters = e, this;
1670
+ }
1671
+ /**
1672
+ * Retrieve the current list of {@link CustomParameters}.
1673
+ */
1674
+ getCustomParameters() {
1675
+ return this.customParameters;
1676
+ }
1677
+ }
1678
+ class H extends Re {
1679
+ constructor() {
1680
+ super(...arguments), this.scopes = [];
1681
+ }
1682
+ /**
1683
+ * Add an OAuth scope to the credential.
1684
+ *
1685
+ * @param scope - Provider OAuth scope to add.
1686
+ */
1687
+ addScope(e) {
1688
+ return this.scopes.includes(e) || this.scopes.push(e), this;
1689
+ }
1690
+ /**
1691
+ * Retrieve the current list of OAuth scopes.
1692
+ */
1693
+ getScopes() {
1694
+ return [...this.scopes];
1695
+ }
1696
+ }
1697
+ class k extends H {
1698
+ constructor() {
1699
+ super(
1700
+ "facebook.com"
1701
+ /* ProviderId.FACEBOOK */
1702
+ );
1703
+ }
1704
+ /**
1705
+ * Creates a credential for Facebook.
1706
+ *
1707
+ * @example
1708
+ * ```javascript
1709
+ * // `event` from the Facebook auth.authResponseChange callback.
1710
+ * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
1711
+ * const result = await signInWithCredential(credential);
1712
+ * ```
1713
+ *
1714
+ * @param accessToken - Facebook access token.
1715
+ */
1716
+ static credential(e) {
1717
+ return C._fromParams({
1718
+ providerId: k.PROVIDER_ID,
1719
+ signInMethod: k.FACEBOOK_SIGN_IN_METHOD,
1720
+ accessToken: e
1721
+ });
1722
+ }
1723
+ /**
1724
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1725
+ *
1726
+ * @param userCredential - The user credential.
1727
+ */
1728
+ static credentialFromResult(e) {
1729
+ return k.credentialFromTaggedObject(e);
1730
+ }
1731
+ /**
1732
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1733
+ * thrown during a sign-in, link, or reauthenticate operation.
1734
+ *
1735
+ * @param userCredential - The user credential.
1736
+ */
1737
+ static credentialFromError(e) {
1738
+ return k.credentialFromTaggedObject(e.customData || {});
1739
+ }
1740
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
1741
+ if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
1742
+ return null;
1743
+ try {
1744
+ return k.credential(e.oauthAccessToken);
1745
+ } catch {
1746
+ return null;
1747
+ }
1748
+ }
1749
+ }
1750
+ k.FACEBOOK_SIGN_IN_METHOD = "facebook.com";
1751
+ k.PROVIDER_ID = "facebook.com";
1752
+ class S extends H {
1753
+ constructor() {
1754
+ super(
1755
+ "google.com"
1756
+ /* ProviderId.GOOGLE */
1757
+ ), this.addScope("profile");
1758
+ }
1759
+ /**
1760
+ * Creates a credential for Google. At least one of ID token and access token is required.
1761
+ *
1762
+ * @example
1763
+ * ```javascript
1764
+ * // \`googleUser\` from the onsuccess Google Sign In callback.
1765
+ * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
1766
+ * const result = await signInWithCredential(credential);
1767
+ * ```
1768
+ *
1769
+ * @param idToken - Google ID token.
1770
+ * @param accessToken - Google access token.
1771
+ */
1772
+ static credential(e, t) {
1773
+ return C._fromParams({
1774
+ providerId: S.PROVIDER_ID,
1775
+ signInMethod: S.GOOGLE_SIGN_IN_METHOD,
1776
+ idToken: e,
1777
+ accessToken: t
1778
+ });
1779
+ }
1780
+ /**
1781
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1782
+ *
1783
+ * @param userCredential - The user credential.
1784
+ */
1785
+ static credentialFromResult(e) {
1786
+ return S.credentialFromTaggedObject(e);
1787
+ }
1788
+ /**
1789
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1790
+ * thrown during a sign-in, link, or reauthenticate operation.
1791
+ *
1792
+ * @param userCredential - The user credential.
1793
+ */
1794
+ static credentialFromError(e) {
1795
+ return S.credentialFromTaggedObject(e.customData || {});
1796
+ }
1797
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
1798
+ if (!e)
1799
+ return null;
1800
+ const { oauthIdToken: t, oauthAccessToken: i } = e;
1801
+ if (!t && !i)
1802
+ return null;
1803
+ try {
1804
+ return S.credential(t, i);
1805
+ } catch {
1806
+ return null;
1807
+ }
1808
+ }
1809
+ }
1810
+ S.GOOGLE_SIGN_IN_METHOD = "google.com";
1811
+ S.PROVIDER_ID = "google.com";
1812
+ class P extends H {
1813
+ constructor() {
1814
+ super(
1815
+ "github.com"
1816
+ /* ProviderId.GITHUB */
1817
+ );
1818
+ }
1819
+ /**
1820
+ * Creates a credential for GitHub.
1821
+ *
1822
+ * @param accessToken - GitHub access token.
1823
+ */
1824
+ static credential(e) {
1825
+ return C._fromParams({
1826
+ providerId: P.PROVIDER_ID,
1827
+ signInMethod: P.GITHUB_SIGN_IN_METHOD,
1828
+ accessToken: e
1829
+ });
1830
+ }
1831
+ /**
1832
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1833
+ *
1834
+ * @param userCredential - The user credential.
1835
+ */
1836
+ static credentialFromResult(e) {
1837
+ return P.credentialFromTaggedObject(e);
1838
+ }
1839
+ /**
1840
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1841
+ * thrown during a sign-in, link, or reauthenticate operation.
1842
+ *
1843
+ * @param userCredential - The user credential.
1844
+ */
1845
+ static credentialFromError(e) {
1846
+ return P.credentialFromTaggedObject(e.customData || {});
1847
+ }
1848
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
1849
+ if (!e || !("oauthAccessToken" in e) || !e.oauthAccessToken)
1850
+ return null;
1851
+ try {
1852
+ return P.credential(e.oauthAccessToken);
1853
+ } catch {
1854
+ return null;
1855
+ }
1856
+ }
1857
+ }
1858
+ P.GITHUB_SIGN_IN_METHOD = "github.com";
1859
+ P.PROVIDER_ID = "github.com";
1860
+ class R extends H {
1861
+ constructor() {
1862
+ super(
1863
+ "twitter.com"
1864
+ /* ProviderId.TWITTER */
1865
+ );
1866
+ }
1867
+ /**
1868
+ * Creates a credential for Twitter.
1869
+ *
1870
+ * @param token - Twitter access token.
1871
+ * @param secret - Twitter secret.
1872
+ */
1873
+ static credential(e, t) {
1874
+ return C._fromParams({
1875
+ providerId: R.PROVIDER_ID,
1876
+ signInMethod: R.TWITTER_SIGN_IN_METHOD,
1877
+ oauthToken: e,
1878
+ oauthTokenSecret: t
1879
+ });
1880
+ }
1881
+ /**
1882
+ * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1883
+ *
1884
+ * @param userCredential - The user credential.
1885
+ */
1886
+ static credentialFromResult(e) {
1887
+ return R.credentialFromTaggedObject(e);
1888
+ }
1889
+ /**
1890
+ * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1891
+ * thrown during a sign-in, link, or reauthenticate operation.
1892
+ *
1893
+ * @param userCredential - The user credential.
1894
+ */
1895
+ static credentialFromError(e) {
1896
+ return R.credentialFromTaggedObject(e.customData || {});
1897
+ }
1898
+ static credentialFromTaggedObject({ _tokenResponse: e }) {
1899
+ if (!e)
1900
+ return null;
1901
+ const { oauthAccessToken: t, oauthTokenSecret: i } = e;
1902
+ if (!t || !i)
1903
+ return null;
1904
+ try {
1905
+ return R.credential(t, i);
1906
+ } catch {
1907
+ return null;
1908
+ }
1909
+ }
1910
+ }
1911
+ R.TWITTER_SIGN_IN_METHOD = "twitter.com";
1912
+ R.PROVIDER_ID = "twitter.com";
1913
+ class U {
1914
+ constructor(e) {
1915
+ this.user = e.user, this.providerId = e.providerId, this._tokenResponse = e._tokenResponse, this.operationType = e.operationType;
1916
+ }
1917
+ static async _fromIdTokenResponse(e, t, i, r = !1) {
1918
+ const s = await g._fromIdTokenResponse(e, i, r), o = Ge(i);
1919
+ return new U({
1920
+ user: s,
1921
+ providerId: o,
1922
+ _tokenResponse: i,
1923
+ operationType: t
1924
+ });
1925
+ }
1926
+ static async _forOperation(e, t, i) {
1927
+ await e._updateTokensIfNecessary(
1928
+ i,
1929
+ /* reload */
1930
+ !0
1931
+ );
1932
+ const r = Ge(i);
1933
+ return new U({
1934
+ user: e,
1935
+ providerId: r,
1936
+ _tokenResponse: i,
1937
+ operationType: t
1938
+ });
1939
+ }
1940
+ }
1941
+ function Ge(n) {
1942
+ return n.providerId ? n.providerId : "phoneNumber" in n ? "phone" : null;
1943
+ }
1944
+ class ee extends ve {
1945
+ constructor(e, t, i, r) {
1946
+ var s;
1947
+ super(t.code, t.message), this.operationType = i, this.user = r, Object.setPrototypeOf(this, ee.prototype), this.customData = {
1948
+ appName: e.name,
1949
+ tenantId: (s = e.tenantId) !== null && s !== void 0 ? s : void 0,
1950
+ _serverResponse: t.customData._serverResponse,
1951
+ operationType: i
1952
+ };
1953
+ }
1954
+ static _fromErrorAndOperation(e, t, i, r) {
1955
+ return new ee(e, t, i, r);
1956
+ }
1957
+ }
1958
+ function Et(n, e, t, i) {
1959
+ return (e === "reauthenticate" ? t._getReauthenticationResolver(n) : t._getIdTokenResponse(n)).catch((s) => {
1960
+ throw s.code === "auth/multi-factor-auth-required" ? ee._fromErrorAndOperation(n, s, e, i) : s;
1961
+ });
1962
+ }
1963
+ async function Ln(n, e, t = !1) {
1964
+ const i = await F(n, e._linkToIdToken(n.auth, await n.getIdToken()), t);
1965
+ return U._forOperation(n, "link", i);
1966
+ }
1967
+ async function Un(n, e, t = !1) {
1968
+ const { auth: i } = n;
1969
+ if (_(i.app))
1970
+ return Promise.reject(A(i));
1971
+ const r = "reauthenticate";
1972
+ try {
1973
+ const s = await F(n, Et(i, r, e, n), t);
1974
+ u(
1975
+ s.idToken,
1976
+ i,
1977
+ "internal-error"
1978
+ /* AuthErrorCode.INTERNAL_ERROR */
1979
+ );
1980
+ const o = ke(s.idToken);
1981
+ u(
1982
+ o,
1983
+ i,
1984
+ "internal-error"
1985
+ /* AuthErrorCode.INTERNAL_ERROR */
1986
+ );
1987
+ const { sub: c } = o;
1988
+ return u(
1989
+ n.uid === c,
1990
+ i,
1991
+ "user-mismatch"
1992
+ /* AuthErrorCode.USER_MISMATCH */
1993
+ ), U._forOperation(n, r, s);
1994
+ } catch (s) {
1995
+ throw s?.code === "auth/user-not-found" && I(
1996
+ i,
1997
+ "user-mismatch"
1998
+ /* AuthErrorCode.USER_MISMATCH */
1999
+ ), s;
2000
+ }
2001
+ }
2002
+ async function Mn(n, e, t = !1) {
2003
+ if (_(n.app))
2004
+ return Promise.reject(A(n));
2005
+ const i = "signIn", r = await Et(n, i, e), s = await U._fromIdTokenResponse(n, i, r);
2006
+ return t || await n._updateCurrentUser(s.user), s;
2007
+ }
2008
+ function Dn(n, e, t, i) {
2009
+ return M(n).onIdTokenChanged(e, t, i);
2010
+ }
2011
+ function xn(n, e, t) {
2012
+ return M(n).beforeAuthStateChanged(e, t);
2013
+ }
2014
+ const te = "__sak";
2015
+ class kt {
2016
+ constructor(e, t) {
2017
+ this.storageRetriever = e, this.type = t;
2018
+ }
2019
+ _isAvailable() {
2020
+ try {
2021
+ return this.storage ? (this.storage.setItem(te, "1"), this.storage.removeItem(te), Promise.resolve(!0)) : Promise.resolve(!1);
2022
+ } catch {
2023
+ return Promise.resolve(!1);
2024
+ }
2025
+ }
2026
+ _set(e, t) {
2027
+ return this.storage.setItem(e, JSON.stringify(t)), Promise.resolve();
2028
+ }
2029
+ _get(e) {
2030
+ const t = this.storage.getItem(e);
2031
+ return Promise.resolve(t ? JSON.parse(t) : null);
2032
+ }
2033
+ _remove(e) {
2034
+ return this.storage.removeItem(e), Promise.resolve();
2035
+ }
2036
+ get storage() {
2037
+ return this.storageRetriever();
2038
+ }
2039
+ }
2040
+ const Fn = 1e3, Vn = 10;
2041
+ class St extends kt {
2042
+ constructor() {
2043
+ super(
2044
+ () => window.localStorage,
2045
+ "LOCAL"
2046
+ /* PersistenceType.LOCAL */
2047
+ ), this.boundEventHandler = (e, t) => this.onStorageEvent(e, t), this.listeners = {}, this.localCache = {}, this.pollTimer = null, this.fallbackToPolling = It(), this._shouldAllowMigration = !0;
2048
+ }
2049
+ forAllChangedKeys(e) {
2050
+ for (const t of Object.keys(this.listeners)) {
2051
+ const i = this.storage.getItem(t), r = this.localCache[t];
2052
+ i !== r && e(t, r, i);
2053
+ }
2054
+ }
2055
+ onStorageEvent(e, t = !1) {
2056
+ if (!e.key) {
2057
+ this.forAllChangedKeys((o, c, a) => {
2058
+ this.notifyListeners(o, a);
2059
+ });
2060
+ return;
2061
+ }
2062
+ const i = e.key;
2063
+ t ? this.detachListener() : this.stopPolling();
2064
+ const r = () => {
2065
+ const o = this.storage.getItem(i);
2066
+ !t && this.localCache[i] === o || this.notifyListeners(i, o);
2067
+ }, s = this.storage.getItem(i);
2068
+ _n() && s !== e.newValue && e.newValue !== e.oldValue ? setTimeout(r, Vn) : r();
2069
+ }
2070
+ notifyListeners(e, t) {
2071
+ this.localCache[e] = t;
2072
+ const i = this.listeners[e];
2073
+ if (i)
2074
+ for (const r of Array.from(i))
2075
+ r(t && JSON.parse(t));
2076
+ }
2077
+ startPolling() {
2078
+ this.stopPolling(), this.pollTimer = setInterval(() => {
2079
+ this.forAllChangedKeys((e, t, i) => {
2080
+ this.onStorageEvent(
2081
+ new StorageEvent("storage", {
2082
+ key: e,
2083
+ oldValue: t,
2084
+ newValue: i
2085
+ }),
2086
+ /* poll */
2087
+ !0
2088
+ );
2089
+ });
2090
+ }, Fn);
2091
+ }
2092
+ stopPolling() {
2093
+ this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
2094
+ }
2095
+ attachListener() {
2096
+ window.addEventListener("storage", this.boundEventHandler);
2097
+ }
2098
+ detachListener() {
2099
+ window.removeEventListener("storage", this.boundEventHandler);
2100
+ }
2101
+ _addListener(e, t) {
2102
+ 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);
2103
+ }
2104
+ _removeListener(e, t) {
2105
+ 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());
2106
+ }
2107
+ // Update local cache on base operations:
2108
+ async _set(e, t) {
2109
+ await super._set(e, t), this.localCache[e] = JSON.stringify(t);
2110
+ }
2111
+ async _get(e) {
2112
+ const t = await super._get(e);
2113
+ return this.localCache[e] = JSON.stringify(t), t;
2114
+ }
2115
+ async _remove(e) {
2116
+ await super._remove(e), delete this.localCache[e];
2117
+ }
2118
+ }
2119
+ St.type = "LOCAL";
2120
+ const Wn = St;
2121
+ class Pt extends kt {
2122
+ constructor() {
2123
+ super(
2124
+ () => window.sessionStorage,
2125
+ "SESSION"
2126
+ /* PersistenceType.SESSION */
2127
+ );
2128
+ }
2129
+ _addListener(e, t) {
2130
+ }
2131
+ _removeListener(e, t) {
2132
+ }
2133
+ }
2134
+ Pt.type = "SESSION";
2135
+ const Rt = Pt;
2136
+ function jn(n) {
2137
+ return Promise.all(n.map(async (e) => {
2138
+ try {
2139
+ return {
2140
+ fulfilled: !0,
2141
+ value: await e
2142
+ };
2143
+ } catch (t) {
2144
+ return {
2145
+ fulfilled: !1,
2146
+ reason: t
2147
+ };
2148
+ }
2149
+ }));
2150
+ }
2151
+ class re {
2152
+ constructor(e) {
2153
+ this.eventTarget = e, this.handlersMap = {}, this.boundEventHandler = this.handleEvent.bind(this);
2154
+ }
2155
+ /**
2156
+ * Obtain an instance of a Receiver for a given event target, if none exists it will be created.
2157
+ *
2158
+ * @param eventTarget - An event target (such as window or self) through which the underlying
2159
+ * messages will be received.
2160
+ */
2161
+ static _getInstance(e) {
2162
+ const t = this.receivers.find((r) => r.isListeningto(e));
2163
+ if (t)
2164
+ return t;
2165
+ const i = new re(e);
2166
+ return this.receivers.push(i), i;
2167
+ }
2168
+ isListeningto(e) {
2169
+ return this.eventTarget === e;
2170
+ }
2171
+ /**
2172
+ * Fans out a MessageEvent to the appropriate listeners.
2173
+ *
2174
+ * @remarks
2175
+ * Sends an {@link Status.ACK} upon receipt and a {@link Status.DONE} once all handlers have
2176
+ * finished processing.
2177
+ *
2178
+ * @param event - The MessageEvent.
2179
+ *
2180
+ */
2181
+ async handleEvent(e) {
2182
+ const t = e, { eventId: i, eventType: r, data: s } = t.data, o = this.handlersMap[r];
2183
+ if (!o?.size)
2184
+ return;
2185
+ t.ports[0].postMessage({
2186
+ status: "ack",
2187
+ eventId: i,
2188
+ eventType: r
2189
+ });
2190
+ const c = Array.from(o).map(async (l) => l(t.origin, s)), a = await jn(c);
2191
+ t.ports[0].postMessage({
2192
+ status: "done",
2193
+ eventId: i,
2194
+ eventType: r,
2195
+ response: a
2196
+ });
2197
+ }
2198
+ /**
2199
+ * Subscribe an event handler for a particular event.
2200
+ *
2201
+ * @param eventType - Event name to subscribe to.
2202
+ * @param eventHandler - The event handler which should receive the events.
2203
+ *
2204
+ */
2205
+ _subscribe(e, t) {
2206
+ 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);
2207
+ }
2208
+ /**
2209
+ * Unsubscribe an event handler from a particular event.
2210
+ *
2211
+ * @param eventType - Event name to unsubscribe from.
2212
+ * @param eventHandler - Optional event handler, if none provided, unsubscribe all handlers on this event.
2213
+ *
2214
+ */
2215
+ _unsubscribe(e, t) {
2216
+ 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);
2217
+ }
2218
+ }
2219
+ re.receivers = [];
2220
+ function be(n = "", e = 10) {
2221
+ let t = "";
2222
+ for (let i = 0; i < e; i++)
2223
+ t += Math.floor(Math.random() * 10);
2224
+ return n + t;
2225
+ }
2226
+ class Hn {
2227
+ constructor(e) {
2228
+ this.target = e, this.handlers = /* @__PURE__ */ new Set();
2229
+ }
2230
+ /**
2231
+ * Unsubscribe the handler and remove it from our tracking Set.
2232
+ *
2233
+ * @param handler - The handler to unsubscribe.
2234
+ */
2235
+ removeMessageHandler(e) {
2236
+ e.messageChannel && (e.messageChannel.port1.removeEventListener("message", e.onMessage), e.messageChannel.port1.close()), this.handlers.delete(e);
2237
+ }
2238
+ /**
2239
+ * Send a message to the Receiver located at {@link target}.
2240
+ *
2241
+ * @remarks
2242
+ * We'll first wait a bit for an ACK , if we get one we will wait significantly longer until the
2243
+ * receiver has had a chance to fully process the event.
2244
+ *
2245
+ * @param eventType - Type of event to send.
2246
+ * @param data - The payload of the event.
2247
+ * @param timeout - Timeout for waiting on an ACK from the receiver.
2248
+ *
2249
+ * @returns An array of settled promises from all the handlers that were listening on the receiver.
2250
+ */
2251
+ async _send(e, t, i = 50) {
2252
+ const r = typeof MessageChannel < "u" ? new MessageChannel() : null;
2253
+ if (!r)
2254
+ throw new Error(
2255
+ "connection_unavailable"
2256
+ /* _MessageError.CONNECTION_UNAVAILABLE */
2257
+ );
2258
+ let s, o;
2259
+ return new Promise((c, a) => {
2260
+ const l = be("", 20);
2261
+ r.port1.start();
2262
+ const d = setTimeout(() => {
2263
+ a(new Error(
2264
+ "unsupported_event"
2265
+ /* _MessageError.UNSUPPORTED_EVENT */
2266
+ ));
2267
+ }, i);
2268
+ o = {
2269
+ messageChannel: r,
2270
+ onMessage(h) {
2271
+ const p = h;
2272
+ if (p.data.eventId === l)
2273
+ switch (p.data.status) {
2274
+ case "ack":
2275
+ clearTimeout(d), s = setTimeout(
2276
+ () => {
2277
+ a(new Error(
2278
+ "timeout"
2279
+ /* _MessageError.TIMEOUT */
2280
+ ));
2281
+ },
2282
+ 3e3
2283
+ /* _TimeoutDuration.COMPLETION */
2284
+ );
2285
+ break;
2286
+ case "done":
2287
+ clearTimeout(s), c(p.data.response);
2288
+ break;
2289
+ default:
2290
+ clearTimeout(d), clearTimeout(s), a(new Error(
2291
+ "invalid_response"
2292
+ /* _MessageError.INVALID_RESPONSE */
2293
+ ));
2294
+ break;
2295
+ }
2296
+ }
2297
+ }, this.handlers.add(o), r.port1.addEventListener("message", o.onMessage), this.target.postMessage({
2298
+ eventType: e,
2299
+ eventId: l,
2300
+ data: t
2301
+ }, [r.port2]);
2302
+ }).finally(() => {
2303
+ o && this.removeMessageHandler(o);
2304
+ });
2305
+ }
2306
+ }
2307
+ function v() {
2308
+ return window;
2309
+ }
2310
+ function $n(n) {
2311
+ v().location.href = n;
2312
+ }
2313
+ function bt() {
2314
+ return typeof v().WorkerGlobalScope < "u" && typeof v().importScripts == "function";
2315
+ }
2316
+ async function qn() {
2317
+ if (!navigator?.serviceWorker)
2318
+ return null;
2319
+ try {
2320
+ return (await navigator.serviceWorker.ready).active;
2321
+ } catch {
2322
+ return null;
2323
+ }
2324
+ }
2325
+ function zn() {
2326
+ var n;
2327
+ return ((n = navigator?.serviceWorker) === null || n === void 0 ? void 0 : n.controller) || null;
2328
+ }
2329
+ function Gn() {
2330
+ return bt() ? self : null;
2331
+ }
2332
+ const At = "firebaseLocalStorageDb", Bn = 1, ne = "firebaseLocalStorage", Ct = "fbase_key";
2333
+ class $ {
2334
+ constructor(e) {
2335
+ this.request = e;
2336
+ }
2337
+ toPromise() {
2338
+ return new Promise((e, t) => {
2339
+ this.request.addEventListener("success", () => {
2340
+ e(this.request.result);
2341
+ }), this.request.addEventListener("error", () => {
2342
+ t(this.request.error);
2343
+ });
2344
+ });
2345
+ }
2346
+ }
2347
+ function se(n, e) {
2348
+ return n.transaction([ne], e ? "readwrite" : "readonly").objectStore(ne);
2349
+ }
2350
+ function Kn() {
2351
+ const n = indexedDB.deleteDatabase(At);
2352
+ return new $(n).toPromise();
2353
+ }
2354
+ function ge() {
2355
+ const n = indexedDB.open(At, Bn);
2356
+ return new Promise((e, t) => {
2357
+ n.addEventListener("error", () => {
2358
+ t(n.error);
2359
+ }), n.addEventListener("upgradeneeded", () => {
2360
+ const i = n.result;
2361
+ try {
2362
+ i.createObjectStore(ne, { keyPath: Ct });
2363
+ } catch (r) {
2364
+ t(r);
2365
+ }
2366
+ }), n.addEventListener("success", async () => {
2367
+ const i = n.result;
2368
+ i.objectStoreNames.contains(ne) ? e(i) : (i.close(), await Kn(), e(await ge()));
2369
+ });
2370
+ });
2371
+ }
2372
+ async function Be(n, e, t) {
2373
+ const i = se(n, !0).put({
2374
+ [Ct]: e,
2375
+ value: t
2376
+ });
2377
+ return new $(i).toPromise();
2378
+ }
2379
+ async function Jn(n, e) {
2380
+ const t = se(n, !1).get(e), i = await new $(t).toPromise();
2381
+ return i === void 0 ? null : i.value;
2382
+ }
2383
+ function Ke(n, e) {
2384
+ const t = se(n, !0).delete(e);
2385
+ return new $(t).toPromise();
2386
+ }
2387
+ const Xn = 800, Yn = 3;
2388
+ class Ot {
2389
+ constructor() {
2390
+ 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(() => {
2391
+ }, () => {
2392
+ });
2393
+ }
2394
+ async _openDb() {
2395
+ return this.db ? this.db : (this.db = await ge(), this.db);
2396
+ }
2397
+ async _withRetries(e) {
2398
+ let t = 0;
2399
+ for (; ; )
2400
+ try {
2401
+ const i = await this._openDb();
2402
+ return await e(i);
2403
+ } catch (i) {
2404
+ if (t++ > Yn)
2405
+ throw i;
2406
+ this.db && (this.db.close(), this.db = void 0);
2407
+ }
2408
+ }
2409
+ /**
2410
+ * IndexedDB events do not propagate from the main window to the worker context. We rely on a
2411
+ * postMessage interface to send these events to the worker ourselves.
2412
+ */
2413
+ async initializeServiceWorkerMessaging() {
2414
+ return bt() ? this.initializeReceiver() : this.initializeSender();
2415
+ }
2416
+ /**
2417
+ * As the worker we should listen to events from the main window.
2418
+ */
2419
+ async initializeReceiver() {
2420
+ this.receiver = re._getInstance(Gn()), this.receiver._subscribe("keyChanged", async (e, t) => ({
2421
+ keyProcessed: (await this._poll()).includes(t.key)
2422
+ })), this.receiver._subscribe("ping", async (e, t) => [
2423
+ "keyChanged"
2424
+ /* _EventType.KEY_CHANGED */
2425
+ ]);
2426
+ }
2427
+ /**
2428
+ * As the main window, we should let the worker know when keys change (set and remove).
2429
+ *
2430
+ * @remarks
2431
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/ready | ServiceWorkerContainer.ready}
2432
+ * may not resolve.
2433
+ */
2434
+ async initializeSender() {
2435
+ var e, t;
2436
+ if (this.activeServiceWorker = await qn(), !this.activeServiceWorker)
2437
+ return;
2438
+ this.sender = new Hn(this.activeServiceWorker);
2439
+ const i = await this.sender._send(
2440
+ "ping",
2441
+ {},
2442
+ 800
2443
+ /* _TimeoutDuration.LONG_ACK */
2444
+ );
2445
+ i && !((e = i[0]) === null || e === void 0) && e.fulfilled && !((t = i[0]) === null || t === void 0) && t.value.includes(
2446
+ "keyChanged"
2447
+ /* _EventType.KEY_CHANGED */
2448
+ ) && (this.serviceWorkerReceiverAvailable = !0);
2449
+ }
2450
+ /**
2451
+ * Let the worker know about a changed key, the exact key doesn't technically matter since the
2452
+ * worker will just trigger a full sync anyway.
2453
+ *
2454
+ * @remarks
2455
+ * For now, we only support one service worker per page.
2456
+ *
2457
+ * @param key - Storage key which changed.
2458
+ */
2459
+ async notifyServiceWorker(e) {
2460
+ if (!(!this.sender || !this.activeServiceWorker || zn() !== this.activeServiceWorker))
2461
+ try {
2462
+ await this.sender._send(
2463
+ "keyChanged",
2464
+ { key: e },
2465
+ // Use long timeout if receiver has previously responded to a ping from us.
2466
+ this.serviceWorkerReceiverAvailable ? 800 : 50
2467
+ /* _TimeoutDuration.ACK */
2468
+ );
2469
+ } catch {
2470
+ }
2471
+ }
2472
+ async _isAvailable() {
2473
+ try {
2474
+ if (!indexedDB)
2475
+ return !1;
2476
+ const e = await ge();
2477
+ return await Be(e, te, "1"), await Ke(e, te), !0;
2478
+ } catch {
2479
+ }
2480
+ return !1;
2481
+ }
2482
+ async _withPendingWrite(e) {
2483
+ this.pendingWrites++;
2484
+ try {
2485
+ await e();
2486
+ } finally {
2487
+ this.pendingWrites--;
2488
+ }
2489
+ }
2490
+ async _set(e, t) {
2491
+ return this._withPendingWrite(async () => (await this._withRetries((i) => Be(i, e, t)), this.localCache[e] = t, this.notifyServiceWorker(e)));
2492
+ }
2493
+ async _get(e) {
2494
+ const t = await this._withRetries((i) => Jn(i, e));
2495
+ return this.localCache[e] = t, t;
2496
+ }
2497
+ async _remove(e) {
2498
+ return this._withPendingWrite(async () => (await this._withRetries((t) => Ke(t, e)), delete this.localCache[e], this.notifyServiceWorker(e)));
2499
+ }
2500
+ async _poll() {
2501
+ const e = await this._withRetries((r) => {
2502
+ const s = se(r, !1).getAll();
2503
+ return new $(s).toPromise();
2504
+ });
2505
+ if (!e)
2506
+ return [];
2507
+ if (this.pendingWrites !== 0)
2508
+ return [];
2509
+ const t = [], i = /* @__PURE__ */ new Set();
2510
+ if (e.length !== 0)
2511
+ for (const { fbase_key: r, value: s } of e)
2512
+ i.add(r), JSON.stringify(this.localCache[r]) !== JSON.stringify(s) && (this.notifyListeners(r, s), t.push(r));
2513
+ for (const r of Object.keys(this.localCache))
2514
+ this.localCache[r] && !i.has(r) && (this.notifyListeners(r, null), t.push(r));
2515
+ return t;
2516
+ }
2517
+ notifyListeners(e, t) {
2518
+ this.localCache[e] = t;
2519
+ const i = this.listeners[e];
2520
+ if (i)
2521
+ for (const r of Array.from(i))
2522
+ r(t);
2523
+ }
2524
+ startPolling() {
2525
+ this.stopPolling(), this.pollTimer = setInterval(async () => this._poll(), Xn);
2526
+ }
2527
+ stopPolling() {
2528
+ this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null);
2529
+ }
2530
+ _addListener(e, t) {
2531
+ 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);
2532
+ }
2533
+ _removeListener(e, t) {
2534
+ 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();
2535
+ }
2536
+ }
2537
+ Ot.type = "LOCAL";
2538
+ const Qn = Ot;
2539
+ new j(3e4, 6e4);
2540
+ function Nt(n, e) {
2541
+ return e ? y(e) : (u(
2542
+ n._popupRedirectResolver,
2543
+ n,
2544
+ "argument-error"
2545
+ /* AuthErrorCode.ARGUMENT_ERROR */
2546
+ ), n._popupRedirectResolver);
2547
+ }
2548
+ class Ae extends Tt {
2549
+ constructor(e) {
2550
+ super(
2551
+ "custom",
2552
+ "custom"
2553
+ /* ProviderId.CUSTOM */
2554
+ ), this.params = e;
2555
+ }
2556
+ _getIdTokenResponse(e) {
2557
+ return L(e, this._buildIdpRequest());
2558
+ }
2559
+ _linkToIdToken(e, t) {
2560
+ return L(e, this._buildIdpRequest(t));
2561
+ }
2562
+ _getReauthenticationResolver(e) {
2563
+ return L(e, this._buildIdpRequest());
2564
+ }
2565
+ _buildIdpRequest(e) {
2566
+ const t = {
2567
+ requestUri: this.params.requestUri,
2568
+ sessionId: this.params.sessionId,
2569
+ postBody: this.params.postBody,
2570
+ tenantId: this.params.tenantId,
2571
+ pendingToken: this.params.pendingToken,
2572
+ returnSecureToken: !0,
2573
+ returnIdpCredential: !0
2574
+ };
2575
+ return e && (t.idToken = e), t;
2576
+ }
2577
+ }
2578
+ function Zn(n) {
2579
+ return Mn(n.auth, new Ae(n), n.bypassAuthState);
2580
+ }
2581
+ function ei(n) {
2582
+ const { auth: e, user: t } = n;
2583
+ return u(
2584
+ t,
2585
+ e,
2586
+ "internal-error"
2587
+ /* AuthErrorCode.INTERNAL_ERROR */
2588
+ ), Un(t, new Ae(n), n.bypassAuthState);
2589
+ }
2590
+ async function ti(n) {
2591
+ const { auth: e, user: t } = n;
2592
+ return u(
2593
+ t,
2594
+ e,
2595
+ "internal-error"
2596
+ /* AuthErrorCode.INTERNAL_ERROR */
2597
+ ), Ln(t, new Ae(n), n.bypassAuthState);
2598
+ }
2599
+ class Lt {
2600
+ constructor(e, t, i, r, s = !1) {
2601
+ 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];
2602
+ }
2603
+ execute() {
2604
+ return new Promise(async (e, t) => {
2605
+ this.pendingPromise = { resolve: e, reject: t };
2606
+ try {
2607
+ this.eventManager = await this.resolver._initialize(this.auth), await this.onExecution(), this.eventManager.registerConsumer(this);
2608
+ } catch (i) {
2609
+ this.reject(i);
2610
+ }
2611
+ });
2612
+ }
2613
+ async onAuthEvent(e) {
2614
+ const { urlResponse: t, sessionId: i, postBody: r, tenantId: s, error: o, type: c } = e;
2615
+ if (o) {
2616
+ this.reject(o);
2617
+ return;
2618
+ }
2619
+ const a = {
2620
+ auth: this.auth,
2621
+ requestUri: t,
2622
+ sessionId: i,
2623
+ tenantId: s || void 0,
2624
+ postBody: r || void 0,
2625
+ user: this.user,
2626
+ bypassAuthState: this.bypassAuthState
2627
+ };
2628
+ try {
2629
+ this.resolve(await this.getIdpTask(c)(a));
2630
+ } catch (l) {
2631
+ this.reject(l);
2632
+ }
2633
+ }
2634
+ onError(e) {
2635
+ this.reject(e);
2636
+ }
2637
+ getIdpTask(e) {
2638
+ switch (e) {
2639
+ case "signInViaPopup":
2640
+ case "signInViaRedirect":
2641
+ return Zn;
2642
+ case "linkViaPopup":
2643
+ case "linkViaRedirect":
2644
+ return ti;
2645
+ case "reauthViaPopup":
2646
+ case "reauthViaRedirect":
2647
+ return ei;
2648
+ default:
2649
+ I(
2650
+ this.auth,
2651
+ "internal-error"
2652
+ /* AuthErrorCode.INTERNAL_ERROR */
2653
+ );
2654
+ }
2655
+ }
2656
+ resolve(e) {
2657
+ T(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.resolve(e), this.unregisterAndCleanUp();
2658
+ }
2659
+ reject(e) {
2660
+ T(this.pendingPromise, "Pending promise was never set"), this.pendingPromise.reject(e), this.unregisterAndCleanUp();
2661
+ }
2662
+ unregisterAndCleanUp() {
2663
+ this.eventManager && this.eventManager.unregisterConsumer(this), this.pendingPromise = null, this.cleanUp();
2664
+ }
2665
+ }
2666
+ const ni = new j(2e3, 1e4);
2667
+ async function Ji(n, e, t) {
2668
+ if (_(n.app))
2669
+ return Promise.reject(m(
2670
+ n,
2671
+ "operation-not-supported-in-this-environment"
2672
+ /* AuthErrorCode.OPERATION_NOT_SUPPORTED */
2673
+ ));
2674
+ const i = ie(n);
2675
+ Qt(n, e, Re);
2676
+ const r = Nt(i, t);
2677
+ return new b(i, "signInViaPopup", e, r).executeNotNull();
2678
+ }
2679
+ class b extends Lt {
2680
+ constructor(e, t, i, r, s) {
2681
+ super(e, t, r, s), this.provider = i, this.authWindow = null, this.pollId = null, b.currentPopupAction && b.currentPopupAction.cancel(), b.currentPopupAction = this;
2682
+ }
2683
+ async executeNotNull() {
2684
+ const e = await this.execute();
2685
+ return u(
2686
+ e,
2687
+ this.auth,
2688
+ "internal-error"
2689
+ /* AuthErrorCode.INTERNAL_ERROR */
2690
+ ), e;
2691
+ }
2692
+ async onExecution() {
2693
+ T(this.filter.length === 1, "Popup operations only handle one event");
2694
+ const e = be();
2695
+ this.authWindow = await this.resolver._openPopup(
2696
+ this.auth,
2697
+ this.provider,
2698
+ this.filter[0],
2699
+ // There's always one, see constructor
2700
+ e
2701
+ ), this.authWindow.associatedEvent = e, this.resolver._originValidation(this.auth).catch((t) => {
2702
+ this.reject(t);
2703
+ }), this.resolver._isIframeWebStorageSupported(this.auth, (t) => {
2704
+ t || this.reject(m(
2705
+ this.auth,
2706
+ "web-storage-unsupported"
2707
+ /* AuthErrorCode.WEB_STORAGE_UNSUPPORTED */
2708
+ ));
2709
+ }), this.pollUserCancellation();
2710
+ }
2711
+ get eventId() {
2712
+ var e;
2713
+ return ((e = this.authWindow) === null || e === void 0 ? void 0 : e.associatedEvent) || null;
2714
+ }
2715
+ cancel() {
2716
+ this.reject(m(
2717
+ this.auth,
2718
+ "cancelled-popup-request"
2719
+ /* AuthErrorCode.EXPIRED_POPUP_REQUEST */
2720
+ ));
2721
+ }
2722
+ cleanUp() {
2723
+ this.authWindow && this.authWindow.close(), this.pollId && window.clearTimeout(this.pollId), this.authWindow = null, this.pollId = null, b.currentPopupAction = null;
2724
+ }
2725
+ pollUserCancellation() {
2726
+ const e = () => {
2727
+ var t, i;
2728
+ if (!((i = (t = this.authWindow) === null || t === void 0 ? void 0 : t.window) === null || i === void 0) && i.closed) {
2729
+ this.pollId = window.setTimeout(
2730
+ () => {
2731
+ this.pollId = null, this.reject(m(
2732
+ this.auth,
2733
+ "popup-closed-by-user"
2734
+ /* AuthErrorCode.POPUP_CLOSED_BY_USER */
2735
+ ));
2736
+ },
2737
+ 8e3
2738
+ /* _Timeout.AUTH_EVENT */
2739
+ );
2740
+ return;
2741
+ }
2742
+ this.pollId = window.setTimeout(e, ni.get());
2743
+ };
2744
+ e();
2745
+ }
2746
+ }
2747
+ b.currentPopupAction = null;
2748
+ const ii = "pendingRedirect", J = /* @__PURE__ */ new Map();
2749
+ class ri extends Lt {
2750
+ constructor(e, t, i = !1) {
2751
+ super(e, [
2752
+ "signInViaRedirect",
2753
+ "linkViaRedirect",
2754
+ "reauthViaRedirect",
2755
+ "unknown"
2756
+ /* AuthEventType.UNKNOWN */
2757
+ ], t, void 0, i), this.eventId = null;
2758
+ }
2759
+ /**
2760
+ * Override the execute function; if we already have a redirect result, then
2761
+ * just return it.
2762
+ */
2763
+ async execute() {
2764
+ let e = J.get(this.auth._key());
2765
+ if (!e) {
2766
+ try {
2767
+ const i = await si(this.resolver, this.auth) ? await super.execute() : null;
2768
+ e = () => Promise.resolve(i);
2769
+ } catch (t) {
2770
+ e = () => Promise.reject(t);
2771
+ }
2772
+ J.set(this.auth._key(), e);
2773
+ }
2774
+ return this.bypassAuthState || J.set(this.auth._key(), () => Promise.resolve(null)), e();
2775
+ }
2776
+ async onAuthEvent(e) {
2777
+ if (e.type === "signInViaRedirect")
2778
+ return super.onAuthEvent(e);
2779
+ if (e.type === "unknown") {
2780
+ this.resolve(null);
2781
+ return;
2782
+ }
2783
+ if (e.eventId) {
2784
+ const t = await this.auth._redirectUserForId(e.eventId);
2785
+ if (t)
2786
+ return this.user = t, super.onAuthEvent(e);
2787
+ this.resolve(null);
2788
+ }
2789
+ }
2790
+ async onExecution() {
2791
+ }
2792
+ cleanUp() {
2793
+ }
2794
+ }
2795
+ async function si(n, e) {
2796
+ const t = ci(e), i = ai(n);
2797
+ if (!await i._isAvailable())
2798
+ return !1;
2799
+ const r = await i._get(t) === "true";
2800
+ return await i._remove(t), r;
2801
+ }
2802
+ function oi(n, e) {
2803
+ J.set(n._key(), e);
2804
+ }
2805
+ function ai(n) {
2806
+ return y(n._redirectPersistence);
2807
+ }
2808
+ function ci(n) {
2809
+ return K(ii, n.config.apiKey, n.name);
2810
+ }
2811
+ async function li(n, e, t = !1) {
2812
+ if (_(n.app))
2813
+ return Promise.reject(A(n));
2814
+ const i = ie(n), r = Nt(i, e), o = await new ri(i, r, t).execute();
2815
+ return o && !t && (delete o.user._redirectEventId, await i._persistUserIfCurrent(o.user), await i._setRedirectUser(null, e)), o;
2816
+ }
2817
+ const ui = 600 * 1e3;
2818
+ class di {
2819
+ constructor(e) {
2820
+ this.auth = e, this.cachedEventUids = /* @__PURE__ */ new Set(), this.consumers = /* @__PURE__ */ new Set(), this.queuedRedirectEvent = null, this.hasHandledPotentialRedirect = !1, this.lastProcessedEventTime = Date.now();
2821
+ }
2822
+ registerConsumer(e) {
2823
+ this.consumers.add(e), this.queuedRedirectEvent && this.isEventForConsumer(this.queuedRedirectEvent, e) && (this.sendToConsumer(this.queuedRedirectEvent, e), this.saveEventToCache(this.queuedRedirectEvent), this.queuedRedirectEvent = null);
2824
+ }
2825
+ unregisterConsumer(e) {
2826
+ this.consumers.delete(e);
2827
+ }
2828
+ onEvent(e) {
2829
+ if (this.hasEventBeenHandled(e))
2830
+ return !1;
2831
+ let t = !1;
2832
+ return this.consumers.forEach((i) => {
2833
+ this.isEventForConsumer(e, i) && (t = !0, this.sendToConsumer(e, i), this.saveEventToCache(e));
2834
+ }), this.hasHandledPotentialRedirect || !hi(e) || (this.hasHandledPotentialRedirect = !0, t || (this.queuedRedirectEvent = e, t = !0)), t;
2835
+ }
2836
+ sendToConsumer(e, t) {
2837
+ var i;
2838
+ if (e.error && !Ut(e)) {
2839
+ const r = ((i = e.error.code) === null || i === void 0 ? void 0 : i.split("auth/")[1]) || "internal-error";
2840
+ t.onError(m(this.auth, r));
2841
+ } else
2842
+ t.onAuthEvent(e);
2843
+ }
2844
+ isEventForConsumer(e, t) {
2845
+ const i = t.eventId === null || !!e.eventId && e.eventId === t.eventId;
2846
+ return t.filter.includes(e.type) && i;
2847
+ }
2848
+ hasEventBeenHandled(e) {
2849
+ return Date.now() - this.lastProcessedEventTime >= ui && this.cachedEventUids.clear(), this.cachedEventUids.has(Je(e));
2850
+ }
2851
+ saveEventToCache(e) {
2852
+ this.cachedEventUids.add(Je(e)), this.lastProcessedEventTime = Date.now();
2853
+ }
2854
+ }
2855
+ function Je(n) {
2856
+ return [n.type, n.eventId, n.sessionId, n.tenantId].filter((e) => e).join("-");
2857
+ }
2858
+ function Ut({ type: n, error: e }) {
2859
+ return n === "unknown" && e?.code === "auth/no-auth-event";
2860
+ }
2861
+ function hi(n) {
2862
+ switch (n.type) {
2863
+ case "signInViaRedirect":
2864
+ case "linkViaRedirect":
2865
+ case "reauthViaRedirect":
2866
+ return !0;
2867
+ case "unknown":
2868
+ return Ut(n);
2869
+ default:
2870
+ return !1;
2871
+ }
2872
+ }
2873
+ async function fi(n, e = {}) {
2874
+ return D(n, "GET", "/v1/projects", e);
2875
+ }
2876
+ const pi = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, gi = /^https?/;
2877
+ async function mi(n) {
2878
+ if (n.config.emulator)
2879
+ return;
2880
+ const { authorizedDomains: e } = await fi(n);
2881
+ for (const t of e)
2882
+ try {
2883
+ if (_i(t))
2884
+ return;
2885
+ } catch {
2886
+ }
2887
+ I(
2888
+ n,
2889
+ "unauthorized-domain"
2890
+ /* AuthErrorCode.INVALID_ORIGIN */
2891
+ );
2892
+ }
2893
+ function _i(n) {
2894
+ const e = fe(), { protocol: t, hostname: i } = new URL(e);
2895
+ if (n.startsWith("chrome-extension://")) {
2896
+ const o = new URL(n);
2897
+ return o.hostname === "" && i === "" ? t === "chrome-extension:" && n.replace("chrome-extension://", "") === e.replace("chrome-extension://", "") : t === "chrome-extension:" && o.hostname === i;
2898
+ }
2899
+ if (!gi.test(t))
2900
+ return !1;
2901
+ if (pi.test(n))
2902
+ return i === n;
2903
+ const r = n.replace(/\./g, "\\.");
2904
+ return new RegExp("^(.+\\." + r + "|" + r + ")$", "i").test(i);
2905
+ }
2906
+ const vi = new j(3e4, 6e4);
2907
+ function Xe() {
2908
+ const n = v().___jsl;
2909
+ if (n?.H) {
2910
+ for (const e of Object.keys(n.H))
2911
+ 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)
2912
+ for (let t = 0; t < n.CP.length; t++)
2913
+ n.CP[t] = null;
2914
+ }
2915
+ }
2916
+ function Ii(n) {
2917
+ return new Promise((e, t) => {
2918
+ var i, r, s;
2919
+ function o() {
2920
+ Xe(), gapi.load("gapi.iframes", {
2921
+ callback: () => {
2922
+ e(gapi.iframes.getContext());
2923
+ },
2924
+ ontimeout: () => {
2925
+ Xe(), t(m(
2926
+ n,
2927
+ "network-request-failed"
2928
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
2929
+ ));
2930
+ },
2931
+ timeout: vi.get()
2932
+ });
2933
+ }
2934
+ if (!((r = (i = v().gapi) === null || i === void 0 ? void 0 : i.iframes) === null || r === void 0) && r.Iframe)
2935
+ e(gapi.iframes.getContext());
2936
+ else if (!((s = v().gapi) === null || s === void 0) && s.load)
2937
+ o();
2938
+ else {
2939
+ const c = Pn("iframefcb");
2940
+ return v()[c] = () => {
2941
+ gapi.load ? o() : t(m(
2942
+ n,
2943
+ "network-request-failed"
2944
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
2945
+ ));
2946
+ }, kn(`${Sn()}?onload=${c}`).catch((a) => t(a));
2947
+ }
2948
+ }).catch((e) => {
2949
+ throw X = null, e;
2950
+ });
2951
+ }
2952
+ let X = null;
2953
+ function wi(n) {
2954
+ return X = X || Ii(n), X;
2955
+ }
2956
+ const yi = new j(5e3, 15e3), Ti = "__/auth/iframe", Ei = "emulator/auth/iframe", ki = {
2957
+ style: {
2958
+ position: "absolute",
2959
+ top: "-100px",
2960
+ width: "1px",
2961
+ height: "1px"
2962
+ },
2963
+ "aria-hidden": "true",
2964
+ tabindex: "-1"
2965
+ }, Si = /* @__PURE__ */ new Map([
2966
+ ["identitytoolkit.googleapis.com", "p"],
2967
+ // production
2968
+ ["staging-identitytoolkit.sandbox.googleapis.com", "s"],
2969
+ // staging
2970
+ ["test-identitytoolkit.sandbox.googleapis.com", "t"]
2971
+ // test
2972
+ ]);
2973
+ function Pi(n) {
2974
+ const e = n.config;
2975
+ u(
2976
+ e.authDomain,
2977
+ n,
2978
+ "auth-domain-config-required"
2979
+ /* AuthErrorCode.MISSING_AUTH_DOMAIN */
2980
+ );
2981
+ const t = e.emulator ? Te(e, Ei) : `https://${n.config.authDomain}/${Ti}`, i = {
2982
+ apiKey: e.apiKey,
2983
+ appName: n.name,
2984
+ v: W
2985
+ }, r = Si.get(n.config.apiHost);
2986
+ r && (i.eid = r);
2987
+ const s = n._getFrameworks();
2988
+ return s.length && (i.fw = s.join(",")), `${t}?${V(i).slice(1)}`;
2989
+ }
2990
+ async function Ri(n) {
2991
+ const e = await wi(n), t = v().gapi;
2992
+ return u(
2993
+ t,
2994
+ n,
2995
+ "internal-error"
2996
+ /* AuthErrorCode.INTERNAL_ERROR */
2997
+ ), e.open({
2998
+ where: document.body,
2999
+ url: Pi(n),
3000
+ messageHandlersFilter: t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,
3001
+ attributes: ki,
3002
+ dontclear: !0
3003
+ }, (i) => new Promise(async (r, s) => {
3004
+ await i.restyle({
3005
+ // Prevent iframe from closing on mouse out.
3006
+ setHideOnLeave: !1
3007
+ });
3008
+ const o = m(
3009
+ n,
3010
+ "network-request-failed"
3011
+ /* AuthErrorCode.NETWORK_REQUEST_FAILED */
3012
+ ), c = v().setTimeout(() => {
3013
+ s(o);
3014
+ }, yi.get());
3015
+ function a() {
3016
+ v().clearTimeout(c), r(i);
3017
+ }
3018
+ i.ping(a).then(a, () => {
3019
+ s(o);
3020
+ });
3021
+ }));
3022
+ }
3023
+ const bi = {
3024
+ location: "yes",
3025
+ resizable: "yes",
3026
+ statusbar: "yes",
3027
+ toolbar: "no"
3028
+ }, Ai = 500, Ci = 600, Oi = "_blank", Ni = "http://localhost";
3029
+ class Ye {
3030
+ constructor(e) {
3031
+ this.window = e, this.associatedEvent = null;
3032
+ }
3033
+ close() {
3034
+ if (this.window)
3035
+ try {
3036
+ this.window.close();
3037
+ } catch {
3038
+ }
3039
+ }
3040
+ }
3041
+ function Li(n, e, t, i = Ai, r = Ci) {
3042
+ const s = Math.max((window.screen.availHeight - r) / 2, 0).toString(), o = Math.max((window.screen.availWidth - i) / 2, 0).toString();
3043
+ let c = "";
3044
+ const a = Object.assign(Object.assign({}, bi), {
3045
+ width: i.toString(),
3046
+ height: r.toString(),
3047
+ top: s,
3048
+ left: o
3049
+ }), l = f().toLowerCase();
3050
+ t && (c = pt(l) ? Oi : t), ht(l) && (e = e || Ni, a.scrollbars = "yes");
3051
+ const d = Object.entries(a).reduce((p, [q, z]) => `${p}${q}=${z},`, "");
3052
+ if (mn(l) && c !== "_self")
3053
+ return Ui(e || "", c), new Ye(null);
3054
+ const h = window.open(e || "", c, d);
3055
+ u(
3056
+ h,
3057
+ n,
3058
+ "popup-blocked"
3059
+ /* AuthErrorCode.POPUP_BLOCKED */
3060
+ );
3061
+ try {
3062
+ h.focus();
3063
+ } catch {
3064
+ }
3065
+ return new Ye(h);
3066
+ }
3067
+ function Ui(n, e) {
3068
+ const t = document.createElement("a");
3069
+ t.href = n, t.target = e;
3070
+ const i = document.createEvent("MouseEvent");
3071
+ i.initMouseEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 1, null), t.dispatchEvent(i);
3072
+ }
3073
+ const Mi = "__/auth/handler", Di = "emulator/auth/handler", xi = encodeURIComponent("fac");
3074
+ async function Qe(n, e, t, i, r, s) {
3075
+ u(
3076
+ n.config.authDomain,
3077
+ n,
3078
+ "auth-domain-config-required"
3079
+ /* AuthErrorCode.MISSING_AUTH_DOMAIN */
3080
+ ), u(
3081
+ n.config.apiKey,
3082
+ n,
3083
+ "invalid-api-key"
3084
+ /* AuthErrorCode.INVALID_API_KEY */
3085
+ );
3086
+ const o = {
3087
+ apiKey: n.config.apiKey,
3088
+ appName: n.name,
3089
+ authType: t,
3090
+ redirectUrl: i,
3091
+ v: W,
3092
+ eventId: r
3093
+ };
3094
+ if (e instanceof Re) {
3095
+ e.setDefaultLanguage(n.languageCode), o.providerId = e.providerId || "", qt(e.getCustomParameters()) || (o.customParameters = JSON.stringify(e.getCustomParameters()));
3096
+ for (const [d, h] of Object.entries({}))
3097
+ o[d] = h;
3098
+ }
3099
+ if (e instanceof H) {
3100
+ const d = e.getScopes().filter((h) => h !== "");
3101
+ d.length > 0 && (o.scopes = d.join(","));
3102
+ }
3103
+ n.tenantId && (o.tid = n.tenantId);
3104
+ const c = o;
3105
+ for (const d of Object.keys(c))
3106
+ c[d] === void 0 && delete c[d];
3107
+ const a = await n._getAppCheckToken(), l = a ? `#${xi}=${encodeURIComponent(a)}` : "";
3108
+ return `${Fi(n)}?${V(c).slice(1)}${l}`;
3109
+ }
3110
+ function Fi({ config: n }) {
3111
+ return n.emulator ? Te(n, Di) : `https://${n.authDomain}/${Mi}`;
3112
+ }
3113
+ const de = "webStorageSupport";
3114
+ class Vi {
3115
+ constructor() {
3116
+ this.eventManagers = {}, this.iframes = {}, this.originValidationPromises = {}, this._redirectPersistence = Rt, this._completeRedirectFn = li, this._overrideRedirectResult = oi;
3117
+ }
3118
+ // Wrapping in async even though we don't await anywhere in order
3119
+ // to make sure errors are raised as promise rejections
3120
+ async _openPopup(e, t, i, r) {
3121
+ var s;
3122
+ T((s = this.eventManagers[e._key()]) === null || s === void 0 ? void 0 : s.manager, "_initialize() not called before _openPopup()");
3123
+ const o = await Qe(e, t, i, fe(), r);
3124
+ return Li(e, o, be());
3125
+ }
3126
+ async _openRedirect(e, t, i, r) {
3127
+ await this._originValidation(e);
3128
+ const s = await Qe(e, t, i, fe(), r);
3129
+ return $n(s), new Promise(() => {
3130
+ });
3131
+ }
3132
+ _initialize(e) {
3133
+ const t = e._key();
3134
+ if (this.eventManagers[t]) {
3135
+ const { manager: r, promise: s } = this.eventManagers[t];
3136
+ return r ? Promise.resolve(r) : (T(s, "If manager is not set, promise should be"), s);
3137
+ }
3138
+ const i = this.initAndGetManager(e);
3139
+ return this.eventManagers[t] = { promise: i }, i.catch(() => {
3140
+ delete this.eventManagers[t];
3141
+ }), i;
3142
+ }
3143
+ async initAndGetManager(e) {
3144
+ const t = await Ri(e), i = new di(e);
3145
+ return t.register("authEvent", (r) => (u(
3146
+ r?.authEvent,
3147
+ e,
3148
+ "invalid-auth-event"
3149
+ /* AuthErrorCode.INVALID_AUTH_EVENT */
3150
+ ), {
3151
+ status: i.onEvent(r.authEvent) ? "ACK" : "ERROR"
3152
+ /* GapiOutcome.ERROR */
3153
+ }), gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER), this.eventManagers[e._key()] = { manager: i }, this.iframes[e._key()] = t, i;
3154
+ }
3155
+ _isIframeWebStorageSupported(e, t) {
3156
+ this.iframes[e._key()].send(de, { type: de }, (r) => {
3157
+ var s;
3158
+ const o = (s = r?.[0]) === null || s === void 0 ? void 0 : s[de];
3159
+ o !== void 0 && t(!!o), I(
3160
+ e,
3161
+ "internal-error"
3162
+ /* AuthErrorCode.INTERNAL_ERROR */
3163
+ );
3164
+ }, gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER);
3165
+ }
3166
+ _originValidation(e) {
3167
+ const t = e._key();
3168
+ return this.originValidationPromises[t] || (this.originValidationPromises[t] = mi(e)), this.originValidationPromises[t];
3169
+ }
3170
+ get _shouldInitProactively() {
3171
+ return It() || ft() || Se();
3172
+ }
3173
+ }
3174
+ const Wi = Vi;
3175
+ var Ze = "@firebase/auth", et = "1.10.7";
3176
+ class ji {
3177
+ constructor(e) {
3178
+ this.auth = e, this.internalListeners = /* @__PURE__ */ new Map();
3179
+ }
3180
+ getUid() {
3181
+ var e;
3182
+ return this.assertAuthConfigured(), ((e = this.auth.currentUser) === null || e === void 0 ? void 0 : e.uid) || null;
3183
+ }
3184
+ async getToken(e) {
3185
+ return this.assertAuthConfigured(), await this.auth._initializationPromise, this.auth.currentUser ? { accessToken: await this.auth.currentUser.getIdToken(e) } : null;
3186
+ }
3187
+ addAuthTokenListener(e) {
3188
+ if (this.assertAuthConfigured(), this.internalListeners.has(e))
3189
+ return;
3190
+ const t = this.auth.onIdTokenChanged((i) => {
3191
+ e(i?.stsTokenManager.accessToken || null);
3192
+ });
3193
+ this.internalListeners.set(e, t), this.updateProactiveRefresh();
3194
+ }
3195
+ removeAuthTokenListener(e) {
3196
+ this.assertAuthConfigured();
3197
+ const t = this.internalListeners.get(e);
3198
+ t && (this.internalListeners.delete(e), t(), this.updateProactiveRefresh());
3199
+ }
3200
+ assertAuthConfigured() {
3201
+ u(
3202
+ this.auth._initializationPromise,
3203
+ "dependent-sdk-initialized-before-auth"
3204
+ /* AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH */
3205
+ );
3206
+ }
3207
+ updateProactiveRefresh() {
3208
+ this.internalListeners.size > 0 ? this.auth._startProactiveRefresh() : this.auth._stopProactiveRefresh();
3209
+ }
3210
+ }
3211
+ function Hi(n) {
3212
+ switch (n) {
3213
+ case "Node":
3214
+ return "node";
3215
+ case "ReactNative":
3216
+ return "rn";
3217
+ case "Worker":
3218
+ return "webworker";
3219
+ case "Cordova":
3220
+ return "cordova";
3221
+ case "WebExtension":
3222
+ return "web-extension";
3223
+ default:
3224
+ return;
3225
+ }
3226
+ }
3227
+ function $i(n) {
3228
+ De(new xe(
3229
+ "auth",
3230
+ (e, { options: t }) => {
3231
+ const i = e.getProvider("app").getImmediate(), r = e.getProvider("heartbeat"), s = e.getProvider("app-check-internal"), { apiKey: o, authDomain: c } = i.options;
3232
+ u(o && !o.includes(":"), "invalid-api-key", { appName: i.name });
3233
+ const a = {
3234
+ apiKey: o,
3235
+ authDomain: c,
3236
+ clientPlatform: n,
3237
+ apiHost: "identitytoolkit.googleapis.com",
3238
+ tokenApiHost: "securetoken.googleapis.com",
3239
+ apiScheme: "https",
3240
+ sdkClientVersion: wt(n)
3241
+ }, l = new Tn(i, r, s, a);
3242
+ return bn(l, t), l;
3243
+ },
3244
+ "PUBLIC"
3245
+ /* ComponentType.PUBLIC */
3246
+ ).setInstantiationMode(
3247
+ "EXPLICIT"
3248
+ /* InstantiationMode.EXPLICIT */
3249
+ ).setInstanceCreatedCallback((e, t, i) => {
3250
+ e.getProvider(
3251
+ "auth-internal"
3252
+ /* _ComponentName.AUTH_INTERNAL */
3253
+ ).initialize();
3254
+ })), De(new xe(
3255
+ "auth-internal",
3256
+ (e) => {
3257
+ const t = ie(e.getProvider(
3258
+ "auth"
3259
+ /* _ComponentName.AUTH */
3260
+ ).getImmediate());
3261
+ return ((i) => new ji(i))(t);
3262
+ },
3263
+ "PRIVATE"
3264
+ /* ComponentType.PRIVATE */
3265
+ ).setInstantiationMode(
3266
+ "EXPLICIT"
3267
+ /* InstantiationMode.EXPLICIT */
3268
+ )), Fe(Ze, et, Hi(n)), Fe(Ze, et, "esm2017");
3269
+ }
3270
+ const qi = 300, zi = it("authIdTokenMaxAge") || qi;
3271
+ let tt = null;
3272
+ const Gi = (n) => async (e) => {
3273
+ const t = e && await e.getIdTokenResult(), i = t && ((/* @__PURE__ */ new Date()).getTime() - Date.parse(t.issuedAtTime)) / 1e3;
3274
+ if (i && i > zi)
3275
+ return;
3276
+ const r = t?.token;
3277
+ tt !== r && (tt = r, await fetch(n, {
3278
+ method: r ? "POST" : "DELETE",
3279
+ headers: r ? {
3280
+ Authorization: `Bearer ${r}`
3281
+ } : {}
3282
+ }));
3283
+ };
3284
+ function Xi(n = Ft()) {
3285
+ const e = nt(n, "auth");
3286
+ if (e.isInitialized())
3287
+ return e.getImmediate();
3288
+ const t = Rn(n, {
3289
+ popupRedirectResolver: Wi,
3290
+ persistence: [
3291
+ Qn,
3292
+ Wn,
3293
+ Rt
3294
+ ]
3295
+ }), i = it("authTokenSyncURL");
3296
+ if (i && typeof isSecureContext == "boolean" && isSecureContext) {
3297
+ const s = new URL(i, location.origin);
3298
+ if (location.origin === s.origin) {
3299
+ const o = Gi(s.toString());
3300
+ xn(t, o, () => o(t.currentUser)), Dn(t, (c) => o(c));
3301
+ }
3302
+ }
3303
+ const r = xt("auth");
3304
+ return r && An(t, `http://${r}`), t;
3305
+ }
3306
+ function Bi() {
3307
+ var n, e;
3308
+ return (e = (n = document.getElementsByTagName("head")) === null || n === void 0 ? void 0 : n[0]) !== null && e !== void 0 ? e : document;
3309
+ }
3310
+ En({
3311
+ loadJS(n) {
3312
+ return new Promise((e, t) => {
3313
+ const i = document.createElement("script");
3314
+ i.setAttribute("src", n), i.onload = e, i.onerror = (r) => {
3315
+ const s = m(
3316
+ "internal-error"
3317
+ /* AuthErrorCode.INTERNAL_ERROR */
3318
+ );
3319
+ s.customData = r, t(s);
3320
+ }, i.type = "text/javascript", i.charset = "UTF-8", Bi().appendChild(i);
3321
+ });
3322
+ },
3323
+ gapiScript: "https://apis.google.com/js/api.js",
3324
+ recaptchaV2Script: "https://www.google.com/recaptcha/api.js",
3325
+ recaptchaEnterpriseScript: "https://www.google.com/recaptcha/enterprise.js?render="
3326
+ });
3327
+ $i(
3328
+ "Browser"
3329
+ /* ClientPlatform.BROWSER */
3330
+ );
3331
+ export {
3332
+ Tt as AuthCredential,
3333
+ k as FacebookAuthProvider,
3334
+ P as GithubAuthProvider,
3335
+ S as GoogleAuthProvider,
3336
+ C as OAuthCredential,
3337
+ R as TwitterAuthProvider,
3338
+ xn as beforeAuthStateChanged,
3339
+ Wn as browserLocalPersistence,
3340
+ Wi as browserPopupRedirectResolver,
3341
+ Rt as browserSessionPersistence,
3342
+ An as connectAuthEmulator,
3343
+ Xi as getAuth,
3344
+ ln as getIdTokenResult,
3345
+ He as inMemoryPersistence,
3346
+ Qn as indexedDBLocalPersistence,
3347
+ Rn as initializeAuth,
3348
+ Dn as onIdTokenChanged,
3349
+ Xt as prodErrorMap,
3350
+ hn as reload,
3351
+ Ji as signInWithPopup
3352
+ };