@paramms/chat-widget 1.0.16 → 1.0.17

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,7 +1,7 @@
1
1
  var Pe = Object.defineProperty;
2
2
  var Be = (s, e, t) => e in s ? Pe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var r = (s, e, t) => Be(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { p as Ke, r as Ae, h as ze } from "./uid.js";
3
+ var a = (s, e, t) => Be(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { p as Ke, h as Ae, r as ze } from "./uid.js";
5
5
  const jt = (s) => s;
6
6
  function Le(s) {
7
7
  const e = s.length;
@@ -13,8 +13,8 @@ function Le(s) {
13
13
  t += 2;
14
14
  else {
15
15
  if (i >= 55296 && i <= 56319 && n < e) {
16
- const o = s.charCodeAt(n);
17
- (o & 64512) === 56320 && (++n, i = ((i & 1023) << 10) + (o & 1023) + 65536);
16
+ const r = s.charCodeAt(n);
17
+ (r & 64512) === 56320 && (++n, i = ((i & 1023) << 10) + (r & 1023) + 65536);
18
18
  }
19
19
  i & 4294901760 ? t += 4 : t += 3;
20
20
  }
@@ -27,24 +27,24 @@ function Le(s) {
27
27
  }
28
28
  function Me(s, e, t) {
29
29
  const n = s.length;
30
- let i = t, o = 0;
31
- for (; o < n; ) {
32
- let c = s.charCodeAt(o++);
33
- if (c & 4294967168)
34
- if (!(c & 4294965248))
35
- e[i++] = c >> 6 & 31 | 192;
30
+ let i = t, r = 0;
31
+ for (; r < n; ) {
32
+ let o = s.charCodeAt(r++);
33
+ if (o & 4294967168)
34
+ if (!(o & 4294965248))
35
+ e[i++] = o >> 6 & 31 | 192;
36
36
  else {
37
- if (c >= 55296 && c <= 56319 && o < n) {
38
- const l = s.charCodeAt(o);
39
- (l & 64512) === 56320 && (++o, c = ((c & 1023) << 10) + (l & 1023) + 65536);
37
+ if (o >= 55296 && o <= 56319 && r < n) {
38
+ const l = s.charCodeAt(r);
39
+ (l & 64512) === 56320 && (++r, o = ((o & 1023) << 10) + (l & 1023) + 65536);
40
40
  }
41
- c & 4294901760 ? (e[i++] = c >> 18 & 7 | 240, e[i++] = c >> 12 & 63 | 128, e[i++] = c >> 6 & 63 | 128) : (e[i++] = c >> 12 & 15 | 224, e[i++] = c >> 6 & 63 | 128);
41
+ o & 4294901760 ? (e[i++] = o >> 18 & 7 | 240, e[i++] = o >> 12 & 63 | 128, e[i++] = o >> 6 & 63 | 128) : (e[i++] = o >> 12 & 15 | 224, e[i++] = o >> 6 & 63 | 128);
42
42
  }
43
43
  else {
44
- e[i++] = c;
44
+ e[i++] = o;
45
45
  continue;
46
46
  }
47
- e[i++] = c & 63 | 128;
47
+ e[i++] = o & 63 | 128;
48
48
  }
49
49
  }
50
50
  const De = new TextEncoder(), _e = 50;
@@ -57,27 +57,27 @@ function He(s, e, t) {
57
57
  const Re = 4096;
58
58
  function ye(s, e, t) {
59
59
  let n = e;
60
- const i = n + t, o = [];
61
- let c = "";
60
+ const i = n + t, r = [];
61
+ let o = "";
62
62
  for (; n < i; ) {
63
63
  const l = s[n++];
64
64
  if (!(l & 128))
65
- o.push(l);
65
+ r.push(l);
66
66
  else if ((l & 224) === 192) {
67
67
  const w = s[n++] & 63;
68
- o.push((l & 31) << 6 | w);
68
+ r.push((l & 31) << 6 | w);
69
69
  } else if ((l & 240) === 224) {
70
- const w = s[n++] & 63, f = s[n++] & 63;
71
- o.push((l & 31) << 12 | w << 6 | f);
70
+ const w = s[n++] & 63, x = s[n++] & 63;
71
+ r.push((l & 31) << 12 | w << 6 | x);
72
72
  } else if ((l & 248) === 240) {
73
- const w = s[n++] & 63, f = s[n++] & 63, b = s[n++] & 63;
74
- let x = (l & 7) << 18 | w << 12 | f << 6 | b;
75
- x > 65535 && (x -= 65536, o.push(x >>> 10 & 1023 | 55296), x = 56320 | x & 1023), o.push(x);
73
+ const w = s[n++] & 63, x = s[n++] & 63, m = s[n++] & 63;
74
+ let f = (l & 7) << 18 | w << 12 | x << 6 | m;
75
+ f > 65535 && (f -= 65536, r.push(f >>> 10 & 1023 | 55296), f = 56320 | f & 1023), r.push(f);
76
76
  } else
77
- o.push(l);
78
- o.length >= Re && (c += String.fromCharCode(...o), o.length = 0);
77
+ r.push(l);
78
+ r.length >= Re && (o += String.fromCharCode(...r), r.length = 0);
79
79
  }
80
- return o.length > 0 && (c += String.fromCharCode(...o)), c;
80
+ return r.length > 0 && (o += String.fromCharCode(...r)), o;
81
81
  }
82
82
  const Fe = new TextDecoder(), je = 200;
83
83
  function qe(s, e, t) {
@@ -89,8 +89,8 @@ function Oe(s, e, t) {
89
89
  }
90
90
  class X {
91
91
  constructor(e, t) {
92
- r(this, "type");
93
- r(this, "data");
92
+ a(this, "type");
93
+ a(this, "data");
94
94
  this.type = e, this.data = t;
95
95
  }
96
96
  }
@@ -105,7 +105,7 @@ class z extends Error {
105
105
  });
106
106
  }
107
107
  }
108
- const q = 4294967295;
108
+ const j = 4294967295;
109
109
  function Ne(s, e, t) {
110
110
  const n = t / 4294967296, i = t;
111
111
  s.setUint32(e, n), s.setUint32(e + 4, i);
@@ -129,8 +129,8 @@ function Je({ sec: s, nsec: e }) {
129
129
  const t = new Uint8Array(4);
130
130
  return new DataView(t.buffer).setUint32(0, s), t;
131
131
  } else {
132
- const t = s / 4294967296, n = s & 4294967295, i = new Uint8Array(8), o = new DataView(i.buffer);
133
- return o.setUint32(0, e << 2 | t & 3), o.setUint32(4, n), i;
132
+ const t = s / 4294967296, n = s & 4294967295, i = new Uint8Array(8), r = new DataView(i.buffer);
133
+ return r.setUint32(0, e << 2 | t & 3), r.setUint32(4, n), i;
134
134
  }
135
135
  else {
136
136
  const t = new Uint8Array(12), n = new DataView(t.buffer);
@@ -157,8 +157,8 @@ function Ze(s) {
157
157
  case 4:
158
158
  return { sec: e.getUint32(0), nsec: 0 };
159
159
  case 8: {
160
- const t = e.getUint32(0), n = e.getUint32(4), i = (t & 3) * 4294967296 + n, o = t >>> 2;
161
- return { sec: i, nsec: o };
160
+ const t = e.getUint32(0), n = e.getUint32(4), i = (t & 3) * 4294967296 + n, r = t >>> 2;
161
+ return { sec: i, nsec: r };
162
162
  }
163
163
  case 12: {
164
164
  const t = be(e, 4), n = e.getUint32(0);
@@ -181,13 +181,13 @@ const tt = {
181
181
  // ensures ExtensionCodecType<X> matches ExtensionCodec<X>
182
182
  // this will make type errors a lot more clear
183
183
  // eslint-disable-next-line @typescript-eslint/naming-convention
184
- r(this, "__brand");
184
+ a(this, "__brand");
185
185
  // built-in extensions
186
- r(this, "builtInEncoders", []);
187
- r(this, "builtInDecoders", []);
186
+ a(this, "builtInEncoders", []);
187
+ a(this, "builtInDecoders", []);
188
188
  // custom extensions
189
- r(this, "encoders", []);
190
- r(this, "decoders", []);
189
+ a(this, "encoders", []);
190
+ a(this, "decoders", []);
191
191
  this.register(tt);
192
192
  }
193
193
  register({ type: e, encode: t, decode: n }) {
@@ -202,20 +202,20 @@ const tt = {
202
202
  for (let n = 0; n < this.builtInEncoders.length; n++) {
203
203
  const i = this.builtInEncoders[n];
204
204
  if (i != null) {
205
- const o = i(e, t);
206
- if (o != null) {
207
- const c = -1 - n;
208
- return new X(c, o);
205
+ const r = i(e, t);
206
+ if (r != null) {
207
+ const o = -1 - n;
208
+ return new X(o, r);
209
209
  }
210
210
  }
211
211
  }
212
212
  for (let n = 0; n < this.encoders.length; n++) {
213
213
  const i = this.encoders[n];
214
214
  if (i != null) {
215
- const o = i(e, t);
216
- if (o != null) {
217
- const c = n;
218
- return new X(c, o);
215
+ const r = i(e, t);
216
+ if (r != null) {
217
+ const o = n;
218
+ return new X(o, r);
219
219
  }
220
220
  }
221
221
  }
@@ -226,7 +226,7 @@ const tt = {
226
226
  return i ? i(e, t, n) : new X(t, e);
227
227
  }
228
228
  };
229
- r(G, "defaultCodec", new G());
229
+ a(G, "defaultCodec", new G());
230
230
  let Y = G;
231
231
  function nt(s) {
232
232
  return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
@@ -237,19 +237,19 @@ function te(s) {
237
237
  const it = 100, st = 2048;
238
238
  class se {
239
239
  constructor(e) {
240
- r(this, "extensionCodec");
241
- r(this, "context");
242
- r(this, "useBigInt64");
243
- r(this, "maxDepth");
244
- r(this, "initialBufferSize");
245
- r(this, "sortKeys");
246
- r(this, "forceFloat32");
247
- r(this, "ignoreUndefined");
248
- r(this, "forceIntegerToFloat");
249
- r(this, "pos");
250
- r(this, "view");
251
- r(this, "bytes");
252
- r(this, "entered", !1);
240
+ a(this, "extensionCodec");
241
+ a(this, "context");
242
+ a(this, "useBigInt64");
243
+ a(this, "maxDepth");
244
+ a(this, "initialBufferSize");
245
+ a(this, "sortKeys");
246
+ a(this, "forceFloat32");
247
+ a(this, "ignoreUndefined");
248
+ a(this, "forceIntegerToFloat");
249
+ a(this, "pos");
250
+ a(this, "view");
251
+ a(this, "bytes");
252
+ a(this, "entered", !1);
253
253
  this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? it, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? st, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
254
254
  }
255
255
  clone() {
@@ -395,9 +395,9 @@ class se {
395
395
  this.writeU8(223), this.writeU32(i);
396
396
  else
397
397
  throw new Error(`Too large map object: ${i}`);
398
- for (const o of n) {
399
- const c = e[o];
400
- this.ignoreUndefined && c === void 0 || (this.encodeString(o), this.doEncode(c, t + 1));
398
+ for (const r of n) {
399
+ const o = e[r];
400
+ this.ignoreUndefined && o === void 0 || (this.encodeString(r), this.doEncode(o, t + 1));
401
401
  }
402
402
  }
403
403
  encodeExtension(e) {
@@ -479,11 +479,11 @@ function Z(s) {
479
479
  const rt = 16, at = 16;
480
480
  class ct {
481
481
  constructor(e = rt, t = at) {
482
- r(this, "hit", 0);
483
- r(this, "miss", 0);
484
- r(this, "caches");
485
- r(this, "maxKeyLength");
486
- r(this, "maxLengthPerKey");
482
+ a(this, "hit", 0);
483
+ a(this, "miss", 0);
484
+ a(this, "caches");
485
+ a(this, "maxKeyLength");
486
+ a(this, "maxLengthPerKey");
487
487
  this.maxKeyLength = e, this.maxLengthPerKey = t, this.caches = [];
488
488
  for (let n = 0; n < this.maxKeyLength; n++)
489
489
  this.caches.push([]);
@@ -493,12 +493,12 @@ class ct {
493
493
  }
494
494
  find(e, t, n) {
495
495
  const i = this.caches[n - 1];
496
- e: for (const o of i) {
497
- const c = o.bytes;
496
+ e: for (const r of i) {
497
+ const o = r.bytes;
498
498
  for (let l = 0; l < n; l++)
499
- if (c[l] !== e[t + l])
499
+ if (o[l] !== e[t + l])
500
500
  continue e;
501
- return o.str;
501
+ return r.str;
502
502
  }
503
503
  return null;
504
504
  }
@@ -511,19 +511,19 @@ class ct {
511
511
  if (i != null)
512
512
  return this.hit++, i;
513
513
  this.miss++;
514
- const o = ye(e, t, n), c = Uint8Array.prototype.slice.call(e, t, t + n);
515
- return this.store(c, o), o;
514
+ const r = ye(e, t, n), o = Uint8Array.prototype.slice.call(e, t, t + n);
515
+ return this.store(o, r), r;
516
516
  }
517
517
  }
518
- const ne = "array", N = "map_key", me = "map_value", dt = (s) => {
518
+ const ne = "array", O = "map_key", me = "map_value", dt = (s) => {
519
519
  if (typeof s == "string" || typeof s == "number")
520
520
  return s;
521
521
  throw new z("The type of key must be string or number but " + typeof s);
522
522
  };
523
523
  class lt {
524
524
  constructor() {
525
- r(this, "stack", []);
526
- r(this, "stackHeadPosition", -1);
525
+ a(this, "stack", []);
526
+ a(this, "stackHeadPosition", -1);
527
527
  }
528
528
  get length() {
529
529
  return this.stackHeadPosition + 1;
@@ -537,7 +537,7 @@ class lt {
537
537
  }
538
538
  pushMapState(e) {
539
539
  const t = this.getUninitializedStateFromPool();
540
- t.type = N, t.readCount = 0, t.size = e, t.map = {};
540
+ t.type = O, t.readCount = 0, t.size = e, t.map = {};
541
541
  }
542
542
  getUninitializedStateFromPool() {
543
543
  if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
@@ -561,7 +561,7 @@ class lt {
561
561
  const n = e;
562
562
  n.size = 0, n.array = void 0, n.position = 0, n.type = void 0;
563
563
  }
564
- if (e.type === N || e.type === me) {
564
+ if (e.type === O || e.type === me) {
565
565
  const n = e;
566
566
  n.size = 0, n.map = void 0, n.readCount = 0, n.type = void 0;
567
567
  }
@@ -571,7 +571,7 @@ class lt {
571
571
  this.stack.length = 0, this.stackHeadPosition = -1;
572
572
  }
573
573
  }
574
- const O = -1, oe = new DataView(new ArrayBuffer(0)), ht = new Uint8Array(oe.buffer);
574
+ const q = -1, oe = new DataView(new ArrayBuffer(0)), ht = new Uint8Array(oe.buffer);
575
575
  try {
576
576
  oe.getInt8(0);
577
577
  } catch (s) {
@@ -581,25 +581,25 @@ try {
581
581
  const pe = new RangeError("Insufficient data"), pt = new ct();
582
582
  class re {
583
583
  constructor(e) {
584
- r(this, "extensionCodec");
585
- r(this, "context");
586
- r(this, "useBigInt64");
587
- r(this, "rawStrings");
588
- r(this, "maxStrLength");
589
- r(this, "maxBinLength");
590
- r(this, "maxArrayLength");
591
- r(this, "maxMapLength");
592
- r(this, "maxExtLength");
593
- r(this, "keyDecoder");
594
- r(this, "mapKeyConverter");
595
- r(this, "totalPos", 0);
596
- r(this, "pos", 0);
597
- r(this, "view", oe);
598
- r(this, "bytes", ht);
599
- r(this, "headByte", O);
600
- r(this, "stack", new lt());
601
- r(this, "entered", !1);
602
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? q, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? q, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? q, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? q, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? q, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : pt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? dt;
584
+ a(this, "extensionCodec");
585
+ a(this, "context");
586
+ a(this, "useBigInt64");
587
+ a(this, "rawStrings");
588
+ a(this, "maxStrLength");
589
+ a(this, "maxBinLength");
590
+ a(this, "maxArrayLength");
591
+ a(this, "maxMapLength");
592
+ a(this, "maxExtLength");
593
+ a(this, "keyDecoder");
594
+ a(this, "mapKeyConverter");
595
+ a(this, "totalPos", 0);
596
+ a(this, "pos", 0);
597
+ a(this, "view", oe);
598
+ a(this, "bytes", ht);
599
+ a(this, "headByte", q);
600
+ a(this, "stack", new lt());
601
+ a(this, "entered", !1);
602
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? j, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? j, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? j, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? j, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? j, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : pt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? dt;
603
603
  }
604
604
  clone() {
605
605
  return new re({
@@ -616,14 +616,14 @@ class re {
616
616
  });
617
617
  }
618
618
  reinitializeState() {
619
- this.totalPos = 0, this.headByte = O, this.stack.reset();
619
+ this.totalPos = 0, this.headByte = q, this.stack.reset();
620
620
  }
621
621
  setBuffer(e) {
622
622
  const t = te(e);
623
623
  this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
624
624
  }
625
625
  appendBuffer(e) {
626
- if (this.headByte === O && !this.hasRemaining(1))
626
+ if (this.headByte === q && !this.hasRemaining(1))
627
627
  this.setBuffer(e);
628
628
  else {
629
629
  const t = this.bytes.subarray(this.pos), n = te(e), i = new Uint8Array(t.length + n.length);
@@ -689,8 +689,8 @@ class re {
689
689
  throw this.createExtraByteError(this.totalPos);
690
690
  return n;
691
691
  }
692
- const { headByte: i, pos: o, totalPos: c } = this;
693
- throw new RangeError(`Insufficient data in parsing ${Z(i)} at ${c} (${o} in the current buffer)`);
692
+ const { headByte: i, pos: r, totalPos: o } = this;
693
+ throw new RangeError(`Insufficient data in parsing ${Z(i)} at ${o} (${r} in the current buffer)`);
694
694
  } finally {
695
695
  this.entered = !1;
696
696
  }
@@ -709,16 +709,16 @@ class re {
709
709
  try {
710
710
  this.entered = !0;
711
711
  let n = t, i = -1;
712
- for await (const o of e) {
712
+ for await (const r of e) {
713
713
  if (t && i === 0)
714
714
  throw this.createExtraByteError(this.totalPos);
715
- this.appendBuffer(o), n && (i = this.readArraySize(), n = !1, this.complete());
715
+ this.appendBuffer(r), n && (i = this.readArraySize(), n = !1, this.complete());
716
716
  try {
717
717
  for (; yield this.doDecodeSync(), --i !== 0; )
718
718
  ;
719
- } catch (c) {
720
- if (!(c instanceof RangeError))
721
- throw c;
719
+ } catch (o) {
720
+ if (!(o instanceof RangeError))
721
+ throw o;
722
722
  }
723
723
  this.totalPos += this.pos;
724
724
  }
@@ -855,7 +855,7 @@ class re {
855
855
  t = i.array, n.release(i);
856
856
  else
857
857
  continue e;
858
- else if (i.type === N) {
858
+ else if (i.type === O) {
859
859
  if (t === "__proto__")
860
860
  throw new z("The key __proto__ is not allowed");
861
861
  i.key = this.mapKeyConverter(t), i.type = me;
@@ -863,7 +863,7 @@ class re {
863
863
  } else if (i.map[i.key] = t, i.readCount++, i.readCount === i.size)
864
864
  t = i.map, n.release(i);
865
865
  else {
866
- i.key = null, i.type = N;
866
+ i.key = null, i.type = O;
867
867
  continue e;
868
868
  }
869
869
  }
@@ -871,10 +871,10 @@ class re {
871
871
  }
872
872
  }
873
873
  readHeadByte() {
874
- return this.headByte === O && (this.headByte = this.readU8()), this.headByte;
874
+ return this.headByte === q && (this.headByte = this.readU8()), this.headByte;
875
875
  }
876
876
  complete() {
877
- this.headByte = O;
877
+ this.headByte = q;
878
878
  }
879
879
  readArraySize() {
880
880
  const e = this.readHeadByte();
@@ -907,17 +907,17 @@ class re {
907
907
  * @throws {@link RangeError}
908
908
  */
909
909
  decodeUtf8String(e, t) {
910
- var o;
910
+ var r;
911
911
  if (e > this.maxStrLength)
912
912
  throw new z(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
913
913
  if (this.bytes.byteLength < this.pos + t + e)
914
914
  throw pe;
915
915
  const n = this.pos + t;
916
916
  let i;
917
- return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, n, e) : i = Oe(this.bytes, n, e), this.pos += t + e, i;
917
+ return this.stateIsMapKey() && ((r = this.keyDecoder) != null && r.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, n, e) : i = Oe(this.bytes, n, e), this.pos += t + e, i;
918
918
  }
919
919
  stateIsMapKey() {
920
- return this.stack.length > 0 ? this.stack.top().type === N : !1;
920
+ return this.stack.length > 0 ? this.stack.top().type === O : !1;
921
921
  }
922
922
  /**
923
923
  * @throws {@link RangeError}
@@ -1035,33 +1035,33 @@ function yt(s) {
1035
1035
  }
1036
1036
  class gt {
1037
1037
  constructor(e) {
1038
- r(this, "conversationId");
1039
- r(this, "state", "");
1040
- r(this, "version", 0);
1041
- r(this, "hasMoreHistory", !1);
1042
- r(this, "lastReadByOthers", 0);
1043
- r(this, "assignedAgentId");
1044
- r(this, "accent");
1045
- r(this, "subject");
1046
- r(this, "name");
1047
- r(this, "e2e", !1);
1048
- r(this, "offline", !1);
1049
- r(this, "offlineMessage", "");
1050
- r(this, "whiteLabel", !1);
1051
- r(this, "typing", /* @__PURE__ */ new Set());
1052
- r(this, "online", /* @__PURE__ */ new Set());
1038
+ a(this, "conversationId");
1039
+ a(this, "state", "");
1040
+ a(this, "version", 0);
1041
+ a(this, "hasMoreHistory", !1);
1042
+ a(this, "lastReadByOthers", 0);
1043
+ a(this, "assignedAgentId");
1044
+ a(this, "accent");
1045
+ a(this, "subject");
1046
+ a(this, "name");
1047
+ a(this, "e2e", !1);
1048
+ a(this, "offline", !1);
1049
+ a(this, "offlineMessage", "");
1050
+ a(this, "whiteLabel", !1);
1051
+ a(this, "typing", /* @__PURE__ */ new Set());
1052
+ a(this, "online", /* @__PURE__ */ new Set());
1053
1053
  /** Co-browsing: shared whiteboard strokes for this conversation. */
1054
- r(this, "annotations", []);
1054
+ a(this, "annotations", []);
1055
1055
  /** Bumped on any annotation change so the renderer can cheaply detect updates. */
1056
- r(this, "annotationVersion", 0);
1056
+ a(this, "annotationVersion", 0);
1057
1057
  /** Live sentiment of the guest's latest message (agent-side only). */
1058
- r(this, "sentiment");
1059
- r(this, "sentimentScore");
1060
- r(this, "actions", []);
1061
- r(this, "byId", /* @__PURE__ */ new Map());
1062
- r(this, "keyByClient", /* @__PURE__ */ new Map());
1063
- r(this, "_maxSeq", 0);
1064
- r(this, "_sorted", null);
1058
+ a(this, "sentiment");
1059
+ a(this, "sentimentScore");
1060
+ a(this, "actions", []);
1061
+ a(this, "byId", /* @__PURE__ */ new Map());
1062
+ a(this, "keyByClient", /* @__PURE__ */ new Map());
1063
+ a(this, "_maxSeq", 0);
1064
+ a(this, "_sorted", null);
1065
1065
  this.me = e;
1066
1066
  }
1067
1067
  messages() {
@@ -1106,8 +1106,8 @@ class gt {
1106
1106
  const n = this.keyByClient.get(e.clientMsgId), i = n ? this.byId.get(n) : void 0;
1107
1107
  if (i && n) {
1108
1108
  this.byId.delete(n);
1109
- const o = { ...i, id: e.messageId, seq: e.seq, ts: e.ts, status: "sent" };
1110
- this.byId.set(e.messageId, o), this.keyByClient.set(e.clientMsgId, e.messageId), e.seq > this._maxSeq && (this._maxSeq = e.seq);
1109
+ const r = { ...i, id: e.messageId, seq: e.seq, ts: e.ts, status: "sent" };
1110
+ this.byId.set(e.messageId, r), this.keyByClient.set(e.clientMsgId, e.messageId), e.seq > this._maxSeq && (this._maxSeq = e.seq);
1111
1111
  }
1112
1112
  this._sorted = null;
1113
1113
  return;
@@ -1131,8 +1131,8 @@ class gt {
1131
1131
  case "reaction": {
1132
1132
  const n = this.byId.get(e.messageId);
1133
1133
  if (!n) return;
1134
- const i = { ...n.reactions ?? {} }, o = (i[e.emoji] ?? []).filter((c) => c !== e.by);
1135
- e.removed || o.push(e.by), o.length ? i[e.emoji] = o : delete i[e.emoji], this.byId.set(e.messageId, { ...n, reactions: i }), this._sorted = null;
1134
+ const i = { ...n.reactions ?? {} }, r = (i[e.emoji] ?? []).filter((o) => o !== e.by);
1135
+ e.removed || r.push(e.by), r.length ? i[e.emoji] = r : delete i[e.emoji], this.byId.set(e.messageId, { ...n, reactions: i }), this._sorted = null;
1136
1136
  return;
1137
1137
  }
1138
1138
  case "edited": {
@@ -1180,8 +1180,8 @@ class gt {
1180
1180
  markOwnStatus(e, t) {
1181
1181
  const n = ue(t);
1182
1182
  let i = !1;
1183
- for (const [o, c] of this.byId)
1184
- c.senderId !== this.me || c.seq <= 0 || c.seq > e || ue(c.status) >= n || (this.byId.set(o, { ...c, status: t }), i = !0);
1183
+ for (const [r, o] of this.byId)
1184
+ o.senderId !== this.me || o.seq <= 0 || o.seq > e || ue(o.status) >= n || (this.byId.set(r, { ...o, status: t }), i = !0);
1185
1185
  i && (this._sorted = null);
1186
1186
  }
1187
1187
  }
@@ -1199,13 +1199,13 @@ function ue(s) {
1199
1199
  }
1200
1200
  class bt {
1201
1201
  constructor(e) {
1202
- r(this, "socket", null);
1203
- r(this, "state", "idle");
1204
- r(this, "authed", !1);
1205
- r(this, "attempt", 0);
1206
- r(this, "outbox", []);
1207
- r(this, "stopped", !1);
1208
- r(this, "timer", null);
1202
+ a(this, "socket", null);
1203
+ a(this, "state", "idle");
1204
+ a(this, "authed", !1);
1205
+ a(this, "attempt", 0);
1206
+ a(this, "outbox", []);
1207
+ a(this, "stopped", !1);
1208
+ a(this, "timer", null);
1209
1209
  this.opts = e;
1210
1210
  }
1211
1211
  connect() {
@@ -1215,9 +1215,9 @@ class bt {
1215
1215
  const t = (this.opts.socketFactory ?? mt)(this.opts.url);
1216
1216
  t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
1217
1217
  this.raw({ type: "auth", token: this.opts.token });
1218
- }, t.onmessage = (o) => {
1219
- const c = yt(new Uint8Array(o.data));
1220
- !c || wt(c) || this.handle(c);
1218
+ }, t.onmessage = (r) => {
1219
+ const o = yt(new Uint8Array(r.data));
1220
+ !o || wt(o) || this.handle(o);
1221
1221
  }, t.onclose = () => this.onClosed(), t.onerror = () => {
1222
1222
  try {
1223
1223
  t.close();
@@ -1277,7 +1277,7 @@ function mt(s) {
1277
1277
  const fe = 200, vt = 7 * 864e5;
1278
1278
  class kt {
1279
1279
  constructor(e) {
1280
- r(this, "key");
1280
+ a(this, "key");
1281
1281
  this.key = `ocw_outbox_${e}`;
1282
1282
  }
1283
1283
  /** All pending items, oldest first, with stale (>7d) entries dropped. */
@@ -1285,7 +1285,7 @@ class kt {
1285
1285
  try {
1286
1286
  const e = localStorage.getItem(this.key);
1287
1287
  if (!e) return [];
1288
- const t = JSON.parse(e), n = Date.now() - vt, i = t.filter((o) => o.ts >= n);
1288
+ const t = JSON.parse(e), n = Date.now() - vt, i = t.filter((r) => r.ts >= n);
1289
1289
  return i.length !== t.length && this.save(i), i;
1290
1290
  } catch {
1291
1291
  return [];
@@ -1325,18 +1325,18 @@ function ie(s) {
1325
1325
  for (let i = 0; i < e.length; i++) n[i] = e.charCodeAt(i);
1326
1326
  return n;
1327
1327
  }
1328
- async function V() {
1328
+ async function N() {
1329
1329
  const s = await S().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1330
1330
  return { publicKey: s.publicKey, privateKey: s.privateKey };
1331
1331
  }
1332
- async function R(s) {
1332
+ async function _(s) {
1333
1333
  return J(await S().exportKey("raw", s));
1334
1334
  }
1335
- async function j(s) {
1335
+ async function F(s) {
1336
1336
  return S().importKey("raw", ie(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1337
1337
  }
1338
1338
  async function St(s, e) {
1339
- const t = await j(e);
1339
+ const t = await F(e);
1340
1340
  return S().deriveKey(
1341
1341
  { name: "ECDH", public: t },
1342
1342
  s,
@@ -1358,15 +1358,15 @@ async function Et(s) {
1358
1358
  try {
1359
1359
  const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
1360
1360
  if (i) {
1361
- const { pub: o, priv: c } = JSON.parse(i), l = await S().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await S().importKey("jwk", c, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1361
+ const { pub: r, priv: o } = JSON.parse(i), l = await S().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await S().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1362
1362
  return { publicKey: l, privateKey: w };
1363
1363
  }
1364
1364
  } catch {
1365
1365
  }
1366
- const e = await V();
1366
+ const e = await N();
1367
1367
  try {
1368
- const i = await S().exportKey("jwk", e.publicKey), o = await S().exportKey("jwk", e.privateKey);
1369
- (n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv: o }));
1368
+ const i = await S().exportKey("jwk", e.publicKey), r = await S().exportKey("jwk", e.privateKey);
1369
+ (n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv: r }));
1370
1370
  } catch {
1371
1371
  }
1372
1372
  return e;
@@ -1376,12 +1376,12 @@ async function Tt(s, e) {
1376
1376
  return J(n);
1377
1377
  }
1378
1378
  async function Ut() {
1379
- const s = await V(), e = await S().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1379
+ const s = await N(), e = await S().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1380
1380
  return {
1381
1381
  ecdhKP: s,
1382
1382
  ecdsaKP: { publicKey: e.publicKey, privateKey: e.privateKey },
1383
- publicKeyB64: await R(s.publicKey),
1384
- sigPublicKeyB64: await R(e.publicKey)
1383
+ publicKeyB64: await _(s.publicKey),
1384
+ sigPublicKeyB64: await _(e.publicKey)
1385
1385
  };
1386
1386
  }
1387
1387
  async function we(s) {
@@ -1389,37 +1389,37 @@ async function we(s) {
1389
1389
  try {
1390
1390
  const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
1391
1391
  if (i) {
1392
- const o = JSON.parse(i), c = await S().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), l = await S().importKey("jwk", o.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await S().importKey("jwk", o.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), f = await S().importKey("jwk", o.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
1392
+ const r = JSON.parse(i), o = await S().importKey("jwk", r.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), l = await S().importKey("jwk", r.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await S().importKey("jwk", r.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), x = await S().importKey("jwk", r.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
1393
1393
  return {
1394
- ecdhKP: { publicKey: c, privateKey: l },
1395
- ecdsaKP: { publicKey: w, privateKey: f },
1396
- publicKeyB64: await R(c),
1397
- sigPublicKeyB64: await R(w)
1394
+ ecdhKP: { publicKey: o, privateKey: l },
1395
+ ecdsaKP: { publicKey: w, privateKey: x },
1396
+ publicKeyB64: await _(o),
1397
+ sigPublicKeyB64: await _(w)
1398
1398
  };
1399
1399
  }
1400
1400
  } catch {
1401
1401
  }
1402
1402
  const e = await Ut();
1403
1403
  try {
1404
- const i = await S().exportKey("jwk", e.ecdhKP.publicKey), o = await S().exportKey("jwk", e.ecdhKP.privateKey), c = await S().exportKey("jwk", e.ecdsaKP.publicKey), l = await S().exportKey("jwk", e.ecdsaKP.privateKey);
1405
- (n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: o, ecdsaPub: c, ecdsaPriv: l }));
1404
+ const i = await S().exportKey("jwk", e.ecdhKP.publicKey), r = await S().exportKey("jwk", e.ecdhKP.privateKey), o = await S().exportKey("jwk", e.ecdsaKP.publicKey), l = await S().exportKey("jwk", e.ecdsaKP.privateKey);
1405
+ (n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: r, ecdsaPub: o, ecdsaPriv: l }));
1406
1406
  } catch {
1407
1407
  }
1408
1408
  return e;
1409
1409
  }
1410
1410
  async function Pt(s, e) {
1411
- const t = await V(), n = await R(t.publicKey), i = await j(e.identityKey), o = await j(e.signedPrekey), c = e.oneTimePrekey ? await j(e.oneTimePrekey) : null, l = await H(s.privateKey, o), w = await H(t.privateKey, i), f = await H(t.privateKey, o), b = c ? await H(t.privateKey, c) : null, x = ve(l, w, f, ...b ? [b] : []);
1412
- return { sharedKey: await ke(x), ephemeralPublicKey: n };
1411
+ const t = await N(), n = await _(t.publicKey), i = await F(e.identityKey), r = await F(e.signedPrekey), o = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, l = await D(s.privateKey, r), w = await D(t.privateKey, i), x = await D(t.privateKey, r), m = o ? await D(t.privateKey, o) : null, f = ve(l, w, x, ...m ? [m] : []);
1412
+ return { sharedKey: await ke(f), ephemeralPublicKey: n };
1413
1413
  }
1414
1414
  async function Bt(s, e, t, n, i) {
1415
- const o = await j(t), c = await j(n), l = await H(e.privateKey, o), w = await H(s.privateKey, c), f = await H(e.privateKey, c), b = i ? await H(i.privateKey, c) : null, x = ve(l, w, f, ...b ? [b] : []);
1416
- return ke(x);
1415
+ const r = await F(t), o = await F(n), l = await D(e.privateKey, r), w = await D(s.privateKey, o), x = await D(e.privateKey, o), m = i ? await D(i.privateKey, o) : null, f = ve(l, w, x, ...m ? [m] : []);
1416
+ return ke(f);
1417
1417
  }
1418
- async function H(s, e) {
1418
+ async function D(s, e) {
1419
1419
  return S().deriveBits({ name: "ECDH", public: e }, s, 256);
1420
1420
  }
1421
1421
  function ve(...s) {
1422
- const e = s.reduce((i, o) => i + o.byteLength, 0), t = new Uint8Array(e);
1422
+ const e = s.reduce((i, r) => i + r.byteLength, 0), t = new Uint8Array(e);
1423
1423
  let n = 0;
1424
1424
  for (const i of s)
1425
1425
  t.set(new Uint8Array(i), n), n += i.byteLength;
@@ -1439,17 +1439,17 @@ const Kt = 20;
1439
1439
  class At {
1440
1440
  constructor(e) {
1441
1441
  // Live ECDH mode state
1442
- r(this, "kp");
1443
- r(this, "shared");
1442
+ a(this, "kp");
1443
+ a(this, "shared");
1444
1444
  // X3DH async mode state
1445
- r(this, "identityKP");
1446
- r(this, "signedPreKP");
1447
- r(this, "signedPrekeyId");
1448
- r(this, "otpKeys", []);
1445
+ a(this, "identityKP");
1446
+ a(this, "signedPreKP");
1447
+ a(this, "signedPrekeyId");
1448
+ a(this, "otpKeys", []);
1449
1449
  // one-time prekeys awaiting matching
1450
- r(this, "x3dhShared");
1450
+ a(this, "x3dhShared");
1451
1451
  // Queued init messages arriving before we could derive (shouldn't happen, but safe)
1452
- r(this, "pendingX3DH");
1452
+ a(this, "pendingX3DH");
1453
1453
  this.storageKey = e;
1454
1454
  }
1455
1455
  get ready() {
@@ -1457,7 +1457,7 @@ class At {
1457
1457
  }
1458
1458
  /** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
1459
1459
  async begin() {
1460
- return this.kp = await Et(this.storageKey), R(this.kp.publicKey);
1460
+ return this.kp = await Et(this.storageKey), _(this.kp.publicKey);
1461
1461
  }
1462
1462
  /** Live ECDH mode: A peer published their key — derive the shared secret. */
1463
1463
  async onPeerKey(e) {
@@ -1467,9 +1467,9 @@ class At {
1467
1467
  /** X3DH: Generate identity key, signed prekey, and OTP prekeys.
1468
1468
  * Returns the upload frame payload the caller should send to the server. */
1469
1469
  async initX3DH() {
1470
- this.identityKP = await we(this.storageKey), this.signedPreKP = await V(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1471
- for (let i = 0; i < Kt; i++) this.otpKeys.push(await V());
1472
- const e = await R(this.signedPreKP.publicKey), t = await Tt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => R(i.publicKey)));
1470
+ this.identityKP = await we(this.storageKey), this.signedPreKP = await N(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1471
+ for (let i = 0; i < Kt; i++) this.otpKeys.push(await N());
1472
+ const e = await _(this.signedPreKP.publicKey), t = await Tt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => _(i.publicKey)));
1473
1473
  return {
1474
1474
  identityKey: this.identityKP.publicKeyB64,
1475
1475
  signedPrekey: e,
@@ -1505,12 +1505,12 @@ class At {
1505
1505
  async sealText(e, t) {
1506
1506
  const n = this.x3dhShared ?? this.shared;
1507
1507
  if (!n) throw new Error("secure channel not ready");
1508
- const { ct: i, iv: o } = await It(n, e);
1508
+ const { ct: i, iv: r } = await It(n, e);
1509
1509
  return {
1510
1510
  kind: "text",
1511
1511
  text: i,
1512
1512
  enc: !0,
1513
- iv: o,
1513
+ iv: r,
1514
1514
  ...t ? { x3dhEK: t.ephemeralKey, x3dhSPK: t.spkId, x3dhIK: t.senderIK } : {}
1515
1515
  };
1516
1516
  }
@@ -1701,7 +1701,7 @@ function Dt() {
1701
1701
  const s = document.createElement("style");
1702
1702
  s.id = xe, s.textContent = Mt, document.head.appendChild(s);
1703
1703
  }
1704
- function a(s, e, t) {
1704
+ function c(s, e, t) {
1705
1705
  const n = document.createElement(s);
1706
1706
  return e && (n.className = e), t !== void 0 && (n.textContent = t), n;
1707
1707
  }
@@ -1732,86 +1732,86 @@ function ee(s) {
1732
1732
  class $t {
1733
1733
  /** Last seq the guest has seen per conversationId — used to compute unread badges. */
1734
1734
  constructor(e, t, n, i = {}) {
1735
- r(this, "scroll");
1736
- r(this, "chips");
1737
- r(this, "typing");
1738
- r(this, "quick");
1739
- r(this, "formHost");
1740
- r(this, "csatPanel");
1741
- r(this, "offlinePanel");
1742
- r(this, "footer");
1743
- r(this, "input");
1744
- r(this, "subjectCard");
1745
- r(this, "e2eBadge");
1746
- r(this, "statusBadge");
1747
- r(this, "headerName");
1748
- r(this, "connStatus");
1749
- r(this, "typingTimer", null);
1750
- r(this, "csatSubmitted", !1);
1735
+ a(this, "scroll");
1736
+ a(this, "chips");
1737
+ a(this, "typing");
1738
+ a(this, "quick");
1739
+ a(this, "formHost");
1740
+ a(this, "csatPanel");
1741
+ a(this, "offlinePanel");
1742
+ a(this, "footer");
1743
+ a(this, "input");
1744
+ a(this, "subjectCard");
1745
+ a(this, "e2eBadge");
1746
+ a(this, "statusBadge");
1747
+ a(this, "headerName");
1748
+ a(this, "connStatus");
1749
+ a(this, "typingTimer", null);
1750
+ a(this, "csatSubmitted", !1);
1751
1751
  // ── Co-browsing (shared whiteboard) ─────────────────────────────────────
1752
- r(this, "cobrowseBtn");
1753
- r(this, "cobrowseCanvas");
1754
- r(this, "cobrowseToolbar");
1755
- r(this, "cobrowseHint");
1756
- r(this, "cobrowseActive", !1);
1757
- r(this, "cobrowseColor", "#f5713c");
1758
- r(this, "lastAnnotationVersion", -1);
1759
- r(this, "storeRef", null);
1760
- r(this, "scrollCleanup", null);
1752
+ a(this, "cobrowseBtn");
1753
+ a(this, "cobrowseCanvas");
1754
+ a(this, "cobrowseToolbar");
1755
+ a(this, "cobrowseHint");
1756
+ a(this, "cobrowseActive", !1);
1757
+ a(this, "cobrowseColor", "#f5713c");
1758
+ a(this, "lastAnnotationVersion", -1);
1759
+ a(this, "storeRef", null);
1760
+ a(this, "scrollCleanup", null);
1761
1761
  // ── Live translation ──────────────────────────────────────────────────-
1762
- r(this, "translationCache", /* @__PURE__ */ new Map());
1763
- r(this, "showingTranslation", /* @__PURE__ */ new Set());
1764
- r(this, "subjectBuilt", !1);
1765
- var v, m, g, I, K, U, P, E, M;
1762
+ a(this, "translationCache", /* @__PURE__ */ new Map());
1763
+ a(this, "showingTranslation", /* @__PURE__ */ new Set());
1764
+ a(this, "subjectBuilt", !1);
1765
+ var v, g, U, b, I, K, P, E, M;
1766
1766
  this.root = e, this.me = t, this.h = n, this.cfg = i, Dt(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
1767
- const o = a("div", "ocw-head"), c = a("div", "ocw-avatar");
1767
+ const r = c("div", "ocw-head"), o = c("div", "ocw-avatar");
1768
1768
  if ((v = i.userInfo) != null && v.avatar) {
1769
1769
  const k = document.createElement("img");
1770
- k.src = i.userInfo.avatar, k.alt = i.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", c.append(k);
1770
+ k.src = i.userInfo.avatar, k.alt = i.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", o.append(k);
1771
1771
  } else
1772
- c.textContent = (m = i.userInfo) != null && m.name ? i.userInfo.name[0].toUpperCase() : "🧑";
1773
- o.append(c);
1774
- const l = a("div", "ocw-head-main");
1775
- this.headerName = a("div", "ocw-head-name", ((g = i.subject) == null ? void 0 : g.ownerLabel) ?? ((I = i.subject) == null ? void 0 : I.title) ?? ""), l.append(this.headerName), (K = i.subject) != null && K.subtitle && l.append(a("div", "ocw-head-meta", i.subject.subtitle)), o.append(l), this.statusBadge = a("span", "ocw-badge", ((U = i.subject) == null ? void 0 : U.status) ?? ""), (P = i.subject) != null && P.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = a("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = a("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.append(this.connStatus), this.cobrowseBtn = a("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
1772
+ o.textContent = (g = i.userInfo) != null && g.name ? i.userInfo.name[0].toUpperCase() : "🧑";
1773
+ r.append(o);
1774
+ const l = c("div", "ocw-head-main");
1775
+ this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((b = i.subject) == null ? void 0 : b.title) ?? ""), l.append(this.headerName), (I = i.subject) != null && I.subtitle && l.append(c("div", "ocw-head-meta", i.subject.subtitle)), r.append(l), this.statusBadge = c("span", "ocw-badge", ((K = i.subject) == null ? void 0 : K.status) ?? ""), (P = i.subject) != null && P.status || (this.statusBadge.style.display = "none"), r.append(this.statusBadge), this.e2eBadge = c("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", r.append(this.e2eBadge), this.connStatus = c("span", "ocw-conn-status"), this.connStatus.style.display = "none", r.append(this.connStatus), this.cobrowseBtn = c("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
1776
1776
  this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
1777
- }), o.append(this.cobrowseBtn), o.append(a("button", "ocw-menu", "⋯")), this.chips = a("div", "ocw-chiprow"), this.scroll = a("div", "ocw-scroll"), this.subjectCard = a("div", "ocw-subject"), this.typing = a("div", "ocw-typing");
1778
- const w = a("div", "ocw-typing-bubble");
1779
- w.append(a("div", "ocw-typing-dot"), a("div", "ocw-typing-dot"), a("div", "ocw-typing-dot")), this.typing.append(a("div", "ocw-dot", "🧑"), w), this.quick = a("div", "ocw-quick");
1777
+ }), r.append(this.cobrowseBtn), r.append(c("button", "ocw-menu", "⋯")), this.chips = c("div", "ocw-chiprow"), this.scroll = c("div", "ocw-scroll"), this.subjectCard = c("div", "ocw-subject"), this.typing = c("div", "ocw-typing");
1778
+ const w = c("div", "ocw-typing-bubble");
1779
+ w.append(c("div", "ocw-typing-dot"), c("div", "ocw-typing-dot"), c("div", "ocw-typing-dot")), this.typing.append(c("div", "ocw-dot", "🧑"), w), this.quick = c("div", "ocw-quick");
1780
1780
  for (const k of i.quickReplies ?? []) {
1781
- const A = a("button", void 0, k);
1781
+ const A = c("button", void 0, k);
1782
1782
  A.addEventListener("click", () => {
1783
1783
  this.h.onSend(k), this.quick.style.display = "none";
1784
1784
  }), this.quick.append(A);
1785
1785
  }
1786
- this.formHost = a("div", "ocw-form-host"), this.csatPanel = a("div", "ocw-csat"), this.csatPanel.style.display = "none", this.offlinePanel = a("div", "ocw-offline"), this.offlinePanel.style.display = "none", this.input = a("textarea", void 0), this.input.rows = 1, this.input.placeholder = "Message…";
1787
- const f = a("button", "ocw-sendbtn", ((E = i.i18n) == null ? void 0 : E.send) ?? "➤");
1788
- f.addEventListener("click", () => this.flushSend()), this.input.addEventListener("keydown", (k) => {
1786
+ this.formHost = c("div", "ocw-form-host"), this.csatPanel = c("div", "ocw-csat"), this.csatPanel.style.display = "none", this.offlinePanel = c("div", "ocw-offline"), this.offlinePanel.style.display = "none", this.input = c("textarea", void 0), this.input.rows = 1, this.input.placeholder = "Message…";
1787
+ const x = c("button", "ocw-sendbtn", ((E = i.i18n) == null ? void 0 : E.send) ?? "➤");
1788
+ x.addEventListener("click", () => this.flushSend()), this.input.addEventListener("keydown", (k) => {
1789
1789
  k.isComposing || k.keyCode === 229 || (k.key === "Enter" && !k.shiftKey ? (k.preventDefault(), this.flushSend()) : this.signalTyping());
1790
1790
  });
1791
- const b = a("button", "ocw-attach", "📎");
1792
- b.title = "Attach image or file";
1793
- const x = document.createElement("input");
1794
- x.type = "file", x.accept = "image/*,.pdf,.txt,.doc,.docx", x.style.display = "none", b.addEventListener("click", () => x.click()), x.addEventListener("change", () => {
1791
+ const m = c("button", "ocw-attach", "📎");
1792
+ m.title = "Attach image or file";
1793
+ const f = document.createElement("input");
1794
+ f.type = "file", f.accept = "image/*,.pdf,.txt,.doc,.docx", f.style.display = "none", m.addEventListener("click", () => f.click()), f.addEventListener("change", () => {
1795
1795
  var k;
1796
- (k = x.files) != null && k[0] && this.h.onAttach && this.h.onAttach(x.files[0]), x.value = "";
1796
+ (k = f.files) != null && k[0] && this.h.onAttach && this.h.onAttach(f.files[0]), f.value = "";
1797
1797
  });
1798
- const h = a("div", "ocw-input");
1799
- h.append(b, x, this.input, f);
1800
- const u = a("div", "ocw-footer");
1801
- ((M = i.i18n) == null ? void 0 : M.poweredBy) !== void 0 ? u.textContent = i.i18n.poweredBy : u.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = u, e.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, h, this.footer), this.cobrowseCanvas = a("canvas", "ocw-cobrowse-canvas"), this.cobrowseToolbar = a("div", "ocw-cobrowse-toolbar");
1798
+ const u = c("div", "ocw-input");
1799
+ u.append(m, f, this.input, x);
1800
+ const h = c("div", "ocw-footer");
1801
+ ((M = i.i18n) == null ? void 0 : M.poweredBy) !== void 0 ? h.textContent = i.i18n.poweredBy : h.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = h, e.append(r, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, u, this.footer), this.cobrowseCanvas = c("canvas", "ocw-cobrowse-canvas"), this.cobrowseToolbar = c("div", "ocw-cobrowse-toolbar");
1802
1802
  for (const k of ["#f5713c", "#1c1b1a", "#2563eb", "#16a34a", "#dc2626"]) {
1803
- const A = a("button", "ocw-cobrowse-swatch");
1803
+ const A = c("button", "ocw-cobrowse-swatch");
1804
1804
  A.style.background = k, A.type = "button", k === this.cobrowseColor && A.classList.add("sel"), A.addEventListener("click", () => {
1805
1805
  this.cobrowseColor = k;
1806
1806
  for (const Q of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) Q.classList.remove("sel");
1807
1807
  A.classList.add("sel");
1808
1808
  }), this.cobrowseToolbar.append(A);
1809
1809
  }
1810
- const T = a("button", "ocw-cobrowse-clear", "Clear");
1810
+ const T = c("button", "ocw-cobrowse-clear", "Clear");
1811
1811
  T.addEventListener("click", () => {
1812
1812
  var k, A;
1813
1813
  return (A = (k = this.h).onAnnotateClear) == null ? void 0 : A.call(k);
1814
- }), this.cobrowseToolbar.append(T), this.cobrowseHint = a("div", "ocw-cobrowse-hint", "🖍 Draw to point things out — visible to both sides"), e.append(this.cobrowseCanvas, this.cobrowseToolbar, this.cobrowseHint), this.bindCobrowsePointerEvents();
1814
+ }), this.cobrowseToolbar.append(T), this.cobrowseHint = c("div", "ocw-cobrowse-hint", "🖍 Draw to point things out — visible to both sides"), e.append(this.cobrowseCanvas, this.cobrowseToolbar, this.cobrowseHint), this.bindCobrowsePointerEvents();
1815
1815
  }
1816
1816
  /** Returns the scroll container so history.ts can attach scroll listeners. */
1817
1817
  getScrollEl() {
@@ -1841,28 +1841,28 @@ class $t {
1841
1841
  this.h.onTyping(!0, e), this.typingTimer && clearTimeout(this.typingTimer), this.typingTimer = setTimeout(() => this.h.onTyping(!1), 2e3);
1842
1842
  }
1843
1843
  render(e) {
1844
- var f, b, x;
1844
+ var x, m, f;
1845
1845
  if (this.storeRef = e, this.cobrowseBtn.classList.toggle("show", !!e.subject), !e.subject && this.cobrowseActive && (this.cobrowseActive = !1, this.updateCobrowseUI()), this.cobrowseActive && e.annotationVersion !== this.lastAnnotationVersion && (this.lastAnnotationVersion = e.annotationVersion, this.resizeCobrowseCanvas(), this.redrawCobrowse()), e.accent && this.root.style.setProperty("--ocw-accent", e.accent), this.e2eBadge.style.display = e.e2e ? "inline-flex" : "none", this.buildSubjectCard(e), e.subject) {
1846
- const h = (f = this.cfg.subject) == null ? void 0 : f.ownerLabel;
1847
- h && (this.headerName.textContent = h);
1846
+ const u = (x = this.cfg.subject) == null ? void 0 : x.ownerLabel;
1847
+ u && (this.headerName.textContent = u);
1848
1848
  }
1849
1849
  this.chips.replaceChildren();
1850
1850
  const t = e.visibleActions();
1851
1851
  this.chips.style.display = t.length ? "flex" : "none";
1852
- for (const h of t) this.chips.append(this.chipEl(h));
1852
+ for (const u of t) this.chips.append(this.chipEl(u));
1853
1853
  const n = this.scroll.scrollHeight, i = this.scroll.scrollTop;
1854
1854
  if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
1855
- const h = a("div", "ocw-load-more");
1856
- h.textContent = "↑ Loading earlier messages…", h.style.pointerEvents = "none", this.scroll.append(h);
1855
+ const u = c("div", "ocw-load-more");
1856
+ u.textContent = "↑ Loading earlier messages…", u.style.pointerEvents = "none", this.scroll.append(u);
1857
1857
  }
1858
- let o = 0;
1859
- for (const h of e.messages())
1860
- this.scroll.append(this.messageEl(h, e)), h.senderId !== this.me && h.seq > o && (o = h.seq);
1861
- i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - n + i : this.scroll.scrollTop = this.scroll.scrollHeight, o > 0 && this.h.onReadUpTo(o);
1862
- const c = [...e.typing];
1863
- this.typing.classList.toggle("active", c.length > 0);
1858
+ let r = 0;
1859
+ for (const u of e.messages())
1860
+ this.scroll.append(this.messageEl(u, e)), u.senderId !== this.me && u.seq > r && (r = u.seq);
1861
+ i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - n + i : this.scroll.scrollTop = this.scroll.scrollHeight, r > 0 && this.h.onReadUpTo(r);
1862
+ const o = [...e.typing];
1863
+ this.typing.classList.toggle("active", o.length > 0);
1864
1864
  const l = this.typing.querySelector(".ocw-typing-bubble");
1865
- l && l.setAttribute("aria-label", c.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block", e.offline ? (this.offlinePanel.style.display === "none" && this.buildOfflinePanel(e.offlineMessage), this.offlinePanel.style.display = "block", (b = this.root.querySelector(".ocw-input")) == null || b.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (x = this.root.querySelector(".ocw-input")) == null || x.style.removeProperty("display"));
1865
+ l && l.setAttribute("aria-label", o.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block", e.offline ? (this.offlinePanel.style.display === "none" && this.buildOfflinePanel(e.offlineMessage), this.offlinePanel.style.display = "block", (m = this.root.querySelector(".ocw-input")) == null || m.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (f = this.root.querySelector(".ocw-input")) == null || f.style.removeProperty("display"));
1866
1866
  const w = ["resolved", "closed", "sold", "issued", "checked_out"];
1867
1867
  this.h.onCsat && !this.csatSubmitted && w.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
1868
1868
  }
@@ -1875,29 +1875,29 @@ class $t {
1875
1875
  }
1876
1876
  buildOfflinePanel(e) {
1877
1877
  var l;
1878
- this.offlinePanel.replaceChildren(), this.offlinePanel.append(a("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(a("div", "ocw-offline-title", ((l = this.cfg.i18n) == null ? void 0 : l.offline) ?? "We're offline right now")), this.offlinePanel.append(a("div", "ocw-offline-msg", e || "Leave your details and we'll get back to you soon."));
1879
- const t = a("div", "ocw-offline-form"), n = a("input", "ocw-offline-input");
1878
+ this.offlinePanel.replaceChildren(), this.offlinePanel.append(c("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(c("div", "ocw-offline-title", ((l = this.cfg.i18n) == null ? void 0 : l.offline) ?? "We're offline right now")), this.offlinePanel.append(c("div", "ocw-offline-msg", e || "Leave your details and we'll get back to you soon."));
1879
+ const t = c("div", "ocw-offline-form"), n = c("input", "ocw-offline-input");
1880
1880
  n.placeholder = "Your name", n.type = "text";
1881
- const i = a("input", "ocw-offline-input");
1881
+ const i = c("input", "ocw-offline-input");
1882
1882
  i.placeholder = "Your email", i.type = "email";
1883
- const o = a("textarea", "ocw-offline-input");
1884
- o.placeholder = "Your message", o.rows = 3;
1885
- const c = a("button", "ocw-offline-submit", "Send message");
1886
- c.addEventListener("click", () => {
1887
- !i.value.trim() || !o.value.trim() || (this.h.onSend(`[Offline form]
1883
+ const r = c("textarea", "ocw-offline-input");
1884
+ r.placeholder = "Your message", r.rows = 3;
1885
+ const o = c("button", "ocw-offline-submit", "Send message");
1886
+ o.addEventListener("click", () => {
1887
+ !i.value.trim() || !r.value.trim() || (this.h.onSend(`[Offline form]
1888
1888
  Name: ${n.value || "Anonymous"}
1889
1889
  Email: ${i.value}
1890
- Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-thanks", "✓ Message sent! We'll reply to your email.")));
1891
- }), t.append(n, i, o, c), this.offlinePanel.append(t);
1890
+ Message: ${r.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-thanks", "✓ Message sent! We'll reply to your email.")));
1891
+ }), t.append(n, i, r, o), this.offlinePanel.append(t);
1892
1892
  }
1893
1893
  buildCsatPanel() {
1894
- this.csatPanel.replaceChildren(), this.csatPanel.append(a("div", "ocw-csat-title", "How did we do?"));
1895
- const e = a("div", "ocw-csat-stars"), t = [];
1894
+ this.csatPanel.replaceChildren(), this.csatPanel.append(c("div", "ocw-csat-title", "How did we do?"));
1895
+ const e = c("div", "ocw-csat-stars"), t = [];
1896
1896
  for (let n = 1; n <= 5; n++) {
1897
- const i = a("button", "ocw-csat-star", "★");
1898
- i.dataset.score = String(n), i.addEventListener("mouseenter", () => t.forEach((o, c) => o.classList.toggle("lit", c < n))), i.addEventListener("mouseleave", () => t.forEach((o) => o.classList.remove("lit"))), i.addEventListener("click", () => {
1899
- var o, c;
1900
- this.csatSubmitted = !0, this.csatPanel.replaceChildren(a("div", "ocw-csat-done", `Thanks for your ${n}★ rating!`)), (c = (o = this.h).onCsat) == null || c.call(o, n);
1897
+ const i = c("button", "ocw-csat-star", "★");
1898
+ i.dataset.score = String(n), i.addEventListener("mouseenter", () => t.forEach((r, o) => r.classList.toggle("lit", o < n))), i.addEventListener("mouseleave", () => t.forEach((r) => r.classList.remove("lit"))), i.addEventListener("click", () => {
1899
+ var r, o;
1900
+ this.csatSubmitted = !0, this.csatPanel.replaceChildren(c("div", "ocw-csat-done", `Thanks for your ${n}★ rating!`)), (o = (r = this.h).onCsat) == null || o.call(r, n);
1901
1901
  }), t.push(i), e.append(i);
1902
1902
  }
1903
1903
  this.csatPanel.append(e);
@@ -1918,7 +1918,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
1918
1918
  if (!t || e.points.length < 2) return;
1919
1919
  const n = this.cobrowseCanvas.width, i = this.cobrowseCanvas.height;
1920
1920
  t.strokeStyle = e.color, t.lineWidth = Math.max(1, e.width * Math.min(n, i)), t.lineJoin = "round", t.lineCap = "round", t.beginPath(), t.moveTo(e.points[0].x * n, e.points[0].y * i);
1921
- for (const o of e.points.slice(1)) t.lineTo(o.x * n, o.y * i);
1921
+ for (const r of e.points.slice(1)) t.lineTo(r.x * n, r.y * i);
1922
1922
  t.stroke();
1923
1923
  }
1924
1924
  redrawCobrowse() {
@@ -1931,41 +1931,41 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
1931
1931
  }
1932
1932
  bindCobrowsePointerEvents() {
1933
1933
  let e = !1, t = [];
1934
- const n = (c) => {
1935
- const l = this.cobrowseCanvas.getBoundingClientRect(), w = l.width > 0 ? (c.clientX - l.left) / l.width : 0, f = l.height > 0 ? (c.clientY - l.top) / l.height : 0;
1936
- return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0, f)) };
1934
+ const n = (o) => {
1935
+ const l = this.cobrowseCanvas.getBoundingClientRect(), w = l.width > 0 ? (o.clientX - l.left) / l.width : 0, x = l.height > 0 ? (o.clientY - l.top) / l.height : 0;
1936
+ return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0, x)) };
1937
1937
  }, i = 6e-3;
1938
- this.cobrowseCanvas.addEventListener("pointerdown", (c) => {
1939
- this.cobrowseActive && (e = !0, t = [n(c)], this.cobrowseCanvas.setPointerCapture(c.pointerId));
1940
- }), this.cobrowseCanvas.addEventListener("pointermove", (c) => {
1941
- e && (t.push(n(c)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: i }));
1938
+ this.cobrowseCanvas.addEventListener("pointerdown", (o) => {
1939
+ this.cobrowseActive && (e = !0, t = [n(o)], this.cobrowseCanvas.setPointerCapture(o.pointerId));
1940
+ }), this.cobrowseCanvas.addEventListener("pointermove", (o) => {
1941
+ e && (t.push(n(o)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: i }));
1942
1942
  });
1943
- const o = (c) => {
1943
+ const r = (o) => {
1944
1944
  var l, w;
1945
1945
  if (e) {
1946
1946
  e = !1, t.length > 1 && ((w = (l = this.h).onAnnotate) == null || w.call(l, { id: `an_${Date.now()}_${Math.random().toString(36).slice(2)}`, points: t, color: this.cobrowseColor, width: i })), t = [];
1947
1947
  try {
1948
- this.cobrowseCanvas.releasePointerCapture(c.pointerId);
1948
+ this.cobrowseCanvas.releasePointerCapture(o.pointerId);
1949
1949
  } catch {
1950
1950
  }
1951
1951
  }
1952
1952
  };
1953
- this.cobrowseCanvas.addEventListener("pointerup", o), this.cobrowseCanvas.addEventListener("pointercancel", o);
1953
+ this.cobrowseCanvas.addEventListener("pointerup", r), this.cobrowseCanvas.addEventListener("pointercancel", r);
1954
1954
  }
1955
1955
  buildSubjectCard(e) {
1956
1956
  if (this.subjectBuilt) return;
1957
1957
  const t = e.subject, n = this.cfg.subject, i = (t == null ? void 0 : t.title) ?? (n == null ? void 0 : n.title);
1958
1958
  if (!i) return;
1959
- this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(a("div", "ocw-subject-title", i)), n != null && n.subtitle && this.subjectCard.append(a("div", "ocw-subject-sub", n.subtitle));
1960
- const o = a("div", "ocw-tags");
1961
- if (t) for (const [l, w] of Object.entries(t.fields)) o.append(a("span", "ocw-tag", `${l}: ${w}`));
1962
- else for (const l of (n == null ? void 0 : n.tags) ?? []) o.append(a("span", "ocw-tag", l));
1963
- o.childNodes.length && this.subjectCard.append(o);
1964
- const c = (t == null ? void 0 : t.state) ?? (n == null ? void 0 : n.status);
1965
- c && (this.statusBadge.textContent = c, this.statusBadge.style.display = "inline-flex");
1959
+ this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(c("div", "ocw-subject-title", i)), n != null && n.subtitle && this.subjectCard.append(c("div", "ocw-subject-sub", n.subtitle));
1960
+ const r = c("div", "ocw-tags");
1961
+ if (t) for (const [l, w] of Object.entries(t.fields)) r.append(c("span", "ocw-tag", `${l}: ${w}`));
1962
+ else for (const l of (n == null ? void 0 : n.tags) ?? []) r.append(c("span", "ocw-tag", l));
1963
+ r.childNodes.length && this.subjectCard.append(r);
1964
+ const o = (t == null ? void 0 : t.state) ?? (n == null ? void 0 : n.status);
1965
+ o && (this.statusBadge.textContent = o, this.statusBadge.style.display = "inline-flex");
1966
1966
  }
1967
1967
  chipEl(e) {
1968
- const t = a("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
1968
+ const t = c("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
1969
1969
  return t.dataset.actionId = e.id, t.addEventListener("click", async () => {
1970
1970
  var n;
1971
1971
  e.confirm && !await this.confirm(e.label) || ((n = e.input) != null && n.length ? this.openForm(e) : this.h.onInvoke(e.id));
@@ -1974,14 +1974,14 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
1974
1974
  /** In-widget confirmation modal (replaces window.confirm). */
1975
1975
  confirm(e) {
1976
1976
  return new Promise((t) => {
1977
- const n = a("div", "ocw-modal"), i = a("div", "ocw-modal-card");
1978
- i.append(a("div", "ocw-modal-title", e)), i.append(a("div", "ocw-modal-body", `Confirm “${e}”?`));
1979
- const o = a("div", "ocw-modal-actions"), c = a("button", "ocw-modal-cancel", "Cancel"), l = a("button", "ocw-modal-ok", "Confirm"), w = (f) => {
1980
- n.remove(), t(f);
1977
+ const n = c("div", "ocw-modal"), i = c("div", "ocw-modal-card");
1978
+ i.append(c("div", "ocw-modal-title", e)), i.append(c("div", "ocw-modal-body", `Confirm “${e}”?`));
1979
+ const r = c("div", "ocw-modal-actions"), o = c("button", "ocw-modal-cancel", "Cancel"), l = c("button", "ocw-modal-ok", "Confirm"), w = (x) => {
1980
+ n.remove(), t(x);
1981
1981
  };
1982
- c.addEventListener("click", () => w(!1)), l.addEventListener("click", () => w(!0)), n.addEventListener("click", (f) => {
1983
- f.target === n && w(!1);
1984
- }), o.append(c, l), i.append(o), n.append(i), this.root.append(n), l.focus();
1982
+ o.addEventListener("click", () => w(!1)), l.addEventListener("click", () => w(!0)), n.addEventListener("click", (x) => {
1983
+ x.target === n && w(!1);
1984
+ }), r.append(o, l), i.append(r), n.append(i), this.root.append(n), l.focus();
1985
1985
  });
1986
1986
  }
1987
1987
  /** Inline form for a form-effect action: typed inputs (date picker, number,
@@ -1989,163 +1989,163 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
1989
1989
  openForm(e) {
1990
1990
  var l, w;
1991
1991
  this.formHost.replaceChildren();
1992
- const t = a("div", "ocw-form");
1993
- t.append(a("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
1992
+ const t = c("div", "ocw-form");
1993
+ t.append(c("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
1994
1994
  const n = /* @__PURE__ */ new Map();
1995
- for (const f of e.input ?? []) {
1996
- const b = a("label", "ocw-form-row");
1997
- if (b.append(a("span", "ocw-form-lbl", f.label)), f.type === "select" && ((l = f.options) != null && l.length)) {
1998
- const x = a("select", "ocw-form-input");
1999
- f.required || x.append(a("option", void 0, "— select —"));
2000
- for (const h of f.options) {
2001
- const u = a("option");
2002
- u.value = h, u.textContent = h, x.append(u);
1995
+ for (const x of e.input ?? []) {
1996
+ const m = c("label", "ocw-form-row");
1997
+ if (m.append(c("span", "ocw-form-lbl", x.label)), x.type === "select" && ((l = x.options) != null && l.length)) {
1998
+ const f = c("select", "ocw-form-input");
1999
+ x.required || f.append(c("option", void 0, "— select —"));
2000
+ for (const u of x.options) {
2001
+ const h = c("option");
2002
+ h.value = u, h.textContent = u, f.append(h);
2003
2003
  }
2004
- f.required && (x.required = !0), b.append(x), n.set(f.name, x);
2004
+ x.required && (f.required = !0), m.append(f), n.set(x.name, f);
2005
2005
  } else {
2006
- const x = a("input", "ocw-form-input");
2007
- x.type = f.type === "number" ? "number" : f.type === "date" ? "datetime-local" : "text", f.required && (x.required = !0), b.append(x), n.set(f.name, x);
2006
+ const f = c("input", "ocw-form-input");
2007
+ f.type = x.type === "number" ? "number" : x.type === "date" ? "datetime-local" : "text", x.required && (f.required = !0), m.append(f), n.set(x.name, f);
2008
2008
  }
2009
- t.append(b);
2009
+ t.append(m);
2010
2010
  }
2011
- const i = a("div", "ocw-form-actions"), o = a("button", "ocw-form-cancel", "Cancel"), c = a("button", "ocw-form-submit", "Send");
2012
- o.addEventListener("click", () => this.formHost.replaceChildren()), c.addEventListener("click", () => {
2013
- const f = {};
2014
- for (const [b, x] of n) {
2015
- if (x.required && !x.value) {
2016
- x.style.borderColor = "#e5484d";
2011
+ const i = c("div", "ocw-form-actions"), r = c("button", "ocw-form-cancel", "Cancel"), o = c("button", "ocw-form-submit", "Send");
2012
+ r.addEventListener("click", () => this.formHost.replaceChildren()), o.addEventListener("click", () => {
2013
+ const x = {};
2014
+ for (const [m, f] of n) {
2015
+ if (f.required && !f.value) {
2016
+ f.style.borderColor = "#e5484d";
2017
2017
  return;
2018
2018
  }
2019
- f[b] = x.type === "number" ? Number(x.value) : x.value;
2019
+ x[m] = f.type === "number" ? Number(f.value) : f.value;
2020
2020
  }
2021
- this.formHost.replaceChildren(), this.h.onInvoke(e.id, f);
2022
- }), i.append(o, c), t.append(i), this.formHost.append(t), (w = n.values().next().value) == null || w.focus();
2021
+ this.formHost.replaceChildren(), this.h.onInvoke(e.id, x);
2022
+ }), i.append(r, o), t.append(i), this.formHost.append(t), (w = n.values().next().value) == null || w.focus();
2023
2023
  }
2024
2024
  messageEl(e, t) {
2025
- var x;
2025
+ var f;
2026
2026
  if (e.senderRole === "system") {
2027
- const h = a("div", "ocw-sys");
2028
- return h.textContent = e.deletedAt ? "message deleted" : ee(e.content), h;
2027
+ const u = c("div", "ocw-sys");
2028
+ return u.textContent = e.deletedAt ? "message deleted" : ee(e.content), u;
2029
2029
  }
2030
- const n = e.senderId === this.me, i = !!e.internal, o = a("div", `ocw-row ${i ? "ocw-note mine" : n ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
2031
- !n && !i && o.append(a("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
2032
- const c = a("div"), l = a("div", "ocw-bubble-wrap");
2030
+ const n = e.senderId === this.me, i = !!e.internal, r = c("div", `ocw-row ${i ? "ocw-note mine" : n ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
2031
+ !n && !i && r.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
2032
+ const o = c("div"), l = c("div", "ocw-bubble-wrap");
2033
2033
  if (e.replyToId) {
2034
- const h = a("div", "ocw-reply-to", "↩ replying to a message");
2035
- h.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", c.append(h);
2034
+ const u = c("div", "ocw-reply-to", "↩ replying to a message");
2035
+ u.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", o.append(u);
2036
2036
  }
2037
- const w = a("div", "ocw-bubble");
2038
- let f = null;
2039
- if (e.deletedAt) w.append(a("span", "ocw-deleted", "message deleted"));
2037
+ const w = c("div", "ocw-bubble");
2038
+ let x = null;
2039
+ if (e.deletedAt) w.append(c("span", "ocw-deleted", "message deleted"));
2040
2040
  else if (e.content.kind === "attachment") {
2041
- const h = e.content;
2042
- if ((x = h.mime) != null && x.startsWith("image/")) {
2043
- const u = document.createElement("img");
2044
- u.src = h.url, u.alt = h.name ?? "image", u.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", u.addEventListener("click", () => window.open(h.url, "_blank")), w.append(u);
2041
+ const u = e.content;
2042
+ if ((f = u.mime) != null && f.startsWith("image/")) {
2043
+ const h = document.createElement("img");
2044
+ h.src = u.url, h.alt = u.name ?? "image", h.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", h.addEventListener("click", () => window.open(u.url, "_blank")), w.append(h);
2045
2045
  } else {
2046
- const u = document.createElement("a");
2047
- u.href = h.url, u.target = "_blank", u.rel = "noopener", u.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", u.append(a("span", void 0, "📄"), a("span", void 0, h.name ?? "file")), w.append(u);
2046
+ const h = document.createElement("a");
2047
+ h.href = u.url, h.target = "_blank", h.rel = "noopener", h.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", h.append(c("span", void 0, "📄"), c("span", void 0, u.name ?? "file")), w.append(h);
2048
2048
  }
2049
2049
  } else if (e.content.kind === "appointment") {
2050
- const h = e.content, u = a("div", "ocw-appt");
2051
- u.append(a("div", "ocw-appt-title", `📅 ${h.title}`)), u.append(a("div", "ocw-appt-time", new Date(h.startIso).toLocaleString() + " – " + new Date(h.endIso).toLocaleTimeString())), h.location && u.append(a("div", "ocw-appt-loc", `📍 ${h.location}`)), h.description && u.append(a("div", "ocw-appt-desc", h.description));
2052
- const T = a("div", "ocw-appt-links"), v = document.createElement("a");
2053
- v.href = h.googleUrl, v.target = "_blank", v.rel = "noopener", v.className = "ocw-appt-btn", v.textContent = "📅 Add to Google Calendar";
2054
- const m = document.createElement("a");
2055
- m.href = h.icalUrl, m.download = `${h.title}.ics`, m.className = "ocw-appt-btn ocw-appt-btn-sec", m.textContent = "🍎 Apple / iCal", T.append(v, m), u.append(T), w.append(u);
2050
+ const u = e.content, h = c("div", "ocw-appt");
2051
+ h.append(c("div", "ocw-appt-title", `📅 ${u.title}`)), h.append(c("div", "ocw-appt-time", new Date(u.startIso).toLocaleString() + " – " + new Date(u.endIso).toLocaleTimeString())), u.location && h.append(c("div", "ocw-appt-loc", `📍 ${u.location}`)), u.description && h.append(c("div", "ocw-appt-desc", u.description));
2052
+ const T = c("div", "ocw-appt-links"), v = document.createElement("a");
2053
+ v.href = u.googleUrl, v.target = "_blank", v.rel = "noopener", v.className = "ocw-appt-btn", v.textContent = "📅 Add to Google Calendar";
2054
+ const g = document.createElement("a");
2055
+ g.href = u.icalUrl, g.download = `${u.title}.ics`, g.className = "ocw-appt-btn ocw-appt-btn-sec", g.textContent = "🍎 Apple / iCal", T.append(v, g), h.append(T), w.append(h);
2056
2056
  } else
2057
- f = document.createTextNode(ee(e.content)), w.append(f), e.editedAt && w.append(a("span", "ocw-edited", "(edited)"));
2058
- if (l.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && f) {
2059
- const h = e.content.text;
2060
- if (h.trim()) {
2061
- const u = a("button", "ocw-translate-btn", "🌐");
2062
- u.type = "button", u.title = "Translate", u.addEventListener("click", (T) => {
2057
+ x = document.createTextNode(ee(e.content)), w.append(x), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
2058
+ if (l.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && x) {
2059
+ const u = e.content.text;
2060
+ if (u.trim()) {
2061
+ const h = c("button", "ocw-translate-btn", "🌐");
2062
+ h.type = "button", h.title = "Translate", h.addEventListener("click", (T) => {
2063
2063
  if (T.stopPropagation(), this.showingTranslation.has(e.id)) {
2064
- this.showingTranslation.delete(e.id), f.textContent = h, u.textContent = "🌐", u.title = "Translate";
2064
+ this.showingTranslation.delete(e.id), x.textContent = u, h.textContent = "🌐", h.title = "Translate";
2065
2065
  return;
2066
2066
  }
2067
2067
  const v = this.translationCache.get(e.id);
2068
2068
  if (v !== void 0) {
2069
- this.showingTranslation.add(e.id), f.textContent = v, u.textContent = "↩", u.title = "Show original";
2069
+ this.showingTranslation.add(e.id), x.textContent = v, h.textContent = "↩", h.title = "Show original";
2070
2070
  return;
2071
2071
  }
2072
- u.textContent = "⏳", this.h.onTranslate(h).then((m) => {
2073
- if (m === null) {
2074
- u.textContent = "⚠️", u.title = "Translation unavailable", setTimeout(() => {
2075
- u.textContent = "🌐", u.title = "Translate";
2072
+ h.textContent = "⏳", this.h.onTranslate(u).then((g) => {
2073
+ if (g === null) {
2074
+ h.textContent = "⚠️", h.title = "Translation unavailable", setTimeout(() => {
2075
+ h.textContent = "🌐", h.title = "Translate";
2076
2076
  }, 1500);
2077
2077
  return;
2078
2078
  }
2079
- this.translationCache.set(e.id, m), this.showingTranslation.add(e.id), f.textContent = m, u.textContent = "↩", u.title = "Show original";
2079
+ this.translationCache.set(e.id, g), this.showingTranslation.add(e.id), x.textContent = g, h.textContent = "↩", h.title = "Show original";
2080
2080
  });
2081
- }), l.append(u);
2081
+ }), l.append(h);
2082
2082
  }
2083
2083
  }
2084
2084
  if (n && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
2085
- const h = a("div", "ocw-msg-menu");
2085
+ const u = c("div", "ocw-msg-menu");
2086
2086
  if (this.h.onEdit) {
2087
- const u = a("button", void 0, "✏️");
2088
- u.title = "Edit", u.addEventListener("click", (T) => {
2087
+ const h = c("button", void 0, "✏️");
2088
+ h.title = "Edit", h.addEventListener("click", (T) => {
2089
2089
  T.stopPropagation();
2090
- const v = ee(e.content), m = document.createElement("textarea");
2091
- m.value = v, m.rows = Math.min(4, Math.ceil(v.length / 40) + 1), m.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
2092
- const g = a("button", "ocw-form-submit", "Save");
2093
- g.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
2094
- const I = a("button", "ocw-form-cancel", "Cancel");
2095
- I.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
2096
- const K = a("div");
2097
- K.style.cssText = "display:flex;gap:6px;justify-content:flex-end", K.append(I, g);
2098
- const U = a("div");
2099
- U.append(m, K), w.replaceChildren(U), m.focus(), m.select();
2100
- const P = () => w.replaceChildren(f ?? document.createTextNode(v));
2101
- I.addEventListener("click", P), g.addEventListener("click", () => {
2102
- const E = m.value.trim();
2090
+ const v = ee(e.content), g = document.createElement("textarea");
2091
+ g.value = v, g.rows = Math.min(4, Math.ceil(v.length / 40) + 1), g.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
2092
+ const U = c("button", "ocw-form-submit", "Save");
2093
+ U.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
2094
+ const b = c("button", "ocw-form-cancel", "Cancel");
2095
+ b.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
2096
+ const I = c("div");
2097
+ I.style.cssText = "display:flex;gap:6px;justify-content:flex-end", I.append(b, U);
2098
+ const K = c("div");
2099
+ K.append(g, I), w.replaceChildren(K), g.focus(), g.select();
2100
+ const P = () => w.replaceChildren(x ?? document.createTextNode(v));
2101
+ b.addEventListener("click", P), U.addEventListener("click", () => {
2102
+ const E = g.value.trim();
2103
2103
  E && E !== v && this.h.onEdit(e.id, E), P();
2104
- }), m.addEventListener("keydown", (E) => {
2105
- E.key === "Enter" && !E.shiftKey && (E.preventDefault(), g.click()), E.key === "Escape" && P();
2104
+ }), g.addEventListener("keydown", (E) => {
2105
+ E.key === "Enter" && !E.shiftKey && (E.preventDefault(), U.click()), E.key === "Escape" && P();
2106
2106
  });
2107
- }), h.append(u);
2107
+ }), u.append(h);
2108
2108
  }
2109
2109
  if (this.h.onDelete) {
2110
- const u = a("button", "del", "🗑");
2111
- u.title = "Delete", u.addEventListener("click", (T) => {
2110
+ const h = c("button", "del", "🗑");
2111
+ h.title = "Delete", h.addEventListener("click", (T) => {
2112
2112
  T.stopPropagation(), this.h.onDelete(e.id);
2113
- }), h.append(u);
2113
+ }), u.append(h);
2114
2114
  }
2115
- l.append(h);
2115
+ l.append(u);
2116
2116
  }
2117
- if (c.append(l), this.h.onReact && !e.deletedAt && e.seq > 0) {
2118
- const h = a("div", "ocw-react-wrap"), u = a("div", "ocw-react");
2117
+ if (o.append(l), this.h.onReact && !e.deletedAt && e.seq > 0) {
2118
+ const u = c("div", "ocw-react-wrap"), h = c("div", "ocw-react");
2119
2119
  if (e.reactions && Object.keys(e.reactions).length)
2120
- for (const [m, g] of Object.entries(e.reactions)) {
2121
- const I = a("button", `ocw-react-pill${g.includes(this.me) ? " mine" : ""}`, `${m} ${g.length}`);
2122
- I.addEventListener("click", () => {
2123
- var K, U;
2124
- return (U = (K = this.h).onReact) == null ? void 0 : U.call(K, e.id, m, g.includes(this.me));
2125
- }), u.append(I);
2120
+ for (const [g, U] of Object.entries(e.reactions)) {
2121
+ const b = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${g} ${U.length}`);
2122
+ b.addEventListener("click", () => {
2123
+ var I, K;
2124
+ return (K = (I = this.h).onReact) == null ? void 0 : K.call(I, e.id, g, U.includes(this.me));
2125
+ }), h.append(b);
2126
2126
  }
2127
- const T = a("button", "ocw-react-btn", "+"), v = a("div", "ocw-react-picker");
2128
- for (const m of Lt) {
2129
- const g = a("button", void 0, m);
2130
- g.addEventListener("click", (I) => {
2131
- var U, P, E, M;
2132
- I.stopPropagation();
2133
- const K = (P = (U = e.reactions) == null ? void 0 : U[m]) == null ? void 0 : P.includes(this.me);
2134
- (M = (E = this.h).onReact) == null || M.call(E, e.id, m, !!K), v.style.display = "none";
2135
- }), v.append(g);
2127
+ const T = c("button", "ocw-react-btn", "+"), v = c("div", "ocw-react-picker");
2128
+ for (const g of Lt) {
2129
+ const U = c("button", void 0, g);
2130
+ U.addEventListener("click", (b) => {
2131
+ var K, P, E, M;
2132
+ b.stopPropagation();
2133
+ const I = (P = (K = e.reactions) == null ? void 0 : K[g]) == null ? void 0 : P.includes(this.me);
2134
+ (M = (E = this.h).onReact) == null || M.call(E, e.id, g, !!I), v.style.display = "none";
2135
+ }), v.append(U);
2136
2136
  }
2137
- v.style.display = "none", T.addEventListener("click", (m) => {
2138
- m.stopPropagation(), v.style.display = v.style.display === "none" ? "flex" : "none";
2137
+ v.style.display = "none", T.addEventListener("click", (g) => {
2138
+ g.stopPropagation(), v.style.display = v.style.display === "none" ? "flex" : "none";
2139
2139
  }), document.addEventListener("click", () => {
2140
2140
  v.style.display = "none";
2141
- }, { once: !0 }), u.append(T), h.append(u, v), c.append(h);
2142
- } else e.reactions && Object.keys(e.reactions).length && c.append(a("div", "ocw-react", Object.entries(e.reactions).map(([h, u]) => `${h}${u.length}`).join(" ")));
2143
- const b = a("div", "ocw-time ocw-meta", _t(e.ts));
2141
+ }, { once: !0 }), h.append(T), u.append(h, v), o.append(u);
2142
+ } else e.reactions && Object.keys(e.reactions).length && o.append(c("div", "ocw-react", Object.entries(e.reactions).map(([u, h]) => `${u}${h.length}`).join(" ")));
2143
+ const m = c("div", "ocw-time ocw-meta", _t(e.ts));
2144
2144
  if (n && e.status) {
2145
- const h = a("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Ht(e.status));
2146
- b.append(h);
2145
+ const u = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Ht(e.status));
2146
+ m.append(u);
2147
2147
  }
2148
- return n && e.seq > 0 && t.lastReadByOthers >= e.seq && b.append(a("span", "ocw-seen", " · Seen")), c.append(b), o.append(c), o;
2148
+ return n && e.seq > 0 && t.lastReadByOthers >= e.seq && m.append(c("span", "ocw-seen", " · Seen")), o.append(m), r.append(o), r;
2149
2149
  }
2150
2150
  }
2151
2151
  function Ht(s) {
@@ -2160,26 +2160,26 @@ function Ht(s) {
2160
2160
  return "🕓";
2161
2161
  }
2162
2162
  }
2163
- const F = /* @__PURE__ */ new WeakMap();
2163
+ const H = /* @__PURE__ */ new WeakMap();
2164
2164
  function qt(s) {
2165
2165
  var e;
2166
- (e = F.get(s)) == null || e.close(), F.delete(s);
2166
+ (e = H.get(s)) == null || e.close(), H.delete(s);
2167
2167
  }
2168
2168
  function Ot(s) {
2169
2169
  var ce, de, le, he;
2170
- F.has(s.el) && (F.get(s.el).close(), F.delete(s.el));
2171
- const e = s.token ?? Ke();
2172
- let t = new gt(e);
2173
- const n = s.subjectId ? `${e}::${s.subjectId}` : e, i = new kt(n);
2174
- let o, c = !1, l = null, w = null;
2170
+ H.has(s.el) && (H.get(s.el).close(), H.delete(s.el));
2171
+ const e = s.token ?? Ke(), t = s.apiUrl ? s.apiUrl.replace(/\/+$/, "") : Ae(s.url);
2172
+ let n = new gt(e);
2173
+ const i = s.subjectId ? `${e}::${s.subjectId}` : e, r = new kt(i);
2174
+ let o, l = !1, w = null, x = null;
2175
2175
  !s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
2176
- for (const d of i.load()) t.addOptimistic(d.clientMsgId, d.content);
2177
- let f = null, b = null, x = 0, h = !s.launcher;
2176
+ for (const d of r.load()) n.addOptimistic(d.clientMsgId, d.content);
2177
+ let m = null, f = null, u = 0, h = !s.launcher;
2178
2178
  if (s.launcher) {
2179
2179
  const p = (s.position ?? "bottom-right").includes("right");
2180
- f = document.createElement("div"), f.style.cssText = `position:fixed;${p ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${p ? "flex-end" : "flex-start"};gap:12px`;
2181
- const y = document.createElement("div"), C = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, _ = (D) => {
2182
- y.style.cssText = D ? [
2180
+ m = document.createElement("div"), m.style.cssText = `position:fixed;${p ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${p ? "flex-end" : "flex-start"};gap:12px`;
2181
+ const y = document.createElement("div"), C = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, R = ($) => {
2182
+ y.style.cssText = $ ? [
2183
2183
  "position:fixed",
2184
2184
  "inset:0",
2185
2185
  "width:100%",
@@ -2208,9 +2208,9 @@ function Ot(s) {
2208
2208
  "transform:scale(.95)"
2209
2209
  ].join(";");
2210
2210
  };
2211
- _((C == null ? void 0 : C.matches) ?? !1);
2212
- const $ = (D) => _(D.matches);
2213
- C == null || C.addEventListener("change", $), l = C, w = $, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2211
+ R((C == null ? void 0 : C.matches) ?? !1);
2212
+ const V = ($) => R($.matches);
2213
+ C == null || C.addEventListener("change", V), w = C, x = V, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2214
2214
  const B = document.createElement("button");
2215
2215
  B.style.cssText = [
2216
2216
  "width:56px;height:56px;border-radius:50%",
@@ -2223,109 +2223,107 @@ function Ot(s) {
2223
2223
  B.style.transform = "scale(1.08)";
2224
2224
  }, B.onmouseleave = () => {
2225
2225
  B.style.transform = "scale(1)";
2226
- }, b = document.createElement("span"), b.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center", B.append(b), f.append(y, B), document.body.append(f);
2227
- const W = (D) => {
2228
- D ? (y.style.display = "flex", requestAnimationFrame(() => {
2226
+ }, f = document.createElement("span"), f.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center", B.append(f), m.append(y, B), document.body.append(m);
2227
+ const W = ($) => {
2228
+ $ ? (y.style.display = "flex", requestAnimationFrame(() => {
2229
2229
  y.style.opacity = "1", y.style.transform = "scale(1)";
2230
2230
  })) : (y.style.opacity = "0", y.style.transform = "scale(.95)", setTimeout(() => {
2231
2231
  h || (y.style.display = "none");
2232
2232
  }, 180));
2233
2233
  };
2234
2234
  B.addEventListener("click", () => {
2235
- h = !h, W(h), B.textContent = h ? "✕" : "💬", B.append(b), h && (x = 0, b && (b.style.display = "none"));
2236
- }), document.addEventListener("keydown", (D) => {
2237
- D.key === "Escape" && h && (h = !1, W(!1), B.textContent = "💬", B.append(b));
2235
+ h = !h, W(h), B.textContent = h ? "✕" : "💬", B.append(f), h && (u = 0, f && (f.style.display = "none"));
2236
+ }), document.addEventListener("keydown", ($) => {
2237
+ $.key === "Escape" && h && (h = !1, W(!1), B.textContent = "💬", B.append(f));
2238
2238
  });
2239
2239
  }
2240
- const u = () => {
2241
- h || (x++, b && (b.textContent = String(x), b.style.display = "flex"));
2242
- }, T = () => {
2240
+ const T = () => {
2241
+ h || (u++, f && (f.textContent = String(u), f.style.display = "flex"));
2242
+ }, v = () => {
2243
2243
  try {
2244
2244
  const d = new AudioContext(), p = d.createOscillator(), y = d.createGain();
2245
2245
  p.connect(y), y.connect(d.destination), p.frequency.setValueAtTime(880, d.currentTime), p.frequency.exponentialRampToValueAtTime(440, d.currentTime + 0.15), y.gain.setValueAtTime(0.3, d.currentTime), y.gain.exponentialRampToValueAtTime(1e-3, d.currentTime + 0.3), p.start(), p.stop(d.currentTime + 0.3);
2246
2246
  } catch {
2247
2247
  }
2248
- }, v = [], m = (d) => {
2249
- for (; v.length; ) {
2250
- const p = v.shift();
2251
- i.add({ clientMsgId: p.clientMsgId, content: p.content, ts: Date.now() }), g.send({ type: "send", conversationId: d, clientMsgId: p.clientMsgId, content: p.content });
2248
+ }, g = [], U = (d) => {
2249
+ for (; g.length; ) {
2250
+ const p = g.shift();
2251
+ r.add({ clientMsgId: p.clientMsgId, content: p.content, ts: Date.now() }), b.send({ type: "send", conversationId: d, clientMsgId: p.clientMsgId, content: p.content });
2252
2252
  }
2253
2253
  };
2254
- let g;
2254
+ let b;
2255
2255
  const I = new At(`ocw-e2e-${s.profileId}`);
2256
2256
  let K = !1;
2257
- const U = [], P = [];
2258
- let E = !1;
2259
- const M = (d, p) => {
2257
+ const P = [], E = [];
2258
+ let M = !1;
2259
+ const k = (d, p) => {
2260
2260
  I.sealText(p).then((y) => {
2261
- o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: y });
2261
+ o && b.send({ type: "send", conversationId: o, clientMsgId: d, content: y });
2262
2262
  });
2263
- }, k = (d, p, y) => {
2263
+ }, A = (d, p, y) => {
2264
2264
  I.sealText(p, y).then((C) => {
2265
- o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: C });
2265
+ o && b.send({ type: "send", conversationId: o, clientMsgId: d, content: C });
2266
2266
  });
2267
- }, A = () => {
2268
- for (; U.length; ) {
2269
- const d = U.shift();
2270
- M(d.clientMsgId, d.text);
2271
- }
2267
+ }, Q = () => {
2272
2268
  for (; P.length; ) {
2273
2269
  const d = P.shift();
2274
- M(d.clientMsgId, d.text);
2270
+ k(d.clientMsgId, d.text);
2271
+ }
2272
+ for (; E.length; ) {
2273
+ const d = E.shift();
2274
+ k(d.clientMsgId, d.text);
2275
2275
  }
2276
- }, Q = (d) => {
2277
- g.send({ type: "fetchPrekey", targetUserId: d });
2278
- }, Se = s.i18n ?? {}, Ie = ["ar", "he", "fa", "ur"], Ce = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2279
- Ie.includes(Ce) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2276
+ }, Se = (d) => {
2277
+ b.send({ type: "fetchPrekey", targetUserId: d });
2278
+ }, Ie = s.i18n ?? {}, Ce = ["ar", "he", "fa", "ur"], Ee = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2279
+ Ce.includes(Ee) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2280
2280
  const L = new $t(s.el, e, {
2281
2281
  onSend(d) {
2282
2282
  const p = `cm_${Math.random().toString(36).slice(2)}`, y = { kind: "text", text: d };
2283
- t.addOptimistic(p, y), L.render(t), t.e2e ? I.ready ? M(p, d) : E ? P.push({ clientMsgId: p, text: d }) : (U.push({ clientMsgId: p, text: d }), t.assignedAgentId && Q(t.assignedAgentId)) : o ? (i.add({ clientMsgId: p, content: y, ts: Date.now() }), g.send({ type: "send", conversationId: o, clientMsgId: p, content: y })) : v.push({ clientMsgId: p, content: y });
2283
+ n.addOptimistic(p, y), L.render(n), n.e2e ? I.ready ? k(p, d) : M ? E.push({ clientMsgId: p, text: d }) : (P.push({ clientMsgId: p, text: d }), n.assignedAgentId && Se(n.assignedAgentId)) : o ? (r.add({ clientMsgId: p, content: y, ts: Date.now() }), b.send({ type: "send", conversationId: o, clientMsgId: p, content: y })) : g.push({ clientMsgId: p, content: y });
2284
2284
  },
2285
2285
  async onAttach(d) {
2286
2286
  if (!o) return;
2287
- const C = `${s.url.replace(/^ws/, "http").replace(/\/ws$/, "")}/upload?name=${encodeURIComponent(d.name)}`, _ = `cm_${Math.random().toString(36).slice(2)}`;
2288
- t.addOptimistic(_, { kind: "text", text: `📎 Uploading ${d.name}…` }), L.render(t);
2287
+ const p = `${t}/upload?name=${encodeURIComponent(d.name)}`, y = `cm_${Math.random().toString(36).slice(2)}`;
2288
+ n.addOptimistic(y, { kind: "text", text: `📎 Uploading ${d.name}…` }), L.render(n);
2289
2289
  try {
2290
- const $ = await fetch(C, {
2290
+ const C = await fetch(p, {
2291
2291
  method: "POST",
2292
2292
  headers: { "content-type": d.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
2293
2293
  body: d
2294
2294
  });
2295
- if (!$.ok) throw new Error(`Upload failed: ${$.status}`);
2296
- const { url: B, name: W, mime: D, size: Ue } = await $.json();
2297
- g.send({ type: "send", conversationId: o, clientMsgId: _, content: { kind: "attachment", url: B, name: W, mime: D, size: Ue } });
2298
- } catch ($) {
2299
- t.addOptimistic(_, { kind: "text", text: `⚠️ Upload failed: ${$.message}` }), L.render(t);
2295
+ if (!C.ok) throw new Error(`Upload failed: ${C.status}`);
2296
+ const { url: R, name: V, mime: B, size: W } = await C.json();
2297
+ b.send({ type: "send", conversationId: o, clientMsgId: y, content: { kind: "attachment", url: R, name: V, mime: B, size: W } });
2298
+ } catch (C) {
2299
+ n.addOptimistic(y, { kind: "text", text: `⚠️ Upload failed: ${C.message}` }), L.render(n);
2300
2300
  }
2301
2301
  },
2302
2302
  onInvoke(d, p) {
2303
- o && g.send({ type: "invoke", conversationId: o, actionId: d, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...p ? { inputs: p } : {} });
2303
+ o && b.send({ type: "invoke", conversationId: o, actionId: d, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...p ? { inputs: p } : {} });
2304
2304
  },
2305
2305
  onTyping(d, p) {
2306
- o && g.send({ type: "typing", conversationId: o, isTyping: d, ...p ? { preview: p } : {} });
2306
+ o && b.send({ type: "typing", conversationId: o, isTyping: d, ...p ? { preview: p } : {} });
2307
2307
  },
2308
2308
  onReadUpTo(d) {
2309
- o && g.send({ type: "read", conversationId: o, seq: d });
2309
+ o && b.send({ type: "read", conversationId: o, seq: d });
2310
2310
  },
2311
2311
  onLoadMore() {
2312
- if (!o || !t.e2e) return;
2313
- const d = t.messages()[0];
2314
- d && g.send({ type: "history", conversationId: o, beforeSeq: d.seq, limit: 20 });
2312
+ if (!o || !n.e2e) return;
2313
+ const d = n.messages()[0];
2314
+ d && b.send({ type: "history", conversationId: o, beforeSeq: d.seq, limit: 20 });
2315
2315
  },
2316
2316
  onEdit(d, p) {
2317
- o && g.send({ type: "edit", conversationId: o, messageId: d, content: { kind: "text", text: p } });
2317
+ o && b.send({ type: "edit", conversationId: o, messageId: d, content: { kind: "text", text: p } });
2318
2318
  },
2319
2319
  onDelete(d) {
2320
- o && g.send({ type: "delete", conversationId: o, messageId: d });
2320
+ o && b.send({ type: "delete", conversationId: o, messageId: d });
2321
2321
  },
2322
2322
  onReact(d, p, y) {
2323
- o && g.send({ type: "react", conversationId: o, messageId: d, emoji: p, remove: y });
2323
+ o && b.send({ type: "react", conversationId: o, messageId: d, emoji: p, remove: y });
2324
2324
  },
2325
2325
  onCsat(d) {
2326
- if (!o) return;
2327
- const p = ze(s.url);
2328
- fetch(`${p}/conversations/${o}/csat`, {
2326
+ o && fetch(`${t}/conversations/${o}/csat`, {
2329
2327
  method: "POST",
2330
2328
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${e}` },
2331
2329
  body: JSON.stringify({ score: d })
@@ -2333,23 +2331,22 @@ function Ot(s) {
2333
2331
  });
2334
2332
  },
2335
2333
  onAnnotate(d) {
2336
- o && g.send({ type: "annotate", conversationId: o, stroke: d });
2334
+ o && b.send({ type: "annotate", conversationId: o, stroke: d });
2337
2335
  },
2338
2336
  onAnnotateClear() {
2339
- o && g.send({ type: "annotate_clear", conversationId: o });
2337
+ o && b.send({ type: "annotate_clear", conversationId: o });
2340
2338
  },
2341
2339
  ...s.translateLang ? {
2342
2340
  async onTranslate(d) {
2343
- const p = s.url.replace(/^ws/, "http").replace(/\/+$/, "");
2344
2341
  try {
2345
- const y = await fetch(`${p}/translate`, {
2342
+ const p = await fetch(`${t}/translate`, {
2346
2343
  method: "POST",
2347
2344
  headers: { "content-type": "application/json", authorization: `Bearer ${e}` },
2348
2345
  body: JSON.stringify({ text: d, targetLang: s.translateLang })
2349
2346
  });
2350
- if (!y.ok) return null;
2351
- const { translated: C } = await y.json();
2352
- return C;
2347
+ if (!p.ok) return null;
2348
+ const { translated: y } = await p.json();
2349
+ return y;
2353
2350
  } catch {
2354
2351
  return null;
2355
2352
  }
@@ -2360,8 +2357,8 @@ function Ot(s) {
2360
2357
  ...s.quickReplies ? { quickReplies: s.quickReplies } : {},
2361
2358
  ...s.accent ? { accent: s.accent } : {},
2362
2359
  ...(ce = s.user) != null && ce.name || (de = s.user) != null && de.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2363
- i18n: Se
2364
- }), Ee = {
2360
+ i18n: Ie
2361
+ }), Te = {
2365
2362
  type: "open",
2366
2363
  profileId: s.profileId,
2367
2364
  ...s.subjectId ? { subjectId: s.subjectId } : {},
@@ -2371,70 +2368,70 @@ function Ot(s) {
2371
2368
  // This is how listingTitle and listingMeta get saved without a separate API call.
2372
2369
  ...(le = s.subject) != null && le.title ? { subjectTitle: s.subject.title } : {},
2373
2370
  ...(he = s.subject) != null && he.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2374
- }, Te = (d) => {
2371
+ }, Ue = (d) => {
2375
2372
  const p = s.user;
2376
2373
  if (!p || !p.name && !p.email && !p.avatar && !p.meta) return;
2377
2374
  const y = [];
2378
- if (p.name && y.push(`Name: ${p.name}`), p.email && y.push(`Email: ${p.email}`), p.avatar && y.push(`Avatar: ${p.avatar}`), p.meta) for (const [C, _] of Object.entries(p.meta)) y.push(`${C}: ${_}`);
2379
- g.send({ type: "note", conversationId: d, clientMsgId: `ui_${Date.now()}`, text: `[User info]
2375
+ if (p.name && y.push(`Name: ${p.name}`), p.email && y.push(`Email: ${p.email}`), p.avatar && y.push(`Avatar: ${p.avatar}`), p.meta) for (const [C, R] of Object.entries(p.meta)) y.push(`${C}: ${R}`);
2376
+ b.send({ type: "note", conversationId: d, clientMsgId: `ui_${Date.now()}`, text: `[User info]
2380
2377
  ${y.join(`
2381
2378
  `)}` });
2382
2379
  };
2383
- g = new bt({
2380
+ b = new bt({
2384
2381
  url: s.url,
2385
2382
  token: e,
2386
- open: Ee,
2387
- getCursor: () => t.highestSeq(),
2383
+ open: Te,
2384
+ getCursor: () => n.highestSeq(),
2388
2385
  onStatusChange: (d) => L.setConnStatus(d),
2389
2386
  onFrame(d) {
2390
2387
  if (d.type === "opened") {
2391
2388
  const p = o === void 0;
2392
- if (o = d.conversation.id, !c) {
2393
- c = !0;
2394
- for (const y of i.load())
2395
- g.send({ type: "send", conversationId: o, clientMsgId: y.clientMsgId, content: y.content });
2389
+ if (o = d.conversation.id, !l) {
2390
+ l = !0;
2391
+ for (const y of r.load())
2392
+ b.send({ type: "send", conversationId: o, clientMsgId: y.clientMsgId, content: y.content });
2396
2393
  }
2397
- Ae(s.url, e, o, t, L), v.length && m(o), p && d.conversation.lastSeq === 0 && Te(o);
2394
+ ze(s.url, e, o, n, L, t), g.length && U(o), p && d.conversation.lastSeq === 0 && Ue(o);
2398
2395
  }
2399
- if (d.type === "ack" && i.remove(d.clientMsgId), d.type === "prekeyBundle") {
2400
- d.bundle && (E = !0, I.x3dhSendTo(d.bundle).then((p) => {
2401
- const y = [...U.splice(0), ...P.splice(0)];
2402
- for (const C of y) k(C.clientMsgId, C.text, p);
2403
- L.render(t);
2396
+ if (d.type === "ack" && r.remove(d.clientMsgId), d.type === "prekeyBundle") {
2397
+ d.bundle && (M = !0, I.x3dhSendTo(d.bundle).then((p) => {
2398
+ const y = [...P.splice(0), ...E.splice(0)];
2399
+ for (const C of y) A(C.clientMsgId, C.text, p);
2400
+ L.render(n);
2404
2401
  }));
2405
2402
  return;
2406
2403
  }
2407
- if (d.type === "message" && t.e2e) {
2404
+ if (d.type === "message" && n.e2e) {
2408
2405
  const p = zt(d.message.content);
2409
2406
  if (p && !I.ready) {
2410
2407
  I.x3dhReceiveFrom(p.x3dhIK, p.x3dhEK, p.x3dhSPK).then(async () => {
2411
- await I.openFrame(d), t.apply(d), L.render(t);
2408
+ await I.openFrame(d), n.apply(d), L.render(n);
2412
2409
  });
2413
2410
  return;
2414
2411
  }
2415
2412
  }
2416
2413
  if (d.type === "peerkey") {
2417
2414
  I.onPeerKey(d.key).then(() => {
2418
- A(), L.render(t);
2415
+ Q(), L.render(n);
2419
2416
  });
2420
2417
  return;
2421
2418
  }
2422
2419
  (async () => {
2423
- if (t.e2e && await I.openFrame(d), t.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (u(), T()), t.e2e && o && !K) {
2420
+ if (n.e2e && await I.openFrame(d), n.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (T(), v()), n.e2e && o && !K) {
2424
2421
  K = !0;
2425
2422
  const p = await I.initX3DH();
2426
- g.send({ type: "uploadPrekeys", ...p });
2423
+ b.send({ type: "uploadPrekeys", ...p });
2427
2424
  const y = await I.begin();
2428
- g.send({ type: "pubkey", conversationId: o, key: y });
2425
+ b.send({ type: "pubkey", conversationId: o, key: y });
2429
2426
  }
2430
- L.render(t);
2427
+ L.render(n);
2431
2428
  })();
2432
2429
  }
2433
- }), g.connect(), L.render(t);
2430
+ }), b.connect(), L.render(n);
2434
2431
  const ae = { close: () => {
2435
- g.close(), f == null || f.remove(), L.destroy(), l && w && l.removeEventListener("change", w), F.delete(s.el);
2432
+ b.close(), m == null || m.remove(), L.destroy(), w && x && w.removeEventListener("change", x), H.delete(s.el);
2436
2433
  } };
2437
- return F.set(s.el, ae), ae;
2434
+ return H.set(s.el, ae), ae;
2438
2435
  }
2439
2436
  export {
2440
2437
  gt as ChatStore,
@@ -2444,9 +2441,9 @@ export {
2444
2441
  $t as Renderer,
2445
2442
  jt as asConversationId,
2446
2443
  zt as extractX3DHInit,
2447
- ze as httpBaseFromWsUrl,
2444
+ Ae as httpBaseFromWsUrl,
2448
2445
  Ot as mount,
2449
- Ae as restoreHistory,
2446
+ ze as restoreHistory,
2450
2447
  qt as unmount
2451
2448
  };
2452
2449
  //# sourceMappingURL=index.js.map