@paramms/chat-widget 1.6.3 → 1.9.0
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 +4 -0
- package/dist/chatlist2.js +407 -353
- package/dist/chatlist2.js.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/embed-lite.js +3 -3
- package/dist/embed-lite.js.map +1 -1
- package/dist/embed.d.ts +3 -0
- package/dist/embed.js +3 -3
- package/dist/embed.js.map +1 -1
- package/dist/i18n.d.ts +41 -0
- package/dist/index.d.ts +12 -16
- package/dist/index.js +551 -518
- package/dist/index.js.map +1 -1
- package/dist/outbox.js +5 -0
- package/dist/outbox.js.map +1 -1
- package/dist/protocol/entities.d.ts +1 -0
- package/dist/react.d.ts +7 -3
- package/dist/react.js +322 -312
- package/dist/react.js.map +1 -1
- package/dist/renderer.d.ts +3 -1
- package/dist/store.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var Be = Object.defineProperty;
|
|
2
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 C = (t, e, l) => $e(t, typeof e != "symbol" ? e + "" : e, l);
|
|
4
|
-
import { l as Re, b as
|
|
5
|
-
import { h as
|
|
6
|
-
import { P as
|
|
7
|
-
import { e as
|
|
8
|
-
import { E2ESession as
|
|
9
|
-
const
|
|
4
|
+
import { l as Re, b as ke, p as Me, r as Ae, c as qe, f as Ne, a as Oe, m as De } from "./chatlist2.js";
|
|
5
|
+
import { h as ht } from "./chatlist2.js";
|
|
6
|
+
import { P as He, C as _e, b as Ue } from "./outbox.js";
|
|
7
|
+
import { e as wt } from "./outbox.js";
|
|
8
|
+
import { E2ESession as Fe, extractX3DHInit as We } from "./e2e.js";
|
|
9
|
+
const Ge = `
|
|
10
10
|
.ocw { ${Re("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; }
|
|
14
|
-
@media (prefers-color-scheme: dark) { .ocw[data-theme="auto"] { ${
|
|
15
|
-
.ocw[data-theme="dark"] { ${
|
|
14
|
+
@media (prefers-color-scheme: dark) { .ocw[data-theme="auto"] { ${ke("ocw")} } }
|
|
15
|
+
.ocw[data-theme="dark"] { ${ke("ocw")} }
|
|
16
16
|
/* ── Responsive sizing ──────────────────────────────────────────────────────
|
|
17
17
|
* Sizing is driven by the WIDGET'S OWN width (ResizeObserver toggles
|
|
18
18
|
* .ocw-compact below 400px), not the viewport — so a widget embedded in a
|
|
@@ -197,23 +197,40 @@ const Fe = `
|
|
|
197
197
|
.ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
|
|
198
198
|
.ocw-translation { margin-top:6px; padding-top:6px; border-top:1px solid var(--ocw-line); font-size:13px; line-height:1.45; }
|
|
199
199
|
.ocw-translation::before { content:'🌐 '; opacity:.75; }
|
|
200
|
-
`,
|
|
201
|
-
function
|
|
202
|
-
if (typeof document > "u" || document.getElementById(
|
|
200
|
+
`, Ce = "objectchat-widget-styles", Ke = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Ve = 400, Ye = '<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 Xe() {
|
|
202
|
+
if (typeof document > "u" || document.getElementById(Ce)) return;
|
|
203
203
|
const t = document.createElement("style");
|
|
204
|
-
t.id =
|
|
204
|
+
t.id = Ce, t.textContent = Ge, document.head.appendChild(t);
|
|
205
205
|
}
|
|
206
|
-
const
|
|
207
|
-
function
|
|
208
|
-
if (typeof document > "u" || document.getElementById(
|
|
206
|
+
const Ie = "ocw-webfont";
|
|
207
|
+
function Qe() {
|
|
208
|
+
if (typeof document > "u" || document.getElementById(Ie)) return;
|
|
209
209
|
const t = document.createElement("link");
|
|
210
|
-
t.id =
|
|
210
|
+
t.id = Ie, 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);
|
|
211
211
|
}
|
|
212
212
|
function n(t, e, l) {
|
|
213
|
-
const
|
|
214
|
-
return e && (
|
|
213
|
+
const c = document.createElement(t);
|
|
214
|
+
return e && (c.className = e), l !== void 0 && (c.textContent = l), c;
|
|
215
|
+
}
|
|
216
|
+
function Je(t, e) {
|
|
217
|
+
const l = /(https?:\/\/[^\s]+)/g;
|
|
218
|
+
let c = 0, a = null, f;
|
|
219
|
+
for (; (f = l.exec(e)) !== null; ) {
|
|
220
|
+
if (f.index > c) {
|
|
221
|
+
const d = document.createTextNode(e.slice(c, f.index));
|
|
222
|
+
t.append(d), a ?? (a = d);
|
|
223
|
+
}
|
|
224
|
+
let y = f[0], s = "";
|
|
225
|
+
const x = /[).,!?;:]+$/.exec(y);
|
|
226
|
+
x && (s = x[0], y = y.slice(0, -s.length));
|
|
227
|
+
const u = document.createElement("a");
|
|
228
|
+
u.href = y, u.target = "_blank", u.rel = "noopener noreferrer", u.textContent = y, u.style.cssText = "color:inherit;text-decoration:underline;word-break:break-all", t.append(u), s && t.append(document.createTextNode(s)), c = f.index + f[0].length;
|
|
229
|
+
}
|
|
230
|
+
const b = document.createTextNode(e.slice(c));
|
|
231
|
+
return t.append(b), a ?? (a = b), a;
|
|
215
232
|
}
|
|
216
|
-
function
|
|
233
|
+
function Ze(t) {
|
|
217
234
|
try {
|
|
218
235
|
return new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
219
236
|
} catch {
|
|
@@ -237,9 +254,9 @@ function se(t) {
|
|
|
237
254
|
return `📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`;
|
|
238
255
|
}
|
|
239
256
|
}
|
|
240
|
-
class
|
|
257
|
+
class et {
|
|
241
258
|
/** Last seq the guest has seen per conversationId — used to compute unread badges. */
|
|
242
|
-
constructor(e, l,
|
|
259
|
+
constructor(e, l, c, a = {}) {
|
|
243
260
|
C(this, "scroll");
|
|
244
261
|
C(this, "chips");
|
|
245
262
|
C(this, "typing");
|
|
@@ -274,59 +291,59 @@ class Qe {
|
|
|
274
291
|
/** Whether the subject card (server Subject entity, mount config fallback)
|
|
275
292
|
* has been built — built once when data first arrives. */
|
|
276
293
|
C(this, "subjectBuilt", !1);
|
|
277
|
-
var
|
|
278
|
-
this.root = e, this.me = l, this.h =
|
|
279
|
-
const
|
|
280
|
-
|
|
294
|
+
var P, O, j, _, E, r, i, h, m, v, k;
|
|
295
|
+
this.root = e, this.me = l, this.h = c, this.cfg = a, Xe(), a.webfont !== !1 && Qe(), e.replaceChildren(), e.classList.add("ocw"), a.accent && e.style.setProperty("--ocw-accent", a.accent);
|
|
296
|
+
const f = a.accent2 ?? a.accent;
|
|
297
|
+
f && e.style.setProperty("--ocw-accent2", f), this.cfgAccent2 = a.accent2, e.dataset.theme = a.theme ?? "light";
|
|
281
298
|
const b = n("div", "ocw-head");
|
|
282
299
|
if (this.h.onBack) {
|
|
283
|
-
const
|
|
284
|
-
|
|
300
|
+
const w = n("button", "ocw-back", "‹");
|
|
301
|
+
w.type = "button", w.setAttribute("aria-label", "Back"), w.addEventListener("click", () => this.h.onBack()), b.append(w);
|
|
285
302
|
}
|
|
286
|
-
const y = ((
|
|
287
|
-
y.trim() && (
|
|
288
|
-
const
|
|
289
|
-
this.headerName = n("div", "ocw-head-name", ((
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
for (const
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
this.h.onSend(
|
|
296
|
-
}), this.quick.append(
|
|
303
|
+
const y = ((P = a.subject) == null ? void 0 : P.ownerLabel) ?? ((O = a.subject) == null ? void 0 : O.title) ?? "", s = n("div", "ocw-avatar");
|
|
304
|
+
y.trim() && (s.textContent = y.trim()[0].toUpperCase(), b.append(s));
|
|
305
|
+
const x = n("div", "ocw-head-main");
|
|
306
|
+
this.headerName = n("div", "ocw-head-name", ((j = a.subject) == null ? void 0 : j.ownerLabel) ?? ((_ = a.subject) == null ? void 0 : _.title) ?? ""), x.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", x.append(this.headStatus), (E = a.subject) != null && E.subtitle && x.append(n("div", "ocw-head-meta", a.subject.subtitle)), b.append(x), this.statusBadge = n("span", "ocw-badge", ((r = a.subject) == null ? void 0 : r.status) ?? ""), (i = a.subject) != null && i.status || (this.statusBadge.style.display = "none"), b.append(this.statusBadge), this.e2eBadge = n("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", b.append(this.e2eBadge), this.connStatus = n("span", "ocw-conn-status"), this.connStatus.style.display = "none", b.append(this.connStatus), b.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");
|
|
307
|
+
const u = n("div", "ocw-typing-bubble");
|
|
308
|
+
u.append(n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot")), this.typing.append(u), this.quick = n("div", "ocw-quick");
|
|
309
|
+
for (const w of a.quickReplies ?? []) {
|
|
310
|
+
const S = n("button", void 0, w);
|
|
311
|
+
S.addEventListener("click", () => {
|
|
312
|
+
this.h.onSend(w), this.quick.style.display = "none";
|
|
313
|
+
}), this.quick.append(S);
|
|
297
314
|
}
|
|
298
|
-
this.formHost = n("div", "ocw-form-host"), this.csatPanel = n("div", "ocw-csat"), this.csatPanel.style.display = "none", this.awayNotice = n("div", "ocw-away"), this.awayNotice.style.display = "none", this.preChatPanel = n("div", "ocw-prechat"), this.preChatPanel.style.display = "none", this.deflectPanel = n("div", "ocw-deflect"), this.deflectPanel.style.display = "none", this.input = n("textarea", void 0), this.input.rows = 1, this.input.placeholder = ((
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
var
|
|
304
|
-
this.sendBtn.disabled = this.input.value.trim().length === 0, this.autoGrowInput(), this.storeRef && !this.storeRef.messages().some((
|
|
305
|
-
}), this.input.addEventListener("keydown", (
|
|
306
|
-
|
|
315
|
+
this.formHost = n("div", "ocw-form-host"), this.csatPanel = n("div", "ocw-csat"), this.csatPanel.style.display = "none", this.awayNotice = n("div", "ocw-away"), this.awayNotice.style.display = "none", this.preChatPanel = n("div", "ocw-prechat"), this.preChatPanel.style.display = "none", this.deflectPanel = n("div", "ocw-deflect"), this.deflectPanel.style.display = "none", this.input = n("textarea", void 0), this.input.rows = 1, this.input.placeholder = ((h = a.i18n) == null ? void 0 : h.placeholder) ?? "Message…";
|
|
316
|
+
const d = n("button", "ocw-sendbtn");
|
|
317
|
+
d.type = "button";
|
|
318
|
+
const I = (m = a.i18n) == null ? void 0 : m.send;
|
|
319
|
+
I ? (d.textContent = I, d.classList.add("ocw-sendbtn-label"), d.setAttribute("aria-label", I)) : (d.innerHTML = Ye, d.setAttribute("aria-label", "Send message")), d.disabled = !0, this.sendBtn = d, d.addEventListener("click", () => this.flushSend()), this.input.addEventListener("input", () => {
|
|
320
|
+
var w, S;
|
|
321
|
+
this.sendBtn.disabled = this.input.value.trim().length === 0, this.autoGrowInput(), this.storeRef && !this.storeRef.messages().some((z) => z.senderRole === "guest") ? (S = (w = this.h).onDeflectQuery) == null || S.call(w, this.input.value) : this.hideDeflection();
|
|
322
|
+
}), this.input.addEventListener("keydown", (w) => {
|
|
323
|
+
w.isComposing || w.keyCode === 229 || (w.key === "Enter" && !w.shiftKey ? (w.preventDefault(), this.flushSend()) : this.signalTyping());
|
|
307
324
|
});
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
var
|
|
313
|
-
(
|
|
325
|
+
const T = n("button", "ocw-attach", "📎");
|
|
326
|
+
T.title = "Attach image or file";
|
|
327
|
+
const L = document.createElement("input");
|
|
328
|
+
L.type = "file", L.accept = "image/*,.pdf,.txt,.doc,.docx", L.style.display = "none", T.addEventListener("click", () => L.click()), L.addEventListener("change", () => {
|
|
329
|
+
var w;
|
|
330
|
+
(w = L.files) != null && w[0] && this.h.onAttach && this.h.onAttach(L.files[0]), L.value = "";
|
|
314
331
|
});
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
((
|
|
332
|
+
const B = n("div", "ocw-input");
|
|
333
|
+
B.append(T, L, this.input, d);
|
|
334
|
+
const M = n("div", "ocw-footer");
|
|
335
|
+
((v = a.i18n) == null ? void 0 : v.poweredBy) !== void 0 ? M.textContent = a.i18n.poweredBy : M.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = M, this.reopenBtn = n("button", "ocw-reopen", ((k = this.cfg.i18n) == null ? void 0 : k.reopen) ?? "Reopen conversation"), this.reopenBtn.type = "button", this.reopenBtn.addEventListener("click", () => {
|
|
319
336
|
this.reopenBtn.style.display = "none";
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
}), e.append(b, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.preChatPanel, this.deflectPanel, this.awayNotice,
|
|
323
|
-
const
|
|
324
|
-
e.classList.toggle("ocw-compact",
|
|
337
|
+
const w = this.root.querySelector(".ocw-input textarea");
|
|
338
|
+
w == null || w.focus();
|
|
339
|
+
}), e.append(b, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.preChatPanel, this.deflectPanel, this.awayNotice, B, this.reopenBtn, this.footer);
|
|
340
|
+
const A = (w) => {
|
|
341
|
+
e.classList.toggle("ocw-compact", w > 0 && w < Ve);
|
|
325
342
|
};
|
|
326
|
-
|
|
327
|
-
var
|
|
328
|
-
const
|
|
329
|
-
|
|
343
|
+
A(e.clientWidth), typeof ResizeObserver < "u" && (this.compactObserver = new ResizeObserver((w) => {
|
|
344
|
+
var z;
|
|
345
|
+
const S = ((z = w[0]) == null ? void 0 : z.contentRect.width) ?? e.clientWidth;
|
|
346
|
+
A(S);
|
|
330
347
|
}), this.compactObserver.observe(e));
|
|
331
348
|
}
|
|
332
349
|
/** Returns the scroll container so history.ts can attach scroll listeners. */
|
|
@@ -365,49 +382,49 @@ class Qe {
|
|
|
365
382
|
this.cfg.i18n = { ...this.cfg.i18n ?? {}, aiAssistant: e };
|
|
366
383
|
}
|
|
367
384
|
render(e) {
|
|
368
|
-
var
|
|
385
|
+
var L, B, M, A, P, O, j, _;
|
|
369
386
|
if (this.storeRef = e, e.accent && (this.root.style.setProperty("--ocw-accent", e.accent), this.root.style.setProperty("--ocw-accent2", this.cfgAccent2 ?? e.accent)), this.e2eBadge.style.display = e.e2e ? "inline-flex" : "none", this.buildSubjectCard(e), e.subject) {
|
|
370
|
-
const
|
|
371
|
-
|
|
387
|
+
const E = (L = this.cfg.subject) == null ? void 0 : L.ownerLabel;
|
|
388
|
+
E && (this.headerName.textContent = E);
|
|
372
389
|
}
|
|
373
390
|
this.quick.style.display = e.messages().length === 0 ? "flex" : "none", this.chips.replaceChildren();
|
|
374
391
|
const l = e.visibleActions();
|
|
375
392
|
this.chips.style.display = l.length ? "flex" : "none";
|
|
376
|
-
for (const
|
|
377
|
-
const
|
|
393
|
+
for (const E of l) this.chips.append(this.chipEl(E));
|
|
394
|
+
const c = this.scroll.scrollHeight, a = this.scroll.scrollTop;
|
|
378
395
|
if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
|
|
379
|
-
const
|
|
380
|
-
|
|
396
|
+
const E = n("div", "ocw-load-more");
|
|
397
|
+
E.textContent = "↑ Loading earlier messages…", E.style.pointerEvents = "none", this.scroll.append(E);
|
|
381
398
|
}
|
|
382
|
-
let
|
|
399
|
+
let f = 0, b = null;
|
|
383
400
|
const y = [...e.messages()];
|
|
384
|
-
for (let
|
|
385
|
-
const
|
|
386
|
-
this.scroll.append(this.messageEl(
|
|
401
|
+
for (let E = 0; E < y.length; E++) {
|
|
402
|
+
const r = y[E], i = r.senderRole !== "system" && r.senderId !== this.me && !r.internal && r.senderId !== b;
|
|
403
|
+
this.scroll.append(this.messageEl(r, e, i, E === y.length - 1)), r.senderRole !== "system" && (b = r.senderId), r.senderId !== this.me && r.seq > f && (f = r.seq);
|
|
387
404
|
}
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
this.typing.classList.toggle("active",
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
if (!!((
|
|
395
|
-
this.preChatBuilt || this.buildPreChatPanel(e.preChat), this.preChatPanel.style.display = "block", this.awayNotice.style.display = "none", (
|
|
405
|
+
a > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - c + a : this.scroll.scrollTop = this.scroll.scrollHeight, f > 0 && this.h.onReadUpTo(f);
|
|
406
|
+
const s = [...e.typing];
|
|
407
|
+
this.typing.classList.toggle("active", s.length > 0);
|
|
408
|
+
const x = this.typing.querySelector(".ocw-typing-bubble");
|
|
409
|
+
x && x.setAttribute("aria-label", s.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block";
|
|
410
|
+
const u = e.messages().some((E) => E.senderRole === "guest");
|
|
411
|
+
if (!!((B = e.preChat) != null && B.enabled) && !this.preChatDone && !u && (e.preChat.showWhen !== "offline" || e.offline))
|
|
412
|
+
this.preChatBuilt || this.buildPreChatPanel(e.preChat), this.preChatPanel.style.display = "block", this.awayNotice.style.display = "none", (M = this.root.querySelector(".ocw-input")) == null || M.style.setProperty("display", "none");
|
|
396
413
|
else {
|
|
397
414
|
if (this.preChatPanel.style.display = "none", e.offline) {
|
|
398
415
|
this.awayNotice.firstChild || this.awayNotice.append(n("span", "ocw-away-icon", "🌙"), n("span", "", ""));
|
|
399
|
-
const
|
|
400
|
-
|
|
416
|
+
const E = this.awayNotice.lastChild;
|
|
417
|
+
E.textContent = e.offlineMessage || ((A = this.cfg.i18n) == null ? void 0 : A.offline) || "We're away right now — send your message and we'll reply as soon as we're back.", this.awayNotice.style.display = "flex";
|
|
401
418
|
} else
|
|
402
419
|
this.awayNotice.style.display = "none";
|
|
403
|
-
(
|
|
420
|
+
(P = this.root.querySelector(".ocw-input")) == null || P.style.removeProperty("display");
|
|
404
421
|
}
|
|
405
|
-
const
|
|
406
|
-
this.h.onCsat && !this.csatSubmitted &&
|
|
407
|
-
const
|
|
408
|
-
if (e.offline ? (this.headStatus.textContent = `● ${e.offlineMessage || ((O = this.cfg.i18n) == null ? void 0 : O.away) || "Away"}`, this.headStatus.className = "ocw-head-status away", this.headStatus.style.display = "") : e.conversationId ? (this.headStatus.textContent = `● ${((
|
|
409
|
-
const
|
|
410
|
-
this.scroll.append(
|
|
422
|
+
const I = ["resolved", "closed", "sold", "issued", "checked_out"];
|
|
423
|
+
this.h.onCsat && !this.csatSubmitted && I.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
|
|
424
|
+
const T = I.includes(e.state);
|
|
425
|
+
if (e.offline ? (this.headStatus.textContent = `● ${e.offlineMessage || ((O = this.cfg.i18n) == null ? void 0 : O.away) || "Away"}`, this.headStatus.className = "ocw-head-status away", this.headStatus.style.display = "") : e.conversationId ? (this.headStatus.textContent = `● ${((j = this.cfg.i18n) == null ? void 0 : j.online) ?? "Online"}`, this.headStatus.className = "ocw-head-status online", this.headStatus.style.display = "") : this.headStatus.style.display = "none", T && e.messages().length > 0) {
|
|
426
|
+
const E = n("div", "ocw-resolved-note", `— ${((_ = this.cfg.i18n) == null ? void 0 : _.resolved) ?? "Marked as resolved"} —`);
|
|
427
|
+
this.scroll.append(E), this.reopenBtn.style.display = "block";
|
|
411
428
|
} else
|
|
412
429
|
this.reopenBtn.style.display = "none";
|
|
413
430
|
}
|
|
@@ -417,56 +434,56 @@ class Qe {
|
|
|
417
434
|
return;
|
|
418
435
|
}
|
|
419
436
|
this.connStatus.style.display = "";
|
|
420
|
-
const
|
|
421
|
-
this.connStatus.className = `ocw-conn-status${
|
|
437
|
+
const c = e === "error";
|
|
438
|
+
this.connStatus.className = `ocw-conn-status${c ? " err" : e === "reconnecting" ? " warn" : ""}`, this.connStatus.textContent = c ? `⚠ ${l ?? "Chat unavailable"}` : e === "reconnecting" ? l ?? "↻ reconnecting…" : "● connecting…";
|
|
422
439
|
}
|
|
423
440
|
buildPreChatPanel(e) {
|
|
424
|
-
var
|
|
441
|
+
var s;
|
|
425
442
|
this.preChatBuilt = !0, this.preChatPanel.replaceChildren(), this.preChatPanel.append(n("div", "ocw-prechat-title", e.title ?? "Before we start…"));
|
|
426
|
-
const l = n("div", "ocw-offline-form"),
|
|
427
|
-
for (const
|
|
428
|
-
const
|
|
429
|
-
|
|
443
|
+
const l = n("div", "ocw-offline-form"), c = {};
|
|
444
|
+
for (const x of e.fields ?? ["name", "email"]) {
|
|
445
|
+
const u = n("input", "ocw-offline-input");
|
|
446
|
+
u.type = x === "email" ? "email" : x === "phone" ? "tel" : "text", u.placeholder = x === "name" ? "Your name" : x === "email" ? "Your email" : "Your phone number", c[x] = u, l.append(u);
|
|
430
447
|
}
|
|
431
|
-
let
|
|
432
|
-
if ((
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
for (const
|
|
437
|
-
const
|
|
438
|
-
|
|
448
|
+
let a = null;
|
|
449
|
+
if ((s = e.topics) != null && s.length) {
|
|
450
|
+
a = n("select", void 0);
|
|
451
|
+
const x = document.createElement("option");
|
|
452
|
+
x.value = "", x.textContent = "What is this about?", a.append(x);
|
|
453
|
+
for (const u of e.topics) {
|
|
454
|
+
const d = document.createElement("option");
|
|
455
|
+
d.value = u, d.textContent = u, a.append(d);
|
|
439
456
|
}
|
|
440
|
-
l.append(
|
|
457
|
+
l.append(a);
|
|
441
458
|
}
|
|
442
|
-
let
|
|
459
|
+
let f = null, b = null;
|
|
443
460
|
if (e.callbackOption) {
|
|
444
|
-
const
|
|
445
|
-
|
|
461
|
+
const x = n("label", "ocw-prechat-cb");
|
|
462
|
+
f = document.createElement("input"), f.type = "checkbox", x.append(f, document.createTextNode("📞 Request a call back")), l.append(x), c.phone || (b = n("input", "ocw-offline-input"), b.type = "tel", b.placeholder = "Phone number for the call", b.style.display = "none", f.addEventListener("change", () => b.style.setProperty("display", f.checked ? "block" : "none")), l.append(b));
|
|
446
463
|
}
|
|
447
464
|
const y = n("button", "ocw-offline-submit", "Start chat");
|
|
448
465
|
y.type = "button", y.addEventListener("click", () => {
|
|
449
|
-
var
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
452
|
-
|
|
466
|
+
var I, T, L, B, M, A, P;
|
|
467
|
+
const x = (I = c.email) == null ? void 0 : I.value.trim();
|
|
468
|
+
if (c.email && (!x || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x))) {
|
|
469
|
+
c.email.focus();
|
|
453
470
|
return;
|
|
454
471
|
}
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
(
|
|
472
|
+
const u = !!(f != null && f.checked), d = (((T = c.phone) == null ? void 0 : T.value) ?? (b == null ? void 0 : b.value) ?? "").trim();
|
|
473
|
+
if (u && !d) {
|
|
474
|
+
(L = c.phone ?? b) == null || L.focus();
|
|
458
475
|
return;
|
|
459
476
|
}
|
|
460
|
-
if (
|
|
461
|
-
|
|
477
|
+
if (a && ((B = e.topics) != null && B.length) && !a.value) {
|
|
478
|
+
a.focus();
|
|
462
479
|
return;
|
|
463
480
|
}
|
|
464
|
-
y.disabled = !0, this.completePreChat(), (
|
|
465
|
-
...(
|
|
466
|
-
...
|
|
467
|
-
...
|
|
468
|
-
...
|
|
469
|
-
...
|
|
481
|
+
y.disabled = !0, this.completePreChat(), (P = (A = this.h).onPreChat) == null || P.call(A, {
|
|
482
|
+
...(M = c.name) != null && M.value.trim() ? { name: c.name.value.trim() } : {},
|
|
483
|
+
...x ? { email: x } : {},
|
|
484
|
+
...d ? { phone: d } : {},
|
|
485
|
+
...a != null && a.value ? { topic: a.value } : {},
|
|
486
|
+
...u ? { callback: !0 } : {}
|
|
470
487
|
});
|
|
471
488
|
}), l.append(y), this.preChatPanel.append(l);
|
|
472
489
|
}
|
|
@@ -479,8 +496,8 @@ class Qe {
|
|
|
479
496
|
if (!e.length) return this.hideDeflection();
|
|
480
497
|
this.deflectPanel.replaceChildren(), this.deflectPanel.append(n("div", "ocw-deflect-hint", "Instant answers — tap to expand"));
|
|
481
498
|
for (const l of e.slice(0, 3)) {
|
|
482
|
-
const
|
|
483
|
-
|
|
499
|
+
const c = n("button", "ocw-deflect-card");
|
|
500
|
+
c.append(n("div", "ocw-deflect-q", l.title), n("div", "ocw-deflect-a", l.answer)), c.addEventListener("click", () => c.classList.toggle("open")), this.deflectPanel.append(c);
|
|
484
501
|
}
|
|
485
502
|
this.deflectPanel.style.display = "flex";
|
|
486
503
|
}
|
|
@@ -490,265 +507,276 @@ class Qe {
|
|
|
490
507
|
buildCsatPanel() {
|
|
491
508
|
this.csatPanel.replaceChildren(), this.csatPanel.append(n("div", "ocw-csat-title", "How did we do?"));
|
|
492
509
|
const e = n("div", "ocw-csat-stars"), l = [];
|
|
493
|
-
for (let
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
var
|
|
497
|
-
this.csatSubmitted = !0, this.csatPanel.replaceChildren(n("div", "ocw-csat-done", `Thanks for your ${
|
|
498
|
-
}), l.push(
|
|
510
|
+
for (let c = 1; c <= 5; c++) {
|
|
511
|
+
const a = n("button", "ocw-csat-star", "★");
|
|
512
|
+
a.dataset.score = String(c), a.addEventListener("mouseenter", () => l.forEach((f, b) => f.classList.toggle("lit", b < c))), a.addEventListener("mouseleave", () => l.forEach((f) => f.classList.remove("lit"))), a.addEventListener("click", () => {
|
|
513
|
+
var f, b;
|
|
514
|
+
this.csatSubmitted = !0, this.csatPanel.replaceChildren(n("div", "ocw-csat-done", `Thanks for your ${c}★ rating!`)), (b = (f = this.h).onCsat) == null || b.call(f, c);
|
|
515
|
+
}), l.push(a), e.append(a);
|
|
499
516
|
}
|
|
500
517
|
this.csatPanel.append(e);
|
|
501
518
|
}
|
|
502
519
|
buildSubjectCard(e) {
|
|
503
520
|
if (this.subjectBuilt) return;
|
|
504
|
-
const l = e.subject,
|
|
505
|
-
if (!
|
|
506
|
-
this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(n("div", "ocw-subject-title",
|
|
507
|
-
const
|
|
508
|
-
if (l) for (const [y,
|
|
509
|
-
else for (const y of (
|
|
510
|
-
|
|
511
|
-
const b = (l == null ? void 0 : l.state) ?? (
|
|
521
|
+
const l = e.subject, c = this.cfg.subject, a = (l == null ? void 0 : l.title) ?? (c == null ? void 0 : c.title);
|
|
522
|
+
if (!a) return;
|
|
523
|
+
this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(n("div", "ocw-subject-title", a)), c != null && c.subtitle && this.subjectCard.append(n("div", "ocw-subject-sub", c.subtitle));
|
|
524
|
+
const f = n("div", "ocw-tags");
|
|
525
|
+
if (l) for (const [y, s] of Object.entries(l.fields)) f.append(n("span", "ocw-tag", `${y}: ${s}`));
|
|
526
|
+
else for (const y of (c == null ? void 0 : c.tags) ?? []) f.append(n("span", "ocw-tag", y));
|
|
527
|
+
f.childNodes.length && this.subjectCard.append(f);
|
|
528
|
+
const b = (l == null ? void 0 : l.state) ?? (c == null ? void 0 : c.status);
|
|
512
529
|
b && (this.statusBadge.textContent = b, this.statusBadge.style.display = "inline-flex");
|
|
513
530
|
}
|
|
514
531
|
chipEl(e) {
|
|
515
532
|
const l = n("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
|
|
516
533
|
return l.dataset.actionId = e.id, l.addEventListener("click", async () => {
|
|
517
|
-
var
|
|
518
|
-
e.confirm && !await this.confirm(e.label) || ((
|
|
534
|
+
var c;
|
|
535
|
+
e.confirm && !await this.confirm(e.label) || ((c = e.input) != null && c.length ? this.openForm(e) : this.h.onInvoke(e.id));
|
|
519
536
|
}), l;
|
|
520
537
|
}
|
|
521
538
|
/** In-widget confirmation modal (replaces window.confirm). */
|
|
522
539
|
confirm(e) {
|
|
523
540
|
return new Promise((l) => {
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
const
|
|
527
|
-
|
|
541
|
+
const c = n("div", "ocw-modal"), a = n("div", "ocw-modal-card");
|
|
542
|
+
a.append(n("div", "ocw-modal-title", e)), a.append(n("div", "ocw-modal-body", `Confirm “${e}”?`));
|
|
543
|
+
const f = n("div", "ocw-modal-actions"), b = n("button", "ocw-modal-cancel", "Cancel"), y = n("button", "ocw-modal-ok", "Confirm"), s = (x) => {
|
|
544
|
+
c.remove(), l(x);
|
|
528
545
|
};
|
|
529
|
-
b.addEventListener("click", () =>
|
|
530
|
-
|
|
531
|
-
}),
|
|
546
|
+
b.addEventListener("click", () => s(!1)), y.addEventListener("click", () => s(!0)), c.addEventListener("click", (x) => {
|
|
547
|
+
x.target === c && s(!1);
|
|
548
|
+
}), f.append(b, y), a.append(f), c.append(a), this.root.append(c), y.focus();
|
|
532
549
|
});
|
|
533
550
|
}
|
|
534
551
|
/** Inline form for a form-effect action: typed inputs (date picker, number,
|
|
535
|
-
* text) rendered above the composer — no browser prompts.
|
|
536
|
-
|
|
537
|
-
|
|
552
|
+
* text) rendered above the composer — no browser prompts. `prefill` seeds
|
|
553
|
+
* field values (search pre-fill) — deterministic parse, correctable before
|
|
554
|
+
* submit. */
|
|
555
|
+
openForm(e, l) {
|
|
556
|
+
var s, x;
|
|
538
557
|
this.formHost.replaceChildren();
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
for (const
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
for (const
|
|
548
|
-
const
|
|
549
|
-
|
|
558
|
+
const c = n("div", "ocw-form");
|
|
559
|
+
c.append(n("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
|
|
560
|
+
const a = /* @__PURE__ */ new Map();
|
|
561
|
+
for (const u of e.input ?? []) {
|
|
562
|
+
const d = l == null ? void 0 : l[u.name], I = n("label", "ocw-form-row");
|
|
563
|
+
if (I.append(n("span", "ocw-form-lbl", u.label)), u.type === "select" && ((s = u.options) != null && s.length)) {
|
|
564
|
+
const T = n("select", "ocw-form-input");
|
|
565
|
+
u.required || T.append(n("option", void 0, "— select —"));
|
|
566
|
+
for (const L of u.options) {
|
|
567
|
+
const B = n("option");
|
|
568
|
+
B.value = L, B.textContent = L, T.append(B);
|
|
550
569
|
}
|
|
551
|
-
|
|
570
|
+
u.required && (T.required = !0), d != null && u.options.includes(d) && (T.value = d), I.append(T), a.set(u.name, T);
|
|
552
571
|
} else {
|
|
553
|
-
const
|
|
554
|
-
|
|
572
|
+
const T = n("input", "ocw-form-input");
|
|
573
|
+
T.type = u.type === "number" ? "number" : u.type === "date" ? "datetime-local" : "text", u.required && (T.required = !0), d != null && d !== "" && (T.value = d), I.append(T), a.set(u.name, T);
|
|
555
574
|
}
|
|
556
|
-
|
|
575
|
+
c.append(I);
|
|
557
576
|
}
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
for (const [
|
|
562
|
-
if (
|
|
563
|
-
|
|
577
|
+
const f = n("div", "ocw-form-actions"), b = n("button", "ocw-form-cancel", "Cancel"), y = n("button", "ocw-form-submit", "Send");
|
|
578
|
+
b.addEventListener("click", () => this.formHost.replaceChildren()), y.addEventListener("click", () => {
|
|
579
|
+
const u = {};
|
|
580
|
+
for (const [d, I] of a) {
|
|
581
|
+
if (I.required && !I.value) {
|
|
582
|
+
I.style.borderColor = "#e5484d";
|
|
564
583
|
return;
|
|
565
584
|
}
|
|
566
|
-
|
|
585
|
+
u[d] = I.type === "number" ? Number(I.value) : I.value;
|
|
567
586
|
}
|
|
568
|
-
this.formHost.replaceChildren(), this.h.onInvoke(e.id,
|
|
569
|
-
}),
|
|
587
|
+
this.formHost.replaceChildren(), this.h.onInvoke(e.id, u);
|
|
588
|
+
}), f.append(b, y), c.append(f), this.formHost.append(c), (x = a.values().next().value) == null || x.focus();
|
|
570
589
|
}
|
|
571
|
-
messageEl(e, l,
|
|
572
|
-
var
|
|
590
|
+
messageEl(e, l, c = !1, a = !1) {
|
|
591
|
+
var T, L, B, M, A, P, O, j, _, E;
|
|
573
592
|
if (e.senderRole === "system") {
|
|
574
|
-
const
|
|
575
|
-
return
|
|
593
|
+
const r = n("div", "ocw-sys");
|
|
594
|
+
return r.textContent = e.deletedAt ? "message deleted" : se(e.content), r;
|
|
576
595
|
}
|
|
577
|
-
const
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
|
|
596
|
+
const f = e.senderId === this.me, b = !!e.internal, y = n("div", `ocw-row ${b ? "ocw-note mine" : f ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`), s = n("div");
|
|
597
|
+
if (c) {
|
|
598
|
+
const r = e.senderRole === "bot" ? ((T = this.cfg.i18n) == null ? void 0 : T.aiAssistant) ?? "AI Assistant" : ((L = this.cfg.subject) == null ? void 0 : L.ownerLabel) ?? ((B = this.cfg.subject) == null ? void 0 : B.title) ?? "Support";
|
|
599
|
+
s.append(n("div", "ocw-msg-sender", r));
|
|
581
600
|
}
|
|
582
|
-
const
|
|
601
|
+
const x = n("div", "ocw-bubble-wrap");
|
|
583
602
|
if (e.replyToId) {
|
|
584
|
-
const
|
|
585
|
-
|
|
603
|
+
const r = n("div", "ocw-reply-to", "↩ replying to a message");
|
|
604
|
+
r.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", s.append(r);
|
|
586
605
|
}
|
|
587
|
-
const
|
|
588
|
-
let
|
|
589
|
-
if (e.deletedAt)
|
|
606
|
+
const u = n("div", "ocw-bubble");
|
|
607
|
+
let d = null;
|
|
608
|
+
if (e.deletedAt) u.append(n("span", "ocw-deleted", "message deleted"));
|
|
590
609
|
else if (e.content.kind === "attachment") {
|
|
591
|
-
const
|
|
592
|
-
if ((
|
|
610
|
+
const r = e.content;
|
|
611
|
+
if ((M = r.mime) != null && M.startsWith("image/")) {
|
|
593
612
|
const i = document.createElement("img");
|
|
594
|
-
i.src =
|
|
595
|
-
} else if ((
|
|
613
|
+
i.src = r.url, i.alt = r.name ?? "image", i.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", i.addEventListener("click", () => window.open(r.url, "_blank")), u.append(i);
|
|
614
|
+
} else if ((A = r.mime) != null && A.startsWith("video/")) {
|
|
596
615
|
const i = document.createElement("video");
|
|
597
|
-
i.src =
|
|
616
|
+
i.src = r.url, i.controls = !0, i.style.cssText = "max-width:240px;max-height:180px;border-radius:10px;display:block", u.append(i);
|
|
598
617
|
} else {
|
|
599
618
|
const i = document.createElement("a");
|
|
600
|
-
i.href =
|
|
619
|
+
i.href = r.url, i.target = "_blank", i.rel = "noopener", i.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", i.append(n("span", void 0, "📄"), n("span", void 0, r.name ?? "file")), u.append(i);
|
|
601
620
|
}
|
|
602
621
|
} else if (e.content.kind === "appointment") {
|
|
603
|
-
const
|
|
604
|
-
i.append(n("div", "ocw-appt-title", `📅 ${
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
|
|
622
|
+
const r = e.content, i = n("div", "ocw-appt");
|
|
623
|
+
i.append(n("div", "ocw-appt-title", `📅 ${r.title}`)), i.append(n("div", "ocw-appt-time", new Date(r.startIso).toLocaleString() + " – " + new Date(r.endIso).toLocaleTimeString())), r.location && i.append(n("div", "ocw-appt-loc", `📍 ${r.location}`)), r.description && i.append(n("div", "ocw-appt-desc", r.description));
|
|
624
|
+
const h = n("div", "ocw-appt-links"), m = document.createElement("a");
|
|
625
|
+
m.href = r.googleUrl, m.target = "_blank", m.rel = "noopener", m.className = "ocw-appt-btn", m.textContent = "📅 Add to Google Calendar";
|
|
626
|
+
const v = document.createElement("a");
|
|
627
|
+
v.href = r.icalUrl, v.download = `${r.title}.ics`, v.className = "ocw-appt-btn ocw-appt-btn-sec", v.textContent = "🍎 Apple / iCal", h.append(m, v), i.append(h), u.append(i);
|
|
609
628
|
} else
|
|
610
|
-
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
|
|
629
|
+
d = Je(u, se(e.content)), e.editedAt && u.append(n("span", "ocw-edited", "(edited)"));
|
|
630
|
+
if (x.append(u), a && !e.deletedAt && e.content.kind === "text" && ((P = e.content.quickReplies) != null && P.length)) {
|
|
631
|
+
const r = n("div", "ocw-flow-choices");
|
|
632
|
+
r.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";
|
|
614
633
|
for (const i of e.content.quickReplies) {
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}),
|
|
634
|
+
const h = n("button", "ocw-flow-choice", i);
|
|
635
|
+
h.type = "button", h.style.cssText = "border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer", h.addEventListener("click", () => {
|
|
636
|
+
r.querySelectorAll("button").forEach((m) => m.disabled = !0), r.style.opacity = "0.5", this.h.onSend(i);
|
|
637
|
+
}), r.append(h);
|
|
638
|
+
}
|
|
639
|
+
x.append(r);
|
|
640
|
+
}
|
|
641
|
+
if (a && !e.deletedAt && e.content.kind === "form") {
|
|
642
|
+
const r = e.content, i = l.actionById(r.actionId);
|
|
643
|
+
if ((O = i == null ? void 0 : i.input) != null && O.length) {
|
|
644
|
+
const h = n("button", "ocw-chip", i.icon ? `${i.icon} ${i.label}` : i.label);
|
|
645
|
+
h.type = "button", h.style.cssText = "margin-top:6px", h.addEventListener("click", async () => {
|
|
646
|
+
i.confirm && !await this.confirm(i.label) || this.openForm(i, r.prefill);
|
|
647
|
+
}), x.append(h);
|
|
619
648
|
}
|
|
620
|
-
h.append(a);
|
|
621
649
|
}
|
|
622
|
-
if (!
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
650
|
+
if (!f && !b && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && d) {
|
|
651
|
+
const r = e.content.text;
|
|
652
|
+
if (r.trim()) {
|
|
625
653
|
const i = n("button", "ocw-translate-btn", "🌐");
|
|
626
654
|
i.type = "button", i.title = "Translate";
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
},
|
|
632
|
-
|
|
655
|
+
const h = n("div", "ocw-translation");
|
|
656
|
+
h.style.display = "none", u.append(h);
|
|
657
|
+
const m = (w) => {
|
|
658
|
+
h.textContent = w, h.style.display = "", this.showingTranslation.add(e.id), i.textContent = "↩", i.title = "Show original";
|
|
659
|
+
}, v = () => {
|
|
660
|
+
h.style.display = "none", this.showingTranslation.delete(e.id), i.textContent = "🌐", i.title = "Translate";
|
|
633
661
|
};
|
|
634
|
-
i.addEventListener("click", (
|
|
635
|
-
if (
|
|
636
|
-
|
|
662
|
+
i.addEventListener("click", (w) => {
|
|
663
|
+
if (w.stopPropagation(), this.showingTranslation.has(e.id)) {
|
|
664
|
+
v();
|
|
637
665
|
return;
|
|
638
666
|
}
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
641
|
-
|
|
667
|
+
const S = this.translationCache.get(e.id);
|
|
668
|
+
if (S !== void 0) {
|
|
669
|
+
m(S);
|
|
642
670
|
return;
|
|
643
671
|
}
|
|
644
|
-
i.textContent = "⏳", this.h.onTranslate(
|
|
645
|
-
if (
|
|
672
|
+
i.textContent = "⏳", this.h.onTranslate(r).then((z) => {
|
|
673
|
+
if (z === null) {
|
|
646
674
|
i.textContent = "⚠️", i.title = "Translation unavailable", setTimeout(() => {
|
|
647
675
|
i.textContent = "🌐", i.title = "Translate";
|
|
648
676
|
}, 1500);
|
|
649
677
|
return;
|
|
650
678
|
}
|
|
651
|
-
this.translationCache.set(e.id,
|
|
679
|
+
this.translationCache.set(e.id, z), m(z);
|
|
652
680
|
});
|
|
653
|
-
}),
|
|
681
|
+
}), x.append(i);
|
|
654
682
|
const k = this.translationCache.get(e.id);
|
|
655
|
-
this.showingTranslation.has(e.id) && k !== void 0 &&
|
|
683
|
+
this.showingTranslation.has(e.id) && k !== void 0 && m(k);
|
|
656
684
|
}
|
|
657
685
|
}
|
|
658
|
-
if (
|
|
659
|
-
const
|
|
686
|
+
if (f && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
|
|
687
|
+
const r = n("div", "ocw-msg-menu");
|
|
660
688
|
if (this.h.onEdit) {
|
|
661
689
|
const i = n("button", void 0, "✏️");
|
|
662
|
-
i.title = "Edit", i.addEventListener("click", (
|
|
663
|
-
|
|
664
|
-
const
|
|
665
|
-
|
|
690
|
+
i.title = "Edit", i.addEventListener("click", (h) => {
|
|
691
|
+
h.stopPropagation();
|
|
692
|
+
const m = se(e.content), v = document.createElement("textarea");
|
|
693
|
+
v.value = m, v.rows = Math.min(4, Math.ceil(m.length / 40) + 1), v.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";
|
|
666
694
|
const k = n("button", "ocw-form-submit", "Save");
|
|
667
695
|
k.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
const D =
|
|
677
|
-
D && D !==
|
|
678
|
-
}),
|
|
679
|
-
D.key === "Enter" && !D.shiftKey && (D.preventDefault(), k.click()), D.key === "Escape" &&
|
|
696
|
+
const w = n("button", "ocw-form-cancel", "Cancel");
|
|
697
|
+
w.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
|
|
698
|
+
const S = n("div");
|
|
699
|
+
S.style.cssText = "display:flex;gap:6px;justify-content:flex-end", S.append(w, k);
|
|
700
|
+
const z = n("div");
|
|
701
|
+
z.append(v, S), u.replaceChildren(z), v.focus(), v.select();
|
|
702
|
+
const U = () => u.replaceChildren(d ?? document.createTextNode(m));
|
|
703
|
+
w.addEventListener("click", U), k.addEventListener("click", () => {
|
|
704
|
+
const D = v.value.trim();
|
|
705
|
+
D && D !== m && this.h.onEdit(e.id, D), U();
|
|
706
|
+
}), v.addEventListener("keydown", (D) => {
|
|
707
|
+
D.key === "Enter" && !D.shiftKey && (D.preventDefault(), k.click()), D.key === "Escape" && U();
|
|
680
708
|
});
|
|
681
|
-
}),
|
|
709
|
+
}), r.append(i);
|
|
682
710
|
}
|
|
683
711
|
if (this.h.onDelete) {
|
|
684
712
|
const i = n("button", "del", "🗑");
|
|
685
|
-
i.title = "Delete", i.addEventListener("click", (
|
|
686
|
-
|
|
687
|
-
}),
|
|
713
|
+
i.title = "Delete", i.addEventListener("click", (h) => {
|
|
714
|
+
h.stopPropagation(), this.h.onDelete(e.id);
|
|
715
|
+
}), r.append(i);
|
|
688
716
|
}
|
|
689
|
-
|
|
717
|
+
x.append(r);
|
|
690
718
|
}
|
|
691
|
-
if (
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
719
|
+
if (s.append(x), e.senderRole === "bot" && !e.deletedAt && e.seq > 0 && e.content.kind === "text") {
|
|
720
|
+
const r = e.content.citations;
|
|
721
|
+
if (r != null && r.length) {
|
|
694
722
|
const i = n("div", "ocw-cites");
|
|
695
|
-
i.style.cssText = "margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)", i.textContent = `${((
|
|
723
|
+
i.style.cssText = "margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)", i.textContent = `${((j = this.cfg.i18n) == null ? void 0 : j.sources) ?? "Sources"}: ${r.map((h) => h.source).join(", ")}`, s.append(i);
|
|
696
724
|
}
|
|
697
725
|
if (this.h.onReact) {
|
|
698
726
|
const i = n("div", "ocw-bot-feedback");
|
|
699
727
|
i.style.cssText = "display:flex;gap:6px;margin-top:4px";
|
|
700
|
-
const
|
|
701
|
-
const k = n("button", "ocw-fb-btn",
|
|
702
|
-
k.type = "button", k.title =
|
|
703
|
-
const
|
|
704
|
-
var
|
|
705
|
-
return !!((
|
|
728
|
+
const h = (m, v) => {
|
|
729
|
+
const k = n("button", "ocw-fb-btn", m);
|
|
730
|
+
k.type = "button", k.title = v, k.style.cssText = "border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";
|
|
731
|
+
const w = () => {
|
|
732
|
+
var S, z;
|
|
733
|
+
return !!((z = (S = e.reactions) == null ? void 0 : S[m]) != null && z.includes(this.me));
|
|
706
734
|
};
|
|
707
|
-
return
|
|
708
|
-
var
|
|
709
|
-
(
|
|
735
|
+
return w() && (k.style.opacity = "1"), k.addEventListener("click", () => {
|
|
736
|
+
var S, z;
|
|
737
|
+
(z = (S = this.h).onReact) == null || z.call(S, e.id, m, w()), k.style.opacity = "1";
|
|
710
738
|
}), k;
|
|
711
739
|
};
|
|
712
|
-
i.append(
|
|
740
|
+
i.append(h("👍", ((_ = this.cfg.i18n) == null ? void 0 : _.helpful) ?? "Helpful"), h("👎", ((E = this.cfg.i18n) == null ? void 0 : E.notHelpful) ?? "Not helpful")), s.append(i);
|
|
713
741
|
}
|
|
714
742
|
}
|
|
715
743
|
if (this.h.onReact && !e.deletedAt && e.seq > 0) {
|
|
716
|
-
const
|
|
744
|
+
const r = n("div", "ocw-react-wrap"), i = n("div", "ocw-react");
|
|
717
745
|
if (e.reactions && Object.keys(e.reactions).length)
|
|
718
|
-
for (const [
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
var
|
|
722
|
-
return (
|
|
723
|
-
}), i.append(
|
|
746
|
+
for (const [v, k] of Object.entries(e.reactions)) {
|
|
747
|
+
const w = n("button", `ocw-react-pill${k.includes(this.me) ? " mine" : ""}`, `${v} ${k.length}`);
|
|
748
|
+
w.addEventListener("click", () => {
|
|
749
|
+
var S, z;
|
|
750
|
+
return (z = (S = this.h).onReact) == null ? void 0 : z.call(S, e.id, v, k.includes(this.me));
|
|
751
|
+
}), i.append(w);
|
|
724
752
|
}
|
|
725
|
-
const
|
|
726
|
-
for (const
|
|
727
|
-
const k = n("button", void 0,
|
|
728
|
-
k.addEventListener("click", (
|
|
729
|
-
var
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
(
|
|
733
|
-
}),
|
|
753
|
+
const h = n("button", "ocw-react-btn", "+"), m = n("div", "ocw-react-picker");
|
|
754
|
+
for (const v of Ke) {
|
|
755
|
+
const k = n("button", void 0, v);
|
|
756
|
+
k.addEventListener("click", (w) => {
|
|
757
|
+
var z, U, D, Q;
|
|
758
|
+
w.stopPropagation();
|
|
759
|
+
const S = (U = (z = e.reactions) == null ? void 0 : z[v]) == null ? void 0 : U.includes(this.me);
|
|
760
|
+
(Q = (D = this.h).onReact) == null || Q.call(D, e.id, v, !!S), m.style.display = "none";
|
|
761
|
+
}), m.append(k);
|
|
734
762
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
const k =
|
|
738
|
-
|
|
739
|
-
|
|
763
|
+
m.style.display = "none", h.addEventListener("click", (v) => {
|
|
764
|
+
v.stopPropagation();
|
|
765
|
+
const k = m.style.display === "none";
|
|
766
|
+
m.style.display = k ? "flex" : "none", k && document.addEventListener("click", () => {
|
|
767
|
+
m.style.display = "none";
|
|
740
768
|
}, { once: !0 });
|
|
741
|
-
}), i.append(
|
|
742
|
-
} else e.reactions && Object.keys(e.reactions).length &&
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
745
|
-
const
|
|
746
|
-
|
|
769
|
+
}), i.append(h), r.append(i, m), s.append(r);
|
|
770
|
+
} else e.reactions && Object.keys(e.reactions).length && s.append(n("div", "ocw-react", Object.entries(e.reactions).map(([r, i]) => `${r}${i.length}`).join(" ")));
|
|
771
|
+
const I = n("div", "ocw-time ocw-meta", Ze(e.ts));
|
|
772
|
+
if (f && e.status) {
|
|
773
|
+
const r = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, tt(e.status));
|
|
774
|
+
I.append(r);
|
|
747
775
|
}
|
|
748
|
-
return
|
|
776
|
+
return f && e.seq > 0 && l.lastReadByOthers >= e.seq && I.append(n("span", "ocw-seen", " · Seen")), s.append(I), y.append(s), y;
|
|
749
777
|
}
|
|
750
778
|
}
|
|
751
|
-
function
|
|
779
|
+
function tt(t) {
|
|
752
780
|
switch (t) {
|
|
753
781
|
case "read":
|
|
754
782
|
return "✓✓";
|
|
@@ -760,31 +788,31 @@ function Je(t) {
|
|
|
760
788
|
return "🕓";
|
|
761
789
|
}
|
|
762
790
|
}
|
|
763
|
-
const
|
|
764
|
-
function
|
|
791
|
+
const G = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new Map();
|
|
792
|
+
function Te(t) {
|
|
765
793
|
return `relay-launcher::${t.profileId}::${t.subjectId ?? ""}`;
|
|
766
794
|
}
|
|
767
|
-
let
|
|
768
|
-
function
|
|
769
|
-
if (
|
|
795
|
+
let X = null;
|
|
796
|
+
function nt() {
|
|
797
|
+
if (X && X.state !== "closed") return X;
|
|
770
798
|
try {
|
|
771
|
-
return
|
|
799
|
+
return X = new AudioContext(), X;
|
|
772
800
|
} catch {
|
|
773
801
|
return null;
|
|
774
802
|
}
|
|
775
803
|
}
|
|
776
|
-
function
|
|
804
|
+
function dt(t) {
|
|
777
805
|
var e;
|
|
778
|
-
(e =
|
|
806
|
+
(e = G.get(t)) == null || e.close(), G.delete(t);
|
|
779
807
|
}
|
|
780
|
-
function
|
|
808
|
+
function ot(t) {
|
|
781
809
|
const e = t.el;
|
|
782
|
-
let l = null,
|
|
783
|
-
const
|
|
784
|
-
l == null || l.close(), l = null,
|
|
810
|
+
let l = null, c = null, a = !1;
|
|
811
|
+
const f = () => {
|
|
812
|
+
l == null || l.close(), l = null, c == null || c.close(), c = null, e.innerHTML = "";
|
|
785
813
|
};
|
|
786
814
|
function b() {
|
|
787
|
-
|
|
815
|
+
a || (f(), c = De({
|
|
788
816
|
el: e,
|
|
789
817
|
url: t.url,
|
|
790
818
|
...t.apiUrl ? { apiUrl: t.apiUrl } : {},
|
|
@@ -795,46 +823,48 @@ function et(t) {
|
|
|
795
823
|
...t.accent ? { accent: t.accent } : {},
|
|
796
824
|
...t.theme ? { theme: t.theme } : {},
|
|
797
825
|
...t.webfont === !1 ? { webfont: !1 } : {},
|
|
798
|
-
|
|
826
|
+
...t.locale ? { locale: t.locale } : {},
|
|
827
|
+
...t.i18n ? { i18n: t.i18n } : {},
|
|
828
|
+
onSelect: (s) => y(s)
|
|
799
829
|
}));
|
|
800
830
|
}
|
|
801
|
-
function y(
|
|
802
|
-
if (
|
|
803
|
-
|
|
804
|
-
const { subjectId:
|
|
805
|
-
l =
|
|
806
|
-
...
|
|
831
|
+
function y(s) {
|
|
832
|
+
if (a) return;
|
|
833
|
+
f();
|
|
834
|
+
const { subjectId: x, kind: u, peerId: d, ...I } = t;
|
|
835
|
+
l = it({
|
|
836
|
+
...I,
|
|
807
837
|
inbox: !1,
|
|
808
838
|
launcher: !1,
|
|
809
839
|
el: e,
|
|
810
|
-
...
|
|
811
|
-
...
|
|
812
|
-
...
|
|
840
|
+
...s.profileId ? { profileId: s.profileId } : {},
|
|
841
|
+
...s.subjectId ? { subjectId: s.subjectId } : {},
|
|
842
|
+
...s.kind === "direct" && s.peerId ? { kind: "direct", peerId: s.peerId } : {},
|
|
813
843
|
onBack: b
|
|
814
844
|
});
|
|
815
845
|
}
|
|
816
846
|
return b(), { close() {
|
|
817
|
-
|
|
847
|
+
a = !0, f();
|
|
818
848
|
} };
|
|
819
849
|
}
|
|
820
|
-
function
|
|
821
|
-
var
|
|
822
|
-
if (t.inbox) return
|
|
823
|
-
|
|
850
|
+
function it(t) {
|
|
851
|
+
var pe, ue, he, fe, we, be, xe, me;
|
|
852
|
+
if (t.inbox) return ot(t);
|
|
853
|
+
G.has(t.el) && (G.get(t.el).close(), G.delete(t.el)), t.launcher && ((pe = oe.get(Te(t))) == null || pe.close());
|
|
824
854
|
const e = Me();
|
|
825
|
-
let l,
|
|
826
|
-
const
|
|
827
|
-
let
|
|
828
|
-
const
|
|
829
|
-
let
|
|
855
|
+
let l, c = !1;
|
|
856
|
+
const a = t.token ?? t.userId ?? e, f = a !== e ? e : void 0, { wsUrl: b, httpBase: y } = Ae(t.url, t.apiUrl);
|
|
857
|
+
let s = new _e(a);
|
|
858
|
+
const x = t.subjectId ? `${a}::${t.subjectId}` : a, u = new He(x);
|
|
859
|
+
let d, I = !1, T = null, L = null, B = null, M = null;
|
|
830
860
|
!t.launcher && !t.el.style.height && t.el.clientHeight === 0 && (t.el.style.width = t.el.style.width || "100%", t.el.style.height = "600px");
|
|
831
|
-
for (const o of
|
|
832
|
-
let
|
|
861
|
+
for (const o of u.load()) s.addOptimistic(o.clientMsgId, o.content);
|
|
862
|
+
let A = null, P = null, O = 0, j = !t.launcher;
|
|
833
863
|
if (t.launcher) {
|
|
834
864
|
const p = (t.position ?? "bottom-right").includes("right");
|
|
835
|
-
|
|
836
|
-
const g = document.createElement("div"),
|
|
837
|
-
t.el.classList.toggle("ocw-fs",
|
|
865
|
+
A = document.createElement("div"), A.style.cssText = `position:fixed;${p ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${p ? "flex-end" : "flex-start"};gap:12px`;
|
|
866
|
+
const g = document.createElement("div"), $ = typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(max-width: 479px)") : null, W = (q) => {
|
|
867
|
+
t.el.classList.toggle("ocw-fs", q), g.style.cssText = q ? [
|
|
838
868
|
"position:fixed",
|
|
839
869
|
"inset:0",
|
|
840
870
|
"width:100%",
|
|
@@ -863,10 +893,10 @@ function tt(t) {
|
|
|
863
893
|
"transform:scale(.95)"
|
|
864
894
|
].join(";");
|
|
865
895
|
};
|
|
866
|
-
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
const
|
|
896
|
+
W(($ == null ? void 0 : $.matches) ?? !1);
|
|
897
|
+
const Y = (q) => W(q.matches);
|
|
898
|
+
$ == null || $.addEventListener("change", Y), T = $, L = Y, t.el.style.cssText = "width:100%;height:100%;overflow:hidden", g.append(t.el);
|
|
899
|
+
const Z = '<svg viewBox="0 0 24 24" width="26" height="26" 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>', ee = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>', H = document.createElement("button");
|
|
870
900
|
H.type = "button", H.style.cssText = [
|
|
871
901
|
"width:56px;height:56px;border-radius:50%",
|
|
872
902
|
`background:${t.accent ?? "#6c5ce7"}`,
|
|
@@ -879,27 +909,27 @@ function tt(t) {
|
|
|
879
909
|
H.style.transform = "scale(1.08)";
|
|
880
910
|
}, H.onmouseleave = () => {
|
|
881
911
|
H.style.transform = "scale(1)";
|
|
882
|
-
},
|
|
883
|
-
const
|
|
884
|
-
H.innerHTML =
|
|
912
|
+
}, P = document.createElement("span"), P.style.cssText = "position:absolute;top:-4px;right:-4px;background:#4c6fff;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center";
|
|
913
|
+
const te = () => {
|
|
914
|
+
H.innerHTML = j ? ee : Z, H.setAttribute("aria-label", j ? "Close chat" : "Open chat"), H.setAttribute("aria-expanded", String(j)), H.append(P);
|
|
885
915
|
};
|
|
886
|
-
|
|
887
|
-
const
|
|
888
|
-
let
|
|
889
|
-
const
|
|
916
|
+
te(), A.append(g, H), document.body.append(A);
|
|
917
|
+
const ie = `ocw-teaser-dismissed::${t.profileId}`, ne = typeof t.launcherMessage == "string" ? { title: t.launcherMessage } : t.launcherMessage;
|
|
918
|
+
let R = null;
|
|
919
|
+
const je = () => {
|
|
890
920
|
try {
|
|
891
|
-
return sessionStorage.getItem(
|
|
921
|
+
return sessionStorage.getItem(ie) === "1";
|
|
892
922
|
} catch {
|
|
893
923
|
return !1;
|
|
894
924
|
}
|
|
895
|
-
}, 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>',
|
|
896
|
-
const
|
|
897
|
-
if (!(!!(
|
|
898
|
-
|
|
925
|
+
}, 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>', ge = () => {
|
|
926
|
+
const q = ne != null && ne.title ? ne : s.launcherMessage ?? void 0;
|
|
927
|
+
if (!(!!(q != null && q.title) && !j && !je())) {
|
|
928
|
+
R && (R.remove(), R = null);
|
|
899
929
|
return;
|
|
900
930
|
}
|
|
901
|
-
if (
|
|
902
|
-
|
|
931
|
+
if (R) return;
|
|
932
|
+
R = document.createElement("div"), R.setAttribute("role", "button"), R.setAttribute("tabindex", "0"), R.setAttribute("aria-label", q.title), R.style.cssText = [
|
|
903
933
|
"max-width:280px",
|
|
904
934
|
"background:#fff",
|
|
905
935
|
"border-radius:16px",
|
|
@@ -911,61 +941,61 @@ function tt(t) {
|
|
|
911
941
|
`align-self:${p ? "flex-end" : "flex-start"}`,
|
|
912
942
|
"animation:ocw-teaser-in .22s ease-out"
|
|
913
943
|
].join(";");
|
|
914
|
-
const
|
|
915
|
-
if (
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
const
|
|
921
|
-
|
|
944
|
+
const ce = document.createElement("div");
|
|
945
|
+
if (ce.textContent = q.title, ce.style.cssText = "font-size:15px;font-weight:600;color:#111;line-height:1.35", R.append(ce), q.subtitle) {
|
|
946
|
+
const F = document.createElement("div");
|
|
947
|
+
F.style.cssText = "display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";
|
|
948
|
+
const re = document.createElement("span");
|
|
949
|
+
re.innerHTML = Pe, re.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
|
|
950
|
+
const ve = document.createElement("span");
|
|
951
|
+
ve.textContent = q.subtitle, F.append(re, ve), R.append(F);
|
|
922
952
|
}
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
953
|
+
const K = document.createElement("button");
|
|
954
|
+
K.type = "button", K.setAttribute("aria-label", "Dismiss"), K.innerHTML = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>', K.style.cssText = "position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:#f3f4f6;color:#6b7280;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0", K.addEventListener("click", (F) => {
|
|
955
|
+
F.stopPropagation();
|
|
926
956
|
try {
|
|
927
|
-
sessionStorage.setItem(
|
|
957
|
+
sessionStorage.setItem(ie, "1");
|
|
928
958
|
} catch {
|
|
929
959
|
}
|
|
930
|
-
|
|
931
|
-
}),
|
|
932
|
-
const
|
|
933
|
-
|
|
960
|
+
R && (R.remove(), R = null);
|
|
961
|
+
}), R.append(K);
|
|
962
|
+
const ye = () => {
|
|
963
|
+
j || (j = !0, ae(!0), te(), O = 0, P && (P.style.display = "none"), R && (R.remove(), R = null));
|
|
934
964
|
};
|
|
935
|
-
|
|
936
|
-
(
|
|
937
|
-
}),
|
|
965
|
+
R.addEventListener("click", ye), R.addEventListener("keydown", (F) => {
|
|
966
|
+
(F.key === "Enter" || F.key === " ") && (F.preventDefault(), ye());
|
|
967
|
+
}), A.insertBefore(R, H);
|
|
938
968
|
};
|
|
939
969
|
if (!document.getElementById("ocw-teaser-style")) {
|
|
940
|
-
const
|
|
941
|
-
|
|
970
|
+
const q = document.createElement("style");
|
|
971
|
+
q.id = "ocw-teaser-style", q.textContent = "@keyframes ocw-teaser-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}", document.head.append(q);
|
|
942
972
|
}
|
|
943
|
-
|
|
944
|
-
const
|
|
945
|
-
|
|
973
|
+
M = ge, ge();
|
|
974
|
+
const ae = (q) => {
|
|
975
|
+
q ? (g.style.display = "flex", requestAnimationFrame(() => {
|
|
946
976
|
g.style.opacity = "1", g.style.transform = "scale(1)";
|
|
947
977
|
})) : (g.style.opacity = "0", g.style.transform = "scale(.95)", setTimeout(() => {
|
|
948
|
-
|
|
978
|
+
j || (g.style.display = "none");
|
|
949
979
|
}, 180));
|
|
950
980
|
};
|
|
951
981
|
H.addEventListener("click", () => {
|
|
952
|
-
if (
|
|
953
|
-
O = 0,
|
|
982
|
+
if (j = !j, ae(j), te(), j) {
|
|
983
|
+
O = 0, P && (P.style.display = "none");
|
|
954
984
|
try {
|
|
955
|
-
sessionStorage.setItem(
|
|
985
|
+
sessionStorage.setItem(ie, "1");
|
|
956
986
|
} catch {
|
|
957
987
|
}
|
|
958
988
|
}
|
|
959
|
-
|
|
960
|
-
}),
|
|
961
|
-
|
|
962
|
-
}, document.addEventListener("keydown",
|
|
989
|
+
M == null || M();
|
|
990
|
+
}), B = (q) => {
|
|
991
|
+
q.key === "Escape" && j && (j = !1, ae(!1), te());
|
|
992
|
+
}, document.addEventListener("keydown", B);
|
|
963
993
|
}
|
|
964
994
|
const _ = () => {
|
|
965
|
-
|
|
966
|
-
},
|
|
995
|
+
j || (O++, P && (P.textContent = String(O), P.style.display = "flex"));
|
|
996
|
+
}, E = () => {
|
|
967
997
|
try {
|
|
968
|
-
const o =
|
|
998
|
+
const o = nt();
|
|
969
999
|
if (!o) return;
|
|
970
1000
|
o.state === "suspended" && o.resume().catch(() => {
|
|
971
1001
|
});
|
|
@@ -973,77 +1003,77 @@ function tt(t) {
|
|
|
973
1003
|
p.connect(g), g.connect(o.destination), p.frequency.setValueAtTime(880, o.currentTime), p.frequency.exponentialRampToValueAtTime(440, o.currentTime + 0.15), g.gain.setValueAtTime(0.3, o.currentTime), g.gain.exponentialRampToValueAtTime(1e-3, o.currentTime + 0.3), p.start(), p.stop(o.currentTime + 0.3);
|
|
974
1004
|
} catch {
|
|
975
1005
|
}
|
|
976
|
-
},
|
|
977
|
-
for (;
|
|
978
|
-
const p =
|
|
979
|
-
|
|
1006
|
+
}, r = [], i = (o) => {
|
|
1007
|
+
for (; r.length; ) {
|
|
1008
|
+
const p = r.shift();
|
|
1009
|
+
u.add({ clientMsgId: p.clientMsgId, content: p.content, ts: Date.now() }), h.send({ type: "send", conversationId: o, clientMsgId: p.clientMsgId, content: p.content });
|
|
980
1010
|
}
|
|
981
1011
|
};
|
|
982
|
-
let
|
|
983
|
-
const
|
|
984
|
-
let
|
|
985
|
-
const
|
|
986
|
-
let
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
1012
|
+
let h;
|
|
1013
|
+
const m = new Fe(`ocw-e2e-${t.profileId}`);
|
|
1014
|
+
let v = !1;
|
|
1015
|
+
const k = [], w = [];
|
|
1016
|
+
let S = !1;
|
|
1017
|
+
const z = (o, p) => {
|
|
1018
|
+
m.sealText(p).then((g) => {
|
|
1019
|
+
d && h.send({ type: "send", conversationId: d, clientMsgId: o, content: g });
|
|
990
1020
|
});
|
|
991
|
-
},
|
|
992
|
-
|
|
993
|
-
|
|
1021
|
+
}, U = (o, p, g) => {
|
|
1022
|
+
m.sealText(p, g).then(($) => {
|
|
1023
|
+
d && h.send({ type: "send", conversationId: d, clientMsgId: o, content: $ });
|
|
994
1024
|
});
|
|
995
|
-
},
|
|
996
|
-
for (;
|
|
997
|
-
const o =
|
|
998
|
-
|
|
1025
|
+
}, D = () => {
|
|
1026
|
+
for (; k.length; ) {
|
|
1027
|
+
const o = k.shift();
|
|
1028
|
+
z(o.clientMsgId, o.text);
|
|
999
1029
|
}
|
|
1000
|
-
for (;
|
|
1001
|
-
const o =
|
|
1002
|
-
|
|
1030
|
+
for (; w.length; ) {
|
|
1031
|
+
const o = w.shift();
|
|
1032
|
+
z(o.clientMsgId, o.text);
|
|
1003
1033
|
}
|
|
1004
|
-
},
|
|
1005
|
-
|
|
1006
|
-
}, Se = t.i18n
|
|
1034
|
+
}, Q = (o) => {
|
|
1035
|
+
h.send({ type: "fetchPrekey", targetUserId: o });
|
|
1036
|
+
}, Se = qe(t.locale, t.i18n), Ee = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
|
|
1007
1037
|
Ee.includes(ze) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
|
|
1008
|
-
const
|
|
1038
|
+
const le = `oc_prechat_${t.profileId}_${a.slice(-8)}`, N = new et(t.el, a, {
|
|
1009
1039
|
onSend(o) {
|
|
1010
1040
|
const p = `cm_${Math.random().toString(36).slice(2)}`, g = { kind: "text", text: o };
|
|
1011
|
-
|
|
1041
|
+
s.addOptimistic(p, g), N.render(s), s.e2e ? m.ready ? z(p, o) : S ? w.push({ clientMsgId: p, text: o }) : (k.push({ clientMsgId: p, text: o }), s.assignedAgentId && Q(s.assignedAgentId)) : d ? (u.add({ clientMsgId: p, content: g, ts: Date.now() }), h.send({ type: "send", conversationId: d, clientMsgId: p, content: g })) : r.push({ clientMsgId: p, content: g });
|
|
1012
1042
|
},
|
|
1013
1043
|
async onAttach(o) {
|
|
1014
|
-
if (!
|
|
1044
|
+
if (!d) return;
|
|
1015
1045
|
const p = `${y}/upload?name=${encodeURIComponent(o.name)}`, g = `cm_${Math.random().toString(36).slice(2)}`;
|
|
1016
|
-
|
|
1046
|
+
s.addOptimistic(g, { kind: "text", text: `📎 Uploading ${o.name}…` }), N.render(s);
|
|
1017
1047
|
try {
|
|
1018
|
-
const
|
|
1048
|
+
const $ = await fetch(p, {
|
|
1019
1049
|
method: "POST",
|
|
1020
1050
|
// Use the resolved connection token (a signed JWT, an explicit userId,
|
|
1021
1051
|
// or the anonymous persistent uid) — NOT just opts.token. The server
|
|
1022
1052
|
// requires an Authorization header, and the verifier accepts an
|
|
1023
1053
|
// anonymous id as a guest; keying off opts.token alone meant anonymous
|
|
1024
1054
|
// visitors (the common case) sent no auth and every upload 401'd.
|
|
1025
|
-
headers: { "content-type": o.type, authorization: `Bearer ${
|
|
1055
|
+
headers: { "content-type": o.type, authorization: `Bearer ${a}` },
|
|
1026
1056
|
body: o
|
|
1027
1057
|
});
|
|
1028
|
-
if (
|
|
1029
|
-
const { url:
|
|
1030
|
-
|
|
1031
|
-
} catch (
|
|
1032
|
-
|
|
1058
|
+
if (!$.ok) throw new Error(`Upload failed: ${$.status}`);
|
|
1059
|
+
const { url: W, name: Y, mime: Z, size: ee } = await $.json();
|
|
1060
|
+
s.addOptimistic(g, { kind: "attachment", url: W, name: Y, mime: Z, size: ee }), N.render(s), h.send({ type: "send", conversationId: d, clientMsgId: g, content: { kind: "attachment", url: W, name: Y, mime: Z, size: ee } });
|
|
1061
|
+
} catch ($) {
|
|
1062
|
+
s.addOptimistic(g, { kind: "text", text: `⚠️ Upload failed: ${$.message}` }), N.render(s);
|
|
1033
1063
|
}
|
|
1034
1064
|
},
|
|
1035
1065
|
onInvoke(o, p) {
|
|
1036
|
-
|
|
1066
|
+
d && h.send({ type: "invoke", conversationId: d, actionId: o, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...p ? { inputs: p } : {} });
|
|
1037
1067
|
},
|
|
1038
1068
|
onTyping(o, p) {
|
|
1039
|
-
|
|
1069
|
+
d && h.send({ type: "typing", conversationId: d, isTyping: o, ...p ? { preview: p } : {} });
|
|
1040
1070
|
},
|
|
1041
1071
|
onPreChat(o) {
|
|
1042
1072
|
try {
|
|
1043
|
-
localStorage.setItem(
|
|
1073
|
+
localStorage.setItem(le, "1");
|
|
1044
1074
|
} catch {
|
|
1045
1075
|
}
|
|
1046
|
-
|
|
1076
|
+
h.send({
|
|
1047
1077
|
type: "open",
|
|
1048
1078
|
profileId: t.profileId,
|
|
1049
1079
|
...t.subjectId ? { subjectId: t.subjectId } : {},
|
|
@@ -1057,67 +1087,70 @@ function tt(t) {
|
|
|
1057
1087
|
}
|
|
1058
1088
|
});
|
|
1059
1089
|
const p = o.callback ? `📞 Call-back requested${o.phone ? `: ${o.phone}` : ""}${o.topic ? ` — ${o.topic}` : ""}` : o.topic ? `Topic: ${o.topic}` : "";
|
|
1060
|
-
p &&
|
|
1090
|
+
p && d && !s.e2e && h.send({ type: "send", conversationId: d, clientMsgId: `pc_${Math.random().toString(36).slice(2, 12)}`, content: { kind: "text", text: p } });
|
|
1061
1091
|
},
|
|
1062
|
-
...((
|
|
1092
|
+
...((ue = t.features) == null ? void 0 : ue.deflection) !== !1 ? {
|
|
1063
1093
|
onDeflectQuery(o) {
|
|
1064
|
-
if (
|
|
1094
|
+
if (c) return;
|
|
1065
1095
|
clearTimeout(l);
|
|
1066
1096
|
const p = o.trim();
|
|
1067
1097
|
if (p.length < 3) {
|
|
1068
|
-
|
|
1098
|
+
N.hideDeflection();
|
|
1069
1099
|
return;
|
|
1070
1100
|
}
|
|
1071
1101
|
l = setTimeout(() => {
|
|
1072
|
-
fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(p.slice(0, 200))}`).then((g) => g.ok ? g.json() : { articles: [] }).then((g) =>
|
|
1102
|
+
fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(p.slice(0, 200))}`).then((g) => g.ok ? g.json() : { articles: [] }).then((g) => N.showDeflection(g.articles ?? [])).catch(() => N.hideDeflection());
|
|
1073
1103
|
}, 350);
|
|
1074
1104
|
}
|
|
1075
1105
|
} : {},
|
|
1076
1106
|
onReadUpTo(o) {
|
|
1077
|
-
|
|
1107
|
+
d && h.send({ type: "read", conversationId: d, seq: o });
|
|
1078
1108
|
},
|
|
1079
1109
|
onLoadMore() {
|
|
1080
|
-
if (!
|
|
1081
|
-
const o =
|
|
1082
|
-
o &&
|
|
1110
|
+
if (!d || !s.e2e) return;
|
|
1111
|
+
const o = s.messages()[0];
|
|
1112
|
+
o && h.send({ type: "history", conversationId: d, beforeSeq: o.seq, limit: 20 });
|
|
1083
1113
|
},
|
|
1084
1114
|
onEdit(o, p) {
|
|
1085
|
-
|
|
1115
|
+
d && h.send({ type: "edit", conversationId: d, messageId: o, content: { kind: "text", text: p } });
|
|
1086
1116
|
},
|
|
1087
1117
|
onDelete(o) {
|
|
1088
|
-
|
|
1118
|
+
d && h.send({ type: "delete", conversationId: d, messageId: o });
|
|
1089
1119
|
},
|
|
1090
|
-
...((
|
|
1120
|
+
...((he = t.features) == null ? void 0 : he.reactions) !== !1 ? {
|
|
1091
1121
|
onReact(o, p, g) {
|
|
1092
|
-
|
|
1122
|
+
d && h.send({ type: "react", conversationId: d, messageId: o, emoji: p, remove: g });
|
|
1093
1123
|
}
|
|
1094
1124
|
} : {},
|
|
1095
|
-
...((
|
|
1125
|
+
...((fe = t.features) == null ? void 0 : fe.csat) !== !1 ? {
|
|
1096
1126
|
onCsat(o) {
|
|
1097
|
-
|
|
1127
|
+
d && fetch(`${y}/conversations/${d}/csat`, {
|
|
1098
1128
|
method: "POST",
|
|
1099
|
-
headers: { "Content-Type": "application/json", Authorization: `Bearer ${
|
|
1129
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${a}` },
|
|
1100
1130
|
body: JSON.stringify({ score: o })
|
|
1101
1131
|
}).catch(() => {
|
|
1102
1132
|
});
|
|
1103
1133
|
}
|
|
1104
1134
|
} : {},
|
|
1105
|
-
...
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1135
|
+
...(() => {
|
|
1136
|
+
const o = t.locale ?? (typeof navigator < "u" ? navigator.language : ""), p = t.translateLang !== void 0 ? t.translateLang : o ? o.split("-")[0] : Ne();
|
|
1137
|
+
return p ? {
|
|
1138
|
+
async onTranslate(g) {
|
|
1139
|
+
try {
|
|
1140
|
+
const $ = await fetch(`${y}/translate`, {
|
|
1141
|
+
method: "POST",
|
|
1142
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${a}` },
|
|
1143
|
+
body: JSON.stringify({ text: g, targetLang: p })
|
|
1144
|
+
});
|
|
1145
|
+
if (!$.ok) return null;
|
|
1146
|
+
const { translated: W } = await $.json();
|
|
1147
|
+
return W;
|
|
1148
|
+
} catch {
|
|
1149
|
+
return null;
|
|
1150
|
+
}
|
|
1118
1151
|
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1152
|
+
} : {};
|
|
1153
|
+
})(),
|
|
1121
1154
|
...t.onBack ? { onBack: t.onBack } : {}
|
|
1122
1155
|
}, {
|
|
1123
1156
|
...t.subject ? { subject: t.subject } : {},
|
|
@@ -1126,107 +1159,107 @@ function tt(t) {
|
|
|
1126
1159
|
...t.accent2 ? { accent2: t.accent2 } : {},
|
|
1127
1160
|
...t.theme ? { theme: t.theme } : {},
|
|
1128
1161
|
...t.webfont === !1 ? { webfont: !1 } : {},
|
|
1129
|
-
...(
|
|
1162
|
+
...(we = t.user) != null && we.name || (be = t.user) != null && be.avatar ? { userInfo: { ...t.user.name ? { name: t.user.name } : {}, ...t.user.avatar ? { avatar: t.user.avatar } : {} } } : {},
|
|
1130
1163
|
i18n: Se
|
|
1131
1164
|
});
|
|
1132
1165
|
try {
|
|
1133
|
-
localStorage.getItem(
|
|
1166
|
+
localStorage.getItem(le) && N.completePreChat();
|
|
1134
1167
|
} catch {
|
|
1135
1168
|
}
|
|
1136
|
-
const
|
|
1169
|
+
const de = t.user && (t.user.name || t.user.email || t.user.avatar || t.user.meta) ? {
|
|
1137
1170
|
...t.user.name ? { name: t.user.name } : {},
|
|
1138
1171
|
...t.user.email ? { email: t.user.email } : {},
|
|
1139
1172
|
...t.user.avatar ? { avatar: t.user.avatar } : {},
|
|
1140
1173
|
...t.user.meta ? { meta: t.user.meta } : {}
|
|
1141
|
-
} : void 0,
|
|
1174
|
+
} : void 0, Le = {
|
|
1142
1175
|
type: "open",
|
|
1143
1176
|
profileId: t.profileId,
|
|
1144
1177
|
// Direct conversations use the kind/peerId pair; the dm:… subject key is
|
|
1145
1178
|
// server-derived and owner-keyed, so passing it as subjectId from the
|
|
1146
1179
|
// NON-owner side would find-or-create a junk duplicate thread.
|
|
1147
1180
|
...t.kind === "direct" && t.peerId ? { kind: "direct", peerId: t.peerId } : t.subjectId ? { subjectId: t.subjectId } : {},
|
|
1148
|
-
...
|
|
1149
|
-
...
|
|
1181
|
+
...f ? { linkFrom: f } : {},
|
|
1182
|
+
...de ? { userInfo: de } : {},
|
|
1150
1183
|
...typeof location < "u" ? { pageUrl: location.href } : {},
|
|
1151
1184
|
...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
|
|
1152
1185
|
// Pass subject display info so the server can persist it to the Subject record.
|
|
1153
1186
|
// This is how listingTitle and listingMeta get saved without a separate API call.
|
|
1154
|
-
...(
|
|
1155
|
-
...(
|
|
1187
|
+
...(xe = t.subject) != null && xe.title ? { subjectTitle: t.subject.title } : {},
|
|
1188
|
+
...(me = t.subject) != null && me.subtitle ? { subjectMeta: t.subject.subtitle } : {}
|
|
1156
1189
|
};
|
|
1157
|
-
|
|
1190
|
+
h = new Ue({
|
|
1158
1191
|
...t.refreshToken ? { refreshToken: t.refreshToken } : {},
|
|
1159
1192
|
url: b,
|
|
1160
|
-
token:
|
|
1161
|
-
open:
|
|
1162
|
-
getCursor: () =>
|
|
1163
|
-
onStatusChange: (o, p) =>
|
|
1193
|
+
token: a,
|
|
1194
|
+
open: Le,
|
|
1195
|
+
getCursor: () => s.highestSeq(),
|
|
1196
|
+
onStatusChange: (o, p) => N.setConnStatus(o, p),
|
|
1164
1197
|
onFrame(o) {
|
|
1165
1198
|
if (o.type === "opened") {
|
|
1166
|
-
if (
|
|
1167
|
-
|
|
1168
|
-
for (const p of
|
|
1169
|
-
|
|
1199
|
+
if (d = o.conversation.id, !I) {
|
|
1200
|
+
I = !0;
|
|
1201
|
+
for (const p of u.load())
|
|
1202
|
+
h.send({ type: "send", conversationId: d, clientMsgId: p.clientMsgId, content: p.content });
|
|
1170
1203
|
}
|
|
1171
|
-
|
|
1204
|
+
Oe(b, a, d, s, N, y), r.length && i(d);
|
|
1172
1205
|
}
|
|
1173
|
-
if (o.type === "ack" &&
|
|
1174
|
-
o.bundle && (
|
|
1175
|
-
const g = [...
|
|
1176
|
-
for (const
|
|
1177
|
-
|
|
1206
|
+
if (o.type === "ack" && u.remove(o.clientMsgId), o.type === "prekeyBundle") {
|
|
1207
|
+
o.bundle && (S = !0, m.x3dhSendTo(o.bundle).then((p) => {
|
|
1208
|
+
const g = [...k.splice(0), ...w.splice(0)];
|
|
1209
|
+
for (const $ of g) U($.clientMsgId, $.text, p);
|
|
1210
|
+
N.render(s);
|
|
1178
1211
|
}));
|
|
1179
1212
|
return;
|
|
1180
1213
|
}
|
|
1181
|
-
if (o.type === "message" &&
|
|
1182
|
-
const p =
|
|
1183
|
-
if (p && !
|
|
1184
|
-
|
|
1185
|
-
await
|
|
1214
|
+
if (o.type === "message" && s.e2e) {
|
|
1215
|
+
const p = We(o.message.content);
|
|
1216
|
+
if (p && !m.ready) {
|
|
1217
|
+
m.x3dhReceiveFrom(p.x3dhIK, p.x3dhEK, p.x3dhSPK, p.x3dhOTP).then(async () => {
|
|
1218
|
+
await m.openFrame(o), s.apply(o), N.render(s);
|
|
1186
1219
|
});
|
|
1187
1220
|
return;
|
|
1188
1221
|
}
|
|
1189
1222
|
}
|
|
1190
1223
|
if (o.type === "peerkey") {
|
|
1191
|
-
|
|
1192
|
-
|
|
1224
|
+
m.onPeerKey(o.key).then(() => {
|
|
1225
|
+
D(), N.render(s);
|
|
1193
1226
|
});
|
|
1194
1227
|
return;
|
|
1195
1228
|
}
|
|
1196
1229
|
(async () => {
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1230
|
+
if (s.e2e && await m.openFrame(o), s.apply(o), o.type === "manifest") {
|
|
1231
|
+
M == null || M();
|
|
1199
1232
|
const p = o.botName;
|
|
1200
|
-
p &&
|
|
1233
|
+
p && N.setBotName(p);
|
|
1201
1234
|
}
|
|
1202
|
-
if (o.type === "message" && o.message.senderId !==
|
|
1203
|
-
|
|
1204
|
-
const p = await
|
|
1205
|
-
|
|
1206
|
-
const g = await
|
|
1207
|
-
|
|
1235
|
+
if (o.type === "message" && o.message.senderId !== a && !o.message.internal && (_(), E()), s.e2e && d && !v) {
|
|
1236
|
+
v = !0;
|
|
1237
|
+
const p = await m.initX3DH();
|
|
1238
|
+
h.send({ type: "uploadPrekeys", ...p });
|
|
1239
|
+
const g = await m.begin();
|
|
1240
|
+
h.send({ type: "pubkey", conversationId: d, key: g });
|
|
1208
1241
|
}
|
|
1209
|
-
|
|
1242
|
+
N.render(s);
|
|
1210
1243
|
})();
|
|
1211
1244
|
}
|
|
1212
|
-
}),
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1245
|
+
}), h.connect(), N.render(s);
|
|
1246
|
+
const V = t.launcher ? Te(t) : null, J = { close: () => {
|
|
1247
|
+
c = !0, clearTimeout(l), h.close(), A == null || A.remove(), N.destroy(), T && L && T.removeEventListener("change", L), B && (document.removeEventListener("keydown", B), B = null), G.delete(t.el), V && oe.get(V) === J && oe.delete(V);
|
|
1215
1248
|
} };
|
|
1216
|
-
return
|
|
1249
|
+
return G.set(t.el, J), V && oe.set(V, J), J;
|
|
1217
1250
|
}
|
|
1218
1251
|
export {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1252
|
+
_e as ChatStore,
|
|
1253
|
+
Ue as ConnectionManager,
|
|
1254
|
+
Fe as E2ESession,
|
|
1255
|
+
He as PersistentOutbox,
|
|
1256
|
+
et as Renderer,
|
|
1257
|
+
wt as asConversationId,
|
|
1258
|
+
We as extractX3DHInit,
|
|
1259
|
+
ht as httpBaseFromWsUrl,
|
|
1260
|
+
it as mount,
|
|
1228
1261
|
Ae as resolveRelayUrls,
|
|
1229
|
-
|
|
1230
|
-
|
|
1262
|
+
Oe as restoreHistory,
|
|
1263
|
+
dt as unmount
|
|
1231
1264
|
};
|
|
1232
1265
|
//# sourceMappingURL=index.js.map
|