@codingfactory/messenger-client 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +775 -738
- package/dist/services/presenceRuntime.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref as de, getCurrentInstance as xt, computed as ie, onUnmounted as qe, toValue as Ln, onMounted as Un, watch as fn } from "vue";
|
|
2
2
|
import { defineStore as ci, storeToRefs as ui } from "pinia";
|
|
3
3
|
import Mt, { isAxiosError as li, AxiosHeaders as pn } from "axios";
|
|
4
|
-
import { isAxiosError as
|
|
4
|
+
import { isAxiosError as $a } from "axios";
|
|
5
5
|
import { useRoute as hi } from "vue-router";
|
|
6
6
|
const On = () => () => {
|
|
7
7
|
}, Nn = async () => {
|
|
@@ -13,7 +13,7 @@ const On = () => () => {
|
|
|
13
13
|
throw new Error("messenger-client subscribeToConversation is not configured");
|
|
14
14
|
}, $n = () => {
|
|
15
15
|
throw new Error("messenger-client subscribeToTyping is not configured");
|
|
16
|
-
},
|
|
16
|
+
}, G = {
|
|
17
17
|
ECHO_INITIALIZED_EVENT: "messenger-client:echo-initialized",
|
|
18
18
|
getEcho: () => null,
|
|
19
19
|
getConnectionStatus: () => "disconnected",
|
|
@@ -25,14 +25,14 @@ const On = () => () => {
|
|
|
25
25
|
unsubscribeFromConversation: qn,
|
|
26
26
|
subscribeToTyping: $n,
|
|
27
27
|
unsubscribeFromTyping: zn
|
|
28
|
-
}, De = () =>
|
|
29
|
-
await
|
|
30
|
-
}, fi = (e) =>
|
|
28
|
+
}, De = () => G.ECHO_INITIALIZED_EVENT, Ae = () => G.getEcho(), Hn = () => G.getConnectionStatus(), xa = () => Hn(), it = (e) => G.onConnectionStatusChange(e), di = async () => {
|
|
29
|
+
await G.reconnect();
|
|
30
|
+
}, fi = (e) => G.subscribeToPresenceStatus(e), pi = () => G.unsubscribeFromPresenceStatus(), gi = (e, n) => G.subscribeToConversation(e, n), mi = (e) => G.unsubscribeFromConversation(e), vi = (e, n) => G.subscribeToTyping(e, n), bi = (e) => G.unsubscribeFromTyping(e);
|
|
31
31
|
function yi(e) {
|
|
32
|
-
e.initializedEvent && (
|
|
32
|
+
e.initializedEvent && (G.ECHO_INITIALIZED_EVENT = e.initializedEvent), e.getEcho && (G.getEcho = e.getEcho), e.getConnectionStatus && (G.getConnectionStatus = e.getConnectionStatus), e.onConnectionStatusChange && (G.onConnectionStatusChange = e.onConnectionStatusChange), e.reconnect && (G.reconnect = e.reconnect), e.subscribeToPresenceStatus && (G.subscribeToPresenceStatus = e.subscribeToPresenceStatus), e.unsubscribeFromPresenceStatus && (G.unsubscribeFromPresenceStatus = e.unsubscribeFromPresenceStatus), e.subscribeToConversation && (G.subscribeToConversation = e.subscribeToConversation), e.unsubscribeFromConversation && (G.unsubscribeFromConversation = e.unsubscribeFromConversation), e.subscribeToTyping && (G.subscribeToTyping = e.subscribeToTyping), e.unsubscribeFromTyping && (G.unsubscribeFromTyping = e.unsubscribeFromTyping);
|
|
33
33
|
}
|
|
34
34
|
function _i() {
|
|
35
|
-
|
|
35
|
+
G.ECHO_INITIALIZED_EVENT = "messenger-client:echo-initialized", G.getEcho = () => null, G.getConnectionStatus = () => "disconnected", G.onConnectionStatusChange = On, G.reconnect = Nn, G.subscribeToPresenceStatus = Fn, G.unsubscribeFromPresenceStatus = Dn, G.subscribeToConversation = jn, G.unsubscribeFromConversation = qn, G.subscribeToTyping = $n, G.unsubscribeFromTyping = zn;
|
|
36
36
|
}
|
|
37
37
|
function tt(e) {
|
|
38
38
|
return typeof e == "object" && e !== null;
|
|
@@ -40,10 +40,10 @@ function tt(e) {
|
|
|
40
40
|
function Si(e) {
|
|
41
41
|
return tt(e) && typeof e.conversation_id == "string" && tt(e.message) && typeof e.message.id == "string" && typeof e.message.conversation_id == "string" && typeof e.message.author_id == "string";
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function wi(e) {
|
|
44
44
|
return tt(e) && typeof e.conversation_id == "string" && typeof e.user_id == "string" && typeof e.message_id == "string";
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function Ci(e) {
|
|
47
47
|
return tt(e) && typeof e.conversation_id == "string";
|
|
48
48
|
}
|
|
49
49
|
const Bn = Mt;
|
|
@@ -70,17 +70,17 @@ function Ri(e) {
|
|
|
70
70
|
function Ai() {
|
|
71
71
|
It = () => Vn;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function Q(e) {
|
|
74
74
|
if (li(e)) {
|
|
75
75
|
const n = e.response?.data?.message || e.message || "An error occurred";
|
|
76
76
|
return n.includes("SQLSTATE") || n.includes("Connection:") || n.includes("\\Illuminate\\") ? "Something went wrong. Please try again later." : n;
|
|
77
77
|
}
|
|
78
78
|
return e instanceof Error ? e.message : typeof e == "string" ? e : typeof e == "object" && e !== null && "message" in e && typeof e.message == "string" ? e.message : "An unexpected error occurred";
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Ma(e) {
|
|
81
81
|
return e instanceof Error;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function ka(e) {
|
|
84
84
|
return typeof e == "object" && e !== null && "response" in e && typeof e.response == "object";
|
|
85
85
|
}
|
|
86
86
|
const Xn = {
|
|
@@ -390,7 +390,7 @@ function he(e) {
|
|
|
390
390
|
function Gi(e) {
|
|
391
391
|
return he(e) ? (he(e.response) ? e.response : null)?.status === 401 : !1;
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function wn(e) {
|
|
394
394
|
if (!Array.isArray(e))
|
|
395
395
|
return [];
|
|
396
396
|
const n = [];
|
|
@@ -424,7 +424,7 @@ function Je(e, n) {
|
|
|
424
424
|
nextCursor: Ji(i, o)
|
|
425
425
|
};
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function Cn(e) {
|
|
428
428
|
return he(e) && typeof e.id == "string" && e.id.length > 0;
|
|
429
429
|
}
|
|
430
430
|
function Tn(e) {
|
|
@@ -454,7 +454,7 @@ function En(e, n) {
|
|
|
454
454
|
};
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function wt(e) {
|
|
458
458
|
const n = /* @__PURE__ */ new Map();
|
|
459
459
|
for (const i of e.requests)
|
|
460
460
|
i.is_request === !0 && n.set(i.id, i);
|
|
@@ -498,9 +498,9 @@ const Nt = ci("messaging", {
|
|
|
498
498
|
hasMoreMessages: (e) => (n) => e.conversationHasMore[n] ?? !1,
|
|
499
499
|
isLoadingMessages: (e) => (n) => e.loadingMessages[n] ?? !1,
|
|
500
500
|
// Message request getters
|
|
501
|
-
requestConversations: (e) =>
|
|
502
|
-
requestCount: (e) =>
|
|
503
|
-
unreadRequestCount: (e) =>
|
|
501
|
+
requestConversations: (e) => wt(e),
|
|
502
|
+
requestCount: (e) => wt(e).length,
|
|
503
|
+
unreadRequestCount: (e) => wt(e).filter((n) => n.unread_count > 0).length
|
|
504
504
|
},
|
|
505
505
|
actions: {
|
|
506
506
|
normalizeFolderAssignmentsState() {
|
|
@@ -514,7 +514,7 @@ const Nt = ci("messaging", {
|
|
|
514
514
|
const e = await Se.fetchFolders();
|
|
515
515
|
return this.folders = Oe(e), this.foldersLoaded = !0, this.normalizeFolderAssignmentsState(), this.folders;
|
|
516
516
|
} catch (e) {
|
|
517
|
-
throw this.error =
|
|
517
|
+
throw this.error = Q(e), e;
|
|
518
518
|
}
|
|
519
519
|
},
|
|
520
520
|
async createFolder(e) {
|
|
@@ -522,7 +522,7 @@ const Nt = ci("messaging", {
|
|
|
522
522
|
const n = await Se.createFolder(e);
|
|
523
523
|
return this.folders = Oe([...this.folders, n]), n;
|
|
524
524
|
} catch (n) {
|
|
525
|
-
throw this.error =
|
|
525
|
+
throw this.error = Q(n), n;
|
|
526
526
|
}
|
|
527
527
|
},
|
|
528
528
|
async updateFolder(e, n) {
|
|
@@ -532,14 +532,14 @@ const Nt = ci("messaging", {
|
|
|
532
532
|
this.folders.map((o) => o.id === e ? i : o)
|
|
533
533
|
), i;
|
|
534
534
|
} catch (i) {
|
|
535
|
-
throw this.error =
|
|
535
|
+
throw this.error = Q(i), i;
|
|
536
536
|
}
|
|
537
537
|
},
|
|
538
538
|
async deleteFolder(e) {
|
|
539
539
|
try {
|
|
540
540
|
await Se.deleteFolder(e), this.folders = this.folders.filter((n) => n.id !== e), this.foldersLoaded = !0, this.activeFolderId === e && (this.activeFolderId = null), this.normalizeFolderAssignmentsState();
|
|
541
541
|
} catch (n) {
|
|
542
|
-
throw this.error =
|
|
542
|
+
throw this.error = Q(n), n;
|
|
543
543
|
}
|
|
544
544
|
},
|
|
545
545
|
async reorderFolders(e) {
|
|
@@ -561,7 +561,7 @@ const Nt = ci("messaging", {
|
|
|
561
561
|
});
|
|
562
562
|
this.folders = i;
|
|
563
563
|
} catch (n) {
|
|
564
|
-
throw this.error =
|
|
564
|
+
throw this.error = Q(n), n;
|
|
565
565
|
}
|
|
566
566
|
},
|
|
567
567
|
async assignToFolder(e, n) {
|
|
@@ -578,7 +578,7 @@ const Nt = ci("messaging", {
|
|
|
578
578
|
folder_id: l
|
|
579
579
|
};
|
|
580
580
|
} catch (i) {
|
|
581
|
-
throw this.error =
|
|
581
|
+
throw this.error = Q(i), i;
|
|
582
582
|
}
|
|
583
583
|
},
|
|
584
584
|
async fetchConversations(e, n, i, o) {
|
|
@@ -589,20 +589,20 @@ const Nt = ci("messaging", {
|
|
|
589
589
|
const h = await X().get("/v1/messaging/conversations", { params: l }), { items: g, nextCursor: d } = Je(
|
|
590
590
|
h.data,
|
|
591
591
|
"conversations"
|
|
592
|
-
),
|
|
592
|
+
), A = g.map((m) => {
|
|
593
593
|
const y = this.conversations.find(
|
|
594
|
-
(
|
|
594
|
+
(E) => E.id === m.id
|
|
595
595
|
);
|
|
596
|
-
return Ue(
|
|
596
|
+
return Ue(m, y);
|
|
597
597
|
});
|
|
598
|
-
e ? this.conversations.push(...
|
|
598
|
+
e ? this.conversations.push(...A) : this.conversations = A, this.normalizeFolderAssignmentsState(), this.lastFetch = Date.now();
|
|
599
599
|
const x = {
|
|
600
|
-
data:
|
|
600
|
+
data: A,
|
|
601
601
|
has_more: !!d
|
|
602
602
|
};
|
|
603
603
|
return d !== void 0 && (x.next_cursor = d), x;
|
|
604
604
|
} catch (u) {
|
|
605
|
-
throw o?.background && bn(u) || (this.error =
|
|
605
|
+
throw o?.background && bn(u) || (this.error = Q(u)), u;
|
|
606
606
|
} finally {
|
|
607
607
|
this.loading = !1;
|
|
608
608
|
}
|
|
@@ -630,7 +630,7 @@ const Nt = ci("messaging", {
|
|
|
630
630
|
const l = this.requests.findIndex((h) => h.id === e);
|
|
631
631
|
return l >= 0 && (this.requests[l] = o), this.normalizeFolderAssignmentsState(), o;
|
|
632
632
|
} catch (n) {
|
|
633
|
-
throw this.error =
|
|
633
|
+
throw this.error = Q(n), n;
|
|
634
634
|
} finally {
|
|
635
635
|
this.loading = !1;
|
|
636
636
|
}
|
|
@@ -647,7 +647,7 @@ const Nt = ci("messaging", {
|
|
|
647
647
|
i.data,
|
|
648
648
|
"conversations"
|
|
649
649
|
), l = o.map((g) => {
|
|
650
|
-
const d = this.requests.find((
|
|
650
|
+
const d = this.requests.find((A) => A.id === g.id);
|
|
651
651
|
return Ue(g, d);
|
|
652
652
|
});
|
|
653
653
|
e ? this.requests.push(...l) : this.requests = l, this.normalizeFolderAssignmentsState();
|
|
@@ -657,7 +657,7 @@ const Nt = ci("messaging", {
|
|
|
657
657
|
};
|
|
658
658
|
return u !== void 0 && (h.next_cursor = u), h;
|
|
659
659
|
} catch (n) {
|
|
660
|
-
throw this.error =
|
|
660
|
+
throw this.error = Q(n), n;
|
|
661
661
|
} finally {
|
|
662
662
|
this.loading = !1;
|
|
663
663
|
}
|
|
@@ -671,21 +671,21 @@ const Nt = ci("messaging", {
|
|
|
671
671
|
try {
|
|
672
672
|
u = await X().get(`/v1/messaging/conversations/${e}/messages`, { params: i });
|
|
673
673
|
break;
|
|
674
|
-
} catch (
|
|
675
|
-
if (!(o < Oi && bn(
|
|
676
|
-
throw
|
|
677
|
-
o += 1, await yn(Di(
|
|
674
|
+
} catch (m) {
|
|
675
|
+
if (!(o < Oi && bn(m)))
|
|
676
|
+
throw m;
|
|
677
|
+
o += 1, await yn(Di(m));
|
|
678
678
|
}
|
|
679
679
|
const { items: l, nextCursor: h } = Je(
|
|
680
680
|
u.data,
|
|
681
681
|
"messages"
|
|
682
682
|
), g = l.map(Ze), d = [...g].reverse();
|
|
683
683
|
if (n ? this.messages[e] = [...d, ...this.messages[e] || []] : this.messages[e] = d, (() => {
|
|
684
|
-
const
|
|
685
|
-
return
|
|
684
|
+
const m = this.conversations.find((y) => y.id === e) ?? this.requests.find((y) => y.id === e);
|
|
685
|
+
return m ? !m.last_message || !m.last_message_at : !1;
|
|
686
686
|
})()) {
|
|
687
|
-
const
|
|
688
|
-
|
|
687
|
+
const m = this.messages[e]?.at(-1);
|
|
688
|
+
m && this.updateConversationLastMessage(e, m);
|
|
689
689
|
}
|
|
690
690
|
h ? (this.conversationCursors[e] = h, this.conversationHasMore[e] = !0) : (delete this.conversationCursors[e], this.conversationHasMore[e] = !1);
|
|
691
691
|
const x = {
|
|
@@ -694,16 +694,16 @@ const Nt = ci("messaging", {
|
|
|
694
694
|
};
|
|
695
695
|
return h !== void 0 && (x.next_cursor = h), x;
|
|
696
696
|
} catch (i) {
|
|
697
|
-
throw this.error =
|
|
697
|
+
throw this.error = Q(i), i;
|
|
698
698
|
} finally {
|
|
699
699
|
this.loadingMessages[e] = !1, this.loading = !1;
|
|
700
700
|
}
|
|
701
701
|
},
|
|
702
702
|
async sendMessage(e, n, i, o, u, l) {
|
|
703
|
-
const h = Pe()(), g = `temp-${Date.now()}-${Math.random()}`, d = typeof l == "string" && l.trim().length > 0 ? l.trim() : null,
|
|
703
|
+
const h = Pe()(), g = `temp-${Date.now()}-${Math.random()}`, d = typeof l == "string" && l.trim().length > 0 ? l.trim() : null, A = h.currentUser, x = {
|
|
704
704
|
id: g,
|
|
705
705
|
conversation_id: e,
|
|
706
|
-
author_id:
|
|
706
|
+
author_id: A?.id || "",
|
|
707
707
|
body: n || "",
|
|
708
708
|
attachments: [],
|
|
709
709
|
meta: d ? { shared_post_id: d } : {},
|
|
@@ -711,14 +711,14 @@ const Nt = ci("messaging", {
|
|
|
711
711
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
712
712
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
713
713
|
};
|
|
714
|
-
|
|
715
|
-
id:
|
|
716
|
-
name:
|
|
717
|
-
...
|
|
718
|
-
...
|
|
714
|
+
A && (x.author = {
|
|
715
|
+
id: A.id,
|
|
716
|
+
name: A.name,
|
|
717
|
+
...A.avatar ? { avatar: A.avatar } : {},
|
|
718
|
+
...A.handle ? { handle: A.handle } : {}
|
|
719
719
|
}), o != null && (x.reply_to_id = o), u != null && (x.reply_to = u), this.messages[e] || (this.messages[e] = []), this.messages[e].push(x), this._pendingSendIds.add(g);
|
|
720
720
|
try {
|
|
721
|
-
let
|
|
721
|
+
let m;
|
|
722
722
|
const y = {
|
|
723
723
|
body: n || "",
|
|
724
724
|
...o ? { reply_to_id: o } : {},
|
|
@@ -726,35 +726,35 @@ const Nt = ci("messaging", {
|
|
|
726
726
|
};
|
|
727
727
|
if (i && i.length > 0) {
|
|
728
728
|
const j = await Promise.all(
|
|
729
|
-
i.map(async (
|
|
730
|
-
const
|
|
729
|
+
i.map(async (B) => {
|
|
730
|
+
const P = await Pi().uploadImage(B);
|
|
731
731
|
return {
|
|
732
|
-
media_id:
|
|
733
|
-
mime:
|
|
734
|
-
size:
|
|
732
|
+
media_id: P.id,
|
|
733
|
+
mime: P.mime_type,
|
|
734
|
+
size: P.size
|
|
735
735
|
};
|
|
736
736
|
})
|
|
737
737
|
);
|
|
738
|
-
|
|
738
|
+
m = await X().post(`/v1/messaging/conversations/${e}/messages`, {
|
|
739
739
|
...y,
|
|
740
740
|
attachments: j
|
|
741
741
|
});
|
|
742
742
|
} else
|
|
743
|
-
|
|
743
|
+
m = await X().post(`/v1/messaging/conversations/${e}/messages`, {
|
|
744
744
|
...y,
|
|
745
745
|
type: "text"
|
|
746
746
|
});
|
|
747
|
-
const
|
|
748
|
-
|
|
747
|
+
const E = m.data.data || m.data, R = { ...x, ...E, attachments: E.attachments ?? x.attachments }, S = Ze(R), f = this.messages[e], v = f.findIndex((j) => j.id === g);
|
|
748
|
+
v >= 0 && (f[v] = S), this._pendingSendIds.delete(g);
|
|
749
749
|
const b = S.id;
|
|
750
750
|
let F = 0;
|
|
751
751
|
for (let j = f.length - 1; j >= 0; j--) {
|
|
752
|
-
const
|
|
753
|
-
|
|
752
|
+
const B = f[j];
|
|
753
|
+
B && B.id === b && (F++, F > 1 && f.splice(j, 1));
|
|
754
754
|
}
|
|
755
755
|
return this.updateConversationLastMessage(e, S), S;
|
|
756
|
-
} catch (
|
|
757
|
-
throw this._pendingSendIds.delete(g), this.messages[e] = this.messages[e].filter((y) => y.id !== g), this.error =
|
|
756
|
+
} catch (m) {
|
|
757
|
+
throw this._pendingSendIds.delete(g), this.messages[e] = this.messages[e].filter((y) => y.id !== g), this.error = Q(m), m;
|
|
758
758
|
}
|
|
759
759
|
},
|
|
760
760
|
async editMessage(e, n, i) {
|
|
@@ -768,7 +768,7 @@ const Nt = ci("messaging", {
|
|
|
768
768
|
}
|
|
769
769
|
return u;
|
|
770
770
|
} catch (o) {
|
|
771
|
-
throw this.error =
|
|
771
|
+
throw this.error = Q(o), o;
|
|
772
772
|
}
|
|
773
773
|
},
|
|
774
774
|
async deleteMessage(e, n) {
|
|
@@ -783,7 +783,7 @@ const Nt = ci("messaging", {
|
|
|
783
783
|
delete l.body, i[o] = l;
|
|
784
784
|
}
|
|
785
785
|
} catch (i) {
|
|
786
|
-
throw this.error =
|
|
786
|
+
throw this.error = Q(i), i;
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
789
|
async markAsRead(e) {
|
|
@@ -809,7 +809,7 @@ const Nt = ci("messaging", {
|
|
|
809
809
|
u.id === e && (u.unread_count = 0);
|
|
810
810
|
});
|
|
811
811
|
} catch (n) {
|
|
812
|
-
throw this.error =
|
|
812
|
+
throw this.error = Q(n), n;
|
|
813
813
|
}
|
|
814
814
|
},
|
|
815
815
|
async markAllAsRead() {
|
|
@@ -844,7 +844,7 @@ const Nt = ci("messaging", {
|
|
|
844
844
|
o === null && (o = u.reason);
|
|
845
845
|
}
|
|
846
846
|
}), o !== null)
|
|
847
|
-
throw this.error =
|
|
847
|
+
throw this.error = Q(o), o;
|
|
848
848
|
},
|
|
849
849
|
async sendTyping(e, n = "start") {
|
|
850
850
|
try {
|
|
@@ -861,7 +861,7 @@ const Nt = ci("messaging", {
|
|
|
861
861
|
const i = { minutes: n }, o = await X().patch(`/v1/messaging/conversations/${e}/mute`, i), l = (o.data.data || o.data).muted_until || null, h = this.conversations.find((g) => g.id === e);
|
|
862
862
|
h && (h.is_muted = l !== null, h.muted_until = l);
|
|
863
863
|
} catch (i) {
|
|
864
|
-
throw this.error =
|
|
864
|
+
throw this.error = Q(i), i;
|
|
865
865
|
}
|
|
866
866
|
},
|
|
867
867
|
async unmuteConversation(e) {
|
|
@@ -871,7 +871,7 @@ const Nt = ci("messaging", {
|
|
|
871
871
|
}), o = (n.data.data || n.data).muted_until || null, u = this.conversations.find((l) => l.id === e);
|
|
872
872
|
u && (u.is_muted = o !== null, u.muted_until = o);
|
|
873
873
|
} catch (n) {
|
|
874
|
-
throw this.error =
|
|
874
|
+
throw this.error = Q(n), n;
|
|
875
875
|
}
|
|
876
876
|
},
|
|
877
877
|
async updateConversationTitle(e, n) {
|
|
@@ -884,7 +884,7 @@ const Nt = ci("messaging", {
|
|
|
884
884
|
});
|
|
885
885
|
this.conversations = l(this.conversations), this.requests = l(this.requests);
|
|
886
886
|
} catch (i) {
|
|
887
|
-
throw this.error =
|
|
887
|
+
throw this.error = Q(i), i;
|
|
888
888
|
}
|
|
889
889
|
},
|
|
890
890
|
async pinConversation(e, n) {
|
|
@@ -893,21 +893,21 @@ const Nt = ci("messaging", {
|
|
|
893
893
|
const i = this.conversations.find((o) => o.id === e);
|
|
894
894
|
i && (i.is_pinned = n), this.conversations.sort(et);
|
|
895
895
|
} catch (i) {
|
|
896
|
-
throw this.error =
|
|
896
|
+
throw this.error = Q(i), i;
|
|
897
897
|
}
|
|
898
898
|
},
|
|
899
899
|
async archiveConversation(e, n) {
|
|
900
900
|
try {
|
|
901
901
|
await X().patch(`/v1/messaging/conversations/${e}/archive`, { archived: n }), this.conversations = this.conversations.filter((i) => i.id !== e);
|
|
902
902
|
} catch (i) {
|
|
903
|
-
throw this.error =
|
|
903
|
+
throw this.error = Q(i), i;
|
|
904
904
|
}
|
|
905
905
|
},
|
|
906
906
|
async deleteConversation(e) {
|
|
907
907
|
try {
|
|
908
908
|
await X().delete(`/v1/messaging/conversations/${e}`), this.conversations = this.conversations.filter((n) => n.id !== e), delete this.messages[e], delete this.typingUsers[e], delete this.conversationCursors[e], delete this.conversationHasMore[e], delete this.loadingMessages[e];
|
|
909
909
|
} catch (n) {
|
|
910
|
-
throw this.error =
|
|
910
|
+
throw this.error = Q(n), n;
|
|
911
911
|
}
|
|
912
912
|
},
|
|
913
913
|
async createDMConversation(e, n) {
|
|
@@ -917,12 +917,12 @@ const Nt = ci("messaging", {
|
|
|
917
917
|
};
|
|
918
918
|
n && (i.message = n);
|
|
919
919
|
const o = await X().post("/v1/messaging/conversations/dm", i), u = o.data.data || o.data;
|
|
920
|
-
if (!
|
|
920
|
+
if (!Cn(u))
|
|
921
921
|
throw new Error("Invalid conversation payload from DM create endpoint.");
|
|
922
922
|
const l = Tn(u) ? Ue(u) : await this.fetchConversation(u.id);
|
|
923
923
|
return l.is_request === !0 ? (this.requests = Ke(this.requests, l), this.conversations = this.conversations.filter((h) => h.id !== l.id), l) : (this.conversations = Ke(this.conversations, l), this.requests = this.requests.filter((h) => h.id !== l.id), l);
|
|
924
924
|
} catch (i) {
|
|
925
|
-
throw this.error =
|
|
925
|
+
throw this.error = Q(i), i;
|
|
926
926
|
}
|
|
927
927
|
},
|
|
928
928
|
async createGroupConversation(e, n) {
|
|
@@ -931,12 +931,12 @@ const Nt = ci("messaging", {
|
|
|
931
931
|
title: e,
|
|
932
932
|
participant_ids: n
|
|
933
933
|
}), o = i.data.data || i.data;
|
|
934
|
-
if (!
|
|
934
|
+
if (!Cn(o))
|
|
935
935
|
throw new Error("Invalid conversation payload from group create endpoint.");
|
|
936
936
|
const u = Tn(o) ? o : await this.fetchConversation(o.id);
|
|
937
937
|
return this.conversations = Ke(this.conversations, u), u;
|
|
938
938
|
} catch (i) {
|
|
939
|
-
throw this.error =
|
|
939
|
+
throw this.error = Q(i), i;
|
|
940
940
|
}
|
|
941
941
|
},
|
|
942
942
|
async addParticipants(e, n) {
|
|
@@ -946,7 +946,7 @@ const Nt = ci("messaging", {
|
|
|
946
946
|
// Changed from participant_ids to user_ids to match backend
|
|
947
947
|
}), await this.fetchConversation(e);
|
|
948
948
|
} catch (i) {
|
|
949
|
-
throw this.error =
|
|
949
|
+
throw this.error = Q(i), i;
|
|
950
950
|
}
|
|
951
951
|
},
|
|
952
952
|
async removeParticipant(e, n) {
|
|
@@ -959,7 +959,7 @@ const Nt = ci("messaging", {
|
|
|
959
959
|
}
|
|
960
960
|
await this.fetchConversation(e);
|
|
961
961
|
} catch (i) {
|
|
962
|
-
throw this.error =
|
|
962
|
+
throw this.error = Q(i), i;
|
|
963
963
|
}
|
|
964
964
|
},
|
|
965
965
|
applyParticipantReadState(e) {
|
|
@@ -987,18 +987,18 @@ const Nt = ci("messaging", {
|
|
|
987
987
|
return;
|
|
988
988
|
const l = Pe()();
|
|
989
989
|
if (i.author_id === l.currentUser?.id) {
|
|
990
|
-
const d = o.findIndex((
|
|
990
|
+
const d = o.findIndex((A) => A.id.startsWith("temp-"));
|
|
991
991
|
if (d >= 0) {
|
|
992
|
-
const
|
|
993
|
-
o[d] = i, this._pendingSendIds.delete(
|
|
992
|
+
const A = o[d]?.id ?? "";
|
|
993
|
+
o[d] = i, this._pendingSendIds.delete(A), this.updateConversationLastMessage(n, i);
|
|
994
994
|
return;
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
const h = i.created_at;
|
|
998
998
|
let g = o.length;
|
|
999
999
|
for (let d = o.length - 1; d >= 0; d--) {
|
|
1000
|
-
const
|
|
1001
|
-
if (
|
|
1000
|
+
const A = o[d];
|
|
1001
|
+
if (A && A.created_at <= h)
|
|
1002
1002
|
break;
|
|
1003
1003
|
g = d;
|
|
1004
1004
|
}
|
|
@@ -1010,8 +1010,8 @@ const Nt = ci("messaging", {
|
|
|
1010
1010
|
},
|
|
1011
1011
|
removeMessage(e, n) {
|
|
1012
1012
|
const i = (d) => {
|
|
1013
|
-
const
|
|
1014
|
-
return delete
|
|
1013
|
+
const A = { ...d, is_deleted: !0 };
|
|
1014
|
+
return delete A.body, A;
|
|
1015
1015
|
};
|
|
1016
1016
|
let o = null;
|
|
1017
1017
|
const u = this.conversations.find((d) => d.id === e);
|
|
@@ -1040,24 +1040,24 @@ const Nt = ci("messaging", {
|
|
|
1040
1040
|
let g;
|
|
1041
1041
|
try {
|
|
1042
1042
|
g = await X().post(o, u);
|
|
1043
|
-
} catch (
|
|
1044
|
-
if (!Gi(
|
|
1045
|
-
throw
|
|
1043
|
+
} catch (m) {
|
|
1044
|
+
if (!Gi(m))
|
|
1045
|
+
throw m;
|
|
1046
1046
|
g = await X().post(o, u);
|
|
1047
1047
|
}
|
|
1048
|
-
const d = he(g.data) && "data" in g.data ? g.data.data : g.data,
|
|
1048
|
+
const d = he(g.data) && "data" in g.data ? g.data.data : g.data, A = wn(
|
|
1049
1049
|
he(d) ? d.reactions : void 0
|
|
1050
1050
|
);
|
|
1051
|
-
(
|
|
1051
|
+
(A.length > 0 || h.length === 0) && this.updateMessageReactions(e, n, A);
|
|
1052
1052
|
try {
|
|
1053
|
-
const
|
|
1053
|
+
const m = await X().get(o), y = he(m.data) && "data" in m.data ? m.data.data : m.data, E = wn(
|
|
1054
1054
|
he(y) ? y.reactions : void 0
|
|
1055
1055
|
);
|
|
1056
|
-
this.updateMessageReactions(e, n,
|
|
1056
|
+
this.updateMessageReactions(e, n, E);
|
|
1057
1057
|
} catch {
|
|
1058
1058
|
}
|
|
1059
1059
|
} catch (g) {
|
|
1060
|
-
throw this.error =
|
|
1060
|
+
throw this.error = Q(g), g;
|
|
1061
1061
|
}
|
|
1062
1062
|
},
|
|
1063
1063
|
updateMessageReactions(e, n, i) {
|
|
@@ -1101,14 +1101,14 @@ const Nt = ci("messaging", {
|
|
|
1101
1101
|
});
|
|
1102
1102
|
this.conversations = Ke(this.conversations, i);
|
|
1103
1103
|
} catch (n) {
|
|
1104
|
-
throw this.error =
|
|
1104
|
+
throw this.error = Q(n), n;
|
|
1105
1105
|
}
|
|
1106
1106
|
},
|
|
1107
1107
|
async declineRequest(e) {
|
|
1108
1108
|
try {
|
|
1109
1109
|
await Se.declineRequest(e), this.requests = this.requests.filter((n) => n.id !== e);
|
|
1110
1110
|
} catch (n) {
|
|
1111
|
-
throw this.error =
|
|
1111
|
+
throw this.error = Q(n), n;
|
|
1112
1112
|
}
|
|
1113
1113
|
},
|
|
1114
1114
|
async searchConversations(e, n, i) {
|
|
@@ -1124,7 +1124,7 @@ const Nt = ci("messaging", {
|
|
|
1124
1124
|
);
|
|
1125
1125
|
return l;
|
|
1126
1126
|
} catch (o) {
|
|
1127
|
-
return this.error =
|
|
1127
|
+
return this.error = Q(o), [];
|
|
1128
1128
|
} finally {
|
|
1129
1129
|
this.searchLoading = !1;
|
|
1130
1130
|
}
|
|
@@ -1137,7 +1137,7 @@ const Nt = ci("messaging", {
|
|
|
1137
1137
|
}), o = i.data.data || i.data || [];
|
|
1138
1138
|
return this.searchResults = o, o;
|
|
1139
1139
|
} catch (i) {
|
|
1140
|
-
return this.error =
|
|
1140
|
+
return this.error = Q(i), [];
|
|
1141
1141
|
} finally {
|
|
1142
1142
|
this.searchLoading = !1;
|
|
1143
1143
|
}
|
|
@@ -1177,109 +1177,109 @@ const Nt = ci("messaging", {
|
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
1179
|
});
|
|
1180
|
-
function
|
|
1181
|
-
const n = Nt(), i = Pe()(), o = de(!1), u = de(null), l = de(null), h = xt(), g = h !== null, d = 20,
|
|
1182
|
-
let x = 0,
|
|
1183
|
-
const
|
|
1180
|
+
function Ia(e) {
|
|
1181
|
+
const n = Nt(), i = Pe()(), o = de(!1), u = de(null), l = de(null), h = xt(), g = h !== null, d = 20, A = 250;
|
|
1182
|
+
let x = 0, m = null, y = null;
|
|
1183
|
+
const E = ie(() => i.currentUser?.id), R = () => Ln(e)?.trim() ?? "";
|
|
1184
1184
|
function S() {
|
|
1185
|
-
|
|
1185
|
+
m && (clearTimeout(m), m = null), x = 0;
|
|
1186
1186
|
}
|
|
1187
1187
|
function f() {
|
|
1188
|
-
!g || o.value ||
|
|
1189
|
-
|
|
1190
|
-
},
|
|
1191
|
-
}
|
|
1192
|
-
function
|
|
1193
|
-
if (n.addMessage(
|
|
1194
|
-
const M = n.getConversationById(
|
|
1195
|
-
M && (M.unread_count = 0), n.markAsRead(
|
|
1188
|
+
!g || o.value || m || x >= d || (m = setTimeout(() => {
|
|
1189
|
+
m = null, x += 1, $();
|
|
1190
|
+
}, A));
|
|
1191
|
+
}
|
|
1192
|
+
function v(w) {
|
|
1193
|
+
if (n.addMessage(w.message), w.message.author_id !== E.value) {
|
|
1194
|
+
const M = n.getConversationById(w.conversation_id);
|
|
1195
|
+
M && (M.unread_count = 0), n.markAsRead(w.conversation_id).catch(() => {
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
|
-
function b(
|
|
1200
|
-
n.applyParticipantReadState(
|
|
1199
|
+
function b(w) {
|
|
1200
|
+
n.applyParticipantReadState(w);
|
|
1201
1201
|
}
|
|
1202
|
-
function F(
|
|
1203
|
-
const M = n.getMessagesByConversationId(
|
|
1204
|
-
if (
|
|
1205
|
-
const C = M[
|
|
1202
|
+
function F(w) {
|
|
1203
|
+
const M = n.getMessagesByConversationId(w.conversation_id), ee = M.findIndex((C) => C.id === w.message.id);
|
|
1204
|
+
if (ee >= 0) {
|
|
1205
|
+
const C = M[ee];
|
|
1206
1206
|
if (!C) return;
|
|
1207
1207
|
const O = { ...C };
|
|
1208
|
-
|
|
1209
|
-
const L = n.getConversationById(
|
|
1210
|
-
L && L.last_message?.id ===
|
|
1208
|
+
w.message.body !== void 0 && (O.body = w.message.body), w.message.edited_at !== void 0 && (O.edited_at = w.message.edited_at), w.message.meta !== void 0 && (O.meta = w.message.meta), M[ee] = O;
|
|
1209
|
+
const L = n.getConversationById(w.conversation_id);
|
|
1210
|
+
L && L.last_message?.id === w.message.id && (L.last_message = O);
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
function j(
|
|
1214
|
-
n.removeMessage(
|
|
1213
|
+
function j(w) {
|
|
1214
|
+
n.removeMessage(w.conversation_id, w.message_id);
|
|
1215
1215
|
}
|
|
1216
|
-
function
|
|
1216
|
+
function B(w) {
|
|
1217
1217
|
n.updateMessageReactions(
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1218
|
+
w.conversation_id,
|
|
1219
|
+
w.message_id,
|
|
1220
|
+
w.reactions
|
|
1221
1221
|
);
|
|
1222
1222
|
}
|
|
1223
|
-
function
|
|
1224
|
-
const M = n.getConversationById(
|
|
1223
|
+
function P(w) {
|
|
1224
|
+
const M = n.getConversationById(w.conversation_id);
|
|
1225
1225
|
M && (M.is_request = !1), n.requests = n.requests.filter(
|
|
1226
|
-
(
|
|
1226
|
+
(ee) => ee.id !== w.conversation_id
|
|
1227
1227
|
);
|
|
1228
1228
|
}
|
|
1229
|
-
function U(
|
|
1230
|
-
|
|
1229
|
+
function U(w) {
|
|
1230
|
+
w.removed_user_id === E.value && (se(), n.deleteConversation(w.conversation_id).catch(() => {
|
|
1231
1231
|
}));
|
|
1232
1232
|
}
|
|
1233
|
-
function
|
|
1234
|
-
const
|
|
1235
|
-
if (!(o.value || !
|
|
1233
|
+
function $() {
|
|
1234
|
+
const w = R();
|
|
1235
|
+
if (!(o.value || !w)) {
|
|
1236
1236
|
if (!Ae()) {
|
|
1237
1237
|
f();
|
|
1238
1238
|
return;
|
|
1239
1239
|
}
|
|
1240
1240
|
u.value = null;
|
|
1241
1241
|
try {
|
|
1242
|
-
y = gi(
|
|
1243
|
-
onMessageSent:
|
|
1242
|
+
y = gi(w, {
|
|
1243
|
+
onMessageSent: v,
|
|
1244
1244
|
onMessageRead: b,
|
|
1245
1245
|
onMessageEdited: F,
|
|
1246
1246
|
onMessageDeleted: j,
|
|
1247
|
-
onReactionToggled:
|
|
1248
|
-
onRequestAccepted:
|
|
1247
|
+
onReactionToggled: B,
|
|
1248
|
+
onRequestAccepted: P,
|
|
1249
1249
|
onParticipantRemoved: U
|
|
1250
|
-
}), o.value = !0, l.value =
|
|
1250
|
+
}), o.value = !0, l.value = w, n.registerDetailSubscription(w), S();
|
|
1251
1251
|
} catch (M) {
|
|
1252
1252
|
u.value = M instanceof Error ? M.message : "Failed to subscribe to conversation", console.error("ConversationChannel: Subscribe error", M);
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
1256
|
function z() {
|
|
1257
|
-
o.value ||
|
|
1257
|
+
o.value || $();
|
|
1258
1258
|
}
|
|
1259
1259
|
typeof window < "u" && window.addEventListener(De(), z);
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1262
|
-
o.value ||
|
|
1260
|
+
const K = it((w) => {
|
|
1261
|
+
if (w === "connected") {
|
|
1262
|
+
o.value || $();
|
|
1263
1263
|
return;
|
|
1264
1264
|
}
|
|
1265
|
-
(
|
|
1265
|
+
(w === "disconnected" || w === "error") && (S(), y && (y(), y = null), l.value && (n.unregisterDetailSubscription(l.value), l.value = null), o.value = !1);
|
|
1266
1266
|
});
|
|
1267
|
-
function
|
|
1268
|
-
const
|
|
1269
|
-
if (S(), !(!o.value || !
|
|
1267
|
+
function se() {
|
|
1268
|
+
const w = l.value;
|
|
1269
|
+
if (S(), !(!o.value || !w))
|
|
1270
1270
|
try {
|
|
1271
|
-
y && (y(), y = null), n.hasGlobalConversationSubscription(
|
|
1271
|
+
y && (y(), y = null), n.hasGlobalConversationSubscription(w) || mi(w), o.value = !1, n.unregisterDetailSubscription(w), l.value = null, u.value = null;
|
|
1272
1272
|
} catch (M) {
|
|
1273
1273
|
u.value = M instanceof Error ? M.message : "Failed to unsubscribe from conversation", console.error("ConversationChannel: Unsubscribe error", M);
|
|
1274
1274
|
}
|
|
1275
1275
|
}
|
|
1276
1276
|
return h !== null && qe(() => {
|
|
1277
|
-
S(),
|
|
1277
|
+
S(), K(), se(), typeof window < "u" && window.removeEventListener(De(), z);
|
|
1278
1278
|
}), {
|
|
1279
1279
|
isSubscribed: ie(() => o.value),
|
|
1280
1280
|
error: ie(() => u.value),
|
|
1281
|
-
subscribe:
|
|
1282
|
-
unsubscribe:
|
|
1281
|
+
subscribe: $,
|
|
1282
|
+
unsubscribe: se
|
|
1283
1283
|
};
|
|
1284
1284
|
}
|
|
1285
1285
|
const Kn = () => () => {
|
|
@@ -1360,13 +1360,13 @@ function co(e) {
|
|
|
1360
1360
|
function Pn(e) {
|
|
1361
1361
|
return e.getEchoConnection()?.state ?? null;
|
|
1362
1362
|
}
|
|
1363
|
-
function
|
|
1363
|
+
function La(e = {}) {
|
|
1364
1364
|
const o = co(e.source ?? "app"), u = {
|
|
1365
1365
|
...ao,
|
|
1366
1366
|
...e.icons
|
|
1367
|
-
}, l = de(o.getConnectionStatus()), h = de(null), g = de(0), d = de(!1),
|
|
1368
|
-
let y = null,
|
|
1369
|
-
const F = ie(() => l.value === "connected"), j = ie(() => l.value === "connecting"),
|
|
1367
|
+
}, l = de(o.getConnectionStatus()), h = de(null), g = de(0), d = de(!1), A = de(!1), x = de(!1), m = de(!1);
|
|
1368
|
+
let y = null, E = null, R = null, S = null, f = null, v = null, b = null;
|
|
1369
|
+
const F = ie(() => l.value === "connected"), j = ie(() => l.value === "connecting"), B = ie(() => l.value === "disconnected"), P = ie(() => l.value === "error"), U = ie(() => B.value || P.value), $ = ie(() => {
|
|
1370
1370
|
switch (l.value) {
|
|
1371
1371
|
case "connecting":
|
|
1372
1372
|
return g.value > 0 ? "Reconnecting..." : "Connecting...";
|
|
@@ -1391,7 +1391,7 @@ function Ia(e = {}) {
|
|
|
1391
1391
|
default:
|
|
1392
1392
|
return "medium";
|
|
1393
1393
|
}
|
|
1394
|
-
}),
|
|
1394
|
+
}), K = ie(() => {
|
|
1395
1395
|
switch (l.value) {
|
|
1396
1396
|
case "connected":
|
|
1397
1397
|
return u.connected;
|
|
@@ -1404,64 +1404,64 @@ function Ia(e = {}) {
|
|
|
1404
1404
|
default:
|
|
1405
1405
|
return u.unknown;
|
|
1406
1406
|
}
|
|
1407
|
-
}),
|
|
1407
|
+
}), se = async () => {
|
|
1408
1408
|
Rn.debug("Manual reconnect triggered"), g.value += 1, await o.reconnect();
|
|
1409
|
-
},
|
|
1410
|
-
if (L !== "connecting" &&
|
|
1411
|
-
const re = !
|
|
1409
|
+
}, w = (L, H = l.value) => {
|
|
1410
|
+
if (L !== "connecting" && E && (clearTimeout(E), E = null), L === "disconnected" || L === "error") {
|
|
1411
|
+
const re = !m.value && H === L, je = !A.value && (re || H === "connected" || H === "connecting");
|
|
1412
1412
|
if (x.value = !0, je) {
|
|
1413
|
-
d.value = !1,
|
|
1414
|
-
|
|
1413
|
+
d.value = !1, R && clearTimeout(R), R = setTimeout(() => {
|
|
1414
|
+
R = null, l.value !== "connected" && (d.value = !0);
|
|
1415
1415
|
}, 2e3);
|
|
1416
1416
|
return;
|
|
1417
1417
|
}
|
|
1418
|
-
|
|
1418
|
+
R && (clearTimeout(R), R = null), d.value = !0;
|
|
1419
1419
|
return;
|
|
1420
1420
|
}
|
|
1421
1421
|
if (L === "connected") {
|
|
1422
|
-
|
|
1422
|
+
R && (clearTimeout(R), R = null), d.value = !1, A.value = !1, x.value = !1;
|
|
1423
1423
|
return;
|
|
1424
1424
|
}
|
|
1425
1425
|
if (L === "connecting") {
|
|
1426
|
-
if (
|
|
1426
|
+
if (A.value) {
|
|
1427
1427
|
d.value = !0;
|
|
1428
1428
|
return;
|
|
1429
1429
|
}
|
|
1430
|
-
if (x.value || (d.value = !1),
|
|
1430
|
+
if (x.value || (d.value = !1), E)
|
|
1431
1431
|
return;
|
|
1432
|
-
|
|
1433
|
-
if (
|
|
1432
|
+
E = setTimeout(() => {
|
|
1433
|
+
if (E = null, l.value === "connecting") {
|
|
1434
1434
|
if (Pn(o) === "connected") {
|
|
1435
1435
|
M("connected");
|
|
1436
1436
|
return;
|
|
1437
1437
|
}
|
|
1438
|
-
|
|
1438
|
+
A.value = !0, Rn.warn("Still connecting after 10s, treating as disconnected"), M("disconnected"), g.value += 1, o.reconnect();
|
|
1439
1439
|
}
|
|
1440
1440
|
}, 1e4);
|
|
1441
1441
|
}
|
|
1442
1442
|
}, M = (L) => {
|
|
1443
|
-
const
|
|
1444
|
-
if (L === "connecting" &&
|
|
1445
|
-
l.value = "disconnected",
|
|
1443
|
+
const H = l.value;
|
|
1444
|
+
if (L === "connecting" && A.value) {
|
|
1445
|
+
l.value = "disconnected", w("disconnected", H);
|
|
1446
1446
|
return;
|
|
1447
1447
|
}
|
|
1448
|
-
l.value = L, L === "connecting" && (
|
|
1449
|
-
},
|
|
1450
|
-
const L = Pn(o),
|
|
1451
|
-
if (L === "connected" &&
|
|
1448
|
+
l.value = L, L === "connecting" && (H === "disconnected" || H === "error") && g.value === 0 && (g.value = 1), L === "connected" && (h.value = /* @__PURE__ */ new Date(), g.value = 0), w(L, H);
|
|
1449
|
+
}, ee = () => {
|
|
1450
|
+
const L = Pn(o), H = l.value;
|
|
1451
|
+
if (L === "connected" && H !== "connected") {
|
|
1452
1452
|
M("connected");
|
|
1453
1453
|
return;
|
|
1454
1454
|
}
|
|
1455
|
-
if (L === "connecting" &&
|
|
1455
|
+
if (L === "connecting" && H !== "connecting") {
|
|
1456
1456
|
M("connecting");
|
|
1457
1457
|
return;
|
|
1458
1458
|
}
|
|
1459
|
-
if ((L === "unavailable" || L === "failed" || L === "disconnected") &&
|
|
1459
|
+
if ((L === "unavailable" || L === "failed" || L === "disconnected") && H !== "disconnected") {
|
|
1460
1460
|
M("disconnected");
|
|
1461
1461
|
return;
|
|
1462
1462
|
}
|
|
1463
1463
|
const re = o.getConnectionStatus();
|
|
1464
|
-
!L && re === "connected" &&
|
|
1464
|
+
!L && re === "connected" && H !== "connected" && M("connected");
|
|
1465
1465
|
}, C = () => {
|
|
1466
1466
|
if (f?.unbind && b && (f.unbind("connected", b.connected), f.unbind("connecting", b.connecting), f.unbind("disconnected", b.disconnected), f.unbind("unavailable", b.unavailable), f.unbind("error", b.error), f.unbind("state_change", b.stateChange)), f = o.getEchoConnection(), b = null, !f?.bind)
|
|
1467
1467
|
return;
|
|
@@ -1471,8 +1471,8 @@ function Ia(e = {}) {
|
|
|
1471
1471
|
disconnected: () => M("disconnected"),
|
|
1472
1472
|
unavailable: () => M("disconnected"),
|
|
1473
1473
|
error: () => M("error"),
|
|
1474
|
-
stateChange: (
|
|
1475
|
-
const re =
|
|
1474
|
+
stateChange: (H) => {
|
|
1475
|
+
const re = H?.current;
|
|
1476
1476
|
if (re === "connected") {
|
|
1477
1477
|
M("connected");
|
|
1478
1478
|
return;
|
|
@@ -1497,32 +1497,32 @@ function Ia(e = {}) {
|
|
|
1497
1497
|
}, O = ie(() => {
|
|
1498
1498
|
if (!h.value || !F.value)
|
|
1499
1499
|
return null;
|
|
1500
|
-
const L = Date.now() - h.value.getTime(),
|
|
1501
|
-
return
|
|
1500
|
+
const L = Date.now() - h.value.getTime(), H = Math.floor(L / 6e4), re = Math.floor(L % 6e4 / 1e3);
|
|
1501
|
+
return H > 0 ? `${H}m ${re}s` : `${re}s`;
|
|
1502
1502
|
});
|
|
1503
1503
|
return Un(() => {
|
|
1504
|
-
l.value = o.getConnectionStatus(), y = o.onConnectionStatusChange(M), F.value && (h.value = /* @__PURE__ */ new Date()),
|
|
1505
|
-
C(),
|
|
1506
|
-
}, window.addEventListener(o.initializedEvent,
|
|
1507
|
-
|
|
1504
|
+
l.value = o.getConnectionStatus(), y = o.onConnectionStatusChange(M), F.value && (h.value = /* @__PURE__ */ new Date()), w(l.value, l.value), m.value = !0, C(), v = () => {
|
|
1505
|
+
C(), ee();
|
|
1506
|
+
}, window.addEventListener(o.initializedEvent, v), ee(), S = setInterval(() => {
|
|
1507
|
+
ee();
|
|
1508
1508
|
}, 3e3);
|
|
1509
1509
|
}), qe(() => {
|
|
1510
|
-
y?.(),
|
|
1510
|
+
y?.(), E && (clearTimeout(E), E = null), R && (clearTimeout(R), R = null), S && (clearInterval(S), S = null), v && (window.removeEventListener(o.initializedEvent, v), v = null), f?.unbind && b && (f.unbind("connected", b.connected), f.unbind("connecting", b.connecting), f.unbind("disconnected", b.disconnected), f.unbind("unavailable", b.unavailable), f.unbind("error", b.error), f.unbind("state_change", b.stateChange)), f = null, b = null;
|
|
1511
1511
|
}), {
|
|
1512
1512
|
connectionStatus: ie(() => l.value),
|
|
1513
1513
|
isConnected: F,
|
|
1514
1514
|
isConnecting: j,
|
|
1515
|
-
isDisconnected:
|
|
1516
|
-
isError:
|
|
1515
|
+
isDisconnected: B,
|
|
1516
|
+
isError: P,
|
|
1517
1517
|
hasConnectionIssues: U,
|
|
1518
|
-
statusMessage:
|
|
1518
|
+
statusMessage: $,
|
|
1519
1519
|
statusColor: z,
|
|
1520
|
-
statusIcon:
|
|
1520
|
+
statusIcon: K,
|
|
1521
1521
|
showConnectionBanner: ie(() => d.value),
|
|
1522
1522
|
lastConnectionTime: ie(() => h.value),
|
|
1523
1523
|
connectionUptime: O,
|
|
1524
1524
|
reconnectAttempts: ie(() => g.value),
|
|
1525
|
-
reconnect:
|
|
1525
|
+
reconnect: se
|
|
1526
1526
|
};
|
|
1527
1527
|
}
|
|
1528
1528
|
const Zn = Mt;
|
|
@@ -1589,98 +1589,98 @@ function vo(e) {
|
|
|
1589
1589
|
function bo() {
|
|
1590
1590
|
zt = ns;
|
|
1591
1591
|
}
|
|
1592
|
-
const Ye = Dt()("GlobalMessaging"), yo = 3, _o = (e) => e.replace(/\/+$/, ""), So = (e) => _o(window.location.pathname) === `/messages/${e}`,
|
|
1593
|
-
function
|
|
1592
|
+
const Ye = Dt()("GlobalMessaging"), yo = 3, _o = (e) => e.replace(/\/+$/, ""), So = (e) => _o(window.location.pathname) === `/messages/${e}`, wo = (e) => e.is_muted ? !0 : typeof e.muted_until == "string" && e.muted_until.length > 0;
|
|
1593
|
+
function Ua() {
|
|
1594
1594
|
const e = Nt(), n = Pe()(), i = mo(), o = es(), u = hi(), l = xt(), { conversations: h } = ui(e), g = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
|
|
1595
|
-
let
|
|
1596
|
-
function x(
|
|
1597
|
-
const U = d.get(
|
|
1598
|
-
if (U && (d.delete(
|
|
1599
|
-
for (const
|
|
1595
|
+
let A = !1;
|
|
1596
|
+
function x(P) {
|
|
1597
|
+
const U = d.get(P);
|
|
1598
|
+
if (U && (d.delete(P), typeof U.channel.stopListening == "function"))
|
|
1599
|
+
for (const $ of U.bindings)
|
|
1600
1600
|
try {
|
|
1601
|
-
U.channel.stopListening(
|
|
1601
|
+
U.channel.stopListening($.event, $.handler);
|
|
1602
1602
|
} catch {
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
|
-
function
|
|
1606
|
-
for (const
|
|
1607
|
-
x(
|
|
1605
|
+
function m() {
|
|
1606
|
+
for (const P of g)
|
|
1607
|
+
x(P), e.unregisterGlobalConversationSubscription(P);
|
|
1608
1608
|
g.clear();
|
|
1609
1609
|
}
|
|
1610
|
-
function y(
|
|
1610
|
+
function y(P) {
|
|
1611
1611
|
const U = Ae();
|
|
1612
|
-
if (!U || g.has(
|
|
1613
|
-
const
|
|
1614
|
-
x(
|
|
1615
|
-
const z = U.private(
|
|
1612
|
+
if (!U || g.has(P)) return;
|
|
1613
|
+
const $ = `conversation.${P}`;
|
|
1614
|
+
x(P);
|
|
1615
|
+
const z = U.private($), K = (M) => {
|
|
1616
1616
|
if (!Si(M)) {
|
|
1617
1617
|
Ye.warn("Dropping malformed ConversationMessageSent event", M);
|
|
1618
1618
|
return;
|
|
1619
1619
|
}
|
|
1620
|
-
const
|
|
1621
|
-
if (!C ||
|
|
1622
|
-
e.addMessage(
|
|
1623
|
-
const O = e.hasDetailSubscription(
|
|
1620
|
+
const ee = M, C = n.currentUser?.id;
|
|
1621
|
+
if (!C || ee.message.author_id === C) return;
|
|
1622
|
+
e.addMessage(ee.message);
|
|
1623
|
+
const O = e.hasDetailSubscription(ee.conversation_id), L = So(ee.conversation_id);
|
|
1624
1624
|
if (O || L) {
|
|
1625
|
-
const re = e.getConversationById(
|
|
1626
|
-
re && (re.unread_count = 0), e.markAsRead(
|
|
1625
|
+
const re = e.getConversationById(ee.conversation_id);
|
|
1626
|
+
re && (re.unread_count = 0), e.markAsRead(ee.conversation_id).catch(() => {
|
|
1627
1627
|
});
|
|
1628
1628
|
return;
|
|
1629
1629
|
}
|
|
1630
|
-
const
|
|
1631
|
-
if (
|
|
1632
|
-
const re =
|
|
1633
|
-
re ||
|
|
1630
|
+
const H = e.getConversationById(ee.conversation_id);
|
|
1631
|
+
if (H) {
|
|
1632
|
+
const re = wo(H);
|
|
1633
|
+
re || H.unread_count++, i(re);
|
|
1634
1634
|
}
|
|
1635
|
-
},
|
|
1636
|
-
if (!
|
|
1635
|
+
}, se = (M) => {
|
|
1636
|
+
if (!wi(M)) {
|
|
1637
1637
|
Ye.warn("Dropping malformed ConversationMessageRead event", M);
|
|
1638
1638
|
return;
|
|
1639
1639
|
}
|
|
1640
1640
|
e.applyParticipantReadState(M);
|
|
1641
|
-
},
|
|
1642
|
-
if (!
|
|
1641
|
+
}, w = (M) => {
|
|
1642
|
+
if (!Ci(M)) {
|
|
1643
1643
|
Ye.warn("Dropping malformed ConversationRequestAccepted event", M);
|
|
1644
1644
|
return;
|
|
1645
1645
|
}
|
|
1646
|
-
const
|
|
1646
|
+
const ee = M, C = e.getConversationById(ee.conversation_id);
|
|
1647
1647
|
C && (C.is_request = !1), e.requests = e.requests.filter(
|
|
1648
|
-
(O) => O.id !==
|
|
1648
|
+
(O) => O.id !== ee.conversation_id
|
|
1649
1649
|
);
|
|
1650
1650
|
};
|
|
1651
|
-
z.listen(".ConversationMessageSent",
|
|
1651
|
+
z.listen(".ConversationMessageSent", K), z.listen(".ConversationMessageRead", se), z.listen(".ConversationRequestAccepted", w), d.set(P, {
|
|
1652
1652
|
channel: z,
|
|
1653
1653
|
bindings: [
|
|
1654
|
-
{ event: ".ConversationMessageSent", handler:
|
|
1655
|
-
{ event: ".ConversationMessageRead", handler:
|
|
1656
|
-
{ event: ".ConversationRequestAccepted", handler:
|
|
1654
|
+
{ event: ".ConversationMessageSent", handler: K },
|
|
1655
|
+
{ event: ".ConversationMessageRead", handler: se },
|
|
1656
|
+
{ event: ".ConversationRequestAccepted", handler: w }
|
|
1657
1657
|
]
|
|
1658
|
-
}), g.add(
|
|
1658
|
+
}), g.add(P), e.registerGlobalConversationSubscription(P);
|
|
1659
1659
|
}
|
|
1660
|
-
function
|
|
1661
|
-
const
|
|
1662
|
-
if (!
|
|
1663
|
-
|
|
1660
|
+
function E() {
|
|
1661
|
+
const P = Ae();
|
|
1662
|
+
if (!P) {
|
|
1663
|
+
m();
|
|
1664
1664
|
return;
|
|
1665
1665
|
}
|
|
1666
1666
|
for (const U of g) {
|
|
1667
1667
|
x(U);
|
|
1668
1668
|
try {
|
|
1669
|
-
|
|
1669
|
+
P.leave(`conversation.${U}`);
|
|
1670
1670
|
} catch {
|
|
1671
1671
|
}
|
|
1672
1672
|
e.unregisterGlobalConversationSubscription(U);
|
|
1673
1673
|
}
|
|
1674
1674
|
g.clear();
|
|
1675
1675
|
}
|
|
1676
|
-
function
|
|
1677
|
-
const
|
|
1678
|
-
if (!
|
|
1679
|
-
const U = e.conversations.slice(0, yo),
|
|
1676
|
+
function R() {
|
|
1677
|
+
const P = Ae();
|
|
1678
|
+
if (!P) return;
|
|
1679
|
+
const U = e.conversations.slice(0, yo), $ = new Set(U.map((z) => z.id));
|
|
1680
1680
|
for (const z of g)
|
|
1681
|
-
if (
|
|
1681
|
+
if (!$.has(z) && !e.hasDetailSubscription(z)) {
|
|
1682
1682
|
try {
|
|
1683
|
-
x(z),
|
|
1683
|
+
x(z), P.leave(`conversation.${z}`);
|
|
1684
1684
|
} catch {
|
|
1685
1685
|
}
|
|
1686
1686
|
g.delete(z), e.unregisterGlobalConversationSubscription(z);
|
|
@@ -1688,56 +1688,56 @@ function La() {
|
|
|
1688
1688
|
for (const z of U)
|
|
1689
1689
|
y(z.id);
|
|
1690
1690
|
}
|
|
1691
|
-
function S(
|
|
1691
|
+
function S(P) {
|
|
1692
1692
|
const U = xn({
|
|
1693
|
-
status:
|
|
1694
|
-
last_seen_at:
|
|
1693
|
+
status: P.status,
|
|
1694
|
+
last_seen_at: P.last_seen_at ?? null
|
|
1695
1695
|
});
|
|
1696
1696
|
U.status !== null && e.updatePresenceForUser(
|
|
1697
|
-
|
|
1697
|
+
P.user_id,
|
|
1698
1698
|
U.status,
|
|
1699
1699
|
U.lastSeenAt
|
|
1700
1700
|
);
|
|
1701
1701
|
}
|
|
1702
1702
|
async function f() {
|
|
1703
|
-
const
|
|
1703
|
+
const P = [...new Set(
|
|
1704
1704
|
e.conversations.filter((U) => U.type === "dm" && typeof U.other_user_id == "string" && U.other_user_id.length > 0).map((U) => U.other_user_id)
|
|
1705
1705
|
)];
|
|
1706
|
-
if (
|
|
1706
|
+
if (P.length !== 0)
|
|
1707
1707
|
try {
|
|
1708
1708
|
const U = await o.get("/v1/presence/users", {
|
|
1709
|
-
params: { ids:
|
|
1710
|
-
}),
|
|
1711
|
-
for (const z of
|
|
1712
|
-
const
|
|
1713
|
-
|
|
1709
|
+
params: { ids: P }
|
|
1710
|
+
}), $ = U.data?.data?.items ?? U.data?.items ?? [];
|
|
1711
|
+
for (const z of $) {
|
|
1712
|
+
const K = xn(z);
|
|
1713
|
+
K.status !== null && e.updatePresenceForUser(z.id, K.status, K.lastSeenAt);
|
|
1714
1714
|
}
|
|
1715
1715
|
} catch (U) {
|
|
1716
1716
|
Ye.warn("Failed to refresh messaging presence snapshot", U);
|
|
1717
1717
|
}
|
|
1718
1718
|
}
|
|
1719
|
-
function
|
|
1720
|
-
!Ae() ||
|
|
1719
|
+
function v() {
|
|
1720
|
+
!Ae() || A || (fi(S), A = !0);
|
|
1721
1721
|
}
|
|
1722
1722
|
function b() {
|
|
1723
|
-
|
|
1723
|
+
A && (pi(), A = !1);
|
|
1724
1724
|
}
|
|
1725
1725
|
const F = fn(
|
|
1726
1726
|
h,
|
|
1727
1727
|
() => {
|
|
1728
|
-
|
|
1728
|
+
R();
|
|
1729
1729
|
},
|
|
1730
1730
|
{ deep: !1, immediate: !0 }
|
|
1731
1731
|
), j = fn(
|
|
1732
1732
|
() => u.fullPath,
|
|
1733
1733
|
() => {
|
|
1734
|
-
|
|
1734
|
+
R();
|
|
1735
1735
|
}
|
|
1736
|
-
),
|
|
1737
|
-
|
|
1736
|
+
), B = it((P) => {
|
|
1737
|
+
P === "connected" ? (m(), R(), b(), v(), f()) : (P === "disconnected" || P === "error") && (m(), b());
|
|
1738
1738
|
});
|
|
1739
|
-
|
|
1740
|
-
F(), j(),
|
|
1739
|
+
R(), v(), f(), l !== null && qe(() => {
|
|
1740
|
+
F(), j(), B(), E(), b();
|
|
1741
1741
|
});
|
|
1742
1742
|
}
|
|
1743
1743
|
const ss = {
|
|
@@ -1750,10 +1750,11 @@ const ss = {
|
|
|
1750
1750
|
idleAfterMs: 6e4,
|
|
1751
1751
|
activityDebounceMs: 5e3,
|
|
1752
1752
|
heartbeatIntervalMs: 3e4,
|
|
1753
|
-
userAgentResolver: () => navigator.userAgent.slice(0, 256)
|
|
1753
|
+
userAgentResolver: () => navigator.userAgent.slice(0, 256),
|
|
1754
|
+
authTokenResolver: () => null
|
|
1754
1755
|
};
|
|
1755
1756
|
let st = { ...ss };
|
|
1756
|
-
function
|
|
1757
|
+
function Co() {
|
|
1757
1758
|
return st;
|
|
1758
1759
|
}
|
|
1759
1760
|
function To(e) {
|
|
@@ -1793,7 +1794,7 @@ function Lo(e) {
|
|
|
1793
1794
|
const i = n.data;
|
|
1794
1795
|
return Fe(i) && typeof i.code == "string" ? i.code : null;
|
|
1795
1796
|
}
|
|
1796
|
-
function
|
|
1797
|
+
function Ct(e) {
|
|
1797
1798
|
const n = Io(e), i = Lo(e);
|
|
1798
1799
|
return n === Ro && i === Po || n === Ao && i === xo;
|
|
1799
1800
|
}
|
|
@@ -1824,111 +1825,147 @@ function No(e, n = Date.now()) {
|
|
|
1824
1825
|
function Fo(e) {
|
|
1825
1826
|
ze()?.removeItem(e);
|
|
1826
1827
|
}
|
|
1827
|
-
function
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
const
|
|
1828
|
+
function Do(e, n, i) {
|
|
1829
|
+
if (typeof fetch > "u")
|
|
1830
|
+
return null;
|
|
1831
|
+
const o = {
|
|
1832
|
+
Accept: "application/json",
|
|
1833
|
+
"Content-Type": "application/json"
|
|
1834
|
+
};
|
|
1835
|
+
i && (o.Authorization = `Bearer ${i}`);
|
|
1836
|
+
try {
|
|
1837
|
+
return fetch(e, {
|
|
1838
|
+
method: "POST",
|
|
1839
|
+
headers: o,
|
|
1840
|
+
body: JSON.stringify({ client_id: n }),
|
|
1841
|
+
keepalive: !0,
|
|
1842
|
+
credentials: "same-origin"
|
|
1843
|
+
}).then(() => {
|
|
1844
|
+
});
|
|
1845
|
+
} catch {
|
|
1846
|
+
return null;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
function Oa() {
|
|
1850
|
+
const e = Pe()(), n = Co(), i = es(), o = Uo(n.clientIdStorageKey);
|
|
1851
|
+
let u = null, l = null, h = !1, g = Tt(n.accountLimitedUntilStorageKey), d = !1, A = null, x = 0;
|
|
1852
|
+
const m = () => {
|
|
1831
1853
|
u && (clearInterval(u), u = null);
|
|
1832
1854
|
}, y = () => {
|
|
1833
1855
|
l && (clearTimeout(l), l = null);
|
|
1834
|
-
},
|
|
1835
|
-
|
|
1856
|
+
}, E = () => {
|
|
1857
|
+
m(), u = setInterval(() => {
|
|
1836
1858
|
U();
|
|
1837
1859
|
}, n.heartbeatIntervalMs);
|
|
1838
|
-
},
|
|
1839
|
-
g || console.warn(
|
|
1840
|
-
}, S = async (
|
|
1841
|
-
if (!(!h || d || g) &&
|
|
1860
|
+
}, R = (w) => {
|
|
1861
|
+
g || console.warn(w), No(n.accountLimitedUntilStorageKey), g = !0, h = !1, A = null, m(), y();
|
|
1862
|
+
}, S = async (w) => {
|
|
1863
|
+
if (!(!h || d || g) && A !== w)
|
|
1842
1864
|
try {
|
|
1843
|
-
await i.patch(n.statusUrl, { status:
|
|
1844
|
-
} catch (
|
|
1845
|
-
|
|
1865
|
+
await i.patch(n.statusUrl, { status: w }), A = w;
|
|
1866
|
+
} catch (M) {
|
|
1867
|
+
Ct(M) && R("[Presence] Presence updates paused: account is temporarily limited");
|
|
1846
1868
|
}
|
|
1847
1869
|
}, f = () => {
|
|
1848
1870
|
y(), !(!h || d || g || document.visibilityState !== "visible") && (l = setTimeout(() => {
|
|
1849
1871
|
l = null, S("idle");
|
|
1850
1872
|
}, n.idleAfterMs));
|
|
1851
|
-
},
|
|
1873
|
+
}, v = () => {
|
|
1852
1874
|
if (d || !h || g || document.visibilityState !== "visible")
|
|
1853
1875
|
return;
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1876
|
+
const w = Date.now();
|
|
1877
|
+
w - x < n.activityDebounceMs || (x = w, S("online"), f());
|
|
1856
1878
|
}, b = () => {
|
|
1857
|
-
|
|
1879
|
+
v();
|
|
1858
1880
|
}, F = () => {
|
|
1859
1881
|
typeof document > "u" || typeof window > "u" || (document.addEventListener("pointerdown", b, { passive: !0 }), document.addEventListener("keydown", b), document.addEventListener("touchstart", b, { passive: !0 }), window.addEventListener("focus", b));
|
|
1860
1882
|
}, j = () => {
|
|
1861
1883
|
typeof document > "u" || typeof window > "u" || (document.removeEventListener("pointerdown", b), document.removeEventListener("keydown", b), document.removeEventListener("touchstart", b), window.removeEventListener("focus", b));
|
|
1862
|
-
},
|
|
1884
|
+
}, B = async () => {
|
|
1863
1885
|
if (Tt(n.accountLimitedUntilStorageKey))
|
|
1864
1886
|
return g = !0, "account_limited";
|
|
1865
1887
|
try {
|
|
1866
1888
|
return await i.post(n.sessionOpenUrl, {
|
|
1867
1889
|
client_id: o,
|
|
1868
1890
|
user_agent: n.userAgentResolver()
|
|
1869
|
-
}), Fo(n.accountLimitedUntilStorageKey), g = !1, h = !0,
|
|
1870
|
-
} catch (
|
|
1871
|
-
return
|
|
1891
|
+
}), Fo(n.accountLimitedUntilStorageKey), g = !1, h = !0, A = null, "opened";
|
|
1892
|
+
} catch (w) {
|
|
1893
|
+
return Ct(w) ? (R("[Presence] Session open skipped: account is temporarily limited"), "account_limited") : "failed";
|
|
1872
1894
|
}
|
|
1873
|
-
},
|
|
1874
|
-
for (let
|
|
1875
|
-
if (await
|
|
1895
|
+
}, P = async () => {
|
|
1896
|
+
for (let w = 0; w < Mo; w += 1)
|
|
1897
|
+
if (await B() !== "failed")
|
|
1876
1898
|
return;
|
|
1877
1899
|
console.warn("[Presence] Failed to open session");
|
|
1878
1900
|
}, U = async () => {
|
|
1879
1901
|
if (h)
|
|
1880
1902
|
try {
|
|
1881
1903
|
await i.post(n.sessionHeartbeatUrl, { client_id: o });
|
|
1882
|
-
} catch (
|
|
1883
|
-
|
|
1904
|
+
} catch (w) {
|
|
1905
|
+
Ct(w) && R("[Presence] Heartbeat paused: account is temporarily limited");
|
|
1884
1906
|
}
|
|
1885
|
-
},
|
|
1886
|
-
|
|
1887
|
-
|
|
1907
|
+
}, $ = () => {
|
|
1908
|
+
if (!h)
|
|
1909
|
+
return;
|
|
1910
|
+
h = !1, A = null, y();
|
|
1911
|
+
const w = Do(
|
|
1912
|
+
n.sessionCloseUrl,
|
|
1913
|
+
o,
|
|
1914
|
+
n.authTokenResolver()
|
|
1915
|
+
);
|
|
1916
|
+
if (w) {
|
|
1917
|
+
w.catch(() => {
|
|
1918
|
+
});
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
i.post(n.sessionCloseUrl, { client_id: o }).catch(() => {
|
|
1922
|
+
});
|
|
1888
1923
|
}, z = async () => {
|
|
1889
1924
|
if (!d) {
|
|
1890
|
-
if (await
|
|
1891
|
-
|
|
1925
|
+
if (await P(), d) {
|
|
1926
|
+
$();
|
|
1892
1927
|
return;
|
|
1893
1928
|
}
|
|
1894
|
-
h && (
|
|
1929
|
+
h && (E(), S("online"), f());
|
|
1895
1930
|
}
|
|
1896
|
-
},
|
|
1931
|
+
}, K = () => {
|
|
1897
1932
|
if (!d) {
|
|
1898
1933
|
if (document.visibilityState === "hidden") {
|
|
1899
|
-
|
|
1934
|
+
$(), m(), y();
|
|
1900
1935
|
return;
|
|
1901
1936
|
}
|
|
1902
1937
|
if (document.visibilityState === "visible" && !h) {
|
|
1903
1938
|
g = Tt(n.accountLimitedUntilStorageKey), g || z();
|
|
1904
1939
|
return;
|
|
1905
1940
|
}
|
|
1906
|
-
document.visibilityState === "visible" && h && !g &&
|
|
1941
|
+
document.visibilityState === "visible" && h && !g && v();
|
|
1907
1942
|
}
|
|
1943
|
+
}, se = () => {
|
|
1944
|
+
d || ($(), m(), y());
|
|
1908
1945
|
};
|
|
1909
1946
|
Un(async () => {
|
|
1910
1947
|
if (e.isAuthenticated ?? e.currentUser !== null) {
|
|
1911
|
-
if (await
|
|
1912
|
-
|
|
1948
|
+
if (await P(), d) {
|
|
1949
|
+
$();
|
|
1913
1950
|
return;
|
|
1914
1951
|
}
|
|
1915
|
-
h && (
|
|
1952
|
+
h && (E(), S("online"), f()), F(), document.addEventListener("visibilitychange", K), window.addEventListener("pagehide", se), window.addEventListener("beforeunload", se);
|
|
1916
1953
|
}
|
|
1917
1954
|
}), qe(() => {
|
|
1918
|
-
d = !0, j(), y(),
|
|
1955
|
+
d = !0, j(), y(), m(), $(), document.removeEventListener("visibilitychange", K), window.removeEventListener("pagehide", se), window.removeEventListener("beforeunload", se);
|
|
1919
1956
|
});
|
|
1920
1957
|
}
|
|
1921
|
-
const
|
|
1922
|
-
function
|
|
1923
|
-
const n = Nt(), i = Pe()(), o = de(!1), u = de(null), l = de(null), h = de([]), g = /* @__PURE__ */ new Map(), d = xt(),
|
|
1924
|
-
let x = 0,
|
|
1925
|
-
const
|
|
1958
|
+
const qo = 12e3, zo = 250, jo = 20;
|
|
1959
|
+
function Na(e) {
|
|
1960
|
+
const n = Nt(), i = Pe()(), o = de(!1), u = de(null), l = de(null), h = de([]), g = /* @__PURE__ */ new Map(), d = xt(), A = d !== null;
|
|
1961
|
+
let x = 0, m = null, y = null;
|
|
1962
|
+
const E = ie(() => i.currentUser?.id), R = () => Ln(e)?.trim() ?? "", S = () => {
|
|
1926
1963
|
const C = l.value?.trim() ?? "";
|
|
1927
1964
|
if (C.length > 0)
|
|
1928
1965
|
return C;
|
|
1929
|
-
const O =
|
|
1966
|
+
const O = R();
|
|
1930
1967
|
return O.length > 0 && (l.value = O), O;
|
|
1931
|
-
}, f = (C) => n.getTypingUsers(C),
|
|
1968
|
+
}, f = (C) => n.getTypingUsers(C), v = (C) => {
|
|
1932
1969
|
const O = f(C);
|
|
1933
1970
|
for (const L of O)
|
|
1934
1971
|
n.removeTypingUser(C, L.id);
|
|
@@ -1943,40 +1980,40 @@ function Oa(e) {
|
|
|
1943
1980
|
}, j = (C, O) => {
|
|
1944
1981
|
b(C);
|
|
1945
1982
|
const L = setTimeout(() => {
|
|
1946
|
-
g.delete(C), n.removeTypingUser(O, C), h.value = h.value.filter((
|
|
1947
|
-
},
|
|
1983
|
+
g.delete(C), n.removeTypingUser(O, C), h.value = h.value.filter((H) => H.id !== C);
|
|
1984
|
+
}, qo);
|
|
1948
1985
|
g.set(C, L);
|
|
1949
|
-
},
|
|
1950
|
-
|
|
1951
|
-
},
|
|
1952
|
-
const C =
|
|
1986
|
+
}, B = () => {
|
|
1987
|
+
m && (clearTimeout(m), m = null), x = 0;
|
|
1988
|
+
}, P = () => {
|
|
1989
|
+
const C = R();
|
|
1953
1990
|
if (!(o.value || !C)) {
|
|
1954
1991
|
if (u.value = null, !Ae()) {
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
},
|
|
1992
|
+
A && !m && x < jo && (m = setTimeout(() => {
|
|
1993
|
+
m = null, x += 1, P();
|
|
1994
|
+
}, zo));
|
|
1958
1995
|
return;
|
|
1959
1996
|
}
|
|
1960
1997
|
try {
|
|
1961
1998
|
y && (y(), y = null), y = vi(C, {
|
|
1962
|
-
onTypingStart:
|
|
1999
|
+
onTypingStart: $,
|
|
1963
2000
|
onTypingStop: z
|
|
1964
|
-
}), o.value = !0, l.value = C,
|
|
2001
|
+
}), o.value = !0, l.value = C, B();
|
|
1965
2002
|
} catch (O) {
|
|
1966
2003
|
u.value = O instanceof Error ? O.message : "Failed to subscribe to typing channel";
|
|
1967
2004
|
}
|
|
1968
2005
|
}
|
|
1969
2006
|
}, U = () => {
|
|
1970
2007
|
const C = l.value;
|
|
1971
|
-
if (
|
|
2008
|
+
if (B(), !(!o.value || !C))
|
|
1972
2009
|
try {
|
|
1973
|
-
y && (y(), y = null), bi(C), F(),
|
|
2010
|
+
y && (y(), y = null), bi(C), F(), v(C), o.value = !1, l.value = null, u.value = null;
|
|
1974
2011
|
} catch (O) {
|
|
1975
2012
|
u.value = O instanceof Error ? O.message : "Failed to unsubscribe from typing channel";
|
|
1976
2013
|
}
|
|
1977
2014
|
};
|
|
1978
|
-
function
|
|
1979
|
-
if (C.user_id ===
|
|
2015
|
+
function $(C) {
|
|
2016
|
+
if (C.user_id === E.value)
|
|
1980
2017
|
return;
|
|
1981
2018
|
const O = S();
|
|
1982
2019
|
if (!O)
|
|
@@ -1986,16 +2023,16 @@ function Oa(e) {
|
|
|
1986
2023
|
name: C.user.name,
|
|
1987
2024
|
...C.user.avatar !== void 0 ? { avatar: C.user.avatar } : {}
|
|
1988
2025
|
};
|
|
1989
|
-
h.value.some((
|
|
2026
|
+
h.value.some((H) => H.id === L.id) || (h.value = [...h.value, L]), n.addTypingUser(O, L), j(C.user_id, O);
|
|
1990
2027
|
}
|
|
1991
2028
|
function z(C) {
|
|
1992
|
-
if (C.user_id ===
|
|
2029
|
+
if (C.user_id === E.value)
|
|
1993
2030
|
return;
|
|
1994
2031
|
b(C.user_id);
|
|
1995
2032
|
const O = S();
|
|
1996
2033
|
O && (h.value = h.value.filter((L) => L.id !== C.user_id), n.removeTypingUser(O, C.user_id));
|
|
1997
2034
|
}
|
|
1998
|
-
const
|
|
2035
|
+
const K = ie(() => {
|
|
1999
2036
|
const C = S();
|
|
2000
2037
|
if (!C)
|
|
2001
2038
|
return h.value;
|
|
@@ -2005,13 +2042,13 @@ function Oa(e) {
|
|
|
2005
2042
|
if (O.length === 0)
|
|
2006
2043
|
return h.value;
|
|
2007
2044
|
const L = /* @__PURE__ */ new Map();
|
|
2008
|
-
for (const
|
|
2009
|
-
L.set(
|
|
2010
|
-
for (const
|
|
2011
|
-
L.set(
|
|
2045
|
+
for (const H of O)
|
|
2046
|
+
L.set(H.id, H);
|
|
2047
|
+
for (const H of h.value)
|
|
2048
|
+
L.set(H.id, H);
|
|
2012
2049
|
return [...L.values()];
|
|
2013
|
-
}),
|
|
2014
|
-
const C =
|
|
2050
|
+
}), se = ie(() => {
|
|
2051
|
+
const C = K.value;
|
|
2015
2052
|
if (C.length === 0)
|
|
2016
2053
|
return "";
|
|
2017
2054
|
const O = C[0];
|
|
@@ -2024,39 +2061,39 @@ function Oa(e) {
|
|
|
2024
2061
|
return `${C.length} people are typing...`;
|
|
2025
2062
|
if (C.length === 2)
|
|
2026
2063
|
return `${O.name} and ${L.name} are typing...`;
|
|
2027
|
-
const
|
|
2028
|
-
return
|
|
2029
|
-
}),
|
|
2030
|
-
o.value ||
|
|
2064
|
+
const H = C[2];
|
|
2065
|
+
return H ? C.length === 3 ? `${O.name}, ${L.name} and ${H.name} are typing...` : `${C.length} people are typing...` : `${C.length} people are typing...`;
|
|
2066
|
+
}), w = ie(() => K.value.length > 0), M = () => {
|
|
2067
|
+
o.value || P();
|
|
2031
2068
|
};
|
|
2032
2069
|
typeof window < "u" && window.addEventListener(De(), M);
|
|
2033
|
-
const
|
|
2070
|
+
const ee = it((C) => {
|
|
2034
2071
|
if (C === "connected") {
|
|
2035
|
-
o.value ||
|
|
2072
|
+
o.value || P();
|
|
2036
2073
|
return;
|
|
2037
2074
|
}
|
|
2038
2075
|
if (C === "disconnected" || C === "error") {
|
|
2039
|
-
|
|
2076
|
+
B(), y && (y(), y = null);
|
|
2040
2077
|
const O = S();
|
|
2041
|
-
O &&
|
|
2078
|
+
O && v(O), o.value = !1, l.value = null, F();
|
|
2042
2079
|
}
|
|
2043
2080
|
});
|
|
2044
2081
|
return d !== null && qe(() => {
|
|
2045
|
-
|
|
2082
|
+
B(), ee(), F(), U(), typeof window < "u" && window.removeEventListener(De(), M);
|
|
2046
2083
|
}), {
|
|
2047
2084
|
isSubscribed: ie(() => o.value),
|
|
2048
2085
|
error: ie(() => u.value),
|
|
2049
|
-
typingUsers:
|
|
2050
|
-
formatTypingIndicator:
|
|
2051
|
-
hasTypingUsers:
|
|
2052
|
-
subscribe:
|
|
2086
|
+
typingUsers: K,
|
|
2087
|
+
formatTypingIndicator: se,
|
|
2088
|
+
hasTypingUsers: w,
|
|
2089
|
+
subscribe: P,
|
|
2053
2090
|
unsubscribe: U
|
|
2054
2091
|
};
|
|
2055
2092
|
}
|
|
2056
|
-
function
|
|
2093
|
+
function Fa(e) {
|
|
2057
2094
|
e.apiClient && Ti(e.apiClient), e.mainApiClient && uo(e.mainApiClient), e.authStore && Ri(e.authStore), e.mediaApi && xi(e.mediaApi), e.createLogger && io(e.createLogger), e.playMessageNotification && vo(e.playMessageNotification), e.echo && yi(e.echo), e.mainEcho && no(e.mainEcho), e.presence && To(e.presence);
|
|
2058
2095
|
}
|
|
2059
|
-
function
|
|
2096
|
+
function Da() {
|
|
2060
2097
|
Ei(), lo(), Ai(), Mi(), oo(), bo(), _i(), so(), Eo();
|
|
2061
2098
|
}
|
|
2062
2099
|
class jt {
|
|
@@ -2108,7 +2145,7 @@ class rs {
|
|
|
2108
2145
|
this.namespace = n;
|
|
2109
2146
|
}
|
|
2110
2147
|
}
|
|
2111
|
-
function
|
|
2148
|
+
function $o(e) {
|
|
2112
2149
|
try {
|
|
2113
2150
|
new e();
|
|
2114
2151
|
} catch (n) {
|
|
@@ -2205,7 +2242,7 @@ class is extends $t {
|
|
|
2205
2242
|
), this;
|
|
2206
2243
|
}
|
|
2207
2244
|
}
|
|
2208
|
-
class
|
|
2245
|
+
class Ho extends $t {
|
|
2209
2246
|
/**
|
|
2210
2247
|
* Send a whisper event to other clients in the channel.
|
|
2211
2248
|
*/
|
|
@@ -2216,7 +2253,7 @@ class $o extends $t {
|
|
|
2216
2253
|
), this;
|
|
2217
2254
|
}
|
|
2218
2255
|
}
|
|
2219
|
-
class
|
|
2256
|
+
class Bo extends is {
|
|
2220
2257
|
/**
|
|
2221
2258
|
* Register a callback to be called anytime the member list changes.
|
|
2222
2259
|
*/
|
|
@@ -2339,7 +2376,7 @@ class as extends os {
|
|
|
2339
2376
|
}), this;
|
|
2340
2377
|
}
|
|
2341
2378
|
}
|
|
2342
|
-
class
|
|
2379
|
+
class Vo extends as {
|
|
2343
2380
|
/**
|
|
2344
2381
|
* Register a callback to be called anytime the member list changes.
|
|
2345
2382
|
*/
|
|
@@ -2433,7 +2470,7 @@ class cs extends rt {
|
|
|
2433
2470
|
return this;
|
|
2434
2471
|
}
|
|
2435
2472
|
}
|
|
2436
|
-
class
|
|
2473
|
+
class Xo extends rt {
|
|
2437
2474
|
/**
|
|
2438
2475
|
* Send a whisper event to other clients in the channel.
|
|
2439
2476
|
*/
|
|
@@ -2441,7 +2478,7 @@ class Vo extends rt {
|
|
|
2441
2478
|
return this;
|
|
2442
2479
|
}
|
|
2443
2480
|
}
|
|
2444
|
-
class
|
|
2481
|
+
class Wo extends cs {
|
|
2445
2482
|
/**
|
|
2446
2483
|
* Register a callback to be called anytime the member list changes.
|
|
2447
2484
|
*/
|
|
@@ -2568,7 +2605,7 @@ class Qe extends Ht {
|
|
|
2568
2605
|
* Get a private encrypted channel instance by name.
|
|
2569
2606
|
*/
|
|
2570
2607
|
encryptedPrivateChannel(n) {
|
|
2571
|
-
return this.channels["private-encrypted-" + n] || (this.channels["private-encrypted-" + n] = new
|
|
2608
|
+
return this.channels["private-encrypted-" + n] || (this.channels["private-encrypted-" + n] = new Ho(
|
|
2572
2609
|
this.pusher,
|
|
2573
2610
|
"private-encrypted-" + n,
|
|
2574
2611
|
this.options
|
|
@@ -2578,7 +2615,7 @@ class Qe extends Ht {
|
|
|
2578
2615
|
* Get a presence channel instance by name.
|
|
2579
2616
|
*/
|
|
2580
2617
|
presenceChannel(n) {
|
|
2581
|
-
return this.channels["presence-" + n] || (this.channels["presence-" + n] = new
|
|
2618
|
+
return this.channels["presence-" + n] || (this.channels["presence-" + n] = new Bo(
|
|
2582
2619
|
this.pusher,
|
|
2583
2620
|
"presence-" + n,
|
|
2584
2621
|
this.options
|
|
@@ -2647,7 +2684,7 @@ class Qe extends Ht {
|
|
|
2647
2684
|
this.pusher.disconnect();
|
|
2648
2685
|
}
|
|
2649
2686
|
}
|
|
2650
|
-
class
|
|
2687
|
+
class Go extends Ht {
|
|
2651
2688
|
constructor() {
|
|
2652
2689
|
super(...arguments), this.channels = {};
|
|
2653
2690
|
}
|
|
@@ -2707,7 +2744,7 @@ class Wo extends Ht {
|
|
|
2707
2744
|
* Get a presence channel instance by name.
|
|
2708
2745
|
*/
|
|
2709
2746
|
presenceChannel(n) {
|
|
2710
|
-
return this.channels["presence-" + n] || (this.channels["presence-" + n] = new
|
|
2747
|
+
return this.channels["presence-" + n] || (this.channels["presence-" + n] = new Vo(
|
|
2711
2748
|
this.socket,
|
|
2712
2749
|
"presence-" + n,
|
|
2713
2750
|
this.options
|
|
@@ -2800,13 +2837,13 @@ class Mn extends Ht {
|
|
|
2800
2837
|
* Get a private encrypted channel instance by name.
|
|
2801
2838
|
*/
|
|
2802
2839
|
encryptedPrivateChannel(n) {
|
|
2803
|
-
return new
|
|
2840
|
+
return new Xo();
|
|
2804
2841
|
}
|
|
2805
2842
|
/**
|
|
2806
2843
|
* Get a presence channel instance by name.
|
|
2807
2844
|
*/
|
|
2808
2845
|
presenceChannel(n) {
|
|
2809
|
-
return new
|
|
2846
|
+
return new Wo();
|
|
2810
2847
|
}
|
|
2811
2848
|
/**
|
|
2812
2849
|
* Leave the given channel, as well as its private and presence variants.
|
|
@@ -2843,7 +2880,7 @@ class Mn extends Ht {
|
|
|
2843
2880
|
disconnect() {
|
|
2844
2881
|
}
|
|
2845
2882
|
}
|
|
2846
|
-
class
|
|
2883
|
+
class Jo {
|
|
2847
2884
|
/**
|
|
2848
2885
|
* Create a new class instance.
|
|
2849
2886
|
*/
|
|
@@ -2874,10 +2911,10 @@ class Go {
|
|
|
2874
2911
|
broadcaster: "pusher"
|
|
2875
2912
|
});
|
|
2876
2913
|
else if (this.options.broadcaster === "socket.io")
|
|
2877
|
-
this.connector = new
|
|
2914
|
+
this.connector = new Go(this.options);
|
|
2878
2915
|
else if (this.options.broadcaster === "null")
|
|
2879
2916
|
this.connector = new Mn(this.options);
|
|
2880
|
-
else if (typeof this.options.broadcaster == "function" &&
|
|
2917
|
+
else if (typeof this.options.broadcaster == "function" && $o(this.options.broadcaster))
|
|
2881
2918
|
this.connector = new this.options.broadcaster(this.options);
|
|
2882
2919
|
else
|
|
2883
2920
|
throw new Error(
|
|
@@ -3001,12 +3038,12 @@ class Go {
|
|
|
3001
3038
|
);
|
|
3002
3039
|
}
|
|
3003
3040
|
}
|
|
3004
|
-
function
|
|
3041
|
+
function Ko(e) {
|
|
3005
3042
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
3006
3043
|
}
|
|
3007
3044
|
var Et = { exports: {} };
|
|
3008
3045
|
var kn;
|
|
3009
|
-
function
|
|
3046
|
+
function Yo() {
|
|
3010
3047
|
return kn || (kn = 1, (function(e, n) {
|
|
3011
3048
|
(function(o, u) {
|
|
3012
3049
|
e.exports = u();
|
|
@@ -3036,8 +3073,8 @@ function Ko() {
|
|
|
3036
3073
|
}, u.t = function(l, h) {
|
|
3037
3074
|
if (h & 1 && (l = u(l)), h & 8 || h & 4 && typeof l == "object" && l && l.__esModule) return l;
|
|
3038
3075
|
var g = /* @__PURE__ */ Object.create(null);
|
|
3039
|
-
if (u.r(g), Object.defineProperty(g, "default", { enumerable: !0, value: l }), h & 2 && typeof l != "string") for (var d in l) u.d(g, d, (function(
|
|
3040
|
-
return l[
|
|
3076
|
+
if (u.r(g), Object.defineProperty(g, "default", { enumerable: !0, value: l }), h & 2 && typeof l != "string") for (var d in l) u.d(g, d, (function(A) {
|
|
3077
|
+
return l[A];
|
|
3041
3078
|
}).bind(null, d));
|
|
3042
3079
|
return g;
|
|
3043
3080
|
}, u.n = function(l) {
|
|
@@ -3061,19 +3098,19 @@ function Ko() {
|
|
|
3061
3098
|
/***/
|
|
3062
3099
|
(function(i, o, u) {
|
|
3063
3100
|
var l = this && this.__extends || /* @__PURE__ */ (function() {
|
|
3064
|
-
var S = function(f,
|
|
3101
|
+
var S = function(f, v) {
|
|
3065
3102
|
return S = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(b, F) {
|
|
3066
3103
|
b.__proto__ = F;
|
|
3067
3104
|
} || function(b, F) {
|
|
3068
3105
|
for (var j in F) F.hasOwnProperty(j) && (b[j] = F[j]);
|
|
3069
|
-
}, S(f,
|
|
3106
|
+
}, S(f, v);
|
|
3070
3107
|
};
|
|
3071
|
-
return function(f,
|
|
3072
|
-
S(f,
|
|
3108
|
+
return function(f, v) {
|
|
3109
|
+
S(f, v);
|
|
3073
3110
|
function b() {
|
|
3074
3111
|
this.constructor = f;
|
|
3075
3112
|
}
|
|
3076
|
-
f.prototype =
|
|
3113
|
+
f.prototype = v === null ? Object.create(v) : (b.prototype = v.prototype, new b());
|
|
3077
3114
|
};
|
|
3078
3115
|
})();
|
|
3079
3116
|
Object.defineProperty(o, "__esModule", { value: !0 });
|
|
@@ -3086,16 +3123,16 @@ function Ko() {
|
|
|
3086
3123
|
return S.prototype.encodedLength = function(f) {
|
|
3087
3124
|
return this._paddingCharacter ? (f + 2) / 3 * 4 | 0 : (f * 8 + 5) / 6 | 0;
|
|
3088
3125
|
}, S.prototype.encode = function(f) {
|
|
3089
|
-
for (var
|
|
3126
|
+
for (var v = "", b = 0; b < f.length - 2; b += 3) {
|
|
3090
3127
|
var F = f[b] << 16 | f[b + 1] << 8 | f[b + 2];
|
|
3091
|
-
|
|
3128
|
+
v += this._encodeByte(F >>> 18 & 63), v += this._encodeByte(F >>> 12 & 63), v += this._encodeByte(F >>> 6 & 63), v += this._encodeByte(F >>> 0 & 63);
|
|
3092
3129
|
}
|
|
3093
3130
|
var j = f.length - b;
|
|
3094
3131
|
if (j > 0) {
|
|
3095
3132
|
var F = f[b] << 16 | (j === 2 ? f[b + 1] << 8 : 0);
|
|
3096
|
-
|
|
3133
|
+
v += this._encodeByte(F >>> 18 & 63), v += this._encodeByte(F >>> 12 & 63), j === 2 ? v += this._encodeByte(F >>> 6 & 63) : v += this._paddingCharacter || "", v += this._paddingCharacter || "";
|
|
3097
3134
|
}
|
|
3098
|
-
return
|
|
3135
|
+
return v;
|
|
3099
3136
|
}, S.prototype.maxDecodedLength = function(f) {
|
|
3100
3137
|
return this._paddingCharacter ? f / 4 * 3 | 0 : (f * 6 + 7) / 8 | 0;
|
|
3101
3138
|
}, S.prototype.decodedLength = function(f) {
|
|
@@ -3103,65 +3140,65 @@ function Ko() {
|
|
|
3103
3140
|
}, S.prototype.decode = function(f) {
|
|
3104
3141
|
if (f.length === 0)
|
|
3105
3142
|
return new Uint8Array(0);
|
|
3106
|
-
for (var
|
|
3107
|
-
U = this._decodeChar(f.charCodeAt(
|
|
3108
|
-
if (
|
|
3143
|
+
for (var v = this._getPaddingLength(f), b = f.length - v, F = new Uint8Array(this.maxDecodedLength(b)), j = 0, B = 0, P = 0, U = 0, $ = 0, z = 0, K = 0; B < b - 4; B += 4)
|
|
3144
|
+
U = this._decodeChar(f.charCodeAt(B + 0)), $ = this._decodeChar(f.charCodeAt(B + 1)), z = this._decodeChar(f.charCodeAt(B + 2)), K = this._decodeChar(f.charCodeAt(B + 3)), F[j++] = U << 2 | $ >>> 4, F[j++] = $ << 4 | z >>> 2, F[j++] = z << 6 | K, P |= U & h, P |= $ & h, P |= z & h, P |= K & h;
|
|
3145
|
+
if (B < b - 1 && (U = this._decodeChar(f.charCodeAt(B)), $ = this._decodeChar(f.charCodeAt(B + 1)), F[j++] = U << 2 | $ >>> 4, P |= U & h, P |= $ & h), B < b - 2 && (z = this._decodeChar(f.charCodeAt(B + 2)), F[j++] = $ << 4 | z >>> 2, P |= z & h), B < b - 3 && (K = this._decodeChar(f.charCodeAt(B + 3)), F[j++] = z << 6 | K, P |= K & h), P !== 0)
|
|
3109
3146
|
throw new Error("Base64Coder: incorrect characters for decoding");
|
|
3110
3147
|
return F;
|
|
3111
3148
|
}, S.prototype._encodeByte = function(f) {
|
|
3112
|
-
var
|
|
3113
|
-
return
|
|
3149
|
+
var v = f;
|
|
3150
|
+
return v += 65, v += 25 - f >>> 8 & 6, v += 51 - f >>> 8 & -75, v += 61 - f >>> 8 & -15, v += 62 - f >>> 8 & 3, String.fromCharCode(v);
|
|
3114
3151
|
}, S.prototype._decodeChar = function(f) {
|
|
3115
|
-
var
|
|
3116
|
-
return
|
|
3152
|
+
var v = h;
|
|
3153
|
+
return v += (42 - f & f - 44) >>> 8 & -h + f - 43 + 62, v += (46 - f & f - 48) >>> 8 & -h + f - 47 + 63, v += (47 - f & f - 58) >>> 8 & -h + f - 48 + 52, v += (64 - f & f - 91) >>> 8 & -h + f - 65 + 0, v += (96 - f & f - 123) >>> 8 & -h + f - 97 + 26, v;
|
|
3117
3154
|
}, S.prototype._getPaddingLength = function(f) {
|
|
3118
|
-
var
|
|
3155
|
+
var v = 0;
|
|
3119
3156
|
if (this._paddingCharacter) {
|
|
3120
3157
|
for (var b = f.length - 1; b >= 0 && f[b] === this._paddingCharacter; b--)
|
|
3121
|
-
|
|
3122
|
-
if (f.length < 4 ||
|
|
3158
|
+
v++;
|
|
3159
|
+
if (f.length < 4 || v > 2)
|
|
3123
3160
|
throw new Error("Base64Coder: incorrect padding");
|
|
3124
3161
|
}
|
|
3125
|
-
return
|
|
3162
|
+
return v;
|
|
3126
3163
|
}, S;
|
|
3127
3164
|
})()
|
|
3128
3165
|
);
|
|
3129
3166
|
o.Coder = g;
|
|
3130
3167
|
var d = new g();
|
|
3131
|
-
function
|
|
3168
|
+
function A(S) {
|
|
3132
3169
|
return d.encode(S);
|
|
3133
3170
|
}
|
|
3134
|
-
o.encode =
|
|
3171
|
+
o.encode = A;
|
|
3135
3172
|
function x(S) {
|
|
3136
3173
|
return d.decode(S);
|
|
3137
3174
|
}
|
|
3138
3175
|
o.decode = x;
|
|
3139
|
-
var
|
|
3176
|
+
var m = (
|
|
3140
3177
|
/** @class */
|
|
3141
3178
|
(function(S) {
|
|
3142
3179
|
l(f, S);
|
|
3143
3180
|
function f() {
|
|
3144
3181
|
return S !== null && S.apply(this, arguments) || this;
|
|
3145
3182
|
}
|
|
3146
|
-
return f.prototype._encodeByte = function(
|
|
3147
|
-
var b =
|
|
3148
|
-
return b += 65, b += 25 -
|
|
3149
|
-
}, f.prototype._decodeChar = function(
|
|
3183
|
+
return f.prototype._encodeByte = function(v) {
|
|
3184
|
+
var b = v;
|
|
3185
|
+
return b += 65, b += 25 - v >>> 8 & 6, b += 51 - v >>> 8 & -75, b += 61 - v >>> 8 & -13, b += 62 - v >>> 8 & 49, String.fromCharCode(b);
|
|
3186
|
+
}, f.prototype._decodeChar = function(v) {
|
|
3150
3187
|
var b = h;
|
|
3151
|
-
return b += (44 -
|
|
3188
|
+
return b += (44 - v & v - 46) >>> 8 & -h + v - 45 + 62, b += (94 - v & v - 96) >>> 8 & -h + v - 95 + 63, b += (47 - v & v - 58) >>> 8 & -h + v - 48 + 52, b += (64 - v & v - 91) >>> 8 & -h + v - 65 + 0, b += (96 - v & v - 123) >>> 8 & -h + v - 97 + 26, b;
|
|
3152
3189
|
}, f;
|
|
3153
3190
|
})(g)
|
|
3154
3191
|
);
|
|
3155
|
-
o.URLSafeCoder =
|
|
3156
|
-
var y = new
|
|
3157
|
-
function
|
|
3192
|
+
o.URLSafeCoder = m;
|
|
3193
|
+
var y = new m();
|
|
3194
|
+
function E(S) {
|
|
3158
3195
|
return y.encode(S);
|
|
3159
3196
|
}
|
|
3160
|
-
o.encodeURLSafe =
|
|
3161
|
-
function
|
|
3197
|
+
o.encodeURLSafe = E;
|
|
3198
|
+
function R(S) {
|
|
3162
3199
|
return y.decode(S);
|
|
3163
3200
|
}
|
|
3164
|
-
o.decodeURLSafe =
|
|
3201
|
+
o.decodeURLSafe = R, o.encodedLength = function(S) {
|
|
3165
3202
|
return d.encodedLength(S);
|
|
3166
3203
|
}, o.maxDecodedLength = function(S) {
|
|
3167
3204
|
return d.maxDecodedLength(S);
|
|
@@ -3175,73 +3212,73 @@ function Ko() {
|
|
|
3175
3212
|
Object.defineProperty(o, "__esModule", { value: !0 });
|
|
3176
3213
|
var l = "utf8: invalid string", h = "utf8: invalid source encoding";
|
|
3177
3214
|
function g(x) {
|
|
3178
|
-
for (var
|
|
3179
|
-
var
|
|
3180
|
-
|
|
3215
|
+
for (var m = new Uint8Array(d(x)), y = 0, E = 0; E < x.length; E++) {
|
|
3216
|
+
var R = x.charCodeAt(E);
|
|
3217
|
+
R < 128 ? m[y++] = R : R < 2048 ? (m[y++] = 192 | R >> 6, m[y++] = 128 | R & 63) : R < 55296 ? (m[y++] = 224 | R >> 12, m[y++] = 128 | R >> 6 & 63, m[y++] = 128 | R & 63) : (E++, R = (R & 1023) << 10, R |= x.charCodeAt(E) & 1023, R += 65536, m[y++] = 240 | R >> 18, m[y++] = 128 | R >> 12 & 63, m[y++] = 128 | R >> 6 & 63, m[y++] = 128 | R & 63);
|
|
3181
3218
|
}
|
|
3182
|
-
return
|
|
3219
|
+
return m;
|
|
3183
3220
|
}
|
|
3184
3221
|
o.encode = g;
|
|
3185
3222
|
function d(x) {
|
|
3186
|
-
for (var
|
|
3187
|
-
var
|
|
3188
|
-
if (
|
|
3189
|
-
|
|
3190
|
-
else if (
|
|
3191
|
-
|
|
3192
|
-
else if (
|
|
3193
|
-
|
|
3194
|
-
else if (
|
|
3223
|
+
for (var m = 0, y = 0; y < x.length; y++) {
|
|
3224
|
+
var E = x.charCodeAt(y);
|
|
3225
|
+
if (E < 128)
|
|
3226
|
+
m += 1;
|
|
3227
|
+
else if (E < 2048)
|
|
3228
|
+
m += 2;
|
|
3229
|
+
else if (E < 55296)
|
|
3230
|
+
m += 3;
|
|
3231
|
+
else if (E <= 57343) {
|
|
3195
3232
|
if (y >= x.length - 1)
|
|
3196
3233
|
throw new Error(l);
|
|
3197
|
-
y++,
|
|
3234
|
+
y++, m += 4;
|
|
3198
3235
|
} else
|
|
3199
3236
|
throw new Error(l);
|
|
3200
3237
|
}
|
|
3201
|
-
return
|
|
3238
|
+
return m;
|
|
3202
3239
|
}
|
|
3203
3240
|
o.encodedLength = d;
|
|
3204
|
-
function
|
|
3205
|
-
for (var
|
|
3206
|
-
var
|
|
3207
|
-
if (
|
|
3208
|
-
var
|
|
3209
|
-
if (
|
|
3241
|
+
function A(x) {
|
|
3242
|
+
for (var m = [], y = 0; y < x.length; y++) {
|
|
3243
|
+
var E = x[y];
|
|
3244
|
+
if (E & 128) {
|
|
3245
|
+
var R = void 0;
|
|
3246
|
+
if (E < 224) {
|
|
3210
3247
|
if (y >= x.length)
|
|
3211
3248
|
throw new Error(h);
|
|
3212
3249
|
var S = x[++y];
|
|
3213
3250
|
if ((S & 192) !== 128)
|
|
3214
3251
|
throw new Error(h);
|
|
3215
|
-
|
|
3216
|
-
} else if (
|
|
3252
|
+
E = (E & 31) << 6 | S & 63, R = 128;
|
|
3253
|
+
} else if (E < 240) {
|
|
3217
3254
|
if (y >= x.length - 1)
|
|
3218
3255
|
throw new Error(h);
|
|
3219
3256
|
var S = x[++y], f = x[++y];
|
|
3220
3257
|
if ((S & 192) !== 128 || (f & 192) !== 128)
|
|
3221
3258
|
throw new Error(h);
|
|
3222
|
-
|
|
3223
|
-
} else if (
|
|
3259
|
+
E = (E & 15) << 12 | (S & 63) << 6 | f & 63, R = 2048;
|
|
3260
|
+
} else if (E < 248) {
|
|
3224
3261
|
if (y >= x.length - 2)
|
|
3225
3262
|
throw new Error(h);
|
|
3226
|
-
var S = x[++y], f = x[++y],
|
|
3227
|
-
if ((S & 192) !== 128 || (f & 192) !== 128 || (
|
|
3263
|
+
var S = x[++y], f = x[++y], v = x[++y];
|
|
3264
|
+
if ((S & 192) !== 128 || (f & 192) !== 128 || (v & 192) !== 128)
|
|
3228
3265
|
throw new Error(h);
|
|
3229
|
-
|
|
3266
|
+
E = (E & 15) << 18 | (S & 63) << 12 | (f & 63) << 6 | v & 63, R = 65536;
|
|
3230
3267
|
} else
|
|
3231
3268
|
throw new Error(h);
|
|
3232
|
-
if (
|
|
3269
|
+
if (E < R || E >= 55296 && E <= 57343)
|
|
3233
3270
|
throw new Error(h);
|
|
3234
|
-
if (
|
|
3235
|
-
if (
|
|
3271
|
+
if (E >= 65536) {
|
|
3272
|
+
if (E > 1114111)
|
|
3236
3273
|
throw new Error(h);
|
|
3237
|
-
|
|
3274
|
+
E -= 65536, m.push(String.fromCharCode(55296 | E >> 10)), E = 56320 | E & 1023;
|
|
3238
3275
|
}
|
|
3239
3276
|
}
|
|
3240
|
-
|
|
3277
|
+
m.push(String.fromCharCode(E));
|
|
3241
3278
|
}
|
|
3242
|
-
return
|
|
3279
|
+
return m.join("");
|
|
3243
3280
|
}
|
|
3244
|
-
o.decode =
|
|
3281
|
+
o.decode = A;
|
|
3245
3282
|
}),
|
|
3246
3283
|
/* 2 */
|
|
3247
3284
|
/***/
|
|
@@ -3295,7 +3332,7 @@ function Ko() {
|
|
|
3295
3332
|
cdn_https: "https://js.pusher.com",
|
|
3296
3333
|
dependency_suffix: ""
|
|
3297
3334
|
}, d = g;
|
|
3298
|
-
class
|
|
3335
|
+
class A {
|
|
3299
3336
|
constructor(t) {
|
|
3300
3337
|
this.options = t, this.receivers = t.receivers || h, this.loading = {};
|
|
3301
3338
|
}
|
|
@@ -3309,10 +3346,10 @@ function Ko() {
|
|
|
3309
3346
|
if (c.receivers.remove(_), c.loading[t]) {
|
|
3310
3347
|
var D = c.loading[t];
|
|
3311
3348
|
delete c.loading[t];
|
|
3312
|
-
for (var
|
|
3349
|
+
for (var J = function(oe) {
|
|
3313
3350
|
oe || p.cleanup();
|
|
3314
|
-
},
|
|
3315
|
-
D[
|
|
3351
|
+
}, Z = 0; Z < D.length; Z++)
|
|
3352
|
+
D[Z](I, J);
|
|
3316
3353
|
}
|
|
3317
3354
|
});
|
|
3318
3355
|
p.send(_);
|
|
@@ -3326,7 +3363,7 @@ function Ko() {
|
|
|
3326
3363
|
return this.getRoot(s) + "/" + t + this.options.suffix + ".js";
|
|
3327
3364
|
}
|
|
3328
3365
|
}
|
|
3329
|
-
var x = new l("_pusher_dependencies", "Pusher.DependenciesReceivers"),
|
|
3366
|
+
var x = new l("_pusher_dependencies", "Pusher.DependenciesReceivers"), m = new A({
|
|
3330
3367
|
cdn_http: d.cdn_http,
|
|
3331
3368
|
cdn_https: d.cdn_https,
|
|
3332
3369
|
version: d.VERSION,
|
|
@@ -3353,7 +3390,7 @@ function Ko() {
|
|
|
3353
3390
|
}
|
|
3354
3391
|
}
|
|
3355
3392
|
};
|
|
3356
|
-
var
|
|
3393
|
+
var R = { buildLogSuffix: function(r) {
|
|
3357
3394
|
const t = "See:", s = y.urls[r];
|
|
3358
3395
|
if (!s)
|
|
3359
3396
|
return "";
|
|
@@ -3368,7 +3405,7 @@ function Ko() {
|
|
|
3368
3405
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3369
3406
|
}
|
|
3370
3407
|
}
|
|
3371
|
-
class
|
|
3408
|
+
class v extends Error {
|
|
3372
3409
|
constructor(t) {
|
|
3373
3410
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3374
3411
|
}
|
|
@@ -3388,12 +3425,12 @@ function Ko() {
|
|
|
3388
3425
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3389
3426
|
}
|
|
3390
3427
|
}
|
|
3391
|
-
class
|
|
3428
|
+
class B extends Error {
|
|
3392
3429
|
constructor(t) {
|
|
3393
3430
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3394
3431
|
}
|
|
3395
3432
|
}
|
|
3396
|
-
class
|
|
3433
|
+
class P extends Error {
|
|
3397
3434
|
constructor(t) {
|
|
3398
3435
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3399
3436
|
}
|
|
@@ -3403,12 +3440,12 @@ function Ko() {
|
|
|
3403
3440
|
super(t), Object.setPrototypeOf(this, new.target.prototype);
|
|
3404
3441
|
}
|
|
3405
3442
|
}
|
|
3406
|
-
class
|
|
3443
|
+
class $ extends Error {
|
|
3407
3444
|
constructor(t, s) {
|
|
3408
3445
|
super(s), this.status = t, Object.setPrototypeOf(this, new.target.prototype);
|
|
3409
3446
|
}
|
|
3410
3447
|
}
|
|
3411
|
-
var
|
|
3448
|
+
var K = function(r, t, s, a, c) {
|
|
3412
3449
|
const p = q.createXHR();
|
|
3413
3450
|
p.open("POST", s.endpoint, !0), p.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
3414
3451
|
for (var _ in s.headers)
|
|
@@ -3425,31 +3462,31 @@ function Ko() {
|
|
|
3425
3462
|
try {
|
|
3426
3463
|
I = JSON.parse(p.responseText), D = !0;
|
|
3427
3464
|
} catch {
|
|
3428
|
-
c(new
|
|
3465
|
+
c(new $(200, `JSON returned from ${a.toString()} endpoint was invalid, yet status code was 200. Data was: ${p.responseText}`), null);
|
|
3429
3466
|
}
|
|
3430
3467
|
D && c(null, I);
|
|
3431
3468
|
} else {
|
|
3432
3469
|
let I = "";
|
|
3433
3470
|
switch (a) {
|
|
3434
3471
|
case S.UserAuthentication:
|
|
3435
|
-
I =
|
|
3472
|
+
I = R.buildLogSuffix("authenticationEndpoint");
|
|
3436
3473
|
break;
|
|
3437
3474
|
case S.ChannelAuthorization:
|
|
3438
|
-
I = `Clients must be authorized to join private or presence channels. ${
|
|
3475
|
+
I = `Clients must be authorized to join private or presence channels. ${R.buildLogSuffix("authorizationEndpoint")}`;
|
|
3439
3476
|
break;
|
|
3440
3477
|
}
|
|
3441
|
-
c(new
|
|
3478
|
+
c(new $(p.status, `Unable to retrieve auth string from ${a.toString()} endpoint - received status: ${p.status} from ${s.endpoint}. ${I}`), null);
|
|
3442
3479
|
}
|
|
3443
3480
|
}, p.send(t), p;
|
|
3444
3481
|
};
|
|
3445
|
-
function
|
|
3482
|
+
function se(r) {
|
|
3446
3483
|
return L(C(r));
|
|
3447
3484
|
}
|
|
3448
|
-
var
|
|
3485
|
+
var w = String.fromCharCode, M = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ee = function(r) {
|
|
3449
3486
|
var t = r.charCodeAt(0);
|
|
3450
|
-
return t < 128 ? r : t < 2048 ?
|
|
3487
|
+
return t < 128 ? r : t < 2048 ? w(192 | t >>> 6) + w(128 | t & 63) : w(224 | t >>> 12 & 15) + w(128 | t >>> 6 & 63) + w(128 | t & 63);
|
|
3451
3488
|
}, C = function(r) {
|
|
3452
|
-
return r.replace(/[^\x00-\x7F]/g,
|
|
3489
|
+
return r.replace(/[^\x00-\x7F]/g, ee);
|
|
3453
3490
|
}, O = function(r) {
|
|
3454
3491
|
var t = [0, 2, 1][r.length % 3], s = r.charCodeAt(0) << 16 | (r.length > 1 ? r.charCodeAt(1) : 0) << 8 | (r.length > 2 ? r.charCodeAt(2) : 0), a = [
|
|
3455
3492
|
M.charAt(s >>> 18),
|
|
@@ -3461,7 +3498,7 @@ function Ko() {
|
|
|
3461
3498
|
}, L = window.btoa || function(r) {
|
|
3462
3499
|
return r.replace(/[\s\S]{1,3}/g, O);
|
|
3463
3500
|
};
|
|
3464
|
-
class
|
|
3501
|
+
class H {
|
|
3465
3502
|
constructor(t, s, a, c) {
|
|
3466
3503
|
this.clear = s, this.timer = t(() => {
|
|
3467
3504
|
this.timer && (this.timer = c(this.timer));
|
|
@@ -3474,14 +3511,14 @@ function Ko() {
|
|
|
3474
3511
|
this.timer && (this.clear(this.timer), this.timer = null);
|
|
3475
3512
|
}
|
|
3476
3513
|
}
|
|
3477
|
-
var re =
|
|
3514
|
+
var re = H;
|
|
3478
3515
|
function je(r) {
|
|
3479
3516
|
window.clearTimeout(r);
|
|
3480
3517
|
}
|
|
3481
3518
|
function Bt(r) {
|
|
3482
3519
|
window.clearInterval(r);
|
|
3483
3520
|
}
|
|
3484
|
-
class
|
|
3521
|
+
class T extends re {
|
|
3485
3522
|
constructor(t, s) {
|
|
3486
3523
|
super(setTimeout, je, t, function(a) {
|
|
3487
3524
|
return s(), null;
|
|
@@ -3495,12 +3532,12 @@ function Ko() {
|
|
|
3495
3532
|
});
|
|
3496
3533
|
}
|
|
3497
3534
|
}
|
|
3498
|
-
var
|
|
3535
|
+
var Y = {
|
|
3499
3536
|
now() {
|
|
3500
3537
|
return Date.now ? Date.now() : (/* @__PURE__ */ new Date()).valueOf();
|
|
3501
3538
|
},
|
|
3502
3539
|
defer(r) {
|
|
3503
|
-
return new
|
|
3540
|
+
return new T(0, r);
|
|
3504
3541
|
},
|
|
3505
3542
|
method(r, ...t) {
|
|
3506
3543
|
var s = Array.prototype.slice.call(arguments, 1);
|
|
@@ -3508,7 +3545,7 @@ function Ko() {
|
|
|
3508
3545
|
return a[r].apply(a, s.concat(arguments));
|
|
3509
3546
|
};
|
|
3510
3547
|
}
|
|
3511
|
-
}, N =
|
|
3548
|
+
}, N = Y;
|
|
3512
3549
|
function V(r, ...t) {
|
|
3513
3550
|
for (var s = 0; s < t.length; s++) {
|
|
3514
3551
|
var a = t[s];
|
|
@@ -3558,13 +3595,13 @@ function Ko() {
|
|
|
3558
3595
|
s.push(t(r[a], a, r, s));
|
|
3559
3596
|
return s;
|
|
3560
3597
|
}
|
|
3561
|
-
function
|
|
3598
|
+
function we(r, t) {
|
|
3562
3599
|
var s = {};
|
|
3563
3600
|
return fe(r, function(a, c) {
|
|
3564
3601
|
s[c] = t(a);
|
|
3565
3602
|
}), s;
|
|
3566
3603
|
}
|
|
3567
|
-
function
|
|
3604
|
+
function W(r, t) {
|
|
3568
3605
|
t = t || function(c) {
|
|
3569
3606
|
return !!c;
|
|
3570
3607
|
};
|
|
@@ -3597,8 +3634,8 @@ function Ko() {
|
|
|
3597
3634
|
return !0;
|
|
3598
3635
|
}
|
|
3599
3636
|
function fs(r) {
|
|
3600
|
-
return
|
|
3601
|
-
return typeof t == "object" && (t = He(t)), encodeURIComponent(
|
|
3637
|
+
return we(r, function(t) {
|
|
3638
|
+
return typeof t == "object" && (t = He(t)), encodeURIComponent(se(t.toString()));
|
|
3602
3639
|
});
|
|
3603
3640
|
}
|
|
3604
3641
|
function ps(r) {
|
|
@@ -3667,18 +3704,18 @@ function Ko() {
|
|
|
3667
3704
|
vt.log ? vt.log(a) : vt.logToConsole && t.bind(this)(a);
|
|
3668
3705
|
}
|
|
3669
3706
|
}
|
|
3670
|
-
var
|
|
3671
|
-
(s.headers !== void 0 || s.headersProvider != null) &&
|
|
3707
|
+
var te = new ms(), vs = function(r, t, s, a, c) {
|
|
3708
|
+
(s.headers !== void 0 || s.headersProvider != null) && te.warn(`To send headers with the ${a.toString()} request, you must use AJAX, rather than JSONP.`);
|
|
3672
3709
|
var p = r.nextAuthCallbackID.toString();
|
|
3673
3710
|
r.nextAuthCallbackID++;
|
|
3674
3711
|
var _ = r.getDocument(), I = _.createElement("script");
|
|
3675
|
-
r.auth_callbacks[p] = function(
|
|
3676
|
-
c(null,
|
|
3712
|
+
r.auth_callbacks[p] = function(Z) {
|
|
3713
|
+
c(null, Z);
|
|
3677
3714
|
};
|
|
3678
3715
|
var D = "Pusher.auth_callbacks['" + p + "']";
|
|
3679
3716
|
I.src = s.endpoint + "?callback=" + encodeURIComponent(D) + "&" + t;
|
|
3680
|
-
var
|
|
3681
|
-
|
|
3717
|
+
var J = _.getElementsByTagName("head")[0] || _.documentElement;
|
|
3718
|
+
J.insertBefore(I, J.firstChild);
|
|
3682
3719
|
}, bs = vs;
|
|
3683
3720
|
class ys {
|
|
3684
3721
|
constructor(t) {
|
|
@@ -3716,15 +3753,15 @@ function Ko() {
|
|
|
3716
3753
|
}
|
|
3717
3754
|
var Ss = function(r, t) {
|
|
3718
3755
|
return function(s, a) {
|
|
3719
|
-
var c = "http" + (t ? "s" : "") + "://", p = c + (r.host || r.options.host) + r.options.path, _ = q.createJSONPRequest(p, s), I = q.ScriptReceivers.create(function(D,
|
|
3720
|
-
h.remove(I), _.cleanup(),
|
|
3756
|
+
var c = "http" + (t ? "s" : "") + "://", p = c + (r.host || r.options.host) + r.options.path, _ = q.createJSONPRequest(p, s), I = q.ScriptReceivers.create(function(D, J) {
|
|
3757
|
+
h.remove(I), _.cleanup(), J && J.host && (r.host = J.host), a && a(D, J);
|
|
3721
3758
|
});
|
|
3722
3759
|
_.send(I);
|
|
3723
3760
|
};
|
|
3724
|
-
},
|
|
3761
|
+
}, ws = {
|
|
3725
3762
|
name: "jsonp",
|
|
3726
3763
|
getAgent: Ss
|
|
3727
|
-
},
|
|
3764
|
+
}, Cs = ws;
|
|
3728
3765
|
function at(r, t, s) {
|
|
3729
3766
|
var a = r + (t.useTLS ? "s" : ""), c = t.useTLS ? t.hostTLS : t.hostNonTLS;
|
|
3730
3767
|
return a + "://" + c + s;
|
|
@@ -3775,7 +3812,7 @@ function Ko() {
|
|
|
3775
3812
|
}
|
|
3776
3813
|
removeCallback(t, s, a) {
|
|
3777
3814
|
ce(t, function(c) {
|
|
3778
|
-
this._callbacks[c] =
|
|
3815
|
+
this._callbacks[c] = W(this._callbacks[c] || [], function(p) {
|
|
3779
3816
|
return s && s !== p.fn || a && a !== p.context;
|
|
3780
3817
|
}), this._callbacks[c].length === 0 && delete this._callbacks[c];
|
|
3781
3818
|
}, this);
|
|
@@ -3803,7 +3840,7 @@ function Ko() {
|
|
|
3803
3840
|
return this.callbacks.remove(t, s, a), this;
|
|
3804
3841
|
}
|
|
3805
3842
|
unbind_global(t) {
|
|
3806
|
-
return t ? (this.global_callbacks =
|
|
3843
|
+
return t ? (this.global_callbacks = W(this.global_callbacks || [], (s) => s !== t), this) : (this.global_callbacks = [], this);
|
|
3807
3844
|
}
|
|
3808
3845
|
unbind_all() {
|
|
3809
3846
|
return this.unbind(), this.unbind_global(), this;
|
|
@@ -3840,7 +3877,7 @@ function Ko() {
|
|
|
3840
3877
|
this.onError(s), this.changeState("closed");
|
|
3841
3878
|
}), !1;
|
|
3842
3879
|
}
|
|
3843
|
-
return this.bindListeners(),
|
|
3880
|
+
return this.bindListeners(), te.debug("Connecting", { transport: this.name, url: t }), this.changeState("connecting"), !0;
|
|
3844
3881
|
}
|
|
3845
3882
|
close() {
|
|
3846
3883
|
return this.socket ? (this.socket.close(), !0) : !1;
|
|
@@ -3958,7 +3995,7 @@ function Ko() {
|
|
|
3958
3995
|
},
|
|
3959
3996
|
getSocket: function(r, t) {
|
|
3960
3997
|
return new window.SockJS(r, null, {
|
|
3961
|
-
js_path:
|
|
3998
|
+
js_path: m.getPath("sockjs", {
|
|
3962
3999
|
useTLS: t.useTLS
|
|
3963
4000
|
}),
|
|
3964
4001
|
ignore_null_origin: t.ignoreNullOrigin
|
|
@@ -4002,12 +4039,12 @@ function Ko() {
|
|
|
4002
4039
|
});
|
|
4003
4040
|
var p = this.transport.createConnection(t, s, a, c), _ = null, I = function() {
|
|
4004
4041
|
p.unbind("open", I), p.bind("closed", D), _ = N.now();
|
|
4005
|
-
}, D = (
|
|
4006
|
-
if (p.unbind("closed", D),
|
|
4042
|
+
}, D = (J) => {
|
|
4043
|
+
if (p.unbind("closed", D), J.code === 1002 || J.code === 1003)
|
|
4007
4044
|
this.manager.reportDeath();
|
|
4008
|
-
else if (!
|
|
4009
|
-
var
|
|
4010
|
-
|
|
4045
|
+
else if (!J.wasClean && _) {
|
|
4046
|
+
var Z = N.now() - _;
|
|
4047
|
+
Z < 2 * this.maxPingDelay && (this.manager.reportDeath(), this.pingDelay = Math.max(Z / 2, this.minPingDelay));
|
|
4011
4048
|
}
|
|
4012
4049
|
};
|
|
4013
4050
|
return p.bind("open", I), p;
|
|
@@ -4070,7 +4107,7 @@ function Ko() {
|
|
|
4070
4107
|
} : null;
|
|
4071
4108
|
}
|
|
4072
4109
|
};
|
|
4073
|
-
var
|
|
4110
|
+
var Ce = Yt;
|
|
4074
4111
|
class zs extends be {
|
|
4075
4112
|
constructor(t, s) {
|
|
4076
4113
|
super(), this.id = t, this.transport = s, this.activityTimeout = s.activityTimeout, this.bindListeners();
|
|
@@ -4083,7 +4120,7 @@ function Ko() {
|
|
|
4083
4120
|
}
|
|
4084
4121
|
send_event(t, s, a) {
|
|
4085
4122
|
var c = { event: t, data: s };
|
|
4086
|
-
return a && (c.channel = a),
|
|
4123
|
+
return a && (c.channel = a), te.debug("Event sent", c), this.send(Ce.encodeMessage(c));
|
|
4087
4124
|
}
|
|
4088
4125
|
ping() {
|
|
4089
4126
|
this.transport.supportsPing() ? this.transport.ping() : this.send_event("pusher:ping", {});
|
|
@@ -4096,7 +4133,7 @@ function Ko() {
|
|
|
4096
4133
|
message: (a) => {
|
|
4097
4134
|
var c;
|
|
4098
4135
|
try {
|
|
4099
|
-
c =
|
|
4136
|
+
c = Ce.decodeMessage(a);
|
|
4100
4137
|
} catch (p) {
|
|
4101
4138
|
this.emit("error", {
|
|
4102
4139
|
type: "MessageParseError",
|
|
@@ -4105,7 +4142,7 @@ function Ko() {
|
|
|
4105
4142
|
});
|
|
4106
4143
|
}
|
|
4107
4144
|
if (c !== void 0) {
|
|
4108
|
-
switch (
|
|
4145
|
+
switch (te.debug("Event recd", c), c.event) {
|
|
4109
4146
|
case "pusher:error":
|
|
4110
4147
|
this.emit("error", {
|
|
4111
4148
|
type: "PusherError",
|
|
@@ -4141,7 +4178,7 @@ function Ko() {
|
|
|
4141
4178
|
});
|
|
4142
4179
|
}
|
|
4143
4180
|
handleCloseEvent(t) {
|
|
4144
|
-
var s =
|
|
4181
|
+
var s = Ce.getCloseAction(t), a = Ce.getCloseError(t);
|
|
4145
4182
|
a && this.emit("error", a), s && this.emit(s, { action: s, error: a });
|
|
4146
4183
|
}
|
|
4147
4184
|
}
|
|
@@ -4157,7 +4194,7 @@ function Ko() {
|
|
|
4157
4194
|
this.unbindListeners();
|
|
4158
4195
|
var s;
|
|
4159
4196
|
try {
|
|
4160
|
-
s =
|
|
4197
|
+
s = Ce.processHandshake(t);
|
|
4161
4198
|
} catch (a) {
|
|
4162
4199
|
this.finish("error", { error: a }), this.transport.close();
|
|
4163
4200
|
return;
|
|
@@ -4168,7 +4205,7 @@ function Ko() {
|
|
|
4168
4205
|
}) : (this.finish(s.action, { error: s.error }), this.transport.close());
|
|
4169
4206
|
}, this.onClosed = (t) => {
|
|
4170
4207
|
this.unbindListeners();
|
|
4171
|
-
var s =
|
|
4208
|
+
var s = Ce.getCloseAction(t) || "backoff", a = Ce.getCloseError(t);
|
|
4172
4209
|
this.finish(s, { error: a });
|
|
4173
4210
|
}, this.transport.bind("message", this.onMessage), this.transport.bind("closed", this.onClosed);
|
|
4174
4211
|
}
|
|
@@ -4190,7 +4227,7 @@ function Ko() {
|
|
|
4190
4227
|
class lt extends be {
|
|
4191
4228
|
constructor(t, s) {
|
|
4192
4229
|
super(function(a, c) {
|
|
4193
|
-
|
|
4230
|
+
te.debug("No callbacks on " + t + " for " + a);
|
|
4194
4231
|
}), this.name = t, this.pusher = s, this.subscribed = !1, this.subscriptionPending = !1, this.subscriptionCancelled = !1;
|
|
4195
4232
|
}
|
|
4196
4233
|
authorize(t, s) {
|
|
@@ -4200,8 +4237,8 @@ function Ko() {
|
|
|
4200
4237
|
if (t.indexOf("client-") !== 0)
|
|
4201
4238
|
throw new f("Event '" + t + "' does not start with 'client-'");
|
|
4202
4239
|
if (!this.subscribed) {
|
|
4203
|
-
var a =
|
|
4204
|
-
|
|
4240
|
+
var a = R.buildLogSuffix("triggeringClientEvents");
|
|
4241
|
+
te.warn(`Client event triggered before channel 'subscription_succeeded' event . ${a}`);
|
|
4205
4242
|
}
|
|
4206
4243
|
return this.pusher.send_event(t, s, this.name);
|
|
4207
4244
|
}
|
|
@@ -4227,10 +4264,10 @@ function Ko() {
|
|
|
4227
4264
|
}
|
|
4228
4265
|
subscribe() {
|
|
4229
4266
|
this.subscribed || (this.subscriptionPending = !0, this.subscriptionCancelled = !1, this.authorize(this.pusher.connection.socket_id, (t, s) => {
|
|
4230
|
-
t ? (this.subscriptionPending = !1,
|
|
4267
|
+
t ? (this.subscriptionPending = !1, te.error(t.toString()), this.emit("pusher:subscription_error", Object.assign({}, {
|
|
4231
4268
|
type: "AuthError",
|
|
4232
4269
|
error: t.message
|
|
4233
|
-
}, t instanceof
|
|
4270
|
+
}, t instanceof $ ? { status: t.status } : {}))) : this.pusher.send_event("pusher:subscribe", {
|
|
4234
4271
|
auth: s.auth,
|
|
4235
4272
|
channel_data: s.channel_data,
|
|
4236
4273
|
channel: this.name
|
|
@@ -4296,24 +4333,24 @@ function Ko() {
|
|
|
4296
4333
|
});
|
|
4297
4334
|
}
|
|
4298
4335
|
return new (s || (s = Promise))(function(p, _) {
|
|
4299
|
-
function I(
|
|
4336
|
+
function I(Z) {
|
|
4300
4337
|
try {
|
|
4301
|
-
|
|
4338
|
+
J(a.next(Z));
|
|
4302
4339
|
} catch (oe) {
|
|
4303
4340
|
_(oe);
|
|
4304
4341
|
}
|
|
4305
4342
|
}
|
|
4306
|
-
function D(
|
|
4343
|
+
function D(Z) {
|
|
4307
4344
|
try {
|
|
4308
|
-
|
|
4345
|
+
J(a.throw(Z));
|
|
4309
4346
|
} catch (oe) {
|
|
4310
4347
|
_(oe);
|
|
4311
4348
|
}
|
|
4312
4349
|
}
|
|
4313
|
-
function
|
|
4314
|
-
|
|
4350
|
+
function J(Z) {
|
|
4351
|
+
Z.done ? p(Z.value) : c(Z.value).then(I, D);
|
|
4315
4352
|
}
|
|
4316
|
-
|
|
4353
|
+
J((a = a.apply(r, t || [])).next());
|
|
4317
4354
|
});
|
|
4318
4355
|
};
|
|
4319
4356
|
class Vs extends ht {
|
|
@@ -4329,8 +4366,8 @@ function Ko() {
|
|
|
4329
4366
|
} else if (yield this.pusher.user.signinDonePromise, this.pusher.user.user_data != null)
|
|
4330
4367
|
this.members.setMyID(this.pusher.user.user_data.id);
|
|
4331
4368
|
else {
|
|
4332
|
-
let _ =
|
|
4333
|
-
|
|
4369
|
+
let _ = R.buildLogSuffix("authorizationEndpoint");
|
|
4370
|
+
te.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${_}, or the user should be signed in.`), s("Invalid auth response");
|
|
4334
4371
|
return;
|
|
4335
4372
|
}
|
|
4336
4373
|
s(a, c);
|
|
@@ -4391,7 +4428,7 @@ function Ko() {
|
|
|
4391
4428
|
});
|
|
4392
4429
|
}
|
|
4393
4430
|
trigger(t, s) {
|
|
4394
|
-
throw new
|
|
4431
|
+
throw new B("Client events are not currently supported for encrypted channels");
|
|
4395
4432
|
}
|
|
4396
4433
|
handleEvent(t) {
|
|
4397
4434
|
var s = t.event, a = t.data;
|
|
@@ -4403,32 +4440,32 @@ function Ko() {
|
|
|
4403
4440
|
}
|
|
4404
4441
|
handleEncryptedEvent(t, s) {
|
|
4405
4442
|
if (!this.key) {
|
|
4406
|
-
|
|
4443
|
+
te.debug("Received encrypted event before key has been retrieved from the authEndpoint");
|
|
4407
4444
|
return;
|
|
4408
4445
|
}
|
|
4409
4446
|
if (!s.ciphertext || !s.nonce) {
|
|
4410
|
-
|
|
4447
|
+
te.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: " + s);
|
|
4411
4448
|
return;
|
|
4412
4449
|
}
|
|
4413
4450
|
let a = Object(dt.decode)(s.ciphertext);
|
|
4414
4451
|
if (a.length < this.nacl.secretbox.overheadLength) {
|
|
4415
|
-
|
|
4452
|
+
te.error(`Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${a.length}`);
|
|
4416
4453
|
return;
|
|
4417
4454
|
}
|
|
4418
4455
|
let c = Object(dt.decode)(s.nonce);
|
|
4419
4456
|
if (c.length < this.nacl.secretbox.nonceLength) {
|
|
4420
|
-
|
|
4457
|
+
te.error(`Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${c.length}`);
|
|
4421
4458
|
return;
|
|
4422
4459
|
}
|
|
4423
4460
|
let p = this.nacl.secretbox.open(a, c, this.key);
|
|
4424
4461
|
if (p === null) {
|
|
4425
|
-
|
|
4462
|
+
te.debug("Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint..."), this.authorize(this.pusher.connection.socket_id, (_, I) => {
|
|
4426
4463
|
if (_) {
|
|
4427
|
-
|
|
4464
|
+
te.error(`Failed to make a request to the authEndpoint: ${I}. Unable to fetch new key, so dropping encrypted event`);
|
|
4428
4465
|
return;
|
|
4429
4466
|
}
|
|
4430
4467
|
if (p = this.nacl.secretbox.open(a, c, this.key), p === null) {
|
|
4431
|
-
|
|
4468
|
+
te.error("Failed to decrypt event with new key. Dropping encrypted event");
|
|
4432
4469
|
return;
|
|
4433
4470
|
}
|
|
4434
4471
|
this.emit(t, this.getDataToEmit(p));
|
|
@@ -4503,7 +4540,7 @@ function Ko() {
|
|
|
4503
4540
|
});
|
|
4504
4541
|
}
|
|
4505
4542
|
retryIn(t) {
|
|
4506
|
-
this.timeline.info({ action: "retry", delay: t }), t > 0 && this.emit("connecting_in", Math.round(t / 1e3)), this.retryTimer = new
|
|
4543
|
+
this.timeline.info({ action: "retry", delay: t }), t > 0 && this.emit("connecting_in", Math.round(t / 1e3)), this.retryTimer = new T(t || 0, () => {
|
|
4507
4544
|
this.disconnectInternally(), this.connect();
|
|
4508
4545
|
});
|
|
4509
4546
|
}
|
|
@@ -4511,7 +4548,7 @@ function Ko() {
|
|
|
4511
4548
|
this.retryTimer && (this.retryTimer.ensureAborted(), this.retryTimer = null);
|
|
4512
4549
|
}
|
|
4513
4550
|
setUnavailableTimer() {
|
|
4514
|
-
this.unavailableTimer = new
|
|
4551
|
+
this.unavailableTimer = new T(this.options.unavailableTimeout, () => {
|
|
4515
4552
|
this.updateState("unavailable");
|
|
4516
4553
|
});
|
|
4517
4554
|
}
|
|
@@ -4519,12 +4556,12 @@ function Ko() {
|
|
|
4519
4556
|
this.unavailableTimer && this.unavailableTimer.ensureAborted();
|
|
4520
4557
|
}
|
|
4521
4558
|
sendActivityCheck() {
|
|
4522
|
-
this.stopActivityCheck(), this.connection.ping(), this.activityTimer = new
|
|
4559
|
+
this.stopActivityCheck(), this.connection.ping(), this.activityTimer = new T(this.options.pongTimeout, () => {
|
|
4523
4560
|
this.timeline.error({ pong_timed_out: this.options.pongTimeout }), this.retryIn(0);
|
|
4524
4561
|
});
|
|
4525
4562
|
}
|
|
4526
4563
|
resetActivityCheck() {
|
|
4527
|
-
this.stopActivityCheck(), this.connection && !this.connection.handlesActivityChecks() && (this.activityTimer = new
|
|
4564
|
+
this.stopActivityCheck(), this.connection && !this.connection.handlesActivityChecks() && (this.activityTimer = new T(this.activityTimeout, () => {
|
|
4528
4565
|
this.sendActivityCheck();
|
|
4529
4566
|
}));
|
|
4530
4567
|
}
|
|
@@ -4595,7 +4632,7 @@ function Ko() {
|
|
|
4595
4632
|
var a = this.state;
|
|
4596
4633
|
if (this.state = t, a !== t) {
|
|
4597
4634
|
var c = t;
|
|
4598
|
-
c === "connected" && (c += " with new socket ID " + s.socket_id),
|
|
4635
|
+
c === "connected" && (c += " with new socket ID " + s.socket_id), te.debug("State changed", a + " -> " + c), this.timeline.info({ state: t, params: s }), this.emit("state_change", { previous: a, current: t }), this.emit(t, s);
|
|
4599
4636
|
}
|
|
4600
4637
|
}
|
|
4601
4638
|
shouldRetry() {
|
|
@@ -4629,15 +4666,15 @@ function Ko() {
|
|
|
4629
4666
|
if (r.indexOf("private-encrypted-") === 0) {
|
|
4630
4667
|
if (t.config.nacl)
|
|
4631
4668
|
return ye.createEncryptedChannel(r, t, t.config.nacl);
|
|
4632
|
-
let s = "Tried to subscribe to a private-encrypted- channel but no nacl implementation available", a =
|
|
4633
|
-
throw new
|
|
4669
|
+
let s = "Tried to subscribe to a private-encrypted- channel but no nacl implementation available", a = R.buildLogSuffix("encryptedChannelSupport");
|
|
4670
|
+
throw new B(`${s}. ${a}`);
|
|
4634
4671
|
} else {
|
|
4635
4672
|
if (r.indexOf("private-") === 0)
|
|
4636
4673
|
return ye.createPrivateChannel(r, t);
|
|
4637
4674
|
if (r.indexOf("presence-") === 0)
|
|
4638
4675
|
return ye.createPresenceChannel(r, t);
|
|
4639
4676
|
if (r.indexOf("#") === 0)
|
|
4640
|
-
throw new
|
|
4677
|
+
throw new v('Cannot create a channel with name "' + r + '".');
|
|
4641
4678
|
return ye.createChannel(r, t);
|
|
4642
4679
|
}
|
|
4643
4680
|
}
|
|
@@ -4695,8 +4732,8 @@ function Ko() {
|
|
|
4695
4732
|
return Vt(this.strategies, N.method("isSupported"));
|
|
4696
4733
|
}
|
|
4697
4734
|
connect(t, s) {
|
|
4698
|
-
var a = this.strategies, c = 0, p = this.timeout, _ = null, I = (D,
|
|
4699
|
-
|
|
4735
|
+
var a = this.strategies, c = 0, p = this.timeout, _ = null, I = (D, J) => {
|
|
4736
|
+
J ? s(null, J) : (c = c + 1, this.loop && (c = c % a.length), c < a.length ? (p && (p = p * 2, this.timeoutLimit && (p = Math.min(p, this.timeoutLimit))), _ = this.tryStrategy(a[c], t, { timeout: p, failFast: this.failFast }, I)) : s(!0));
|
|
4700
4737
|
};
|
|
4701
4738
|
return _ = this.tryStrategy(a[c], t, { timeout: p, failFast: this.failFast }, I), {
|
|
4702
4739
|
abort: function() {
|
|
@@ -4709,7 +4746,7 @@ function Ko() {
|
|
|
4709
4746
|
}
|
|
4710
4747
|
tryStrategy(t, s, a, c) {
|
|
4711
4748
|
var p = null, _ = null;
|
|
4712
|
-
return a.timeout > 0 && (p = new
|
|
4749
|
+
return a.timeout > 0 && (p = new T(a.timeout, function() {
|
|
4713
4750
|
_.abort(), c(!0);
|
|
4714
4751
|
})), _ = t.connect(s, function(I, D) {
|
|
4715
4752
|
I && p && p.isRunning() && !a.failFast || (p && p.ensureAborted(), c(I, D));
|
|
@@ -4787,15 +4824,15 @@ function Ko() {
|
|
|
4787
4824
|
failFast: !0
|
|
4788
4825
|
}))) : p++);
|
|
4789
4826
|
}
|
|
4790
|
-
var D = N.now(),
|
|
4791
|
-
oe ? (Zt(a), _.length > 0 ? (D = N.now(),
|
|
4827
|
+
var D = N.now(), J = _.pop().connect(t, function Z(oe, We) {
|
|
4828
|
+
oe ? (Zt(a), _.length > 0 ? (D = N.now(), J = _.pop().connect(t, Z)) : s(oe)) : (sr(a, We.transport.name, N.now() - D, p), s(null, We));
|
|
4792
4829
|
});
|
|
4793
4830
|
return {
|
|
4794
4831
|
abort: function() {
|
|
4795
|
-
|
|
4832
|
+
J.abort();
|
|
4796
4833
|
},
|
|
4797
|
-
forceMinPriority: function(
|
|
4798
|
-
t =
|
|
4834
|
+
forceMinPriority: function(Z) {
|
|
4835
|
+
t = Z, J && J.forceMinPriority(Z);
|
|
4799
4836
|
}
|
|
4800
4837
|
};
|
|
4801
4838
|
}
|
|
@@ -4844,7 +4881,7 @@ function Ko() {
|
|
|
4844
4881
|
return this.strategy.isSupported();
|
|
4845
4882
|
}
|
|
4846
4883
|
connect(t, s) {
|
|
4847
|
-
var a = this.strategy, c, p = new
|
|
4884
|
+
var a = this.strategy, c, p = new T(this.options.delay, function() {
|
|
4848
4885
|
c = a.connect(t, s);
|
|
4849
4886
|
});
|
|
4850
4887
|
return {
|
|
@@ -4909,14 +4946,14 @@ function Ko() {
|
|
|
4909
4946
|
loop: !0,
|
|
4910
4947
|
timeout: 15e3,
|
|
4911
4948
|
timeoutLimit: 6e4
|
|
4912
|
-
},
|
|
4949
|
+
}, J = new Qt({
|
|
4913
4950
|
minPingDelay: 1e4,
|
|
4914
4951
|
maxPingDelay: r.activityTimeout
|
|
4915
|
-
}),
|
|
4952
|
+
}), Z = new Qt({
|
|
4916
4953
|
lives: 2,
|
|
4917
4954
|
minPingDelay: 1e4,
|
|
4918
4955
|
maxPingDelay: r.activityTimeout
|
|
4919
|
-
}), oe = c("ws", "ws", 3, p,
|
|
4956
|
+
}), oe = c("ws", "ws", 3, p, J), We = c("wss", "ws", 3, _, J), Zr = c("sockjs", "sockjs", 1, I), rn = c("xhr_streaming", "xhr_streaming", 1, I, Z), ei = c("xdr_streaming", "xdr_streaming", 1, I, Z), on = c("xhr_polling", "xhr_polling", 1, I), ti = c("xdr_polling", "xdr_polling", 1, I), an = new Te([oe], D), ni = new Te([We], D), si = new Te([Zr], D), cn = new Te([
|
|
4920
4957
|
new ke(Ie(rn), rn, ei)
|
|
4921
4958
|
], D), un = new Te([
|
|
4922
4959
|
new ke(Ie(on), on, ti)
|
|
@@ -4942,7 +4979,7 @@ function Ko() {
|
|
|
4942
4979
|
var r = this;
|
|
4943
4980
|
r.timeline.info(r.buildTimelineMessage({
|
|
4944
4981
|
transport: r.name + (r.options.useTLS ? "s" : "")
|
|
4945
|
-
})), r.hooks.isInitialized() ? r.changeState("initialized") : r.hooks.file ? (r.changeState("initializing"),
|
|
4982
|
+
})), r.hooks.isInitialized() ? r.changeState("initialized") : r.hooks.file ? (r.changeState("initializing"), m.load(r.hooks.file, { useTLS: r.options.useTLS }, function(t, s) {
|
|
4946
4983
|
r.hooks.isInitialized() ? (r.changeState("initialized"), s(!0)) : (t && r.onError(t), r.onClose(), s(!1));
|
|
4947
4984
|
})) : r.onClose();
|
|
4948
4985
|
}), cr = {
|
|
@@ -5140,7 +5177,7 @@ function Ko() {
|
|
|
5140
5177
|
onFinished: function(r, t) {
|
|
5141
5178
|
t === 200 ? r.reconnect() : r.onClose(1006, "Connection interrupted (" + t + ")", !1);
|
|
5142
5179
|
}
|
|
5143
|
-
},
|
|
5180
|
+
}, wr = Sr, Cr = {
|
|
5144
5181
|
getRequest: function(r) {
|
|
5145
5182
|
var t = q.getXHRAPI(), s = new t();
|
|
5146
5183
|
return s.onreadystatechange = s.onprogress = function() {
|
|
@@ -5157,12 +5194,12 @@ function Ko() {
|
|
|
5157
5194
|
abortRequest: function(r) {
|
|
5158
5195
|
r.onreadystatechange = null, r.abort();
|
|
5159
5196
|
}
|
|
5160
|
-
}, Tr =
|
|
5197
|
+
}, Tr = Cr, Er = {
|
|
5161
5198
|
createStreamingSocket(r) {
|
|
5162
5199
|
return this.createSocket(_r, r);
|
|
5163
5200
|
},
|
|
5164
5201
|
createPollingSocket(r) {
|
|
5165
|
-
return this.createSocket(
|
|
5202
|
+
return this.createSocket(wr, r);
|
|
5166
5203
|
},
|
|
5167
5204
|
createSocket(r, t) {
|
|
5168
5205
|
return new br(r, t);
|
|
@@ -5186,7 +5223,7 @@ function Ko() {
|
|
|
5186
5223
|
Transports: Ns,
|
|
5187
5224
|
transportConnectionInitializer: ar,
|
|
5188
5225
|
HTTPFactory: Rr,
|
|
5189
|
-
TimelineTransport:
|
|
5226
|
+
TimelineTransport: Cs,
|
|
5190
5227
|
getXHRAPI() {
|
|
5191
5228
|
return window.XMLHttpRequest;
|
|
5192
5229
|
},
|
|
@@ -5198,7 +5235,7 @@ function Ko() {
|
|
|
5198
5235
|
var t = () => {
|
|
5199
5236
|
this.onDocumentBody(r.ready);
|
|
5200
5237
|
};
|
|
5201
|
-
window.JSON ? t() :
|
|
5238
|
+
window.JSON ? t() : m.load("json2", {}, t);
|
|
5202
5239
|
},
|
|
5203
5240
|
getDocument() {
|
|
5204
5241
|
return document;
|
|
@@ -5207,7 +5244,7 @@ function Ko() {
|
|
|
5207
5244
|
return this.getDocument().location.protocol;
|
|
5208
5245
|
},
|
|
5209
5246
|
getAuthorizers() {
|
|
5210
|
-
return { ajax:
|
|
5247
|
+
return { ajax: K, jsonp: bs };
|
|
5211
5248
|
},
|
|
5212
5249
|
onDocumentBody(r) {
|
|
5213
5250
|
document.body ? r() : setTimeout(() => {
|
|
@@ -5331,20 +5368,20 @@ function Ko() {
|
|
|
5331
5368
|
c.unbind("initialized", _), c.connect();
|
|
5332
5369
|
}, I = function() {
|
|
5333
5370
|
p = ye.createHandshake(c, function(oe) {
|
|
5334
|
-
a = !0,
|
|
5371
|
+
a = !0, Z(), s(null, oe);
|
|
5335
5372
|
});
|
|
5336
5373
|
}, D = function(oe) {
|
|
5337
|
-
|
|
5338
|
-
},
|
|
5339
|
-
|
|
5374
|
+
Z(), s(oe);
|
|
5375
|
+
}, J = function() {
|
|
5376
|
+
Z();
|
|
5340
5377
|
var oe;
|
|
5341
5378
|
oe = He(c), s(new j(oe));
|
|
5342
|
-
},
|
|
5343
|
-
c.unbind("initialized", _), c.unbind("open", I), c.unbind("error", D), c.unbind("closed",
|
|
5379
|
+
}, Z = function() {
|
|
5380
|
+
c.unbind("initialized", _), c.unbind("open", I), c.unbind("error", D), c.unbind("closed", J);
|
|
5344
5381
|
};
|
|
5345
|
-
return c.bind("initialized", _), c.bind("open", I), c.bind("error", D), c.bind("closed",
|
|
5382
|
+
return c.bind("initialized", _), c.bind("open", I), c.bind("error", D), c.bind("closed", J), c.initialize(), {
|
|
5346
5383
|
abort: () => {
|
|
5347
|
-
a || (
|
|
5384
|
+
a || (Z(), p ? p.close() : c.close());
|
|
5348
5385
|
},
|
|
5349
5386
|
forceMinPriority: (oe) => {
|
|
5350
5387
|
a || this.priority < oe && (p ? p.close() : c.close());
|
|
@@ -5366,7 +5403,7 @@ function Ko() {
|
|
|
5366
5403
|
var kr = function(r, t, s, a, c, p) {
|
|
5367
5404
|
var _ = Mr[s];
|
|
5368
5405
|
if (!_)
|
|
5369
|
-
throw new
|
|
5406
|
+
throw new P(s);
|
|
5370
5407
|
var I = (!r.enabledTransports || ve(r.enabledTransports, t) !== -1) && (!r.disabledTransports || ve(r.disabledTransports, t) === -1), D;
|
|
5371
5408
|
return I ? (c = Object.assign({ ignoreNullOrigin: r.ignoreNullOrigin }, c), D = new xr(t, a, p ? p.getAssistant(_) : _, c)) : D = Ir, D;
|
|
5372
5409
|
}, Ir = {
|
|
@@ -5391,7 +5428,7 @@ function Ko() {
|
|
|
5391
5428
|
throw "You must pass an options object";
|
|
5392
5429
|
if (r.cluster == null)
|
|
5393
5430
|
throw "Options object must provide a cluster";
|
|
5394
|
-
"disableStats" in r &&
|
|
5431
|
+
"disableStats" in r && te.warn("The disableStats option is deprecated in favor of enableStats");
|
|
5395
5432
|
}
|
|
5396
5433
|
const Ur = (r, t) => {
|
|
5397
5434
|
var s = "socket_id=" + encodeURIComponent(r.socketId);
|
|
@@ -5501,7 +5538,7 @@ function Ko() {
|
|
|
5501
5538
|
class Gr extends be {
|
|
5502
5539
|
constructor(t) {
|
|
5503
5540
|
super(function(s, a) {
|
|
5504
|
-
|
|
5541
|
+
te.debug(`No callbacks on watchlist events for ${s}`);
|
|
5505
5542
|
}), this.pusher = t, this.bindWatchlistInternalEvent();
|
|
5506
5543
|
}
|
|
5507
5544
|
handleEvent(t) {
|
|
@@ -5526,10 +5563,10 @@ function Ko() {
|
|
|
5526
5563
|
class Yr extends be {
|
|
5527
5564
|
constructor(t) {
|
|
5528
5565
|
super(function(s, a) {
|
|
5529
|
-
|
|
5566
|
+
te.debug("No callbacks on user for " + s);
|
|
5530
5567
|
}), this.signin_requested = !1, this.user_data = null, this.serverToUserChannel = null, this.signinDonePromise = null, this._signinDoneResolve = null, this._onAuthorize = (s, a) => {
|
|
5531
5568
|
if (s) {
|
|
5532
|
-
|
|
5569
|
+
te.warn(`Error during signin: ${s}`), this._cleanup();
|
|
5533
5570
|
return;
|
|
5534
5571
|
}
|
|
5535
5572
|
this.pusher.send_event("pusher:signin", {
|
|
@@ -5555,11 +5592,11 @@ function Ko() {
|
|
|
5555
5592
|
try {
|
|
5556
5593
|
this.user_data = JSON.parse(t.user_data);
|
|
5557
5594
|
} catch {
|
|
5558
|
-
|
|
5595
|
+
te.error(`Failed parsing user data after signin: ${t.user_data}`), this._cleanup();
|
|
5559
5596
|
return;
|
|
5560
5597
|
}
|
|
5561
5598
|
if (typeof this.user_data.id != "string" || this.user_data.id === "") {
|
|
5562
|
-
|
|
5599
|
+
te.error(`user_data doesn't contain an id. user_data: ${this.user_data}`), this._cleanup();
|
|
5563
5600
|
return;
|
|
5564
5601
|
}
|
|
5565
5602
|
this._signinDoneResolve(), this._subscribeChannels();
|
|
@@ -5631,7 +5668,7 @@ function Ko() {
|
|
|
5631
5668
|
}), this.connection.bind("disconnected", () => {
|
|
5632
5669
|
this.channels.disconnect();
|
|
5633
5670
|
}), this.connection.bind("error", (c) => {
|
|
5634
|
-
|
|
5671
|
+
te.warn(c);
|
|
5635
5672
|
}), ue.instances.push(this), this.timeline.info({ instances: ue.instances.length }), this.user = new Yr(this), ue.isReady && this.connect();
|
|
5636
5673
|
}
|
|
5637
5674
|
channel(t) {
|
|
@@ -5703,9 +5740,9 @@ function Ko() {
|
|
|
5703
5740
|
});
|
|
5704
5741
|
})(Et)), Et.exports;
|
|
5705
5742
|
}
|
|
5706
|
-
var
|
|
5707
|
-
const
|
|
5708
|
-
function
|
|
5743
|
+
var Qo = Yo();
|
|
5744
|
+
const Zo = /* @__PURE__ */ Ko(Qo), ea = "/v1/messenger/bootstrap", ta = 3e4, na = 3e4, sa = 5 * 6e4;
|
|
5745
|
+
function ne(e) {
|
|
5709
5746
|
return typeof e == "object" && e !== null;
|
|
5710
5747
|
}
|
|
5711
5748
|
function ae(e, n) {
|
|
@@ -5726,7 +5763,7 @@ function Ne(e, n) {
|
|
|
5726
5763
|
const o = i.trim();
|
|
5727
5764
|
return o === "" ? null : o;
|
|
5728
5765
|
}
|
|
5729
|
-
function
|
|
5766
|
+
function ra(e, n) {
|
|
5730
5767
|
const i = e[n];
|
|
5731
5768
|
if (typeof i == "number" && Number.isFinite(i))
|
|
5732
5769
|
return i;
|
|
@@ -5737,23 +5774,23 @@ function sa(e, n) {
|
|
|
5737
5774
|
}
|
|
5738
5775
|
throw new Error(`Invalid messenger bootstrap payload: missing integer ${n}`);
|
|
5739
5776
|
}
|
|
5740
|
-
function
|
|
5777
|
+
function ia(e) {
|
|
5741
5778
|
return e.toLowerCase() === "http" ? "http" : "https";
|
|
5742
5779
|
}
|
|
5743
|
-
function
|
|
5780
|
+
function oa(e) {
|
|
5744
5781
|
if (e !== null)
|
|
5745
5782
|
return e.startsWith("/") ? e : `/${e}`;
|
|
5746
5783
|
}
|
|
5747
|
-
function
|
|
5748
|
-
if (!
|
|
5784
|
+
function aa(e) {
|
|
5785
|
+
if (!ne(e))
|
|
5749
5786
|
throw new Error("Invalid messenger bootstrap payload: expected object");
|
|
5750
5787
|
const n = e.auth, i = e.service;
|
|
5751
|
-
if (!
|
|
5788
|
+
if (!ne(n) || !ne(i))
|
|
5752
5789
|
throw new Error("Invalid messenger bootstrap payload: missing auth or service data");
|
|
5753
5790
|
const o = n.user, u = i.reverb;
|
|
5754
|
-
if (!
|
|
5791
|
+
if (!ne(o) || !ne(u))
|
|
5755
5792
|
throw new Error("Invalid messenger bootstrap payload: missing user or reverb data");
|
|
5756
|
-
const l =
|
|
5793
|
+
const l = oa(Ne(u, "path"));
|
|
5757
5794
|
return {
|
|
5758
5795
|
auth: {
|
|
5759
5796
|
token: ge(n, "token"),
|
|
@@ -5775,14 +5812,14 @@ function oa(e) {
|
|
|
5775
5812
|
reverb: {
|
|
5776
5813
|
appKey: ge(u, "app_key"),
|
|
5777
5814
|
host: ge(u, "host"),
|
|
5778
|
-
port:
|
|
5779
|
-
scheme:
|
|
5815
|
+
port: ra(u, "port"),
|
|
5816
|
+
scheme: ia(ge(u, "scheme")),
|
|
5780
5817
|
...l ? { path: l } : {}
|
|
5781
5818
|
}
|
|
5782
5819
|
}
|
|
5783
5820
|
};
|
|
5784
5821
|
}
|
|
5785
|
-
function
|
|
5822
|
+
function ca(e) {
|
|
5786
5823
|
return e.replace(/^https?:\/\//, "").replace(/\/.*$/, "").replace(/:\d+$/, "");
|
|
5787
5824
|
}
|
|
5788
5825
|
function In(e, n) {
|
|
@@ -5790,7 +5827,7 @@ function In(e, n) {
|
|
|
5790
5827
|
e.headers.set("Authorization", `Bearer ${n}`), e.headers.set("Accept", "application/json"), e.headers.set("X-Requested-With", "XMLHttpRequest"), typeof FormData < "u" && e.data instanceof FormData && (e.headers.delete("Content-Type"), e.headers.delete("content-type"));
|
|
5791
5828
|
return;
|
|
5792
5829
|
}
|
|
5793
|
-
const i =
|
|
5830
|
+
const i = ne(e.headers) ? e.headers : {};
|
|
5794
5831
|
e.headers = new pn({
|
|
5795
5832
|
...i,
|
|
5796
5833
|
Authorization: `Bearer ${n}`,
|
|
@@ -5805,16 +5842,16 @@ function _e(e, n, i) {
|
|
|
5805
5842
|
const u = e[i];
|
|
5806
5843
|
return typeof u == "string" && u.trim() !== "" ? u : null;
|
|
5807
5844
|
}
|
|
5808
|
-
function
|
|
5845
|
+
function ua(e) {
|
|
5809
5846
|
if (typeof e != "string")
|
|
5810
5847
|
return null;
|
|
5811
5848
|
const n = e.trim().toLowerCase();
|
|
5812
5849
|
return n === "online" || n === "idle" || n === "dnd" || n === "offline" ? n : null;
|
|
5813
5850
|
}
|
|
5814
|
-
function
|
|
5815
|
-
if (!
|
|
5851
|
+
function la(e, n) {
|
|
5852
|
+
if (!ne(e))
|
|
5816
5853
|
return null;
|
|
5817
|
-
const i = _e(e, "user_id", "userId"), o =
|
|
5854
|
+
const i = _e(e, "user_id", "userId"), o = ua(e.status);
|
|
5818
5855
|
if (!i || !o)
|
|
5819
5856
|
return null;
|
|
5820
5857
|
const u = {
|
|
@@ -5827,13 +5864,13 @@ function ua(e, n) {
|
|
|
5827
5864
|
const h = e.last_seen_at ?? e.lastSeenAt;
|
|
5828
5865
|
return typeof h == "string" ? u.last_seen_at = h : h === null && (u.last_seen_at = null), u;
|
|
5829
5866
|
}
|
|
5830
|
-
function
|
|
5831
|
-
if (!
|
|
5867
|
+
function ha(e) {
|
|
5868
|
+
if (!ne(e))
|
|
5832
5869
|
return null;
|
|
5833
5870
|
const n = _e(e, "user_id", "userId"), i = _e(e, "conversation_id", "conversationId");
|
|
5834
5871
|
if (!n || !i)
|
|
5835
5872
|
return null;
|
|
5836
|
-
const o = e.user, u =
|
|
5873
|
+
const o = e.user, u = ne(o) ? {
|
|
5837
5874
|
id: typeof o.id == "string" && o.id !== "" ? o.id : n,
|
|
5838
5875
|
name: typeof o.name == "string" ? o.name : "",
|
|
5839
5876
|
...typeof o.avatar == "string" && o.avatar !== "" ? { avatar: o.avatar } : {}
|
|
@@ -5848,13 +5885,13 @@ function la(e) {
|
|
|
5848
5885
|
...typeof e.stopped_at == "string" ? { stopped_at: e.stopped_at } : {}
|
|
5849
5886
|
};
|
|
5850
5887
|
}
|
|
5851
|
-
function
|
|
5852
|
-
if (!
|
|
5888
|
+
function da(e) {
|
|
5889
|
+
if (!ne(e))
|
|
5853
5890
|
return null;
|
|
5854
5891
|
const n = _e(e, "user_id", "userId"), i = _e(e, "conversation_id", "conversationId");
|
|
5855
5892
|
if (!n || !i)
|
|
5856
5893
|
return null;
|
|
5857
|
-
const o =
|
|
5894
|
+
const o = ne(e.user) ? {
|
|
5858
5895
|
...typeof e.user.id == "string" && e.user.id !== "" ? { id: e.user.id } : {},
|
|
5859
5896
|
...typeof e.user.name == "string" ? { name: e.user.name } : {},
|
|
5860
5897
|
...typeof e.user.avatar == "string" && e.user.avatar !== "" ? { avatar: e.user.avatar } : {}
|
|
@@ -5867,8 +5904,8 @@ function ha(e) {
|
|
|
5867
5904
|
...typeof e.ts == "string" ? { ts: e.ts } : {}
|
|
5868
5905
|
};
|
|
5869
5906
|
}
|
|
5870
|
-
function
|
|
5871
|
-
if (!
|
|
5907
|
+
function fa(e) {
|
|
5908
|
+
if (!ne(e))
|
|
5872
5909
|
return null;
|
|
5873
5910
|
const n = _e(e, "user_id", "userId"), i = _e(e, "conversation_id", "conversationId");
|
|
5874
5911
|
return !n || !i ? null : {
|
|
@@ -5878,32 +5915,32 @@ function da(e) {
|
|
|
5878
5915
|
...typeof e.ts == "string" ? { ts: e.ts } : {}
|
|
5879
5916
|
};
|
|
5880
5917
|
}
|
|
5881
|
-
function fa(e) {
|
|
5882
|
-
return se(e) && ae(e, "id") && ae(e, "name");
|
|
5883
|
-
}
|
|
5884
5918
|
function pa(e) {
|
|
5885
|
-
return
|
|
5919
|
+
return ne(e) && ae(e, "id") && ae(e, "name");
|
|
5886
5920
|
}
|
|
5887
5921
|
function ga(e) {
|
|
5888
|
-
return
|
|
5922
|
+
return !ne(e) || !ae(e, "reaction") || typeof e.count != "number" ? !1 : Array.isArray(e.users) && e.users.every((n) => pa(n));
|
|
5889
5923
|
}
|
|
5890
5924
|
function ma(e) {
|
|
5891
|
-
return
|
|
5925
|
+
return ne(e) && ne(e.message) && ae(e.message, "id") && ae(e.message, "conversation_id") && ae(e.message, "author_id");
|
|
5892
5926
|
}
|
|
5893
5927
|
function va(e) {
|
|
5894
|
-
return
|
|
5928
|
+
return ne(e) && ae(e, "conversation_id") && ae(e, "user_id") && ae(e, "message_id");
|
|
5895
5929
|
}
|
|
5896
5930
|
function ba(e) {
|
|
5897
|
-
return
|
|
5931
|
+
return ne(e) && ae(e, "conversation_id") && ne(e.message) && ae(e.message, "id");
|
|
5898
5932
|
}
|
|
5899
5933
|
function ya(e) {
|
|
5900
|
-
return
|
|
5934
|
+
return ne(e) && ae(e, "conversation_id") && ae(e, "message_id");
|
|
5901
5935
|
}
|
|
5902
5936
|
function _a(e) {
|
|
5903
|
-
return
|
|
5937
|
+
return ne(e) && ae(e, "conversation_id") && ae(e, "message_id") && Array.isArray(e.reactions) && e.reactions.every((n) => ga(n));
|
|
5904
5938
|
}
|
|
5905
5939
|
function Sa(e) {
|
|
5906
|
-
return
|
|
5940
|
+
return ne(e) && ae(e, "conversation_id");
|
|
5941
|
+
}
|
|
5942
|
+
function wa(e) {
|
|
5943
|
+
return ne(e) && ae(e, "conversation_id") && ae(e, "removed_user_id");
|
|
5907
5944
|
}
|
|
5908
5945
|
function Re(e, n, i, o) {
|
|
5909
5946
|
const u = (l) => {
|
|
@@ -5911,61 +5948,61 @@ function Re(e, n, i, o) {
|
|
|
5911
5948
|
};
|
|
5912
5949
|
return e.listen(n, u), u;
|
|
5913
5950
|
}
|
|
5914
|
-
function
|
|
5915
|
-
const n = e.initializedEvent ?? "messenger-client:echo-initialized", i = e.bootstrapEndpoint ??
|
|
5916
|
-
typeof window < "u" && (window.Pusher =
|
|
5917
|
-
let h = null, g = null, d = null,
|
|
5918
|
-
const
|
|
5919
|
-
x =
|
|
5920
|
-
for (const k of
|
|
5921
|
-
k(
|
|
5951
|
+
function qa(e) {
|
|
5952
|
+
const n = e.initializedEvent ?? "messenger-client:echo-initialized", i = e.bootstrapEndpoint ?? ea, o = e.bootstrapRefreshSkewMs ?? ta, u = e.presenceFreshnessTtlMs ?? sa, l = (e.createLogger ?? Dt())("MessengerEcho");
|
|
5953
|
+
typeof window < "u" && (window.Pusher = Zo);
|
|
5954
|
+
let h = null, g = null, d = null, A = null, x = "disconnected", m = null, y = null;
|
|
5955
|
+
const E = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map(), S = (T) => {
|
|
5956
|
+
x = T;
|
|
5957
|
+
for (const k of E)
|
|
5958
|
+
k(T);
|
|
5922
5959
|
}, f = () => {
|
|
5923
5960
|
y !== null && (clearTimeout(y), y = null);
|
|
5924
|
-
},
|
|
5925
|
-
d !== null && (d.disconnect(), d = null),
|
|
5961
|
+
}, v = (T = !0) => {
|
|
5962
|
+
d !== null && (d.disconnect(), d = null), A = null, T && S("disconnected");
|
|
5926
5963
|
}, b = () => {
|
|
5927
|
-
f(), h = null, g = null,
|
|
5964
|
+
f(), h = null, g = null, m = null, v(), R.clear();
|
|
5928
5965
|
}, F = () => {
|
|
5929
5966
|
if (!e.getSourceToken)
|
|
5930
5967
|
return null;
|
|
5931
|
-
const
|
|
5932
|
-
return
|
|
5933
|
-
}, j = (
|
|
5934
|
-
if (
|
|
5968
|
+
const T = e.getSourceToken();
|
|
5969
|
+
return T === null ? (b(), null) : (m !== null && m !== T && (f(), h = null, g = null, v()), m = T, T);
|
|
5970
|
+
}, j = (T) => {
|
|
5971
|
+
if (T === null)
|
|
5935
5972
|
return !1;
|
|
5936
|
-
if (
|
|
5937
|
-
return
|
|
5938
|
-
const k = Date.parse(
|
|
5973
|
+
if (T.auth.expiresAt === null)
|
|
5974
|
+
return T.auth.token !== "";
|
|
5975
|
+
const k = Date.parse(T.auth.expiresAt);
|
|
5939
5976
|
return Number.isNaN(k) ? !1 : k - Date.now() > o;
|
|
5940
|
-
},
|
|
5941
|
-
if (f(),
|
|
5977
|
+
}, B = (T) => {
|
|
5978
|
+
if (f(), T.auth.expiresAt === null)
|
|
5942
5979
|
return;
|
|
5943
|
-
const k = Date.parse(
|
|
5980
|
+
const k = Date.parse(T.auth.expiresAt);
|
|
5944
5981
|
if (Number.isNaN(k))
|
|
5945
5982
|
return;
|
|
5946
|
-
const
|
|
5983
|
+
const Y = Math.max(0, k - Date.now() - o);
|
|
5947
5984
|
y = setTimeout(() => {
|
|
5948
5985
|
U();
|
|
5949
|
-
},
|
|
5950
|
-
},
|
|
5951
|
-
const
|
|
5986
|
+
}, Y);
|
|
5987
|
+
}, P = async (T = !1) => e.getSourceToken && F() === null ? null : !T && j(h) ? h : !T && g !== null ? await g : (g = (async () => {
|
|
5988
|
+
const Y = await e.bootstrapClient.get(
|
|
5952
5989
|
i,
|
|
5953
|
-
|
|
5954
|
-
), N =
|
|
5955
|
-
return h = N,
|
|
5990
|
+
T ? { params: { refresh: 1 } } : void 0
|
|
5991
|
+
), N = aa(Y.data);
|
|
5992
|
+
return h = N, B(N), N;
|
|
5956
5993
|
})().finally(() => {
|
|
5957
5994
|
g = null;
|
|
5958
5995
|
}), await g), U = async () => {
|
|
5959
|
-
const
|
|
5996
|
+
const T = d !== null;
|
|
5960
5997
|
try {
|
|
5961
|
-
if (await
|
|
5998
|
+
if (await P(!0), !T)
|
|
5962
5999
|
return;
|
|
5963
|
-
|
|
6000
|
+
v(!1), await z(!0);
|
|
5964
6001
|
} catch (k) {
|
|
5965
6002
|
l.warn("Failed to refresh messenger bootstrap", k);
|
|
5966
6003
|
}
|
|
5967
|
-
},
|
|
5968
|
-
const k =
|
|
6004
|
+
}, $ = (T) => {
|
|
6005
|
+
const k = T.connector?.pusher?.connection;
|
|
5969
6006
|
if (!k) {
|
|
5970
6007
|
l.warn("Messenger echo connector does not expose a Pusher connection");
|
|
5971
6008
|
return;
|
|
@@ -5981,92 +6018,92 @@ function Da(e) {
|
|
|
5981
6018
|
}), k.bind("error", () => {
|
|
5982
6019
|
S("error");
|
|
5983
6020
|
}), k.state === "connected" && S("connected");
|
|
5984
|
-
}, z = async (
|
|
5985
|
-
const
|
|
5986
|
-
if (
|
|
6021
|
+
}, z = async (T = !1) => !T && d !== null && j(h) ? d : !T && A !== null ? await A : (A = (async () => {
|
|
6022
|
+
const Y = await P(T);
|
|
6023
|
+
if (Y === null)
|
|
5987
6024
|
return null;
|
|
5988
|
-
d !== null &&
|
|
5989
|
-
const N =
|
|
6025
|
+
d !== null && v(!1);
|
|
6026
|
+
const N = Y.service.reverb.scheme === "https", V = {
|
|
5990
6027
|
broadcaster: "reverb",
|
|
5991
|
-
key:
|
|
5992
|
-
wsHost:
|
|
5993
|
-
wsPort:
|
|
5994
|
-
wssPort:
|
|
6028
|
+
key: Y.service.reverb.appKey,
|
|
6029
|
+
wsHost: ca(Y.service.reverb.host),
|
|
6030
|
+
wsPort: Y.service.reverb.port,
|
|
6031
|
+
wssPort: Y.service.reverb.port,
|
|
5995
6032
|
forceTLS: N,
|
|
5996
6033
|
encrypted: N,
|
|
5997
6034
|
disableStats: !0,
|
|
5998
6035
|
enabledTransports: ["ws", "wss"],
|
|
5999
|
-
authEndpoint:
|
|
6036
|
+
authEndpoint: Y.service.broadcastingAuthUrl,
|
|
6000
6037
|
auth: {
|
|
6001
6038
|
headers: {
|
|
6002
|
-
Authorization: `Bearer ${
|
|
6039
|
+
Authorization: `Bearer ${Y.auth.token}`,
|
|
6003
6040
|
Accept: "application/json"
|
|
6004
6041
|
}
|
|
6005
6042
|
}
|
|
6006
6043
|
};
|
|
6007
|
-
return
|
|
6044
|
+
return Y.service.reverb.path && (V.wsPath = Y.service.reverb.path), d = new Jo(V), $(d), S("connecting"), typeof window < "u" && window.dispatchEvent(new CustomEvent(n)), d;
|
|
6008
6045
|
})().finally(() => {
|
|
6009
|
-
|
|
6010
|
-
}), await
|
|
6011
|
-
timeout: e.requestTimeoutMs ??
|
|
6046
|
+
A = null;
|
|
6047
|
+
}), await A), K = Mt.create({
|
|
6048
|
+
timeout: e.requestTimeoutMs ?? na,
|
|
6012
6049
|
withCredentials: !1,
|
|
6013
6050
|
headers: {
|
|
6014
6051
|
Accept: "application/json",
|
|
6015
6052
|
"X-Requested-With": "XMLHttpRequest"
|
|
6016
6053
|
}
|
|
6017
6054
|
});
|
|
6018
|
-
|
|
6019
|
-
const k = await
|
|
6055
|
+
K.interceptors.request.use(async (T) => {
|
|
6056
|
+
const k = await P();
|
|
6020
6057
|
if (k === null)
|
|
6021
6058
|
throw new Error("Messenger bootstrap is unavailable.");
|
|
6022
|
-
return
|
|
6023
|
-
}),
|
|
6024
|
-
(
|
|
6025
|
-
async (
|
|
6026
|
-
const k =
|
|
6027
|
-
if (
|
|
6059
|
+
return T.baseURL = k.service.apiBaseUrl, In(T, k.auth.token), T;
|
|
6060
|
+
}), K.interceptors.response.use(
|
|
6061
|
+
(T) => T,
|
|
6062
|
+
async (T) => {
|
|
6063
|
+
const k = T.config;
|
|
6064
|
+
if (T.response?.status === 401 && k && k._messengerRetry !== !0) {
|
|
6028
6065
|
k._messengerRetry = !0;
|
|
6029
|
-
const
|
|
6030
|
-
if (
|
|
6031
|
-
return k.baseURL =
|
|
6066
|
+
const Y = await P(!0);
|
|
6067
|
+
if (Y !== null)
|
|
6068
|
+
return k.baseURL = Y.service.apiBaseUrl, In(k, Y.auth.token), await K(k);
|
|
6032
6069
|
}
|
|
6033
|
-
return Promise.reject(
|
|
6070
|
+
return Promise.reject(T);
|
|
6034
6071
|
}
|
|
6035
6072
|
);
|
|
6036
|
-
const
|
|
6037
|
-
l.warn("Failed to initialize messenger echo",
|
|
6038
|
-
}), d),
|
|
6039
|
-
|
|
6040
|
-
}), M = () => h?.auth.tenantId ?? "global",
|
|
6041
|
-
const k = Pt(
|
|
6073
|
+
const se = () => (z().catch((T) => {
|
|
6074
|
+
l.warn("Failed to initialize messenger echo", T);
|
|
6075
|
+
}), d), w = (T) => (E.add(T), T(x), () => {
|
|
6076
|
+
E.delete(T);
|
|
6077
|
+
}), M = () => h?.auth.tenantId ?? "global", ee = (T) => {
|
|
6078
|
+
const k = Pt(T.ts)?.getTime() ?? Pt(T.last_seen_at)?.getTime() ?? null;
|
|
6042
6079
|
if (k === null)
|
|
6043
6080
|
return !0;
|
|
6044
|
-
const
|
|
6081
|
+
const Y = `${T.tenant_scope ?? "global"}:${T.user_id}`, N = R.get(Y);
|
|
6045
6082
|
if (N && k < N.timestampMs)
|
|
6046
6083
|
return !1;
|
|
6047
6084
|
const V = Date.now();
|
|
6048
|
-
|
|
6085
|
+
R.set(Y, {
|
|
6049
6086
|
timestampMs: k,
|
|
6050
6087
|
seenAt: V
|
|
6051
6088
|
});
|
|
6052
|
-
for (const [me, ve] of
|
|
6053
|
-
V - ve.seenAt > u &&
|
|
6089
|
+
for (const [me, ve] of R.entries())
|
|
6090
|
+
V - ve.seenAt > u && R.delete(me);
|
|
6054
6091
|
return !0;
|
|
6055
6092
|
};
|
|
6056
6093
|
return {
|
|
6057
|
-
apiClient:
|
|
6094
|
+
apiClient: K,
|
|
6058
6095
|
initializedEvent: n,
|
|
6059
|
-
getEcho:
|
|
6096
|
+
getEcho: se,
|
|
6060
6097
|
getConnectionStatus: () => x,
|
|
6061
|
-
onConnectionStatusChange:
|
|
6098
|
+
onConnectionStatusChange: w,
|
|
6062
6099
|
reconnect: async () => {
|
|
6063
|
-
|
|
6100
|
+
v(), await z(!0);
|
|
6064
6101
|
},
|
|
6065
|
-
subscribeToPresenceStatus: (
|
|
6066
|
-
const k =
|
|
6102
|
+
subscribeToPresenceStatus: (T) => {
|
|
6103
|
+
const k = se();
|
|
6067
6104
|
if (!k || typeof k.join != "function")
|
|
6068
6105
|
return;
|
|
6069
|
-
const
|
|
6106
|
+
const Y = k.join(`online-users.${M()}`), N = [
|
|
6070
6107
|
".PresenceStatusChanged",
|
|
6071
6108
|
"PresenceStatusChanged",
|
|
6072
6109
|
".presence.status.changed",
|
|
@@ -6077,56 +6114,56 @@ function Da(e) {
|
|
|
6077
6114
|
"Modules\\Presence\\Events\\UserPresenceStatusChanged"
|
|
6078
6115
|
];
|
|
6079
6116
|
for (const V of N)
|
|
6080
|
-
|
|
6081
|
-
const ve =
|
|
6082
|
-
!ve || !
|
|
6117
|
+
Y.listen(V, (me) => {
|
|
6118
|
+
const ve = la(me, M());
|
|
6119
|
+
!ve || !ee(ve) || T(ve);
|
|
6083
6120
|
});
|
|
6084
6121
|
},
|
|
6085
6122
|
unsubscribeFromPresenceStatus: () => {
|
|
6086
6123
|
d?.leave(`online-users.${M()}`);
|
|
6087
6124
|
},
|
|
6088
|
-
subscribeToConversation: (
|
|
6089
|
-
const
|
|
6090
|
-
if (!
|
|
6125
|
+
subscribeToConversation: (T, k) => {
|
|
6126
|
+
const Y = se();
|
|
6127
|
+
if (!Y)
|
|
6091
6128
|
return () => {
|
|
6092
6129
|
};
|
|
6093
|
-
const N =
|
|
6130
|
+
const N = Y.private(`conversation.${T}`), V = [];
|
|
6094
6131
|
return k.onMessageSent && V.push({
|
|
6095
6132
|
event: ".ConversationMessageSent",
|
|
6096
|
-
handler: Re(N, ".ConversationMessageSent",
|
|
6133
|
+
handler: Re(N, ".ConversationMessageSent", ma, k.onMessageSent)
|
|
6097
6134
|
}), k.onMessageRead && V.push({
|
|
6098
6135
|
event: ".ConversationMessageRead",
|
|
6099
|
-
handler: Re(N, ".ConversationMessageRead",
|
|
6136
|
+
handler: Re(N, ".ConversationMessageRead", va, k.onMessageRead)
|
|
6100
6137
|
}), k.onMessageEdited && V.push({
|
|
6101
6138
|
event: ".ConversationMessageEdited",
|
|
6102
|
-
handler: Re(N, ".ConversationMessageEdited",
|
|
6139
|
+
handler: Re(N, ".ConversationMessageEdited", ba, k.onMessageEdited)
|
|
6103
6140
|
}), k.onMessageDeleted && V.push({
|
|
6104
6141
|
event: ".ConversationMessageDeleted",
|
|
6105
|
-
handler: Re(N, ".ConversationMessageDeleted",
|
|
6142
|
+
handler: Re(N, ".ConversationMessageDeleted", ya, k.onMessageDeleted)
|
|
6106
6143
|
}), k.onReactionToggled && V.push({
|
|
6107
6144
|
event: ".MessageReactionToggled",
|
|
6108
|
-
handler: Re(N, ".MessageReactionToggled",
|
|
6145
|
+
handler: Re(N, ".MessageReactionToggled", _a, k.onReactionToggled)
|
|
6109
6146
|
}), k.onRequestAccepted && V.push({
|
|
6110
6147
|
event: ".ConversationRequestAccepted",
|
|
6111
|
-
handler: Re(N, ".ConversationRequestAccepted",
|
|
6148
|
+
handler: Re(N, ".ConversationRequestAccepted", Sa, k.onRequestAccepted)
|
|
6112
6149
|
}), k.onParticipantRemoved && V.push({
|
|
6113
6150
|
event: ".ConversationParticipantRemoved",
|
|
6114
|
-
handler: Re(N, ".ConversationParticipantRemoved",
|
|
6151
|
+
handler: Re(N, ".ConversationParticipantRemoved", wa, k.onParticipantRemoved)
|
|
6115
6152
|
}), () => {
|
|
6116
6153
|
if (typeof N.stopListening == "function")
|
|
6117
6154
|
for (const me of V)
|
|
6118
6155
|
N.stopListening(me.event, me.handler);
|
|
6119
6156
|
};
|
|
6120
6157
|
},
|
|
6121
|
-
unsubscribeFromConversation: (
|
|
6122
|
-
d?.leave(`conversation.${
|
|
6158
|
+
unsubscribeFromConversation: (T) => {
|
|
6159
|
+
d?.leave(`conversation.${T}`);
|
|
6123
6160
|
},
|
|
6124
|
-
subscribeToTyping: (
|
|
6125
|
-
const
|
|
6126
|
-
if (!
|
|
6161
|
+
subscribeToTyping: (T, k) => {
|
|
6162
|
+
const Y = se();
|
|
6163
|
+
if (!Y)
|
|
6127
6164
|
return () => {
|
|
6128
6165
|
};
|
|
6129
|
-
const N =
|
|
6166
|
+
const N = Y.private(`typing-conversation.${T}`), V = [], me = [
|
|
6130
6167
|
".TypingStateChanged",
|
|
6131
6168
|
"TypingStateChanged",
|
|
6132
6169
|
".typing.changed",
|
|
@@ -6137,58 +6174,58 @@ function Da(e) {
|
|
|
6137
6174
|
"Modules\\Messaging\\Events\\Broadcast\\TypingStateChanged"
|
|
6138
6175
|
], ve = [".typing.start", "typing.start", ".TypingStarted", "TypingStarted", ".TypingStart", "TypingStart"], fe = [".typing.stop", "typing.stop", ".TypingStopped", "TypingStopped", ".TypingStop", "TypingStop"], $e = /* @__PURE__ */ new Set(["start", "typing"]), ot = /* @__PURE__ */ new Set(["stop", "idle", "viewing"]);
|
|
6139
6176
|
for (const ce of me) {
|
|
6140
|
-
const pe = (
|
|
6141
|
-
const
|
|
6142
|
-
if (
|
|
6143
|
-
if ($e.has(
|
|
6177
|
+
const pe = (we) => {
|
|
6178
|
+
const W = ha(we);
|
|
6179
|
+
if (W) {
|
|
6180
|
+
if ($e.has(W.state)) {
|
|
6144
6181
|
k.onTypingStart?.({
|
|
6145
|
-
user_id:
|
|
6146
|
-
user:
|
|
6147
|
-
id:
|
|
6182
|
+
user_id: W.user_id,
|
|
6183
|
+
user: W.user ?? {
|
|
6184
|
+
id: W.user_id,
|
|
6148
6185
|
name: ""
|
|
6149
6186
|
},
|
|
6150
|
-
conversation_id:
|
|
6151
|
-
started_at:
|
|
6187
|
+
conversation_id: W.conversation_id,
|
|
6188
|
+
started_at: W.started_at ?? W.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6152
6189
|
});
|
|
6153
6190
|
return;
|
|
6154
6191
|
}
|
|
6155
|
-
ot.has(
|
|
6156
|
-
user_id:
|
|
6157
|
-
conversation_id:
|
|
6158
|
-
stopped_at:
|
|
6192
|
+
ot.has(W.state) && k.onTypingStop?.({
|
|
6193
|
+
user_id: W.user_id,
|
|
6194
|
+
conversation_id: W.conversation_id,
|
|
6195
|
+
stopped_at: W.stopped_at ?? W.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6159
6196
|
});
|
|
6160
6197
|
}
|
|
6161
6198
|
};
|
|
6162
6199
|
N.listen(ce, pe), V.push({ event: ce, handler: pe });
|
|
6163
6200
|
}
|
|
6164
6201
|
for (const ce of ve) {
|
|
6165
|
-
const pe = (
|
|
6166
|
-
const
|
|
6167
|
-
if (!
|
|
6202
|
+
const pe = (we) => {
|
|
6203
|
+
const W = da(we);
|
|
6204
|
+
if (!W)
|
|
6168
6205
|
return;
|
|
6169
6206
|
const xe = {
|
|
6170
|
-
user_id:
|
|
6207
|
+
user_id: W.user_id,
|
|
6171
6208
|
user: {
|
|
6172
|
-
id:
|
|
6173
|
-
name:
|
|
6174
|
-
...
|
|
6209
|
+
id: W.user?.id ?? W.user_id,
|
|
6210
|
+
name: W.user?.name ?? "",
|
|
6211
|
+
...W.user?.avatar ? { avatar: W.user.avatar } : {}
|
|
6175
6212
|
},
|
|
6176
|
-
conversation_id:
|
|
6177
|
-
started_at:
|
|
6213
|
+
conversation_id: W.conversation_id,
|
|
6214
|
+
started_at: W.started_at ?? W.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6178
6215
|
};
|
|
6179
6216
|
k.onTypingStart?.(xe);
|
|
6180
6217
|
};
|
|
6181
6218
|
N.listen(ce, pe), V.push({ event: ce, handler: pe });
|
|
6182
6219
|
}
|
|
6183
6220
|
for (const ce of fe) {
|
|
6184
|
-
const pe = (
|
|
6185
|
-
const
|
|
6186
|
-
if (!
|
|
6221
|
+
const pe = (we) => {
|
|
6222
|
+
const W = fa(we);
|
|
6223
|
+
if (!W)
|
|
6187
6224
|
return;
|
|
6188
6225
|
const xe = {
|
|
6189
|
-
user_id:
|
|
6190
|
-
conversation_id:
|
|
6191
|
-
stopped_at:
|
|
6226
|
+
user_id: W.user_id,
|
|
6227
|
+
conversation_id: W.conversation_id,
|
|
6228
|
+
stopped_at: W.stopped_at ?? W.ts ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
6192
6229
|
};
|
|
6193
6230
|
k.onTypingStop?.(xe);
|
|
6194
6231
|
};
|
|
@@ -6200,36 +6237,36 @@ function Da(e) {
|
|
|
6200
6237
|
N.stopListening(ce.event, ce.handler);
|
|
6201
6238
|
};
|
|
6202
6239
|
},
|
|
6203
|
-
unsubscribeFromTyping: (
|
|
6204
|
-
d?.leave(`typing-conversation.${
|
|
6240
|
+
unsubscribeFromTyping: (T) => {
|
|
6241
|
+
d?.leave(`typing-conversation.${T}`);
|
|
6205
6242
|
},
|
|
6206
6243
|
clearRuntime: b
|
|
6207
6244
|
};
|
|
6208
6245
|
}
|
|
6209
6246
|
export {
|
|
6210
6247
|
ho as DEFAULT_PRESENCE_STALE_AFTER_MS,
|
|
6211
|
-
|
|
6212
|
-
|
|
6248
|
+
Fa as configureMessengerClient,
|
|
6249
|
+
qa as createMessengerEcho,
|
|
6213
6250
|
X as getApi,
|
|
6214
6251
|
Pe as getAuthStore,
|
|
6215
|
-
|
|
6252
|
+
xa as getConnectionStatus,
|
|
6216
6253
|
Ae as getEcho,
|
|
6217
6254
|
Hn as getEchoConnectionStatus,
|
|
6218
6255
|
De as getEchoInitializedEvent,
|
|
6219
|
-
|
|
6256
|
+
Q as getErrorMessage,
|
|
6220
6257
|
Dt as getLoggerFactory,
|
|
6221
6258
|
es as getMainApi,
|
|
6222
6259
|
Qi as getMainEcho,
|
|
6223
6260
|
Zi as getMainEchoConnectionStatus,
|
|
6224
6261
|
Yi as getMainEchoInitializedEvent,
|
|
6225
6262
|
Pi as getMediaApi,
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6263
|
+
Co as getPresenceRuntimeConfig,
|
|
6264
|
+
ka as hasResponse,
|
|
6265
|
+
$a as isAxiosError,
|
|
6266
|
+
Ma as isError,
|
|
6267
|
+
wi as isValidMessageReadEvent,
|
|
6231
6268
|
Si as isValidMessageSentEvent,
|
|
6232
|
-
|
|
6269
|
+
Ci as isValidRequestAcceptedEvent,
|
|
6233
6270
|
Se as messagingApi,
|
|
6234
6271
|
po as normalizePresenceStatus,
|
|
6235
6272
|
ts as normalizePresenceTimestamp,
|
|
@@ -6245,7 +6282,7 @@ export {
|
|
|
6245
6282
|
Ei as resetMessagingApiClient,
|
|
6246
6283
|
Ai as resetMessagingAuthStoreResolver,
|
|
6247
6284
|
Mi as resetMessagingMediaApi,
|
|
6248
|
-
|
|
6285
|
+
Da as resetMessengerClientConfig,
|
|
6249
6286
|
Eo as resetPresenceRuntimeConfig,
|
|
6250
6287
|
go as resolveFreshPresenceStatus,
|
|
6251
6288
|
xn as resolvePresenceSnapshot,
|
|
@@ -6263,10 +6300,10 @@ export {
|
|
|
6263
6300
|
mi as unsubscribeFromConversation,
|
|
6264
6301
|
pi as unsubscribeFromPresenceStatus,
|
|
6265
6302
|
bi as unsubscribeFromTyping,
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6303
|
+
La as useConnectionStatus,
|
|
6304
|
+
Ia as useConversationChannel,
|
|
6305
|
+
Ua as useGlobalMessaging,
|
|
6269
6306
|
Nt as useMessagingStore,
|
|
6270
|
-
|
|
6271
|
-
|
|
6307
|
+
Oa as usePresence,
|
|
6308
|
+
Na as useTypingChannel
|
|
6272
6309
|
};
|