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