@paramms/chat-widget 1.9.0 โ†’ 1.9.1

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,13 +1,13 @@
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
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; }
@@ -192,9 +192,8 @@ const Ge = `
192
192
  .ocw-sendbtn:disabled { opacity:.5; cursor:default; }
193
193
  .ocw-sendbtn:focus-visible, .ocw-back:focus-visible, .ocw-chip:focus-visible { outline:2px solid var(--ocw-accent); outline-offset:2px; }
194
194
 
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; }
195
+ .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; }
196
+ .ocw-translate-btn:hover { opacity:1; text-decoration:underline; }
198
197
  .ocw-translation { margin-top:6px; padding-top:6px; border-top:1px solid var(--ocw-line); font-size:13px; line-height:1.45; }
199
198
  .ocw-translation::before { content:'๐ŸŒ '; opacity:.75; }
200
199
  `, 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 +214,11 @@ function n(t, e, l) {
215
214
  }
216
215
  function Je(t, e) {
217
216
  const l = /(https?:\/\/[^\s]+)/g;
218
- let c = 0, a = null, f;
217
+ let c = 0, i = null, f;
219
218
  for (; (f = l.exec(e)) !== null; ) {
220
219
  if (f.index > c) {
221
220
  const d = document.createTextNode(e.slice(c, f.index));
222
- t.append(d), a ?? (a = d);
221
+ t.append(d), i ?? (i = d);
223
222
  }
224
223
  let y = f[0], s = "";
225
224
  const x = /[).,!?;:]+$/.exec(y);
@@ -228,7 +227,7 @@ function Je(t, e) {
228
227
  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
228
  }
230
229
  const b = document.createTextNode(e.slice(c));
231
- return t.append(b), a ?? (a = b), a;
230
+ return t.append(b), i ?? (i = b), i;
232
231
  }
233
232
  function Ze(t) {
234
233
  try {
@@ -256,7 +255,7 @@ function se(t) {
256
255
  }
257
256
  class et {
258
257
  /** Last seq the guest has seen per conversationId โ€” used to compute unread badges. */
259
- constructor(e, l, c, a = {}) {
258
+ constructor(e, l, c, i = {}) {
260
259
  C(this, "scroll");
261
260
  C(this, "chips");
262
261
  C(this, "typing");
@@ -291,31 +290,31 @@ class et {
291
290
  /** Whether the subject card (server Subject entity, mount config fallback)
292
291
  * has been built โ€” built once when data first arrives. */
293
292
  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";
293
+ var P, O, j, _, E, r, a, h, m, v, k;
294
+ 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);
295
+ const f = i.accent2 ?? i.accent;
296
+ f && e.style.setProperty("--ocw-accent2", f), this.cfgAccent2 = i.accent2, e.dataset.theme = i.theme ?? "light";
298
297
  const b = n("div", "ocw-head");
299
298
  if (this.h.onBack) {
300
299
  const w = n("button", "ocw-back", "โ€น");
301
300
  w.type = "button", w.setAttribute("aria-label", "Back"), w.addEventListener("click", () => this.h.onBack()), b.append(w);
302
301
  }
303
- const y = ((P = a.subject) == null ? void 0 : P.ownerLabel) ?? ((O = a.subject) == null ? void 0 : O.title) ?? "", s = n("div", "ocw-avatar");
302
+ const y = ((P = i.subject) == null ? void 0 : P.ownerLabel) ?? ((O = i.subject) == null ? void 0 : O.title) ?? "", s = n("div", "ocw-avatar");
304
303
  y.trim() && (s.textContent = y.trim()[0].toUpperCase(), b.append(s));
305
304
  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");
305
+ 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
306
  const u = n("div", "ocw-typing-bubble");
308
307
  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 ?? []) {
308
+ for (const w of i.quickReplies ?? []) {
310
309
  const S = n("button", void 0, w);
311
310
  S.addEventListener("click", () => {
312
311
  this.h.onSend(w), this.quick.style.display = "none";
313
312
  }), this.quick.append(S);
314
313
  }
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โ€ฆ";
314
+ 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
315
  const d = n("button", "ocw-sendbtn");
317
316
  d.type = "button";
318
- const I = (m = a.i18n) == null ? void 0 : m.send;
317
+ const I = (m = i.i18n) == null ? void 0 : m.send;
319
318
  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
319
  var w, S;
321
320
  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 +330,8 @@ class et {
331
330
  });
332
331
  const B = n("div", "ocw-input");
333
332
  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", () => {
333
+ const R = n("div", "ocw-footer");
334
+ ((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
335
  this.reopenBtn.style.display = "none";
337
336
  const w = this.root.querySelector(".ocw-input textarea");
338
337
  w == null || w.focus();
@@ -382,7 +381,7 @@ class et {
382
381
  this.cfg.i18n = { ...this.cfg.i18n ?? {}, aiAssistant: e };
383
382
  }
384
383
  render(e) {
385
- var L, B, M, A, P, O, j, _;
384
+ var L, B, R, A, P, O, j, _;
386
385
  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
386
  const E = (L = this.cfg.subject) == null ? void 0 : L.ownerLabel;
388
387
  E && (this.headerName.textContent = E);
@@ -391,7 +390,7 @@ class et {
391
390
  const l = e.visibleActions();
392
391
  this.chips.style.display = l.length ? "flex" : "none";
393
392
  for (const E of l) this.chips.append(this.chipEl(E));
394
- const c = this.scroll.scrollHeight, a = this.scroll.scrollTop;
393
+ const c = this.scroll.scrollHeight, i = this.scroll.scrollTop;
395
394
  if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
396
395
  const E = n("div", "ocw-load-more");
397
396
  E.textContent = "โ†‘ Loading earlier messagesโ€ฆ", E.style.pointerEvents = "none", this.scroll.append(E);
@@ -399,17 +398,17 @@ class et {
399
398
  let f = 0, b = null;
400
399
  const y = [...e.messages()];
401
400
  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);
401
+ const r = y[E], a = r.senderRole !== "system" && r.senderId !== this.me && !r.internal && r.senderId !== b;
402
+ 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
403
  }
405
- a > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - c + a : this.scroll.scrollTop = this.scroll.scrollHeight, f > 0 && this.h.onReadUpTo(f);
404
+ i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - c + i : this.scroll.scrollTop = this.scroll.scrollHeight, f > 0 && this.h.onReadUpTo(f);
406
405
  const s = [...e.typing];
407
406
  this.typing.classList.toggle("active", s.length > 0);
408
407
  const x = this.typing.querySelector(".ocw-typing-bubble");
409
408
  x && x.setAttribute("aria-label", s.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block";
410
409
  const u = e.messages().some((E) => E.senderRole === "guest");
411
410
  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");
411
+ 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
412
  else {
414
413
  if (this.preChatPanel.style.display = "none", e.offline) {
415
414
  this.awayNotice.firstChild || this.awayNotice.append(n("span", "ocw-away-icon", "๐ŸŒ™"), n("span", "", ""));
@@ -445,16 +444,16 @@ class et {
445
444
  const u = n("input", "ocw-offline-input");
446
445
  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
446
  }
448
- let a = null;
447
+ let i = null;
449
448
  if ((s = e.topics) != null && s.length) {
450
- a = n("select", void 0);
449
+ i = n("select", void 0);
451
450
  const x = document.createElement("option");
452
- x.value = "", x.textContent = "What is this about?", a.append(x);
451
+ x.value = "", x.textContent = "What is this about?", i.append(x);
453
452
  for (const u of e.topics) {
454
453
  const d = document.createElement("option");
455
- d.value = u, d.textContent = u, a.append(d);
454
+ d.value = u, d.textContent = u, i.append(d);
456
455
  }
457
- l.append(a);
456
+ l.append(i);
458
457
  }
459
458
  let f = null, b = null;
460
459
  if (e.callbackOption) {
@@ -463,7 +462,7 @@ class et {
463
462
  }
464
463
  const y = n("button", "ocw-offline-submit", "Start chat");
465
464
  y.type = "button", y.addEventListener("click", () => {
466
- var I, T, L, B, M, A, P;
465
+ var I, T, L, B, R, A, P;
467
466
  const x = (I = c.email) == null ? void 0 : I.value.trim();
468
467
  if (c.email && (!x || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x))) {
469
468
  c.email.focus();
@@ -474,15 +473,15 @@ class et {
474
473
  (L = c.phone ?? b) == null || L.focus();
475
474
  return;
476
475
  }
477
- if (a && ((B = e.topics) != null && B.length) && !a.value) {
478
- a.focus();
476
+ if (i && ((B = e.topics) != null && B.length) && !i.value) {
477
+ i.focus();
479
478
  return;
480
479
  }
481
480
  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() } : {},
481
+ ...(R = c.name) != null && R.value.trim() ? { name: c.name.value.trim() } : {},
483
482
  ...x ? { email: x } : {},
484
483
  ...d ? { phone: d } : {},
485
- ...a != null && a.value ? { topic: a.value } : {},
484
+ ...i != null && i.value ? { topic: i.value } : {},
486
485
  ...u ? { callback: !0 } : {}
487
486
  });
488
487
  }), l.append(y), this.preChatPanel.append(l);
@@ -508,19 +507,19 @@ class et {
508
507
  this.csatPanel.replaceChildren(), this.csatPanel.append(n("div", "ocw-csat-title", "How did we do?"));
509
508
  const e = n("div", "ocw-csat-stars"), l = [];
510
509
  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", () => {
510
+ const i = n("button", "ocw-csat-star", "โ˜…");
511
+ 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
512
  var f, b;
514
513
  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);
514
+ }), l.push(i), e.append(i);
516
515
  }
517
516
  this.csatPanel.append(e);
518
517
  }
519
518
  buildSubjectCard(e) {
520
519
  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));
520
+ const l = e.subject, c = this.cfg.subject, i = (l == null ? void 0 : l.title) ?? (c == null ? void 0 : c.title);
521
+ if (!i) return;
522
+ 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
523
  const f = n("div", "ocw-tags");
525
524
  if (l) for (const [y, s] of Object.entries(l.fields)) f.append(n("span", "ocw-tag", `${y}: ${s}`));
526
525
  else for (const y of (c == null ? void 0 : c.tags) ?? []) f.append(n("span", "ocw-tag", y));
@@ -538,14 +537,14 @@ class et {
538
537
  /** In-widget confirmation modal (replaces window.confirm). */
539
538
  confirm(e) {
540
539
  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}โ€?`));
540
+ const c = n("div", "ocw-modal"), i = n("div", "ocw-modal-card");
541
+ i.append(n("div", "ocw-modal-title", e)), i.append(n("div", "ocw-modal-body", `Confirm โ€œ${e}โ€?`));
543
542
  const f = n("div", "ocw-modal-actions"), b = n("button", "ocw-modal-cancel", "Cancel"), y = n("button", "ocw-modal-ok", "Confirm"), s = (x) => {
544
543
  c.remove(), l(x);
545
544
  };
546
545
  b.addEventListener("click", () => s(!1)), y.addEventListener("click", () => s(!0)), c.addEventListener("click", (x) => {
547
546
  x.target === c && s(!1);
548
- }), f.append(b, y), a.append(f), c.append(a), this.root.append(c), y.focus();
547
+ }), f.append(b, y), i.append(f), c.append(i), this.root.append(c), y.focus();
549
548
  });
550
549
  }
551
550
  /** Inline form for a form-effect action: typed inputs (date picker, number,
@@ -557,7 +556,7 @@ class et {
557
556
  this.formHost.replaceChildren();
558
557
  const c = n("div", "ocw-form");
559
558
  c.append(n("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
560
- const a = /* @__PURE__ */ new Map();
559
+ const i = /* @__PURE__ */ new Map();
561
560
  for (const u of e.input ?? []) {
562
561
  const d = l == null ? void 0 : l[u.name], I = n("label", "ocw-form-row");
563
562
  if (I.append(n("span", "ocw-form-lbl", u.label)), u.type === "select" && ((s = u.options) != null && s.length)) {
@@ -567,17 +566,17 @@ class et {
567
566
  const B = n("option");
568
567
  B.value = L, B.textContent = L, T.append(B);
569
568
  }
570
- u.required && (T.required = !0), d != null && u.options.includes(d) && (T.value = d), I.append(T), a.set(u.name, T);
569
+ u.required && (T.required = !0), d != null && u.options.includes(d) && (T.value = d), I.append(T), i.set(u.name, T);
571
570
  } else {
572
571
  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);
572
+ 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
573
  }
575
574
  c.append(I);
576
575
  }
577
576
  const f = n("div", "ocw-form-actions"), b = n("button", "ocw-form-cancel", "Cancel"), y = n("button", "ocw-form-submit", "Send");
578
577
  b.addEventListener("click", () => this.formHost.replaceChildren()), y.addEventListener("click", () => {
579
578
  const u = {};
580
- for (const [d, I] of a) {
579
+ for (const [d, I] of i) {
581
580
  if (I.required && !I.value) {
582
581
  I.style.borderColor = "#e5484d";
583
582
  return;
@@ -585,10 +584,10 @@ class et {
585
584
  u[d] = I.type === "number" ? Number(I.value) : I.value;
586
585
  }
587
586
  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();
587
+ }), f.append(b, y), c.append(f), this.formHost.append(c), (x = i.values().next().value) == null || x.focus();
589
588
  }
590
- messageEl(e, l, c = !1, a = !1) {
591
- var T, L, B, M, A, P, O, j, _, E;
589
+ messageEl(e, l, c = !1, i = !1) {
590
+ var T, L, B, R, A, P, O, j, _, E;
592
591
  if (e.senderRole === "system") {
593
592
  const r = n("div", "ocw-sys");
594
593
  return r.textContent = e.deletedAt ? "message deleted" : se(e.content), r;
@@ -608,58 +607,58 @@ class et {
608
607
  if (e.deletedAt) u.append(n("span", "ocw-deleted", "message deleted"));
609
608
  else if (e.content.kind === "attachment") {
610
609
  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);
610
+ if ((R = r.mime) != null && R.startsWith("image/")) {
611
+ const a = document.createElement("img");
612
+ 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
613
  } 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);
614
+ const a = document.createElement("video");
615
+ 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
616
  } 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);
617
+ const a = document.createElement("a");
618
+ 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
619
  }
621
620
  } 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));
621
+ const r = e.content, a = n("div", "ocw-appt");
622
+ 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
623
  const h = n("div", "ocw-appt-links"), m = document.createElement("a");
625
624
  m.href = r.googleUrl, m.target = "_blank", m.rel = "noopener", m.className = "ocw-appt-btn", m.textContent = "๐Ÿ“… Add to Google Calendar";
626
625
  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);
626
+ 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
627
  } else
629
628
  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)) {
629
+ if (x.append(u), i && !e.deletedAt && e.content.kind === "text" && ((P = e.content.quickReplies) != null && P.length)) {
631
630
  const r = n("div", "ocw-flow-choices");
632
631
  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);
632
+ for (const a of e.content.quickReplies) {
633
+ const h = n("button", "ocw-flow-choice", a);
635
634
  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);
635
+ r.querySelectorAll("button").forEach((m) => m.disabled = !0), r.style.opacity = "0.5", this.h.onSend(a);
637
636
  }), r.append(h);
638
637
  }
639
638
  x.append(r);
640
639
  }
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);
640
+ if (i && !e.deletedAt && e.content.kind === "form") {
641
+ const r = e.content, a = l.actionById(r.actionId);
642
+ if ((O = a == null ? void 0 : a.input) != null && O.length) {
643
+ const h = n("button", "ocw-chip", a.icon ? `${a.icon} ${a.label}` : a.label);
645
644
  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);
645
+ a.confirm && !await this.confirm(a.label) || this.openForm(a, r.prefill);
647
646
  }), x.append(h);
648
647
  }
649
648
  }
650
649
  if (!f && !b && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && d) {
651
650
  const r = e.content.text;
652
651
  if (r.trim()) {
653
- const i = n("button", "ocw-translate-btn", "๐ŸŒ");
654
- i.type = "button", i.title = "Translate";
652
+ const a = n("button", "ocw-translate-btn");
653
+ a.type = "button", a.innerHTML = '<span aria-hidden="true">๐ŸŒ</span> Translate', a.title = "Translate";
655
654
  const h = n("div", "ocw-translation");
656
655
  h.style.display = "none", u.append(h);
657
656
  const m = (w) => {
658
- h.textContent = w, h.style.display = "", this.showingTranslation.add(e.id), i.textContent = "โ†ฉ", i.title = "Show original";
657
+ h.textContent = w, h.style.display = "", this.showingTranslation.add(e.id), a.innerHTML = '<span aria-hidden="true">โ†ฉ</span> Original', a.title = "Show original";
659
658
  }, v = () => {
660
- h.style.display = "none", this.showingTranslation.delete(e.id), i.textContent = "๐ŸŒ", i.title = "Translate";
659
+ h.style.display = "none", this.showingTranslation.delete(e.id), a.innerHTML = '<span aria-hidden="true">๐ŸŒ</span> Translate', a.title = "Translate";
661
660
  };
662
- i.addEventListener("click", (w) => {
661
+ a.addEventListener("click", (w) => {
663
662
  if (w.stopPropagation(), this.showingTranslation.has(e.id)) {
664
663
  v();
665
664
  return;
@@ -669,16 +668,14 @@ class et {
669
668
  m(S);
670
669
  return;
671
670
  }
672
- i.textContent = "โณ", this.h.onTranslate(r).then((z) => {
671
+ a.textContent = "โณ โ€ฆ", this.h.onTranslate(r).then((z) => {
673
672
  if (z === null) {
674
- i.textContent = "โš ๏ธ", i.title = "Translation unavailable", setTimeout(() => {
675
- i.textContent = "๐ŸŒ", i.title = "Translate";
676
- }, 1500);
673
+ a.textContent = "โš ๏ธ Unavailable", setTimeout(() => v(), 1500);
677
674
  return;
678
675
  }
679
676
  this.translationCache.set(e.id, z), m(z);
680
677
  });
681
- }), x.append(i);
678
+ }), x.append(a);
682
679
  const k = this.translationCache.get(e.id);
683
680
  this.showingTranslation.has(e.id) && k !== void 0 && m(k);
684
681
  }
@@ -686,8 +683,8 @@ class et {
686
683
  if (f && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
687
684
  const r = n("div", "ocw-msg-menu");
688
685
  if (this.h.onEdit) {
689
- const i = n("button", void 0, "โœ๏ธ");
690
- i.title = "Edit", i.addEventListener("click", (h) => {
686
+ const a = n("button", void 0, "โœ๏ธ");
687
+ a.title = "Edit", a.addEventListener("click", (h) => {
691
688
  h.stopPropagation();
692
689
  const m = se(e.content), v = document.createElement("textarea");
693
690
  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 +703,25 @@ class et {
706
703
  }), v.addEventListener("keydown", (D) => {
707
704
  D.key === "Enter" && !D.shiftKey && (D.preventDefault(), k.click()), D.key === "Escape" && U();
708
705
  });
709
- }), r.append(i);
706
+ }), r.append(a);
710
707
  }
711
708
  if (this.h.onDelete) {
712
- const i = n("button", "del", "๐Ÿ—‘");
713
- i.title = "Delete", i.addEventListener("click", (h) => {
709
+ const a = n("button", "del", "๐Ÿ—‘");
710
+ a.title = "Delete", a.addEventListener("click", (h) => {
714
711
  h.stopPropagation(), this.h.onDelete(e.id);
715
- }), r.append(i);
712
+ }), r.append(a);
716
713
  }
717
714
  x.append(r);
718
715
  }
719
716
  if (s.append(x), e.senderRole === "bot" && !e.deletedAt && e.seq > 0 && e.content.kind === "text") {
720
717
  const r = e.content.citations;
721
718
  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);
719
+ const a = n("div", "ocw-cites");
720
+ 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
721
  }
725
722
  if (this.h.onReact) {
726
- const i = n("div", "ocw-bot-feedback");
727
- i.style.cssText = "display:flex;gap:6px;margin-top:4px";
723
+ const a = n("div", "ocw-bot-feedback");
724
+ a.style.cssText = "display:flex;gap:6px;margin-top:4px";
728
725
  const h = (m, v) => {
729
726
  const k = n("button", "ocw-fb-btn", m);
730
727
  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 +734,18 @@ class et {
737
734
  (z = (S = this.h).onReact) == null || z.call(S, e.id, m, w()), k.style.opacity = "1";
738
735
  }), k;
739
736
  };
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);
737
+ 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
738
  }
742
739
  }
743
740
  if (this.h.onReact && !e.deletedAt && e.seq > 0) {
744
- const r = n("div", "ocw-react-wrap"), i = n("div", "ocw-react");
741
+ const r = n("div", "ocw-react-wrap"), a = n("div", "ocw-react");
745
742
  if (e.reactions && Object.keys(e.reactions).length)
746
743
  for (const [v, k] of Object.entries(e.reactions)) {
747
744
  const w = n("button", `ocw-react-pill${k.includes(this.me) ? " mine" : ""}`, `${v} ${k.length}`);
748
745
  w.addEventListener("click", () => {
749
746
  var S, z;
750
747
  return (z = (S = this.h).onReact) == null ? void 0 : z.call(S, e.id, v, k.includes(this.me));
751
- }), i.append(w);
748
+ }), a.append(w);
752
749
  }
753
750
  const h = n("button", "ocw-react-btn", "๏ผ‹"), m = n("div", "ocw-react-picker");
754
751
  for (const v of Ke) {
@@ -766,8 +763,8 @@ class et {
766
763
  m.style.display = k ? "flex" : "none", k && document.addEventListener("click", () => {
767
764
  m.style.display = "none";
768
765
  }, { 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(" ")));
766
+ }), a.append(h), r.append(a, m), s.append(r);
767
+ } 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
768
  const I = n("div", "ocw-time ocw-meta", Ze(e.ts));
772
769
  if (f && e.status) {
773
770
  const r = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, tt(e.status));
@@ -807,12 +804,12 @@ function dt(t) {
807
804
  }
808
805
  function ot(t) {
809
806
  const e = t.el;
810
- let l = null, c = null, a = !1;
807
+ let l = null, c = null, i = !1;
811
808
  const f = () => {
812
809
  l == null || l.close(), l = null, c == null || c.close(), c = null, e.innerHTML = "";
813
810
  };
814
811
  function b() {
815
- a || (f(), c = De({
812
+ i || (f(), c = De({
816
813
  el: e,
817
814
  url: t.url,
818
815
  ...t.apiUrl ? { apiUrl: t.apiUrl } : {},
@@ -829,7 +826,7 @@ function ot(t) {
829
826
  }));
830
827
  }
831
828
  function y(s) {
832
- if (a) return;
829
+ if (i) return;
833
830
  f();
834
831
  const { subjectId: x, kind: u, peerId: d, ...I } = t;
835
832
  l = it({
@@ -844,19 +841,19 @@ function ot(t) {
844
841
  });
845
842
  }
846
843
  return b(), { close() {
847
- a = !0, f();
844
+ i = !0, f();
848
845
  } };
849
846
  }
850
847
  function it(t) {
851
848
  var pe, ue, he, fe, we, be, xe, me;
852
849
  if (t.inbox) return ot(t);
853
850
  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();
851
+ const e = Re();
855
852
  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;
853
+ const i = t.token ?? t.userId ?? e, f = i !== e ? e : void 0, { wsUrl: b, httpBase: y } = Ae(t.url, t.apiUrl);
854
+ let s = new _e(i);
855
+ const x = t.subjectId ? `${i}::${t.subjectId}` : i, u = new He(x);
856
+ let d, I = !1, T = null, L = null, B = null, R = null;
860
857
  !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
858
  for (const o of u.load()) s.addOptimistic(o.clientMsgId, o.content);
862
859
  let A = null, P = null, O = 0, j = !t.launcher;
@@ -915,7 +912,7 @@ function it(t) {
915
912
  };
916
913
  te(), A.append(g, H), document.body.append(A);
917
914
  const ie = `ocw-teaser-dismissed::${t.profileId}`, ne = typeof t.launcherMessage == "string" ? { title: t.launcherMessage } : t.launcherMessage;
918
- let R = null;
915
+ let M = null;
919
916
  const je = () => {
920
917
  try {
921
918
  return sessionStorage.getItem(ie) === "1";
@@ -925,11 +922,11 @@ function it(t) {
925
922
  }, 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
923
  const q = ne != null && ne.title ? ne : s.launcherMessage ?? void 0;
927
924
  if (!(!!(q != null && q.title) && !j && !je())) {
928
- R && (R.remove(), R = null);
925
+ M && (M.remove(), M = null);
929
926
  return;
930
927
  }
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 = [
928
+ if (M) return;
929
+ M = document.createElement("div"), M.setAttribute("role", "button"), M.setAttribute("tabindex", "0"), M.setAttribute("aria-label", q.title), M.style.cssText = [
933
930
  "max-width:280px",
934
931
  "background:#fff",
935
932
  "border-radius:16px",
@@ -942,13 +939,13 @@ function it(t) {
942
939
  "animation:ocw-teaser-in .22s ease-out"
943
940
  ].join(";");
944
941
  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) {
942
+ 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
943
  const F = document.createElement("div");
947
944
  F.style.cssText = "display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";
948
945
  const re = document.createElement("span");
949
946
  re.innerHTML = Pe, re.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
950
947
  const ve = document.createElement("span");
951
- ve.textContent = q.subtitle, F.append(re, ve), R.append(F);
948
+ ve.textContent = q.subtitle, F.append(re, ve), M.append(F);
952
949
  }
953
950
  const K = document.createElement("button");
954
951
  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 +954,20 @@ function it(t) {
957
954
  sessionStorage.setItem(ie, "1");
958
955
  } catch {
959
956
  }
960
- R && (R.remove(), R = null);
961
- }), R.append(K);
957
+ M && (M.remove(), M = null);
958
+ }), M.append(K);
962
959
  const ye = () => {
963
- j || (j = !0, ae(!0), te(), O = 0, P && (P.style.display = "none"), R && (R.remove(), R = null));
960
+ j || (j = !0, ae(!0), te(), O = 0, P && (P.style.display = "none"), M && (M.remove(), M = null));
964
961
  };
965
- R.addEventListener("click", ye), R.addEventListener("keydown", (F) => {
962
+ M.addEventListener("click", ye), M.addEventListener("keydown", (F) => {
966
963
  (F.key === "Enter" || F.key === " ") && (F.preventDefault(), ye());
967
- }), A.insertBefore(R, H);
964
+ }), A.insertBefore(M, H);
968
965
  };
969
966
  if (!document.getElementById("ocw-teaser-style")) {
970
967
  const q = document.createElement("style");
971
968
  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
969
  }
973
- M = ge, ge();
970
+ R = ge, ge();
974
971
  const ae = (q) => {
975
972
  q ? (g.style.display = "flex", requestAnimationFrame(() => {
976
973
  g.style.opacity = "1", g.style.transform = "scale(1)";
@@ -986,7 +983,7 @@ function it(t) {
986
983
  } catch {
987
984
  }
988
985
  }
989
- M == null || M();
986
+ R == null || R();
990
987
  }), B = (q) => {
991
988
  q.key === "Escape" && j && (j = !1, ae(!1), te());
992
989
  }, document.addEventListener("keydown", B);
@@ -1003,7 +1000,7 @@ function it(t) {
1003
1000
  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
1001
  } catch {
1005
1002
  }
1006
- }, r = [], i = (o) => {
1003
+ }, r = [], a = (o) => {
1007
1004
  for (; r.length; ) {
1008
1005
  const p = r.shift();
1009
1006
  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 +1032,7 @@ function it(t) {
1035
1032
  h.send({ type: "fetchPrekey", targetUserId: o });
1036
1033
  }, Se = qe(t.locale, t.i18n), Ee = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
1037
1034
  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, {
1035
+ const le = `oc_prechat_${t.profileId}_${i.slice(-8)}`, N = new et(t.el, i, {
1039
1036
  onSend(o) {
1040
1037
  const p = `cm_${Math.random().toString(36).slice(2)}`, g = { kind: "text", text: o };
1041
1038
  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 +1049,7 @@ function it(t) {
1052
1049
  // requires an Authorization header, and the verifier accepts an
1053
1050
  // anonymous id as a guest; keying off opts.token alone meant anonymous
1054
1051
  // visitors (the common case) sent no auth and every upload 401'd.
1055
- headers: { "content-type": o.type, authorization: `Bearer ${a}` },
1052
+ headers: { "content-type": o.type, authorization: `Bearer ${i}` },
1056
1053
  body: o
1057
1054
  });
1058
1055
  if (!$.ok) throw new Error(`Upload failed: ${$.status}`);
@@ -1126,7 +1123,7 @@ function it(t) {
1126
1123
  onCsat(o) {
1127
1124
  d && fetch(`${y}/conversations/${d}/csat`, {
1128
1125
  method: "POST",
1129
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${a}` },
1126
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${i}` },
1130
1127
  body: JSON.stringify({ score: o })
1131
1128
  }).catch(() => {
1132
1129
  });
@@ -1139,7 +1136,7 @@ function it(t) {
1139
1136
  try {
1140
1137
  const $ = await fetch(`${y}/translate`, {
1141
1138
  method: "POST",
1142
- headers: { "content-type": "application/json", authorization: `Bearer ${a}` },
1139
+ headers: { "content-type": "application/json", authorization: `Bearer ${i}` },
1143
1140
  body: JSON.stringify({ text: g, targetLang: p })
1144
1141
  });
1145
1142
  if (!$.ok) return null;
@@ -1190,7 +1187,7 @@ function it(t) {
1190
1187
  h = new Ue({
1191
1188
  ...t.refreshToken ? { refreshToken: t.refreshToken } : {},
1192
1189
  url: b,
1193
- token: a,
1190
+ token: i,
1194
1191
  open: Le,
1195
1192
  getCursor: () => s.highestSeq(),
1196
1193
  onStatusChange: (o, p) => N.setConnStatus(o, p),
@@ -1201,7 +1198,7 @@ function it(t) {
1201
1198
  for (const p of u.load())
1202
1199
  h.send({ type: "send", conversationId: d, clientMsgId: p.clientMsgId, content: p.content });
1203
1200
  }
1204
- Oe(b, a, d, s, N, y), r.length && i(d);
1201
+ Oe(b, i, d, s, N, y), r.length && a(d);
1205
1202
  }
1206
1203
  if (o.type === "ack" && u.remove(o.clientMsgId), o.type === "prekeyBundle") {
1207
1204
  o.bundle && (S = !0, m.x3dhSendTo(o.bundle).then((p) => {
@@ -1228,11 +1225,11 @@ function it(t) {
1228
1225
  }
1229
1226
  (async () => {
1230
1227
  if (s.e2e && await m.openFrame(o), s.apply(o), o.type === "manifest") {
1231
- M == null || M();
1228
+ R == null || R();
1232
1229
  const p = o.botName;
1233
1230
  p && N.setBotName(p);
1234
1231
  }
1235
- if (o.type === "message" && o.message.senderId !== a && !o.message.internal && (_(), E()), s.e2e && d && !v) {
1232
+ if (o.type === "message" && o.message.senderId !== i && !o.message.internal && (_(), E()), s.e2e && d && !v) {
1236
1233
  v = !0;
1237
1234
  const p = await m.initX3DH();
1238
1235
  h.send({ type: "uploadPrekeys", ...p });