@paramms/chat-widget 1.0.45 → 1.0.46
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/chatlist.d.ts +1 -0
- package/dist/chatlist.js +29 -25
- package/dist/chatlist.js.map +1 -1
- package/dist/embed-lite.js +3 -3
- package/dist/embed-lite.js.map +1 -1
- package/dist/embed.d.ts +2 -0
- package/dist/embed.js +3 -3
- package/dist/embed.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +95 -88
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +6 -3
- package/dist/react.js +319 -307
- package/dist/react.js.map +1 -1
- package/dist/renderer.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface MountOptions {
|
|
|
52
52
|
accent2?: string;
|
|
53
53
|
/** Colour scheme: 'auto' (follow OS, default), 'light', or 'dark'. */
|
|
54
54
|
theme?: 'auto' | 'light' | 'dark';
|
|
55
|
+
/** Load Baloo 2 + Nunito webfonts (default true). false = system fonts only. */
|
|
56
|
+
webfont?: boolean;
|
|
55
57
|
/** Stack navigation: when set, the chatroom header shows a back chevron that
|
|
56
58
|
* calls this. Used by `<ChatApp>` so tapping a conversation opens the room and
|
|
57
59
|
* the back arrow returns to the list — native-app style. */
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var $e = (t, e, l) => e in t ?
|
|
1
|
+
var Be = Object.defineProperty;
|
|
2
|
+
var $e = (t, e, l) => e in t ? Be(t, e, { enumerable: !0, configurable: !0, writable: !0, value: l }) : t[e] = l;
|
|
3
3
|
var T = (t, e, l) => $e(t, typeof e != "symbol" ? e + "" : e, l);
|
|
4
|
-
import { l as
|
|
5
|
-
import { h as
|
|
6
|
-
import { P as
|
|
7
|
-
import { e as
|
|
8
|
-
import { E2ESession as
|
|
9
|
-
const
|
|
10
|
-
.ocw { ${
|
|
4
|
+
import { l as Me, b as ge, p as Re, r as Ae, a as qe } from "./codec.js";
|
|
5
|
+
import { h as st } from "./codec.js";
|
|
6
|
+
import { P as Ne, C as Oe, b as De } from "./outbox.js";
|
|
7
|
+
import { e as dt } from "./outbox.js";
|
|
8
|
+
import { E2ESession as He, extractX3DHInit as _e } from "./e2e.js";
|
|
9
|
+
const Ue = `
|
|
10
|
+
.ocw { ${Me("ocw")}
|
|
11
11
|
position:relative;
|
|
12
12
|
display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
|
|
13
13
|
font-family:var(--ocw-fb); color:var(--ocw-ink); overflow:hidden; }
|
|
@@ -197,17 +197,23 @@ const _e = `
|
|
|
197
197
|
.ocw-row.theirs .ocw-translate-btn { right:auto; left:-26px; }
|
|
198
198
|
.ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
|
|
199
199
|
.ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
|
|
200
|
-
`, ye = "objectchat-widget-styles",
|
|
201
|
-
function
|
|
200
|
+
`, ye = "objectchat-widget-styles", Fe = ["👍", "❤️", "😂", "😮", "😢", "🙏"], We = 400, Ge = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
201
|
+
function Ke() {
|
|
202
202
|
if (typeof document > "u" || document.getElementById(ye)) return;
|
|
203
203
|
const t = document.createElement("style");
|
|
204
|
-
t.id = ye, t.textContent =
|
|
204
|
+
t.id = ye, t.textContent = Ue, document.head.appendChild(t);
|
|
205
|
+
}
|
|
206
|
+
const ve = "ocw-webfont";
|
|
207
|
+
function Ve() {
|
|
208
|
+
if (typeof document > "u" || document.getElementById(ve)) return;
|
|
209
|
+
const t = document.createElement("link");
|
|
210
|
+
t.id = ve, t.rel = "stylesheet", t.href = "https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap", document.head.appendChild(t);
|
|
205
211
|
}
|
|
206
212
|
function n(t, e, l) {
|
|
207
213
|
const c = document.createElement(t);
|
|
208
214
|
return e && (c.className = e), l !== void 0 && (c.textContent = l), c;
|
|
209
215
|
}
|
|
210
|
-
function
|
|
216
|
+
function Ye(t) {
|
|
211
217
|
try {
|
|
212
218
|
return new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
213
219
|
} catch {
|
|
@@ -231,7 +237,7 @@ function ae(t) {
|
|
|
231
237
|
return `📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`;
|
|
232
238
|
}
|
|
233
239
|
}
|
|
234
|
-
class
|
|
240
|
+
class Xe {
|
|
235
241
|
/** Last seq the guest has seen per conversationId — used to compute unread badges. */
|
|
236
242
|
constructor(e, l, c, i = {}) {
|
|
237
243
|
T(this, "scroll");
|
|
@@ -268,8 +274,8 @@ class Ve {
|
|
|
268
274
|
/** Whether the subject card (server Subject entity, mount config fallback)
|
|
269
275
|
* has been built — built once when data first arrives. */
|
|
270
276
|
T(this, "subjectBuilt", !1);
|
|
271
|
-
var r, C, v, u, f, R,
|
|
272
|
-
this.root = e, this.me = l, this.h = c, this.cfg = i,
|
|
277
|
+
var r, C, v, u, f, R, B, A, k, S, D;
|
|
278
|
+
this.root = e, this.me = l, this.h = c, this.cfg = i, Ke(), i.webfont !== !1 && Ve(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
|
|
273
279
|
const x = i.accent2 ?? i.accent;
|
|
274
280
|
x && e.style.setProperty("--ocw-accent2", x), this.cfgAccent2 = i.accent2, i.theme && i.theme !== "auto" && (e.dataset.theme = i.theme);
|
|
275
281
|
const w = n("div", "ocw-head");
|
|
@@ -285,7 +291,7 @@ class Ve {
|
|
|
285
291
|
y.textContent = (C = i.userInfo) != null && C.name ? i.userInfo.name[0].toUpperCase() : "🧑";
|
|
286
292
|
w.append(y);
|
|
287
293
|
const p = n("div", "ocw-head-main");
|
|
288
|
-
this.headerName = n("div", "ocw-head-name", ((v = i.subject) == null ? void 0 : v.ownerLabel) ?? ((u = i.subject) == null ? void 0 : u.title) ?? ""), p.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", p.append(this.headStatus), (f = i.subject) != null && f.subtitle && p.append(n("div", "ocw-head-meta", i.subject.subtitle)), w.append(p), this.statusBadge = n("span", "ocw-badge", ((R = i.subject) == null ? void 0 : R.status) ?? ""), (
|
|
294
|
+
this.headerName = n("div", "ocw-head-name", ((v = i.subject) == null ? void 0 : v.ownerLabel) ?? ((u = i.subject) == null ? void 0 : u.title) ?? ""), p.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", p.append(this.headStatus), (f = i.subject) != null && f.subtitle && p.append(n("div", "ocw-head-meta", i.subject.subtitle)), w.append(p), this.statusBadge = n("span", "ocw-badge", ((R = i.subject) == null ? void 0 : R.status) ?? ""), (B = i.subject) != null && B.status || (this.statusBadge.style.display = "none"), w.append(this.statusBadge), this.e2eBadge = n("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", w.append(this.e2eBadge), this.connStatus = n("span", "ocw-conn-status"), this.connStatus.style.display = "none", w.append(this.connStatus), w.append(n("button", "ocw-menu", "⋯")), this.chips = n("div", "ocw-chiprow"), this.scroll = n("div", "ocw-scroll"), this.subjectCard = n("div", "ocw-subject"), this.typing = n("div", "ocw-typing");
|
|
289
295
|
const h = n("div", "ocw-typing-bubble");
|
|
290
296
|
h.append(n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot")), this.typing.append(n("div", "ocw-dot", "🧑"), h), this.quick = n("div", "ocw-quick");
|
|
291
297
|
for (const g of i.quickReplies ?? []) {
|
|
@@ -298,7 +304,7 @@ class Ve {
|
|
|
298
304
|
const b = n("button", "ocw-sendbtn");
|
|
299
305
|
b.type = "button";
|
|
300
306
|
const a = (k = i.i18n) == null ? void 0 : k.send;
|
|
301
|
-
a ? (b.textContent = a, b.classList.add("ocw-sendbtn-label"), b.setAttribute("aria-label", a)) : (b.innerHTML =
|
|
307
|
+
a ? (b.textContent = a, b.classList.add("ocw-sendbtn-label"), b.setAttribute("aria-label", a)) : (b.innerHTML = Ge, b.setAttribute("aria-label", "Send message")), b.disabled = !0, this.sendBtn = b, b.addEventListener("click", () => this.flushSend()), this.input.addEventListener("input", () => {
|
|
302
308
|
var g, N;
|
|
303
309
|
this.sendBtn.disabled = this.input.value.trim().length === 0, this.autoGrowInput(), this.storeRef && !this.storeRef.messages().some((H) => H.senderRole === "guest") ? (N = (g = this.h).onDeflectQuery) == null || N.call(g, this.input.value) : this.hideDeflection();
|
|
304
310
|
}), this.input.addEventListener("keydown", (g) => {
|
|
@@ -320,7 +326,7 @@ class Ve {
|
|
|
320
326
|
g == null || g.focus();
|
|
321
327
|
}), e.append(w, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.preChatPanel, this.deflectPanel, this.awayNotice, M, this.reopenBtn, this.footer);
|
|
322
328
|
const d = (g) => {
|
|
323
|
-
e.classList.toggle("ocw-compact", g > 0 && g <
|
|
329
|
+
e.classList.toggle("ocw-compact", g > 0 && g < We);
|
|
324
330
|
};
|
|
325
331
|
d(e.clientWidth), typeof ResizeObserver < "u" && (this.compactObserver = new ResizeObserver((g) => {
|
|
326
332
|
var H;
|
|
@@ -639,10 +645,10 @@ class Ve {
|
|
|
639
645
|
f.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
|
|
640
646
|
const R = n("button", "ocw-form-cancel", "Cancel");
|
|
641
647
|
R.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
|
|
642
|
-
const
|
|
643
|
-
|
|
648
|
+
const B = n("div");
|
|
649
|
+
B.style.cssText = "display:flex;gap:6px;justify-content:flex-end", B.append(R, f);
|
|
644
650
|
const A = n("div");
|
|
645
|
-
A.append(u,
|
|
651
|
+
A.append(u, B), h.replaceChildren(A), u.focus(), u.select();
|
|
646
652
|
const k = () => h.replaceChildren(b ?? document.createTextNode(v));
|
|
647
653
|
R.addEventListener("click", k), f.addEventListener("click", () => {
|
|
648
654
|
const S = u.value.trim();
|
|
@@ -666,18 +672,18 @@ class Ve {
|
|
|
666
672
|
for (const [u, f] of Object.entries(e.reactions)) {
|
|
667
673
|
const R = n("button", `ocw-react-pill${f.includes(this.me) ? " mine" : ""}`, `${u} ${f.length}`);
|
|
668
674
|
R.addEventListener("click", () => {
|
|
669
|
-
var
|
|
670
|
-
return (A = (
|
|
675
|
+
var B, A;
|
|
676
|
+
return (A = (B = this.h).onReact) == null ? void 0 : A.call(B, e.id, u, f.includes(this.me));
|
|
671
677
|
}), r.append(R);
|
|
672
678
|
}
|
|
673
679
|
const C = n("button", "ocw-react-btn", "+"), v = n("div", "ocw-react-picker");
|
|
674
|
-
for (const u of
|
|
680
|
+
for (const u of Fe) {
|
|
675
681
|
const f = n("button", void 0, u);
|
|
676
682
|
f.addEventListener("click", (R) => {
|
|
677
683
|
var A, k, S, D;
|
|
678
684
|
R.stopPropagation();
|
|
679
|
-
const
|
|
680
|
-
(D = (S = this.h).onReact) == null || D.call(S, e.id, u,
|
|
685
|
+
const B = (k = (A = e.reactions) == null ? void 0 : A[u]) == null ? void 0 : k.includes(this.me);
|
|
686
|
+
(D = (S = this.h).onReact) == null || D.call(S, e.id, u, !!B), v.style.display = "none";
|
|
681
687
|
}), v.append(f);
|
|
682
688
|
}
|
|
683
689
|
v.style.display = "none", C.addEventListener("click", (u) => {
|
|
@@ -688,15 +694,15 @@ class Ve {
|
|
|
688
694
|
}, { once: !0 });
|
|
689
695
|
}), r.append(C), d.append(r, v), y.append(d);
|
|
690
696
|
} else e.reactions && Object.keys(e.reactions).length && y.append(n("div", "ocw-react", Object.entries(e.reactions).map(([d, r]) => `${d}${r.length}`).join(" ")));
|
|
691
|
-
const a = n("div", "ocw-time ocw-meta",
|
|
697
|
+
const a = n("div", "ocw-time ocw-meta", Ye(e.ts));
|
|
692
698
|
if (i && e.status) {
|
|
693
|
-
const d = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`,
|
|
699
|
+
const d = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Qe(e.status));
|
|
694
700
|
a.append(d);
|
|
695
701
|
}
|
|
696
702
|
return i && e.seq > 0 && l.lastReadByOthers >= e.seq && a.append(n("span", "ocw-seen", " · Seen")), y.append(a), w.append(y), w;
|
|
697
703
|
}
|
|
698
704
|
}
|
|
699
|
-
function
|
|
705
|
+
function Qe(t) {
|
|
700
706
|
switch (t) {
|
|
701
707
|
case "read":
|
|
702
708
|
return "✓✓";
|
|
@@ -709,11 +715,11 @@ function Ye(t) {
|
|
|
709
715
|
}
|
|
710
716
|
}
|
|
711
717
|
const _ = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
|
|
712
|
-
function
|
|
718
|
+
function ke(t) {
|
|
713
719
|
return `relay-launcher::${t.profileId}::${t.subjectId ?? ""}`;
|
|
714
720
|
}
|
|
715
721
|
let K = null;
|
|
716
|
-
function
|
|
722
|
+
function Je() {
|
|
717
723
|
if (K && K.state !== "closed") return K;
|
|
718
724
|
try {
|
|
719
725
|
return K = new AudioContext(), K;
|
|
@@ -721,18 +727,18 @@ function Xe() {
|
|
|
721
727
|
return null;
|
|
722
728
|
}
|
|
723
729
|
}
|
|
724
|
-
function
|
|
730
|
+
function it(t) {
|
|
725
731
|
var e;
|
|
726
732
|
(e = _.get(t)) == null || e.close(), _.delete(t);
|
|
727
733
|
}
|
|
728
|
-
function
|
|
734
|
+
function at(t) {
|
|
729
735
|
var se, le, de, pe, he, ue, fe, we;
|
|
730
|
-
_.has(t.el) && (_.get(t.el).close(), _.delete(t.el)), t.launcher && ((se = Z.get(
|
|
731
|
-
const e =
|
|
736
|
+
_.has(t.el) && (_.get(t.el).close(), _.delete(t.el)), t.launcher && ((se = Z.get(ke(t))) == null || se.close());
|
|
737
|
+
const e = Re();
|
|
732
738
|
let l, c = !1;
|
|
733
|
-
const i = t.token ?? t.userId ?? e, x = i !== e ? e : void 0, { wsUrl: w, httpBase: y } =
|
|
734
|
-
let p = new
|
|
735
|
-
const h = t.subjectId ? `${i}::${t.subjectId}` : i, b = new
|
|
739
|
+
const i = t.token ?? t.userId ?? e, x = i !== e ? e : void 0, { wsUrl: w, httpBase: y } = Ae(t.url, t.apiUrl);
|
|
740
|
+
let p = new Oe(i);
|
|
741
|
+
const h = t.subjectId ? `${i}::${t.subjectId}` : i, b = new Ne(h);
|
|
736
742
|
let a, P = !1, I = null, M = null, j = null, d = null;
|
|
737
743
|
!t.launcher && !t.el.style.height && t.el.clientHeight === 0 && (t.el.style.width = t.el.style.width || "100%", t.el.style.height = "600px");
|
|
738
744
|
for (const o of b.load()) p.addOptimistic(o.clientMsgId, o.content);
|
|
@@ -793,15 +799,15 @@ function ot(t) {
|
|
|
793
799
|
Q(), r.append(m, q), document.body.append(r);
|
|
794
800
|
const te = `ocw-teaser-dismissed::${t.profileId}`, J = typeof t.launcherMessage == "string" ? { title: t.launcherMessage } : t.launcherMessage;
|
|
795
801
|
let E = null;
|
|
796
|
-
const
|
|
802
|
+
const Le = () => {
|
|
797
803
|
try {
|
|
798
804
|
return sessionStorage.getItem(te) === "1";
|
|
799
805
|
} catch {
|
|
800
806
|
return !1;
|
|
801
807
|
}
|
|
802
|
-
},
|
|
808
|
+
}, Pe = '<svg viewBox="0 0 24 24" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>', be = () => {
|
|
803
809
|
const z = J != null && J.title ? J : p.launcherMessage ?? void 0;
|
|
804
|
-
if (!(!!(z != null && z.title) && !u && !
|
|
810
|
+
if (!(!!(z != null && z.title) && !u && !Le())) {
|
|
805
811
|
E && (E.remove(), E = null);
|
|
806
812
|
return;
|
|
807
813
|
}
|
|
@@ -823,7 +829,7 @@ function ot(t) {
|
|
|
823
829
|
const O = document.createElement("div");
|
|
824
830
|
O.style.cssText = "display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";
|
|
825
831
|
const ie = document.createElement("span");
|
|
826
|
-
ie.innerHTML =
|
|
832
|
+
ie.innerHTML = Pe, ie.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
|
|
827
833
|
const me = document.createElement("span");
|
|
828
834
|
me.textContent = z.subtitle, O.append(ie, me), E.append(O);
|
|
829
835
|
}
|
|
@@ -872,7 +878,7 @@ function ot(t) {
|
|
|
872
878
|
u || (v++, C && (C.textContent = String(v), C.style.display = "flex"));
|
|
873
879
|
}, R = () => {
|
|
874
880
|
try {
|
|
875
|
-
const o =
|
|
881
|
+
const o = Je();
|
|
876
882
|
if (!o) return;
|
|
877
883
|
o.state === "suspended" && o.resume().catch(() => {
|
|
878
884
|
});
|
|
@@ -880,14 +886,14 @@ function ot(t) {
|
|
|
880
886
|
s.connect(m), m.connect(o.destination), s.frequency.setValueAtTime(880, o.currentTime), s.frequency.exponentialRampToValueAtTime(440, o.currentTime + 0.15), m.gain.setValueAtTime(0.3, o.currentTime), m.gain.exponentialRampToValueAtTime(1e-3, o.currentTime + 0.3), s.start(), s.stop(o.currentTime + 0.3);
|
|
881
887
|
} catch {
|
|
882
888
|
}
|
|
883
|
-
},
|
|
884
|
-
for (;
|
|
885
|
-
const s =
|
|
889
|
+
}, B = [], A = (o) => {
|
|
890
|
+
for (; B.length; ) {
|
|
891
|
+
const s = B.shift();
|
|
886
892
|
b.add({ clientMsgId: s.clientMsgId, content: s.content, ts: Date.now() }), k.send({ type: "send", conversationId: o, clientMsgId: s.clientMsgId, content: s.content });
|
|
887
893
|
}
|
|
888
894
|
};
|
|
889
895
|
let k;
|
|
890
|
-
const S = new
|
|
896
|
+
const S = new He(`ocw-e2e-${t.profileId}`);
|
|
891
897
|
let D = !1;
|
|
892
898
|
const g = [], N = [];
|
|
893
899
|
let H = !1;
|
|
@@ -895,11 +901,11 @@ function ot(t) {
|
|
|
895
901
|
S.sealText(s).then((m) => {
|
|
896
902
|
a && k.send({ type: "send", conversationId: a, clientMsgId: o, content: m });
|
|
897
903
|
});
|
|
898
|
-
},
|
|
904
|
+
}, Ce = (o, s, m) => {
|
|
899
905
|
S.sealText(s, m).then((L) => {
|
|
900
906
|
a && k.send({ type: "send", conversationId: a, clientMsgId: o, content: L });
|
|
901
907
|
});
|
|
902
|
-
},
|
|
908
|
+
}, Te = () => {
|
|
903
909
|
for (; g.length; ) {
|
|
904
910
|
const o = g.shift();
|
|
905
911
|
ee(o.clientMsgId, o.text);
|
|
@@ -908,19 +914,19 @@ function ot(t) {
|
|
|
908
914
|
const o = N.shift();
|
|
909
915
|
ee(o.clientMsgId, o.text);
|
|
910
916
|
}
|
|
911
|
-
},
|
|
917
|
+
}, Ie = (o) => {
|
|
912
918
|
k.send({ type: "fetchPrekey", targetUserId: o });
|
|
913
|
-
},
|
|
914
|
-
|
|
915
|
-
const re = `oc_prechat_${t.profileId}_${i.slice(-8)}`,
|
|
919
|
+
}, Se = t.i18n ?? {}, Ee = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
|
|
920
|
+
Ee.includes(ze) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
|
|
921
|
+
const re = `oc_prechat_${t.profileId}_${i.slice(-8)}`, $ = new Xe(t.el, i, {
|
|
916
922
|
onSend(o) {
|
|
917
923
|
const s = `cm_${Math.random().toString(36).slice(2)}`, m = { kind: "text", text: o };
|
|
918
|
-
p.addOptimistic(s, m),
|
|
924
|
+
p.addOptimistic(s, m), $.render(p), p.e2e ? S.ready ? ee(s, o) : H ? N.push({ clientMsgId: s, text: o }) : (g.push({ clientMsgId: s, text: o }), p.assignedAgentId && Ie(p.assignedAgentId)) : a ? (b.add({ clientMsgId: s, content: m, ts: Date.now() }), k.send({ type: "send", conversationId: a, clientMsgId: s, content: m })) : B.push({ clientMsgId: s, content: m });
|
|
919
925
|
},
|
|
920
926
|
async onAttach(o) {
|
|
921
927
|
if (!a) return;
|
|
922
928
|
const s = `${y}/upload?name=${encodeURIComponent(o.name)}`, m = `cm_${Math.random().toString(36).slice(2)}`;
|
|
923
|
-
p.addOptimistic(m, { kind: "text", text: `📎 Uploading ${o.name}…` }),
|
|
929
|
+
p.addOptimistic(m, { kind: "text", text: `📎 Uploading ${o.name}…` }), $.render(p);
|
|
924
930
|
try {
|
|
925
931
|
const L = await fetch(s, {
|
|
926
932
|
method: "POST",
|
|
@@ -934,9 +940,9 @@ function ot(t) {
|
|
|
934
940
|
});
|
|
935
941
|
if (!L.ok) throw new Error(`Upload failed: ${L.status}`);
|
|
936
942
|
const { url: W, name: G, mime: Y, size: X } = await L.json();
|
|
937
|
-
p.addOptimistic(m, { kind: "attachment", url: W, name: G, mime: Y, size: X }),
|
|
943
|
+
p.addOptimistic(m, { kind: "attachment", url: W, name: G, mime: Y, size: X }), $.render(p), k.send({ type: "send", conversationId: a, clientMsgId: m, content: { kind: "attachment", url: W, name: G, mime: Y, size: X } });
|
|
938
944
|
} catch (L) {
|
|
939
|
-
p.addOptimistic(m, { kind: "text", text: `⚠️ Upload failed: ${L.message}` }),
|
|
945
|
+
p.addOptimistic(m, { kind: "text", text: `⚠️ Upload failed: ${L.message}` }), $.render(p);
|
|
940
946
|
}
|
|
941
947
|
},
|
|
942
948
|
onInvoke(o, s) {
|
|
@@ -972,11 +978,11 @@ function ot(t) {
|
|
|
972
978
|
clearTimeout(l);
|
|
973
979
|
const s = o.trim();
|
|
974
980
|
if (s.length < 3) {
|
|
975
|
-
|
|
981
|
+
$.hideDeflection();
|
|
976
982
|
return;
|
|
977
983
|
}
|
|
978
984
|
l = setTimeout(() => {
|
|
979
|
-
fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(s.slice(0, 200))}`).then((m) => m.ok ? m.json() : { articles: [] }).then((m) =>
|
|
985
|
+
fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(s.slice(0, 200))}`).then((m) => m.ok ? m.json() : { articles: [] }).then((m) => $.showDeflection(m.articles ?? [])).catch(() => $.hideDeflection());
|
|
980
986
|
}, 350);
|
|
981
987
|
}
|
|
982
988
|
} : {},
|
|
@@ -1032,11 +1038,12 @@ function ot(t) {
|
|
|
1032
1038
|
...t.accent ? { accent: t.accent } : {},
|
|
1033
1039
|
...t.accent2 ? { accent2: t.accent2 } : {},
|
|
1034
1040
|
...t.theme ? { theme: t.theme } : {},
|
|
1041
|
+
...t.webfont === !1 ? { webfont: !1 } : {},
|
|
1035
1042
|
...(he = t.user) != null && he.name || (ue = t.user) != null && ue.avatar ? { userInfo: { ...t.user.name ? { name: t.user.name } : {}, ...t.user.avatar ? { avatar: t.user.avatar } : {} } } : {},
|
|
1036
|
-
i18n:
|
|
1043
|
+
i18n: Se
|
|
1037
1044
|
});
|
|
1038
1045
|
try {
|
|
1039
|
-
localStorage.getItem(re) &&
|
|
1046
|
+
localStorage.getItem(re) && $.completePreChat();
|
|
1040
1047
|
} catch {
|
|
1041
1048
|
}
|
|
1042
1049
|
const ce = t.user && (t.user.name || t.user.email || t.user.avatar || t.user.meta) ? {
|
|
@@ -1044,7 +1051,7 @@ function ot(t) {
|
|
|
1044
1051
|
...t.user.email ? { email: t.user.email } : {},
|
|
1045
1052
|
...t.user.avatar ? { avatar: t.user.avatar } : {},
|
|
1046
1053
|
...t.user.meta ? { meta: t.user.meta } : {}
|
|
1047
|
-
} : void 0,
|
|
1054
|
+
} : void 0, je = {
|
|
1048
1055
|
type: "open",
|
|
1049
1056
|
profileId: t.profileId,
|
|
1050
1057
|
// Direct conversations use the kind/peerId pair; the dm:… subject key is
|
|
@@ -1060,13 +1067,13 @@ function ot(t) {
|
|
|
1060
1067
|
...(fe = t.subject) != null && fe.title ? { subjectTitle: t.subject.title } : {},
|
|
1061
1068
|
...(we = t.subject) != null && we.subtitle ? { subjectMeta: t.subject.subtitle } : {}
|
|
1062
1069
|
};
|
|
1063
|
-
k = new
|
|
1070
|
+
k = new De({
|
|
1064
1071
|
...t.refreshToken ? { refreshToken: t.refreshToken } : {},
|
|
1065
1072
|
url: w,
|
|
1066
1073
|
token: i,
|
|
1067
|
-
open:
|
|
1074
|
+
open: je,
|
|
1068
1075
|
getCursor: () => p.highestSeq(),
|
|
1069
|
-
onStatusChange: (o, s) =>
|
|
1076
|
+
onStatusChange: (o, s) => $.setConnStatus(o, s),
|
|
1070
1077
|
onFrame(o) {
|
|
1071
1078
|
if (o.type === "opened") {
|
|
1072
1079
|
if (a = o.conversation.id, !P) {
|
|
@@ -1074,28 +1081,28 @@ function ot(t) {
|
|
|
1074
1081
|
for (const s of b.load())
|
|
1075
1082
|
k.send({ type: "send", conversationId: a, clientMsgId: s.clientMsgId, content: s.content });
|
|
1076
1083
|
}
|
|
1077
|
-
|
|
1084
|
+
qe(w, i, a, p, $, y), B.length && A(a);
|
|
1078
1085
|
}
|
|
1079
1086
|
if (o.type === "ack" && b.remove(o.clientMsgId), o.type === "prekeyBundle") {
|
|
1080
1087
|
o.bundle && (H = !0, S.x3dhSendTo(o.bundle).then((s) => {
|
|
1081
1088
|
const m = [...g.splice(0), ...N.splice(0)];
|
|
1082
|
-
for (const L of m)
|
|
1083
|
-
|
|
1089
|
+
for (const L of m) Ce(L.clientMsgId, L.text, s);
|
|
1090
|
+
$.render(p);
|
|
1084
1091
|
}));
|
|
1085
1092
|
return;
|
|
1086
1093
|
}
|
|
1087
1094
|
if (o.type === "message" && p.e2e) {
|
|
1088
|
-
const s =
|
|
1095
|
+
const s = _e(o.message.content);
|
|
1089
1096
|
if (s && !S.ready) {
|
|
1090
1097
|
S.x3dhReceiveFrom(s.x3dhIK, s.x3dhEK, s.x3dhSPK, s.x3dhOTP).then(async () => {
|
|
1091
|
-
await S.openFrame(o), p.apply(o),
|
|
1098
|
+
await S.openFrame(o), p.apply(o), $.render(p);
|
|
1092
1099
|
});
|
|
1093
1100
|
return;
|
|
1094
1101
|
}
|
|
1095
1102
|
}
|
|
1096
1103
|
if (o.type === "peerkey") {
|
|
1097
1104
|
S.onPeerKey(o.key).then(() => {
|
|
1098
|
-
|
|
1105
|
+
Te(), $.render(p);
|
|
1099
1106
|
});
|
|
1100
1107
|
return;
|
|
1101
1108
|
}
|
|
@@ -1107,27 +1114,27 @@ function ot(t) {
|
|
|
1107
1114
|
const m = await S.begin();
|
|
1108
1115
|
k.send({ type: "pubkey", conversationId: a, key: m });
|
|
1109
1116
|
}
|
|
1110
|
-
|
|
1117
|
+
$.render(p);
|
|
1111
1118
|
})();
|
|
1112
1119
|
}
|
|
1113
|
-
}), k.connect(),
|
|
1114
|
-
const F = t.launcher ?
|
|
1115
|
-
c = !0, clearTimeout(l), k.close(), r == null || r.remove(),
|
|
1120
|
+
}), k.connect(), $.render(p);
|
|
1121
|
+
const F = t.launcher ? ke(t) : null, V = { close: () => {
|
|
1122
|
+
c = !0, clearTimeout(l), k.close(), r == null || r.remove(), $.destroy(), I && M && I.removeEventListener("change", M), j && (document.removeEventListener("keydown", j), j = null), _.delete(t.el), F && Z.get(F) === V && Z.delete(F);
|
|
1116
1123
|
} };
|
|
1117
1124
|
return _.set(t.el, V), F && Z.set(F, V), V;
|
|
1118
1125
|
}
|
|
1119
1126
|
export {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1127
|
+
Oe as ChatStore,
|
|
1128
|
+
De as ConnectionManager,
|
|
1129
|
+
He as E2ESession,
|
|
1130
|
+
Ne as PersistentOutbox,
|
|
1131
|
+
Xe as Renderer,
|
|
1132
|
+
dt as asConversationId,
|
|
1133
|
+
_e as extractX3DHInit,
|
|
1134
|
+
st as httpBaseFromWsUrl,
|
|
1135
|
+
at as mount,
|
|
1136
|
+
Ae as resolveRelayUrls,
|
|
1137
|
+
qe as restoreHistory,
|
|
1138
|
+
it as unmount
|
|
1132
1139
|
};
|
|
1133
1140
|
//# sourceMappingURL=index.js.map
|