@nethesis/chat-island 0.1.5 → 0.1.7
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 +178 -174
- package/dist/xmpp.d.ts +1 -0
- package/dist-widget/index.widget.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2315,6 +2315,8 @@ var U = {
|
|
|
2315
2315
|
mucsub: "urn:xmpp:mucsub:0",
|
|
2316
2316
|
pubsubEvent: "http://jabber.org/protocol/pubsub#event",
|
|
2317
2317
|
mucsubMessages: "urn:xmpp:mucsub:nodes:messages",
|
|
2318
|
+
mucsubConfig: "urn:xmpp:mucsub:nodes:config",
|
|
2319
|
+
mucUser: "http://jabber.org/protocol/muc#user",
|
|
2318
2320
|
conference: "jabber:x:conference",
|
|
2319
2321
|
vcard: "vcard-temp",
|
|
2320
2322
|
ping: "urn:xmpp:ping",
|
|
@@ -2558,14 +2560,14 @@ var U = {
|
|
|
2558
2560
|
xmlns: U.mucsub,
|
|
2559
2561
|
jid: `${e}@${this.domain}`,
|
|
2560
2562
|
nick: e
|
|
2561
|
-
}, P("event", { node: U.mucsubMessages }))), 15e3).catch(() => {});
|
|
2563
|
+
}, P("event", { node: U.mucsubMessages }), P("event", { node: U.mucsubConfig }))), 15e3).catch(() => {});
|
|
2562
2564
|
await this.xmpp.iqCaller.request(P("iq", {
|
|
2563
2565
|
type: "set",
|
|
2564
2566
|
to: r
|
|
2565
2567
|
}, P("subscribe", {
|
|
2566
2568
|
xmlns: U.mucsub,
|
|
2567
2569
|
nick: i
|
|
2568
|
-
}, P("event", { node: U.mucsubMessages }))), 15e3), await this.xmpp.send(P("presence", {
|
|
2570
|
+
}, P("event", { node: U.mucsubMessages }), P("event", { node: U.mucsubConfig }))), 15e3), await this.xmpp.send(P("presence", {
|
|
2569
2571
|
to: `${r}/${i}`,
|
|
2570
2572
|
type: "unavailable"
|
|
2571
2573
|
}));
|
|
@@ -2730,9 +2732,15 @@ var U = {
|
|
|
2730
2732
|
e && this.deliver(e);
|
|
2731
2733
|
return;
|
|
2732
2734
|
}
|
|
2733
|
-
let i = e.getChild("
|
|
2734
|
-
if (i) {
|
|
2735
|
-
let
|
|
2735
|
+
let i = e.getChild("event", U.pubsubEvent);
|
|
2736
|
+
if (i?.getChild("items")?.attrs.node === U.mucsubConfig) {
|
|
2737
|
+
let t = W(e.attrs.from);
|
|
2738
|
+
this.isGroup(t) && bn(i, "presence")?.getChild("x", U.mucUser)?.getChild("destroy") && this.h.groupDestroyed(t);
|
|
2739
|
+
return;
|
|
2740
|
+
}
|
|
2741
|
+
let a = e.getChild("x", U.conference);
|
|
2742
|
+
if (a) {
|
|
2743
|
+
let e = W(a.attrs.jid);
|
|
2736
2744
|
this.isGroup(e) && this.h.groupInvite(e);
|
|
2737
2745
|
return;
|
|
2738
2746
|
}
|
|
@@ -2757,7 +2765,7 @@ var U = {
|
|
|
2757
2765
|
let t = e.getChild("event", U.pubsubEvent), n = e, r;
|
|
2758
2766
|
if (t && t.getChild("items")?.attrs.node === U.mucsubMessages) {
|
|
2759
2767
|
r = W(e.attrs.from);
|
|
2760
|
-
let i =
|
|
2768
|
+
let i = xn(t);
|
|
2761
2769
|
if (!this.isGroup(r) || !i || W(i.attrs.from) !== r) return;
|
|
2762
2770
|
n = i;
|
|
2763
2771
|
} else if (e.attrs.type === "groupchat" && (r = W(e.attrs.from), !this.isGroup(r))) return;
|
|
@@ -2787,7 +2795,7 @@ var U = {
|
|
|
2787
2795
|
if (r && r.getChild("items")?.attrs.node === U.mucsubMessages) {
|
|
2788
2796
|
let i = W(e.attrs.from);
|
|
2789
2797
|
if (!this.isGroup(i)) return;
|
|
2790
|
-
let a =
|
|
2798
|
+
let a = xn(r);
|
|
2791
2799
|
if (!a || W(a.attrs.from) !== i) return;
|
|
2792
2800
|
let o = (a.attrs.from ?? "").split("/")[1] ?? "", s = a.getChildText("body");
|
|
2793
2801
|
return s == null ? void 0 : {
|
|
@@ -2839,18 +2847,16 @@ var U = {
|
|
|
2839
2847
|
let t = e?.getChild("delay", U.delay)?.attrs.stamp;
|
|
2840
2848
|
return t ? Date.parse(t) : Date.now();
|
|
2841
2849
|
};
|
|
2842
|
-
function bn(e) {
|
|
2843
|
-
for (let
|
|
2844
|
-
if (typeof
|
|
2845
|
-
if (
|
|
2846
|
-
let e = bn(t);
|
|
2850
|
+
function bn(e, t) {
|
|
2851
|
+
for (let n of e.children) {
|
|
2852
|
+
if (typeof n == "string") continue;
|
|
2853
|
+
if (n.name === t) return n;
|
|
2854
|
+
let e = bn(n, t);
|
|
2847
2855
|
if (e) return e;
|
|
2848
2856
|
}
|
|
2849
2857
|
}
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
var K;
|
|
2853
|
-
function xn() {
|
|
2858
|
+
var xn = (e) => bn(e, "message"), K;
|
|
2859
|
+
function Sn() {
|
|
2854
2860
|
try {
|
|
2855
2861
|
K ??= new AudioContext(), K.state === "suspended" && K.resume();
|
|
2856
2862
|
let e = K.currentTime;
|
|
@@ -2870,7 +2876,7 @@ function xn() {
|
|
|
2870
2876
|
}
|
|
2871
2877
|
//#endregion
|
|
2872
2878
|
//#region node_modules/zustand/esm/vanilla.mjs
|
|
2873
|
-
var
|
|
2879
|
+
var Cn = (e) => {
|
|
2874
2880
|
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
|
|
2875
2881
|
let i = typeof e == "function" ? e(t) : e;
|
|
2876
2882
|
if (!Object.is(i, t)) {
|
|
@@ -2887,15 +2893,15 @@ var Sn = (e) => {
|
|
|
2887
2893
|
}
|
|
2888
2894
|
}, o = t = e(r, i, a);
|
|
2889
2895
|
return a;
|
|
2890
|
-
},
|
|
2891
|
-
function
|
|
2892
|
-
let r =
|
|
2893
|
-
return
|
|
2896
|
+
}, wn = (e) => e ? Cn(e) : Cn, { useDebugValue: Tn } = e, { useSyncExternalStoreWithSelector: En } = l, Dn = (e) => e;
|
|
2897
|
+
function On(e, t = Dn, n) {
|
|
2898
|
+
let r = En(e.subscribe, e.getState, e.getServerState || e.getInitialState, t, n);
|
|
2899
|
+
return Tn(r), r;
|
|
2894
2900
|
}
|
|
2895
|
-
var
|
|
2896
|
-
let t = typeof e == "function" ?
|
|
2901
|
+
var kn = (e) => {
|
|
2902
|
+
let t = typeof e == "function" ? wn(e) : e, n = (e, n) => On(t, e, n);
|
|
2897
2903
|
return Object.assign(n, t), n;
|
|
2898
|
-
},
|
|
2904
|
+
}, An = (e) => e ? kn(e) : kn, jn = (e) => e.room ?? (e.mine ? e.to : e.from), q = (e, t) => ({
|
|
2899
2905
|
peer: e,
|
|
2900
2906
|
kind: t && e.endsWith("@" + t) ? "group" : "chat",
|
|
2901
2907
|
messages: [],
|
|
@@ -2903,13 +2909,13 @@ var On = (e) => {
|
|
|
2903
2909
|
typing: !1,
|
|
2904
2910
|
loaded: !1,
|
|
2905
2911
|
complete: !1
|
|
2906
|
-
}),
|
|
2912
|
+
}), Mn = (e, t, n, r) => {
|
|
2907
2913
|
if (e.includes(t)) return e;
|
|
2908
2914
|
let i = [t, ...e];
|
|
2909
2915
|
if (i.length <= n) return i;
|
|
2910
2916
|
let a = [...i].reverse().find((e) => e !== r);
|
|
2911
2917
|
return i.filter((e) => e !== a);
|
|
2912
|
-
}, J =
|
|
2918
|
+
}, J = An((e, t) => ({
|
|
2913
2919
|
me: "",
|
|
2914
2920
|
mucHost: "",
|
|
2915
2921
|
status: "connecting",
|
|
@@ -2974,7 +2980,7 @@ var On = (e) => {
|
|
|
2974
2980
|
seed: (t, n) => e((e) => {
|
|
2975
2981
|
let r = { ...e.conversations };
|
|
2976
2982
|
for (let i of t) {
|
|
2977
|
-
let t =
|
|
2983
|
+
let t = jn(i);
|
|
2978
2984
|
if (!t || t === n) continue;
|
|
2979
2985
|
let a = r[t] ?? q(t, e.mucHost);
|
|
2980
2986
|
if (a.messages.some((e) => e.id === i.id)) continue;
|
|
@@ -2997,7 +3003,7 @@ var On = (e) => {
|
|
|
2997
3003
|
let i = e.conversations[t] ?? q(t, e.mucHost), a = i.messages.filter((e) => e.id !== n.id && !(e.pending && n.mine && e.body === n.body && e.oob === n.oob)), o = a.length;
|
|
2998
3004
|
for (; o > 0 && a[o - 1].ts > n.ts;) o--;
|
|
2999
3005
|
a.splice(o, 0, n);
|
|
3000
|
-
let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l =
|
|
3006
|
+
let s = e.open === t, c = r?.live && !n.mine && !s ? i.unread + 1 : i.unread, l = Mn(e.order, t, e.maxHeads, e.open);
|
|
3001
3007
|
return {
|
|
3002
3008
|
conversations: {
|
|
3003
3009
|
...e.conversations,
|
|
@@ -3048,7 +3054,7 @@ var On = (e) => {
|
|
|
3048
3054
|
...e.conversations,
|
|
3049
3055
|
[t]: q(t, e.mucHost)
|
|
3050
3056
|
},
|
|
3051
|
-
order:
|
|
3057
|
+
order: Mn(e.order, t, e.maxHeads, e.open),
|
|
3052
3058
|
open: t,
|
|
3053
3059
|
picker: !1
|
|
3054
3060
|
})),
|
|
@@ -3077,15 +3083,15 @@ var On = (e) => {
|
|
|
3077
3083
|
}));
|
|
3078
3084
|
//#endregion
|
|
3079
3085
|
//#region src/api.ts
|
|
3080
|
-
async function
|
|
3086
|
+
async function Nn(e, t, n) {
|
|
3081
3087
|
let r = await fetch(`https://${e}/api${n}`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3082
3088
|
if (!r.ok) throw Error(`${n}: HTTP ${r.status}`);
|
|
3083
3089
|
return await r.json();
|
|
3084
3090
|
}
|
|
3085
|
-
async function
|
|
3086
|
-
let r = await
|
|
3091
|
+
async function Pn(e, t, n) {
|
|
3092
|
+
let r = await Nn(e, t, "/user/endpoints/all"), i = {};
|
|
3087
3093
|
try {
|
|
3088
|
-
i = await
|
|
3094
|
+
i = await Nn(e, t, "/user/all_avatars");
|
|
3089
3095
|
} catch {}
|
|
3090
3096
|
return Object.values(r).filter((e) => e.username && e.username !== n).map((e) => ({
|
|
3091
3097
|
username: e.username,
|
|
@@ -3094,12 +3100,12 @@ async function Nn(e, t, n) {
|
|
|
3094
3100
|
presence: e.mainPresence
|
|
3095
3101
|
})).sort((e, t) => e.name.localeCompare(t.name));
|
|
3096
3102
|
}
|
|
3097
|
-
async function
|
|
3103
|
+
async function Fn(e, t) {
|
|
3098
3104
|
let n = await fetch(`https://${e}/chat-gw/push/mobile`, { headers: { Authorization: `Bearer ${t}` } });
|
|
3099
3105
|
if (!n.ok) throw Error(`push/mobile: HTTP ${n.status}`);
|
|
3100
3106
|
return (await n.json()).users;
|
|
3101
3107
|
}
|
|
3102
|
-
async function
|
|
3108
|
+
async function In(e, t, n) {
|
|
3103
3109
|
let r = await fetch(`https://${e}/chat-gw/conversations/${encodeURIComponent(n)}`, {
|
|
3104
3110
|
method: "DELETE",
|
|
3105
3111
|
headers: { Authorization: `Bearer ${t}` }
|
|
@@ -3108,16 +3114,16 @@ async function Fn(e, t, n) {
|
|
|
3108
3114
|
}
|
|
3109
3115
|
//#endregion
|
|
3110
3116
|
//#region src/push.ts
|
|
3111
|
-
var
|
|
3117
|
+
var Ln = (e) => {
|
|
3112
3118
|
let t = atob((e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"));
|
|
3113
3119
|
return Uint8Array.from(t, (e) => e.charCodeAt(0));
|
|
3114
|
-
},
|
|
3115
|
-
function
|
|
3116
|
-
|
|
3120
|
+
}, Rn = !1;
|
|
3121
|
+
function zn() {
|
|
3122
|
+
Rn || (Rn = !0, navigator.serviceWorker.addEventListener("message", (e) => {
|
|
3117
3123
|
e.data?.type === "chat-island-open" && typeof e.data.username == "string" && window.dispatchEvent(new CustomEvent("chat-island-open", { detail: { username: e.data.username } }));
|
|
3118
3124
|
}));
|
|
3119
3125
|
}
|
|
3120
|
-
async function
|
|
3126
|
+
async function Bn(e, t) {
|
|
3121
3127
|
if (!("serviceWorker" in navigator) || !("PushManager" in window)) throw Error("push not supported by this browser");
|
|
3122
3128
|
if (Notification.permission === "denied" || Notification.permission !== "granted" && await Notification.requestPermission() !== "granted") return null;
|
|
3123
3129
|
let n = `https://${e.host}/chat-gw`, r = await fetch(`${n}/push/vapid`);
|
|
@@ -3126,7 +3132,7 @@ async function zn(e, t) {
|
|
|
3126
3132
|
await navigator.serviceWorker.ready;
|
|
3127
3133
|
let o = await a.pushManager.getSubscription() ?? await a.pushManager.subscribe({
|
|
3128
3134
|
userVisibleOnly: !0,
|
|
3129
|
-
applicationServerKey:
|
|
3135
|
+
applicationServerKey: Ln(i.publicKey)
|
|
3130
3136
|
}), s = await fetch(`${n}/push/web`, {
|
|
3131
3137
|
method: "POST",
|
|
3132
3138
|
headers: {
|
|
@@ -3137,7 +3143,7 @@ async function zn(e, t) {
|
|
|
3137
3143
|
});
|
|
3138
3144
|
if (!s.ok) throw Error(`push/web: HTTP ${s.status} ${(await s.text()).slice(0, 120)}`);
|
|
3139
3145
|
let c = await s.json();
|
|
3140
|
-
return
|
|
3146
|
+
return zn(), {
|
|
3141
3147
|
node: c.node,
|
|
3142
3148
|
service: c.service
|
|
3143
3149
|
};
|
|
@@ -3153,8 +3159,8 @@ function X(e, t) {
|
|
|
3153
3159
|
}
|
|
3154
3160
|
//#endregion
|
|
3155
3161
|
//#region src/components/Avatar.tsx
|
|
3156
|
-
var
|
|
3157
|
-
function
|
|
3162
|
+
var Vn = (e) => e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
|
|
3163
|
+
function Hn({ contact: e, username: t, size: n = 40 }) {
|
|
3158
3164
|
let r = e?.name || t, i = {
|
|
3159
3165
|
width: n,
|
|
3160
3166
|
height: n,
|
|
@@ -3169,13 +3175,13 @@ function Vn({ contact: e, username: t, size: n = 40 }) {
|
|
|
3169
3175
|
}) : /* @__PURE__ */ d("div", {
|
|
3170
3176
|
style: i,
|
|
3171
3177
|
className: "ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-gray-700 ci-text-gray-50 dark:ci-bg-gray-300 dark:ci-text-gray-900",
|
|
3172
|
-
children:
|
|
3178
|
+
children: Vn(r)
|
|
3173
3179
|
});
|
|
3174
3180
|
}
|
|
3175
|
-
function
|
|
3181
|
+
function Un({ online: e, presence: t, mobile: n }) {
|
|
3176
3182
|
return /* @__PURE__ */ d("span", { className: `ci-absolute ci-bottom-0 ci-right-0 ci-w-3 ci-h-3 ci-rounded-full ci-ring-2 ci-ring-gray-50 dark:ci-ring-gray-950 ${t === "dnd" || t === "busy" ? "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark" : e || n ? "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark" : "ci-bg-gray-400 dark:ci-bg-gray-600"}` });
|
|
3177
3183
|
}
|
|
3178
|
-
function
|
|
3184
|
+
function Wn({ name: e, size: t = 40, avatar: n }) {
|
|
3179
3185
|
let r = {
|
|
3180
3186
|
width: t,
|
|
3181
3187
|
height: t,
|
|
@@ -3190,12 +3196,12 @@ function Un({ name: e, size: t = 40, avatar: n }) {
|
|
|
3190
3196
|
}) : /* @__PURE__ */ d("div", {
|
|
3191
3197
|
style: r,
|
|
3192
3198
|
className: "ci-rounded-full ci-shrink-0 ci-flex ci-items-center ci-justify-center ci-font-medium ci-bg-iconSecondary dark:ci-bg-iconSecondaryDark ci-text-white",
|
|
3193
|
-
children:
|
|
3199
|
+
children: Vn(e || "G")
|
|
3194
3200
|
});
|
|
3195
3201
|
}
|
|
3196
3202
|
//#endregion
|
|
3197
3203
|
//#region src/components/Button.tsx
|
|
3198
|
-
var
|
|
3204
|
+
var Gn = "ci-flex ci-content-center ci-items-center ci-justify-center ci-tracking-wide ci-duration-200 ci-transform ci-outline-none focus:ci-ring-2 focus:ci-z-20 focus:ci-ring-offset-2 disabled:ci-opacity-40 disabled:ci-cursor-not-allowed ci-border ci-border-transparent focus:ci-ring-offset-white dark:focus:ci-ring-offset-black ci-text-sm ci-leading-4 ci-transition-colors ci-shrink-0 ci-font-light", Kn = {
|
|
3199
3205
|
default: "ci-bg-phoneIslandActive dark:ci-bg-phoneIslandActiveDark hover:ci-bg-gray-500 dark:hover:ci-bg-gray-50 focus:ci-ring-emerald-500 dark:focus:ci-ring-emerald-300 ci-text-primaryInvert dark:ci-text-primaryInvertDark ci-h-12 ci-w-12 ci-rounded-full",
|
|
3200
3206
|
green: "ci-bg-phoneIslandCall dark:ci-bg-phoneIslandCallDark hover:ci-bg-phoneIslandCallHover dark:hover:ci-bg-phoneIslandCallHoverDark focus:ci-ring-green-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
|
|
3201
3207
|
red: "ci-bg-phoneIslandClose dark:ci-bg-phoneIslandCloseDark hover:ci-bg-phoneIslandCloseHover dark:hover:ci-bg-phoneIslandCloseHoverDark focus:ci-ring-emerald-500 ci-text-white dark:ci-text-gray-950 ci-h-12 ci-w-12 ci-rounded-full",
|
|
@@ -3208,22 +3214,18 @@ function Z({ variant: e, className: t = "", children: n, ...r }) {
|
|
|
3208
3214
|
return /* @__PURE__ */ d("button", {
|
|
3209
3215
|
type: "button",
|
|
3210
3216
|
"aria-label": r["aria-label"] ?? r.title,
|
|
3211
|
-
className: `${
|
|
3217
|
+
className: `${Gn} ${Kn[e]} ${t}`,
|
|
3212
3218
|
...r,
|
|
3213
3219
|
children: n
|
|
3214
3220
|
});
|
|
3215
3221
|
}
|
|
3216
3222
|
var Q = {
|
|
3217
3223
|
chat: /* @__PURE__ */ d("svg", {
|
|
3218
|
-
width: "
|
|
3219
|
-
height: "
|
|
3220
|
-
viewBox: "0 0
|
|
3221
|
-
fill: "
|
|
3222
|
-
|
|
3223
|
-
strokeWidth: "2",
|
|
3224
|
-
strokeLinecap: "round",
|
|
3225
|
-
strokeLinejoin: "round",
|
|
3226
|
-
children: /* @__PURE__ */ d("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
|
|
3224
|
+
width: "20",
|
|
3225
|
+
height: "20",
|
|
3226
|
+
viewBox: "0 0 512 512",
|
|
3227
|
+
fill: "currentColor",
|
|
3228
|
+
children: /* @__PURE__ */ d("path", { d: "M0 240c0 54.4 19.3 104.6 51.9 144.9L3.1 474.3c-2 3.7-3.1 7.9-3.1 12.2 0 14.1 11.4 25.5 25.5 25.5 4 0 7.8-.6 11.5-2.1L153.4 460c31.4 12.9 66.1 20 102.6 20 141.4 0 256-107.5 256-240S397.4 0 256 0 0 107.5 0 240zM94 407.9c9.3-17.1 7.4-38.1-4.8-53.2-26.1-32.3-41.2-71.9-41.2-114.7 0-103.2 90.2-192 208-192s208 88.8 208 192-90.2 192-208 192c-30.2 0-58.7-5.9-84.3-16.4-11.9-4.9-25.3-4.8-37.1 .3L76 440.9 94 407.9zM144 272a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm144-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm80 32a32 32 0 1 0 0-64 32 32 0 1 0 0 64z" })
|
|
3227
3229
|
}),
|
|
3228
3230
|
bell: /* @__PURE__ */ d("svg", {
|
|
3229
3231
|
width: "18",
|
|
@@ -3369,7 +3371,7 @@ var Q = {
|
|
|
3369
3371
|
};
|
|
3370
3372
|
//#endregion
|
|
3371
3373
|
//#region src/components/Dock.tsx
|
|
3372
|
-
function
|
|
3374
|
+
function qn({ onDragStart: e, pushButton: t = !0 }) {
|
|
3373
3375
|
let { order: n, open: r, conversations: i, contacts: a, online: o, mobile: s, openChat: c, removeHead: l, picker: p, setPicker: m, status: h, push: g, enablePush: _, newChatButton: v } = J(w((e) => ({
|
|
3374
3376
|
order: e.order,
|
|
3375
3377
|
open: e.open,
|
|
@@ -3399,15 +3401,15 @@ function Kn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3399
3401
|
title: t?.kind === "group" ? t.name ?? e : a[e]?.name ?? e,
|
|
3400
3402
|
onClick: () => n ? J.getState().closeChat() : c(e),
|
|
3401
3403
|
className: `ci-relative ci-rounded-full ci-shadow-lg ci-transition-transform hover:ci-scale-105 ci-ring-2 ci-border-0 ci-p-0 ci-bg-transparent ${n ? "ci-ring-iconSecondary dark:ci-ring-iconSecondaryDark" : "ci-ring-gray-50 dark:ci-ring-gray-950"}`,
|
|
3402
|
-
children: [t?.kind === "group" ? /* @__PURE__ */ d(
|
|
3404
|
+
children: [t?.kind === "group" ? /* @__PURE__ */ d(Wn, {
|
|
3403
3405
|
name: t.name ?? e,
|
|
3404
3406
|
size: 48,
|
|
3405
3407
|
avatar: t.avatar
|
|
3406
|
-
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(
|
|
3408
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(Hn, {
|
|
3407
3409
|
contact: a[e],
|
|
3408
3410
|
username: e,
|
|
3409
3411
|
size: 48
|
|
3410
|
-
}), /* @__PURE__ */ d(
|
|
3412
|
+
}), /* @__PURE__ */ d(Un, {
|
|
3411
3413
|
online: o[e],
|
|
3412
3414
|
presence: a[e]?.presence,
|
|
3413
3415
|
mobile: s[e]
|
|
@@ -3443,7 +3445,7 @@ function Kn({ onDragStart: e, pushButton: t = !0 }) {
|
|
|
3443
3445
|
}
|
|
3444
3446
|
//#endregion
|
|
3445
3447
|
//#region src/shortcodes.ts
|
|
3446
|
-
var
|
|
3448
|
+
var Jn = {
|
|
3447
3449
|
"+1": "👍",
|
|
3448
3450
|
thumbsup: "👍",
|
|
3449
3451
|
"-1": "👎",
|
|
@@ -3637,13 +3639,13 @@ var qn = {
|
|
|
3637
3639
|
zzz: "💤",
|
|
3638
3640
|
sweat_drops: "💦",
|
|
3639
3641
|
dash: "💨"
|
|
3640
|
-
},
|
|
3642
|
+
}, Yn = /(```[\s\S]*?(?:```|$)|`[^`\n]*`?)/g, Xn = /:([a-z0-9_+-]+):/g, Zn = (e) => e.replace(Xn, (e, t) => Jn[t] ?? e);
|
|
3641
3643
|
function $(e) {
|
|
3642
|
-
return e.includes(":") ? e.split(
|
|
3644
|
+
return e.includes(":") ? e.split(Yn).map((e, t) => t % 2 ? e : Zn(e)).join("") : e;
|
|
3643
3645
|
}
|
|
3644
3646
|
//#endregion
|
|
3645
3647
|
//#region src/components/EmojiPicker.tsx
|
|
3646
|
-
var
|
|
3648
|
+
var Qn = [
|
|
3647
3649
|
{
|
|
3648
3650
|
label: "Smileys",
|
|
3649
3651
|
icon: "😀",
|
|
@@ -3674,7 +3676,7 @@ var Zn = [
|
|
|
3674
3676
|
icon: "☕",
|
|
3675
3677
|
emojis: "☕ 🍵 🥤 🍕 🍔 🍟 🌭 🥪 🌮 🍝 🍣 🍩 🍪 🍫 🍎 🍌 🍓 🥐 🚗 🚕 🚌 🚆 ✈️ 🚀 🏠 🏢 🏖️ 🌍 ☀️ 🌤️ 🌧️ ⛈️ ❄️ ⚡ 🌈 🌙"
|
|
3676
3678
|
}
|
|
3677
|
-
],
|
|
3679
|
+
], $n = [
|
|
3678
3680
|
"👍",
|
|
3679
3681
|
"❤️",
|
|
3680
3682
|
"😂",
|
|
@@ -3682,7 +3684,7 @@ var Zn = [
|
|
|
3682
3684
|
"😢",
|
|
3683
3685
|
"🙏"
|
|
3684
3686
|
];
|
|
3685
|
-
function
|
|
3687
|
+
function er({ onPick: e, onClose: t, className: n = "" }) {
|
|
3686
3688
|
let [r, a] = c(0), o = s(null);
|
|
3687
3689
|
return i(() => {
|
|
3688
3690
|
let e = (e) => o.current && !o.current.contains(e.target) && t(), n = (e) => {
|
|
@@ -3698,7 +3700,7 @@ function $n({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3698
3700
|
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-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ci-select-none ${n}`,
|
|
3699
3701
|
children: [/* @__PURE__ */ d("div", {
|
|
3700
3702
|
className: "ci-flex ci-gap-1 ci-px-2 ci-pt-2 ci-border-b ci-border-gray-300 dark:ci-border-gray-700",
|
|
3701
|
-
children:
|
|
3703
|
+
children: Qn.map((e, t) => /* @__PURE__ */ d("button", {
|
|
3702
3704
|
type: "button",
|
|
3703
3705
|
title: e.label,
|
|
3704
3706
|
"aria-label": e.label,
|
|
@@ -3712,7 +3714,7 @@ function $n({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3712
3714
|
}, e.label))
|
|
3713
3715
|
}), /* @__PURE__ */ d("div", {
|
|
3714
3716
|
className: "ci-grid ci-grid-cols-7 ci-gap-1 ci-p-2 ci-h-64 ci-overflow-y-auto",
|
|
3715
|
-
children:
|
|
3717
|
+
children: Qn[r].emojis.split(" ").map((t) => /* @__PURE__ */ d("button", {
|
|
3716
3718
|
type: "button",
|
|
3717
3719
|
onClick: () => e(t),
|
|
3718
3720
|
style: {
|
|
@@ -3727,27 +3729,27 @@ function $n({ onPick: e, onClose: t, className: n = "" }) {
|
|
|
3727
3729
|
}
|
|
3728
3730
|
//#endregion
|
|
3729
3731
|
//#region src/components/MessageList.tsx
|
|
3730
|
-
var
|
|
3732
|
+
var tr = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), nr = (e) => /\.(webm|ogg|oga|opus|mp3|m4a|wav)(\?|$)/i.test(e), rr = (e) => {
|
|
3731
3733
|
let t = e.split("/").pop() || "file";
|
|
3732
3734
|
try {
|
|
3733
3735
|
return decodeURIComponent(t);
|
|
3734
3736
|
} catch {
|
|
3735
3737
|
return t;
|
|
3736
3738
|
}
|
|
3737
|
-
},
|
|
3739
|
+
}, ir = (e) => {
|
|
3738
3740
|
try {
|
|
3739
3741
|
return new URL(e).protocol === "https:";
|
|
3740
3742
|
} catch {
|
|
3741
3743
|
return !1;
|
|
3742
3744
|
}
|
|
3743
|
-
},
|
|
3745
|
+
}, ar = (e) => new Date(e).toLocaleTimeString([], {
|
|
3744
3746
|
hour: "2-digit",
|
|
3745
3747
|
minute: "2-digit"
|
|
3746
|
-
}),
|
|
3748
|
+
}), or = (e) => new Date(e).toLocaleDateString([], {
|
|
3747
3749
|
weekday: "short",
|
|
3748
3750
|
day: "numeric",
|
|
3749
3751
|
month: "short"
|
|
3750
|
-
}),
|
|
3752
|
+
}), sr = (e, t) => new Date(e).toDateString() === new Date(t).toDateString(), cr = (e) => {
|
|
3751
3753
|
if (!e.startsWith("{\"")) return null;
|
|
3752
3754
|
try {
|
|
3753
3755
|
let t = JSON.parse(e);
|
|
@@ -3758,17 +3760,17 @@ var er = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), tr = (e) => /\
|
|
|
3758
3760
|
} catch {
|
|
3759
3761
|
return null;
|
|
3760
3762
|
}
|
|
3761
|
-
},
|
|
3762
|
-
return
|
|
3763
|
+
}, lr = n(function({ url: e }) {
|
|
3764
|
+
return ir(e) ? tr(e) ? /* @__PURE__ */ d("a", {
|
|
3763
3765
|
href: e,
|
|
3764
3766
|
target: "_blank",
|
|
3765
3767
|
rel: "noreferrer",
|
|
3766
3768
|
children: /* @__PURE__ */ d("img", {
|
|
3767
3769
|
src: e,
|
|
3768
|
-
alt:
|
|
3770
|
+
alt: rr(e),
|
|
3769
3771
|
className: "ci-max-w-full ci-max-h-60 ci-rounded-2xl ci-block"
|
|
3770
3772
|
})
|
|
3771
|
-
}) :
|
|
3773
|
+
}) : nr(e) ? /* @__PURE__ */ d("audio", {
|
|
3772
3774
|
controls: !0,
|
|
3773
3775
|
src: e,
|
|
3774
3776
|
className: "ci-max-w-full"
|
|
@@ -3785,15 +3787,15 @@ var er = (e) => /\.(png|jpe?g|gif|webp|avif|svg)(\?|$)/i.test(e), tr = (e) => /\
|
|
|
3785
3787
|
stroke: "currentColor",
|
|
3786
3788
|
strokeWidth: "2",
|
|
3787
3789
|
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" })
|
|
3788
|
-
}),
|
|
3790
|
+
}), rr(e)]
|
|
3789
3791
|
}) : /* @__PURE__ */ d("span", {
|
|
3790
3792
|
className: "ci-break-all",
|
|
3791
3793
|
children: e
|
|
3792
3794
|
});
|
|
3793
|
-
}),
|
|
3794
|
-
function
|
|
3795
|
+
}), ur = /(`[^`\n]+`)|(\*\*[^*\n]+\*\*|__[^_\n]+__)|(~~[^~\n]+~~)|(\*[^*\s][^*\n]*\*|_[^_\s][^_\n]*_)|\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|(https?:\/\/[^\s<]+)/g;
|
|
3796
|
+
function dr({ text: e }) {
|
|
3795
3797
|
let t = [], n = 0;
|
|
3796
|
-
for (let r of e.matchAll(
|
|
3798
|
+
for (let r of e.matchAll(ur)) {
|
|
3797
3799
|
let i = r[0], a = r.index ?? 0;
|
|
3798
3800
|
a > n && t.push($(e.slice(n, a))), r[1] ? t.push(/* @__PURE__ */ d("code", {
|
|
3799
3801
|
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]",
|
|
@@ -3814,17 +3816,17 @@ function ur({ text: e }) {
|
|
|
3814
3816
|
}
|
|
3815
3817
|
return n < e.length && t.push($(e.slice(n))), /* @__PURE__ */ d(u, { children: t });
|
|
3816
3818
|
}
|
|
3817
|
-
var
|
|
3819
|
+
var fr = n(function({ text: e }) {
|
|
3818
3820
|
let t = e.split(/```[^\n]*\n?([\s\S]*?)```/g);
|
|
3819
3821
|
return /* @__PURE__ */ d("span", {
|
|
3820
3822
|
className: "ci-whitespace-pre-wrap ci-break-words",
|
|
3821
3823
|
children: t.map((e, t) => t % 2 ? /* @__PURE__ */ d("pre", {
|
|
3822
3824
|
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",
|
|
3823
3825
|
children: e.replace(/\n$/, "")
|
|
3824
|
-
}, t) : /* @__PURE__ */ d(
|
|
3826
|
+
}, t) : /* @__PURE__ */ d(dr, { text: e.replace(/^(\s*)[-*] (?=\S)/gm, "$1• ") }, t))
|
|
3825
3827
|
});
|
|
3826
3828
|
});
|
|
3827
|
-
function
|
|
3829
|
+
function pr({ text: e, count: t }) {
|
|
3828
3830
|
return /* @__PURE__ */ f("span", {
|
|
3829
3831
|
className: "ci-italic ci-opacity-80",
|
|
3830
3832
|
children: [
|
|
@@ -3837,7 +3839,7 @@ function fr({ text: e, count: t }) {
|
|
|
3837
3839
|
]
|
|
3838
3840
|
});
|
|
3839
3841
|
}
|
|
3840
|
-
function
|
|
3842
|
+
function mr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
3841
3843
|
if (!e) return null;
|
|
3842
3844
|
let a = /* @__PURE__ */ new Map();
|
|
3843
3845
|
for (let [t, n] of Object.entries(e)) for (let e of n) a.set(e, [...a.get(e) ?? [], t]);
|
|
@@ -3862,7 +3864,7 @@ function pr({ forMsg: e, me: t, onReact: n, nameOf: r, mine: i }) {
|
|
|
3862
3864
|
})
|
|
3863
3865
|
}) : null;
|
|
3864
3866
|
}
|
|
3865
|
-
function
|
|
3867
|
+
function hr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, reactions: o, me: l = "", onReact: u }) {
|
|
3866
3868
|
let p = J((e) => e.contacts), m = s(null), h = s(!0), [g, _] = c(null), [v, y] = c(null), b = (e) => p[e]?.name ?? e;
|
|
3867
3869
|
i(() => {
|
|
3868
3870
|
let e = m.current;
|
|
@@ -3896,7 +3898,7 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3896
3898
|
children: "Scroll up for older messages"
|
|
3897
3899
|
}),
|
|
3898
3900
|
e.map((t, n) => {
|
|
3899
|
-
let r = e[n - 1], i = !r || !
|
|
3901
|
+
let r = e[n - 1], i = !r || !sr(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 ? b(t.nick) : null, m = t.oid, h = !!u && !!m && !t.pending, v = h && /* @__PURE__ */ d("button", {
|
|
3900
3902
|
type: "button",
|
|
3901
3903
|
title: "React",
|
|
3902
3904
|
"aria-label": "React to this message",
|
|
@@ -3908,14 +3910,14 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3908
3910
|
});
|
|
3909
3911
|
return /* @__PURE__ */ f("div", { children: [i && /* @__PURE__ */ d("div", {
|
|
3910
3912
|
className: "ci-text-center ci-text-xs ci-text-gray-500 dark:ci-text-gray-400 ci-py-2",
|
|
3911
|
-
children:
|
|
3913
|
+
children: or(t.ts)
|
|
3912
3914
|
}), /* @__PURE__ */ f("div", {
|
|
3913
3915
|
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"}`,
|
|
3914
3916
|
children: [
|
|
3915
3917
|
c && /* @__PURE__ */ d("span", {
|
|
3916
3918
|
className: "ci-w-7 ci-shrink-0",
|
|
3917
3919
|
title: c,
|
|
3918
|
-
children: !s && /* @__PURE__ */ d(
|
|
3920
|
+
children: !s && /* @__PURE__ */ d(Hn, {
|
|
3919
3921
|
contact: p[t.nick],
|
|
3920
3922
|
username: t.nick,
|
|
3921
3923
|
size: 28
|
|
@@ -3929,7 +3931,7 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3929
3931
|
role: "menu",
|
|
3930
3932
|
onClick: (e) => e.stopPropagation(),
|
|
3931
3933
|
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-ring-1 ci-ring-gray-300 dark:ci-ring-gray-700 ${t.mine ? "ci-right-0" : "ci-left-0"}`,
|
|
3932
|
-
children: [
|
|
3934
|
+
children: [$n.map((e) => /* @__PURE__ */ d("button", {
|
|
3933
3935
|
type: "button",
|
|
3934
3936
|
role: "menuitem",
|
|
3935
3937
|
"aria-label": e,
|
|
@@ -3953,22 +3955,22 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3953
3955
|
})]
|
|
3954
3956
|
}),
|
|
3955
3957
|
/* @__PURE__ */ f("div", {
|
|
3956
|
-
title:
|
|
3957
|
-
onDoubleClick: () => h && S(m,
|
|
3958
|
+
title: ar(t.ts),
|
|
3959
|
+
onDoubleClick: () => h && S(m, $n[0]),
|
|
3958
3960
|
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" : ""}`,
|
|
3959
3961
|
children: [
|
|
3960
|
-
t.oob ? /* @__PURE__ */ d(
|
|
3961
|
-
t.oob && t.body && t.body !== t.oob && t.body !==
|
|
3962
|
+
t.oob ? /* @__PURE__ */ d(lr, { url: t.oob }) : cr(t.body) ? /* @__PURE__ */ d(pr, { ...cr(t.body) }) : /* @__PURE__ */ d(fr, { text: t.body }),
|
|
3963
|
+
t.oob && t.body && t.body !== t.oob && t.body !== rr(t.oob) && /* @__PURE__ */ d("div", {
|
|
3962
3964
|
className: "ci-text-xs ci-opacity-80 ci-mt-1",
|
|
3963
3965
|
children: t.body
|
|
3964
3966
|
}),
|
|
3965
3967
|
/* @__PURE__ */ d("span", {
|
|
3966
3968
|
className: "ci-block ci-text-right ci-text-[10px] ci-leading-none ci-opacity-60 ci-mt-1",
|
|
3967
|
-
children:
|
|
3969
|
+
children: ar(t.ts)
|
|
3968
3970
|
})
|
|
3969
3971
|
]
|
|
3970
3972
|
}),
|
|
3971
|
-
m && /* @__PURE__ */ d(
|
|
3973
|
+
m && /* @__PURE__ */ d(mr, {
|
|
3972
3974
|
forMsg: o?.[m],
|
|
3973
3975
|
me: l,
|
|
3974
3976
|
mine: t.mine,
|
|
@@ -3989,7 +3991,7 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3989
3991
|
})
|
|
3990
3992
|
})
|
|
3991
3993
|
]
|
|
3992
|
-
}), v && /* @__PURE__ */ d(
|
|
3994
|
+
}), v && /* @__PURE__ */ d(er, {
|
|
3993
3995
|
className: "ci-absolute ci-bottom-2 ci-left-1/2 ci--translate-x-1/2",
|
|
3994
3996
|
onPick: (e) => S(v, e),
|
|
3995
3997
|
onClose: () => y(null)
|
|
@@ -3998,7 +4000,7 @@ function mr({ messages: e, typing: t, onLoadOlder: n, hasOlder: r, group: a, rea
|
|
|
3998
4000
|
}
|
|
3999
4001
|
//#endregion
|
|
4000
4002
|
//#region src/ogg.ts
|
|
4001
|
-
function
|
|
4003
|
+
function gr(e, t, n) {
|
|
4002
4004
|
let r = e[t];
|
|
4003
4005
|
if (r === void 0) return null;
|
|
4004
4006
|
let i = 1;
|
|
@@ -4012,7 +4014,7 @@ function hr(e, t, n) {
|
|
|
4012
4014
|
unknown: !n && o
|
|
4013
4015
|
};
|
|
4014
4016
|
}
|
|
4015
|
-
var
|
|
4017
|
+
var _r = /* @__PURE__ */ new Set([
|
|
4016
4018
|
408125543,
|
|
4017
4019
|
524531317,
|
|
4018
4020
|
374648427,
|
|
@@ -4020,18 +4022,18 @@ var gr = /* @__PURE__ */ new Set([
|
|
|
4020
4022
|
225,
|
|
4021
4023
|
160
|
|
4022
4024
|
]);
|
|
4023
|
-
function
|
|
4025
|
+
function vr(e) {
|
|
4024
4026
|
let t = {
|
|
4025
4027
|
channels: 1,
|
|
4026
4028
|
packets: []
|
|
4027
4029
|
}, n = 0;
|
|
4028
4030
|
for (; n < e.length;) {
|
|
4029
|
-
let r =
|
|
4031
|
+
let r = gr(e, n, !0);
|
|
4030
4032
|
if (!r) break;
|
|
4031
|
-
let i =
|
|
4033
|
+
let i = gr(e, n + r.len, !1);
|
|
4032
4034
|
if (!i) break;
|
|
4033
4035
|
let a = n + r.len + i.len;
|
|
4034
|
-
if (
|
|
4036
|
+
if (_r.has(r.value)) {
|
|
4035
4037
|
n = a;
|
|
4036
4038
|
continue;
|
|
4037
4039
|
}
|
|
@@ -4040,14 +4042,14 @@ function _r(e) {
|
|
|
4040
4042
|
if (r.value === 25506) t.head = e.slice(a, o);
|
|
4041
4043
|
else if (r.value === 159) t.channels = e[a] || 1;
|
|
4042
4044
|
else if (r.value === 163 || r.value === 161) {
|
|
4043
|
-
let n =
|
|
4045
|
+
let n = gr(e, a, !1);
|
|
4044
4046
|
n && (e[a + n.len + 2] >> 1 & 3 || t.packets.push(e.slice(a + n.len + 3, o)));
|
|
4045
4047
|
}
|
|
4046
4048
|
n = o;
|
|
4047
4049
|
}
|
|
4048
4050
|
return t;
|
|
4049
4051
|
}
|
|
4050
|
-
function
|
|
4052
|
+
function yr(e) {
|
|
4051
4053
|
if (!e.length) return 0;
|
|
4052
4054
|
let t = e[0], n = t >> 3, r;
|
|
4053
4055
|
r = n < 12 ? [
|
|
@@ -4064,7 +4066,7 @@ function vr(e) {
|
|
|
4064
4066
|
let i = t & 3, a = i === 0 ? 1 : i === 3 ? (e[1] ?? 0) & 63 : 2;
|
|
4065
4067
|
return Math.round(a * r * 48);
|
|
4066
4068
|
}
|
|
4067
|
-
var
|
|
4069
|
+
var br = (() => {
|
|
4068
4070
|
let e = /* @__PURE__ */ new Uint32Array(256);
|
|
4069
4071
|
for (let t = 0; t < 256; t++) {
|
|
4070
4072
|
let n = t << 24;
|
|
@@ -4073,12 +4075,12 @@ var yr = (() => {
|
|
|
4073
4075
|
}
|
|
4074
4076
|
return e;
|
|
4075
4077
|
})();
|
|
4076
|
-
function
|
|
4078
|
+
function xr(e) {
|
|
4077
4079
|
let t = 0;
|
|
4078
|
-
for (let n = 0; n < e.length; n++) t = (t << 8 ^
|
|
4080
|
+
for (let n = 0; n < e.length; n++) t = (t << 8 ^ br[(t >>> 24 ^ e[n]) & 255]) >>> 0;
|
|
4079
4081
|
return t;
|
|
4080
4082
|
}
|
|
4081
|
-
function
|
|
4083
|
+
function Sr(e, t, n, r, i) {
|
|
4082
4084
|
let a = [];
|
|
4083
4085
|
for (let t of e) {
|
|
4084
4086
|
let e = t.length;
|
|
@@ -4094,29 +4096,29 @@ function xr(e, t, n, r, i) {
|
|
|
4094
4096
|
], 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);
|
|
4095
4097
|
let l = 27 + a.length;
|
|
4096
4098
|
for (let t of e) s.set(t, l), l += t.length;
|
|
4097
|
-
return c.setUint32(22,
|
|
4099
|
+
return c.setUint32(22, xr(s), !0), s;
|
|
4098
4100
|
}
|
|
4099
|
-
function
|
|
4101
|
+
function Cr(e) {
|
|
4100
4102
|
let t = /* @__PURE__ */ new Uint8Array(19), n = new DataView(t.buffer);
|
|
4101
4103
|
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;
|
|
4102
4104
|
}
|
|
4103
|
-
function
|
|
4105
|
+
function wr() {
|
|
4104
4106
|
let e = new TextEncoder().encode("chat-island"), t = new Uint8Array(12 + e.length + 4);
|
|
4105
4107
|
return t.set(new TextEncoder().encode("OpusTags"), 0), new DataView(t.buffer).setUint32(8, e.length, !0), t.set(e, 12), t;
|
|
4106
4108
|
}
|
|
4107
|
-
function
|
|
4108
|
-
let { head: t, channels: n, packets: r } =
|
|
4109
|
+
function Tr(e) {
|
|
4110
|
+
let { head: t, channels: n, packets: r } = vr(e);
|
|
4109
4111
|
if (!r.length) return null;
|
|
4110
|
-
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [
|
|
4112
|
+
let i = t && t.length >= 19 && new TextDecoder().decode(t.slice(0, 8)) === "OpusHead", a = Math.random() * 4294967295 >>> 0, o = [Sr([i ? t : Cr(n)], 0, a, 0, 2), Sr([wr()], 0, a, 1, 0)], s = 0, c = 2;
|
|
4111
4113
|
for (let e = 0; e < r.length;) {
|
|
4112
4114
|
let t = [], n = 0;
|
|
4113
4115
|
for (; e < r.length && t.length < 50;) {
|
|
4114
4116
|
let i = Math.floor(r[e].length / 255) + 1;
|
|
4115
4117
|
if (n + i > 255) break;
|
|
4116
|
-
t.push(r[e]), n += i, s +=
|
|
4118
|
+
t.push(r[e]), n += i, s += yr(r[e]), e++;
|
|
4117
4119
|
}
|
|
4118
4120
|
if (!t.length) return null;
|
|
4119
|
-
o.push(
|
|
4121
|
+
o.push(Sr(t, s, a, c++, e >= r.length ? 4 : 0));
|
|
4120
4122
|
}
|
|
4121
4123
|
let l = o.reduce((e, t) => e + t.length, 0), u = new Uint8Array(l), d = 0;
|
|
4122
4124
|
for (let e of o) u.set(e, d), d += e.length;
|
|
@@ -4124,22 +4126,22 @@ function wr(e) {
|
|
|
4124
4126
|
}
|
|
4125
4127
|
//#endregion
|
|
4126
4128
|
//#region src/components/Composer.tsx
|
|
4127
|
-
var
|
|
4129
|
+
var Er = [
|
|
4128
4130
|
"audio/ogg;codecs=opus",
|
|
4129
4131
|
"audio/webm;codecs=opus",
|
|
4130
4132
|
"audio/mp4",
|
|
4131
4133
|
"audio/webm"
|
|
4132
4134
|
];
|
|
4133
|
-
async function
|
|
4135
|
+
async function Dr(e, t) {
|
|
4134
4136
|
let n = Date.now();
|
|
4135
4137
|
if (/webm/.test(t) && /opus/.test(t)) try {
|
|
4136
|
-
let t =
|
|
4138
|
+
let t = Tr(new Uint8Array(await new Blob(e).arrayBuffer()));
|
|
4137
4139
|
if (t) return new File([t], `voice-${n}.ogg`, { type: "audio/ogg" });
|
|
4138
4140
|
} catch {}
|
|
4139
|
-
return new File(e, `voice-${n}.${
|
|
4141
|
+
return new File(e, `voice-${n}.${Or(t)}`, { type: t.split(";")[0] });
|
|
4140
4142
|
}
|
|
4141
|
-
var
|
|
4142
|
-
function
|
|
4143
|
+
var Or = (e) => /mp4/.test(e) ? "m4a" : /ogg/.test(e) ? "ogg" : "webm", kr = (e) => `${Math.floor(e / 6e4)}:${String(Math.floor(e % 6e4 / 1e3)).padStart(2, "0")}`;
|
|
4144
|
+
function Ar({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
4143
4145
|
let [o, l] = c(""), [u, p] = c(!1), m = s(null), h = s(null), g = s(null), _ = s(), v = s(!1), [y, b] = c(null), [x, S] = c(0), C = s(!1), w = s(!1), T = s(!1), E = s({});
|
|
4144
4146
|
i(() => g.current?.focus(), []), i(() => () => {
|
|
4145
4147
|
T.current = !0, C.current = !0, window.clearTimeout(_.current);
|
|
@@ -4178,9 +4180,9 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4178
4180
|
t.getTracks().forEach((e) => e.stop());
|
|
4179
4181
|
return;
|
|
4180
4182
|
}
|
|
4181
|
-
let r =
|
|
4183
|
+
let r = Er.find((e) => MediaRecorder.isTypeSupported(e)), i = new MediaRecorder(e, r ? { mimeType: r } : void 0), a = [];
|
|
4182
4184
|
i.ondataavailable = (e) => e.data.size && a.push(e.data), i.onstop = () => {
|
|
4183
|
-
t.getTracks().forEach((e) => e.stop()), E.current = {}, b(null), !C.current && a.length &&
|
|
4185
|
+
t.getTracks().forEach((e) => e.stop()), E.current = {}, b(null), !C.current && a.length && Dr(a, i.mimeType || r || "").then(n);
|
|
4184
4186
|
}, C.current = !1, i.start(), E.current = {
|
|
4185
4187
|
r: i,
|
|
4186
4188
|
stream: t
|
|
@@ -4209,7 +4211,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4209
4211
|
}),
|
|
4210
4212
|
/* @__PURE__ */ f("div", {
|
|
4211
4213
|
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",
|
|
4212
|
-
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 ",
|
|
4214
|
+
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 ", kr(x)] })]
|
|
4213
4215
|
}),
|
|
4214
4216
|
/* @__PURE__ */ d(Z, {
|
|
4215
4217
|
variant: "green",
|
|
@@ -4223,7 +4225,7 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4223
4225
|
}) : /* @__PURE__ */ f("div", {
|
|
4224
4226
|
className: "ci-relative ci-flex ci-items-center ci-gap-2 ci-px-3 ci-py-3",
|
|
4225
4227
|
children: [
|
|
4226
|
-
u && /* @__PURE__ */ d(
|
|
4228
|
+
u && /* @__PURE__ */ d(er, {
|
|
4227
4229
|
className: "ci-absolute ci-bottom-full ci-left-3 ci-mb-1",
|
|
4228
4230
|
onPick: ee,
|
|
4229
4231
|
onClose: () => p(!1)
|
|
@@ -4289,14 +4291,14 @@ function kr({ onSend: e, onTyping: t, onFile: n, disabled: r }) {
|
|
|
4289
4291
|
}
|
|
4290
4292
|
//#endregion
|
|
4291
4293
|
//#region src/components/ChatWindow.tsx
|
|
4292
|
-
var
|
|
4294
|
+
var jr = (e) => !!e && ![
|
|
4293
4295
|
"offline",
|
|
4294
4296
|
"dnd",
|
|
4295
4297
|
"busy",
|
|
4296
4298
|
"ringing",
|
|
4297
4299
|
"onhold"
|
|
4298
4300
|
].includes(e);
|
|
4299
|
-
function
|
|
4301
|
+
function Mr({ peer: e, actions: t, onDragStart: n }) {
|
|
4300
4302
|
let { c: r, contacts: a, online: o, mobile: s, status: l, closeChat: p, openChat: m, markRead: h, order: g, me: _ } = J(w((t) => ({
|
|
4301
4303
|
c: t.conversations[e],
|
|
4302
4304
|
contacts: t.contacts,
|
|
@@ -4330,17 +4332,17 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4330
4332
|
className: `ci-flex ci-items-center ci-gap-3 ci-px-4 ci-py-3 ci-rounded-t-3xl ${n ? "ci-cursor-grab active:ci-cursor-grabbing ci-touch-none" : ""}`,
|
|
4331
4333
|
onPointerDown: n,
|
|
4332
4334
|
children: [
|
|
4333
|
-
r.kind === "group" ? /* @__PURE__ */ d(
|
|
4335
|
+
r.kind === "group" ? /* @__PURE__ */ d(Wn, {
|
|
4334
4336
|
name: r.name ?? e,
|
|
4335
4337
|
size: 36,
|
|
4336
4338
|
avatar: r.avatar
|
|
4337
4339
|
}) : /* @__PURE__ */ f("span", {
|
|
4338
4340
|
className: "ci-relative",
|
|
4339
|
-
children: [/* @__PURE__ */ d(
|
|
4341
|
+
children: [/* @__PURE__ */ d(Hn, {
|
|
4340
4342
|
contact: y,
|
|
4341
4343
|
username: e,
|
|
4342
4344
|
size: 36
|
|
4343
|
-
}), /* @__PURE__ */ d(
|
|
4345
|
+
}), /* @__PURE__ */ d(Un, {
|
|
4344
4346
|
online: o[e],
|
|
4345
4347
|
presence: y?.presence,
|
|
4346
4348
|
mobile: s[e]
|
|
@@ -4363,7 +4365,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4363
4365
|
children: l === "online" ? r.kind === "group" ? C.map(S).join(", ") : r.typing ? "typing…" : o[e] ? "online" : s[e] ? "Mobile" : "offline" : l
|
|
4364
4366
|
})]
|
|
4365
4367
|
}),
|
|
4366
|
-
r.kind !== "group" && y?.number &&
|
|
4368
|
+
r.kind !== "group" && y?.number && jr(y.presence) && /* @__PURE__ */ d(Z, {
|
|
4367
4369
|
variant: "call",
|
|
4368
4370
|
title: `Call ${y.number}`,
|
|
4369
4371
|
"aria-label": "Call",
|
|
@@ -4376,8 +4378,9 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4376
4378
|
/* @__PURE__ */ d(Z, {
|
|
4377
4379
|
variant: "small",
|
|
4378
4380
|
onClick: () => p(),
|
|
4379
|
-
"aria-label": "
|
|
4380
|
-
|
|
4381
|
+
"aria-label": "Minimize",
|
|
4382
|
+
title: "Minimize",
|
|
4383
|
+
children: Q.minus
|
|
4381
4384
|
})
|
|
4382
4385
|
]
|
|
4383
4386
|
}),
|
|
@@ -4389,11 +4392,11 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4389
4392
|
children: [
|
|
4390
4393
|
/* @__PURE__ */ f("span", {
|
|
4391
4394
|
className: "ci-relative",
|
|
4392
|
-
children: [/* @__PURE__ */ d(
|
|
4395
|
+
children: [/* @__PURE__ */ d(Hn, {
|
|
4393
4396
|
contact: a[e],
|
|
4394
4397
|
username: e,
|
|
4395
4398
|
size: 28
|
|
4396
|
-
}), e !== _ && /* @__PURE__ */ d(
|
|
4399
|
+
}), e !== _ && /* @__PURE__ */ d(Un, {
|
|
4397
4400
|
online: o[e],
|
|
4398
4401
|
presence: a[e]?.presence,
|
|
4399
4402
|
mobile: s[e]
|
|
@@ -4409,7 +4412,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4409
4412
|
"aria-label": "Chat",
|
|
4410
4413
|
onClick: () => m(e),
|
|
4411
4414
|
children: Q.chat
|
|
4412
|
-
}), a[e]?.number &&
|
|
4415
|
+
}), a[e]?.number && jr(a[e]?.presence) && /* @__PURE__ */ d(Z, {
|
|
4413
4416
|
variant: "call",
|
|
4414
4417
|
title: `Call ${a[e]?.number}`,
|
|
4415
4418
|
"aria-label": "Call",
|
|
@@ -4424,7 +4427,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4424
4427
|
}),
|
|
4425
4428
|
/* @__PURE__ */ f("div", {
|
|
4426
4429
|
className: "ci-flex-1 ci-min-h-0 ci-flex ci-flex-col ci-overflow-hidden ci-rounded-b-3xl",
|
|
4427
|
-
children: [/* @__PURE__ */ d(
|
|
4430
|
+
children: [/* @__PURE__ */ d(hr, {
|
|
4428
4431
|
messages: r.messages,
|
|
4429
4432
|
typing: r.typing,
|
|
4430
4433
|
group: r.kind === "group",
|
|
@@ -4433,7 +4436,7 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4433
4436
|
reactions: r.reactions,
|
|
4434
4437
|
me: _,
|
|
4435
4438
|
onReact: (n, r) => t.react(e, n, r)
|
|
4436
|
-
}), /* @__PURE__ */ d(
|
|
4439
|
+
}), /* @__PURE__ */ d(Ar, {
|
|
4437
4440
|
disabled: l !== "online",
|
|
4438
4441
|
onSend: (n) => t.send(e, n),
|
|
4439
4442
|
onTyping: (n) => t.typing(e, n),
|
|
@@ -4445,11 +4448,11 @@ function jr({ peer: e, actions: t, onDragStart: n }) {
|
|
|
4445
4448
|
}
|
|
4446
4449
|
//#endregion
|
|
4447
4450
|
//#region src/components/NewChat.tsx
|
|
4448
|
-
async function
|
|
4451
|
+
async function Nr(e) {
|
|
4449
4452
|
let t = await createImageBitmap(e), n = Math.min(t.width, t.height), r = document.createElement("canvas");
|
|
4450
4453
|
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);
|
|
4451
4454
|
}
|
|
4452
|
-
function
|
|
4455
|
+
function Pr({ onOpen: e, onCreateGroup: t }) {
|
|
4453
4456
|
let { contacts: n, online: r, mobile: i, setPicker: a } = J(), [l, p] = c(""), [m, h] = c([]), [g, _] = c(""), [v, y] = c(!1), [b, x] = c(), S = s(null), C = o(() => {
|
|
4454
4457
|
let e = Object.values(n), t = l.trim().toLowerCase();
|
|
4455
4458
|
return t ? e.filter((e) => (e.name ?? "").toLowerCase().includes(t) || e.username.includes(t)) : e;
|
|
@@ -4506,11 +4509,11 @@ function Nr({ onOpen: e, onCreateGroup: t }) {
|
|
|
4506
4509
|
children: [
|
|
4507
4510
|
/* @__PURE__ */ f("span", {
|
|
4508
4511
|
className: "ci-relative",
|
|
4509
|
-
children: [/* @__PURE__ */ d(
|
|
4512
|
+
children: [/* @__PURE__ */ d(Hn, {
|
|
4510
4513
|
contact: e,
|
|
4511
4514
|
username: e.username,
|
|
4512
4515
|
size: 36
|
|
4513
|
-
}), /* @__PURE__ */ d(
|
|
4516
|
+
}), /* @__PURE__ */ d(Un, {
|
|
4514
4517
|
online: r[e.username],
|
|
4515
4518
|
presence: e.presence,
|
|
4516
4519
|
mobile: i[e.username]
|
|
@@ -4557,7 +4560,7 @@ function Nr({ onOpen: e, onCreateGroup: t }) {
|
|
|
4557
4560
|
type: "file",
|
|
4558
4561
|
accept: "image/*",
|
|
4559
4562
|
hidden: !0,
|
|
4560
|
-
onChange: (e) => e.target.files?.[0] &&
|
|
4563
|
+
onChange: (e) => e.target.files?.[0] && Nr(e.target.files[0]).then(x).catch(() => {})
|
|
4561
4564
|
}),
|
|
4562
4565
|
/* @__PURE__ */ d("button", {
|
|
4563
4566
|
type: "button",
|
|
@@ -4592,22 +4595,22 @@ function Nr({ onOpen: e, onCreateGroup: t }) {
|
|
|
4592
4595
|
}
|
|
4593
4596
|
//#endregion
|
|
4594
4597
|
//#region src/theme.ts
|
|
4595
|
-
var
|
|
4598
|
+
var Fr = "chat-island-theme", Ir = () => {
|
|
4596
4599
|
try {
|
|
4597
|
-
let e = localStorage.getItem(
|
|
4600
|
+
let e = localStorage.getItem(Fr);
|
|
4598
4601
|
return e === "light" || e === "dark" || e === "system" ? e : void 0;
|
|
4599
4602
|
} catch {
|
|
4600
4603
|
return;
|
|
4601
4604
|
}
|
|
4602
4605
|
};
|
|
4603
|
-
function
|
|
4604
|
-
let [t, n] = c(() => e ??
|
|
4605
|
-
return i(() => n(e ??
|
|
4606
|
+
function Lr(e) {
|
|
4607
|
+
let [t, n] = c(() => e ?? Ir()), [r, a] = c(!1);
|
|
4608
|
+
return i(() => n(e ?? Ir()), [e]), i(() => {
|
|
4606
4609
|
let e = (e) => {
|
|
4607
4610
|
let t = e.detail?.theme;
|
|
4608
4611
|
if (t === "light" || t === "dark" || t === "system") {
|
|
4609
4612
|
try {
|
|
4610
|
-
localStorage.setItem(
|
|
4613
|
+
localStorage.setItem(Fr, t);
|
|
4611
4614
|
} catch {}
|
|
4612
4615
|
n(t);
|
|
4613
4616
|
}
|
|
@@ -4633,7 +4636,7 @@ function Ir(e) {
|
|
|
4633
4636
|
}
|
|
4634
4637
|
//#endregion
|
|
4635
4638
|
//#region src/ChatIsland.tsx
|
|
4636
|
-
function
|
|
4639
|
+
function Rr() {
|
|
4637
4640
|
let e = J.getState();
|
|
4638
4641
|
return Object.values(e.conversations).map((t) => {
|
|
4639
4642
|
let n = t.messages[t.messages.length - 1], r = e.contacts[t.peer];
|
|
@@ -4648,7 +4651,7 @@ function Lr() {
|
|
|
4648
4651
|
unread: t.unread,
|
|
4649
4652
|
members: t.members,
|
|
4650
4653
|
last: n ? {
|
|
4651
|
-
body:
|
|
4654
|
+
body: Vr(n.body),
|
|
4652
4655
|
ts: n.ts,
|
|
4653
4656
|
mine: n.mine,
|
|
4654
4657
|
oob: n.oob,
|
|
@@ -4657,7 +4660,7 @@ function Lr() {
|
|
|
4657
4660
|
};
|
|
4658
4661
|
}).filter((e) => e.last || e.kind === "group").sort((e, t) => (t.last?.ts ?? 0) - (e.last?.ts ?? 0));
|
|
4659
4662
|
}
|
|
4660
|
-
var
|
|
4663
|
+
var zr = class extends t {
|
|
4661
4664
|
state = { failed: !1 };
|
|
4662
4665
|
failures = [];
|
|
4663
4666
|
static getDerivedStateFromError() {
|
|
@@ -4675,7 +4678,7 @@ var Rr = class extends t {
|
|
|
4675
4678
|
return this.state.failed ? null : this.props.children;
|
|
4676
4679
|
}
|
|
4677
4680
|
};
|
|
4678
|
-
function
|
|
4681
|
+
function Br(e) {
|
|
4679
4682
|
try {
|
|
4680
4683
|
let [t, n, r] = atob(e).split(":");
|
|
4681
4684
|
return t && n && r ? {
|
|
@@ -4687,9 +4690,9 @@ function zr(e) {
|
|
|
4687
4690
|
return null;
|
|
4688
4691
|
}
|
|
4689
4692
|
}
|
|
4690
|
-
var
|
|
4691
|
-
function
|
|
4692
|
-
let g = o(() =>
|
|
4693
|
+
var Vr = (e) => (cr(e) ? "Attachment" : $(e)).replace(/```[^\n]*\n?/g, "").replace(/(\*\*|__|~~|`)/g, "").replace(/(^|\s)[*_](\S[^*_]*)[*_]/g, "$1$2").replace(/\s+/g, " ").trim();
|
|
4694
|
+
function Hr({ 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 }) {
|
|
4695
|
+
let g = o(() => Br(e), [e]), _ = Lr(n), v = s(g), y = s(p), b = s(u);
|
|
4693
4696
|
i(() => {
|
|
4694
4697
|
v.current = g, y.current = p, b.current = u;
|
|
4695
4698
|
}, [
|
|
@@ -4752,7 +4755,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4752
4755
|
if (!t || !n) return;
|
|
4753
4756
|
let r = J.getState().conversations[e];
|
|
4754
4757
|
try {
|
|
4755
|
-
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await
|
|
4758
|
+
r?.kind === "group" && await t.leaveGroup(e, !!r.owner).catch(() => {}), await In(n.host, n.token, e), J.getState().removeConversation(e);
|
|
4756
4759
|
} catch (e) {
|
|
4757
4760
|
Y("chat-island-error", {
|
|
4758
4761
|
scope: "delete",
|
|
@@ -4821,6 +4824,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4821
4824
|
typing: (t, n) => e.setTyping(t, n),
|
|
4822
4825
|
reaction: (t) => e.applyReactions([t]),
|
|
4823
4826
|
presence: (t, n) => e.setOnline(t, n),
|
|
4827
|
+
groupDestroyed: (t) => e.removeConversation(t),
|
|
4824
4828
|
groupInvite: (n) => {
|
|
4825
4829
|
t.subscribed(n).then(async (r) => {
|
|
4826
4830
|
if (!r) return;
|
|
@@ -4829,7 +4833,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4829
4833
|
}).catch(() => {});
|
|
4830
4834
|
},
|
|
4831
4835
|
message: (r) => {
|
|
4832
|
-
let i =
|
|
4836
|
+
let i = jn(r);
|
|
4833
4837
|
r.room && !J.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 }), Y("chat-island-message", {
|
|
4834
4838
|
...r,
|
|
4835
4839
|
peer: i
|
|
@@ -4839,7 +4843,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4839
4843
|
let n = J.getState(), r = document.visibilityState === "visible";
|
|
4840
4844
|
if (r && n.open === e) return;
|
|
4841
4845
|
let i = n.conversations[e], a = i?.kind === "group" ? i.name ?? e : n.contacts[e]?.name ?? e, o = t.oob ? "Attachment" : $(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;
|
|
4842
|
-
y.current &&
|
|
4846
|
+
y.current && Sn();
|
|
4843
4847
|
let u = s ? i?.avatar : n.contacts[e]?.avatar;
|
|
4844
4848
|
if (Y("chat-island-notify", {
|
|
4845
4849
|
peer: e,
|
|
@@ -4863,7 +4867,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4863
4867
|
};
|
|
4864
4868
|
C.current = t;
|
|
4865
4869
|
let i = () => {
|
|
4866
|
-
r && !D.current && (D.current = !0,
|
|
4870
|
+
r && !D.current && (D.current = !0, Bn(g, r).then((e) => {
|
|
4867
4871
|
if (!e) {
|
|
4868
4872
|
D.current = !1, J.setState({ push: Notification.permission === "denied" ? "denied" : "ask" });
|
|
4869
4873
|
return;
|
|
@@ -4884,14 +4888,14 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4884
4888
|
});
|
|
4885
4889
|
let s = () => t.stop();
|
|
4886
4890
|
window.addEventListener("pagehide", s), t.start();
|
|
4887
|
-
let c = () =>
|
|
4891
|
+
let c = () => Fn(g.host, g.token).then(e.setMobile).catch(() => {});
|
|
4888
4892
|
c();
|
|
4889
4893
|
let u = window.setInterval(c, 12e4);
|
|
4890
|
-
|
|
4894
|
+
Pn(g.host, g.token, g.username).then(e.setContacts).catch((e) => Y("chat-island-error", {
|
|
4891
4895
|
scope: "contacts",
|
|
4892
4896
|
message: e.message
|
|
4893
4897
|
}));
|
|
4894
|
-
let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && ne.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations:
|
|
4898
|
+
let d = X("chat-island-open", ({ username: t }) => t && e.openChat(t)), f = X("chat-island-close", () => e.closeChat()), p = X("chat-island-new", () => e.setPicker(!0)), m = X("chat-island-delete", ({ username: e }) => e && ne.remove(e)), h = X("chat-island-contacts", ({ contacts: t }) => t && e.setContacts(t)), _ = X("chat-island-conversations-request", () => Y("chat-island-conversations", { conversations: Rr() }));
|
|
4895
4899
|
return () => {
|
|
4896
4900
|
window.removeEventListener("pagehide", s), window.clearInterval(u), _(), p(), m(), d(), f(), h(), O.current && t.disablePush(O.current.service, O.current.node).catch(() => {}), O.current = null, t.stop(), C.current = null, D.current = !1;
|
|
4897
4901
|
};
|
|
@@ -4905,7 +4909,7 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4905
4909
|
j === "online" && M && C.current?.announce(M.split(","));
|
|
4906
4910
|
}, [j, M]);
|
|
4907
4911
|
let re = J((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);
|
|
4908
|
-
i(() => Y("chat-island-conversations", { conversations:
|
|
4912
|
+
i(() => Y("chat-island-conversations", { conversations: Rr() }), [re]);
|
|
4909
4913
|
let ie = J((e) => Object.values(e.conversations).reduce((e, t) => e + t.unread, 0));
|
|
4910
4914
|
if (i(() => Y("chat-island-unread", { total: ie }), [ie]), !g) return null;
|
|
4911
4915
|
let ae = m && !h && k.anchor ? {
|
|
@@ -4918,17 +4922,17 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4918
4922
|
onClickCapture: k.onClickCapture,
|
|
4919
4923
|
className: `chat-island-root ${_ ? "ci-dark" : ""} ci-fixed ${oe} ci-z-[9999] ci-flex ci-items-end ci-gap-3 ci-font-sans ci-select-none`,
|
|
4920
4924
|
"data-status": j,
|
|
4921
|
-
children: /* @__PURE__ */ f(
|
|
4922
|
-
te && /* @__PURE__ */ d(
|
|
4925
|
+
children: /* @__PURE__ */ f(zr, { children: [
|
|
4926
|
+
te && /* @__PURE__ */ d(Mr, {
|
|
4923
4927
|
peer: te,
|
|
4924
4928
|
actions: ne,
|
|
4925
4929
|
onDragStart: h ?? (m ? k.start : void 0)
|
|
4926
4930
|
}),
|
|
4927
|
-
A && /* @__PURE__ */ d(
|
|
4931
|
+
A && /* @__PURE__ */ d(Pr, {
|
|
4928
4932
|
onOpen: (e) => J.getState().openChat(e),
|
|
4929
4933
|
onCreateGroup: ne.createGroup
|
|
4930
4934
|
}),
|
|
4931
|
-
/* @__PURE__ */ d(
|
|
4935
|
+
/* @__PURE__ */ d(qn, {
|
|
4932
4936
|
onDragStart: h ?? (m ? k.start : void 0),
|
|
4933
4937
|
pushButton: u !== "auto"
|
|
4934
4938
|
})
|
|
@@ -4936,4 +4940,4 @@ function Vr({ dataConfig: e, position: t = "bottom-right", theme: n, serviceWork
|
|
|
4936
4940
|
});
|
|
4937
4941
|
}
|
|
4938
4942
|
//#endregion
|
|
4939
|
-
export {
|
|
4943
|
+
export { Hr as ChatIsland };
|