@paramms/chat-widget 1.9.0 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,16 +1,19 @@
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 ke, p as Me, r as Ae, c as qe, f as Ne, a as Oe, m as De } from "./chatlist2.js";
4
+ import { l as Me, b as ke, p as Re, r as Ae, c as qe, f as Ne, a as Oe, m as De } from "./chatlist2.js";
5
5
  import { h as ht } from "./chatlist2.js";
6
6
  import { P as He, C as _e, b as Ue } from "./outbox.js";
7
7
  import { e as wt } from "./outbox.js";
8
8
  import { E2ESession as Fe, extractX3DHInit as We } from "./e2e.js";
9
9
  const Ge = `
10
- .ocw { ${Re("ocw")}
10
+ .ocw { ${Me("ocw")}
11
11
  position:relative;
12
- display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
12
+ display:flex; flex-direction:column; height:100%; min-height:320px; max-width:100%; background:var(--ocw-bg);
13
13
  font-family:var(--ocw-fb); color:var(--ocw-ink); overflow:hidden; }
14
+ .ocw, .ocw *, .ocw *::before, .ocw *::after { box-sizing:border-box; }
15
+ .ocw input, .ocw textarea, .ocw select, .ocw button { font-family:inherit; }
16
+ .ocw a, .ocw .ocw-bubble { overflow-wrap:anywhere; word-break:break-word; }
14
17
  @media (prefers-color-scheme: dark) { .ocw[data-theme="auto"] { ${ke("ocw")} } }
15
18
  .ocw[data-theme="dark"] { ${ke("ocw")} }
16
19
  /* ── Responsive sizing ──────────────────────────────────────────────────────
@@ -58,7 +61,7 @@ const Ge = `
58
61
  .ocw-chiprow { display:flex; gap:8px; padding:10px 12px; background:var(--ocw-card); border-bottom:1px solid var(--ocw-line); overflow-x:auto; }
59
62
  .ocw-chip { flex:none; display:flex; align-items:center; gap:6px; border:none; background:var(--ocw-tint); color:var(--ocw-accent); border-radius:999px; padding:7px 13px; font-size:12px; font-weight:600; cursor:pointer; white-space:nowrap; }
60
63
  .ocw-chip:hover { border-color:var(--ocw-accent); color:var(--ocw-accent); }
61
- .ocw-scroll { flex:1; min-height:0; overflow-y:auto; padding:16px 14px; display:flex; flex-direction:column; gap:10px; }
64
+ .ocw-scroll { flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; padding:16px 14px; display:flex; flex-direction:column; gap:10px; }
62
65
  .ocw-subject { background:var(--ocw-tint); border:none; border-radius:16px; padding:10px 12px; }
63
66
  .ocw-subject-title { font-family:var(--ocw-fh); font-weight:600; font-size:13px; margin-bottom:2px; }
64
67
  .ocw-subject-sub { color:var(--ocw-mut); font-size:10.5px; margin-bottom:6px; }
@@ -160,8 +163,9 @@ const Ge = `
160
163
  .ocw-form-title { font-weight:700; font-size:14px; margin-bottom:8px; }
161
164
  .ocw-form-row { display:flex; flex-direction:column; gap:3px; margin-bottom:8px; }
162
165
  .ocw-form-lbl { font-size:12px; color:var(--ocw-mut); }
163
- .ocw-form-input { border:1px solid var(--ocw-line); border-radius:9px; padding:9px 11px; font:inherit; font-size:14px; outline:none; }
166
+ .ocw-form-input { width:100%; box-sizing:border-box; border:1px solid var(--ocw-line); border-radius:9px; padding:9px 11px; font:inherit; font-size:14px; outline:none; background:var(--ocw-card); color:var(--ocw-ink); appearance:none; }
164
167
  .ocw-form-input:focus { border-color:var(--ocw-accent); }
168
+ .ocw-form-input::placeholder { color:var(--ocw-mut); }
165
169
  .ocw-form-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:4px; }
166
170
  .ocw-form-cancel { background:none; border:none; color:var(--ocw-mut); font-size:13px; cursor:pointer; padding:8px 10px; }
167
171
  .ocw-form-submit { background:var(--ocw-accent); color:#fff; border:none; border-radius:999px; padding:8px 18px; font-size:13px; font-weight:600; cursor:pointer; }
@@ -192,9 +196,8 @@ const Ge = `
192
196
  .ocw-sendbtn:disabled { opacity:.5; cursor:default; }
193
197
  .ocw-sendbtn:focus-visible, .ocw-back:focus-visible, .ocw-chip:focus-visible { outline:2px solid var(--ocw-accent); outline-offset:2px; }
194
198
 
195
- .ocw-translate-btn { position:absolute; bottom:2px; right:-26px; background:var(--ocw-card); border:1px solid var(--ocw-line); border-radius:50%; width:22px; height:22px; font-size:11px; cursor:pointer; color:var(--ocw-mut); display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .15s; padding:0; }
196
- .ocw-row.theirs .ocw-translate-btn { right:auto; left:-26px; }
197
- .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
199
+ .ocw-translate-btn { display:inline-flex; align-items:center; gap:4px; margin-top:3px; background:none; border:none; padding:2px 0; font-size:11px; line-height:1; cursor:pointer; color:var(--ocw-mut); opacity:.85; }
200
+ .ocw-translate-btn:hover { opacity:1; text-decoration:underline; }
198
201
  .ocw-translation { margin-top:6px; padding-top:6px; border-top:1px solid var(--ocw-line); font-size:13px; line-height:1.45; }
199
202
  .ocw-translation::before { content:'🌐 '; opacity:.75; }
200
203
  `, 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>';
@@ -215,11 +218,11 @@ function n(t, e, l) {
215
218
  }
216
219
  function Je(t, e) {
217
220
  const l = /(https?:\/\/[^\s]+)/g;
218
- let c = 0, a = null, f;
221
+ let c = 0, i = null, f;
219
222
  for (; (f = l.exec(e)) !== null; ) {
220
223
  if (f.index > c) {
221
224
  const d = document.createTextNode(e.slice(c, f.index));
222
- t.append(d), a ?? (a = d);
225
+ t.append(d), i ?? (i = d);
223
226
  }
224
227
  let y = f[0], s = "";
225
228
  const x = /[).,!?;:]+$/.exec(y);
@@ -228,7 +231,7 @@ function Je(t, e) {
228
231
  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
232
  }
230
233
  const b = document.createTextNode(e.slice(c));
231
- return t.append(b), a ?? (a = b), a;
234
+ return t.append(b), i ?? (i = b), i;
232
235
  }
233
236
  function Ze(t) {
234
237
  try {
@@ -256,7 +259,7 @@ function se(t) {
256
259
  }
257
260
  class et {
258
261
  /** Last seq the guest has seen per conversationId — used to compute unread badges. */
259
- constructor(e, l, c, a = {}) {
262
+ constructor(e, l, c, i = {}) {
260
263
  C(this, "scroll");
261
264
  C(this, "chips");
262
265
  C(this, "typing");
@@ -291,31 +294,31 @@ class et {
291
294
  /** Whether the subject card (server Subject entity, mount config fallback)
292
295
  * has been built — built once when data first arrives. */
293
296
  C(this, "subjectBuilt", !1);
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";
297
+ var P, O, j, _, E, r, a, h, m, v, k;
298
+ this.root = e, this.me = l, this.h = c, this.cfg = i, Xe(), i.webfont !== !1 && Qe(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
299
+ const f = i.accent2 ?? i.accent;
300
+ f && e.style.setProperty("--ocw-accent2", f), this.cfgAccent2 = i.accent2, e.dataset.theme = i.theme ?? "light";
298
301
  const b = n("div", "ocw-head");
299
302
  if (this.h.onBack) {
300
303
  const w = n("button", "ocw-back", "‹");
301
304
  w.type = "button", w.setAttribute("aria-label", "Back"), w.addEventListener("click", () => this.h.onBack()), b.append(w);
302
305
  }
303
- const y = ((P = a.subject) == null ? void 0 : P.ownerLabel) ?? ((O = a.subject) == null ? void 0 : O.title) ?? "", s = n("div", "ocw-avatar");
306
+ const y = ((P = i.subject) == null ? void 0 : P.ownerLabel) ?? ((O = i.subject) == null ? void 0 : O.title) ?? "", s = n("div", "ocw-avatar");
304
307
  y.trim() && (s.textContent = y.trim()[0].toUpperCase(), b.append(s));
305
308
  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");
309
+ this.headerName = n("div", "ocw-head-name", ((j = i.subject) == null ? void 0 : j.ownerLabel) ?? ((_ = i.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 = i.subject) != null && E.subtitle && x.append(n("div", "ocw-head-meta", i.subject.subtitle)), b.append(x), this.statusBadge = n("span", "ocw-badge", ((r = i.subject) == null ? void 0 : r.status) ?? ""), (a = i.subject) != null && a.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
310
  const u = n("div", "ocw-typing-bubble");
308
311
  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 ?? []) {
312
+ for (const w of i.quickReplies ?? []) {
310
313
  const S = n("button", void 0, w);
311
314
  S.addEventListener("click", () => {
312
315
  this.h.onSend(w), this.quick.style.display = "none";
313
316
  }), this.quick.append(S);
314
317
  }
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…";
318
+ 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 = i.i18n) == null ? void 0 : h.placeholder) ?? "Message…";
316
319
  const d = n("button", "ocw-sendbtn");
317
320
  d.type = "button";
318
- const I = (m = a.i18n) == null ? void 0 : m.send;
321
+ const I = (m = i.i18n) == null ? void 0 : m.send;
319
322
  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
323
  var w, S;
321
324
  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();
@@ -331,8 +334,8 @@ class et {
331
334
  });
332
335
  const B = n("div", "ocw-input");
333
336
  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", () => {
337
+ const R = n("div", "ocw-footer");
338
+ ((v = i.i18n) == null ? void 0 : v.poweredBy) !== void 0 ? R.textContent = i.i18n.poweredBy : R.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = R, 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", () => {
336
339
  this.reopenBtn.style.display = "none";
337
340
  const w = this.root.querySelector(".ocw-input textarea");
338
341
  w == null || w.focus();
@@ -382,7 +385,7 @@ class et {
382
385
  this.cfg.i18n = { ...this.cfg.i18n ?? {}, aiAssistant: e };
383
386
  }
384
387
  render(e) {
385
- var L, B, M, A, P, O, j, _;
388
+ var L, B, R, A, P, O, j, _;
386
389
  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) {
387
390
  const E = (L = this.cfg.subject) == null ? void 0 : L.ownerLabel;
388
391
  E && (this.headerName.textContent = E);
@@ -391,7 +394,7 @@ class et {
391
394
  const l = e.visibleActions();
392
395
  this.chips.style.display = l.length ? "flex" : "none";
393
396
  for (const E of l) this.chips.append(this.chipEl(E));
394
- const c = this.scroll.scrollHeight, a = this.scroll.scrollTop;
397
+ const c = this.scroll.scrollHeight, i = this.scroll.scrollTop;
395
398
  if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
396
399
  const E = n("div", "ocw-load-more");
397
400
  E.textContent = "↑ Loading earlier messages…", E.style.pointerEvents = "none", this.scroll.append(E);
@@ -399,17 +402,17 @@ class et {
399
402
  let f = 0, b = null;
400
403
  const y = [...e.messages()];
401
404
  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);
405
+ const r = y[E], a = r.senderRole !== "system" && r.senderId !== this.me && !r.internal && r.senderId !== b;
406
+ this.scroll.append(this.messageEl(r, e, a, E === y.length - 1)), r.senderRole !== "system" && (b = r.senderId), r.senderId !== this.me && r.seq > f && (f = r.seq);
404
407
  }
405
- a > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - c + a : this.scroll.scrollTop = this.scroll.scrollHeight, f > 0 && this.h.onReadUpTo(f);
408
+ i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - c + i : this.scroll.scrollTop = this.scroll.scrollHeight, f > 0 && this.h.onReadUpTo(f);
406
409
  const s = [...e.typing];
407
410
  this.typing.classList.toggle("active", s.length > 0);
408
411
  const x = this.typing.querySelector(".ocw-typing-bubble");
409
412
  x && x.setAttribute("aria-label", s.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block";
410
413
  const u = e.messages().some((E) => E.senderRole === "guest");
411
414
  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");
415
+ this.preChatBuilt || this.buildPreChatPanel(e.preChat), this.preChatPanel.style.display = "block", this.awayNotice.style.display = "none", (R = this.root.querySelector(".ocw-input")) == null || R.style.setProperty("display", "none");
413
416
  else {
414
417
  if (this.preChatPanel.style.display = "none", e.offline) {
415
418
  this.awayNotice.firstChild || this.awayNotice.append(n("span", "ocw-away-icon", "🌙"), n("span", "", ""));
@@ -445,16 +448,16 @@ class et {
445
448
  const u = n("input", "ocw-offline-input");
446
449
  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);
447
450
  }
448
- let a = null;
451
+ let i = null;
449
452
  if ((s = e.topics) != null && s.length) {
450
- a = n("select", void 0);
453
+ i = n("select", void 0);
451
454
  const x = document.createElement("option");
452
- x.value = "", x.textContent = "What is this about?", a.append(x);
455
+ x.value = "", x.textContent = "What is this about?", i.append(x);
453
456
  for (const u of e.topics) {
454
457
  const d = document.createElement("option");
455
- d.value = u, d.textContent = u, a.append(d);
458
+ d.value = u, d.textContent = u, i.append(d);
456
459
  }
457
- l.append(a);
460
+ l.append(i);
458
461
  }
459
462
  let f = null, b = null;
460
463
  if (e.callbackOption) {
@@ -463,7 +466,7 @@ class et {
463
466
  }
464
467
  const y = n("button", "ocw-offline-submit", "Start chat");
465
468
  y.type = "button", y.addEventListener("click", () => {
466
- var I, T, L, B, M, A, P;
469
+ var I, T, L, B, R, A, P;
467
470
  const x = (I = c.email) == null ? void 0 : I.value.trim();
468
471
  if (c.email && (!x || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x))) {
469
472
  c.email.focus();
@@ -474,15 +477,15 @@ class et {
474
477
  (L = c.phone ?? b) == null || L.focus();
475
478
  return;
476
479
  }
477
- if (a && ((B = e.topics) != null && B.length) && !a.value) {
478
- a.focus();
480
+ if (i && ((B = e.topics) != null && B.length) && !i.value) {
481
+ i.focus();
479
482
  return;
480
483
  }
481
484
  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() } : {},
485
+ ...(R = c.name) != null && R.value.trim() ? { name: c.name.value.trim() } : {},
483
486
  ...x ? { email: x } : {},
484
487
  ...d ? { phone: d } : {},
485
- ...a != null && a.value ? { topic: a.value } : {},
488
+ ...i != null && i.value ? { topic: i.value } : {},
486
489
  ...u ? { callback: !0 } : {}
487
490
  });
488
491
  }), l.append(y), this.preChatPanel.append(l);
@@ -508,19 +511,19 @@ class et {
508
511
  this.csatPanel.replaceChildren(), this.csatPanel.append(n("div", "ocw-csat-title", "How did we do?"));
509
512
  const e = n("div", "ocw-csat-stars"), l = [];
510
513
  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", () => {
514
+ const i = n("button", "ocw-csat-star", "★");
515
+ i.dataset.score = String(c), i.addEventListener("mouseenter", () => l.forEach((f, b) => f.classList.toggle("lit", b < c))), i.addEventListener("mouseleave", () => l.forEach((f) => f.classList.remove("lit"))), i.addEventListener("click", () => {
513
516
  var f, b;
514
517
  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);
518
+ }), l.push(i), e.append(i);
516
519
  }
517
520
  this.csatPanel.append(e);
518
521
  }
519
522
  buildSubjectCard(e) {
520
523
  if (this.subjectBuilt) return;
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 l = e.subject, c = this.cfg.subject, i = (l == null ? void 0 : l.title) ?? (c == null ? void 0 : c.title);
525
+ if (!i) return;
526
+ this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(n("div", "ocw-subject-title", i)), c != null && c.subtitle && this.subjectCard.append(n("div", "ocw-subject-sub", c.subtitle));
524
527
  const f = n("div", "ocw-tags");
525
528
  if (l) for (const [y, s] of Object.entries(l.fields)) f.append(n("span", "ocw-tag", `${y}: ${s}`));
526
529
  else for (const y of (c == null ? void 0 : c.tags) ?? []) f.append(n("span", "ocw-tag", y));
@@ -538,14 +541,14 @@ class et {
538
541
  /** In-widget confirmation modal (replaces window.confirm). */
539
542
  confirm(e) {
540
543
  return new Promise((l) => {
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}”?`));
544
+ const c = n("div", "ocw-modal"), i = n("div", "ocw-modal-card");
545
+ i.append(n("div", "ocw-modal-title", e)), i.append(n("div", "ocw-modal-body", `Confirm “${e}”?`));
543
546
  const f = n("div", "ocw-modal-actions"), b = n("button", "ocw-modal-cancel", "Cancel"), y = n("button", "ocw-modal-ok", "Confirm"), s = (x) => {
544
547
  c.remove(), l(x);
545
548
  };
546
549
  b.addEventListener("click", () => s(!1)), y.addEventListener("click", () => s(!0)), c.addEventListener("click", (x) => {
547
550
  x.target === c && s(!1);
548
- }), f.append(b, y), a.append(f), c.append(a), this.root.append(c), y.focus();
551
+ }), f.append(b, y), i.append(f), c.append(i), this.root.append(c), y.focus();
549
552
  });
550
553
  }
551
554
  /** Inline form for a form-effect action: typed inputs (date picker, number,
@@ -557,7 +560,7 @@ class et {
557
560
  this.formHost.replaceChildren();
558
561
  const c = n("div", "ocw-form");
559
562
  c.append(n("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
560
- const a = /* @__PURE__ */ new Map();
563
+ const i = /* @__PURE__ */ new Map();
561
564
  for (const u of e.input ?? []) {
562
565
  const d = l == null ? void 0 : l[u.name], I = n("label", "ocw-form-row");
563
566
  if (I.append(n("span", "ocw-form-lbl", u.label)), u.type === "select" && ((s = u.options) != null && s.length)) {
@@ -567,17 +570,17 @@ class et {
567
570
  const B = n("option");
568
571
  B.value = L, B.textContent = L, T.append(B);
569
572
  }
570
- u.required && (T.required = !0), d != null && u.options.includes(d) && (T.value = d), I.append(T), a.set(u.name, T);
573
+ u.required && (T.required = !0), d != null && u.options.includes(d) && (T.value = d), I.append(T), i.set(u.name, T);
571
574
  } else {
572
575
  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);
576
+ 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), i.set(u.name, T);
574
577
  }
575
578
  c.append(I);
576
579
  }
577
580
  const f = n("div", "ocw-form-actions"), b = n("button", "ocw-form-cancel", "Cancel"), y = n("button", "ocw-form-submit", "Send");
578
581
  b.addEventListener("click", () => this.formHost.replaceChildren()), y.addEventListener("click", () => {
579
582
  const u = {};
580
- for (const [d, I] of a) {
583
+ for (const [d, I] of i) {
581
584
  if (I.required && !I.value) {
582
585
  I.style.borderColor = "#e5484d";
583
586
  return;
@@ -585,10 +588,10 @@ class et {
585
588
  u[d] = I.type === "number" ? Number(I.value) : I.value;
586
589
  }
587
590
  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();
591
+ }), f.append(b, y), c.append(f), this.formHost.append(c), (x = i.values().next().value) == null || x.focus();
589
592
  }
590
- messageEl(e, l, c = !1, a = !1) {
591
- var T, L, B, M, A, P, O, j, _, E;
593
+ messageEl(e, l, c = !1, i = !1) {
594
+ var T, L, B, R, A, P, O, j, _, E;
592
595
  if (e.senderRole === "system") {
593
596
  const r = n("div", "ocw-sys");
594
597
  return r.textContent = e.deletedAt ? "message deleted" : se(e.content), r;
@@ -608,58 +611,58 @@ class et {
608
611
  if (e.deletedAt) u.append(n("span", "ocw-deleted", "message deleted"));
609
612
  else if (e.content.kind === "attachment") {
610
613
  const r = e.content;
611
- if ((M = r.mime) != null && M.startsWith("image/")) {
612
- const i = document.createElement("img");
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
+ if ((R = r.mime) != null && R.startsWith("image/")) {
615
+ const a = document.createElement("img");
616
+ a.src = r.url, a.alt = r.name ?? "image", a.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", a.addEventListener("click", () => window.open(r.url, "_blank")), u.append(a);
614
617
  } else if ((A = r.mime) != null && A.startsWith("video/")) {
615
- const i = document.createElement("video");
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);
618
+ const a = document.createElement("video");
619
+ a.src = r.url, a.controls = !0, a.style.cssText = "max-width:240px;max-height:180px;border-radius:10px;display:block", u.append(a);
617
620
  } else {
618
- const i = document.createElement("a");
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);
621
+ const a = document.createElement("a");
622
+ a.href = r.url, a.target = "_blank", a.rel = "noopener", a.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", a.append(n("span", void 0, "📄"), n("span", void 0, r.name ?? "file")), u.append(a);
620
623
  }
621
624
  } else if (e.content.kind === "appointment") {
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));
625
+ const r = e.content, a = n("div", "ocw-appt");
626
+ a.append(n("div", "ocw-appt-title", `📅 ${r.title}`)), a.append(n("div", "ocw-appt-time", new Date(r.startIso).toLocaleString() + " – " + new Date(r.endIso).toLocaleTimeString())), r.location && a.append(n("div", "ocw-appt-loc", `📍 ${r.location}`)), r.description && a.append(n("div", "ocw-appt-desc", r.description));
624
627
  const h = n("div", "ocw-appt-links"), m = document.createElement("a");
625
628
  m.href = r.googleUrl, m.target = "_blank", m.rel = "noopener", m.className = "ocw-appt-btn", m.textContent = "📅 Add to Google Calendar";
626
629
  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);
630
+ 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), a.append(h), u.append(a);
628
631
  } else
629
632
  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)) {
633
+ if (x.append(u), i && !e.deletedAt && e.content.kind === "text" && ((P = e.content.quickReplies) != null && P.length)) {
631
634
  const r = n("div", "ocw-flow-choices");
632
635
  r.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";
633
- for (const i of e.content.quickReplies) {
634
- const h = n("button", "ocw-flow-choice", i);
636
+ for (const a of e.content.quickReplies) {
637
+ const h = n("button", "ocw-flow-choice", a);
635
638
  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);
639
+ r.querySelectorAll("button").forEach((m) => m.disabled = !0), r.style.opacity = "0.5", this.h.onSend(a);
637
640
  }), r.append(h);
638
641
  }
639
642
  x.append(r);
640
643
  }
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);
644
+ if (i && !e.deletedAt && e.content.kind === "form") {
645
+ const r = e.content, a = l.actionById(r.actionId);
646
+ if ((O = a == null ? void 0 : a.input) != null && O.length) {
647
+ const h = n("button", "ocw-chip", a.icon ? `${a.icon} ${a.label}` : a.label);
645
648
  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);
649
+ a.confirm && !await this.confirm(a.label) || this.openForm(a, r.prefill);
647
650
  }), x.append(h);
648
651
  }
649
652
  }
650
653
  if (!f && !b && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && d) {
651
654
  const r = e.content.text;
652
655
  if (r.trim()) {
653
- const i = n("button", "ocw-translate-btn", "🌐");
654
- i.type = "button", i.title = "Translate";
656
+ const a = n("button", "ocw-translate-btn");
657
+ a.type = "button", a.innerHTML = '<span aria-hidden="true">🌐</span> Translate', a.title = "Translate";
655
658
  const h = n("div", "ocw-translation");
656
659
  h.style.display = "none", u.append(h);
657
660
  const m = (w) => {
658
- h.textContent = w, h.style.display = "", this.showingTranslation.add(e.id), i.textContent = "", i.title = "Show original";
661
+ h.textContent = w, h.style.display = "", this.showingTranslation.add(e.id), a.innerHTML = '<span aria-hidden="true">↩</span> Original', a.title = "Show original";
659
662
  }, v = () => {
660
- h.style.display = "none", this.showingTranslation.delete(e.id), i.textContent = "🌐", i.title = "Translate";
663
+ h.style.display = "none", this.showingTranslation.delete(e.id), a.innerHTML = '<span aria-hidden="true">🌐</span> Translate', a.title = "Translate";
661
664
  };
662
- i.addEventListener("click", (w) => {
665
+ a.addEventListener("click", (w) => {
663
666
  if (w.stopPropagation(), this.showingTranslation.has(e.id)) {
664
667
  v();
665
668
  return;
@@ -669,16 +672,14 @@ class et {
669
672
  m(S);
670
673
  return;
671
674
  }
672
- i.textContent = "⏳", this.h.onTranslate(r).then((z) => {
675
+ a.textContent = "⏳", this.h.onTranslate(r).then((z) => {
673
676
  if (z === null) {
674
- i.textContent = "⚠️", i.title = "Translation unavailable", setTimeout(() => {
675
- i.textContent = "🌐", i.title = "Translate";
676
- }, 1500);
677
+ a.textContent = "⚠️ Unavailable", setTimeout(() => v(), 1500);
677
678
  return;
678
679
  }
679
680
  this.translationCache.set(e.id, z), m(z);
680
681
  });
681
- }), x.append(i);
682
+ }), x.append(a);
682
683
  const k = this.translationCache.get(e.id);
683
684
  this.showingTranslation.has(e.id) && k !== void 0 && m(k);
684
685
  }
@@ -686,8 +687,8 @@ class et {
686
687
  if (f && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
687
688
  const r = n("div", "ocw-msg-menu");
688
689
  if (this.h.onEdit) {
689
- const i = n("button", void 0, "✏️");
690
- i.title = "Edit", i.addEventListener("click", (h) => {
690
+ const a = n("button", void 0, "✏️");
691
+ a.title = "Edit", a.addEventListener("click", (h) => {
691
692
  h.stopPropagation();
692
693
  const m = se(e.content), v = document.createElement("textarea");
693
694
  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";
@@ -706,25 +707,25 @@ class et {
706
707
  }), v.addEventListener("keydown", (D) => {
707
708
  D.key === "Enter" && !D.shiftKey && (D.preventDefault(), k.click()), D.key === "Escape" && U();
708
709
  });
709
- }), r.append(i);
710
+ }), r.append(a);
710
711
  }
711
712
  if (this.h.onDelete) {
712
- const i = n("button", "del", "🗑");
713
- i.title = "Delete", i.addEventListener("click", (h) => {
713
+ const a = n("button", "del", "🗑");
714
+ a.title = "Delete", a.addEventListener("click", (h) => {
714
715
  h.stopPropagation(), this.h.onDelete(e.id);
715
- }), r.append(i);
716
+ }), r.append(a);
716
717
  }
717
718
  x.append(r);
718
719
  }
719
720
  if (s.append(x), e.senderRole === "bot" && !e.deletedAt && e.seq > 0 && e.content.kind === "text") {
720
721
  const r = e.content.citations;
721
722
  if (r != null && r.length) {
722
- const i = n("div", "ocw-cites");
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);
723
+ const a = n("div", "ocw-cites");
724
+ a.style.cssText = "margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)", a.textContent = `${((j = this.cfg.i18n) == null ? void 0 : j.sources) ?? "Sources"}: ${r.map((h) => h.source).join(", ")}`, s.append(a);
724
725
  }
725
726
  if (this.h.onReact) {
726
- const i = n("div", "ocw-bot-feedback");
727
- i.style.cssText = "display:flex;gap:6px;margin-top:4px";
727
+ const a = n("div", "ocw-bot-feedback");
728
+ a.style.cssText = "display:flex;gap:6px;margin-top:4px";
728
729
  const h = (m, v) => {
729
730
  const k = n("button", "ocw-fb-btn", m);
730
731
  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";
@@ -737,18 +738,18 @@ class et {
737
738
  (z = (S = this.h).onReact) == null || z.call(S, e.id, m, w()), k.style.opacity = "1";
738
739
  }), k;
739
740
  };
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);
741
+ a.append(h("👍", ((_ = this.cfg.i18n) == null ? void 0 : _.helpful) ?? "Helpful"), h("👎", ((E = this.cfg.i18n) == null ? void 0 : E.notHelpful) ?? "Not helpful")), s.append(a);
741
742
  }
742
743
  }
743
744
  if (this.h.onReact && !e.deletedAt && e.seq > 0) {
744
- const r = n("div", "ocw-react-wrap"), i = n("div", "ocw-react");
745
+ const r = n("div", "ocw-react-wrap"), a = n("div", "ocw-react");
745
746
  if (e.reactions && Object.keys(e.reactions).length)
746
747
  for (const [v, k] of Object.entries(e.reactions)) {
747
748
  const w = n("button", `ocw-react-pill${k.includes(this.me) ? " mine" : ""}`, `${v} ${k.length}`);
748
749
  w.addEventListener("click", () => {
749
750
  var S, z;
750
751
  return (z = (S = this.h).onReact) == null ? void 0 : z.call(S, e.id, v, k.includes(this.me));
751
- }), i.append(w);
752
+ }), a.append(w);
752
753
  }
753
754
  const h = n("button", "ocw-react-btn", "+"), m = n("div", "ocw-react-picker");
754
755
  for (const v of Ke) {
@@ -766,8 +767,8 @@ class et {
766
767
  m.style.display = k ? "flex" : "none", k && document.addEventListener("click", () => {
767
768
  m.style.display = "none";
768
769
  }, { once: !0 });
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(" ")));
770
+ }), a.append(h), r.append(a, m), s.append(r);
771
+ } else e.reactions && Object.keys(e.reactions).length && s.append(n("div", "ocw-react", Object.entries(e.reactions).map(([r, a]) => `${r}${a.length}`).join(" ")));
771
772
  const I = n("div", "ocw-time ocw-meta", Ze(e.ts));
772
773
  if (f && e.status) {
773
774
  const r = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, tt(e.status));
@@ -807,12 +808,12 @@ function dt(t) {
807
808
  }
808
809
  function ot(t) {
809
810
  const e = t.el;
810
- let l = null, c = null, a = !1;
811
+ let l = null, c = null, i = !1;
811
812
  const f = () => {
812
813
  l == null || l.close(), l = null, c == null || c.close(), c = null, e.innerHTML = "";
813
814
  };
814
815
  function b() {
815
- a || (f(), c = De({
816
+ i || (f(), c = De({
816
817
  el: e,
817
818
  url: t.url,
818
819
  ...t.apiUrl ? { apiUrl: t.apiUrl } : {},
@@ -829,7 +830,7 @@ function ot(t) {
829
830
  }));
830
831
  }
831
832
  function y(s) {
832
- if (a) return;
833
+ if (i) return;
833
834
  f();
834
835
  const { subjectId: x, kind: u, peerId: d, ...I } = t;
835
836
  l = it({
@@ -844,19 +845,19 @@ function ot(t) {
844
845
  });
845
846
  }
846
847
  return b(), { close() {
847
- a = !0, f();
848
+ i = !0, f();
848
849
  } };
849
850
  }
850
851
  function it(t) {
851
852
  var pe, ue, he, fe, we, be, xe, me;
852
853
  if (t.inbox) return ot(t);
853
854
  G.has(t.el) && (G.get(t.el).close(), G.delete(t.el)), t.launcher && ((pe = oe.get(Te(t))) == null || pe.close());
854
- const e = Me();
855
+ const e = Re();
855
856
  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;
857
+ const i = t.token ?? t.userId ?? e, f = i !== e ? e : void 0, { wsUrl: b, httpBase: y } = Ae(t.url, t.apiUrl);
858
+ let s = new _e(i);
859
+ const x = t.subjectId ? `${i}::${t.subjectId}` : i, u = new He(x);
860
+ let d, I = !1, T = null, L = null, B = null, R = null;
860
861
  !t.launcher && !t.el.style.height && t.el.clientHeight === 0 && (t.el.style.width = t.el.style.width || "100%", t.el.style.height = "600px");
861
862
  for (const o of u.load()) s.addOptimistic(o.clientMsgId, o.content);
862
863
  let A = null, P = null, O = 0, j = !t.launcher;
@@ -915,7 +916,7 @@ function it(t) {
915
916
  };
916
917
  te(), A.append(g, H), document.body.append(A);
917
918
  const ie = `ocw-teaser-dismissed::${t.profileId}`, ne = typeof t.launcherMessage == "string" ? { title: t.launcherMessage } : t.launcherMessage;
918
- let R = null;
919
+ let M = null;
919
920
  const je = () => {
920
921
  try {
921
922
  return sessionStorage.getItem(ie) === "1";
@@ -925,11 +926,11 @@ function it(t) {
925
926
  }, 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
927
  const q = ne != null && ne.title ? ne : s.launcherMessage ?? void 0;
927
928
  if (!(!!(q != null && q.title) && !j && !je())) {
928
- R && (R.remove(), R = null);
929
+ M && (M.remove(), M = null);
929
930
  return;
930
931
  }
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 = [
932
+ if (M) return;
933
+ M = document.createElement("div"), M.setAttribute("role", "button"), M.setAttribute("tabindex", "0"), M.setAttribute("aria-label", q.title), M.style.cssText = [
933
934
  "max-width:280px",
934
935
  "background:#fff",
935
936
  "border-radius:16px",
@@ -942,13 +943,13 @@ function it(t) {
942
943
  "animation:ocw-teaser-in .22s ease-out"
943
944
  ].join(";");
944
945
  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
+ if (ce.textContent = q.title, ce.style.cssText = "font-size:15px;font-weight:600;color:#111;line-height:1.35", M.append(ce), q.subtitle) {
946
947
  const F = document.createElement("div");
947
948
  F.style.cssText = "display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";
948
949
  const re = document.createElement("span");
949
950
  re.innerHTML = Pe, re.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
950
951
  const ve = document.createElement("span");
951
- ve.textContent = q.subtitle, F.append(re, ve), R.append(F);
952
+ ve.textContent = q.subtitle, F.append(re, ve), M.append(F);
952
953
  }
953
954
  const K = document.createElement("button");
954
955
  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) => {
@@ -957,20 +958,20 @@ function it(t) {
957
958
  sessionStorage.setItem(ie, "1");
958
959
  } catch {
959
960
  }
960
- R && (R.remove(), R = null);
961
- }), R.append(K);
961
+ M && (M.remove(), M = null);
962
+ }), M.append(K);
962
963
  const ye = () => {
963
- j || (j = !0, ae(!0), te(), O = 0, P && (P.style.display = "none"), R && (R.remove(), R = null));
964
+ j || (j = !0, ae(!0), te(), O = 0, P && (P.style.display = "none"), M && (M.remove(), M = null));
964
965
  };
965
- R.addEventListener("click", ye), R.addEventListener("keydown", (F) => {
966
+ M.addEventListener("click", ye), M.addEventListener("keydown", (F) => {
966
967
  (F.key === "Enter" || F.key === " ") && (F.preventDefault(), ye());
967
- }), A.insertBefore(R, H);
968
+ }), A.insertBefore(M, H);
968
969
  };
969
970
  if (!document.getElementById("ocw-teaser-style")) {
970
971
  const q = document.createElement("style");
971
972
  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);
972
973
  }
973
- M = ge, ge();
974
+ R = ge, ge();
974
975
  const ae = (q) => {
975
976
  q ? (g.style.display = "flex", requestAnimationFrame(() => {
976
977
  g.style.opacity = "1", g.style.transform = "scale(1)";
@@ -986,7 +987,7 @@ function it(t) {
986
987
  } catch {
987
988
  }
988
989
  }
989
- M == null || M();
990
+ R == null || R();
990
991
  }), B = (q) => {
991
992
  q.key === "Escape" && j && (j = !1, ae(!1), te());
992
993
  }, document.addEventListener("keydown", B);
@@ -1003,7 +1004,7 @@ function it(t) {
1003
1004
  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);
1004
1005
  } catch {
1005
1006
  }
1006
- }, r = [], i = (o) => {
1007
+ }, r = [], a = (o) => {
1007
1008
  for (; r.length; ) {
1008
1009
  const p = r.shift();
1009
1010
  u.add({ clientMsgId: p.clientMsgId, content: p.content, ts: Date.now() }), h.send({ type: "send", conversationId: o, clientMsgId: p.clientMsgId, content: p.content });
@@ -1035,7 +1036,7 @@ function it(t) {
1035
1036
  h.send({ type: "fetchPrekey", targetUserId: o });
1036
1037
  }, Se = qe(t.locale, t.i18n), Ee = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
1037
1038
  Ee.includes(ze) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
1038
- const le = `oc_prechat_${t.profileId}_${a.slice(-8)}`, N = new et(t.el, a, {
1039
+ const le = `oc_prechat_${t.profileId}_${i.slice(-8)}`, N = new et(t.el, i, {
1039
1040
  onSend(o) {
1040
1041
  const p = `cm_${Math.random().toString(36).slice(2)}`, g = { kind: "text", text: o };
1041
1042
  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 });
@@ -1052,7 +1053,7 @@ function it(t) {
1052
1053
  // requires an Authorization header, and the verifier accepts an
1053
1054
  // anonymous id as a guest; keying off opts.token alone meant anonymous
1054
1055
  // visitors (the common case) sent no auth and every upload 401'd.
1055
- headers: { "content-type": o.type, authorization: `Bearer ${a}` },
1056
+ headers: { "content-type": o.type, authorization: `Bearer ${i}` },
1056
1057
  body: o
1057
1058
  });
1058
1059
  if (!$.ok) throw new Error(`Upload failed: ${$.status}`);
@@ -1126,7 +1127,7 @@ function it(t) {
1126
1127
  onCsat(o) {
1127
1128
  d && fetch(`${y}/conversations/${d}/csat`, {
1128
1129
  method: "POST",
1129
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${a}` },
1130
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${i}` },
1130
1131
  body: JSON.stringify({ score: o })
1131
1132
  }).catch(() => {
1132
1133
  });
@@ -1139,7 +1140,7 @@ function it(t) {
1139
1140
  try {
1140
1141
  const $ = await fetch(`${y}/translate`, {
1141
1142
  method: "POST",
1142
- headers: { "content-type": "application/json", authorization: `Bearer ${a}` },
1143
+ headers: { "content-type": "application/json", authorization: `Bearer ${i}` },
1143
1144
  body: JSON.stringify({ text: g, targetLang: p })
1144
1145
  });
1145
1146
  if (!$.ok) return null;
@@ -1190,7 +1191,7 @@ function it(t) {
1190
1191
  h = new Ue({
1191
1192
  ...t.refreshToken ? { refreshToken: t.refreshToken } : {},
1192
1193
  url: b,
1193
- token: a,
1194
+ token: i,
1194
1195
  open: Le,
1195
1196
  getCursor: () => s.highestSeq(),
1196
1197
  onStatusChange: (o, p) => N.setConnStatus(o, p),
@@ -1201,7 +1202,7 @@ function it(t) {
1201
1202
  for (const p of u.load())
1202
1203
  h.send({ type: "send", conversationId: d, clientMsgId: p.clientMsgId, content: p.content });
1203
1204
  }
1204
- Oe(b, a, d, s, N, y), r.length && i(d);
1205
+ Oe(b, i, d, s, N, y), r.length && a(d);
1205
1206
  }
1206
1207
  if (o.type === "ack" && u.remove(o.clientMsgId), o.type === "prekeyBundle") {
1207
1208
  o.bundle && (S = !0, m.x3dhSendTo(o.bundle).then((p) => {
@@ -1228,11 +1229,11 @@ function it(t) {
1228
1229
  }
1229
1230
  (async () => {
1230
1231
  if (s.e2e && await m.openFrame(o), s.apply(o), o.type === "manifest") {
1231
- M == null || M();
1232
+ R == null || R();
1232
1233
  const p = o.botName;
1233
1234
  p && N.setBotName(p);
1234
1235
  }
1235
- if (o.type === "message" && o.message.senderId !== a && !o.message.internal && (_(), E()), s.e2e && d && !v) {
1236
+ if (o.type === "message" && o.message.senderId !== i && !o.message.internal && (_(), E()), s.e2e && d && !v) {
1236
1237
  v = !0;
1237
1238
  const p = await m.initX3DH();
1238
1239
  h.send({ type: "uploadPrekeys", ...p });