@nethesis/chat-island 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/ChatIsland.d.ts +3 -1
- package/dist/components/ChatWindow.d.ts +1 -0
- package/dist/components/MessageList.d.ts +3 -1
- package/dist/index.css +1 -1
- package/dist/index.js +477 -262
- package/dist/store.d.ts +2 -0
- package/dist/types.d.ts +3 -0
- package/dist/xmpp.d.ts +15 -0
- package/dist-widget/index.widget.css +1 -1
- package/dist-widget/index.widget.js +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -565,14 +565,14 @@ var D = /* @__PURE__ */ y(((e) => {
|
|
|
565
565
|
e && this.write(e), this.write = function() {};
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
|
-
})), M = D(), N = /* @__PURE__ */ x(O(), 1), P = /* @__PURE__ */ x(k(), 1), F = A(), ee = /* @__PURE__ */ x(j(), 1),
|
|
568
|
+
})), M = D(), N = /* @__PURE__ */ x(O(), 1), P = /* @__PURE__ */ x(k(), 1), F = A(), ee = /* @__PURE__ */ x(j(), 1), I = class extends Error {
|
|
569
569
|
constructor(e) {
|
|
570
570
|
super(e), this.name = "TimeoutError";
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
573
|
//#endregion
|
|
574
574
|
//#region node_modules/@xmpp/events/lib/delay.js
|
|
575
|
-
function
|
|
575
|
+
function te(e) {
|
|
576
576
|
let t, n = new Promise((n) => {
|
|
577
577
|
t = setTimeout(n, e);
|
|
578
578
|
});
|
|
@@ -580,32 +580,32 @@ function ne(e) {
|
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region node_modules/@xmpp/events/lib/timeout.js
|
|
583
|
-
function
|
|
584
|
-
let n =
|
|
583
|
+
function ne(e, t) {
|
|
584
|
+
let n = te(t);
|
|
585
585
|
function r() {
|
|
586
586
|
clearTimeout(n.timeout);
|
|
587
587
|
}
|
|
588
|
-
let i = new
|
|
588
|
+
let i = new I();
|
|
589
589
|
return Promise.race([e.finally(r), n.then(() => {
|
|
590
590
|
throw i;
|
|
591
591
|
})]);
|
|
592
592
|
}
|
|
593
593
|
//#endregion
|
|
594
594
|
//#region node_modules/@xmpp/events/lib/onoff.js
|
|
595
|
-
var
|
|
596
|
-
function
|
|
597
|
-
let t =
|
|
595
|
+
var re = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
function ie(e) {
|
|
597
|
+
let t = re.get(e);
|
|
598
598
|
return t || (t = {
|
|
599
599
|
on: (e.addEventListener ?? e.addListener).bind(e),
|
|
600
600
|
off: (e.removeEventListener ?? e.removeListener).bind(e),
|
|
601
601
|
once: (e.once ?? ((t, n) => e.addEventListener(t, n, { once: !0 }))).bind(e)
|
|
602
|
-
},
|
|
602
|
+
}, re.set(e, t)), t;
|
|
603
603
|
}
|
|
604
604
|
//#endregion
|
|
605
605
|
//#region node_modules/@xmpp/events/lib/promise.js
|
|
606
606
|
function L(e, t, n = "error", r) {
|
|
607
607
|
return new Promise((i, a) => {
|
|
608
|
-
let o, { off: s, once: c } =
|
|
608
|
+
let o, { off: s, once: c } = ie(e), l = () => {
|
|
609
609
|
clearTimeout(o), s(t, d), s(n, u);
|
|
610
610
|
};
|
|
611
611
|
function u(e) {
|
|
@@ -615,7 +615,7 @@ function L(e, t, n = "error", r) {
|
|
|
615
615
|
i(e), l();
|
|
616
616
|
}
|
|
617
617
|
if (c(t, d), n && c(n, u), r) {
|
|
618
|
-
let e = new
|
|
618
|
+
let e = new I();
|
|
619
619
|
o = setTimeout(() => {
|
|
620
620
|
l(), a(e);
|
|
621
621
|
}, r);
|
|
@@ -654,11 +654,11 @@ function oe(e, t = null, n) {
|
|
|
654
654
|
function se(e) {
|
|
655
655
|
return {
|
|
656
656
|
subscribe(t) {
|
|
657
|
-
let { on: n } =
|
|
657
|
+
let { on: n } = ie(t);
|
|
658
658
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
659
659
|
},
|
|
660
660
|
unsubscribe(t) {
|
|
661
|
-
let { off: n } =
|
|
661
|
+
let { off: n } = ie(t);
|
|
662
662
|
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
663
663
|
}
|
|
664
664
|
};
|
|
@@ -1345,7 +1345,7 @@ var qe = class {
|
|
|
1345
1345
|
let n = new ae();
|
|
1346
1346
|
this.handlers.set(e.attrs.id, n);
|
|
1347
1347
|
try {
|
|
1348
|
-
await this.entity.send(e), await
|
|
1348
|
+
await this.entity.send(e), await ne(n.promise, t);
|
|
1349
1349
|
} catch (t) {
|
|
1350
1350
|
throw this.handlers.delete(e.attrs.id), t;
|
|
1351
1351
|
}
|
|
@@ -2322,7 +2322,8 @@ var hn = "chat.internal", W = {
|
|
|
2322
2322
|
ping: "urn:xmpp:ping",
|
|
2323
2323
|
reactions: "urn:xmpp:reactions:0",
|
|
2324
2324
|
reply: "urn:xmpp:reply:0",
|
|
2325
|
-
fallback: "urn:xmpp:fallback:0"
|
|
2325
|
+
fallback: "urn:xmpp:fallback:0",
|
|
2326
|
+
markers: "urn:xmpp:chat-markers:0"
|
|
2326
2327
|
}, gn = 3e4, _n = class {
|
|
2327
2328
|
xmpp;
|
|
2328
2329
|
me;
|
|
@@ -2331,6 +2332,7 @@ var hn = "chat.internal", W = {
|
|
|
2331
2332
|
uploadService;
|
|
2332
2333
|
mamQueries = /* @__PURE__ */ new Map();
|
|
2333
2334
|
mamReactions = /* @__PURE__ */ new Map();
|
|
2335
|
+
mamMarkers = /* @__PURE__ */ new Map();
|
|
2334
2336
|
stopped = !1;
|
|
2335
2337
|
attempt = 0;
|
|
2336
2338
|
retryTimer;
|
|
@@ -2461,7 +2463,7 @@ var hn = "chat.internal", W = {
|
|
|
2461
2463
|
room: e,
|
|
2462
2464
|
nick: this.cfg.username,
|
|
2463
2465
|
reply: r
|
|
2464
|
-
}) : (s.push(R("active", { xmlns: W.chatstates })), await this.xmpp.send(R("message", {
|
|
2466
|
+
}) : (s.push(R("active", { xmlns: W.chatstates }), R("markable", { xmlns: W.markers })), await this.xmpp.send(R("message", {
|
|
2465
2467
|
to: `${e}@${this.domain}`,
|
|
2466
2468
|
type: "chat",
|
|
2467
2469
|
id: i
|
|
@@ -2477,6 +2479,16 @@ var hn = "chat.internal", W = {
|
|
|
2477
2479
|
reply: r
|
|
2478
2480
|
});
|
|
2479
2481
|
}
|
|
2482
|
+
async marker(e, t, n) {
|
|
2483
|
+
await this.xmpp.send(R("message", {
|
|
2484
|
+
to: `${e}@${this.domain}`,
|
|
2485
|
+
type: "chat",
|
|
2486
|
+
id: crypto.randomUUID()
|
|
2487
|
+
}, R(t, {
|
|
2488
|
+
xmlns: W.markers,
|
|
2489
|
+
id: n
|
|
2490
|
+
}), R("store", { xmlns: W.hints })));
|
|
2491
|
+
}
|
|
2480
2492
|
async react(e, t, n) {
|
|
2481
2493
|
let r = this.isGroup(e), i = R("reactions", {
|
|
2482
2494
|
xmlns: W.reactions,
|
|
@@ -2519,7 +2531,7 @@ var hn = "chat.internal", W = {
|
|
|
2519
2531
|
}
|
|
2520
2532
|
async mam(e, t, n) {
|
|
2521
2533
|
let r = crypto.randomUUID();
|
|
2522
|
-
this.mamQueries.set(r, []), this.mamReactions.set(r, []);
|
|
2534
|
+
this.mamQueries.set(r, []), this.mamReactions.set(r, []), this.mamMarkers.set(r, []);
|
|
2523
2535
|
let i = R("set", { xmlns: W.rsm }, R("max", {}, String(n)), R("before", {}, t ?? "")), a = [R("field", {
|
|
2524
2536
|
var: "FORM_TYPE",
|
|
2525
2537
|
type: "hidden"
|
|
@@ -2528,7 +2540,7 @@ var hn = "chat.internal", W = {
|
|
|
2528
2540
|
let o = R("x", {
|
|
2529
2541
|
xmlns: W.data,
|
|
2530
2542
|
type: "submit"
|
|
2531
|
-
}, ...a), s, c, l;
|
|
2543
|
+
}, ...a), s, c, l, u;
|
|
2532
2544
|
try {
|
|
2533
2545
|
s = await this.xmpp.iqCaller.request(R("iq", {
|
|
2534
2546
|
type: "set",
|
|
@@ -2538,14 +2550,15 @@ var hn = "chat.internal", W = {
|
|
|
2538
2550
|
queryid: r
|
|
2539
2551
|
}, o, i)), 3e4);
|
|
2540
2552
|
} finally {
|
|
2541
|
-
c = this.mamQueries.get(r) ?? [], l = this.mamReactions.get(r) ?? [], this.mamQueries.delete(r), this.mamReactions.delete(r);
|
|
2553
|
+
c = this.mamQueries.get(r) ?? [], l = this.mamReactions.get(r) ?? [], u = this.mamMarkers.get(r) ?? [], this.mamQueries.delete(r), this.mamReactions.delete(r), this.mamMarkers.delete(r);
|
|
2542
2554
|
}
|
|
2543
|
-
let
|
|
2555
|
+
let d = s.getChild("fin", W.mam), f = d?.getChild("set", W.rsm)?.getChildText("first") ?? void 0;
|
|
2544
2556
|
return {
|
|
2545
2557
|
messages: c,
|
|
2546
2558
|
reactions: l,
|
|
2547
|
-
|
|
2548
|
-
|
|
2559
|
+
markers: u,
|
|
2560
|
+
complete: d?.attrs.complete === "true",
|
|
2561
|
+
first: f
|
|
2549
2562
|
};
|
|
2550
2563
|
}
|
|
2551
2564
|
async createGroup(e, t, n) {
|
|
@@ -2732,10 +2745,12 @@ var hn = "chat.internal", W = {
|
|
|
2732
2745
|
if (!t) return;
|
|
2733
2746
|
let e = n.getChild("forwarded", W.forward)?.getChild("message"), r = this.mamQueries.get(n.attrs.queryid);
|
|
2734
2747
|
if (e && r) {
|
|
2735
|
-
let t = this.
|
|
2736
|
-
|
|
2737
|
-
let
|
|
2738
|
-
|
|
2748
|
+
let t = bn(n.getChild("forwarded", W.forward)), i = this.markerOf(e, t);
|
|
2749
|
+
i && this.mamMarkers.get(n.attrs.queryid)?.push(i);
|
|
2750
|
+
let a = i ? void 0 : this.reactionOf(e);
|
|
2751
|
+
a && this.mamReactions.get(n.attrs.queryid)?.push(a);
|
|
2752
|
+
let o = a || i ? void 0 : this.toMessage(e, n.attrs.id, bn(n.getChild("forwarded", W.forward)));
|
|
2753
|
+
o && r.push(o);
|
|
2739
2754
|
}
|
|
2740
2755
|
return;
|
|
2741
2756
|
}
|
|
@@ -2761,19 +2776,37 @@ var hn = "chat.internal", W = {
|
|
|
2761
2776
|
this.deliver(e);
|
|
2762
2777
|
}
|
|
2763
2778
|
deliver(e) {
|
|
2764
|
-
let t = this.
|
|
2779
|
+
let t = this.markerOf(e, bn(e));
|
|
2765
2780
|
if (t) {
|
|
2766
|
-
this.h.
|
|
2781
|
+
this.h.marker(t);
|
|
2767
2782
|
return;
|
|
2768
2783
|
}
|
|
2769
|
-
let n = this.
|
|
2784
|
+
let n = this.reactionOf(e);
|
|
2770
2785
|
if (n) {
|
|
2771
|
-
this.h.
|
|
2786
|
+
this.h.reaction(n);
|
|
2787
|
+
return;
|
|
2788
|
+
}
|
|
2789
|
+
let r = this.toMessage(e, e.getChild("stanza-id", W.sid)?.attrs.id, bn(e));
|
|
2790
|
+
if (r) {
|
|
2791
|
+
this.h.message(r);
|
|
2772
2792
|
return;
|
|
2773
2793
|
}
|
|
2774
2794
|
if (e.attrs.type !== "chat") return;
|
|
2775
|
-
let
|
|
2776
|
-
!e.getChild("body") &&
|
|
2795
|
+
let i = G(e.attrs.from), a = i === this.me ? G(e.attrs.to) : i, o = e.getChildByAttr("xmlns", W.chatstates);
|
|
2796
|
+
!e.getChild("body") && o && this.h.typing(K(a), o.name === "composing");
|
|
2797
|
+
}
|
|
2798
|
+
markerOf(e, t) {
|
|
2799
|
+
if (e.attrs.type !== "chat") return;
|
|
2800
|
+
let n = e.getChild("received", W.markers) ?? e.getChild("displayed", W.markers);
|
|
2801
|
+
if (!n?.attrs.id) return;
|
|
2802
|
+
let r = G(e.attrs.from), i = r === this.me || !e.attrs.from, a = K(i ? G(e.attrs.to) : r);
|
|
2803
|
+
return a ? {
|
|
2804
|
+
peer: a,
|
|
2805
|
+
kind: n.name,
|
|
2806
|
+
id: n.attrs.id,
|
|
2807
|
+
ts: t,
|
|
2808
|
+
mine: i
|
|
2809
|
+
} : void 0;
|
|
2777
2810
|
}
|
|
2778
2811
|
reactionOf(e) {
|
|
2779
2812
|
let t = e.getChild("event", W.pubsubEvent), n = e, r;
|
|
@@ -2959,11 +2992,16 @@ var An = (e) => {
|
|
|
2959
2992
|
loaded: !1,
|
|
2960
2993
|
complete: !1
|
|
2961
2994
|
}), Nn = (e, t, n, r) => {
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2995
|
+
let i = e.indexOf(t);
|
|
2996
|
+
if (i >= 0 && i < n) return e;
|
|
2997
|
+
let a = [t, ...e.filter((e) => e !== t)].slice(0, 100);
|
|
2998
|
+
if (!r || a.indexOf(r) < n) return a;
|
|
2999
|
+
let o = a.filter((e) => e !== r);
|
|
3000
|
+
return [
|
|
3001
|
+
...o.slice(0, n - 1),
|
|
3002
|
+
r,
|
|
3003
|
+
...o.slice(n - 1)
|
|
3004
|
+
];
|
|
2967
3005
|
}, Pn = (e, t) => e.id === t.id || !!e.oid && e.oid === t.oid, Y = jn((e, t) => ({
|
|
2968
3006
|
me: "",
|
|
2969
3007
|
myName: "",
|
|
@@ -3083,6 +3121,33 @@ var An = (e) => {
|
|
|
3083
3121
|
}
|
|
3084
3122
|
} };
|
|
3085
3123
|
}),
|
|
3124
|
+
applyMarkers: (t) => e((e) => {
|
|
3125
|
+
if (!t.length) return {};
|
|
3126
|
+
let n = { ...e.conversations };
|
|
3127
|
+
for (let e of t) {
|
|
3128
|
+
let t = n[e.peer];
|
|
3129
|
+
if (!t || t.kind !== "chat") continue;
|
|
3130
|
+
let r = t.messages.find((t) => t.mine !== e.mine && (t.oid === e.id || t.id === e.id))?.ts ?? e.ts;
|
|
3131
|
+
if (e.mine) {
|
|
3132
|
+
e.kind === "displayed" && (n[e.peer] = {
|
|
3133
|
+
...t,
|
|
3134
|
+
myRead: Math.max(t.myRead ?? 0, r),
|
|
3135
|
+
unread: 0
|
|
3136
|
+
});
|
|
3137
|
+
continue;
|
|
3138
|
+
}
|
|
3139
|
+
let i = Math.max(t.delivered ?? 0, r);
|
|
3140
|
+
n[e.peer] = e.kind === "displayed" ? {
|
|
3141
|
+
...t,
|
|
3142
|
+
delivered: i,
|
|
3143
|
+
read: Math.max(t.read ?? 0, r)
|
|
3144
|
+
} : {
|
|
3145
|
+
...t,
|
|
3146
|
+
delivered: i
|
|
3147
|
+
};
|
|
3148
|
+
}
|
|
3149
|
+
return { conversations: n };
|
|
3150
|
+
}),
|
|
3086
3151
|
applyReactions: (t) => e((e) => {
|
|
3087
3152
|
if (!t.length) return {};
|
|
3088
3153
|
let n = { ...e.conversations };
|
|
@@ -3525,7 +3590,7 @@ var $ = {
|
|
|
3525
3590
|
//#endregion
|
|
3526
3591
|
//#region src/components/Dock.tsx
|
|
3527
3592
|
function Zn({ onDragStart: e, pushButton: t = !0 }) {
|
|
3528
|
-
let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y } = Y(w((e) => ({
|
|
3593
|
+
let { order: n, open: r, conversations: i, contacts: a, inactive: o, online: s, mobile: c, openChat: l, removeHead: p, picker: m, setPicker: h, status: g, push: _, enablePush: v, newChatButton: y, maxHeads: b } = Y(w((e) => ({
|
|
3529
3594
|
order: e.order,
|
|
3530
3595
|
open: e.open,
|
|
3531
3596
|
conversations: e.conversations,
|
|
@@ -3540,13 +3605,14 @@ function Zn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3540
3605
|
status: e.status,
|
|
3541
3606
|
push: e.push,
|
|
3542
3607
|
enablePush: e.enablePush,
|
|
3543
|
-
newChatButton: e.newChatButton
|
|
3608
|
+
newChatButton: e.newChatButton,
|
|
3609
|
+
maxHeads: e.maxHeads
|
|
3544
3610
|
})));
|
|
3545
3611
|
return /* @__PURE__ */ f("div", {
|
|
3546
3612
|
className: `ci-flex ci-flex-col-reverse ci-items-center ci-gap-3 ci-mb-3 ${e ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
3547
3613
|
onPointerDown: e,
|
|
3548
3614
|
children: [
|
|
3549
|
-
n.map((e) => {
|
|
3615
|
+
n.slice(0, b).map((e) => {
|
|
3550
3616
|
let t = i[e], n = r === e;
|
|
3551
3617
|
return /* @__PURE__ */ f("div", {
|
|
3552
3618
|
className: "ci-relative ci-group",
|
|
@@ -3580,6 +3646,7 @@ function Zn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3580
3646
|
})]
|
|
3581
3647
|
}, e);
|
|
3582
3648
|
}),
|
|
3649
|
+
n.length > b && /* @__PURE__ */ d(Qn, { peers: n.slice(b) }),
|
|
3583
3650
|
y && /* @__PURE__ */ f(Q, {
|
|
3584
3651
|
variant: "default",
|
|
3585
3652
|
title: g === "online" ? "New chat" : `Chat ${g}`,
|
|
@@ -3597,9 +3664,96 @@ function Zn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3597
3664
|
]
|
|
3598
3665
|
});
|
|
3599
3666
|
}
|
|
3667
|
+
function Qn({ peers: e }) {
|
|
3668
|
+
let { conversations: t, contacts: n, inactive: r, online: a, mobile: o, openChat: l, removeHead: p } = Y(w((e) => ({
|
|
3669
|
+
conversations: e.conversations,
|
|
3670
|
+
contacts: e.contacts,
|
|
3671
|
+
inactive: e.inactive,
|
|
3672
|
+
online: e.online,
|
|
3673
|
+
mobile: e.mobile,
|
|
3674
|
+
openChat: e.openChat,
|
|
3675
|
+
removeHead: e.removeHead
|
|
3676
|
+
}))), [m, h] = c(!1), g = s(null), _ = e.reduce((e, n) => e + (t[n]?.unread ?? 0), 0), v = (e) => t[e]?.kind === "group" ? t[e]?.name ?? e : n[e]?.name ?? r[e] ?? e;
|
|
3677
|
+
return i(() => {
|
|
3678
|
+
if (!m) return;
|
|
3679
|
+
let e = (e) => g.current && !g.current.contains(e.target) && h(!1), t = (e) => e.key === "Escape" && h(!1);
|
|
3680
|
+
return document.addEventListener("pointerdown", e, !0), document.addEventListener("keydown", t, !0), () => {
|
|
3681
|
+
document.removeEventListener("pointerdown", e, !0), document.removeEventListener("keydown", t, !0);
|
|
3682
|
+
};
|
|
3683
|
+
}, [m]), /* @__PURE__ */ f("div", {
|
|
3684
|
+
ref: g,
|
|
3685
|
+
className: "ci-relative",
|
|
3686
|
+
children: [/* @__PURE__ */ f(Q, {
|
|
3687
|
+
variant: "default",
|
|
3688
|
+
title: `${e.length} more chats`,
|
|
3689
|
+
"aria-expanded": m,
|
|
3690
|
+
onClick: () => h((e) => !e),
|
|
3691
|
+
className: "ci-relative ci-shadow-lg ci-font-medium ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950",
|
|
3692
|
+
children: [
|
|
3693
|
+
"+",
|
|
3694
|
+
e.length,
|
|
3695
|
+
_ > 0 && /* @__PURE__ */ d("span", {
|
|
3696
|
+
className: "ci-absolute ci--top-1 ci--right-1 ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center",
|
|
3697
|
+
children: _ > 99 ? "99+" : _
|
|
3698
|
+
})
|
|
3699
|
+
]
|
|
3700
|
+
}), m && /* @__PURE__ */ d("div", {
|
|
3701
|
+
role: "menu",
|
|
3702
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
3703
|
+
className: "ci-anim-drop ci-absolute ci-right-full ci-mr-3 ci-top-0 ci-z-30 ci-w-64 ci-max-h-80 ci-overflow-y-auto ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-text-gray-900 dark:ci-text-white ci-text-sm ci-cursor-default",
|
|
3704
|
+
children: e.map((e) => {
|
|
3705
|
+
let r = t[e];
|
|
3706
|
+
return /* @__PURE__ */ f("div", {
|
|
3707
|
+
className: "ci-group ci-flex ci-items-center ci-pr-2 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-700",
|
|
3708
|
+
children: [/* @__PURE__ */ f("button", {
|
|
3709
|
+
type: "button",
|
|
3710
|
+
role: "menuitem",
|
|
3711
|
+
onClick: () => {
|
|
3712
|
+
h(!1), l(e);
|
|
3713
|
+
},
|
|
3714
|
+
className: "ci-flex-1 ci-min-w-0 ci-flex ci-items-center ci-gap-3 ci-px-3 ci-py-2 ci-border-0 ci-bg-transparent ci-text-left ci-text-inherit",
|
|
3715
|
+
children: [
|
|
3716
|
+
/* @__PURE__ */ d("span", {
|
|
3717
|
+
className: "ci-relative",
|
|
3718
|
+
children: r?.kind === "group" ? /* @__PURE__ */ d(Jn, {
|
|
3719
|
+
name: v(e),
|
|
3720
|
+
size: 32,
|
|
3721
|
+
avatar: r.avatar
|
|
3722
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Kn, {
|
|
3723
|
+
contact: n[e],
|
|
3724
|
+
username: e,
|
|
3725
|
+
size: 32
|
|
3726
|
+
}), /* @__PURE__ */ d(qn, {
|
|
3727
|
+
online: a[e],
|
|
3728
|
+
presence: n[e]?.presence,
|
|
3729
|
+
mobile: o[e]
|
|
3730
|
+
})] })
|
|
3731
|
+
}),
|
|
3732
|
+
/* @__PURE__ */ d("span", {
|
|
3733
|
+
className: "ci-flex-1 ci-truncate",
|
|
3734
|
+
children: v(e)
|
|
3735
|
+
}),
|
|
3736
|
+
(r?.unread ?? 0) > 0 && /* @__PURE__ */ d("span", {
|
|
3737
|
+
className: "ci-min-w-5 ci-h-5 ci-px-1 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-text-white dark:ci-text-gray-950 ci-text-xs ci-font-medium ci-flex ci-items-center ci-justify-center",
|
|
3738
|
+
children: r.unread > 99 ? "99+" : r.unread
|
|
3739
|
+
})
|
|
3740
|
+
]
|
|
3741
|
+
}), /* @__PURE__ */ d(Q, {
|
|
3742
|
+
variant: "small",
|
|
3743
|
+
"aria-label": `Remove ${v(e)} from the dock`,
|
|
3744
|
+
title: "Remove from the dock",
|
|
3745
|
+
onClick: () => p(e),
|
|
3746
|
+
className: "ci-opacity-0 group-hover:ci-opacity-100 focus:ci-opacity-100",
|
|
3747
|
+
children: $.close
|
|
3748
|
+
})]
|
|
3749
|
+
}, e);
|
|
3750
|
+
})
|
|
3751
|
+
})]
|
|
3752
|
+
});
|
|
3753
|
+
}
|
|
3600
3754
|
//#endregion
|
|
3601
3755
|
//#region src/shortcodes.ts
|
|
3602
|
-
var
|
|
3756
|
+
var $n = {
|
|
3603
3757
|
"+1": "👍",
|
|
3604
3758
|
thumbsup: "👍",
|
|
3605
3759
|
"-1": "👎",
|
|
@@ -3793,13 +3947,13 @@ var Qn = {
|
|
|
3793
3947
|
zzz: "💤",
|
|
3794
3948
|
sweat_drops: "💦",
|
|
3795
3949
|
dash: "💨"
|
|
3796
|
-
},
|
|
3797
|
-
function
|
|
3798
|
-
return e.includes(":") ? e.split(
|
|
3950
|
+
}, er = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, tr = /:([a-z0-9_+-]+):/g, nr = (e) => e.replace(tr, (e, t) => $n[t] ?? e);
|
|
3951
|
+
function rr(e) {
|
|
3952
|
+
return e.includes(":") ? e.split(er).map((e, t) => t % 2 ? e : nr(e)).join("") : e;
|
|
3799
3953
|
}
|
|
3800
3954
|
//#endregion
|
|
3801
3955
|
//#region src/components/EmojiPicker.tsx
|
|
3802
|
-
var
|
|
3956
|
+
var ir = [
|
|
3803
3957
|
{
|
|
3804
3958
|
label: "Smileys",
|
|
3805
3959
|
icon: "😀",
|
|
@@ -3830,7 +3984,7 @@ var rr = [
|
|
|
3830
3984
|
icon: "☕",
|
|
3831
3985
|
emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
|
|
3832
3986
|
}
|
|
3833
|
-
],
|
|
3987
|
+
], ar = [
|
|
3834
3988
|
"👍",
|
|
3835
3989
|
"❤️",
|
|
3836
3990
|
"😂",
|
|
@@ -3838,7 +3992,7 @@ var rr = [
|
|
|
3838
3992
|
"😢",
|
|
3839
3993
|
"🙏"
|
|
3840
3994
|
];
|
|
3841
|
-
function
|
|
3995
|
+
function or({ onPick: e, onClose: t, className: n = "" }) {
|
|
3842
3996
|
let [r, a] = c(0), o = s(null);
|
|
3843
3997
|
return i(() => {
|
|
3844
3998
|
let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
|
|
@@ -3851,10 +4005,10 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3851
4005
|
ref: o,
|
|
3852
4006
|
role: "dialog",
|
|
3853
4007
|
"aria-label": "Emoji",
|
|
3854
|
-
className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-
|
|
4008
|
+
className: `ci-z-30 ci-w-[21rem] ci-max-w-full ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-select-none ${n}`,
|
|
3855
4009
|
children: [/* @__PURE__ */ d("div", {
|
|
3856
4010
|
className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
|
|
3857
|
-
children:
|
|
4011
|
+
children: ir.map((e, t) => /* @__PURE__ */ d("button", {
|
|
3858
4012
|
type: "button",
|
|
3859
4013
|
title: e.label,
|
|
3860
4014
|
"aria-label": e.label,
|
|
@@ -3868,7 +4022,7 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3868
4022
|
}, e.label))
|
|
3869
4023
|
}), /* @__PURE__ */ d("div", {
|
|
3870
4024
|
className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
|
|
3871
|
-
children:
|
|
4025
|
+
children: ir[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
|
|
3872
4026
|
type: "button",
|
|
3873
4027
|
onClick: () => e(t),
|
|
3874
4028
|
style: {
|
|
@@ -3883,27 +4037,27 @@ function ar({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3883
4037
|
}
|
|
3884
4038
|
//#endregion
|
|
3885
4039
|
//#region src/components/MessageList.tsx
|
|
3886
|
-
var
|
|
4040
|
+
var sr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), cr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), lr = (e) => {
|
|
3887
4041
|
let t = e.split("/").pop() || "file";
|
|
3888
4042
|
try {
|
|
3889
4043
|
return decodeURIComponent(t);
|
|
3890
4044
|
} catch {
|
|
3891
4045
|
return t;
|
|
3892
4046
|
}
|
|
3893
|
-
},
|
|
4047
|
+
}, ur = (e) => {
|
|
3894
4048
|
try {
|
|
3895
4049
|
return new URL(e).protocol === "https:";
|
|
3896
4050
|
} catch {
|
|
3897
4051
|
return !1;
|
|
3898
4052
|
}
|
|
3899
|
-
},
|
|
4053
|
+
}, dr = (e) => new Date(e).toLocaleTimeString([], {
|
|
3900
4054
|
hour: "2-digit",
|
|
3901
4055
|
minute: "2-digit"
|
|
3902
|
-
}),
|
|
4056
|
+
}), fr = (e) => new Date(e).toLocaleDateString([], {
|
|
3903
4057
|
weekday: "short",
|
|
3904
4058
|
day: "numeric",
|
|
3905
4059
|
month: "short"
|
|
3906
|
-
}),
|
|
4060
|
+
}), pr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), mr = (e) => {
|
|
3907
4061
|
if (!e.startsWith("{\"")) return null;
|
|
3908
4062
|
try {
|
|
3909
4063
|
let t = JSON.parse(e);
|
|
@@ -3914,17 +4068,17 @@ var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\
|
|
|
3914
4068
|
} catch {
|
|
3915
4069
|
return null;
|
|
3916
4070
|
}
|
|
3917
|
-
},
|
|
3918
|
-
return
|
|
4071
|
+
}, hr = n(function({ url: e }) {
|
|
4072
|
+
return ur(e) ? sr(e) ? /* @__PURE__ */ d("a", {
|
|
3919
4073
|
href: e,
|
|
3920
4074
|
target: "_blank",
|
|
3921
4075
|
rel: "noreferrer",
|
|
3922
4076
|
children: /* @__PURE__ */ d("img", {
|
|
3923
4077
|
src: e,
|
|
3924
|
-
alt:
|
|
4078
|
+
alt: lr(e),
|
|
3925
4079
|
className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
|
|
3926
4080
|
})
|
|
3927
|
-
}) :
|
|
4081
|
+
}) : cr(e) ? /* @__PURE__ */ d("audio", {
|
|
3928
4082
|
controls: !0,
|
|
3929
4083
|
src: e,
|
|
3930
4084
|
className: "ci-max-w-full"
|
|
@@ -3941,17 +4095,17 @@ var or = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), sr = (e) => /\
|
|
|
3941
4095
|
stroke: "currentColor",
|
|
3942
4096
|
strokeWidth: "2",
|
|
3943
4097
|
children: /* @__PURE__ */ d("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
|
|
3944
|
-
}),
|
|
4098
|
+
}), lr(e)]
|
|
3945
4099
|
}) : /* @__PURE__ */ d("span", {
|
|
3946
4100
|
className: "ci-break-all",
|
|
3947
4101
|
children: e
|
|
3948
4102
|
});
|
|
3949
|
-
}),
|
|
3950
|
-
function
|
|
4103
|
+
}), gr = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
|
|
4104
|
+
function _r({ text: e }) {
|
|
3951
4105
|
let t = [], n = 0;
|
|
3952
|
-
for (let r of e.matchAll(
|
|
4106
|
+
for (let r of e.matchAll(gr)) {
|
|
3953
4107
|
let i = r[0], a = r.index ?? 0;
|
|
3954
|
-
a > n && t.push(
|
|
4108
|
+
a > n && t.push(rr(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
|
|
3955
4109
|
className: "ci-px-1 ci-py-0.5 ci-rounded ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-[0.85em]",
|
|
3956
4110
|
children: i.slice(1, -1)
|
|
3957
4111
|
}, a)) : r[2] ? t.push(/* @__PURE__ */ d("strong", { children: i.slice(2, -2) }, a)) : r[3] ? t.push(/* @__PURE__ */ d("s", { children: i.slice(2, -2) }, a)) : r[4] ? t.push(/* @__PURE__ */ d("em", { children: i.slice(1, -1) }, a)) : r[5] ? t.push(/* @__PURE__ */ d("a", {
|
|
@@ -3968,19 +4122,19 @@ function gr({ text: e }) {
|
|
|
3968
4122
|
children: i
|
|
3969
4123
|
}, a)), n = a + i.length;
|
|
3970
4124
|
}
|
|
3971
|
-
return n < e.length && t.push(
|
|
4125
|
+
return n < e.length && t.push(rr(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
|
|
3972
4126
|
}
|
|
3973
|
-
var
|
|
4127
|
+
var vr = n(function({ text: e }) {
|
|
3974
4128
|
let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
|
|
3975
4129
|
return /* @__PURE__ */ d("span", {
|
|
3976
4130
|
className: "ci-whitespace-pre-wrap ci-break-words",
|
|
3977
4131
|
children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
|
|
3978
4132
|
className: "ci-my-1 ci-p-2 ci-rounded-xl ci-bg-black/10 dark:ci-bg-white/10 ci-font-mono ci-text-xs ci-overflow-x-auto ci-whitespace-pre",
|
|
3979
4133
|
children: e.replace(/\n$/, "")
|
|
3980
|
-
}, t) : /* @__PURE__ */ d(
|
|
4134
|
+
}, t) : /* @__PURE__ */ d(_r, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
|
|
3981
4135
|
});
|
|
3982
4136
|
});
|
|
3983
|
-
function
|
|
4137
|
+
function yr({ text: e, count: t }) {
|
|
3984
4138
|
return /* @__PURE__ */ f("span", {
|
|
3985
4139
|
className: "ci-italic ci-opacity-80",
|
|
3986
4140
|
children: [
|
|
@@ -3993,7 +4147,7 @@ function vr({ text: e, count: t }) {
|
|
|
3993
4147
|
]
|
|
3994
4148
|
});
|
|
3995
4149
|
}
|
|
3996
|
-
function
|
|
4150
|
+
function br({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
3997
4151
|
if (!e) return null;
|
|
3998
4152
|
let a = /* @__PURE__ */ new Map();
|
|
3999
4153
|
for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
|
|
@@ -4018,7 +4172,7 @@ function yr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
|
4018
4172
|
})
|
|
4019
4173
|
}) : null;
|
|
4020
4174
|
}
|
|
4021
|
-
function
|
|
4175
|
+
function xr({ reply: e, messages: t, mine: n, name: r }) {
|
|
4022
4176
|
let i = t.find((t) => t.oid === e.id), a = i ? i.oob ? "Attachment" : i.body : e.quote?.replace(/^[^:]*: /, "") ?? "", o = (t) => {
|
|
4023
4177
|
t.stopPropagation();
|
|
4024
4178
|
let n = document.querySelector(`.chat-island-root [data-oid="${CSS.escape(e.id)}"]`);
|
|
@@ -4042,33 +4196,33 @@ function br({ reply: e, messages: t, mine: n, name: r }) {
|
|
|
4042
4196
|
})]
|
|
4043
4197
|
});
|
|
4044
4198
|
}
|
|
4045
|
-
function
|
|
4046
|
-
let
|
|
4199
|
+
function Sr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, delivered: l = 0, read: u = 0, me: p = "", onReact: m, onReply: h }) {
|
|
4200
|
+
let g = Y((e) => e.contacts), _ = s(null), v = s(!0), [y, b] = c(null), [x, S] = c(null), C = (e) => g[e]?.name ?? e;
|
|
4047
4201
|
i(() => {
|
|
4048
|
-
let e =
|
|
4049
|
-
e &&
|
|
4202
|
+
let e = _.current;
|
|
4203
|
+
e && v.current && (e.scrollTop = e.scrollHeight);
|
|
4050
4204
|
}, [
|
|
4051
4205
|
e.length,
|
|
4052
4206
|
t,
|
|
4053
4207
|
o
|
|
4054
4208
|
]), i(() => {
|
|
4055
|
-
if (!
|
|
4056
|
-
let e = () =>
|
|
4209
|
+
if (!y) return;
|
|
4210
|
+
let e = () => b(null), t = window.setTimeout(() => document.addEventListener("click", e, { once: !0 }), 0);
|
|
4057
4211
|
return () => {
|
|
4058
4212
|
window.clearTimeout(t), document.removeEventListener("click", e);
|
|
4059
4213
|
};
|
|
4060
|
-
}, [
|
|
4061
|
-
let
|
|
4062
|
-
let e =
|
|
4063
|
-
e && (
|
|
4064
|
-
},
|
|
4065
|
-
|
|
4214
|
+
}, [y]);
|
|
4215
|
+
let w = () => {
|
|
4216
|
+
let e = _.current;
|
|
4217
|
+
e && (v.current = e.scrollHeight - e.scrollTop - e.clientHeight < 40, e.scrollTop < 30 && r && n());
|
|
4218
|
+
}, T = (e, t) => {
|
|
4219
|
+
b(null), S(null), m?.(e, t);
|
|
4066
4220
|
};
|
|
4067
4221
|
return /* @__PURE__ */ f("div", {
|
|
4068
4222
|
className: "ci-relative ci-flex-1 ci-min-h-0 ci-flex ci-flex-col",
|
|
4069
4223
|
children: [/* @__PURE__ */ f("div", {
|
|
4070
|
-
ref:
|
|
4071
|
-
onScroll:
|
|
4224
|
+
ref: _,
|
|
4225
|
+
onScroll: w,
|
|
4072
4226
|
className: "ci-flex-1 ci-overflow-y-auto ci-px-4 ci-py-2 ci-space-y-1",
|
|
4073
4227
|
children: [
|
|
4074
4228
|
r && /* @__PURE__ */ d("div", {
|
|
@@ -4076,21 +4230,21 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4076
4230
|
children: "Scroll up for older messages"
|
|
4077
4231
|
}),
|
|
4078
4232
|
e.map((t, n) => {
|
|
4079
|
-
let r = e[n - 1], i = !r || !
|
|
4233
|
+
let r = e[n - 1], i = !r || !pr(r.ts, t.ts), s = r && !i && r.mine === t.mine && r.nick === t.nick && t.ts - r.ts < 12e4, c = a && !t.mine && t.nick ? C(t.nick) : null, _ = t.oid, v = !!m && !!_ && !t.pending, x = v && /* @__PURE__ */ d("button", {
|
|
4080
4234
|
type: "button",
|
|
4081
4235
|
title: "React",
|
|
4082
4236
|
"aria-label": "React to this message",
|
|
4083
4237
|
onClick: (e) => {
|
|
4084
|
-
e.stopPropagation(),
|
|
4238
|
+
e.stopPropagation(), b(y === _ ? null : _);
|
|
4085
4239
|
},
|
|
4086
|
-
className: `ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ${
|
|
4240
|
+
className: `ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ${y === _ ? "ci-opacity-100" : "ci-opacity-0 group-hover:ci-opacity-100"}`,
|
|
4087
4241
|
children: $.react
|
|
4088
|
-
}),
|
|
4242
|
+
}), w = !!h && !!_ && !t.pending && /* @__PURE__ */ d("button", {
|
|
4089
4243
|
type: "button",
|
|
4090
4244
|
title: "Reply",
|
|
4091
4245
|
"aria-label": "Reply to this message",
|
|
4092
4246
|
onClick: (e) => {
|
|
4093
|
-
e.stopPropagation(),
|
|
4247
|
+
e.stopPropagation(), h(t);
|
|
4094
4248
|
},
|
|
4095
4249
|
className: "ci-self-center ci-h-7 ci-w-7 ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-transparent ci-text-gray-500 dark:ci-text-gray-400 hover:ci-bg-gray-200 dark:hover:ci-bg-gray-800 focus:ci-opacity-100 ci-opacity-0 group-hover:ci-opacity-100",
|
|
4096
4250
|
children: $.reply
|
|
@@ -4099,7 +4253,7 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4099
4253
|
"data-oid": t.oid,
|
|
4100
4254
|
children: [i && /* @__PURE__ */ d("div", {
|
|
4101
4255
|
className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
|
|
4102
|
-
children:
|
|
4256
|
+
children: fr(t.ts)
|
|
4103
4257
|
}), /* @__PURE__ */ f("div", {
|
|
4104
4258
|
className: `ci-group ci-flex ci-items-start ci-gap-1.5 ${t.mine ? "ci-justify-end" : "ci-justify-start"} ${s ? "ci-mt-0.5" : "ci-mt-2"}`,
|
|
4105
4259
|
children: [
|
|
@@ -4107,30 +4261,30 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4107
4261
|
className: "ci-w-7 ci-shrink-0",
|
|
4108
4262
|
title: c,
|
|
4109
4263
|
children: !s && /* @__PURE__ */ d(Kn, {
|
|
4110
|
-
contact:
|
|
4264
|
+
contact: g[t.nick],
|
|
4111
4265
|
username: t.nick,
|
|
4112
4266
|
size: 28
|
|
4113
4267
|
})
|
|
4114
4268
|
}),
|
|
4115
|
-
t.mine &&
|
|
4116
|
-
t.mine &&
|
|
4269
|
+
t.mine && w,
|
|
4270
|
+
t.mine && x,
|
|
4117
4271
|
/* @__PURE__ */ f("div", {
|
|
4118
4272
|
className: `ci-relative ci-flex ci-flex-col ci-max-w-[80%] ${t.mine ? "ci-items-end" : "ci-items-start"}`,
|
|
4119
4273
|
children: [
|
|
4120
|
-
|
|
4274
|
+
y === _ && _ && /* @__PURE__ */ f("div", {
|
|
4121
4275
|
role: "menu",
|
|
4122
4276
|
onClick: (e) => e.stopPropagation(),
|
|
4123
|
-
className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-
|
|
4124
|
-
children: [
|
|
4277
|
+
className: `ci-absolute ci-bottom-full ci-mb-1 ci-z-20 ci-flex ci-items-center ci-gap-0.5 ci-p-1 ci-rounded-full ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
|
|
4278
|
+
children: [ar.map((e) => /* @__PURE__ */ d("button", {
|
|
4125
4279
|
type: "button",
|
|
4126
4280
|
role: "menuitem",
|
|
4127
4281
|
"aria-label": e,
|
|
4128
|
-
onClick: () =>
|
|
4282
|
+
onClick: () => T(_, e),
|
|
4129
4283
|
style: {
|
|
4130
4284
|
fontSize: 22,
|
|
4131
4285
|
lineHeight: "32px"
|
|
4132
4286
|
},
|
|
4133
|
-
className: `ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${o?.[
|
|
4287
|
+
className: `ci-h-9 ci-w-9 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 hover:ci-scale-125 ci-transition-transform ${o?.[_]?.[p]?.includes(e) ? "ci-bg-gray-200 dark:ci-bg-gray-800" : "ci-bg-transparent"}`,
|
|
4134
4288
|
children: e
|
|
4135
4289
|
}, e)), /* @__PURE__ */ d("button", {
|
|
4136
4290
|
type: "button",
|
|
@@ -4138,45 +4292,48 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4138
4292
|
title: "More emojis",
|
|
4139
4293
|
"aria-label": "More emojis",
|
|
4140
4294
|
onClick: () => {
|
|
4141
|
-
|
|
4295
|
+
b(null), S(_);
|
|
4142
4296
|
},
|
|
4143
4297
|
className: "ci-h-8 ci-w-8 ci-flex ci-items-center ci-justify-center ci-rounded-full ci-border-0 ci-bg-gray-200 dark:ci-bg-gray-800 ci-text-gray-700 dark:ci-text-gray-200 ci-text-lg",
|
|
4144
4298
|
children: "+"
|
|
4145
4299
|
})]
|
|
4146
4300
|
}),
|
|
4147
4301
|
/* @__PURE__ */ f("div", {
|
|
4148
|
-
title:
|
|
4149
|
-
onDoubleClick: () =>
|
|
4302
|
+
title: dr(t.ts),
|
|
4303
|
+
onDoubleClick: () => v && T(_, ar[0]),
|
|
4150
4304
|
className: `ci-px-3.5 ci-py-2 ci-rounded-3xl ci-text-sm ci-select-text ci-cursor-text ${t.mine ? "ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900 ci-rounded-br-lg" : "ci-bg-elevationL2 ci-text-gray-900 dark:ci-bg-elevationL2Dark dark:ci-text-white ci-rounded-bl-lg"} ${t.pending ? "ci-opacity-60" : ""}`,
|
|
4151
4305
|
children: [
|
|
4152
|
-
t.reply && /* @__PURE__ */ d(
|
|
4306
|
+
t.reply && /* @__PURE__ */ d(xr, {
|
|
4153
4307
|
reply: t.reply,
|
|
4154
4308
|
messages: e,
|
|
4155
4309
|
mine: t.mine,
|
|
4156
|
-
name: (e) => e ===
|
|
4310
|
+
name: (e) => e === p ? "You" : C(e)
|
|
4157
4311
|
}),
|
|
4158
|
-
t.oob ? /* @__PURE__ */ d(
|
|
4159
|
-
t.oob && t.body && t.body !== t.oob && t.body !==
|
|
4312
|
+
t.oob ? /* @__PURE__ */ d(hr, { url: t.oob }) : mr(t.body) ? /* @__PURE__ */ d(yr, { ...mr(t.body) }) : /* @__PURE__ */ d(vr, { text: t.body }),
|
|
4313
|
+
t.oob && t.body && t.body !== t.oob && t.body !== lr(t.oob) && /* @__PURE__ */ d("div", {
|
|
4160
4314
|
className: "ci-text-xs ci-opacity-80 ci-mt-1",
|
|
4161
4315
|
children: t.body
|
|
4162
4316
|
}),
|
|
4163
|
-
/* @__PURE__ */
|
|
4164
|
-
className: "ci-
|
|
4165
|
-
children:
|
|
4317
|
+
/* @__PURE__ */ f("span", {
|
|
4318
|
+
className: "ci-flex ci-items-center ci-justify-end ci-gap-1 ci-text-[10px] ci-leading-none ci-mt-1",
|
|
4319
|
+
children: [/* @__PURE__ */ d("span", {
|
|
4320
|
+
className: "ci-opacity-60",
|
|
4321
|
+
children: dr(t.ts)
|
|
4322
|
+
}), t.mine && !a && /* @__PURE__ */ d(wr, { state: t.pending ? "pending" : t.ts <= u ? "read" : t.ts <= l ? "delivered" : "sent" })]
|
|
4166
4323
|
})
|
|
4167
4324
|
]
|
|
4168
4325
|
}),
|
|
4169
|
-
|
|
4170
|
-
forMsg: o?.[
|
|
4171
|
-
me:
|
|
4326
|
+
_ && /* @__PURE__ */ d(br, {
|
|
4327
|
+
forMsg: o?.[_],
|
|
4328
|
+
me: p,
|
|
4172
4329
|
mine: t.mine,
|
|
4173
|
-
nameOf:
|
|
4174
|
-
onReact: (e) =>
|
|
4330
|
+
nameOf: C,
|
|
4331
|
+
onReact: (e) => v && T(_, e)
|
|
4175
4332
|
})
|
|
4176
4333
|
]
|
|
4177
4334
|
}),
|
|
4178
|
-
!t.mine &&
|
|
4179
|
-
!t.mine &&
|
|
4335
|
+
!t.mine && x,
|
|
4336
|
+
!t.mine && w
|
|
4180
4337
|
]
|
|
4181
4338
|
})]
|
|
4182
4339
|
}, t.id);
|
|
@@ -4189,16 +4346,53 @@ function xr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
4189
4346
|
})
|
|
4190
4347
|
})
|
|
4191
4348
|
]
|
|
4192
|
-
}),
|
|
4349
|
+
}), x && /* @__PURE__ */ d(or, {
|
|
4193
4350
|
className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
|
|
4194
|
-
onPick: (e) =>
|
|
4195
|
-
onClose: () =>
|
|
4351
|
+
onPick: (e) => T(x, e),
|
|
4352
|
+
onClose: () => S(null)
|
|
4196
4353
|
})]
|
|
4197
4354
|
});
|
|
4198
4355
|
}
|
|
4356
|
+
var Cr = {
|
|
4357
|
+
pending: "Sending",
|
|
4358
|
+
sent: "Sent",
|
|
4359
|
+
delivered: "Delivered",
|
|
4360
|
+
read: "Read"
|
|
4361
|
+
};
|
|
4362
|
+
function wr({ state: e }) {
|
|
4363
|
+
return /* @__PURE__ */ d("span", {
|
|
4364
|
+
title: Cr[e],
|
|
4365
|
+
"aria-label": Cr[e],
|
|
4366
|
+
className: e === "read" ? "ci-text-phoneIslandCallDark dark:ci-text-phoneIslandCall" : "ci-opacity-60",
|
|
4367
|
+
children: e === "pending" ? /* @__PURE__ */ f("svg", {
|
|
4368
|
+
width: "12",
|
|
4369
|
+
height: "12",
|
|
4370
|
+
viewBox: "0 0 24 24",
|
|
4371
|
+
fill: "none",
|
|
4372
|
+
stroke: "currentColor",
|
|
4373
|
+
strokeWidth: "2.5",
|
|
4374
|
+
strokeLinecap: "round",
|
|
4375
|
+
children: [/* @__PURE__ */ d("circle", {
|
|
4376
|
+
cx: "12",
|
|
4377
|
+
cy: "12",
|
|
4378
|
+
r: "9"
|
|
4379
|
+
}), /* @__PURE__ */ d("path", { d: "M12 7v5l3 2" })]
|
|
4380
|
+
}) : /* @__PURE__ */ f("svg", {
|
|
4381
|
+
width: "16",
|
|
4382
|
+
height: "12",
|
|
4383
|
+
viewBox: "0 0 28 16",
|
|
4384
|
+
fill: "none",
|
|
4385
|
+
stroke: "currentColor",
|
|
4386
|
+
strokeWidth: "2.5",
|
|
4387
|
+
strokeLinecap: "round",
|
|
4388
|
+
strokeLinejoin: "round",
|
|
4389
|
+
children: [/* @__PURE__ */ d("path", { d: "M2 9l4 4 9-10" }), e !== "sent" && /* @__PURE__ */ d("path", { d: "M12 12l1 1 9-10" })]
|
|
4390
|
+
})
|
|
4391
|
+
});
|
|
4392
|
+
}
|
|
4199
4393
|
//#endregion
|
|
4200
4394
|
//#region src/ogg.ts
|
|
4201
|
-
function
|
|
4395
|
+
function Tr(e, t, n) {
|
|
4202
4396
|
let r = e[t];
|
|
4203
4397
|
if (r === void 0) return null;
|
|
4204
4398
|
let i = 1;
|
|
@@ -4212,7 +4406,7 @@ function Sr(e, t, n) {
|
|
|
4212
4406
|
unknown: !n && o
|
|
4213
4407
|
};
|
|
4214
4408
|
}
|
|
4215
|
-
var
|
|
4409
|
+
var Er = /* @__PURE__ */ new Set([
|
|
4216
4410
|
408125543,
|
|
4217
4411
|
524531317,
|
|
4218
4412
|
374648427,
|
|
@@ -4220,18 +4414,18 @@ var Cr = /* @__PURE__ */ new Set([
|
|
|
4220
4414
|
225,
|
|
4221
4415
|
160
|
|
4222
4416
|
]);
|
|
4223
|
-
function
|
|
4417
|
+
function Dr(e) {
|
|
4224
4418
|
let t = {
|
|
4225
4419
|
channels: 1,
|
|
4226
4420
|
packets: []
|
|
4227
4421
|
}, n = 0;
|
|
4228
4422
|
for (; n < e.length;) {
|
|
4229
|
-
let r =
|
|
4423
|
+
let r = Tr(e, n, !0);
|
|
4230
4424
|
if (!r) break;
|
|
4231
|
-
let i =
|
|
4425
|
+
let i = Tr(e, n + r.len, !1);
|
|
4232
4426
|
if (!i) break;
|
|
4233
4427
|
let a = n + r.len + i.len;
|
|
4234
|
-
if (
|
|
4428
|
+
if (Er.has(r.value)) {
|
|
4235
4429
|
n = a;
|
|
4236
4430
|
continue;
|
|
4237
4431
|
}
|
|
@@ -4240,14 +4434,14 @@ function wr(e) {
|
|
|
4240
4434
|
if (r.value === 25506) t.head = e.slice(a, o);
|
|
4241
4435
|
else if (r.value === 159) t.channels = e[a] || 1;
|
|
4242
4436
|
else if (r.value === 163 || r.value === 161) {
|
|
4243
|
-
let n =
|
|
4437
|
+
let n = Tr(e, a, !1);
|
|
4244
4438
|
n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
|
|
4245
4439
|
}
|
|
4246
4440
|
n = o;
|
|
4247
4441
|
}
|
|
4248
4442
|
return t;
|
|
4249
4443
|
}
|
|
4250
|
-
function
|
|
4444
|
+
function Or(e) {
|
|
4251
4445
|
if (!e.length) return 0;
|
|
4252
4446
|
let t = e[0], n = t >> 3, r;
|
|
4253
4447
|
r = n < 12 ? [
|
|
@@ -4264,7 +4458,7 @@ function Tr(e) {
|
|
|
4264
4458
|
let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
|
|
4265
4459
|
return Math.round(a * r * 48);
|
|
4266
4460
|
}
|
|
4267
|
-
var
|
|
4461
|
+
var kr = (() => {
|
|
4268
4462
|
let e = /* @__PURE__ */ new Uint32Array(256);
|
|
4269
4463
|
for (let t = 0; t < 256; t++) {
|
|
4270
4464
|
let n = t << 24;
|
|
@@ -4273,12 +4467,12 @@ var Er = (() => {
|
|
|
4273
4467
|
}
|
|
4274
4468
|
return e;
|
|
4275
4469
|
})();
|
|
4276
|
-
function
|
|
4470
|
+
function Ar(e) {
|
|
4277
4471
|
let t = 0;
|
|
4278
|
-
for (let n = 0; n < e.length; n++) t = (t << 8 ^
|
|
4472
|
+
for (let n = 0; n < e.length; n++) t = (t << 8 ^ kr[(t >>> 24 ^ e[n]) & 255]) >>> 0;
|
|
4279
4473
|
return t;
|
|
4280
4474
|
}
|
|
4281
|
-
function
|
|
4475
|
+
function jr(e, t, n, r, i) {
|
|
4282
4476
|
let a = [];
|
|
4283
4477
|
for (let t of e) {
|
|
4284
4478
|
let e = t.length;
|
|
@@ -4294,29 +4488,29 @@ function Or(e, t, n, r, i) {
|
|
|
4294
4488
|
], 0), s[5] = i, c.setUint32(6, t % 4294967296, !0), c.setUint32(10, Math.floor(t / 4294967296), !0), c.setUint32(14, n, !0), c.setUint32(18, r, !0), s[26] = a.length, s.set(a, 27);
|
|
4295
4489
|
let l = 27 + a.length;
|
|
4296
4490
|
for (let t of e) s.set(t, l), l += t.length;
|
|
4297
|
-
return c.setUint32(22,
|
|
4491
|
+
return c.setUint32(22, Ar(s), !0), s;
|
|
4298
4492
|
}
|
|
4299
|
-
function
|
|
4493
|
+
function Mr(e) {
|
|
4300
4494
|
let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
|
|
4301
4495
|
return t.set(new TextEncoder().encode("OpusHead"), 0), t[8] = 1, t[9] = e, n.setUint16(10, 312, !0), n.setUint32(12, 48e3, !0), t;
|
|
4302
4496
|
}
|
|
4303
|
-
function
|
|
4497
|
+
function Nr() {
|
|
4304
4498
|
let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
|
|
4305
4499
|
return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
|
|
4306
4500
|
}
|
|
4307
|
-
function
|
|
4308
|
-
let { head: t, channels: n, packets: r } =
|
|
4501
|
+
function Pr(e) {
|
|
4502
|
+
let { head: t, channels: n, packets: r } = Dr(e);
|
|
4309
4503
|
if (!r.length) return null;
|
|
4310
|
-
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [
|
|
4504
|
+
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [jr([i ? t : Mr(n)], 0, a, 0, 2), jr([Nr()], 0, a, 1, 0)], s = 0, c = 2;
|
|
4311
4505
|
for (let e = 0; e < r.length;) {
|
|
4312
4506
|
let t = [], n = 0;
|
|
4313
4507
|
for (; e < r.length && t.length < 50;) {
|
|
4314
4508
|
let i = Math.floor(r[e].length / 255) + 1;
|
|
4315
4509
|
if (n + i > 255) break;
|
|
4316
|
-
t.push(r[e]), n += i, s +=
|
|
4510
|
+
t.push(r[e]), n += i, s += Or(r[e]), e++;
|
|
4317
4511
|
}
|
|
4318
4512
|
if (!t.length) return null;
|
|
4319
|
-
o.push(
|
|
4513
|
+
o.push(jr(t, s, a, c++, e >= r.length ? 4 : 0));
|
|
4320
4514
|
}
|
|
4321
4515
|
let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
|
|
4322
4516
|
for (let e of o) u.set(e, d), d += e.length;
|
|
@@ -4324,22 +4518,22 @@ function jr(e) {
|
|
|
4324
4518
|
}
|
|
4325
4519
|
//#endregion
|
|
4326
4520
|
//#region src/components/Composer.tsx
|
|
4327
|
-
var
|
|
4521
|
+
var Fr = [
|
|
4328
4522
|
"audio/ogg;codecs=opus",
|
|
4329
4523
|
"audio/webm;codecs=opus",
|
|
4330
4524
|
"audio/mp4",
|
|
4331
4525
|
"audio/webm"
|
|
4332
4526
|
];
|
|
4333
|
-
async function
|
|
4527
|
+
async function Ir(e, t) {
|
|
4334
4528
|
let n = Date.now();
|
|
4335
4529
|
if (/webm/.test(t) && /opus/.test(t)) try {
|
|
4336
|
-
let t =
|
|
4530
|
+
let t = Pr(new Uint8Array(await new Blob(e).arrayBuffer()));
|
|
4337
4531
|
if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
|
|
4338
4532
|
} catch {}
|
|
4339
|
-
return new File(e, `voice-${n}.${
|
|
4533
|
+
return new File(e, `voice-${n}.${Lr(t)}`, { type: t.split(";")[0] });
|
|
4340
4534
|
}
|
|
4341
|
-
var
|
|
4342
|
-
function
|
|
4535
|
+
var Lr = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", Rr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
|
|
4536
|
+
function zr({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, focusKey: l }) {
|
|
4343
4537
|
let [u, p] = c(""), [m, h] = c(!1), g = s(null), _ = s(null), v = s(null), y = s(), b = s(!1), [x, S] = c(null), [C, w] = c(0), T = s(!1), E = s(!1), D = s(!1), O = s({});
|
|
4344
4538
|
i(() => v.current?.focus(), []), i(() => () => {
|
|
4345
4539
|
D.current = !0, T.current = !0, window.clearTimeout(y.current);
|
|
@@ -4355,7 +4549,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4355
4549
|
let k = (e) => {
|
|
4356
4550
|
b.current !== e && (b.current = e, t(e));
|
|
4357
4551
|
}, A = (e) => {
|
|
4358
|
-
let t = e.includes(":") ?
|
|
4552
|
+
let t = e.includes(":") ? rr(e) : e;
|
|
4359
4553
|
t !== e && (g.current = Math.max(0, (v.current?.selectionStart ?? e.length) - (e.length - t.length))), p(t), t ? (k(!0), window.clearTimeout(y.current), y.current = window.setTimeout(() => k(!1), 4e3)) : k(!1);
|
|
4360
4554
|
};
|
|
4361
4555
|
a(() => {
|
|
@@ -4380,9 +4574,9 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4380
4574
|
t.getTracks().forEach((e) => e.stop());
|
|
4381
4575
|
return;
|
|
4382
4576
|
}
|
|
4383
|
-
let r =
|
|
4577
|
+
let r = Fr.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
|
|
4384
4578
|
i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
|
|
4385
|
-
t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length &&
|
|
4579
|
+
t.getTracks().forEach((e) => e.stop()), O.current = {}, S(null), !T.current && a.length && Ir(a, i.mimeType || r || "").then(n);
|
|
4386
4580
|
}, T.current = !1, i.start(), O.current = {
|
|
4387
4581
|
r: i,
|
|
4388
4582
|
stream: t
|
|
@@ -4411,7 +4605,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4411
4605
|
}),
|
|
4412
4606
|
/* @__PURE__ */ f("div", {
|
|
4413
4607
|
className: "ci-flex-1 ci-flex ci-items-center ci-gap-2 ci-px-4 ci-py-2.5 ci-rounded-3xl ci-bg-elevationL2 dark:ci-bg-elevationL2Dark ci-text-sm",
|
|
4414
|
-
children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ",
|
|
4608
|
+
children: [/* @__PURE__ */ d("span", { className: "ci-w-2.5 ci-h-2.5 ci-rounded-full ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark ci-animate-pulse" }), /* @__PURE__ */ f("span", { children: ["Recording ", Rr(C)] })]
|
|
4415
4609
|
}),
|
|
4416
4610
|
/* @__PURE__ */ d(Q, {
|
|
4417
4611
|
variant: "green",
|
|
@@ -4425,7 +4619,7 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4425
4619
|
}) : /* @__PURE__ */ f("div", {
|
|
4426
4620
|
className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4427
4621
|
children: [
|
|
4428
|
-
m && /* @__PURE__ */ d(
|
|
4622
|
+
m && /* @__PURE__ */ d(or, {
|
|
4429
4623
|
className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
|
|
4430
4624
|
onPick: j,
|
|
4431
4625
|
onClose: () => h(!1)
|
|
@@ -4491,14 +4685,14 @@ function Ir({ onSend: e, onTyping: t, onFile: n, disabled: r, disabledText: o, f
|
|
|
4491
4685
|
}
|
|
4492
4686
|
//#endregion
|
|
4493
4687
|
//#region src/components/ChatWindow.tsx
|
|
4494
|
-
var
|
|
4688
|
+
var Br = (e) => !!e && ![
|
|
4495
4689
|
"offline",
|
|
4496
4690
|
"dnd",
|
|
4497
4691
|
"busy",
|
|
4498
4692
|
"ringing",
|
|
4499
4693
|
"onhold"
|
|
4500
4694
|
].includes(e);
|
|
4501
|
-
function
|
|
4695
|
+
function Vr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
4502
4696
|
let { c: a, contacts: o, online: s, mobile: l, inactive: p, status: m, closeChat: h, openChat: g, markRead: _, order: v, me: y } = Y(w((t) => ({
|
|
4503
4697
|
c: t.conversations[e],
|
|
4504
4698
|
contacts: t.contacts,
|
|
@@ -4515,7 +4709,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4515
4709
|
i(() => {
|
|
4516
4710
|
a && !a.loaded && t.loadOlder(e);
|
|
4517
4711
|
}, [e, a?.loaded]), i(() => {
|
|
4518
|
-
_(e);
|
|
4712
|
+
_(e), t.seen(e);
|
|
4519
4713
|
}, [e, a?.messages.length]), i(() => {
|
|
4520
4714
|
C(!1), E(!1), O(null);
|
|
4521
4715
|
}, [e]);
|
|
@@ -4536,10 +4730,10 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4536
4730
|
role: "dialog",
|
|
4537
4731
|
"aria-label": a.kind === "group" ? a.name ?? e : x?.name ?? p[e] ?? e,
|
|
4538
4732
|
onKeyDown: P,
|
|
4539
|
-
className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
|
|
4733
|
+
className: "ci-relative ci-w-[22rem] ci-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-bg-gray-50 dark:ci-bg-gray-950 dark:ci-border dark:ci-border-solid dark:ci-border-gray-700 ci-text-gray-900 dark:ci-text-white",
|
|
4540
4734
|
children: [
|
|
4541
4735
|
/* @__PURE__ */ d("span", {
|
|
4542
|
-
className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-transition-all ci-duration-200",
|
|
4736
|
+
className: "ci-absolute ci--right-1.5 ci-w-3 ci-h-3 ci-rotate-45 ci-bg-gray-50 dark:ci-bg-gray-950 dark:ci-border-0 dark:ci-border-t dark:ci-border-r dark:ci-border-solid dark:ci-border-gray-700 ci-shadow-2xl ci-transition-all ci-duration-200",
|
|
4543
4737
|
style: { bottom: `calc(1.875rem + ${b} * 3.75rem)` },
|
|
4544
4738
|
"aria-hidden": "true"
|
|
4545
4739
|
}),
|
|
@@ -4580,7 +4774,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4580
4774
|
children: F ? "No longer active" : m === "online" ? a.kind === "group" ? M.map(j).join(", ") : a.typing ? "typing…" : s[e] ? "online" : l[e] ? "Mobile" : "offline" : m
|
|
4581
4775
|
})]
|
|
4582
4776
|
}),
|
|
4583
|
-
!F && a.kind !== "group" && x?.number &&
|
|
4777
|
+
!F && a.kind !== "group" && x?.number && Br(x.presence) && /* @__PURE__ */ d(Q, {
|
|
4584
4778
|
variant: "call",
|
|
4585
4779
|
title: `Call ${x.number}`,
|
|
4586
4780
|
"aria-label": "Call",
|
|
@@ -4608,12 +4802,12 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4608
4802
|
]
|
|
4609
4803
|
}),
|
|
4610
4804
|
/* @__PURE__ */ d("div", { className: "ci-border-t ci-border-gray-300 dark:ci-border-gray-700" }),
|
|
4611
|
-
T && /* @__PURE__ */ d(
|
|
4805
|
+
T && /* @__PURE__ */ d(Ur, {
|
|
4612
4806
|
theme: n,
|
|
4613
4807
|
onClose: () => E(!1)
|
|
4614
4808
|
}),
|
|
4615
4809
|
S && a.kind === "group" && /* @__PURE__ */ d("div", {
|
|
4616
|
-
className: "ci-anim-drop ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-
|
|
4810
|
+
className: "ci-anim-drop ci-absolute ci-left-3 ci-right-3 ci-top-16 ci-z-10 ci-max-h-64 ci-overflow-y-auto ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-p-2",
|
|
4617
4811
|
children: M.map((e) => /* @__PURE__ */ f("div", {
|
|
4618
4812
|
className: "ci-flex ci-items-center ci-gap-3 ci-px-2 ci-py-1.5 ci-text-sm",
|
|
4619
4813
|
children: [
|
|
@@ -4639,7 +4833,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4639
4833
|
"aria-label": "Chat",
|
|
4640
4834
|
onClick: () => g(e),
|
|
4641
4835
|
children: $.chat
|
|
4642
|
-
}), o[e]?.number &&
|
|
4836
|
+
}), o[e]?.number && Br(o[e]?.presence) && /* @__PURE__ */ d(Q, {
|
|
4643
4837
|
variant: "call",
|
|
4644
4838
|
title: `Call ${o[e]?.number}`,
|
|
4645
4839
|
"aria-label": "Call",
|
|
@@ -4655,13 +4849,15 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4655
4849
|
/* @__PURE__ */ f("div", {
|
|
4656
4850
|
className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
|
|
4657
4851
|
children: [
|
|
4658
|
-
/* @__PURE__ */ d(
|
|
4852
|
+
/* @__PURE__ */ d(Sr, {
|
|
4659
4853
|
messages: a.messages,
|
|
4660
4854
|
typing: a.typing,
|
|
4661
4855
|
group: a.kind === "group",
|
|
4662
4856
|
hasOlder: a.loaded && !a.complete,
|
|
4663
4857
|
onLoadOlder: () => t.loadOlder(e),
|
|
4664
4858
|
reactions: a.reactions,
|
|
4859
|
+
delivered: a.delivered,
|
|
4860
|
+
read: a.read,
|
|
4665
4861
|
me: y,
|
|
4666
4862
|
onReact: (n, r) => t.react(e, n, r),
|
|
4667
4863
|
onReply: N
|
|
@@ -4685,7 +4881,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4685
4881
|
children: $.close
|
|
4686
4882
|
})]
|
|
4687
4883
|
}),
|
|
4688
|
-
/* @__PURE__ */ d(
|
|
4884
|
+
/* @__PURE__ */ d(zr, {
|
|
4689
4885
|
focusKey: k,
|
|
4690
4886
|
disabled: m !== "online" || F,
|
|
4691
4887
|
disabledText: F ? "No longer active" : void 0,
|
|
@@ -4698,7 +4894,7 @@ function Rr({ peer: e, actions: t, theme: n, onDragStart: r }) {
|
|
|
4698
4894
|
]
|
|
4699
4895
|
});
|
|
4700
4896
|
}
|
|
4701
|
-
var
|
|
4897
|
+
var Hr = [
|
|
4702
4898
|
{
|
|
4703
4899
|
value: "light",
|
|
4704
4900
|
label: "Light",
|
|
@@ -4715,7 +4911,7 @@ var zr = [
|
|
|
4715
4911
|
icon: $.monitor
|
|
4716
4912
|
}
|
|
4717
4913
|
];
|
|
4718
|
-
function
|
|
4914
|
+
function Ur({ theme: e, onClose: t }) {
|
|
4719
4915
|
let n = s(null);
|
|
4720
4916
|
return i(() => {
|
|
4721
4917
|
let e = (e) => n.current && !n.current.contains(e.target) && !e.target.closest("[aria-label=\"Menu\"]") && t();
|
|
@@ -4723,11 +4919,11 @@ function Br({ theme: e, onClose: t }) {
|
|
|
4723
4919
|
}, [t]), /* @__PURE__ */ f("div", {
|
|
4724
4920
|
ref: n,
|
|
4725
4921
|
role: "menu",
|
|
4726
|
-
className: "ci-anim-drop ci-absolute ci-right-3 ci-top-14 ci-z-20 ci-w-44 ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-
|
|
4922
|
+
className: "ci-anim-drop ci-absolute ci-right-3 ci-top-14 ci-z-20 ci-w-44 ci-py-2 ci-rounded-2xl ci-bg-gray-50 dark:ci-bg-gray-950 ci-shadow-2xl ci-border ci-border-solid ci-border-gray-300 dark:ci-border-gray-600 ci-text-sm",
|
|
4727
4923
|
children: [/* @__PURE__ */ d("div", {
|
|
4728
4924
|
className: "ci-px-4 ci-py-1 ci-font-semibold ci-text-gray-600 dark:ci-text-gray-50",
|
|
4729
4925
|
children: "Theme"
|
|
4730
|
-
}),
|
|
4926
|
+
}), Hr.map((n) => /* @__PURE__ */ f("button", {
|
|
4731
4927
|
type: "button",
|
|
4732
4928
|
role: "menuitemradio",
|
|
4733
4929
|
"aria-checked": e === n.value,
|
|
@@ -4751,11 +4947,11 @@ function Br({ theme: e, onClose: t }) {
|
|
|
4751
4947
|
}
|
|
4752
4948
|
//#endregion
|
|
4753
4949
|
//#region src/components/NewChat.tsx
|
|
4754
|
-
async function
|
|
4950
|
+
async function Wr(e) {
|
|
4755
4951
|
let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
|
|
4756
4952
|
return r.width = r.height = 128, r.getContext("2d")?.drawImage(t, (t.width - n) / 2, (t.height - n) / 2, n, n, 0, 0, 128, 128), r.toDataURL("image/jpeg", .8);
|
|
4757
4953
|
}
|
|
4758
|
-
function
|
|
4954
|
+
function Gr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
4759
4955
|
let { contacts: r, online: i, mobile: a, setPicker: l } = Y(), [p, m] = c(""), [h, g] = c([]), [_, v] = c(""), [y, b] = c(!1), [x, S] = c(), C = s(null), w = o(() => {
|
|
4760
4956
|
let e = Object.values(r), t = p.trim().toLowerCase();
|
|
4761
4957
|
return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
|
|
@@ -4768,7 +4964,7 @@ function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4768
4964
|
}
|
|
4769
4965
|
};
|
|
4770
4966
|
return /* @__PURE__ */ f("div", {
|
|
4771
|
-
className: "ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
|
|
4967
|
+
className: "ci-w-[22rem] ci-max-h-[30rem] ci-flex ci-flex-col ci-rounded-3xl ci-shadow-2xl dark:ci-border dark:ci-border-solid dark:ci-border-gray-700 ci-overflow-hidden ci-bg-gray-50 dark:ci-bg-gray-950 ci-text-gray-900 dark:ci-text-white",
|
|
4772
4968
|
children: [
|
|
4773
4969
|
/* @__PURE__ */ f("div", {
|
|
4774
4970
|
className: `ci-px-4 ci-py-3 ci-flex ci-items-center ci-gap-2 ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
@@ -4864,7 +5060,7 @@ function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4864
5060
|
type: "file",
|
|
4865
5061
|
accept: "image/*",
|
|
4866
5062
|
hidden: !0,
|
|
4867
|
-
onChange: (e) => e.target.files?.[0] &&
|
|
5063
|
+
onChange: (e) => e.target.files?.[0] && Wr(e.target.files[0]).then(S).catch(() => {})
|
|
4868
5064
|
}),
|
|
4869
5065
|
/* @__PURE__ */ d("button", {
|
|
4870
5066
|
type: "button",
|
|
@@ -4899,22 +5095,22 @@ function Hr({ onOpen: e, onCreateGroup: t, onDragStart: n }) {
|
|
|
4899
5095
|
}
|
|
4900
5096
|
//#endregion
|
|
4901
5097
|
//#region src/theme.ts
|
|
4902
|
-
var
|
|
5098
|
+
var Kr = "chat-island-theme", qr = () => {
|
|
4903
5099
|
try {
|
|
4904
|
-
let e = localStorage.getItem(
|
|
5100
|
+
let e = localStorage.getItem(Kr);
|
|
4905
5101
|
return e === "light" || e === "dark" || e === "system" ? e : void 0;
|
|
4906
5102
|
} catch {
|
|
4907
5103
|
return;
|
|
4908
5104
|
}
|
|
4909
5105
|
};
|
|
4910
|
-
function
|
|
4911
|
-
let [t, n] = c(() => e ??
|
|
4912
|
-
return i(() => n(e ??
|
|
5106
|
+
function Jr(e) {
|
|
5107
|
+
let [t, n] = c(() => e ?? qr()), [r, a] = c(!1);
|
|
5108
|
+
return i(() => n(e ?? qr()), [e]), i(() => {
|
|
4913
5109
|
let e = (e) => {
|
|
4914
5110
|
let t = e.detail?.theme;
|
|
4915
5111
|
if (t === "light" || t === "dark" || t === "system") {
|
|
4916
5112
|
try {
|
|
4917
|
-
localStorage.setItem(
|
|
5113
|
+
localStorage.setItem(Kr, t);
|
|
4918
5114
|
} catch {}
|
|
4919
5115
|
n(t);
|
|
4920
5116
|
}
|
|
@@ -4940,7 +5136,7 @@ function Gr(e) {
|
|
|
4940
5136
|
}
|
|
4941
5137
|
//#endregion
|
|
4942
5138
|
//#region src/ChatIsland.tsx
|
|
4943
|
-
function
|
|
5139
|
+
function Yr() {
|
|
4944
5140
|
let e = Y.getState();
|
|
4945
5141
|
return Object.values(e.conversations).map((t) => {
|
|
4946
5142
|
let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
|
|
@@ -4956,7 +5152,7 @@ function Kr() {
|
|
|
4956
5152
|
unread: t.unread,
|
|
4957
5153
|
members: t.members,
|
|
4958
5154
|
last: n ? {
|
|
4959
|
-
body:
|
|
5155
|
+
body: Qr(n.body),
|
|
4960
5156
|
ts: n.ts,
|
|
4961
5157
|
mine: n.mine,
|
|
4962
5158
|
oob: n.oob,
|
|
@@ -4965,7 +5161,7 @@ function Kr() {
|
|
|
4965
5161
|
};
|
|
4966
5162
|
}).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
|
|
4967
5163
|
}
|
|
4968
|
-
var
|
|
5164
|
+
var Xr = class extends t {
|
|
4969
5165
|
state = { failed: !1 };
|
|
4970
5166
|
failures = [];
|
|
4971
5167
|
static getDerivedStateFromError() {
|
|
@@ -4983,7 +5179,7 @@ var qr = class extends t {
|
|
|
4983
5179
|
return this.state.failed ? null : this.props.children;
|
|
4984
5180
|
}
|
|
4985
5181
|
};
|
|
4986
|
-
function
|
|
5182
|
+
function Zr(e) {
|
|
4987
5183
|
try {
|
|
4988
5184
|
let [t, n, r] = atob(e).split(":");
|
|
4989
5185
|
return t && n && r ? {
|
|
@@ -4995,8 +5191,8 @@ function Jr(e) {
|
|
|
4995
5191
|
return null;
|
|
4996
5192
|
}
|
|
4997
5193
|
}
|
|
4998
|
-
var
|
|
4999
|
-
function
|
|
5194
|
+
var Qr = (e) => (mr(e) ? "Attachment" : rr(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
|
|
5195
|
+
function $r(e, t = !1) {
|
|
5000
5196
|
let [n, r] = c(e);
|
|
5001
5197
|
return i(() => {
|
|
5002
5198
|
if (e || t) return r(e);
|
|
@@ -5008,33 +5204,45 @@ function Xr(e, t = !1) {
|
|
|
5008
5204
|
(t) => !e && t.target === t.currentTarget && r(e)
|
|
5009
5205
|
];
|
|
5010
5206
|
}
|
|
5011
|
-
function
|
|
5012
|
-
let
|
|
5013
|
-
i(() => {
|
|
5014
|
-
|
|
5207
|
+
function ei({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWorker: r, maxHeads: a = 5, newChatButton: l = !0, notifications: u = "click", sound: p = !0, drag: m = !0, onDragStart: h, headless: g = !1 }) {
|
|
5208
|
+
let _ = o(() => Zr(e), [e]), [v, y] = Jr(n), b = s(_), x = s(p), S = s(u), C = s(g);
|
|
5209
|
+
C.current = g, i(() => {
|
|
5210
|
+
b.current = _, x.current = p, S.current = u;
|
|
5015
5211
|
}, [
|
|
5016
|
-
|
|
5212
|
+
_,
|
|
5017
5213
|
p,
|
|
5018
5214
|
u
|
|
5019
5215
|
]), i(() => Y.setState({
|
|
5020
5216
|
maxHeads: a,
|
|
5021
5217
|
newChatButton: l
|
|
5022
5218
|
}), [a, l]);
|
|
5023
|
-
let [
|
|
5219
|
+
let [T, D] = c(0);
|
|
5024
5220
|
i(() => {
|
|
5025
|
-
let e = (e) => e.persisted &&
|
|
5221
|
+
let e = (e) => e.persisted && D((e) => e + 1);
|
|
5026
5222
|
return window.addEventListener("pageshow", e), () => window.removeEventListener("pageshow", e);
|
|
5027
5223
|
}, []);
|
|
5028
|
-
let
|
|
5224
|
+
let O = s(null), k = s(/* @__PURE__ */ new Set()), A = s(!1), j = s(null), M = s(null), N = E(M, `chat-island-pos:${_?.host ?? ""}:${_?.username ?? ""}`), { open: P, picker: F, status: ee } = Y(w((e) => ({
|
|
5029
5225
|
open: e.open,
|
|
5030
5226
|
picker: e.picker,
|
|
5031
5227
|
status: e.status
|
|
5032
|
-
}))),
|
|
5228
|
+
}))), I = o(() => ({
|
|
5229
|
+
seen: (e) => {
|
|
5230
|
+
let t = Y.getState().conversations[e];
|
|
5231
|
+
if (C.current || document.visibilityState !== "visible" || t?.kind !== "chat") return;
|
|
5232
|
+
let n = t.messages.findLast((e) => !e.mine && e.oid);
|
|
5233
|
+
!n || n.ts <= (t.myRead ?? 0) || (Y.setState((t) => ({ conversations: {
|
|
5234
|
+
...t.conversations,
|
|
5235
|
+
[e]: {
|
|
5236
|
+
...t.conversations[e],
|
|
5237
|
+
myRead: n.ts
|
|
5238
|
+
}
|
|
5239
|
+
} })), O.current?.marker(e, "displayed", n.oid).catch(() => {}));
|
|
5240
|
+
},
|
|
5033
5241
|
send: async (e, t, n) => {
|
|
5034
|
-
let r =
|
|
5242
|
+
let r = O.current;
|
|
5035
5243
|
if (!r) throw Error("not connected");
|
|
5036
5244
|
try {
|
|
5037
|
-
Y.getState().addMessage(e, await r.send(e,
|
|
5245
|
+
Y.getState().addMessage(e, await r.send(e, rr(t), void 0, n));
|
|
5038
5246
|
} catch (e) {
|
|
5039
5247
|
throw X("chat-island-error", {
|
|
5040
5248
|
scope: "send",
|
|
@@ -5042,9 +5250,9 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5042
5250
|
}), e;
|
|
5043
5251
|
}
|
|
5044
5252
|
},
|
|
5045
|
-
typing: (e, t) => Y.getState().online[e] &&
|
|
5253
|
+
typing: (e, t) => Y.getState().online[e] && O.current?.typing(e, t).catch(() => {}),
|
|
5046
5254
|
upload: async (e, t) => {
|
|
5047
|
-
let n =
|
|
5255
|
+
let n = O.current;
|
|
5048
5256
|
if (n) try {
|
|
5049
5257
|
let r = await n.upload(t);
|
|
5050
5258
|
Y.getState().addMessage(e, await n.send(e, t.name, r));
|
|
@@ -5056,7 +5264,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5056
5264
|
}
|
|
5057
5265
|
},
|
|
5058
5266
|
createGroup: async (e, t, n) => {
|
|
5059
|
-
let r =
|
|
5267
|
+
let r = O.current, i = b.current;
|
|
5060
5268
|
if (r && i) try {
|
|
5061
5269
|
let a = await r.createGroup(e, t, n), o = Y.getState();
|
|
5062
5270
|
o.setGroup(a, e, [...t, i.username], n), o.openChat(a);
|
|
@@ -5068,7 +5276,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5068
5276
|
}
|
|
5069
5277
|
},
|
|
5070
5278
|
remove: async (e) => {
|
|
5071
|
-
let t =
|
|
5279
|
+
let t = O.current, n = b.current;
|
|
5072
5280
|
if (!t || !n) return;
|
|
5073
5281
|
let r = Y.getState().conversations[e];
|
|
5074
5282
|
try {
|
|
@@ -5081,7 +5289,7 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5081
5289
|
}
|
|
5082
5290
|
},
|
|
5083
5291
|
react: async (e, t, n) => {
|
|
5084
|
-
let r =
|
|
5292
|
+
let r = O.current, i = b.current?.username;
|
|
5085
5293
|
if (!r || !i) return;
|
|
5086
5294
|
let a = (Y.getState().conversations[e]?.reactions?.[t]?.[i] ?? []).includes(n) ? [] : [n];
|
|
5087
5295
|
try {
|
|
@@ -5099,47 +5307,48 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5099
5307
|
}
|
|
5100
5308
|
},
|
|
5101
5309
|
loadOlder: async (e) => {
|
|
5102
|
-
let t =
|
|
5103
|
-
if (!(!t || n.complete ||
|
|
5104
|
-
|
|
5310
|
+
let t = O.current, n = Y.getState().ensure(e);
|
|
5311
|
+
if (!(!t || n.complete || k.current.has(e))) {
|
|
5312
|
+
k.current.add(e);
|
|
5105
5313
|
try {
|
|
5106
5314
|
let r = await t.history(e, n.oldest);
|
|
5107
|
-
Y.getState().prependHistory(e, r.messages, r.complete, r.first), Y.getState().applyReactions(r.reactions);
|
|
5315
|
+
Y.getState().prependHistory(e, r.messages, r.complete, r.first), Y.getState().applyReactions(r.reactions), Y.getState().applyMarkers(r.markers);
|
|
5108
5316
|
} catch (e) {
|
|
5109
5317
|
X("chat-island-error", {
|
|
5110
5318
|
scope: "history",
|
|
5111
5319
|
message: e.message
|
|
5112
5320
|
});
|
|
5113
5321
|
} finally {
|
|
5114
|
-
|
|
5322
|
+
k.current.delete(e);
|
|
5115
5323
|
}
|
|
5116
5324
|
}
|
|
5117
5325
|
}
|
|
5118
5326
|
}), []);
|
|
5119
5327
|
i(() => {
|
|
5120
|
-
if (!
|
|
5328
|
+
if (!_) return;
|
|
5121
5329
|
let e = Y.getState();
|
|
5122
5330
|
e.reset(), Y.setState({
|
|
5123
|
-
me:
|
|
5331
|
+
me: _.username,
|
|
5124
5332
|
mucHost: `conference.${hn}`,
|
|
5125
5333
|
maxHeads: a,
|
|
5126
5334
|
newChatButton: l
|
|
5127
5335
|
});
|
|
5128
|
-
let t = new _n(
|
|
5336
|
+
let t = new _n(_, {
|
|
5129
5337
|
status: (n, a) => {
|
|
5130
5338
|
if (e.setStatus(n, a), X("chat-island-status", {
|
|
5131
5339
|
status: n,
|
|
5132
5340
|
error: a
|
|
5133
|
-
}), n === "online" && r && !
|
|
5341
|
+
}), n === "online" && r && !C.current && !A.current && typeof Notification < "u") {
|
|
5134
5342
|
let e = Notification.permission;
|
|
5135
|
-
(e === "granted" ||
|
|
5343
|
+
(e === "granted" || S.current === "auto" && e === "default") && i();
|
|
5136
5344
|
}
|
|
5137
5345
|
n === "online" && t.listGroups().then((t) => t.forEach((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner))).catch(() => {}).then(() => t.recent()).then((e) => {
|
|
5138
|
-
e && (Y.getState().seed(e.messages,
|
|
5346
|
+
e && (Y.getState().seed(e.messages, _.username), Y.getState().applyReactions(e.reactions), Y.getState().applyMarkers(e.markers));
|
|
5139
5347
|
}).catch(() => {});
|
|
5140
5348
|
},
|
|
5141
5349
|
typing: (t, n) => e.setTyping(t, n),
|
|
5142
5350
|
reaction: (t) => e.applyReactions([t]),
|
|
5351
|
+
marker: (t) => e.applyMarkers([t]),
|
|
5143
5352
|
presence: (t, n) => e.setOnline(t, n),
|
|
5144
5353
|
groupDestroyed: (t) => e.removeConversation(t),
|
|
5145
5354
|
groupInvite: (n) => {
|
|
@@ -5154,13 +5363,13 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5154
5363
|
r.room && !Y.getState().conversations[r.room]?.name && t.groupInfo(r.room).then((t) => e.setGroup(t.peer, t.name, t.members, t.avatar, t.owner)).catch(() => {}), e.addMessage(i, r, { live: !0 }), X("chat-island-message", {
|
|
5155
5364
|
...r,
|
|
5156
5365
|
peer: i
|
|
5157
|
-
}), X("chat-island-unread", { total: Y.getState().totalUnread() }), r.mine
|
|
5366
|
+
}), X("chat-island-unread", { total: Y.getState().totalUnread() }), !r.mine && !r.room && r.oid && t.marker(i, "received", r.oid).catch(() => {}), !r.mine && !C.current && n(i, r);
|
|
5158
5367
|
}
|
|
5159
5368
|
}), n = (e, t) => {
|
|
5160
5369
|
let n = Y.getState(), r = document.visibilityState === "visible";
|
|
5161
5370
|
if (r && n.open === e) return;
|
|
5162
|
-
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" :
|
|
5163
|
-
|
|
5371
|
+
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? n.inactive[e] ?? e, o = t.oob ? "Attachment" : rr(t.body), s = i?.kind === "group", c = s && t.nick ? n.contacts[t.nick]?.name ?? t.nick : a, l = s && t.nick ? `${c}: ${o}` : o;
|
|
5372
|
+
x.current && Cn();
|
|
5164
5373
|
let u = s ? i?.avatar : n.contacts[e]?.avatar;
|
|
5165
5374
|
if (X("chat-island-notify", {
|
|
5166
5375
|
peer: e,
|
|
@@ -5182,18 +5391,18 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5182
5391
|
};
|
|
5183
5392
|
} catch {}
|
|
5184
5393
|
};
|
|
5185
|
-
|
|
5394
|
+
O.current = t;
|
|
5186
5395
|
let i = () => {
|
|
5187
|
-
r && !
|
|
5396
|
+
r && !A.current && (A.current = !0, Wn(_, r).then((e) => {
|
|
5188
5397
|
if (!e) {
|
|
5189
|
-
|
|
5398
|
+
A.current = !1, Y.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
|
|
5190
5399
|
return;
|
|
5191
5400
|
}
|
|
5192
5401
|
return t.enablePush(e.service, e.node).then(() => {
|
|
5193
|
-
|
|
5402
|
+
j.current = e, Y.setState({ push: "enabled" }), X("chat-island-push", { enabled: !0 });
|
|
5194
5403
|
});
|
|
5195
5404
|
}).catch((e) => {
|
|
5196
|
-
|
|
5405
|
+
A.current = !1, X("chat-island-error", {
|
|
5197
5406
|
scope: "push",
|
|
5198
5407
|
message: e.message
|
|
5199
5408
|
});
|
|
@@ -5206,75 +5415,81 @@ function Zr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
5206
5415
|
let s = () => t.stop();
|
|
5207
5416
|
window.addEventListener("pagehide", s), t.start();
|
|
5208
5417
|
let c = () => {
|
|
5209
|
-
Rn(
|
|
5418
|
+
Rn(_.host, _.token).then(e.setMobile).catch(() => {}), zn(_.host, _.token).then(e.setInactive).catch(() => {});
|
|
5210
5419
|
};
|
|
5211
5420
|
c();
|
|
5212
5421
|
let u = window.setInterval(c, 12e4);
|
|
5213
|
-
Ln(
|
|
5422
|
+
Ln(_.host, _.token, _.username, (e) => Y.setState({ myName: e })).then(e.setContacts).catch((e) => X("chat-island-error", {
|
|
5214
5423
|
scope: "contacts",
|
|
5215
5424
|
message: e.message
|
|
5216
5425
|
}));
|
|
5217
|
-
let d = Z("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Z("chat-island-close", () => e.closeChat()), p = Z("chat-island-new", () => e.setPicker(!0)), m = Z("chat-island-delete", ({ username: e }) => e &&
|
|
5426
|
+
let d = Z("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = Z("chat-island-close", () => e.closeChat()), p = Z("chat-island-new", () => e.setPicker(!0)), m = Z("chat-island-delete", ({ username: e }) => e && I.remove(e)), h = Z("chat-island-send", ({ username: e, text: t }) => e && t && I.send(e, t).catch(() => {})), g = Z("chat-island-group-create", ({ name: e, members: t }) => e && t?.length && I.createGroup(e, t)), v = Z("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), y = Z("chat-island-conversations-request", () => X("chat-island-conversations", { conversations: Yr() }));
|
|
5218
5427
|
return () => {
|
|
5219
|
-
window.removeEventListener("pagehide", s), window.clearInterval(u), y(), p(), m(), h(),
|
|
5428
|
+
window.removeEventListener("pagehide", s), window.clearInterval(u), y(), p(), m(), h(), g(), d(), f(), v(), j.current && t.disablePush(j.current.service, j.current.node).catch(() => {}), j.current = null, t.stop(), O.current = null, A.current = !1;
|
|
5220
5429
|
};
|
|
5221
5430
|
}, [
|
|
5222
|
-
|
|
5431
|
+
_,
|
|
5223
5432
|
r,
|
|
5224
|
-
|
|
5433
|
+
T
|
|
5225
5434
|
]);
|
|
5226
|
-
let
|
|
5435
|
+
let te = Y((e) => Object.keys(e.contacts).join(","));
|
|
5227
5436
|
i(() => {
|
|
5228
|
-
|
|
5229
|
-
}, [
|
|
5230
|
-
let
|
|
5231
|
-
i(() => X("chat-island-conversations", { conversations:
|
|
5232
|
-
let
|
|
5233
|
-
i(() => X("chat-island-unread", { total:
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
let
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
}
|
|
5437
|
+
ee === "online" && te && O.current?.announce(te.split(","));
|
|
5438
|
+
}, [ee, te]);
|
|
5439
|
+
let ne = Y((e) => Object.values(e.conversations).map((e) => `${e.peer}:${e.kind}:${e.name ?? ""}:${(e.members ?? []).length}:${e.unread}:${e.messages[e.messages.length - 1]?.id ?? ""}`).join("|") + "#" + Object.keys(e.contacts).length + "#" + Object.values(e.online).filter(Boolean).length + "#" + Object.keys(e.inactive).length);
|
|
5440
|
+
i(() => X("chat-island-conversations", { conversations: Yr() }), [ne]);
|
|
5441
|
+
let re = Y((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
|
|
5442
|
+
i(() => X("chat-island-unread", { total: re }), [re]), i(() => {
|
|
5443
|
+
let e = () => {
|
|
5444
|
+
let e = Y.getState().open;
|
|
5445
|
+
document.visibilityState === "visible" && e && I.seen(e);
|
|
5446
|
+
};
|
|
5447
|
+
return document.addEventListener("visibilitychange", e), () => document.removeEventListener("visibilitychange", e);
|
|
5448
|
+
}, [I]);
|
|
5449
|
+
let ie = s(null), L = s(P), ae = s(null), oe = !F && !!P && P !== L.current && !!ie.current;
|
|
5450
|
+
oe && (ae.current = ie.current.offsetHeight), i(() => {
|
|
5451
|
+
L.current = P, P || (ae.current = null);
|
|
5452
|
+
}, [P]);
|
|
5453
|
+
let [se, ce, le] = $r(P), [R, ue, de] = $r(F, oe);
|
|
5454
|
+
if (!_ || g) return null;
|
|
5455
|
+
let fe = m && !h && N.anchor ? {
|
|
5456
|
+
right: N.anchor.right,
|
|
5457
|
+
bottom: N.anchor.bottom
|
|
5458
|
+
} : void 0, z = fe ? "" : t === "bottom-left" ? "ci-left-4 ci-bottom-5" : "ci-right-4 ci-bottom-5";
|
|
5244
5459
|
return /* @__PURE__ */ d("div", {
|
|
5245
|
-
ref:
|
|
5246
|
-
style:
|
|
5247
|
-
onClickCapture:
|
|
5248
|
-
className: `chat-island-root ${
|
|
5249
|
-
"data-status":
|
|
5250
|
-
children: /* @__PURE__ */ f(
|
|
5251
|
-
|
|
5252
|
-
className:
|
|
5253
|
-
style:
|
|
5254
|
-
onAnimationEnd:
|
|
5255
|
-
children: /* @__PURE__ */ d(
|
|
5256
|
-
peer:
|
|
5257
|
-
actions:
|
|
5258
|
-
theme:
|
|
5259
|
-
onDragStart: h ?? (m ?
|
|
5460
|
+
ref: M,
|
|
5461
|
+
style: fe,
|
|
5462
|
+
onClickCapture: N.onClickCapture,
|
|
5463
|
+
className: `chat-island-root ${v ? "ci-dark" : ""} ci-fixed ${z} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
|
|
5464
|
+
"data-status": ee,
|
|
5465
|
+
children: /* @__PURE__ */ f(Xr, { children: [
|
|
5466
|
+
se && /* @__PURE__ */ d("div", {
|
|
5467
|
+
className: ce ? "ci-anim-close" : ae.current ? "ci-anim-morph" : "ci-anim-open",
|
|
5468
|
+
style: ae.current ? { "--ci-from": `${ae.current}px` } : void 0,
|
|
5469
|
+
onAnimationEnd: le,
|
|
5470
|
+
children: /* @__PURE__ */ d(Vr, {
|
|
5471
|
+
peer: se,
|
|
5472
|
+
actions: I,
|
|
5473
|
+
theme: y,
|
|
5474
|
+
onDragStart: h ?? (m ? N.start : void 0)
|
|
5260
5475
|
})
|
|
5261
5476
|
}),
|
|
5262
|
-
|
|
5263
|
-
ref:
|
|
5264
|
-
className:
|
|
5265
|
-
onAnimationEnd:
|
|
5266
|
-
children: /* @__PURE__ */ d(
|
|
5477
|
+
R && /* @__PURE__ */ d("div", {
|
|
5478
|
+
ref: ie,
|
|
5479
|
+
className: ue ? "ci-anim-close" : "ci-anim-open",
|
|
5480
|
+
onAnimationEnd: de,
|
|
5481
|
+
children: /* @__PURE__ */ d(Gr, {
|
|
5267
5482
|
onOpen: (e) => Y.getState().openChat(e),
|
|
5268
|
-
onCreateGroup:
|
|
5269
|
-
onDragStart: h ?? (m ?
|
|
5483
|
+
onCreateGroup: I.createGroup,
|
|
5484
|
+
onDragStart: h ?? (m ? N.start : void 0)
|
|
5270
5485
|
})
|
|
5271
5486
|
}),
|
|
5272
5487
|
/* @__PURE__ */ d(Zn, {
|
|
5273
|
-
onDragStart: h ?? (m ?
|
|
5488
|
+
onDragStart: h ?? (m ? N.start : void 0),
|
|
5274
5489
|
pushButton: u !== "auto"
|
|
5275
5490
|
})
|
|
5276
5491
|
] })
|
|
5277
5492
|
});
|
|
5278
5493
|
}
|
|
5279
5494
|
//#endregion
|
|
5280
|
-
export {
|
|
5495
|
+
export { ei as ChatIsland, Fn as contactsFromOperators };
|