@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.
- package/README.md +72 -16
- package/dist/ChatProfileModal-hxsWI8cx.js +2139 -0
- package/dist/FilePreviewModal-CwWnHsB1.js +736 -0
- package/dist/ManageDataModal-CDPXcC93.js +159 -0
- package/dist/MarkdownBody-DBJGraWM.js +16874 -0
- package/dist/SideDrawer-Dr_lkaOW.js +226 -0
- package/dist/UserProfileModal-Q_jhXpsX.js +568 -0
- package/dist/UserSettingsModal-OcAJao-d.js +50 -0
- package/dist/{VideoCallOverlay-BUfKp87t.js → VideoCallOverlay-CC4sShdK.js} +9 -10
- package/dist/VisibilityModal-DkMhx_2k.js +132 -0
- package/dist/assets/icons.d.ts +30 -0
- package/dist/components/ContextMenu/ContextMenuComponents.d.ts +1 -3
- package/dist/components/EmojiPicker/LazyEmojiPicker.d.ts +3 -0
- package/dist/components/ExampleComponents/CustomMessage.d.ts +3 -3
- package/dist/components/Files/FilesList.d.ts +12 -0
- package/dist/components/Files/FilesPanel.d.ts +3 -0
- package/dist/components/Files/fileCategory.d.ts +13 -0
- package/dist/components/InputComponents/AttachmentPreview.d.ts +17 -0
- package/dist/components/InputComponents/MentionDropdown.d.ts +13 -0
- package/dist/components/InputComponents/MentionPickerModal.d.ts +19 -0
- package/dist/components/MainComponents/AttachmentList.d.ts +7 -0
- package/dist/components/MainComponents/ChatErrorBoundary.d.ts +53 -0
- package/dist/components/MainComponents/ChatErrorScreen.d.ts +24 -0
- package/dist/components/MainComponents/HeaderLogo.d.ts +18 -0
- package/dist/components/MainComponents/MediaMessage.d.ts +5 -0
- package/dist/components/MainComponents/MessageContainer.d.ts +2 -2
- package/dist/components/MainComponents/ReduxWrapper.d.ts +1 -2
- package/dist/components/MainComponents/SystemMessage.d.ts +1 -2
- package/dist/components/MenuRoom/MenuRoom.d.ts +1 -0
- package/dist/components/MessageBubble/CustomDivider.d.ts +3 -3
- package/dist/components/MessageBubble/Message.d.ts +2 -2
- package/dist/components/MessageBubble/MessageTranslate.d.ts +28 -10
- package/dist/components/MessageBubble/QuickReplies.d.ts +19 -0
- package/dist/components/Modals/ChatProfileModal/ChatProfileMemberRow.d.ts +18 -0
- package/dist/components/Modals/FilePreviewModal/FilePreviewModal.d.ts +17 -0
- package/dist/components/Modals/FilePreviewModal/ImageLightbox.d.ts +35 -0
- package/dist/components/Modals/FilePreviewModal/PdfView.d.ts +14 -3
- package/dist/components/Modals/NewChatModal/styledNewChatComponents.d.ts +12 -0
- package/dist/components/Modals/SettingsModals/Visibility/StyledComponents.d.ts +1 -1
- package/dist/components/Modals/SideDrawer/DrawerProfileParts.d.ts +13 -0
- package/dist/components/Modals/SideDrawer/SideDrawer.d.ts +44 -0
- package/dist/components/Modals/modalComponents.d.ts +6 -0
- package/dist/components/Modals/styledModalComponents.d.ts +14 -3
- package/dist/components/RoomComponents/ChatRoomItem.d.ts +0 -1
- package/dist/components/RoomComponents/OnlineUsersPopover.d.ts +0 -1
- package/dist/components/UsersList/StyledComponents.d.ts +5 -1
- package/dist/components/UsersList/UsersList.d.ts +23 -0
- package/dist/components/styled/Button.d.ts +11 -1
- package/dist/components/styled/ChatWrapperBox.d.ts +3 -1
- package/dist/components/styled/PdfMessage.d.ts +13 -0
- package/dist/components/styled/RoomListComponents/index.d.ts +22 -1
- package/dist/components/styled/SendInput.d.ts +19 -5
- package/dist/components/styled/StyledComponents.d.ts +1 -1
- package/dist/components/styled/StyledInputComponents/MediaComponents.d.ts +18 -0
- package/dist/components/styled/StyledInputComponents/StyledInputComponents.d.ts +21 -0
- package/dist/components/styled/TreadLabel.d.ts +2 -2
- package/dist/components/styled/UnsupportedType.d.ts +1 -1
- package/dist/examples/quiz/QuizDemo.d.ts +3 -0
- package/dist/examples/quiz/quizScript.d.ts +38 -0
- package/dist/examples/quiz/useDemoSession.d.ts +42 -0
- package/dist/examples/quiz/useQuizFlow.d.ts +47 -0
- package/dist/firebase-config.d.ts +2 -4
- package/dist/handleCopyClick-CpmPa6VI.js +32 -0
- package/dist/helpers/MarkdownBody.d.ts +7 -0
- package/dist/helpers/attachments.d.ts +33 -0
- package/dist/helpers/botMarkup.d.ts +30 -0
- package/dist/helpers/constants/MODAL_TYPES.d.ts +11 -7
- package/dist/helpers/ethoraLogger.d.ts +8 -0
- package/dist/helpers/fileKind.d.ts +17 -0
- package/dist/helpers/hiddenRooms.d.ts +1 -1
- package/dist/helpers/historyPreloadScheduler.d.ts +1 -0
- package/dist/helpers/lazyEmoji.d.ts +3 -0
- package/dist/helpers/localStorageUser.d.ts +1 -1
- package/dist/helpers/markdownSanitizeSchema.d.ts +3 -0
- package/dist/helpers/mentions.d.ts +63 -0
- package/dist/helpers/parseMessageBody.d.ts +12 -2
- package/dist/helpers/pdf/loadPdfjs.d.ts +64 -0
- package/dist/helpers/quickReplies.d.ts +31 -0
- package/dist/helpers/remarkLineBreaks.d.ts +42 -0
- package/dist/helpers/resolveMessageTranslation.d.ts +34 -0
- package/dist/helpers/roomImageGallery.d.ts +53 -0
- package/dist/helpers/secureFileUrl.d.ts +8 -0
- package/dist/helpers/sendFailureWatchdog.d.ts +62 -0
- package/dist/helpers/transformTranslatations.d.ts +1 -2
- package/dist/hooks/pushSubscriptionSweep.d.ts +41 -0
- package/dist/hooks/useChatWrapperInit.d.ts +1 -0
- package/dist/hooks/useFilesEndpointSupport.d.ts +9 -0
- package/dist/hooks/useInView.d.ts +17 -0
- package/dist/hooks/useMentionComposer.d.ts +45 -0
- package/dist/hooks/useMessageHeapState.d.ts +1 -1
- package/dist/hooks/useMessageTranslation.d.ts +4 -3
- package/dist/hooks/useModalDismiss.d.ts +27 -0
- package/dist/hooks/useMyFiles.d.ts +16 -0
- package/dist/hooks/usePdfThumbnail.d.ts +22 -0
- package/dist/hooks/useRoomMute.d.ts +19 -0
- package/dist/hooks/useRoomState.d.ts +1 -1
- package/dist/hooks/useSendMessage.d.ts +4 -3
- package/dist/hooks/useTypography.d.ts +1 -1
- package/dist/hooks/useUnreadMessagesCounter.d.ts +11 -2
- package/dist/index.esm-B-3fyDHY.js +28 -0
- package/dist/index.esm-CRM4VCRa.js +943 -0
- package/dist/index.esm-msbp26WN.js +3352 -0
- package/dist/index.esm2017-CL0mvq6y.js +1578 -0
- package/dist/main-B-8IhwaP.js +31837 -0
- package/dist/main.css +1 -1
- package/dist/main.d.ts +16 -0
- package/dist/main.js +19 -18
- package/dist/module-DGXkb0R_.js +2960 -0
- package/dist/native-CDi4YD_s.js +13 -0
- package/dist/networking/api-requests/files.api.d.ts +19 -0
- package/dist/networking/api-requests/rooms.api.d.ts +10 -2
- package/dist/networking/api-requests/translate.api.d.ts +15 -0
- package/dist/networking/api-requests/user.api.d.ts +2 -0
- package/dist/networking/sharedRequest.d.ts +4 -0
- package/dist/networking/xmpp/allRoomPresences.xmpp.d.ts +3 -1
- package/dist/networking/xmpp/createTimeoutPromise.xmpp.d.ts +14 -0
- package/dist/networking/xmpp/sendTextMessage.xmpp.d.ts +2 -1
- package/dist/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.d.ts +2 -1
- package/dist/networking/xmppClient.d.ts +12 -3
- package/dist/pdf-B5b7qHu6.js +17130 -0
- package/dist/pdf.worker.min-COYn-gId.js +24385 -0
- package/dist/roomStore/index.d.ts +20 -0
- package/dist/roomStore/persistEncryption.d.ts +51 -0
- package/dist/roomStore/roomsSlice.d.ts +49 -6
- package/dist/styles/classNames.d.ts +35 -0
- package/dist/styles/motion.d.ts +44 -0
- package/dist/styles/tokens.d.ts +27 -0
- package/dist/testIds.d.ts +1 -1
- package/dist/types/models/attachment.model.d.ts +33 -0
- package/dist/types/models/config.model.d.ts +179 -19
- package/dist/types/models/file.model.d.ts +20 -0
- package/dist/types/models/message.model.d.ts +16 -6
- package/dist/types/models/room.model.d.ts +12 -2
- package/dist/types/types.d.ts +3 -1
- package/dist/utils/resendMessage.d.ts +22 -1
- package/dist/utils/translateModePolicy.d.ts +1 -0
- package/dist/wavesurfer.esm-D_a19qBW.js +952 -0
- package/package.json +22 -2
- package/dist/VideoCallOverlay-BUfKp87t.js.map +0 -1
- package/dist/components/MainComponents/VirtualList.d.ts +0 -10
- package/dist/components/Modals/SettingsModals/BlockedUsers/BlockedUsersModal.d.ts +0 -6
- package/dist/components/Modals/SettingsModals/DocumentShares/DocumentSharesModal.d.ts +0 -6
- package/dist/components/Modals/SettingsModals/ManageDataModal/StyledComponents.d.ts +0 -0
- package/dist/components/Modals/SettingsModals/ProfileShares/ProfileShares.d.ts +0 -6
- package/dist/components/Modals/SettingsModals/Referrals/Referrals.d.ts +0 -6
- package/dist/hooks/useMessageQueue.d.ts +0 -4
- package/dist/main-DFqqDiy-.js +0 -55707
- package/dist/main-DFqqDiy-.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/networking/xmpp/getHistory.xmpp.d.ts +0 -3
- package/dist/networking/xmpp/listenerManager.d.ts +0 -17
- package/dist/utils/xmppMemoryMonitor.d.ts +0 -16
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
import { r as m, _ as y, C as T, a as R, E as Q, o as M, F as Se, g as I, b as Ae, v as Ee, i as _e, c as Oe, d as A } from "./index.esm2017-CL0mvq6y.js";
|
|
2
|
+
const Z = "@firebase/installations", P = "0.6.17";
|
|
3
|
+
const ee = 1e4, te = `w:${P}`, ne = "FIS_v2", Ce = "https://firebaseinstallations.googleapis.com/v1", Ne = 3600 * 1e3, De = "installations", Re = "Installations";
|
|
4
|
+
const Me = {
|
|
5
|
+
"missing-app-config-values": 'Missing App configuration value: "{$valueName}"',
|
|
6
|
+
"not-registered": "Firebase Installation is not registered.",
|
|
7
|
+
"installation-not-found": "Firebase Installation not found.",
|
|
8
|
+
"request-failed": '{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',
|
|
9
|
+
"app-offline": "Could not process request. Application offline.",
|
|
10
|
+
"delete-pending-registration": "Can't delete installation while there is a pending registration request."
|
|
11
|
+
}, g = new Q(De, Re, Me);
|
|
12
|
+
function oe(e) {
|
|
13
|
+
return e instanceof Se && e.code.includes(
|
|
14
|
+
"request-failed"
|
|
15
|
+
/* ErrorCode.REQUEST_FAILED */
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function ie({ projectId: e }) {
|
|
19
|
+
return `${Ce}/projects/${e}/installations`;
|
|
20
|
+
}
|
|
21
|
+
function re(e) {
|
|
22
|
+
return {
|
|
23
|
+
token: e.token,
|
|
24
|
+
requestStatus: 2,
|
|
25
|
+
expiresIn: je(e.expiresIn),
|
|
26
|
+
creationTime: Date.now()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function ae(e, t) {
|
|
30
|
+
const o = (await t.json()).error;
|
|
31
|
+
return g.create("request-failed", {
|
|
32
|
+
requestName: e,
|
|
33
|
+
serverCode: o.code,
|
|
34
|
+
serverMessage: o.message,
|
|
35
|
+
serverStatus: o.status
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function se({ apiKey: e }) {
|
|
39
|
+
return new Headers({
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
Accept: "application/json",
|
|
42
|
+
"x-goog-api-key": e
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function Pe(e, { refreshToken: t }) {
|
|
46
|
+
const n = se(e);
|
|
47
|
+
return n.append("Authorization", Fe(t)), n;
|
|
48
|
+
}
|
|
49
|
+
async function ce(e) {
|
|
50
|
+
const t = await e();
|
|
51
|
+
return t.status >= 500 && t.status < 600 ? e() : t;
|
|
52
|
+
}
|
|
53
|
+
function je(e) {
|
|
54
|
+
return Number(e.replace("s", "000"));
|
|
55
|
+
}
|
|
56
|
+
function Fe(e) {
|
|
57
|
+
return `${ne} ${e}`;
|
|
58
|
+
}
|
|
59
|
+
async function $e({ appConfig: e, heartbeatServiceProvider: t }, { fid: n }) {
|
|
60
|
+
const o = ie(e), i = se(e), r = t.getImmediate({
|
|
61
|
+
optional: !0
|
|
62
|
+
});
|
|
63
|
+
if (r) {
|
|
64
|
+
const d = await r.getHeartbeatsHeader();
|
|
65
|
+
d && i.append("x-firebase-client", d);
|
|
66
|
+
}
|
|
67
|
+
const a = {
|
|
68
|
+
fid: n,
|
|
69
|
+
authVersion: ne,
|
|
70
|
+
appId: e.appId,
|
|
71
|
+
sdkVersion: te
|
|
72
|
+
}, c = {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: i,
|
|
75
|
+
body: JSON.stringify(a)
|
|
76
|
+
}, f = await ce(() => fetch(o, c));
|
|
77
|
+
if (f.ok) {
|
|
78
|
+
const d = await f.json();
|
|
79
|
+
return {
|
|
80
|
+
fid: d.fid || n,
|
|
81
|
+
registrationStatus: 2,
|
|
82
|
+
refreshToken: d.refreshToken,
|
|
83
|
+
authToken: re(d.authToken)
|
|
84
|
+
};
|
|
85
|
+
} else
|
|
86
|
+
throw await ae("Create Installation", f);
|
|
87
|
+
}
|
|
88
|
+
function ue(e) {
|
|
89
|
+
return new Promise((t) => {
|
|
90
|
+
setTimeout(t, e);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function Ke(e) {
|
|
94
|
+
return btoa(String.fromCharCode(...e)).replace(/\+/g, "-").replace(/\//g, "_");
|
|
95
|
+
}
|
|
96
|
+
const qe = /^[cdef][\w-]{21}$/, D = "";
|
|
97
|
+
function Le() {
|
|
98
|
+
try {
|
|
99
|
+
const e = new Uint8Array(17);
|
|
100
|
+
(self.crypto || self.msCrypto).getRandomValues(e), e[0] = 112 + e[0] % 16;
|
|
101
|
+
const n = xe(e);
|
|
102
|
+
return qe.test(n) ? n : D;
|
|
103
|
+
} catch {
|
|
104
|
+
return D;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function xe(e) {
|
|
108
|
+
return Ke(e).substr(0, 22);
|
|
109
|
+
}
|
|
110
|
+
function v(e) {
|
|
111
|
+
return `${e.appName}!${e.appId}`;
|
|
112
|
+
}
|
|
113
|
+
const de = /* @__PURE__ */ new Map();
|
|
114
|
+
function fe(e, t) {
|
|
115
|
+
const n = v(e);
|
|
116
|
+
pe(n, t), Ve(n, t);
|
|
117
|
+
}
|
|
118
|
+
function pe(e, t) {
|
|
119
|
+
const n = de.get(e);
|
|
120
|
+
if (n)
|
|
121
|
+
for (const o of n)
|
|
122
|
+
o(t);
|
|
123
|
+
}
|
|
124
|
+
function Ve(e, t) {
|
|
125
|
+
const n = Be();
|
|
126
|
+
n && n.postMessage({ key: e, fid: t }), He();
|
|
127
|
+
}
|
|
128
|
+
let l = null;
|
|
129
|
+
function Be() {
|
|
130
|
+
return !l && "BroadcastChannel" in self && (l = new BroadcastChannel("[Firebase] FID Change"), l.onmessage = (e) => {
|
|
131
|
+
pe(e.data.key, e.data.fid);
|
|
132
|
+
}), l;
|
|
133
|
+
}
|
|
134
|
+
function He() {
|
|
135
|
+
de.size === 0 && l && (l.close(), l = null);
|
|
136
|
+
}
|
|
137
|
+
const We = "firebase-installations-database", Ue = 1, w = "firebase-installations-store";
|
|
138
|
+
let E = null;
|
|
139
|
+
function j() {
|
|
140
|
+
return E || (E = M(We, Ue, {
|
|
141
|
+
upgrade: (e, t) => {
|
|
142
|
+
t === 0 && e.createObjectStore(w);
|
|
143
|
+
}
|
|
144
|
+
})), E;
|
|
145
|
+
}
|
|
146
|
+
async function k(e, t) {
|
|
147
|
+
const n = v(e), i = (await j()).transaction(w, "readwrite"), r = i.objectStore(w), a = await r.get(n);
|
|
148
|
+
return await r.put(t, n), await i.done, (!a || a.fid !== t.fid) && fe(e, t.fid), t;
|
|
149
|
+
}
|
|
150
|
+
async function le(e) {
|
|
151
|
+
const t = v(e), o = (await j()).transaction(w, "readwrite");
|
|
152
|
+
await o.objectStore(w).delete(t), await o.done;
|
|
153
|
+
}
|
|
154
|
+
async function S(e, t) {
|
|
155
|
+
const n = v(e), i = (await j()).transaction(w, "readwrite"), r = i.objectStore(w), a = await r.get(n), c = t(a);
|
|
156
|
+
return c === void 0 ? await r.delete(n) : await r.put(c, n), await i.done, c && (!a || a.fid !== c.fid) && fe(e, c.fid), c;
|
|
157
|
+
}
|
|
158
|
+
async function F(e) {
|
|
159
|
+
let t;
|
|
160
|
+
const n = await S(e.appConfig, (o) => {
|
|
161
|
+
const i = Ge(o), r = Je(e, i);
|
|
162
|
+
return t = r.registrationPromise, r.installationEntry;
|
|
163
|
+
});
|
|
164
|
+
return n.fid === D ? { installationEntry: await t } : {
|
|
165
|
+
installationEntry: n,
|
|
166
|
+
registrationPromise: t
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function Ge(e) {
|
|
170
|
+
const t = e || {
|
|
171
|
+
fid: Le(),
|
|
172
|
+
registrationStatus: 0
|
|
173
|
+
/* RequestStatus.NOT_STARTED */
|
|
174
|
+
};
|
|
175
|
+
return ge(t);
|
|
176
|
+
}
|
|
177
|
+
function Je(e, t) {
|
|
178
|
+
if (t.registrationStatus === 0) {
|
|
179
|
+
if (!navigator.onLine) {
|
|
180
|
+
const i = Promise.reject(g.create(
|
|
181
|
+
"app-offline"
|
|
182
|
+
/* ErrorCode.APP_OFFLINE */
|
|
183
|
+
));
|
|
184
|
+
return {
|
|
185
|
+
installationEntry: t,
|
|
186
|
+
registrationPromise: i
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const n = {
|
|
190
|
+
fid: t.fid,
|
|
191
|
+
registrationStatus: 1,
|
|
192
|
+
registrationTime: Date.now()
|
|
193
|
+
}, o = Ye(e, n);
|
|
194
|
+
return { installationEntry: n, registrationPromise: o };
|
|
195
|
+
} else return t.registrationStatus === 1 ? {
|
|
196
|
+
installationEntry: t,
|
|
197
|
+
registrationPromise: ze(e)
|
|
198
|
+
} : { installationEntry: t };
|
|
199
|
+
}
|
|
200
|
+
async function Ye(e, t) {
|
|
201
|
+
try {
|
|
202
|
+
const n = await $e(e, t);
|
|
203
|
+
return k(e.appConfig, n);
|
|
204
|
+
} catch (n) {
|
|
205
|
+
throw oe(n) && n.customData.serverCode === 409 ? await le(e.appConfig) : await k(e.appConfig, {
|
|
206
|
+
fid: t.fid,
|
|
207
|
+
registrationStatus: 0
|
|
208
|
+
/* RequestStatus.NOT_STARTED */
|
|
209
|
+
}), n;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async function ze(e) {
|
|
213
|
+
let t = await B(e.appConfig);
|
|
214
|
+
for (; t.registrationStatus === 1; )
|
|
215
|
+
await ue(100), t = await B(e.appConfig);
|
|
216
|
+
if (t.registrationStatus === 0) {
|
|
217
|
+
const { installationEntry: n, registrationPromise: o } = await F(e);
|
|
218
|
+
return o || n;
|
|
219
|
+
}
|
|
220
|
+
return t;
|
|
221
|
+
}
|
|
222
|
+
function B(e) {
|
|
223
|
+
return S(e, (t) => {
|
|
224
|
+
if (!t)
|
|
225
|
+
throw g.create(
|
|
226
|
+
"installation-not-found"
|
|
227
|
+
/* ErrorCode.INSTALLATION_NOT_FOUND */
|
|
228
|
+
);
|
|
229
|
+
return ge(t);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function ge(e) {
|
|
233
|
+
return Xe(e) ? {
|
|
234
|
+
fid: e.fid,
|
|
235
|
+
registrationStatus: 0
|
|
236
|
+
/* RequestStatus.NOT_STARTED */
|
|
237
|
+
} : e;
|
|
238
|
+
}
|
|
239
|
+
function Xe(e) {
|
|
240
|
+
return e.registrationStatus === 1 && e.registrationTime + ee < Date.now();
|
|
241
|
+
}
|
|
242
|
+
async function Qe({ appConfig: e, heartbeatServiceProvider: t }, n) {
|
|
243
|
+
const o = Ze(e, n), i = Pe(e, n), r = t.getImmediate({
|
|
244
|
+
optional: !0
|
|
245
|
+
});
|
|
246
|
+
if (r) {
|
|
247
|
+
const d = await r.getHeartbeatsHeader();
|
|
248
|
+
d && i.append("x-firebase-client", d);
|
|
249
|
+
}
|
|
250
|
+
const a = {
|
|
251
|
+
installation: {
|
|
252
|
+
sdkVersion: te,
|
|
253
|
+
appId: e.appId
|
|
254
|
+
}
|
|
255
|
+
}, c = {
|
|
256
|
+
method: "POST",
|
|
257
|
+
headers: i,
|
|
258
|
+
body: JSON.stringify(a)
|
|
259
|
+
}, f = await ce(() => fetch(o, c));
|
|
260
|
+
if (f.ok) {
|
|
261
|
+
const d = await f.json();
|
|
262
|
+
return re(d);
|
|
263
|
+
} else
|
|
264
|
+
throw await ae("Generate Auth Token", f);
|
|
265
|
+
}
|
|
266
|
+
function Ze(e, { fid: t }) {
|
|
267
|
+
return `${ie(e)}/${t}/authTokens:generate`;
|
|
268
|
+
}
|
|
269
|
+
async function $(e, t = !1) {
|
|
270
|
+
let n;
|
|
271
|
+
const o = await S(e.appConfig, (r) => {
|
|
272
|
+
if (!we(r))
|
|
273
|
+
throw g.create(
|
|
274
|
+
"not-registered"
|
|
275
|
+
/* ErrorCode.NOT_REGISTERED */
|
|
276
|
+
);
|
|
277
|
+
const a = r.authToken;
|
|
278
|
+
if (!t && nt(a))
|
|
279
|
+
return r;
|
|
280
|
+
if (a.requestStatus === 1)
|
|
281
|
+
return n = et(e, t), r;
|
|
282
|
+
{
|
|
283
|
+
if (!navigator.onLine)
|
|
284
|
+
throw g.create(
|
|
285
|
+
"app-offline"
|
|
286
|
+
/* ErrorCode.APP_OFFLINE */
|
|
287
|
+
);
|
|
288
|
+
const c = it(r);
|
|
289
|
+
return n = tt(e, c), c;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return n ? await n : o.authToken;
|
|
293
|
+
}
|
|
294
|
+
async function et(e, t) {
|
|
295
|
+
let n = await H(e.appConfig);
|
|
296
|
+
for (; n.authToken.requestStatus === 1; )
|
|
297
|
+
await ue(100), n = await H(e.appConfig);
|
|
298
|
+
const o = n.authToken;
|
|
299
|
+
return o.requestStatus === 0 ? $(e, t) : o;
|
|
300
|
+
}
|
|
301
|
+
function H(e) {
|
|
302
|
+
return S(e, (t) => {
|
|
303
|
+
if (!we(t))
|
|
304
|
+
throw g.create(
|
|
305
|
+
"not-registered"
|
|
306
|
+
/* ErrorCode.NOT_REGISTERED */
|
|
307
|
+
);
|
|
308
|
+
const n = t.authToken;
|
|
309
|
+
return rt(n) ? Object.assign(Object.assign({}, t), { authToken: {
|
|
310
|
+
requestStatus: 0
|
|
311
|
+
/* RequestStatus.NOT_STARTED */
|
|
312
|
+
} }) : t;
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
async function tt(e, t) {
|
|
316
|
+
try {
|
|
317
|
+
const n = await Qe(e, t), o = Object.assign(Object.assign({}, t), { authToken: n });
|
|
318
|
+
return await k(e.appConfig, o), n;
|
|
319
|
+
} catch (n) {
|
|
320
|
+
if (oe(n) && (n.customData.serverCode === 401 || n.customData.serverCode === 404))
|
|
321
|
+
await le(e.appConfig);
|
|
322
|
+
else {
|
|
323
|
+
const o = Object.assign(Object.assign({}, t), { authToken: {
|
|
324
|
+
requestStatus: 0
|
|
325
|
+
/* RequestStatus.NOT_STARTED */
|
|
326
|
+
} });
|
|
327
|
+
await k(e.appConfig, o);
|
|
328
|
+
}
|
|
329
|
+
throw n;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function we(e) {
|
|
333
|
+
return e !== void 0 && e.registrationStatus === 2;
|
|
334
|
+
}
|
|
335
|
+
function nt(e) {
|
|
336
|
+
return e.requestStatus === 2 && !ot(e);
|
|
337
|
+
}
|
|
338
|
+
function ot(e) {
|
|
339
|
+
const t = Date.now();
|
|
340
|
+
return t < e.creationTime || e.creationTime + e.expiresIn < t + Ne;
|
|
341
|
+
}
|
|
342
|
+
function it(e) {
|
|
343
|
+
const t = {
|
|
344
|
+
requestStatus: 1,
|
|
345
|
+
requestTime: Date.now()
|
|
346
|
+
};
|
|
347
|
+
return Object.assign(Object.assign({}, e), { authToken: t });
|
|
348
|
+
}
|
|
349
|
+
function rt(e) {
|
|
350
|
+
return e.requestStatus === 1 && e.requestTime + ee < Date.now();
|
|
351
|
+
}
|
|
352
|
+
async function at(e) {
|
|
353
|
+
const t = e, { installationEntry: n, registrationPromise: o } = await F(t);
|
|
354
|
+
return o ? o.catch(console.error) : $(t).catch(console.error), n.fid;
|
|
355
|
+
}
|
|
356
|
+
async function st(e, t = !1) {
|
|
357
|
+
const n = e;
|
|
358
|
+
return await ct(n), (await $(n, t)).token;
|
|
359
|
+
}
|
|
360
|
+
async function ct(e) {
|
|
361
|
+
const { registrationPromise: t } = await F(e);
|
|
362
|
+
t && await t;
|
|
363
|
+
}
|
|
364
|
+
function ut(e) {
|
|
365
|
+
if (!e || !e.options)
|
|
366
|
+
throw _("App Configuration");
|
|
367
|
+
if (!e.name)
|
|
368
|
+
throw _("App Name");
|
|
369
|
+
const t = [
|
|
370
|
+
"projectId",
|
|
371
|
+
"apiKey",
|
|
372
|
+
"appId"
|
|
373
|
+
];
|
|
374
|
+
for (const n of t)
|
|
375
|
+
if (!e.options[n])
|
|
376
|
+
throw _(n);
|
|
377
|
+
return {
|
|
378
|
+
appName: e.name,
|
|
379
|
+
projectId: e.options.projectId,
|
|
380
|
+
apiKey: e.options.apiKey,
|
|
381
|
+
appId: e.options.appId
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function _(e) {
|
|
385
|
+
return g.create("missing-app-config-values", {
|
|
386
|
+
valueName: e
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
const he = "installations", dt = "installations-internal", ft = (e) => {
|
|
390
|
+
const t = e.getProvider("app").getImmediate(), n = ut(t), o = R(t, "heartbeat");
|
|
391
|
+
return {
|
|
392
|
+
app: t,
|
|
393
|
+
appConfig: n,
|
|
394
|
+
heartbeatServiceProvider: o,
|
|
395
|
+
_delete: () => Promise.resolve()
|
|
396
|
+
};
|
|
397
|
+
}, pt = (e) => {
|
|
398
|
+
const t = e.getProvider("app").getImmediate(), n = R(t, he).getImmediate();
|
|
399
|
+
return {
|
|
400
|
+
getId: () => at(n),
|
|
401
|
+
getToken: (i) => st(n, i)
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
function lt() {
|
|
405
|
+
y(new T(
|
|
406
|
+
he,
|
|
407
|
+
ft,
|
|
408
|
+
"PUBLIC"
|
|
409
|
+
/* ComponentType.PUBLIC */
|
|
410
|
+
)), y(new T(
|
|
411
|
+
dt,
|
|
412
|
+
pt,
|
|
413
|
+
"PRIVATE"
|
|
414
|
+
/* ComponentType.PRIVATE */
|
|
415
|
+
));
|
|
416
|
+
}
|
|
417
|
+
lt();
|
|
418
|
+
m(Z, P);
|
|
419
|
+
m(Z, P, "esm2017");
|
|
420
|
+
const gt = "/firebase-messaging-sw.js", wt = "/firebase-cloud-messaging-push-scope", be = "BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4", ht = "https://fcmregistrations.googleapis.com/v1", me = "google.c.a.c_id", bt = "google.c.a.c_l", mt = "google.c.a.ts", yt = "google.c.a.e", W = 1e4;
|
|
421
|
+
var U;
|
|
422
|
+
(function(e) {
|
|
423
|
+
e[e.DATA_MESSAGE = 1] = "DATA_MESSAGE", e[e.DISPLAY_NOTIFICATION = 3] = "DISPLAY_NOTIFICATION";
|
|
424
|
+
})(U || (U = {}));
|
|
425
|
+
var b;
|
|
426
|
+
(function(e) {
|
|
427
|
+
e.PUSH_RECEIVED = "push-received", e.NOTIFICATION_CLICKED = "notification-clicked";
|
|
428
|
+
})(b || (b = {}));
|
|
429
|
+
function p(e) {
|
|
430
|
+
const t = new Uint8Array(e);
|
|
431
|
+
return btoa(String.fromCharCode(...t)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
432
|
+
}
|
|
433
|
+
function Tt(e) {
|
|
434
|
+
const t = "=".repeat((4 - e.length % 4) % 4), n = (e + t).replace(/\-/g, "+").replace(/_/g, "/"), o = atob(n), i = new Uint8Array(o.length);
|
|
435
|
+
for (let r = 0; r < o.length; ++r)
|
|
436
|
+
i[r] = o.charCodeAt(r);
|
|
437
|
+
return i;
|
|
438
|
+
}
|
|
439
|
+
const O = "fcm_token_details_db", kt = 5, G = "fcm_token_object_Store";
|
|
440
|
+
async function It(e) {
|
|
441
|
+
if ("databases" in indexedDB && !(await indexedDB.databases()).map((r) => r.name).includes(O))
|
|
442
|
+
return null;
|
|
443
|
+
let t = null;
|
|
444
|
+
return (await M(O, kt, {
|
|
445
|
+
upgrade: async (o, i, r, a) => {
|
|
446
|
+
var c;
|
|
447
|
+
if (i < 2 || !o.objectStoreNames.contains(G))
|
|
448
|
+
return;
|
|
449
|
+
const f = a.objectStore(G), d = await f.index("fcmSenderId").get(e);
|
|
450
|
+
if (await f.clear(), !!d) {
|
|
451
|
+
if (i === 2) {
|
|
452
|
+
const s = d;
|
|
453
|
+
if (!s.auth || !s.p256dh || !s.endpoint)
|
|
454
|
+
return;
|
|
455
|
+
t = {
|
|
456
|
+
token: s.fcmToken,
|
|
457
|
+
createTime: (c = s.createTime) !== null && c !== void 0 ? c : Date.now(),
|
|
458
|
+
subscriptionOptions: {
|
|
459
|
+
auth: s.auth,
|
|
460
|
+
p256dh: s.p256dh,
|
|
461
|
+
endpoint: s.endpoint,
|
|
462
|
+
swScope: s.swScope,
|
|
463
|
+
vapidKey: typeof s.vapidKey == "string" ? s.vapidKey : p(s.vapidKey)
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
} else if (i === 3) {
|
|
467
|
+
const s = d;
|
|
468
|
+
t = {
|
|
469
|
+
token: s.fcmToken,
|
|
470
|
+
createTime: s.createTime,
|
|
471
|
+
subscriptionOptions: {
|
|
472
|
+
auth: p(s.auth),
|
|
473
|
+
p256dh: p(s.p256dh),
|
|
474
|
+
endpoint: s.endpoint,
|
|
475
|
+
swScope: s.swScope,
|
|
476
|
+
vapidKey: p(s.vapidKey)
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
} else if (i === 4) {
|
|
480
|
+
const s = d;
|
|
481
|
+
t = {
|
|
482
|
+
token: s.fcmToken,
|
|
483
|
+
createTime: s.createTime,
|
|
484
|
+
subscriptionOptions: {
|
|
485
|
+
auth: p(s.auth),
|
|
486
|
+
p256dh: p(s.p256dh),
|
|
487
|
+
endpoint: s.endpoint,
|
|
488
|
+
swScope: s.swScope,
|
|
489
|
+
vapidKey: p(s.vapidKey)
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
})).close(), await A(O), await A("fcm_vapid_details_db"), await A("undefined"), vt(t) ? t : null;
|
|
496
|
+
}
|
|
497
|
+
function vt(e) {
|
|
498
|
+
if (!e || !e.subscriptionOptions)
|
|
499
|
+
return !1;
|
|
500
|
+
const { subscriptionOptions: t } = e;
|
|
501
|
+
return typeof e.createTime == "number" && e.createTime > 0 && typeof e.token == "string" && e.token.length > 0 && typeof t.auth == "string" && t.auth.length > 0 && typeof t.p256dh == "string" && t.p256dh.length > 0 && typeof t.endpoint == "string" && t.endpoint.length > 0 && typeof t.swScope == "string" && t.swScope.length > 0 && typeof t.vapidKey == "string" && t.vapidKey.length > 0;
|
|
502
|
+
}
|
|
503
|
+
const St = "firebase-messaging-database", At = 1, h = "firebase-messaging-store";
|
|
504
|
+
let C = null;
|
|
505
|
+
function K() {
|
|
506
|
+
return C || (C = M(St, At, {
|
|
507
|
+
upgrade: (e, t) => {
|
|
508
|
+
t === 0 && e.createObjectStore(h);
|
|
509
|
+
}
|
|
510
|
+
})), C;
|
|
511
|
+
}
|
|
512
|
+
async function ye(e) {
|
|
513
|
+
const t = L(e), o = await (await K()).transaction(h).objectStore(h).get(t);
|
|
514
|
+
if (o)
|
|
515
|
+
return o;
|
|
516
|
+
{
|
|
517
|
+
const i = await It(e.appConfig.senderId);
|
|
518
|
+
if (i)
|
|
519
|
+
return await q(e, i), i;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
async function q(e, t) {
|
|
523
|
+
const n = L(e), i = (await K()).transaction(h, "readwrite");
|
|
524
|
+
return await i.objectStore(h).put(t, n), await i.done, t;
|
|
525
|
+
}
|
|
526
|
+
async function Et(e) {
|
|
527
|
+
const t = L(e), o = (await K()).transaction(h, "readwrite");
|
|
528
|
+
await o.objectStore(h).delete(t), await o.done;
|
|
529
|
+
}
|
|
530
|
+
function L({ appConfig: e }) {
|
|
531
|
+
return e.appId;
|
|
532
|
+
}
|
|
533
|
+
const _t = {
|
|
534
|
+
"missing-app-config-values": 'Missing App configuration value: "{$valueName}"',
|
|
535
|
+
"only-available-in-window": "This method is available in a Window context.",
|
|
536
|
+
"only-available-in-sw": "This method is available in a service worker context.",
|
|
537
|
+
"permission-default": "The notification permission was not granted and dismissed instead.",
|
|
538
|
+
"permission-blocked": "The notification permission was not granted and blocked instead.",
|
|
539
|
+
"unsupported-browser": "This browser doesn't support the API's required to use the Firebase SDK.",
|
|
540
|
+
"indexed-db-unsupported": "This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)",
|
|
541
|
+
"failed-service-worker-registration": "We are unable to register the default service worker. {$browserErrorMessage}",
|
|
542
|
+
"token-subscribe-failed": "A problem occurred while subscribing the user to FCM: {$errorInfo}",
|
|
543
|
+
"token-subscribe-no-token": "FCM returned no token when subscribing the user to push.",
|
|
544
|
+
"token-unsubscribe-failed": "A problem occurred while unsubscribing the user from FCM: {$errorInfo}",
|
|
545
|
+
"token-update-failed": "A problem occurred while updating the user from FCM: {$errorInfo}",
|
|
546
|
+
"token-update-no-token": "FCM returned no token when updating the user to push.",
|
|
547
|
+
"use-sw-after-get-token": "The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.",
|
|
548
|
+
"invalid-sw-registration": "The input to useServiceWorker() must be a ServiceWorkerRegistration.",
|
|
549
|
+
"invalid-bg-handler": "The input to setBackgroundMessageHandler() must be a function.",
|
|
550
|
+
"invalid-vapid-key": "The public VAPID key must be a string.",
|
|
551
|
+
"use-vapid-key-after-get-token": "The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."
|
|
552
|
+
}, u = new Q("messaging", "Messaging", _t);
|
|
553
|
+
async function Ot(e, t) {
|
|
554
|
+
const n = await V(e), o = ke(t), i = {
|
|
555
|
+
method: "POST",
|
|
556
|
+
headers: n,
|
|
557
|
+
body: JSON.stringify(o)
|
|
558
|
+
};
|
|
559
|
+
let r;
|
|
560
|
+
try {
|
|
561
|
+
r = await (await fetch(x(e.appConfig), i)).json();
|
|
562
|
+
} catch (a) {
|
|
563
|
+
throw u.create("token-subscribe-failed", {
|
|
564
|
+
errorInfo: a?.toString()
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
if (r.error) {
|
|
568
|
+
const a = r.error.message;
|
|
569
|
+
throw u.create("token-subscribe-failed", {
|
|
570
|
+
errorInfo: a
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
if (!r.token)
|
|
574
|
+
throw u.create(
|
|
575
|
+
"token-subscribe-no-token"
|
|
576
|
+
/* ErrorCode.TOKEN_SUBSCRIBE_NO_TOKEN */
|
|
577
|
+
);
|
|
578
|
+
return r.token;
|
|
579
|
+
}
|
|
580
|
+
async function Ct(e, t) {
|
|
581
|
+
const n = await V(e), o = ke(t.subscriptionOptions), i = {
|
|
582
|
+
method: "PATCH",
|
|
583
|
+
headers: n,
|
|
584
|
+
body: JSON.stringify(o)
|
|
585
|
+
};
|
|
586
|
+
let r;
|
|
587
|
+
try {
|
|
588
|
+
r = await (await fetch(`${x(e.appConfig)}/${t.token}`, i)).json();
|
|
589
|
+
} catch (a) {
|
|
590
|
+
throw u.create("token-update-failed", {
|
|
591
|
+
errorInfo: a?.toString()
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
if (r.error) {
|
|
595
|
+
const a = r.error.message;
|
|
596
|
+
throw u.create("token-update-failed", {
|
|
597
|
+
errorInfo: a
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
if (!r.token)
|
|
601
|
+
throw u.create(
|
|
602
|
+
"token-update-no-token"
|
|
603
|
+
/* ErrorCode.TOKEN_UPDATE_NO_TOKEN */
|
|
604
|
+
);
|
|
605
|
+
return r.token;
|
|
606
|
+
}
|
|
607
|
+
async function Te(e, t) {
|
|
608
|
+
const o = {
|
|
609
|
+
method: "DELETE",
|
|
610
|
+
headers: await V(e)
|
|
611
|
+
};
|
|
612
|
+
try {
|
|
613
|
+
const r = await (await fetch(`${x(e.appConfig)}/${t}`, o)).json();
|
|
614
|
+
if (r.error) {
|
|
615
|
+
const a = r.error.message;
|
|
616
|
+
throw u.create("token-unsubscribe-failed", {
|
|
617
|
+
errorInfo: a
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
} catch (i) {
|
|
621
|
+
throw u.create("token-unsubscribe-failed", {
|
|
622
|
+
errorInfo: i?.toString()
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function x({ projectId: e }) {
|
|
627
|
+
return `${ht}/projects/${e}/registrations`;
|
|
628
|
+
}
|
|
629
|
+
async function V({ appConfig: e, installations: t }) {
|
|
630
|
+
const n = await t.getToken();
|
|
631
|
+
return new Headers({
|
|
632
|
+
"Content-Type": "application/json",
|
|
633
|
+
Accept: "application/json",
|
|
634
|
+
"x-goog-api-key": e.apiKey,
|
|
635
|
+
"x-goog-firebase-installations-auth": `FIS ${n}`
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
function ke({ p256dh: e, auth: t, endpoint: n, vapidKey: o }) {
|
|
639
|
+
const i = {
|
|
640
|
+
web: {
|
|
641
|
+
endpoint: n,
|
|
642
|
+
auth: t,
|
|
643
|
+
p256dh: e
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
return o !== be && (i.web.applicationPubKey = o), i;
|
|
647
|
+
}
|
|
648
|
+
const Nt = 10080 * 60 * 1e3;
|
|
649
|
+
async function Dt(e) {
|
|
650
|
+
const t = await Pt(e.swRegistration, e.vapidKey), n = {
|
|
651
|
+
vapidKey: e.vapidKey,
|
|
652
|
+
swScope: e.swRegistration.scope,
|
|
653
|
+
endpoint: t.endpoint,
|
|
654
|
+
auth: p(t.getKey("auth")),
|
|
655
|
+
p256dh: p(t.getKey("p256dh"))
|
|
656
|
+
}, o = await ye(e.firebaseDependencies);
|
|
657
|
+
if (o) {
|
|
658
|
+
if (jt(o.subscriptionOptions, n))
|
|
659
|
+
return Date.now() >= o.createTime + Nt ? Mt(e, {
|
|
660
|
+
token: o.token,
|
|
661
|
+
createTime: Date.now(),
|
|
662
|
+
subscriptionOptions: n
|
|
663
|
+
}) : o.token;
|
|
664
|
+
try {
|
|
665
|
+
await Te(e.firebaseDependencies, o.token);
|
|
666
|
+
} catch (i) {
|
|
667
|
+
console.warn(i);
|
|
668
|
+
}
|
|
669
|
+
return J(e.firebaseDependencies, n);
|
|
670
|
+
} else return J(e.firebaseDependencies, n);
|
|
671
|
+
}
|
|
672
|
+
async function Rt(e) {
|
|
673
|
+
const t = await ye(e.firebaseDependencies);
|
|
674
|
+
t && (await Te(e.firebaseDependencies, t.token), await Et(e.firebaseDependencies));
|
|
675
|
+
const n = await e.swRegistration.pushManager.getSubscription();
|
|
676
|
+
return n ? n.unsubscribe() : !0;
|
|
677
|
+
}
|
|
678
|
+
async function Mt(e, t) {
|
|
679
|
+
try {
|
|
680
|
+
const n = await Ct(e.firebaseDependencies, t), o = Object.assign(Object.assign({}, t), { token: n, createTime: Date.now() });
|
|
681
|
+
return await q(e.firebaseDependencies, o), n;
|
|
682
|
+
} catch (n) {
|
|
683
|
+
throw n;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
async function J(e, t) {
|
|
687
|
+
const o = {
|
|
688
|
+
token: await Ot(e, t),
|
|
689
|
+
createTime: Date.now(),
|
|
690
|
+
subscriptionOptions: t
|
|
691
|
+
};
|
|
692
|
+
return await q(e, o), o.token;
|
|
693
|
+
}
|
|
694
|
+
async function Pt(e, t) {
|
|
695
|
+
const n = await e.pushManager.getSubscription();
|
|
696
|
+
return n || e.pushManager.subscribe({
|
|
697
|
+
userVisibleOnly: !0,
|
|
698
|
+
// Chrome <= 75 doesn't support base64-encoded VAPID key. For backward compatibility, VAPID key
|
|
699
|
+
// submitted to pushManager#subscribe must be of type Uint8Array.
|
|
700
|
+
applicationServerKey: Tt(t)
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
function jt(e, t) {
|
|
704
|
+
const n = t.vapidKey === e.vapidKey, o = t.endpoint === e.endpoint, i = t.auth === e.auth, r = t.p256dh === e.p256dh;
|
|
705
|
+
return n && o && i && r;
|
|
706
|
+
}
|
|
707
|
+
function Y(e) {
|
|
708
|
+
const t = {
|
|
709
|
+
from: e.from,
|
|
710
|
+
// eslint-disable-next-line camelcase
|
|
711
|
+
collapseKey: e.collapse_key,
|
|
712
|
+
// eslint-disable-next-line camelcase
|
|
713
|
+
messageId: e.fcmMessageId
|
|
714
|
+
};
|
|
715
|
+
return Ft(t, e), $t(t, e), Kt(t, e), t;
|
|
716
|
+
}
|
|
717
|
+
function Ft(e, t) {
|
|
718
|
+
if (!t.notification)
|
|
719
|
+
return;
|
|
720
|
+
e.notification = {};
|
|
721
|
+
const n = t.notification.title;
|
|
722
|
+
n && (e.notification.title = n);
|
|
723
|
+
const o = t.notification.body;
|
|
724
|
+
o && (e.notification.body = o);
|
|
725
|
+
const i = t.notification.image;
|
|
726
|
+
i && (e.notification.image = i);
|
|
727
|
+
const r = t.notification.icon;
|
|
728
|
+
r && (e.notification.icon = r);
|
|
729
|
+
}
|
|
730
|
+
function $t(e, t) {
|
|
731
|
+
t.data && (e.data = t.data);
|
|
732
|
+
}
|
|
733
|
+
function Kt(e, t) {
|
|
734
|
+
var n, o, i, r, a;
|
|
735
|
+
if (!t.fcmOptions && !(!((n = t.notification) === null || n === void 0) && n.click_action))
|
|
736
|
+
return;
|
|
737
|
+
e.fcmOptions = {};
|
|
738
|
+
const c = (i = (o = t.fcmOptions) === null || o === void 0 ? void 0 : o.link) !== null && i !== void 0 ? i : (r = t.notification) === null || r === void 0 ? void 0 : r.click_action;
|
|
739
|
+
c && (e.fcmOptions.link = c);
|
|
740
|
+
const f = (a = t.fcmOptions) === null || a === void 0 ? void 0 : a.analytics_label;
|
|
741
|
+
f && (e.fcmOptions.analyticsLabel = f);
|
|
742
|
+
}
|
|
743
|
+
function qt(e) {
|
|
744
|
+
return typeof e == "object" && !!e && me in e;
|
|
745
|
+
}
|
|
746
|
+
function Lt(e) {
|
|
747
|
+
if (!e || !e.options)
|
|
748
|
+
throw N("App Configuration Object");
|
|
749
|
+
if (!e.name)
|
|
750
|
+
throw N("App Name");
|
|
751
|
+
const t = [
|
|
752
|
+
"projectId",
|
|
753
|
+
"apiKey",
|
|
754
|
+
"appId",
|
|
755
|
+
"messagingSenderId"
|
|
756
|
+
], { options: n } = e;
|
|
757
|
+
for (const o of t)
|
|
758
|
+
if (!n[o])
|
|
759
|
+
throw N(o);
|
|
760
|
+
return {
|
|
761
|
+
appName: e.name,
|
|
762
|
+
projectId: n.projectId,
|
|
763
|
+
apiKey: n.apiKey,
|
|
764
|
+
appId: n.appId,
|
|
765
|
+
senderId: n.messagingSenderId
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function N(e) {
|
|
769
|
+
return u.create("missing-app-config-values", {
|
|
770
|
+
valueName: e
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
class xt {
|
|
774
|
+
constructor(t, n, o) {
|
|
775
|
+
this.deliveryMetricsExportedToBigQueryEnabled = !1, this.onBackgroundMessageHandler = null, this.onMessageHandler = null, this.logEvents = [], this.isLogServiceStarted = !1;
|
|
776
|
+
const i = Lt(t);
|
|
777
|
+
this.firebaseDependencies = {
|
|
778
|
+
app: t,
|
|
779
|
+
appConfig: i,
|
|
780
|
+
installations: n,
|
|
781
|
+
analyticsProvider: o
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
_delete() {
|
|
785
|
+
return Promise.resolve();
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
async function Ie(e) {
|
|
789
|
+
try {
|
|
790
|
+
e.swRegistration = await navigator.serviceWorker.register(gt, {
|
|
791
|
+
scope: wt
|
|
792
|
+
}), e.swRegistration.update().catch(() => {
|
|
793
|
+
}), await Vt(e.swRegistration);
|
|
794
|
+
} catch (t) {
|
|
795
|
+
throw u.create("failed-service-worker-registration", {
|
|
796
|
+
browserErrorMessage: t?.message
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
async function Vt(e) {
|
|
801
|
+
return new Promise((t, n) => {
|
|
802
|
+
const o = setTimeout(() => n(new Error(`Service worker not registered after ${W} ms`)), W), i = e.installing || e.waiting;
|
|
803
|
+
e.active ? (clearTimeout(o), t()) : i ? i.onstatechange = (r) => {
|
|
804
|
+
var a;
|
|
805
|
+
((a = r.target) === null || a === void 0 ? void 0 : a.state) === "activated" && (i.onstatechange = null, clearTimeout(o), t());
|
|
806
|
+
} : (clearTimeout(o), n(new Error("No incoming service worker found.")));
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
async function Bt(e, t) {
|
|
810
|
+
if (!t && !e.swRegistration && await Ie(e), !(!t && e.swRegistration)) {
|
|
811
|
+
if (!(t instanceof ServiceWorkerRegistration))
|
|
812
|
+
throw u.create(
|
|
813
|
+
"invalid-sw-registration"
|
|
814
|
+
/* ErrorCode.INVALID_SW_REGISTRATION */
|
|
815
|
+
);
|
|
816
|
+
e.swRegistration = t;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async function Ht(e, t) {
|
|
820
|
+
t ? e.vapidKey = t : e.vapidKey || (e.vapidKey = be);
|
|
821
|
+
}
|
|
822
|
+
async function ve(e, t) {
|
|
823
|
+
if (!navigator)
|
|
824
|
+
throw u.create(
|
|
825
|
+
"only-available-in-window"
|
|
826
|
+
/* ErrorCode.AVAILABLE_IN_WINDOW */
|
|
827
|
+
);
|
|
828
|
+
if (Notification.permission === "default" && await Notification.requestPermission(), Notification.permission !== "granted")
|
|
829
|
+
throw u.create(
|
|
830
|
+
"permission-blocked"
|
|
831
|
+
/* ErrorCode.PERMISSION_BLOCKED */
|
|
832
|
+
);
|
|
833
|
+
return await Ht(e, t?.vapidKey), await Bt(e, t?.serviceWorkerRegistration), Dt(e);
|
|
834
|
+
}
|
|
835
|
+
async function Wt(e, t, n) {
|
|
836
|
+
const o = Ut(t);
|
|
837
|
+
(await e.firebaseDependencies.analyticsProvider.get()).logEvent(o, {
|
|
838
|
+
/* eslint-disable camelcase */
|
|
839
|
+
message_id: n[me],
|
|
840
|
+
message_name: n[bt],
|
|
841
|
+
message_time: n[mt],
|
|
842
|
+
message_device_time: Math.floor(Date.now() / 1e3)
|
|
843
|
+
/* eslint-enable camelcase */
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
function Ut(e) {
|
|
847
|
+
switch (e) {
|
|
848
|
+
case b.NOTIFICATION_CLICKED:
|
|
849
|
+
return "notification_open";
|
|
850
|
+
case b.PUSH_RECEIVED:
|
|
851
|
+
return "notification_foreground";
|
|
852
|
+
default:
|
|
853
|
+
throw new Error();
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
async function Gt(e, t) {
|
|
857
|
+
const n = t.data;
|
|
858
|
+
if (!n.isFirebaseMessaging)
|
|
859
|
+
return;
|
|
860
|
+
e.onMessageHandler && n.messageType === b.PUSH_RECEIVED && (typeof e.onMessageHandler == "function" ? e.onMessageHandler(Y(n)) : e.onMessageHandler.next(Y(n)));
|
|
861
|
+
const o = n.data;
|
|
862
|
+
qt(o) && o[yt] === "1" && await Wt(e, n.messageType, o);
|
|
863
|
+
}
|
|
864
|
+
const z = "@firebase/messaging", X = "0.12.21";
|
|
865
|
+
const Jt = (e) => {
|
|
866
|
+
const t = new xt(e.getProvider("app").getImmediate(), e.getProvider("installations-internal").getImmediate(), e.getProvider("analytics-internal"));
|
|
867
|
+
return navigator.serviceWorker.addEventListener("message", (n) => Gt(t, n)), t;
|
|
868
|
+
}, Yt = (e) => {
|
|
869
|
+
const t = e.getProvider("messaging").getImmediate();
|
|
870
|
+
return {
|
|
871
|
+
getToken: (o) => ve(t, o)
|
|
872
|
+
};
|
|
873
|
+
};
|
|
874
|
+
function zt() {
|
|
875
|
+
y(new T(
|
|
876
|
+
"messaging",
|
|
877
|
+
Jt,
|
|
878
|
+
"PUBLIC"
|
|
879
|
+
/* ComponentType.PUBLIC */
|
|
880
|
+
)), y(new T(
|
|
881
|
+
"messaging-internal",
|
|
882
|
+
Yt,
|
|
883
|
+
"PRIVATE"
|
|
884
|
+
/* ComponentType.PRIVATE */
|
|
885
|
+
)), m(z, X), m(z, X, "esm2017");
|
|
886
|
+
}
|
|
887
|
+
async function Xt() {
|
|
888
|
+
try {
|
|
889
|
+
await Ee();
|
|
890
|
+
} catch {
|
|
891
|
+
return !1;
|
|
892
|
+
}
|
|
893
|
+
return typeof window < "u" && _e() && Oe() && "serviceWorker" in navigator && "PushManager" in window && "Notification" in window && "fetch" in window && ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification") && PushSubscription.prototype.hasOwnProperty("getKey");
|
|
894
|
+
}
|
|
895
|
+
async function Qt(e) {
|
|
896
|
+
if (!navigator)
|
|
897
|
+
throw u.create(
|
|
898
|
+
"only-available-in-window"
|
|
899
|
+
/* ErrorCode.AVAILABLE_IN_WINDOW */
|
|
900
|
+
);
|
|
901
|
+
return e.swRegistration || await Ie(e), Rt(e);
|
|
902
|
+
}
|
|
903
|
+
function Zt(e, t) {
|
|
904
|
+
if (!navigator)
|
|
905
|
+
throw u.create(
|
|
906
|
+
"only-available-in-window"
|
|
907
|
+
/* ErrorCode.AVAILABLE_IN_WINDOW */
|
|
908
|
+
);
|
|
909
|
+
return e.onMessageHandler = t, () => {
|
|
910
|
+
e.onMessageHandler = null;
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function tn(e = Ae()) {
|
|
914
|
+
return Xt().then((t) => {
|
|
915
|
+
if (!t)
|
|
916
|
+
throw u.create(
|
|
917
|
+
"unsupported-browser"
|
|
918
|
+
/* ErrorCode.UNSUPPORTED_BROWSER */
|
|
919
|
+
);
|
|
920
|
+
}, (t) => {
|
|
921
|
+
throw u.create(
|
|
922
|
+
"indexed-db-unsupported"
|
|
923
|
+
/* ErrorCode.INDEXED_DB_UNSUPPORTED */
|
|
924
|
+
);
|
|
925
|
+
}), R(I(e), "messaging").getImmediate();
|
|
926
|
+
}
|
|
927
|
+
async function nn(e, t) {
|
|
928
|
+
return e = I(e), ve(e, t);
|
|
929
|
+
}
|
|
930
|
+
function on(e) {
|
|
931
|
+
return e = I(e), Qt(e);
|
|
932
|
+
}
|
|
933
|
+
function rn(e, t) {
|
|
934
|
+
return e = I(e), Zt(e, t);
|
|
935
|
+
}
|
|
936
|
+
zt();
|
|
937
|
+
export {
|
|
938
|
+
on as deleteToken,
|
|
939
|
+
tn as getMessaging,
|
|
940
|
+
nn as getToken,
|
|
941
|
+
Xt as isSupported,
|
|
942
|
+
rn as onMessage
|
|
943
|
+
};
|