@paramms/chat-widget 1.0.6 → 1.0.8

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,8 +1,10 @@
1
- var Te = Object.defineProperty;
2
- var Be = (s, e, t) => e in s ? Te(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var a = (s, e, t) => Be(s, typeof e != "symbol" ? e + "" : e, t);
4
- const _t = (s) => s;
5
- function Ae(s) {
1
+ var Ie = Object.defineProperty;
2
+ var Ce = (s, e, t) => e in s ? Ie(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var r = (s, e, t) => Ce(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { p as Ee, r as Ue } from "./uid.js";
5
+ import { h as Rt } from "./uid.js";
6
+ const Dt = (s) => s;
7
+ function Te(s) {
6
8
  const e = s.length;
7
9
  let t = 0, i = 0;
8
10
  for (; i < e; ) {
@@ -28,103 +30,103 @@ function Pe(s, e, t) {
28
30
  const i = s.length;
29
31
  let n = t, o = 0;
30
32
  for (; o < i; ) {
31
- let r = s.charCodeAt(o++);
32
- if (r & 4294967168)
33
- if (!(r & 4294965248))
34
- e[n++] = r >> 6 & 31 | 192;
33
+ let c = s.charCodeAt(o++);
34
+ if (c & 4294967168)
35
+ if (!(c & 4294965248))
36
+ e[n++] = c >> 6 & 31 | 192;
35
37
  else {
36
- if (r >= 55296 && r <= 56319 && o < i) {
38
+ if (c >= 55296 && c <= 56319 && o < i) {
37
39
  const l = s.charCodeAt(o);
38
- (l & 64512) === 56320 && (++o, r = ((r & 1023) << 10) + (l & 1023) + 65536);
40
+ (l & 64512) === 56320 && (++o, c = ((c & 1023) << 10) + (l & 1023) + 65536);
39
41
  }
40
- r & 4294901760 ? (e[n++] = r >> 18 & 7 | 240, e[n++] = r >> 12 & 63 | 128, e[n++] = r >> 6 & 63 | 128) : (e[n++] = r >> 12 & 15 | 224, e[n++] = r >> 6 & 63 | 128);
42
+ c & 4294901760 ? (e[n++] = c >> 18 & 7 | 240, e[n++] = c >> 12 & 63 | 128, e[n++] = c >> 6 & 63 | 128) : (e[n++] = c >> 12 & 15 | 224, e[n++] = c >> 6 & 63 | 128);
41
43
  }
42
44
  else {
43
- e[n++] = r;
45
+ e[n++] = c;
44
46
  continue;
45
47
  }
46
- e[n++] = r & 63 | 128;
48
+ e[n++] = c & 63 | 128;
47
49
  }
48
50
  }
49
- const Ke = new TextEncoder(), Le = 50;
50
- function ze(s, e, t) {
51
- Ke.encodeInto(s, e.subarray(t));
51
+ const Be = new TextEncoder(), Ke = 50;
52
+ function Ae(s, e, t) {
53
+ Be.encodeInto(s, e.subarray(t));
52
54
  }
53
- function Me(s, e, t) {
54
- s.length > Le ? ze(s, e, t) : Pe(s, e, t);
55
+ function ze(s, e, t) {
56
+ s.length > Ke ? Ae(s, e, t) : Pe(s, e, t);
55
57
  }
56
- const $e = 4096;
57
- function ye(s, e, t) {
58
+ const Le = 4096;
59
+ function ue(s, e, t) {
58
60
  let i = e;
59
61
  const n = i + t, o = [];
60
- let r = "";
62
+ let c = "";
61
63
  for (; i < n; ) {
62
64
  const l = s[i++];
63
65
  if (!(l & 128))
64
66
  o.push(l);
65
67
  else if ((l & 224) === 192) {
66
- const w = s[i++] & 63;
67
- o.push((l & 31) << 6 | w);
68
+ const x = s[i++] & 63;
69
+ o.push((l & 31) << 6 | x);
68
70
  } else if ((l & 240) === 224) {
69
- const w = s[i++] & 63, u = s[i++] & 63;
70
- o.push((l & 31) << 12 | w << 6 | u);
71
+ const x = s[i++] & 63, f = s[i++] & 63;
72
+ o.push((l & 31) << 12 | x << 6 | f);
71
73
  } else if ((l & 248) === 240) {
72
- const w = s[i++] & 63, u = s[i++] & 63, m = s[i++] & 63;
73
- let x = (l & 7) << 18 | w << 12 | u << 6 | m;
74
- x > 65535 && (x -= 65536, o.push(x >>> 10 & 1023 | 55296), x = 56320 | x & 1023), o.push(x);
74
+ const x = s[i++] & 63, f = s[i++] & 63, m = s[i++] & 63;
75
+ let w = (l & 7) << 18 | x << 12 | f << 6 | m;
76
+ w > 65535 && (w -= 65536, o.push(w >>> 10 & 1023 | 55296), w = 56320 | w & 1023), o.push(w);
75
77
  } else
76
78
  o.push(l);
77
- o.length >= $e && (r += String.fromCharCode(...o), o.length = 0);
79
+ o.length >= Le && (c += String.fromCharCode(...o), o.length = 0);
78
80
  }
79
- return o.length > 0 && (r += String.fromCharCode(...o)), r;
81
+ return o.length > 0 && (c += String.fromCharCode(...o)), c;
80
82
  }
81
- const De = new TextDecoder(), _e = 200;
82
- function qe(s, e, t) {
83
+ const Me = new TextDecoder(), De = 200;
84
+ function $e(s, e, t) {
83
85
  const i = s.subarray(e, e + t);
84
- return De.decode(i);
86
+ return Me.decode(i);
85
87
  }
86
- function He(s, e, t) {
87
- return t > _e ? qe(s, e, t) : ye(s, e, t);
88
+ function _e(s, e, t) {
89
+ return t > De ? $e(s, e, t) : ue(s, e, t);
88
90
  }
89
- class J {
91
+ class N {
90
92
  constructor(e, t) {
91
- a(this, "type");
92
- a(this, "data");
93
+ r(this, "type");
94
+ r(this, "data");
93
95
  this.type = e, this.data = t;
94
96
  }
95
97
  }
96
- class B extends Error {
98
+ class U extends Error {
97
99
  constructor(e) {
98
100
  super(e);
99
- const t = Object.create(B.prototype);
101
+ const t = Object.create(U.prototype);
100
102
  Object.setPrototypeOf(this, t), Object.defineProperty(this, "name", {
101
103
  configurable: !0,
102
104
  enumerable: !1,
103
- value: B.name
105
+ value: U.name
104
106
  });
105
107
  }
106
108
  }
107
- const O = 4294967295;
108
- function Re(s, e, t) {
109
+ const F = 4294967295;
110
+ function He(s, e, t) {
109
111
  const i = t / 4294967296, n = t;
110
112
  s.setUint32(e, i), s.setUint32(e + 4, n);
111
113
  }
112
- function be(s, e, t) {
114
+ function fe(s, e, t) {
113
115
  const i = Math.floor(t / 4294967296), n = t;
114
116
  s.setUint32(e, i), s.setUint32(e + 4, n);
115
117
  }
116
- function me(s, e) {
118
+ function we(s, e) {
117
119
  const t = s.getInt32(e), i = s.getUint32(e + 4);
118
120
  return t * 4294967296 + i;
119
121
  }
120
- function je(s, e) {
122
+ function Re(s, e) {
121
123
  const t = s.getUint32(e), i = s.getUint32(e + 4);
122
124
  return t * 4294967296 + i;
123
125
  }
124
- const Fe = -1, Oe = 4294967296 - 1, Ne = 17179869184 - 1;
125
- function We({ sec: s, nsec: e }) {
126
- if (s >= 0 && e >= 0 && s <= Ne)
127
- if (e === 0 && s <= Oe) {
126
+ const Fe = -1, je = 4294967296 - 1, qe = 17179869184 - 1;
127
+ function Oe({ sec: s, nsec: e }) {
128
+ if (s >= 0 && e >= 0 && s <= qe)
129
+ if (e === 0 && s <= je) {
128
130
  const t = new Uint8Array(4);
129
131
  return new DataView(t.buffer).setUint32(0, s), t;
130
132
  } else {
@@ -133,24 +135,24 @@ function We({ sec: s, nsec: e }) {
133
135
  }
134
136
  else {
135
137
  const t = new Uint8Array(12), i = new DataView(t.buffer);
136
- return i.setUint32(0, e), be(i, 4, s), t;
138
+ return i.setUint32(0, e), fe(i, 4, s), t;
137
139
  }
138
140
  }
139
- function Ve(s) {
141
+ function Ne(s) {
140
142
  const e = s.getTime(), t = Math.floor(e / 1e3), i = (e - t * 1e3) * 1e6, n = Math.floor(i / 1e9);
141
143
  return {
142
144
  sec: t + n,
143
145
  nsec: i - n * 1e9
144
146
  };
145
147
  }
146
- function Xe(s) {
148
+ function Ve(s) {
147
149
  if (s instanceof Date) {
148
- const e = Ve(s);
149
- return We(e);
150
+ const e = Ne(s);
151
+ return Oe(e);
150
152
  } else
151
153
  return null;
152
154
  }
153
- function Ye(s) {
155
+ function We(s) {
154
156
  const e = new DataView(s.buffer, s.byteOffset, s.byteLength);
155
157
  switch (s.byteLength) {
156
158
  case 4:
@@ -160,34 +162,34 @@ function Ye(s) {
160
162
  return { sec: n, nsec: o };
161
163
  }
162
164
  case 12: {
163
- const t = me(e, 4), i = e.getUint32(0);
165
+ const t = we(e, 4), i = e.getUint32(0);
164
166
  return { sec: t, nsec: i };
165
167
  }
166
168
  default:
167
- throw new B(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`);
169
+ throw new U(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`);
168
170
  }
169
171
  }
170
- function Je(s) {
171
- const e = Ye(s);
172
+ function Xe(s) {
173
+ const e = We(s);
172
174
  return new Date(e.sec * 1e3 + e.nsec / 1e6);
173
175
  }
174
- const Ge = {
176
+ const Ye = {
175
177
  type: Fe,
176
- encode: Xe,
177
- decode: Je
178
- }, Q = class Q {
178
+ encode: Ve,
179
+ decode: Xe
180
+ }, X = class X {
179
181
  constructor() {
180
182
  // ensures ExtensionCodecType<X> matches ExtensionCodec<X>
181
183
  // this will make type errors a lot more clear
182
184
  // eslint-disable-next-line @typescript-eslint/naming-convention
183
- a(this, "__brand");
185
+ r(this, "__brand");
184
186
  // built-in extensions
185
- a(this, "builtInEncoders", []);
186
- a(this, "builtInDecoders", []);
187
+ r(this, "builtInEncoders", []);
188
+ r(this, "builtInDecoders", []);
187
189
  // custom extensions
188
- a(this, "encoders", []);
189
- a(this, "decoders", []);
190
- this.register(Ge);
190
+ r(this, "encoders", []);
191
+ r(this, "decoders", []);
192
+ this.register(Ye);
191
193
  }
192
194
  register({ type: e, encode: t, decode: i }) {
193
195
  if (e >= 0)
@@ -203,8 +205,8 @@ const Ge = {
203
205
  if (n != null) {
204
206
  const o = n(e, t);
205
207
  if (o != null) {
206
- const r = -1 - i;
207
- return new J(r, o);
208
+ const c = -1 - i;
209
+ return new N(c, o);
208
210
  }
209
211
  }
210
212
  }
@@ -213,46 +215,46 @@ const Ge = {
213
215
  if (n != null) {
214
216
  const o = n(e, t);
215
217
  if (o != null) {
216
- const r = i;
217
- return new J(r, o);
218
+ const c = i;
219
+ return new N(c, o);
218
220
  }
219
221
  }
220
222
  }
221
- return e instanceof J ? e : null;
223
+ return e instanceof N ? e : null;
222
224
  }
223
225
  decode(e, t, i) {
224
226
  const n = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
225
- return n ? n(e, t, i) : new J(t, e);
227
+ return n ? n(e, t, i) : new N(t, e);
226
228
  }
227
229
  };
228
- a(Q, "defaultCodec", new Q());
229
- let G = Q;
230
- function Ze(s) {
230
+ r(X, "defaultCodec", new X());
231
+ let V = X;
232
+ function Je(s) {
231
233
  return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
232
234
  }
233
- function ie(s) {
234
- return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) : Ze(s) ? new Uint8Array(s) : Uint8Array.from(s);
235
+ function Z(s) {
236
+ return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) : Je(s) ? new Uint8Array(s) : Uint8Array.from(s);
235
237
  }
236
- const Qe = 100, et = 2048;
237
- class oe {
238
+ const Ge = 100, Ze = 2048;
239
+ class te {
238
240
  constructor(e) {
239
- a(this, "extensionCodec");
240
- a(this, "context");
241
- a(this, "useBigInt64");
242
- a(this, "maxDepth");
243
- a(this, "initialBufferSize");
244
- a(this, "sortKeys");
245
- a(this, "forceFloat32");
246
- a(this, "ignoreUndefined");
247
- a(this, "forceIntegerToFloat");
248
- a(this, "pos");
249
- a(this, "view");
250
- a(this, "bytes");
251
- a(this, "entered", !1);
252
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? G.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) ?? Qe, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? et, 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);
241
+ r(this, "extensionCodec");
242
+ r(this, "context");
243
+ r(this, "useBigInt64");
244
+ r(this, "maxDepth");
245
+ r(this, "initialBufferSize");
246
+ r(this, "sortKeys");
247
+ r(this, "forceFloat32");
248
+ r(this, "ignoreUndefined");
249
+ r(this, "forceIntegerToFloat");
250
+ r(this, "pos");
251
+ r(this, "view");
252
+ r(this, "bytes");
253
+ r(this, "entered", !1);
254
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? V.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) ?? Ge, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? Ze, 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);
253
255
  }
254
256
  clone() {
255
- return new oe({
257
+ return new te({
256
258
  extensionCodec: this.extensionCodec,
257
259
  context: this.context,
258
260
  useBigInt64: this.useBigInt64,
@@ -334,8 +336,8 @@ class oe {
334
336
  throw new Error(`Too long string: ${e} bytes in UTF-8`);
335
337
  }
336
338
  encodeString(e) {
337
- const i = Ae(e);
338
- this.ensureBufferSizeToWrite(5 + i), this.writeStringHeader(i), Me(e, this.bytes, this.pos), this.pos += i;
339
+ const i = Te(e);
340
+ this.ensureBufferSizeToWrite(5 + i), this.writeStringHeader(i), ze(e, this.bytes, this.pos), this.pos += i;
339
341
  }
340
342
  encodeObject(e, t) {
341
343
  const i = this.extensionCodec.tryToEncode(e, this.context);
@@ -360,7 +362,7 @@ class oe {
360
362
  this.writeU8(198), this.writeU32(t);
361
363
  else
362
364
  throw new Error(`Too large binary: ${t}`);
363
- const i = ie(e);
365
+ const i = Z(e);
364
366
  this.writeU8a(i);
365
367
  }
366
368
  encodeArray(e, t) {
@@ -395,8 +397,8 @@ class oe {
395
397
  else
396
398
  throw new Error(`Too large map object: ${n}`);
397
399
  for (const o of i) {
398
- const r = e[o];
399
- this.ignoreUndefined && r === void 0 || (this.encodeString(o), this.doEncode(r, t + 1));
400
+ const c = e[o];
401
+ this.ignoreUndefined && c === void 0 || (this.encodeString(o), this.doEncode(c, t + 1));
400
402
  }
401
403
  }
402
404
  encodeExtension(e) {
@@ -457,10 +459,10 @@ class oe {
457
459
  this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
458
460
  }
459
461
  writeU64(e) {
460
- this.ensureBufferSizeToWrite(8), Re(this.view, this.pos, e), this.pos += 8;
462
+ this.ensureBufferSizeToWrite(8), He(this.view, this.pos, e), this.pos += 8;
461
463
  }
462
464
  writeI64(e) {
463
- this.ensureBufferSizeToWrite(8), be(this.view, this.pos, e), this.pos += 8;
465
+ this.ensureBufferSizeToWrite(8), fe(this.view, this.pos, e), this.pos += 8;
464
466
  }
465
467
  writeBigUint64(e) {
466
468
  this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
@@ -469,20 +471,20 @@ class oe {
469
471
  this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
470
472
  }
471
473
  }
472
- function tt(s, e) {
473
- return new oe(e).encodeSharedRef(s);
474
+ function Qe(s, e) {
475
+ return new te(e).encodeSharedRef(s);
474
476
  }
475
- function ee(s) {
477
+ function J(s) {
476
478
  return `${s < 0 ? "-" : ""}0x${Math.abs(s).toString(16).padStart(2, "0")}`;
477
479
  }
478
- const it = 16, nt = 16;
479
- class st {
480
- constructor(e = it, t = nt) {
481
- a(this, "hit", 0);
482
- a(this, "miss", 0);
483
- a(this, "caches");
484
- a(this, "maxKeyLength");
485
- a(this, "maxLengthPerKey");
480
+ const et = 16, tt = 16;
481
+ class it {
482
+ constructor(e = et, t = tt) {
483
+ r(this, "hit", 0);
484
+ r(this, "miss", 0);
485
+ r(this, "caches");
486
+ r(this, "maxKeyLength");
487
+ r(this, "maxLengthPerKey");
486
488
  this.maxKeyLength = e, this.maxLengthPerKey = t, this.caches = [];
487
489
  for (let i = 0; i < this.maxKeyLength; i++)
488
490
  this.caches.push([]);
@@ -493,9 +495,9 @@ class st {
493
495
  find(e, t, i) {
494
496
  const n = this.caches[i - 1];
495
497
  e: for (const o of n) {
496
- const r = o.bytes;
498
+ const c = o.bytes;
497
499
  for (let l = 0; l < i; l++)
498
- if (r[l] !== e[t + l])
500
+ if (c[l] !== e[t + l])
499
501
  continue e;
500
502
  return o.str;
501
503
  }
@@ -510,19 +512,19 @@ class st {
510
512
  if (n != null)
511
513
  return this.hit++, n;
512
514
  this.miss++;
513
- const o = ye(e, t, i), r = Uint8Array.prototype.slice.call(e, t, t + i);
514
- return this.store(r, o), o;
515
+ const o = ue(e, t, i), c = Uint8Array.prototype.slice.call(e, t, t + i);
516
+ return this.store(c, o), o;
515
517
  }
516
518
  }
517
- const ne = "array", W = "map_key", ve = "map_value", ot = (s) => {
519
+ const Q = "array", q = "map_key", xe = "map_value", nt = (s) => {
518
520
  if (typeof s == "string" || typeof s == "number")
519
521
  return s;
520
- throw new B("The type of key must be string or number but " + typeof s);
522
+ throw new U("The type of key must be string or number but " + typeof s);
521
523
  };
522
- class rt {
524
+ class st {
523
525
  constructor() {
524
- a(this, "stack", []);
525
- a(this, "stackHeadPosition", -1);
526
+ r(this, "stack", []);
527
+ r(this, "stackHeadPosition", -1);
526
528
  }
527
529
  get length() {
528
530
  return this.stackHeadPosition + 1;
@@ -532,11 +534,11 @@ class rt {
532
534
  }
533
535
  pushArrayState(e) {
534
536
  const t = this.getUninitializedStateFromPool();
535
- t.type = ne, t.position = 0, t.size = e, t.array = new Array(e);
537
+ t.type = Q, t.position = 0, t.size = e, t.array = new Array(e);
536
538
  }
537
539
  pushMapState(e) {
538
540
  const t = this.getUninitializedStateFromPool();
539
- t.type = W, t.readCount = 0, t.size = e, t.map = {};
541
+ t.type = q, t.readCount = 0, t.size = e, t.map = {};
540
542
  }
541
543
  getUninitializedStateFromPool() {
542
544
  if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
@@ -556,11 +558,11 @@ class rt {
556
558
  release(e) {
557
559
  if (this.stack[this.stackHeadPosition] !== e)
558
560
  throw new Error("Invalid stack state. Released state is not on top of the stack.");
559
- if (e.type === ne) {
561
+ if (e.type === Q) {
560
562
  const i = e;
561
563
  i.size = 0, i.array = void 0, i.position = 0, i.type = void 0;
562
564
  }
563
- if (e.type === W || e.type === ve) {
565
+ if (e.type === q || e.type === xe) {
564
566
  const i = e;
565
567
  i.size = 0, i.map = void 0, i.readCount = 0, i.type = void 0;
566
568
  }
@@ -570,38 +572,38 @@ class rt {
570
572
  this.stack.length = 0, this.stackHeadPosition = -1;
571
573
  }
572
574
  }
573
- const N = -1, re = new DataView(new ArrayBuffer(0)), at = new Uint8Array(re.buffer);
575
+ const j = -1, ie = new DataView(new ArrayBuffer(0)), ot = new Uint8Array(ie.buffer);
574
576
  try {
575
- re.getInt8(0);
577
+ ie.getInt8(0);
576
578
  } catch (s) {
577
579
  if (!(s instanceof RangeError))
578
580
  throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
579
581
  }
580
- const ce = new RangeError("Insufficient data"), ct = new st();
581
- class ae {
582
+ const ce = new RangeError("Insufficient data"), rt = new it();
583
+ class ne {
582
584
  constructor(e) {
583
- a(this, "extensionCodec");
584
- a(this, "context");
585
- a(this, "useBigInt64");
586
- a(this, "rawStrings");
587
- a(this, "maxStrLength");
588
- a(this, "maxBinLength");
589
- a(this, "maxArrayLength");
590
- a(this, "maxMapLength");
591
- a(this, "maxExtLength");
592
- a(this, "keyDecoder");
593
- a(this, "mapKeyConverter");
594
- a(this, "totalPos", 0);
595
- a(this, "pos", 0);
596
- a(this, "view", re);
597
- a(this, "bytes", at);
598
- a(this, "headByte", N);
599
- a(this, "stack", new rt());
600
- a(this, "entered", !1);
601
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? G.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) ?? O, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? O, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? O, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? O, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? O, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : ct, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? ot;
585
+ r(this, "extensionCodec");
586
+ r(this, "context");
587
+ r(this, "useBigInt64");
588
+ r(this, "rawStrings");
589
+ r(this, "maxStrLength");
590
+ r(this, "maxBinLength");
591
+ r(this, "maxArrayLength");
592
+ r(this, "maxMapLength");
593
+ r(this, "maxExtLength");
594
+ r(this, "keyDecoder");
595
+ r(this, "mapKeyConverter");
596
+ r(this, "totalPos", 0);
597
+ r(this, "pos", 0);
598
+ r(this, "view", ie);
599
+ r(this, "bytes", ot);
600
+ r(this, "headByte", j);
601
+ r(this, "stack", new st());
602
+ r(this, "entered", !1);
603
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? V.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) ?? F, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? F, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? F, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? F, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? F, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : rt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? nt;
602
604
  }
603
605
  clone() {
604
- return new ae({
606
+ return new ne({
605
607
  extensionCodec: this.extensionCodec,
606
608
  context: this.context,
607
609
  useBigInt64: this.useBigInt64,
@@ -615,17 +617,17 @@ class ae {
615
617
  });
616
618
  }
617
619
  reinitializeState() {
618
- this.totalPos = 0, this.headByte = N, this.stack.reset();
620
+ this.totalPos = 0, this.headByte = j, this.stack.reset();
619
621
  }
620
622
  setBuffer(e) {
621
- const t = ie(e);
623
+ const t = Z(e);
622
624
  this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
623
625
  }
624
626
  appendBuffer(e) {
625
- if (this.headByte === N && !this.hasRemaining(1))
627
+ if (this.headByte === j && !this.hasRemaining(1))
626
628
  this.setBuffer(e);
627
629
  else {
628
- const t = this.bytes.subarray(this.pos), i = ie(e), n = new Uint8Array(t.length + i.length);
630
+ const t = this.bytes.subarray(this.pos), i = Z(e), n = new Uint8Array(t.length + i.length);
629
631
  n.set(t), n.set(i, t.length), this.setBuffer(n);
630
632
  }
631
633
  }
@@ -677,9 +679,9 @@ class ae {
677
679
  this.appendBuffer(l);
678
680
  try {
679
681
  i = this.doDecodeSync(), t = !0;
680
- } catch (w) {
681
- if (!(w instanceof RangeError))
682
- throw w;
682
+ } catch (x) {
683
+ if (!(x instanceof RangeError))
684
+ throw x;
683
685
  }
684
686
  this.totalPos += this.pos;
685
687
  }
@@ -688,8 +690,8 @@ class ae {
688
690
  throw this.createExtraByteError(this.totalPos);
689
691
  return i;
690
692
  }
691
- const { headByte: n, pos: o, totalPos: r } = this;
692
- throw new RangeError(`Insufficient data in parsing ${ee(n)} at ${r} (${o} in the current buffer)`);
693
+ const { headByte: n, pos: o, totalPos: c } = this;
694
+ throw new RangeError(`Insufficient data in parsing ${J(n)} at ${c} (${o} in the current buffer)`);
693
695
  } finally {
694
696
  this.entered = !1;
695
697
  }
@@ -715,9 +717,9 @@ class ae {
715
717
  try {
716
718
  for (; yield this.doDecodeSync(), --n !== 0; )
717
719
  ;
718
- } catch (r) {
719
- if (!(r instanceof RangeError))
720
- throw r;
720
+ } catch (c) {
721
+ if (!(c instanceof RangeError))
722
+ throw c;
721
723
  }
722
724
  this.totalPos += this.pos;
723
725
  }
@@ -844,25 +846,25 @@ class ae {
844
846
  const n = this.lookU32();
845
847
  t = this.decodeExtension(n, 4);
846
848
  } else
847
- throw new B(`Unrecognized type byte: ${ee(e)}`);
849
+ throw new U(`Unrecognized type byte: ${J(e)}`);
848
850
  this.complete();
849
851
  const i = this.stack;
850
852
  for (; i.length > 0; ) {
851
853
  const n = i.top();
852
- if (n.type === ne)
854
+ if (n.type === Q)
853
855
  if (n.array[n.position] = t, n.position++, n.position === n.size)
854
856
  t = n.array, i.release(n);
855
857
  else
856
858
  continue e;
857
- else if (n.type === W) {
859
+ else if (n.type === q) {
858
860
  if (t === "__proto__")
859
- throw new B("The key __proto__ is not allowed");
860
- n.key = this.mapKeyConverter(t), n.type = ve;
861
+ throw new U("The key __proto__ is not allowed");
862
+ n.key = this.mapKeyConverter(t), n.type = xe;
861
863
  continue e;
862
864
  } else if (n.map[n.key] = t, n.readCount++, n.readCount === n.size)
863
865
  t = n.map, i.release(n);
864
866
  else {
865
- n.key = null, n.type = W;
867
+ n.key = null, n.type = q;
866
868
  continue e;
867
869
  }
868
870
  }
@@ -870,10 +872,10 @@ class ae {
870
872
  }
871
873
  }
872
874
  readHeadByte() {
873
- return this.headByte === N && (this.headByte = this.readU8()), this.headByte;
875
+ return this.headByte === j && (this.headByte = this.readU8()), this.headByte;
874
876
  }
875
877
  complete() {
876
- this.headByte = N;
878
+ this.headByte = j;
877
879
  }
878
880
  readArraySize() {
879
881
  const e = this.readHeadByte();
@@ -885,18 +887,18 @@ class ae {
885
887
  default: {
886
888
  if (e < 160)
887
889
  return e - 144;
888
- throw new B(`Unrecognized array type byte: ${ee(e)}`);
890
+ throw new U(`Unrecognized array type byte: ${J(e)}`);
889
891
  }
890
892
  }
891
893
  }
892
894
  pushMapState(e) {
893
895
  if (e > this.maxMapLength)
894
- throw new B(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);
896
+ throw new U(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);
895
897
  this.stack.pushMapState(e);
896
898
  }
897
899
  pushArrayState(e) {
898
900
  if (e > this.maxArrayLength)
899
- throw new B(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);
901
+ throw new U(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);
900
902
  this.stack.pushArrayState(e);
901
903
  }
902
904
  decodeString(e, t) {
@@ -908,22 +910,22 @@ class ae {
908
910
  decodeUtf8String(e, t) {
909
911
  var o;
910
912
  if (e > this.maxStrLength)
911
- throw new B(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
913
+ throw new U(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
912
914
  if (this.bytes.byteLength < this.pos + t + e)
913
915
  throw ce;
914
916
  const i = this.pos + t;
915
917
  let n;
916
- return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? n = this.keyDecoder.decode(this.bytes, i, e) : n = He(this.bytes, i, e), this.pos += t + e, n;
918
+ return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? n = this.keyDecoder.decode(this.bytes, i, e) : n = _e(this.bytes, i, e), this.pos += t + e, n;
917
919
  }
918
920
  stateIsMapKey() {
919
- return this.stack.length > 0 ? this.stack.top().type === W : !1;
921
+ return this.stack.length > 0 ? this.stack.top().type === q : !1;
920
922
  }
921
923
  /**
922
924
  * @throws {@link RangeError}
923
925
  */
924
926
  decodeBinary(e, t) {
925
927
  if (e > this.maxBinLength)
926
- throw new B(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
928
+ throw new U(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
927
929
  if (!this.hasRemaining(e + t))
928
930
  throw ce;
929
931
  const i = this.pos + t, n = this.bytes.subarray(i, i + e);
@@ -931,7 +933,7 @@ class ae {
931
933
  }
932
934
  decodeExtension(e, t) {
933
935
  if (e > this.maxExtLength)
934
- throw new B(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);
936
+ throw new U(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);
935
937
  const i = this.view.getInt8(this.pos + t), n = this.decodeBinary(
936
938
  e,
937
939
  t + 1
@@ -973,11 +975,11 @@ class ae {
973
975
  return this.pos += 4, e;
974
976
  }
975
977
  readU64() {
976
- const e = je(this.view, this.pos);
978
+ const e = Re(this.view, this.pos);
977
979
  return this.pos += 8, e;
978
980
  }
979
981
  readI64() {
980
- const e = me(this.view, this.pos);
982
+ const e = we(this.view, this.pos);
981
983
  return this.pos += 8, e;
982
984
  }
983
985
  readU64AsBigInt() {
@@ -997,10 +999,10 @@ class ae {
997
999
  return this.pos += 8, e;
998
1000
  }
999
1001
  }
1000
- function dt(s, e) {
1001
- return new ae(e).decode(s);
1002
+ function at(s, e) {
1003
+ return new ne(e).decode(s);
1002
1004
  }
1003
- const lt = /* @__PURE__ */ new Set([
1005
+ const ct = /* @__PURE__ */ new Set([
1004
1006
  "auth",
1005
1007
  "open",
1006
1008
  "send",
@@ -1017,50 +1019,50 @@ const lt = /* @__PURE__ */ new Set([
1017
1019
  "annotate",
1018
1020
  "annotate_clear"
1019
1021
  ]);
1020
- function ht(s) {
1021
- return lt.has(s.type);
1022
+ function dt(s) {
1023
+ return ct.has(s.type);
1022
1024
  }
1023
- function pt(s) {
1024
- return tt(s);
1025
+ function lt(s) {
1026
+ return Qe(s);
1025
1027
  }
1026
- function ft(s) {
1028
+ function ht(s) {
1027
1029
  let e;
1028
1030
  try {
1029
- e = dt(s);
1031
+ e = at(s);
1030
1032
  } catch {
1031
1033
  return null;
1032
1034
  }
1033
1035
  return typeof e != "object" || e === null || typeof e.type != "string" ? null : e;
1034
1036
  }
1035
- class de {
1037
+ class pt {
1036
1038
  constructor(e) {
1037
- a(this, "conversationId");
1038
- a(this, "state", "");
1039
- a(this, "version", 0);
1040
- a(this, "hasMoreHistory", !1);
1041
- a(this, "lastReadByOthers", 0);
1042
- a(this, "assignedAgentId");
1043
- a(this, "accent");
1044
- a(this, "subject");
1045
- a(this, "name");
1046
- a(this, "e2e", !1);
1047
- a(this, "offline", !1);
1048
- a(this, "offlineMessage", "");
1049
- a(this, "whiteLabel", !1);
1050
- a(this, "typing", /* @__PURE__ */ new Set());
1051
- a(this, "online", /* @__PURE__ */ new Set());
1039
+ r(this, "conversationId");
1040
+ r(this, "state", "");
1041
+ r(this, "version", 0);
1042
+ r(this, "hasMoreHistory", !1);
1043
+ r(this, "lastReadByOthers", 0);
1044
+ r(this, "assignedAgentId");
1045
+ r(this, "accent");
1046
+ r(this, "subject");
1047
+ r(this, "name");
1048
+ r(this, "e2e", !1);
1049
+ r(this, "offline", !1);
1050
+ r(this, "offlineMessage", "");
1051
+ r(this, "whiteLabel", !1);
1052
+ r(this, "typing", /* @__PURE__ */ new Set());
1053
+ r(this, "online", /* @__PURE__ */ new Set());
1052
1054
  /** Co-browsing: shared whiteboard strokes for this conversation. */
1053
- a(this, "annotations", []);
1055
+ r(this, "annotations", []);
1054
1056
  /** Bumped on any annotation change so the renderer can cheaply detect updates. */
1055
- a(this, "annotationVersion", 0);
1057
+ r(this, "annotationVersion", 0);
1056
1058
  /** Live sentiment of the guest's latest message (agent-side only). */
1057
- a(this, "sentiment");
1058
- a(this, "sentimentScore");
1059
- a(this, "actions", []);
1060
- a(this, "byId", /* @__PURE__ */ new Map());
1061
- a(this, "keyByClient", /* @__PURE__ */ new Map());
1062
- a(this, "_maxSeq", 0);
1063
- a(this, "_sorted", null);
1059
+ r(this, "sentiment");
1060
+ r(this, "sentimentScore");
1061
+ r(this, "actions", []);
1062
+ r(this, "byId", /* @__PURE__ */ new Map());
1063
+ r(this, "keyByClient", /* @__PURE__ */ new Map());
1064
+ r(this, "_maxSeq", 0);
1065
+ r(this, "_sorted", null);
1064
1066
  this.me = e;
1065
1067
  }
1066
1068
  messages() {
@@ -1130,7 +1132,7 @@ class de {
1130
1132
  case "reaction": {
1131
1133
  const i = this.byId.get(e.messageId);
1132
1134
  if (!i) return;
1133
- const n = { ...i.reactions ?? {} }, o = (n[e.emoji] ?? []).filter((r) => r !== e.by);
1135
+ const n = { ...i.reactions ?? {} }, o = (n[e.emoji] ?? []).filter((c) => c !== e.by);
1134
1136
  e.removed || o.push(e.by), o.length ? n[e.emoji] = o : delete n[e.emoji], this.byId.set(e.messageId, { ...i, reactions: n }), this._sorted = null;
1135
1137
  return;
1136
1138
  }
@@ -1178,10 +1180,10 @@ class de {
1178
1180
  }
1179
1181
  markOwnStatus(e, t) {
1180
1182
  for (const [i, n] of this.byId)
1181
- n.senderId === this.me && n.seq > 0 && n.seq <= e && le(t) > le(n.status) && (this.byId.set(i, { ...n, status: t }), this._sorted = null);
1183
+ n.senderId === this.me && n.seq > 0 && n.seq <= e && de(t) > de(n.status) && (this.byId.set(i, { ...n, status: t }), this._sorted = null);
1182
1184
  }
1183
1185
  }
1184
- function le(s) {
1186
+ function de(s) {
1185
1187
  switch (s) {
1186
1188
  case "read":
1187
1189
  return 3;
@@ -1193,27 +1195,27 @@ function le(s) {
1193
1195
  return 0;
1194
1196
  }
1195
1197
  }
1196
- class he {
1198
+ class ut {
1197
1199
  constructor(e) {
1198
- a(this, "socket", null);
1199
- a(this, "state", "idle");
1200
- a(this, "authed", !1);
1201
- a(this, "attempt", 0);
1202
- a(this, "outbox", []);
1203
- a(this, "stopped", !1);
1204
- a(this, "timer", null);
1200
+ r(this, "socket", null);
1201
+ r(this, "state", "idle");
1202
+ r(this, "authed", !1);
1203
+ r(this, "attempt", 0);
1204
+ r(this, "outbox", []);
1205
+ r(this, "stopped", !1);
1206
+ r(this, "timer", null);
1205
1207
  this.opts = e;
1206
1208
  }
1207
1209
  connect() {
1208
1210
  var i, n;
1209
1211
  if (this.state === "connecting" || this.state === "open") return;
1210
1212
  this.stopped = !1, this.state = "connecting", this.authed = !1, (n = (i = this.opts).onStatusChange) == null || n.call(i, this.attempt > 0 ? "reconnecting" : "connecting");
1211
- const t = (this.opts.socketFactory ?? ut)(this.opts.url);
1213
+ const t = (this.opts.socketFactory ?? ft)(this.opts.url);
1212
1214
  t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
1213
1215
  this.raw({ type: "auth", token: this.opts.token });
1214
1216
  }, t.onmessage = (o) => {
1215
- const r = ft(new Uint8Array(o.data));
1216
- !r || ht(r) || this.handle(r);
1217
+ const c = ht(new Uint8Array(o.data));
1218
+ !c || dt(c) || this.handle(c);
1217
1219
  }, t.onclose = () => this.onClosed(), t.onerror = () => {
1218
1220
  try {
1219
1221
  t.close();
@@ -1252,7 +1254,7 @@ class he {
1252
1254
  raw(e) {
1253
1255
  var t;
1254
1256
  try {
1255
- (t = this.socket) == null || t.send(pt(e));
1257
+ (t = this.socket) == null || t.send(lt(e));
1256
1258
  } catch {
1257
1259
  this.outbox.push(e);
1258
1260
  }
@@ -1267,13 +1269,13 @@ class he {
1267
1269
  this.attempt++, this.timer = setTimeout(() => this.connect(), i);
1268
1270
  }
1269
1271
  }
1270
- function ut(s) {
1272
+ function ft(s) {
1271
1273
  return new WebSocket(s);
1272
1274
  }
1273
- const pe = 200, wt = 7 * 864e5;
1274
- class fe {
1275
+ const le = 200, wt = 7 * 864e5;
1276
+ class xt {
1275
1277
  constructor(e) {
1276
- a(this, "key");
1278
+ r(this, "key");
1277
1279
  this.key = `ocw_outbox_${e}`;
1278
1280
  }
1279
1281
  /** All pending items, oldest first, with stale (>7d) entries dropped. */
@@ -1290,7 +1292,7 @@ class fe {
1290
1292
  add(e) {
1291
1293
  try {
1292
1294
  const t = this.load();
1293
- t.push(e), this.save(t.length > pe ? t.slice(t.length - pe) : t);
1295
+ t.push(e), this.save(t.length > le ? t.slice(t.length - le) : t);
1294
1296
  } catch {
1295
1297
  }
1296
1298
  }
@@ -1309,31 +1311,31 @@ class fe {
1309
1311
  }
1310
1312
  }
1311
1313
  }
1312
- const I = () => globalThis.crypto.subtle;
1313
- function Z(s) {
1314
+ const S = () => globalThis.crypto.subtle;
1315
+ function W(s) {
1314
1316
  const e = s instanceof Uint8Array ? s : new Uint8Array(s);
1315
1317
  let t = "";
1316
1318
  for (const i of e) t += String.fromCharCode(i);
1317
1319
  return btoa(t);
1318
1320
  }
1319
- function se(s) {
1321
+ function ee(s) {
1320
1322
  const e = atob(s), t = new ArrayBuffer(e.length), i = new Uint8Array(t);
1321
1323
  for (let n = 0; n < e.length; n++) i[n] = e.charCodeAt(n);
1322
1324
  return i;
1323
1325
  }
1324
- async function V() {
1325
- const s = await I().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1326
+ async function O() {
1327
+ const s = await S().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1326
1328
  return { publicKey: s.publicKey, privateKey: s.privateKey };
1327
1329
  }
1328
- async function $(s) {
1329
- return Z(await I().exportKey("raw", s));
1330
+ async function M(s) {
1331
+ return W(await S().exportKey("raw", s));
1330
1332
  }
1331
- async function j(s) {
1332
- return I().importKey("raw", se(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1333
+ async function H(s) {
1334
+ return S().importKey("raw", ee(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1333
1335
  }
1334
- async function xt(s, e) {
1335
- const t = await j(e);
1336
- return I().deriveKey(
1336
+ async function yt(s, e) {
1337
+ const t = await H(e);
1338
+ return S().deriveKey(
1337
1339
  { name: "ECDH", public: t },
1338
1340
  s,
1339
1341
  { name: "AES-GCM", length: 256 },
@@ -1342,88 +1344,88 @@ async function xt(s, e) {
1342
1344
  );
1343
1345
  }
1344
1346
  async function gt(s, e) {
1345
- const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), i = new TextEncoder().encode(e), n = await I().encrypt({ name: "AES-GCM", iv: t }, s, i);
1346
- return { ct: Z(n), iv: Z(t) };
1347
+ const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), i = new TextEncoder().encode(e), n = await S().encrypt({ name: "AES-GCM", iv: t }, s, i);
1348
+ return { ct: W(n), iv: W(t) };
1347
1349
  }
1348
- async function yt(s, e, t) {
1349
- const i = await I().decrypt({ name: "AES-GCM", iv: se(t) }, s, se(e));
1350
+ async function bt(s, e, t) {
1351
+ const i = await S().decrypt({ name: "AES-GCM", iv: ee(t) }, s, ee(e));
1350
1352
  return new TextDecoder().decode(i);
1351
1353
  }
1352
- async function bt(s) {
1354
+ async function mt(s) {
1353
1355
  var t, i;
1354
1356
  try {
1355
1357
  const n = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
1356
1358
  if (n) {
1357
- const { pub: o, priv: r } = JSON.parse(n), l = await I().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await I().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1358
- return { publicKey: l, privateKey: w };
1359
+ const { pub: o, priv: c } = JSON.parse(n), l = await S().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), x = await S().importKey("jwk", c, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1360
+ return { publicKey: l, privateKey: x };
1359
1361
  }
1360
1362
  } catch {
1361
1363
  }
1362
- const e = await V();
1364
+ const e = await O();
1363
1365
  try {
1364
- const n = await I().exportKey("jwk", e.publicKey), o = await I().exportKey("jwk", e.privateKey);
1366
+ const n = await S().exportKey("jwk", e.publicKey), o = await S().exportKey("jwk", e.privateKey);
1365
1367
  (i = globalThis.localStorage) == null || i.setItem(s, JSON.stringify({ pub: n, priv: o }));
1366
1368
  } catch {
1367
1369
  }
1368
1370
  return e;
1369
1371
  }
1370
- async function mt(s, e) {
1371
- const t = await I().exportKey("raw", e), i = await I().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
1372
- return Z(i);
1372
+ async function vt(s, e) {
1373
+ const t = await S().exportKey("raw", e), i = await S().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
1374
+ return W(i);
1373
1375
  }
1374
- async function vt() {
1375
- const s = await V(), e = await I().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1376
+ async function kt() {
1377
+ const s = await O(), e = await S().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1376
1378
  return {
1377
1379
  ecdhKP: s,
1378
1380
  ecdsaKP: { publicKey: e.publicKey, privateKey: e.privateKey },
1379
- publicKeyB64: await $(s.publicKey),
1380
- sigPublicKeyB64: await $(e.publicKey)
1381
+ publicKeyB64: await M(s.publicKey),
1382
+ sigPublicKeyB64: await M(e.publicKey)
1381
1383
  };
1382
1384
  }
1383
- async function ue(s) {
1385
+ async function he(s) {
1384
1386
  var t, i;
1385
1387
  try {
1386
1388
  const n = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
1387
1389
  if (n) {
1388
- const o = JSON.parse(n), r = await I().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), l = await I().importKey("jwk", o.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await I().importKey("jwk", o.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), u = await I().importKey("jwk", o.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
1390
+ const o = JSON.parse(n), 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"]), x = 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"]);
1389
1391
  return {
1390
- ecdhKP: { publicKey: r, privateKey: l },
1391
- ecdsaKP: { publicKey: w, privateKey: u },
1392
- publicKeyB64: await $(r),
1393
- sigPublicKeyB64: await $(w)
1392
+ ecdhKP: { publicKey: c, privateKey: l },
1393
+ ecdsaKP: { publicKey: x, privateKey: f },
1394
+ publicKeyB64: await M(c),
1395
+ sigPublicKeyB64: await M(x)
1394
1396
  };
1395
1397
  }
1396
1398
  } catch {
1397
1399
  }
1398
- const e = await vt();
1400
+ const e = await kt();
1399
1401
  try {
1400
- const n = await I().exportKey("jwk", e.ecdhKP.publicKey), o = await I().exportKey("jwk", e.ecdhKP.privateKey), r = await I().exportKey("jwk", e.ecdsaKP.publicKey), l = await I().exportKey("jwk", e.ecdsaKP.privateKey);
1401
- (i = globalThis.localStorage) == null || i.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: n, ecdhPriv: o, ecdsaPub: r, ecdsaPriv: l }));
1402
+ const n = 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);
1403
+ (i = globalThis.localStorage) == null || i.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: n, ecdhPriv: o, ecdsaPub: c, ecdsaPriv: l }));
1402
1404
  } catch {
1403
1405
  }
1404
1406
  return e;
1405
1407
  }
1406
- async function kt(s, e) {
1407
- const t = await V(), i = await $(t.publicKey), n = await j(e.identityKey), o = await j(e.signedPrekey), r = e.oneTimePrekey ? await j(e.oneTimePrekey) : null, l = await M(s.privateKey, o), w = await M(t.privateKey, n), u = await M(t.privateKey, o), m = r ? await M(t.privateKey, r) : null, x = ke(l, w, u, ...m ? [m] : []);
1408
- return { sharedKey: await Se(x), ephemeralPublicKey: i };
1408
+ async function St(s, e) {
1409
+ const t = await O(), i = await M(t.publicKey), n = await H(e.identityKey), o = await H(e.signedPrekey), c = e.oneTimePrekey ? await H(e.oneTimePrekey) : null, l = await L(s.privateKey, o), x = await L(t.privateKey, n), f = await L(t.privateKey, o), m = c ? await L(t.privateKey, c) : null, w = ye(l, x, f, ...m ? [m] : []);
1410
+ return { sharedKey: await ge(w), ephemeralPublicKey: i };
1409
1411
  }
1410
- async function St(s, e, t, i, n) {
1411
- const o = await j(t), r = await j(i), l = await M(e.privateKey, o), w = await M(s.privateKey, r), u = await M(e.privateKey, r), m = n ? await M(n.privateKey, r) : null, x = ke(l, w, u, ...m ? [m] : []);
1412
- return Se(x);
1412
+ async function It(s, e, t, i, n) {
1413
+ const o = await H(t), c = await H(i), l = await L(e.privateKey, o), x = await L(s.privateKey, c), f = await L(e.privateKey, c), m = n ? await L(n.privateKey, c) : null, w = ye(l, x, f, ...m ? [m] : []);
1414
+ return ge(w);
1413
1415
  }
1414
- async function M(s, e) {
1415
- return I().deriveBits({ name: "ECDH", public: e }, s, 256);
1416
+ async function L(s, e) {
1417
+ return S().deriveBits({ name: "ECDH", public: e }, s, 256);
1416
1418
  }
1417
- function ke(...s) {
1419
+ function ye(...s) {
1418
1420
  const e = s.reduce((n, o) => n + o.byteLength, 0), t = new Uint8Array(e);
1419
1421
  let i = 0;
1420
1422
  for (const n of s)
1421
1423
  t.set(new Uint8Array(n), i), i += n.byteLength;
1422
1424
  return t.buffer;
1423
1425
  }
1424
- async function Se(s) {
1425
- const e = await I().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
1426
- return I().deriveKey(
1426
+ async function ge(s) {
1427
+ const e = await S().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
1428
+ return S().deriveKey(
1427
1429
  { name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info: new TextEncoder().encode("ObjectChat X3DH v1") },
1428
1430
  e,
1429
1431
  { name: "AES-GCM", length: 256 },
@@ -1432,20 +1434,20 @@ async function Se(s) {
1432
1434
  );
1433
1435
  }
1434
1436
  const Ct = 20;
1435
- class It {
1437
+ class Et {
1436
1438
  constructor(e) {
1437
1439
  // Live ECDH mode state
1438
- a(this, "kp");
1439
- a(this, "shared");
1440
+ r(this, "kp");
1441
+ r(this, "shared");
1440
1442
  // X3DH async mode state
1441
- a(this, "identityKP");
1442
- a(this, "signedPreKP");
1443
- a(this, "signedPrekeyId");
1444
- a(this, "otpKeys", []);
1443
+ r(this, "identityKP");
1444
+ r(this, "signedPreKP");
1445
+ r(this, "signedPrekeyId");
1446
+ r(this, "otpKeys", []);
1445
1447
  // one-time prekeys awaiting matching
1446
- a(this, "x3dhShared");
1448
+ r(this, "x3dhShared");
1447
1449
  // Queued init messages arriving before we could derive (shouldn't happen, but safe)
1448
- a(this, "pendingX3DH");
1450
+ r(this, "pendingX3DH");
1449
1451
  this.storageKey = e;
1450
1452
  }
1451
1453
  get ready() {
@@ -1453,19 +1455,19 @@ class It {
1453
1455
  }
1454
1456
  /** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
1455
1457
  async begin() {
1456
- return this.kp = await bt(this.storageKey), $(this.kp.publicKey);
1458
+ return this.kp = await mt(this.storageKey), M(this.kp.publicKey);
1457
1459
  }
1458
1460
  /** Live ECDH mode: A peer published their key — derive the shared secret. */
1459
1461
  async onPeerKey(e) {
1460
- this.kp && (this.shared = await xt(this.kp.privateKey, e));
1462
+ this.kp && (this.shared = await yt(this.kp.privateKey, e));
1461
1463
  }
1462
1464
  // ── X3DH async mode ────────────────────────────────────────────────────────
1463
1465
  /** X3DH: Generate identity key, signed prekey, and OTP prekeys.
1464
1466
  * Returns the upload frame payload the caller should send to the server. */
1465
1467
  async initX3DH() {
1466
- this.identityKP = await ue(this.storageKey), this.signedPreKP = await V(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1467
- for (let n = 0; n < Ct; n++) this.otpKeys.push(await V());
1468
- const e = await $(this.signedPreKP.publicKey), t = await mt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), i = await Promise.all(this.otpKeys.map((n) => $(n.publicKey)));
1468
+ this.identityKP = await he(this.storageKey), this.signedPreKP = await O(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1469
+ for (let n = 0; n < Ct; n++) this.otpKeys.push(await O());
1470
+ const e = await M(this.signedPreKP.publicKey), t = await vt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), i = await Promise.all(this.otpKeys.map((n) => M(n.publicKey)));
1469
1471
  return {
1470
1472
  identityKey: this.identityKP.publicKeyB64,
1471
1473
  signedPrekey: e,
@@ -1477,8 +1479,8 @@ class It {
1477
1479
  /** X3DH sender: given a recipient's prekey bundle, derive the shared key and
1478
1480
  * return the init message fields to embed in the first encrypted message. */
1479
1481
  async x3dhSendTo(e) {
1480
- this.identityKP || (this.identityKP = await ue(this.storageKey));
1481
- const { sharedKey: t, ephemeralPublicKey: i } = await kt(this.identityKP.ecdhKP, e);
1482
+ this.identityKP || (this.identityKP = await he(this.storageKey));
1483
+ const { sharedKey: t, ephemeralPublicKey: i } = await St(this.identityKP.ecdhKP, e);
1482
1484
  return this.x3dhShared = t, { ephemeralKey: i, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
1483
1485
  }
1484
1486
  /** X3DH recipient: given an init message's sender IK + EK + SPK ID, derive the shared key. */
@@ -1488,7 +1490,7 @@ class It {
1488
1490
  return;
1489
1491
  }
1490
1492
  const n = this.otpKeys.shift();
1491
- this.x3dhShared = await St(this.identityKP.ecdhKP, this.signedPreKP, e, t, n);
1493
+ this.x3dhShared = await It(this.identityKP.ecdhKP, this.signedPreKP, e, t, n);
1492
1494
  }
1493
1495
  /** Flush pending X3DH derivation after initX3DH() completes. */
1494
1496
  async flushPendingX3DH() {
@@ -1516,7 +1518,7 @@ class It {
1516
1518
  const t = this.x3dhShared ?? this.shared;
1517
1519
  if (!t) return { kind: "text", text: "🔒 encrypted" };
1518
1520
  try {
1519
- return { kind: "text", text: await yt(t, e.text, e.iv) };
1521
+ return { kind: "text", text: await bt(t, e.text, e.iv) };
1520
1522
  } catch {
1521
1523
  return { kind: "text", text: "🔒 unable to decrypt" };
1522
1524
  }
@@ -1528,12 +1530,12 @@ class It {
1528
1530
  for (const t of e.messages) t.content = await this.openContent(t.content);
1529
1531
  }
1530
1532
  }
1531
- function Et(s) {
1533
+ function Ut(s) {
1532
1534
  if (s.kind !== "text" || !s.enc) return null;
1533
1535
  const e = s;
1534
1536
  return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
1535
1537
  }
1536
- const we = "objectchat-widget-styles", Ut = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Tt = `
1538
+ const pe = "objectchat-widget-styles", Tt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Pt = `
1537
1539
  .ocw { --ocw-accent:#f5713c; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
1538
1540
  position:relative;
1539
1541
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
@@ -1685,74 +1687,29 @@ const we = "objectchat-widget-styles", Ut = ["👍", "❤️", "😂", "😮", "
1685
1687
  .ocw-cobrowse-clear:hover { border-color:#e74c3c; color:#e74c3c; }
1686
1688
  .ocw-cobrowse-hint { position:absolute; bottom:8px; left:8px; z-index:41; font-size:11px; color:var(--ocw-mut); background:rgba(255,255,255,.9); border-radius:8px; padding:3px 8px; display:none; }
1687
1689
  .ocw-cobrowse-hint.active { display:block; }
1688
- /* ── Chat-app mode (showChatList=true): WhatsApp-style two-screen navigation ── */
1689
- /* Screen A: conversation list — full widget, like WhatsApp's home screen */
1690
- .ocw-screen { position:absolute; inset:0; display:flex; flex-direction:column; background:var(--ocw-bg); transition:transform .22s cubic-bezier(.4,0,.2,1); will-change:transform; }
1691
- .ocw-screen-list { transform:translateX(0); z-index:10; }
1692
- .ocw-screen-chat { transform:translateX(100%); z-index:20; background:var(--ocw-card); }
1693
- .ocw-screen-list.hidden { transform:translateX(-30%); }
1694
- .ocw-screen-chat.visible { transform:translateX(0); }
1695
- /* List header */
1696
- .ocw-cl-head { display:flex; align-items:center; padding:14px 16px 10px; background:var(--ocw-card); border-bottom:1px solid var(--ocw-line); gap:8px; }
1697
- .ocw-cl-title { flex:1; font-size:17px; font-weight:700; color:var(--ocw-ink); }
1698
- .ocw-cl-new { width:34px; height:34px; border-radius:50%; border:none; background:var(--ocw-accent); color:#fff; font-size:20px; cursor:pointer; display:flex; align-items:center; justify-content:center; flex:none; }
1699
- /* Search bar */
1700
- .ocw-cl-search-wrap { padding:8px 12px; background:var(--ocw-card); }
1701
- .ocw-cl-search { width:100%; box-sizing:border-box; border:none; background:var(--ocw-bg); border-radius:20px; padding:8px 14px; font:inherit; font-size:14px; color:var(--ocw-ink); outline:none; }
1702
- /* Section dividers: read / unread */
1703
- .ocw-cl-section { padding:4px 16px 4px; font-size:11px; font-weight:700; color:var(--ocw-mut); letter-spacing:.5px; text-transform:uppercase; background:var(--ocw-bg); }
1704
- /* Conversation row */
1705
- .ocw-cl-row { display:flex; align-items:center; gap:12px; padding:10px 16px; background:var(--ocw-card); border:none; width:100%; text-align:left; cursor:pointer; border-bottom:1px solid var(--ocw-line); transition:background .1s; }
1706
- .ocw-cl-row:hover, .ocw-cl-row:active { background:#faf8f6; }
1707
- .ocw-cl-row.unread { background:var(--ocw-card); }
1708
- /* Avatar circle with initial */
1709
- .ocw-cl-av { width:46px; height:46px; border-radius:50%; background:var(--ocw-accent); color:#fff; font-size:18px; font-weight:700; display:flex; align-items:center; justify-content:center; flex:none; position:relative; }
1710
- .ocw-cl-av img { width:100%; height:100%; border-radius:50%; object-fit:cover; }
1711
- /* Status dot on avatar: green=open, grey=resolved */
1712
- .ocw-cl-status { position:absolute; bottom:1px; right:1px; width:12px; height:12px; border-radius:50%; border:2px solid var(--ocw-card); background:#9b9690; }
1713
- .ocw-cl-status.open { background:#22c55e; }
1714
- .ocw-cl-status.waiting { background:#f59e0b; }
1715
- /* Row content */
1716
- .ocw-cl-body { flex:1; min-width:0; }
1717
- .ocw-cl-name { font-size:15px; font-weight:600; color:var(--ocw-ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-bottom:2px; }
1718
- .ocw-cl-row.unread .ocw-cl-name { font-weight:700; }
1719
- .ocw-cl-preview { font-size:13px; color:var(--ocw-mut); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
1720
- .ocw-cl-row.unread .ocw-cl-preview { color:var(--ocw-ink); }
1721
- /* Right side: time + unread badge */
1722
- .ocw-cl-right { display:flex; flex-direction:column; align-items:flex-end; gap:4px; flex:none; }
1723
- .ocw-cl-time { font-size:11px; color:var(--ocw-mut); }
1724
- .ocw-cl-row.unread .ocw-cl-time { color:var(--ocw-accent); font-weight:600; }
1725
- .ocw-cl-badge { background:var(--ocw-accent); color:#fff; border-radius:999px; font-size:11px; font-weight:700; min-width:20px; height:20px; padding:0 5px; display:flex; align-items:center; justify-content:center; }
1726
- .ocw-cl-body-scroll { flex:1; overflow-y:auto; }
1727
- /* Chat screen back button */
1728
- .ocw-chat-back { background:none; border:none; cursor:pointer; font-size:22px; color:var(--ocw-ink); padding:2px 6px 2px 0; line-height:1; display:none; }
1729
- .ocw-chat-back.show { display:block; }
1690
+
1730
1691
  .ocw-translate-btn { position:absolute; bottom:2px; right:-26px; background:#fff; border:1px solid #e3ded7; border-radius:50%; width:22px; height:22px; font-size:11px; cursor:pointer; color:var(--ocw-mut); display:flex; align-items:center; justify-content:center; opacity:0; transition:opacity .15s; padding:0; }
1731
1692
  .ocw-row.theirs .ocw-translate-btn { right:auto; left:-26px; }
1732
1693
  .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
1733
1694
  .ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
1734
1695
  `;
1735
1696
  function Bt() {
1736
- if (typeof document > "u" || document.getElementById(we)) return;
1697
+ if (typeof document > "u" || document.getElementById(pe)) return;
1737
1698
  const s = document.createElement("style");
1738
- s.id = we, s.textContent = Tt, document.head.appendChild(s);
1699
+ s.id = pe, s.textContent = Pt, document.head.appendChild(s);
1739
1700
  }
1740
- function c(s, e, t) {
1701
+ function a(s, e, t) {
1741
1702
  const i = document.createElement(s);
1742
1703
  return e && (i.className = e), t !== void 0 && (i.textContent = t), i;
1743
1704
  }
1744
- function At(s) {
1705
+ function Kt(s) {
1745
1706
  try {
1746
1707
  return new Date(s).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
1747
1708
  } catch {
1748
1709
  return "";
1749
1710
  }
1750
1711
  }
1751
- function Pt(s) {
1752
- const e = Math.floor((Date.now() - s) / 1e3);
1753
- return e < 60 ? "now" : e < 3600 ? `${Math.floor(e / 60)}m` : e < 86400 ? `${Math.floor(e / 3600)}h` : `${Math.floor(e / 86400)}d`;
1754
- }
1755
- function te(s) {
1712
+ function G(s) {
1756
1713
  var e;
1757
1714
  switch (s.kind) {
1758
1715
  case "text":
@@ -1769,116 +1726,87 @@ function te(s) {
1769
1726
  return `📅 ${s.title} — ${new Date(s.startIso).toLocaleString()}`;
1770
1727
  }
1771
1728
  }
1772
- class Kt {
1729
+ class At {
1730
+ /** Last seq the guest has seen per conversationId — used to compute unread badges. */
1773
1731
  constructor(e, t, i, n = {}) {
1774
- a(this, "scroll");
1775
- a(this, "chips");
1776
- a(this, "typing");
1777
- a(this, "quick");
1778
- a(this, "formHost");
1779
- a(this, "csatPanel");
1780
- a(this, "offlinePanel");
1781
- a(this, "footer");
1782
- a(this, "input");
1783
- a(this, "subjectCard");
1784
- a(this, "e2eBadge");
1785
- a(this, "statusBadge");
1786
- a(this, "headerName");
1787
- a(this, "connStatus");
1788
- a(this, "typingTimer", null);
1789
- a(this, "csatSubmitted", !1);
1732
+ r(this, "scroll");
1733
+ r(this, "chips");
1734
+ r(this, "typing");
1735
+ r(this, "quick");
1736
+ r(this, "formHost");
1737
+ r(this, "csatPanel");
1738
+ r(this, "offlinePanel");
1739
+ r(this, "footer");
1740
+ r(this, "input");
1741
+ r(this, "subjectCard");
1742
+ r(this, "e2eBadge");
1743
+ r(this, "statusBadge");
1744
+ r(this, "headerName");
1745
+ r(this, "connStatus");
1746
+ r(this, "typingTimer", null);
1747
+ r(this, "csatSubmitted", !1);
1790
1748
  // ── Co-browsing (shared whiteboard) ─────────────────────────────────────
1791
- a(this, "cobrowseBtn");
1792
- a(this, "cobrowseCanvas");
1793
- a(this, "cobrowseToolbar");
1794
- a(this, "cobrowseHint");
1795
- a(this, "cobrowseActive", !1);
1796
- a(this, "cobrowseColor", "#f5713c");
1797
- a(this, "lastAnnotationVersion", -1);
1798
- a(this, "storeRef", null);
1799
- a(this, "scrollCleanup", null);
1749
+ r(this, "cobrowseBtn");
1750
+ r(this, "cobrowseCanvas");
1751
+ r(this, "cobrowseToolbar");
1752
+ r(this, "cobrowseHint");
1753
+ r(this, "cobrowseActive", !1);
1754
+ r(this, "cobrowseColor", "#f5713c");
1755
+ r(this, "lastAnnotationVersion", -1);
1756
+ r(this, "storeRef", null);
1757
+ r(this, "scrollCleanup", null);
1800
1758
  // ── Live translation ──────────────────────────────────────────────────-
1801
- a(this, "translationCache", /* @__PURE__ */ new Map());
1802
- a(this, "showingTranslation", /* @__PURE__ */ new Set());
1803
- // ── Chat-app two-screen navigation ──────────────────────────────────────────
1804
- a(this, "listScreen", null);
1805
- a(this, "chatScreen", null);
1806
- a(this, "listBody", null);
1807
- a(this, "listSearch", null);
1808
- a(this, "backBtn", null);
1809
- a(this, "activeChatId", null);
1810
- a(this, "inChatScreen", !1);
1811
- a(this, "allEntries", []);
1812
- /** Last seq the guest has seen per conversationId — used to compute unread badges. */
1813
- a(this, "seenSeq", /* @__PURE__ */ new Map());
1814
- a(this, "seenSeqKey", "");
1815
- /** Fetch the list and re-render it. Called on mount and after switching chats. */
1816
- a(this, "destroyed", !1);
1817
- a(this, "subjectBuilt", !1);
1818
- var b, v, U, A, K, P, D, _, q, X;
1759
+ r(this, "translationCache", /* @__PURE__ */ new Map());
1760
+ r(this, "showingTranslation", /* @__PURE__ */ new Set());
1761
+ r(this, "subjectBuilt", !1);
1762
+ var b, v, C, T, A, P, D, $, _;
1819
1763
  this.root = e, this.me = t, this.h = i, this.cfg = n, Bt(), e.classList.add("ocw"), n.accent && e.style.setProperty("--ocw-accent", n.accent);
1820
- const o = c("div", "ocw-head"), r = c("div", "ocw-avatar");
1764
+ const o = a("div", "ocw-head"), c = a("div", "ocw-avatar");
1821
1765
  if ((b = n.userInfo) != null && b.avatar) {
1822
1766
  const k = document.createElement("img");
1823
- k.src = n.userInfo.avatar, k.alt = n.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", r.append(k);
1767
+ k.src = n.userInfo.avatar, k.alt = n.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", c.append(k);
1824
1768
  } else
1825
- r.textContent = (v = n.userInfo) != null && v.name ? n.userInfo.name[0].toUpperCase() : "🧑";
1826
- o.append(r);
1827
- const l = c("div", "ocw-head-main");
1828
- this.headerName = c("div", "ocw-head-name", ((U = n.subject) == null ? void 0 : U.ownerLabel) ?? ((A = n.subject) == null ? void 0 : A.title) ?? ""), l.append(this.headerName), (K = n.subject) != null && K.subtitle && l.append(c("div", "ocw-head-meta", n.subject.subtitle)), o.append(l), this.statusBadge = c("span", "ocw-badge", ((P = n.subject) == null ? void 0 : P.status) ?? ""), (D = n.subject) != null && D.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = c("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = c("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.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", () => {
1769
+ c.textContent = (v = n.userInfo) != null && v.name ? n.userInfo.name[0].toUpperCase() : "🧑";
1770
+ o.append(c);
1771
+ const l = a("div", "ocw-head-main");
1772
+ this.headerName = a("div", "ocw-head-name", ((C = n.subject) == null ? void 0 : C.ownerLabel) ?? ((T = n.subject) == null ? void 0 : T.title) ?? ""), l.append(this.headerName), (A = n.subject) != null && A.subtitle && l.append(a("div", "ocw-head-meta", n.subject.subtitle)), o.append(l), this.statusBadge = a("span", "ocw-badge", ((P = n.subject) == null ? void 0 : P.status) ?? ""), (D = n.subject) != null && D.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", () => {
1829
1773
  this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
1830
- }), o.append(this.cobrowseBtn), this.h.onListChats && (this.backBtn = c("button", "ocw-chat-back", "←"), this.backBtn.addEventListener("click", () => this.showListScreen()), o.prepend(this.backBtn)), o.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");
1831
- const w = c("div", "ocw-typing-bubble");
1832
- 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");
1774
+ }), 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");
1775
+ const x = a("div", "ocw-typing-bubble");
1776
+ x.append(a("div", "ocw-typing-dot"), a("div", "ocw-typing-dot"), a("div", "ocw-typing-dot")), this.typing.append(a("div", "ocw-dot", "🧑"), x), this.quick = a("div", "ocw-quick");
1833
1777
  for (const k of n.quickReplies ?? []) {
1834
- const E = c("button", void 0, k);
1778
+ const E = a("button", void 0, k);
1835
1779
  E.addEventListener("click", () => this.h.onSend(k)), this.quick.append(E);
1836
1780
  }
1837
- 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…";
1838
- const u = c("button", "ocw-sendbtn", ((_ = n.i18n) == null ? void 0 : _.send) ?? "➤");
1839
- u.addEventListener("click", () => this.flushSend()), this.input.addEventListener("keydown", (k) => {
1781
+ 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…";
1782
+ const f = a("button", "ocw-sendbtn", (($ = n.i18n) == null ? void 0 : $.send) ?? "➤");
1783
+ f.addEventListener("click", () => this.flushSend()), this.input.addEventListener("keydown", (k) => {
1840
1784
  k.isComposing || k.keyCode === 229 || (k.key === "Enter" && !k.shiftKey ? (k.preventDefault(), this.flushSend()) : this.signalTyping());
1841
1785
  });
1842
- const m = c("button", "ocw-attach", "📎");
1786
+ const m = a("button", "ocw-attach", "📎");
1843
1787
  m.title = "Attach image or file";
1844
- const x = document.createElement("input");
1845
- x.type = "file", x.accept = "image/*,.pdf,.txt,.doc,.docx", x.style.display = "none", m.addEventListener("click", () => x.click()), x.addEventListener("change", () => {
1788
+ const w = document.createElement("input");
1789
+ w.type = "file", w.accept = "image/*,.pdf,.txt,.doc,.docx", w.style.display = "none", m.addEventListener("click", () => w.click()), w.addEventListener("change", () => {
1846
1790
  var k;
1847
- (k = x.files) != null && k[0] && this.h.onAttach && this.h.onAttach(x.files[0]), x.value = "";
1791
+ (k = w.files) != null && k[0] && this.h.onAttach && this.h.onAttach(w.files[0]), w.value = "";
1848
1792
  });
1849
- const h = c("div", "ocw-input");
1850
- h.append(m, x, this.input, u);
1851
- const p = c("div", "ocw-footer");
1852
- if (p.innerHTML = ((q = n.i18n) == null ? void 0 : q.poweredBy) !== void 0 ? n.i18n.poweredBy : 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = p, this.h.onListChats) {
1853
- const k = c("div", "ocw-screen ocw-screen-list"), E = c("div", "ocw-cl-head");
1854
- E.append(c("span", "ocw-cl-title", "Messages"));
1855
- const S = c("button", "ocw-cl-new", "+");
1856
- S.title = "New conversation", S.addEventListener("click", () => {
1857
- var d, f;
1858
- (f = (d = this.h).onSwitchChat) == null || f.call(d, { id: "__new__", state: "open", updatedAt: Date.now() });
1859
- }), E.append(S);
1860
- const Y = c("div", "ocw-cl-search-wrap"), z = c("input", "ocw-cl-search");
1861
- z.placeholder = "🔍 Search", z.type = "search", z.addEventListener("input", () => this.renderListRows(this.allEntries, z.value.trim().toLowerCase())), Y.append(z);
1862
- const H = c("div", "ocw-cl-body-scroll");
1863
- H.append(c("div", "ocw-cl-section", "Loading…")), k.append(E, Y, H), e.append(k), this.listScreen = k, this.listBody = H, this.listSearch = z;
1864
- const R = c("div", "ocw-screen ocw-screen-chat");
1865
- R.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, h, this.footer), e.append(R), this.chatScreen = R, n.startOnChat ? (this.inChatScreen = !0, this.listScreen.classList.add("hidden"), this.chatScreen.classList.add("visible"), (X = this.backBtn) == null || X.classList.add("show")) : this.inChatScreen = !1, this.refreshList();
1866
- } else
1867
- e.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, h, this.footer);
1868
- this.cobrowseCanvas = c("canvas", "ocw-cobrowse-canvas"), this.cobrowseToolbar = c("div", "ocw-cobrowse-toolbar");
1793
+ const h = a("div", "ocw-input");
1794
+ h.append(m, w, this.input, f);
1795
+ const p = a("div", "ocw-footer");
1796
+ p.innerHTML = ((_ = n.i18n) == null ? void 0 : _.poweredBy) !== void 0 ? n.i18n.poweredBy : 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = p, 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");
1869
1797
  for (const k of ["#f5713c", "#1c1b1a", "#2563eb", "#16a34a", "#dc2626"]) {
1870
- const E = c("button", "ocw-cobrowse-swatch");
1798
+ const E = a("button", "ocw-cobrowse-swatch");
1871
1799
  E.style.background = k, E.type = "button", k === this.cobrowseColor && E.classList.add("sel"), E.addEventListener("click", () => {
1872
1800
  this.cobrowseColor = k;
1873
- for (const S of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) S.classList.remove("sel");
1801
+ for (const Y of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) Y.classList.remove("sel");
1874
1802
  E.classList.add("sel");
1875
1803
  }), this.cobrowseToolbar.append(E);
1876
1804
  }
1877
- const g = c("button", "ocw-cobrowse-clear", "Clear");
1805
+ const g = a("button", "ocw-cobrowse-clear", "Clear");
1878
1806
  g.addEventListener("click", () => {
1879
1807
  var k, E;
1880
1808
  return (E = (k = this.h).onAnnotateClear) == null ? void 0 : E.call(k);
1881
- }), this.cobrowseToolbar.append(g), 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();
1809
+ }), this.cobrowseToolbar.append(g), 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();
1882
1810
  }
1883
1811
  /** Returns the scroll container so history.ts can attach scroll listeners. */
1884
1812
  getScrollEl() {
@@ -1889,98 +1817,16 @@ class Kt {
1889
1817
  var t;
1890
1818
  (t = this.scrollCleanup) == null || t.call(this), this.scrollCleanup = e;
1891
1819
  }
1892
- /** Load seenSeq from localStorage (keyed by userId+profileId). */
1893
- initSeenSeq(e) {
1894
- this.seenSeqKey = e;
1895
- try {
1896
- const t = localStorage.getItem(`ocw_seen_${e}`);
1897
- if (t) {
1898
- const i = JSON.parse(t);
1899
- for (const [n, o] of Object.entries(i)) this.seenSeq.set(n, o);
1900
- }
1901
- } catch {
1902
- }
1903
- }
1904
- setSeenSeq(e, t) {
1905
- if (this.seenSeq.set(e, Math.max(this.seenSeq.get(e) ?? 0, t)), this.seenSeqKey)
1906
- try {
1907
- const i = {};
1908
- for (const [n, o] of this.seenSeq) i[n] = o;
1909
- localStorage.setItem(`ocw_seen_${this.seenSeqKey}`, JSON.stringify(i));
1910
- } catch {
1911
- }
1912
- }
1913
- /** Call when the widget is unmounted. Disconnects scroll listeners and
1914
- * prevents in-flight fetches from writing to dead DOM. */
1820
+ /** Call when the widget is unmounted. Disconnects scroll listeners. */
1915
1821
  destroy() {
1916
1822
  var e;
1917
- this.destroyed = !0, (e = this.scrollCleanup) == null || e.call(this), this.scrollCleanup = null;
1918
- }
1919
- refreshList() {
1920
- var e, t;
1921
- !this.listBody || this.destroyed || (t = (e = this.h).onListChats) == null || t.call(e).then((i) => {
1922
- var n;
1923
- this.destroyed || (this.allEntries = i, this.renderListRows(i, ((n = this.listSearch) == null ? void 0 : n.value.trim().toLowerCase()) ?? ""));
1924
- }).catch(() => {
1925
- var i;
1926
- this.destroyed || (i = this.listBody) == null || i.replaceChildren(c("div", "ocw-cl-section", "Could not load conversations."));
1927
- });
1823
+ (e = this.scrollCleanup) == null || e.call(this), this.scrollCleanup = null;
1928
1824
  }
1929
1825
  /** Render list rows, optionally filtered by search query. */
1930
- renderListRows(e, t) {
1931
- if (!this.listBody) return;
1932
- const i = t ? e.filter((r) => (r.subjectTitle ?? "General enquiry").toLowerCase().includes(t) || r.state.includes(t)) : e;
1933
- if (!i.length) {
1934
- this.listBody.replaceChildren(c("div", "ocw-cl-section", t ? "No results." : "No conversations yet."));
1935
- return;
1936
- }
1937
- const n = i.filter((r) => this.isUnread(r)).sort((r, l) => l.updatedAt - r.updatedAt), o = i.filter((r) => !this.isUnread(r)).sort((r, l) => l.updatedAt - r.updatedAt);
1938
- if (this.listBody.replaceChildren(), n.length) {
1939
- this.listBody.append(c("div", "ocw-cl-section", `Unread (${n.length})`));
1940
- for (const r of n) this.listBody.append(this.buildRow(r));
1941
- }
1942
- if (o.length) {
1943
- this.listBody.append(c("div", "ocw-cl-section", n.length ? "Read" : "All conversations"));
1944
- for (const r of o) this.listBody.append(this.buildRow(r));
1945
- }
1946
- }
1947
- isUnread(e) {
1948
- return e.id === this.activeChatId ? !1 : (e.lastSeq ?? 0) > (this.seenSeq.get(e.id) ?? 0);
1949
- }
1950
1826
  /** Build a single WhatsApp-style conversation row. */
1951
- buildRow(e) {
1952
- var g;
1953
- const t = this.seenSeq.get(e.id) ?? 0, i = e.lastSeq ?? 0, n = this.isUnread(e) ? Math.max(1, i - t) : 0, o = e.subjectTitle ?? "General enquiry", r = ((g = o[0]) == null ? void 0 : g.toUpperCase()) ?? "?", l = c("button", `ocw-cl-row${n > 0 ? " unread" : ""}`), w = c("div", "ocw-cl-av", r), u = c("div", "ocw-cl-status");
1954
- e.state === "open" ? u.classList.add("open") : e.state === "awaiting_staff" && u.classList.add("waiting"), w.append(u), l.append(w);
1955
- const m = c("div", "ocw-cl-body");
1956
- m.append(c("div", "ocw-cl-name", o));
1957
- const x = {
1958
- open: "Conversation open",
1959
- awaiting_staff: "Waiting for reply…",
1960
- resolved: "Conversation resolved ✓",
1961
- closed: "Conversation closed"
1962
- }, h = e.lastMessage ?? x[e.state] ?? e.state;
1963
- m.append(c("div", "ocw-cl-preview", h)), l.append(m);
1964
- const p = c("div", "ocw-cl-right");
1965
- return p.append(c("div", "ocw-cl-time", Pt(e.updatedAt))), n > 0 && p.append(c("div", "ocw-cl-badge", String(n > 99 ? "99+" : n))), l.append(p), l.addEventListener("click", () => {
1966
- var b, v;
1967
- i > 0 && this.seenSeq.set(e.id, i), this.activeChatId = e.id, this.showChatScreen(), (v = (b = this.h).onSwitchChat) == null || v.call(b, e);
1968
- }), l;
1969
- }
1970
1827
  /** Returns true when the chat screen is visible (not the list). */
1971
- isInChatScreen() {
1972
- return this.inChatScreen;
1973
- }
1974
1828
  /** Navigate to the chat screen (slide list left, slide chat in from right). */
1975
- showChatScreen() {
1976
- var e, t, i;
1977
- this.inChatScreen || (this.inChatScreen = !0, (e = this.listScreen) == null || e.classList.add("hidden"), (t = this.chatScreen) == null || t.classList.add("visible"), (i = this.backBtn) == null || i.classList.add("show"));
1978
- }
1979
1829
  /** Navigate back to the list screen. */
1980
- showListScreen() {
1981
- var e, t, i;
1982
- this.inChatScreen && (this.inChatScreen = !1, (e = this.listScreen) == null || e.classList.remove("hidden"), (t = this.chatScreen) == null || t.classList.remove("visible"), (i = this.backBtn) == null || i.classList.remove("show"), this.refreshList());
1983
- }
1984
1830
  flushSend() {
1985
1831
  const e = this.input.value.trim();
1986
1832
  e && (this.input.value = "", this.h.onTyping(!1), this.h.onSend(e));
@@ -1989,9 +1835,9 @@ class Kt {
1989
1835
  this.h.onTyping(!0), this.typingTimer && clearTimeout(this.typingTimer), this.typingTimer = setTimeout(() => this.h.onTyping(!1), 2e3);
1990
1836
  }
1991
1837
  render(e) {
1992
- var u, m, x;
1838
+ var f, m, w;
1993
1839
  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) {
1994
- const h = (u = this.cfg.subject) == null ? void 0 : u.ownerLabel;
1840
+ const h = (f = this.cfg.subject) == null ? void 0 : f.ownerLabel;
1995
1841
  h && (this.headerName.textContent = h);
1996
1842
  }
1997
1843
  this.chips.replaceChildren();
@@ -2000,19 +1846,19 @@ class Kt {
2000
1846
  for (const h of t) this.chips.append(this.chipEl(h));
2001
1847
  const i = this.scroll.scrollHeight, n = this.scroll.scrollTop;
2002
1848
  if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
2003
- const h = c("div", "ocw-load-more");
1849
+ const h = a("div", "ocw-load-more");
2004
1850
  h.textContent = "↑ Loading earlier messages…", h.style.pointerEvents = "none", this.scroll.append(h);
2005
1851
  }
2006
1852
  let o = 0;
2007
1853
  for (const h of e.messages())
2008
1854
  this.scroll.append(this.messageEl(h, e)), h.senderId !== this.me && h.seq > o && (o = h.seq);
2009
1855
  n > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - i + n : this.scroll.scrollTop = this.scroll.scrollHeight, o > 0 && this.h.onReadUpTo(o);
2010
- const r = [...e.typing];
2011
- this.typing.classList.toggle("active", r.length > 0);
1856
+ const c = [...e.typing];
1857
+ this.typing.classList.toggle("active", c.length > 0);
2012
1858
  const l = this.typing.querySelector(".ocw-typing-bubble");
2013
- l && l.setAttribute("aria-label", r.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", (x = this.root.querySelector(".ocw-input")) == null || x.style.removeProperty("display"));
2014
- const w = ["resolved", "closed", "sold", "issued", "checked_out"];
2015
- 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");
1859
+ 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", (m = this.root.querySelector(".ocw-input")) == null || m.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (w = this.root.querySelector(".ocw-input")) == null || w.style.removeProperty("display"));
1860
+ const x = ["resolved", "closed", "sold", "issued", "checked_out"];
1861
+ this.h.onCsat && !this.csatSubmitted && x.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
2016
1862
  }
2017
1863
  setConnStatus(e) {
2018
1864
  if (e === "open") {
@@ -2023,29 +1869,29 @@ class Kt {
2023
1869
  }
2024
1870
  buildOfflinePanel(e) {
2025
1871
  var l;
2026
- 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."));
2027
- const t = c("div", "ocw-offline-form"), i = c("input", "ocw-offline-input");
1872
+ 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."));
1873
+ const t = a("div", "ocw-offline-form"), i = a("input", "ocw-offline-input");
2028
1874
  i.placeholder = "Your name", i.type = "text";
2029
- const n = c("input", "ocw-offline-input");
1875
+ const n = a("input", "ocw-offline-input");
2030
1876
  n.placeholder = "Your email", n.type = "email";
2031
- const o = c("textarea", "ocw-offline-input");
1877
+ const o = a("textarea", "ocw-offline-input");
2032
1878
  o.placeholder = "Your message", o.rows = 3;
2033
- const r = c("button", "ocw-offline-submit", "Send message");
2034
- r.addEventListener("click", () => {
1879
+ const c = a("button", "ocw-offline-submit", "Send message");
1880
+ c.addEventListener("click", () => {
2035
1881
  !n.value.trim() || !o.value.trim() || (this.h.onSend(`[Offline form]
2036
1882
  Name: ${i.value || "Anonymous"}
2037
1883
  Email: ${n.value}
2038
- Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-thanks", "✓ Message sent! We'll reply to your email.")));
2039
- }), t.append(i, n, o, r), this.offlinePanel.append(t);
1884
+ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-thanks", "✓ Message sent! We'll reply to your email.")));
1885
+ }), t.append(i, n, o, c), this.offlinePanel.append(t);
2040
1886
  }
2041
1887
  buildCsatPanel() {
2042
- this.csatPanel.replaceChildren(), this.csatPanel.append(c("div", "ocw-csat-title", "How did we do?"));
2043
- const e = c("div", "ocw-csat-stars"), t = [];
1888
+ this.csatPanel.replaceChildren(), this.csatPanel.append(a("div", "ocw-csat-title", "How did we do?"));
1889
+ const e = a("div", "ocw-csat-stars"), t = [];
2044
1890
  for (let i = 1; i <= 5; i++) {
2045
- const n = c("button", "ocw-csat-star", "★");
2046
- n.dataset.score = String(i), n.addEventListener("mouseenter", () => t.forEach((o, r) => o.classList.toggle("lit", r < i))), n.addEventListener("mouseleave", () => t.forEach((o) => o.classList.remove("lit"))), n.addEventListener("click", () => {
2047
- var o, r;
2048
- this.csatSubmitted = !0, this.csatPanel.replaceChildren(c("div", "ocw-csat-done", `Thanks for your ${i}★ rating!`)), (r = (o = this.h).onCsat) == null || r.call(o, i);
1891
+ const n = a("button", "ocw-csat-star", "★");
1892
+ n.dataset.score = String(i), n.addEventListener("mouseenter", () => t.forEach((o, c) => o.classList.toggle("lit", c < i))), n.addEventListener("mouseleave", () => t.forEach((o) => o.classList.remove("lit"))), n.addEventListener("click", () => {
1893
+ var o, c;
1894
+ this.csatSubmitted = !0, this.csatPanel.replaceChildren(a("div", "ocw-csat-done", `Thanks for your ${i}★ rating!`)), (c = (o = this.h).onCsat) == null || c.call(o, i);
2049
1895
  }), t.push(n), e.append(n);
2050
1896
  }
2051
1897
  this.csatPanel.append(e);
@@ -2079,21 +1925,21 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2079
1925
  }
2080
1926
  bindCobrowsePointerEvents() {
2081
1927
  let e = !1, t = [];
2082
- const i = (r) => {
2083
- const l = this.cobrowseCanvas.getBoundingClientRect(), w = l.width > 0 ? (r.clientX - l.left) / l.width : 0, u = l.height > 0 ? (r.clientY - l.top) / l.height : 0;
2084
- return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0, u)) };
1928
+ const i = (c) => {
1929
+ const l = this.cobrowseCanvas.getBoundingClientRect(), x = l.width > 0 ? (c.clientX - l.left) / l.width : 0, f = l.height > 0 ? (c.clientY - l.top) / l.height : 0;
1930
+ return { x: Math.min(1, Math.max(0, x)), y: Math.min(1, Math.max(0, f)) };
2085
1931
  }, n = 6e-3;
2086
- this.cobrowseCanvas.addEventListener("pointerdown", (r) => {
2087
- this.cobrowseActive && (e = !0, t = [i(r)], this.cobrowseCanvas.setPointerCapture(r.pointerId));
2088
- }), this.cobrowseCanvas.addEventListener("pointermove", (r) => {
2089
- e && (t.push(i(r)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: n }));
1932
+ this.cobrowseCanvas.addEventListener("pointerdown", (c) => {
1933
+ this.cobrowseActive && (e = !0, t = [i(c)], this.cobrowseCanvas.setPointerCapture(c.pointerId));
1934
+ }), this.cobrowseCanvas.addEventListener("pointermove", (c) => {
1935
+ e && (t.push(i(c)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: n }));
2090
1936
  });
2091
- const o = (r) => {
2092
- var l, w;
1937
+ const o = (c) => {
1938
+ var l, x;
2093
1939
  if (e) {
2094
- 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: n })), t = [];
1940
+ e = !1, t.length > 1 && ((x = (l = this.h).onAnnotate) == null || x.call(l, { id: `an_${Date.now()}_${Math.random().toString(36).slice(2)}`, points: t, color: this.cobrowseColor, width: n })), t = [];
2095
1941
  try {
2096
- this.cobrowseCanvas.releasePointerCapture(r.pointerId);
1942
+ this.cobrowseCanvas.releasePointerCapture(c.pointerId);
2097
1943
  } catch {
2098
1944
  }
2099
1945
  }
@@ -2104,16 +1950,16 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2104
1950
  if (this.subjectBuilt) return;
2105
1951
  const t = e.subject, i = this.cfg.subject, n = (t == null ? void 0 : t.title) ?? (i == null ? void 0 : i.title);
2106
1952
  if (!n) return;
2107
- this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(c("div", "ocw-subject-title", n)), i != null && i.subtitle && this.subjectCard.append(c("div", "ocw-subject-sub", i.subtitle));
2108
- const o = c("div", "ocw-tags");
2109
- if (t) for (const [l, w] of Object.entries(t.fields)) o.append(c("span", "ocw-tag", `${l}: ${w}`));
2110
- else for (const l of (i == null ? void 0 : i.tags) ?? []) o.append(c("span", "ocw-tag", l));
1953
+ this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(a("div", "ocw-subject-title", n)), i != null && i.subtitle && this.subjectCard.append(a("div", "ocw-subject-sub", i.subtitle));
1954
+ const o = a("div", "ocw-tags");
1955
+ if (t) for (const [l, x] of Object.entries(t.fields)) o.append(a("span", "ocw-tag", `${l}: ${x}`));
1956
+ else for (const l of (i == null ? void 0 : i.tags) ?? []) o.append(a("span", "ocw-tag", l));
2111
1957
  o.childNodes.length && this.subjectCard.append(o);
2112
- const r = (t == null ? void 0 : t.state) ?? (i == null ? void 0 : i.status);
2113
- r && (this.statusBadge.textContent = r, this.statusBadge.style.display = "inline-flex");
1958
+ const c = (t == null ? void 0 : t.state) ?? (i == null ? void 0 : i.status);
1959
+ c && (this.statusBadge.textContent = c, this.statusBadge.style.display = "inline-flex");
2114
1960
  }
2115
1961
  chipEl(e) {
2116
- const t = c("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
1962
+ const t = a("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
2117
1963
  return t.dataset.actionId = e.id, t.addEventListener("click", async () => {
2118
1964
  var i;
2119
1965
  e.confirm && !await this.confirm(e.label) || ((i = e.input) != null && i.length ? this.openForm(e) : this.h.onInvoke(e.id));
@@ -2122,99 +1968,99 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2122
1968
  /** In-widget confirmation modal (replaces window.confirm). */
2123
1969
  confirm(e) {
2124
1970
  return new Promise((t) => {
2125
- const i = c("div", "ocw-modal"), n = c("div", "ocw-modal-card");
2126
- n.append(c("div", "ocw-modal-title", e)), n.append(c("div", "ocw-modal-body", `Confirm “${e}”?`));
2127
- const o = c("div", "ocw-modal-actions"), r = c("button", "ocw-modal-cancel", "Cancel"), l = c("button", "ocw-modal-ok", "Confirm"), w = (u) => {
2128
- i.remove(), t(u);
1971
+ const i = a("div", "ocw-modal"), n = a("div", "ocw-modal-card");
1972
+ n.append(a("div", "ocw-modal-title", e)), n.append(a("div", "ocw-modal-body", `Confirm “${e}”?`));
1973
+ const o = a("div", "ocw-modal-actions"), c = a("button", "ocw-modal-cancel", "Cancel"), l = a("button", "ocw-modal-ok", "Confirm"), x = (f) => {
1974
+ i.remove(), t(f);
2129
1975
  };
2130
- r.addEventListener("click", () => w(!1)), l.addEventListener("click", () => w(!0)), i.addEventListener("click", (u) => {
2131
- u.target === i && w(!1);
2132
- }), o.append(r, l), n.append(o), i.append(n), this.root.append(i), l.focus();
1976
+ c.addEventListener("click", () => x(!1)), l.addEventListener("click", () => x(!0)), i.addEventListener("click", (f) => {
1977
+ f.target === i && x(!1);
1978
+ }), o.append(c, l), n.append(o), i.append(n), this.root.append(i), l.focus();
2133
1979
  });
2134
1980
  }
2135
1981
  /** Inline form for a form-effect action: typed inputs (date picker, number,
2136
1982
  * text) rendered above the composer — no browser prompts. */
2137
1983
  openForm(e) {
2138
- var l, w;
1984
+ var l, x;
2139
1985
  this.formHost.replaceChildren();
2140
- const t = c("div", "ocw-form");
2141
- t.append(c("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
1986
+ const t = a("div", "ocw-form");
1987
+ t.append(a("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
2142
1988
  const i = /* @__PURE__ */ new Map();
2143
- for (const u of e.input ?? []) {
2144
- const m = c("label", "ocw-form-row");
2145
- if (m.append(c("span", "ocw-form-lbl", u.label)), u.type === "select" && ((l = u.options) != null && l.length)) {
2146
- const x = c("select", "ocw-form-input");
2147
- u.required || x.append(c("option", void 0, "— select —"));
2148
- for (const h of u.options) {
2149
- const p = c("option");
2150
- p.value = h, p.textContent = h, x.append(p);
1989
+ for (const f of e.input ?? []) {
1990
+ const m = a("label", "ocw-form-row");
1991
+ if (m.append(a("span", "ocw-form-lbl", f.label)), f.type === "select" && ((l = f.options) != null && l.length)) {
1992
+ const w = a("select", "ocw-form-input");
1993
+ f.required || w.append(a("option", void 0, "— select —"));
1994
+ for (const h of f.options) {
1995
+ const p = a("option");
1996
+ p.value = h, p.textContent = h, w.append(p);
2151
1997
  }
2152
- u.required && (x.required = !0), m.append(x), i.set(u.name, x);
1998
+ f.required && (w.required = !0), m.append(w), i.set(f.name, w);
2153
1999
  } else {
2154
- const x = c("input", "ocw-form-input");
2155
- x.type = u.type === "number" ? "number" : u.type === "date" ? "datetime-local" : "text", u.required && (x.required = !0), m.append(x), i.set(u.name, x);
2000
+ const w = a("input", "ocw-form-input");
2001
+ w.type = f.type === "number" ? "number" : f.type === "date" ? "datetime-local" : "text", f.required && (w.required = !0), m.append(w), i.set(f.name, w);
2156
2002
  }
2157
2003
  t.append(m);
2158
2004
  }
2159
- const n = c("div", "ocw-form-actions"), o = c("button", "ocw-form-cancel", "Cancel"), r = c("button", "ocw-form-submit", "Send");
2160
- o.addEventListener("click", () => this.formHost.replaceChildren()), r.addEventListener("click", () => {
2161
- const u = {};
2162
- for (const [m, x] of i) {
2163
- if (x.required && !x.value) {
2164
- x.style.borderColor = "#e5484d";
2005
+ const n = a("div", "ocw-form-actions"), o = a("button", "ocw-form-cancel", "Cancel"), c = a("button", "ocw-form-submit", "Send");
2006
+ o.addEventListener("click", () => this.formHost.replaceChildren()), c.addEventListener("click", () => {
2007
+ const f = {};
2008
+ for (const [m, w] of i) {
2009
+ if (w.required && !w.value) {
2010
+ w.style.borderColor = "#e5484d";
2165
2011
  return;
2166
2012
  }
2167
- u[m] = x.type === "number" ? Number(x.value) : x.value;
2013
+ f[m] = w.type === "number" ? Number(w.value) : w.value;
2168
2014
  }
2169
- this.formHost.replaceChildren(), this.h.onInvoke(e.id, u);
2170
- }), n.append(o, r), t.append(n), this.formHost.append(t), (w = i.values().next().value) == null || w.focus();
2015
+ this.formHost.replaceChildren(), this.h.onInvoke(e.id, f);
2016
+ }), n.append(o, c), t.append(n), this.formHost.append(t), (x = i.values().next().value) == null || x.focus();
2171
2017
  }
2172
2018
  messageEl(e, t) {
2173
- var x;
2019
+ var w;
2174
2020
  if (e.senderRole === "system") {
2175
- const h = c("div", "ocw-sys");
2176
- return h.textContent = e.deletedAt ? "message deleted" : te(e.content), h;
2021
+ const h = a("div", "ocw-sys");
2022
+ return h.textContent = e.deletedAt ? "message deleted" : G(e.content), h;
2177
2023
  }
2178
- const i = e.senderId === this.me, n = !!e.internal, o = c("div", `ocw-row ${n ? "ocw-note mine" : i ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
2179
- !i && !n && o.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
2180
- const r = c("div"), l = c("div", "ocw-bubble-wrap");
2024
+ const i = e.senderId === this.me, n = !!e.internal, o = a("div", `ocw-row ${n ? "ocw-note mine" : i ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
2025
+ !i && !n && o.append(a("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
2026
+ const c = a("div"), l = a("div", "ocw-bubble-wrap");
2181
2027
  if (e.replyToId) {
2182
- const h = c("div", "ocw-reply-to", "↩ replying to a message");
2183
- h.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", r.append(h);
2028
+ const h = a("div", "ocw-reply-to", "↩ replying to a message");
2029
+ h.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", c.append(h);
2184
2030
  }
2185
- const w = c("div", "ocw-bubble");
2186
- let u = null;
2187
- if (e.deletedAt) w.append(c("span", "ocw-deleted", "message deleted"));
2031
+ const x = a("div", "ocw-bubble");
2032
+ let f = null;
2033
+ if (e.deletedAt) x.append(a("span", "ocw-deleted", "message deleted"));
2188
2034
  else if (e.content.kind === "attachment") {
2189
2035
  const h = e.content;
2190
- if ((x = h.mime) != null && x.startsWith("image/")) {
2036
+ if ((w = h.mime) != null && w.startsWith("image/")) {
2191
2037
  const p = document.createElement("img");
2192
- p.src = h.url, p.alt = h.name ?? "image", p.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", p.addEventListener("click", () => window.open(h.url, "_blank")), w.append(p);
2038
+ p.src = h.url, p.alt = h.name ?? "image", p.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", p.addEventListener("click", () => window.open(h.url, "_blank")), x.append(p);
2193
2039
  } else {
2194
2040
  const p = document.createElement("a");
2195
- p.href = h.url, p.target = "_blank", p.rel = "noopener", p.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", p.append(c("span", void 0, "📄"), c("span", void 0, h.name ?? "file")), w.append(p);
2041
+ p.href = h.url, p.target = "_blank", p.rel = "noopener", p.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", p.append(a("span", void 0, "📄"), a("span", void 0, h.name ?? "file")), x.append(p);
2196
2042
  }
2197
2043
  } else if (e.content.kind === "appointment") {
2198
- const h = e.content, p = c("div", "ocw-appt");
2199
- p.append(c("div", "ocw-appt-title", `📅 ${h.title}`)), p.append(c("div", "ocw-appt-time", new Date(h.startIso).toLocaleString() + " – " + new Date(h.endIso).toLocaleTimeString())), h.location && p.append(c("div", "ocw-appt-loc", `📍 ${h.location}`)), h.description && p.append(c("div", "ocw-appt-desc", h.description));
2200
- const g = c("div", "ocw-appt-links"), b = document.createElement("a");
2044
+ const h = e.content, p = a("div", "ocw-appt");
2045
+ p.append(a("div", "ocw-appt-title", `📅 ${h.title}`)), p.append(a("div", "ocw-appt-time", new Date(h.startIso).toLocaleString() + " – " + new Date(h.endIso).toLocaleTimeString())), h.location && p.append(a("div", "ocw-appt-loc", `📍 ${h.location}`)), h.description && p.append(a("div", "ocw-appt-desc", h.description));
2046
+ const g = a("div", "ocw-appt-links"), b = document.createElement("a");
2201
2047
  b.href = h.googleUrl, b.target = "_blank", b.rel = "noopener", b.className = "ocw-appt-btn", b.textContent = "📅 Add to Google Calendar";
2202
2048
  const v = document.createElement("a");
2203
- v.href = h.icalUrl, v.download = `${h.title}.ics`, v.className = "ocw-appt-btn ocw-appt-btn-sec", v.textContent = "🍎 Apple / iCal", g.append(b, v), p.append(g), w.append(p);
2049
+ v.href = h.icalUrl, v.download = `${h.title}.ics`, v.className = "ocw-appt-btn ocw-appt-btn-sec", v.textContent = "🍎 Apple / iCal", g.append(b, v), p.append(g), x.append(p);
2204
2050
  } else
2205
- u = document.createTextNode(te(e.content)), w.append(u), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
2206
- if (l.append(w), !i && !n && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && u) {
2051
+ f = document.createTextNode(G(e.content)), x.append(f), e.editedAt && x.append(a("span", "ocw-edited", "(edited)"));
2052
+ if (l.append(x), !i && !n && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && f) {
2207
2053
  const h = e.content.text;
2208
2054
  if (h.trim()) {
2209
- const p = c("button", "ocw-translate-btn", "🌐");
2055
+ const p = a("button", "ocw-translate-btn", "🌐");
2210
2056
  p.type = "button", p.title = "Translate", p.addEventListener("click", (g) => {
2211
2057
  if (g.stopPropagation(), this.showingTranslation.has(e.id)) {
2212
- this.showingTranslation.delete(e.id), u.textContent = h, p.textContent = "🌐", p.title = "Translate";
2058
+ this.showingTranslation.delete(e.id), f.textContent = h, p.textContent = "🌐", p.title = "Translate";
2213
2059
  return;
2214
2060
  }
2215
2061
  const b = this.translationCache.get(e.id);
2216
2062
  if (b !== void 0) {
2217
- this.showingTranslation.add(e.id), u.textContent = b, p.textContent = "↩", p.title = "Show original";
2063
+ this.showingTranslation.add(e.id), f.textContent = b, p.textContent = "↩", p.title = "Show original";
2218
2064
  return;
2219
2065
  }
2220
2066
  p.textContent = "⏳", this.h.onTranslate(h).then((v) => {
@@ -2224,64 +2070,64 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2224
2070
  }, 1500);
2225
2071
  return;
2226
2072
  }
2227
- this.translationCache.set(e.id, v), this.showingTranslation.add(e.id), u.textContent = v, p.textContent = "↩", p.title = "Show original";
2073
+ this.translationCache.set(e.id, v), this.showingTranslation.add(e.id), f.textContent = v, p.textContent = "↩", p.title = "Show original";
2228
2074
  });
2229
2075
  }), l.append(p);
2230
2076
  }
2231
2077
  }
2232
2078
  if (i && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
2233
- const h = c("div", "ocw-msg-menu");
2079
+ const h = a("div", "ocw-msg-menu");
2234
2080
  if (this.h.onEdit) {
2235
- const p = c("button", void 0, "✏️");
2081
+ const p = a("button", void 0, "✏️");
2236
2082
  p.title = "Edit", p.addEventListener("click", (g) => {
2237
2083
  g.stopPropagation();
2238
- const b = te(e.content), v = prompt("Edit message:", b);
2084
+ const b = G(e.content), v = prompt("Edit message:", b);
2239
2085
  v !== null && v.trim() && v !== b && this.h.onEdit(e.id, v.trim());
2240
2086
  }), h.append(p);
2241
2087
  }
2242
2088
  if (this.h.onDelete) {
2243
- const p = c("button", "del", "🗑");
2089
+ const p = a("button", "del", "🗑");
2244
2090
  p.title = "Delete", p.addEventListener("click", (g) => {
2245
2091
  g.stopPropagation(), this.h.onDelete(e.id);
2246
2092
  }), h.append(p);
2247
2093
  }
2248
2094
  l.append(h);
2249
2095
  }
2250
- if (r.append(l), this.h.onReact && !e.deletedAt && e.seq > 0) {
2251
- const h = c("div", "ocw-react-wrap"), p = c("div", "ocw-react");
2096
+ if (c.append(l), this.h.onReact && !e.deletedAt && e.seq > 0) {
2097
+ const h = a("div", "ocw-react-wrap"), p = a("div", "ocw-react");
2252
2098
  if (e.reactions && Object.keys(e.reactions).length)
2253
- for (const [v, U] of Object.entries(e.reactions)) {
2254
- const A = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${v} ${U.length}`);
2255
- A.addEventListener("click", () => {
2256
- var K, P;
2257
- return (P = (K = this.h).onReact) == null ? void 0 : P.call(K, e.id, v, U.includes(this.me));
2258
- }), p.append(A);
2099
+ for (const [v, C] of Object.entries(e.reactions)) {
2100
+ const T = a("button", `ocw-react-pill${C.includes(this.me) ? " mine" : ""}`, `${v} ${C.length}`);
2101
+ T.addEventListener("click", () => {
2102
+ var A, P;
2103
+ return (P = (A = this.h).onReact) == null ? void 0 : P.call(A, e.id, v, C.includes(this.me));
2104
+ }), p.append(T);
2259
2105
  }
2260
- const g = c("button", "ocw-react-btn", "+"), b = c("div", "ocw-react-picker");
2261
- for (const v of Ut) {
2262
- const U = c("button", void 0, v);
2263
- U.addEventListener("click", (A) => {
2264
- var P, D, _, q;
2265
- A.stopPropagation();
2266
- const K = (D = (P = e.reactions) == null ? void 0 : P[v]) == null ? void 0 : D.includes(this.me);
2267
- (q = (_ = this.h).onReact) == null || q.call(_, e.id, v, !!K), b.style.display = "none";
2268
- }), b.append(U);
2106
+ const g = a("button", "ocw-react-btn", "+"), b = a("div", "ocw-react-picker");
2107
+ for (const v of Tt) {
2108
+ const C = a("button", void 0, v);
2109
+ C.addEventListener("click", (T) => {
2110
+ var P, D, $, _;
2111
+ T.stopPropagation();
2112
+ const A = (D = (P = e.reactions) == null ? void 0 : P[v]) == null ? void 0 : D.includes(this.me);
2113
+ (_ = ($ = this.h).onReact) == null || _.call($, e.id, v, !!A), b.style.display = "none";
2114
+ }), b.append(C);
2269
2115
  }
2270
2116
  b.style.display = "none", g.addEventListener("click", (v) => {
2271
2117
  v.stopPropagation(), b.style.display = b.style.display === "none" ? "flex" : "none";
2272
2118
  }), document.addEventListener("click", () => {
2273
2119
  b.style.display = "none";
2274
- }, { once: !0 }), p.append(g), h.append(p, b), r.append(h);
2275
- } else e.reactions && Object.keys(e.reactions).length && r.append(c("div", "ocw-react", Object.entries(e.reactions).map(([h, p]) => `${h}${p.length}`).join(" ")));
2276
- const m = c("div", "ocw-time ocw-meta", At(e.ts));
2120
+ }, { once: !0 }), p.append(g), h.append(p, b), c.append(h);
2121
+ } else e.reactions && Object.keys(e.reactions).length && c.append(a("div", "ocw-react", Object.entries(e.reactions).map(([h, p]) => `${h}${p.length}`).join(" ")));
2122
+ const m = a("div", "ocw-time ocw-meta", Kt(e.ts));
2277
2123
  if (i && e.status) {
2278
- const h = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Lt(e.status));
2124
+ const h = a("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, zt(e.status));
2279
2125
  m.append(h);
2280
2126
  }
2281
- return i && e.seq > 0 && t.lastReadByOthers >= e.seq && m.append(c("span", "ocw-seen", " · Seen")), r.append(m), o.append(r), o;
2127
+ return i && e.seq > 0 && t.lastReadByOthers >= e.seq && m.append(a("span", "ocw-seen", " · Seen")), c.append(m), o.append(c), o;
2282
2128
  }
2283
2129
  }
2284
- function Lt(s) {
2130
+ function zt(s) {
2285
2131
  switch (s) {
2286
2132
  case "read":
2287
2133
  return "✓✓";
@@ -2293,78 +2139,20 @@ function Lt(s) {
2293
2139
  return "🕓";
2294
2140
  }
2295
2141
  }
2296
- const zt = 20;
2297
- function Ce(s) {
2298
- return s.replace(/^ws/, "http").replace(/\/ws\/?$/, "");
2299
- }
2300
- function Mt(s, e, t, i) {
2301
- const n = `beforeSeq=${t}&limit=${i}`;
2302
- return [
2303
- `${s}/conversations/${e}/messages?${n}`,
2304
- `${s}/conversations/${e}/history?${n}`
2305
- ];
2306
- }
2307
- async function xe(s, e, t, i, n = zt) {
2308
- for (const o of Mt(s, e, i, n))
2309
- try {
2310
- const r = await fetch(o, { headers: { authorization: `Bearer ${t}` } });
2311
- if (!r.ok) continue;
2312
- const l = await r.json();
2313
- return { messages: l.messages ?? [], hasMore: l.hasMore ?? !1 };
2314
- } catch {
2315
- }
2316
- return null;
2317
- }
2318
- async function ge(s, e, t, i, n) {
2319
- const o = Ce(s), r = await xe(o, t, e, Number.MAX_SAFE_INTEGER);
2320
- if (!r || (r.messages.length ? (i.apply({ type: "sync", conversationId: t, messages: r.messages }), i.apply({ type: "history", conversationId: t, messages: [], hasMore: r.hasMore }), n.render(i)) : i.apply({ type: "history", conversationId: t, messages: [], hasMore: !1 }), !r.hasMore)) return;
2321
- let l = !1;
2322
- const w = async () => {
2323
- if (l || !i.hasMoreHistory) return;
2324
- l = !0;
2325
- const h = i.messages()[0];
2326
- if (!h) {
2327
- l = !1;
2328
- return;
2329
- }
2330
- const p = await xe(o, t, e, h.seq);
2331
- p && (i.apply({ type: "history", conversationId: t, messages: p.messages, hasMore: p.hasMore }), n.render(i)), l = !1;
2332
- }, u = n.getScrollEl();
2333
- if (!u) return;
2334
- let m = !1;
2335
- setTimeout(() => {
2336
- m = !0;
2337
- }, 300);
2338
- const x = () => {
2339
- m && u.scrollTop < 80 && i.hasMoreHistory && !l && w();
2340
- };
2341
- u.addEventListener("scroll", x, { passive: !0 }), n.setScrollCleanup(() => u.removeEventListener("scroll", x));
2342
- }
2343
- function $t() {
2344
- const s = "oc_uid";
2345
- try {
2346
- const e = localStorage.getItem(s);
2347
- if (e) return e;
2348
- const t = `g_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
2349
- return localStorage.setItem(s, t), t;
2350
- } catch {
2351
- return `g_${Math.random().toString(36).slice(2)}`;
2352
- }
2353
- }
2354
- function qt(s) {
2355
- var H, R;
2356
- const e = s.token ?? $t();
2357
- let t = new de(e);
2358
- const i = s.subjectId ? `${e}::${s.subjectId}` : e, n = new fe(i);
2359
- let o, r = !1, l = null;
2142
+ function $t(s) {
2143
+ var se, oe, re, ae;
2144
+ const e = s.token ?? Ee();
2145
+ let t = new pt(e);
2146
+ const i = s.subjectId ? `${e}::${s.subjectId}` : e, n = new xt(i);
2147
+ let o, c = !1, l = null;
2360
2148
  !s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
2361
2149
  for (const d of n.load()) t.addOptimistic(d.clientMsgId, d.content);
2362
- let w = null, u = null, m = 0, x = !s.launcher;
2150
+ let x = null, f = null, m = 0, w = !s.launcher;
2363
2151
  if (s.launcher) {
2364
- const f = (s.position ?? "bottom-right").includes("right");
2365
- w = document.createElement("div"), w.style.cssText = `position:fixed;${f ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${f ? "flex-end" : "flex-start"};gap:12px`;
2366
- const y = document.createElement("div"), T = typeof window < "u" && window.innerWidth < 480;
2367
- y.style.cssText = T ? [
2152
+ const u = (s.position ?? "bottom-right").includes("right");
2153
+ x = document.createElement("div"), x.style.cssText = `position:fixed;${u ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${u ? "flex-end" : "flex-start"};gap:12px`;
2154
+ const y = document.createElement("div"), B = typeof window < "u" && window.innerWidth < 480;
2155
+ y.style.cssText = B ? [
2368
2156
  "position:fixed",
2369
2157
  "inset:0",
2370
2158
  "width:100%",
@@ -2387,97 +2175,97 @@ function qt(s) {
2387
2175
  "display:none",
2388
2176
  "flex-direction:column",
2389
2177
  "background:#fff",
2390
- "transform-origin:bottom " + (f ? "right" : "left"),
2178
+ "transform-origin:bottom " + (u ? "right" : "left"),
2391
2179
  "transition:opacity .18s,transform .18s",
2392
2180
  "opacity:0",
2393
2181
  "transform:scale(.95)"
2394
2182
  ].join(";"), s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2395
- const C = document.createElement("button");
2396
- C.style.cssText = [
2183
+ const I = document.createElement("button");
2184
+ I.style.cssText = [
2397
2185
  "width:56px;height:56px;border-radius:50%",
2398
2186
  `background:${s.accent ?? "#4F63F5"}`,
2399
2187
  "color:#fff;border:none;font-size:24px;cursor:pointer",
2400
2188
  "box-shadow:0 4px 16px rgba(0,0,0,.25)",
2401
2189
  "position:relative;flex:none",
2402
2190
  "transition:transform .15s"
2403
- ].join(";"), C.textContent = "💬", C.onmouseenter = () => {
2404
- C.style.transform = "scale(1.08)";
2405
- }, C.onmouseleave = () => {
2406
- C.style.transform = "scale(1)";
2407
- }, u = document.createElement("span"), u.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", C.append(u), w.append(y, C), document.body.append(w);
2408
- const L = (F) => {
2409
- F ? (y.style.display = "flex", requestAnimationFrame(() => {
2191
+ ].join(";"), I.textContent = "💬", I.onmouseenter = () => {
2192
+ I.style.transform = "scale(1.08)";
2193
+ }, I.onmouseleave = () => {
2194
+ I.style.transform = "scale(1)";
2195
+ }, 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", I.append(f), x.append(y, I), document.body.append(x);
2196
+ const z = (R) => {
2197
+ R ? (y.style.display = "flex", requestAnimationFrame(() => {
2410
2198
  y.style.opacity = "1", y.style.transform = "scale(1)";
2411
2199
  })) : (y.style.opacity = "0", y.style.transform = "scale(.95)", setTimeout(() => {
2412
- x || (y.style.display = "none");
2200
+ w || (y.style.display = "none");
2413
2201
  }, 180));
2414
2202
  };
2415
- C.addEventListener("click", () => {
2416
- x = !x, L(x), C.textContent = x ? "✕" : "💬", C.append(u), x && (m = 0, u && (u.style.display = "none"));
2417
- }), document.addEventListener("keydown", (F) => {
2418
- F.key === "Escape" && x && (x = !1, L(!1), C.textContent = "💬", C.append(u));
2203
+ I.addEventListener("click", () => {
2204
+ w = !w, z(w), I.textContent = w ? "✕" : "💬", I.append(f), w && (m = 0, f && (f.style.display = "none"));
2205
+ }), document.addEventListener("keydown", (R) => {
2206
+ R.key === "Escape" && w && (w = !1, z(!1), I.textContent = "💬", I.append(f));
2419
2207
  });
2420
2208
  }
2421
2209
  const h = () => {
2422
- x || (m++, u && (u.textContent = String(m), u.style.display = "flex"));
2210
+ w || (m++, f && (f.textContent = String(m), f.style.display = "flex"));
2423
2211
  }, p = () => {
2424
2212
  try {
2425
- const d = new AudioContext(), f = d.createOscillator(), y = d.createGain();
2426
- f.connect(y), y.connect(d.destination), f.frequency.setValueAtTime(880, d.currentTime), f.frequency.exponentialRampToValueAtTime(440, d.currentTime + 0.15), y.gain.setValueAtTime(0.3, d.currentTime), y.gain.exponentialRampToValueAtTime(1e-3, d.currentTime + 0.3), f.start(), f.stop(d.currentTime + 0.3);
2213
+ const d = new AudioContext(), u = d.createOscillator(), y = d.createGain();
2214
+ u.connect(y), y.connect(d.destination), u.frequency.setValueAtTime(880, d.currentTime), u.frequency.exponentialRampToValueAtTime(440, d.currentTime + 0.15), y.gain.setValueAtTime(0.3, d.currentTime), y.gain.exponentialRampToValueAtTime(1e-3, d.currentTime + 0.3), u.start(), u.stop(d.currentTime + 0.3);
2427
2215
  } catch {
2428
2216
  }
2429
2217
  };
2430
2218
  let g;
2431
- const b = new It(`ocw-e2e-${s.profileId}`);
2219
+ const b = new Et(`ocw-e2e-${s.profileId}`);
2432
2220
  let v = !1;
2433
- const U = [], A = [];
2434
- let K = !1;
2435
- const P = (d, f) => {
2436
- b.sealText(f).then((y) => {
2221
+ const C = [], T = [];
2222
+ let A = !1;
2223
+ const P = (d, u) => {
2224
+ b.sealText(u).then((y) => {
2437
2225
  o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: y });
2438
2226
  });
2439
- }, D = (d, f, y) => {
2440
- b.sealText(f, y).then((T) => {
2441
- o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: T });
2227
+ }, D = (d, u, y) => {
2228
+ b.sealText(u, y).then((B) => {
2229
+ o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: B });
2442
2230
  });
2443
- }, _ = () => {
2444
- for (; U.length; ) {
2445
- const d = U.shift();
2231
+ }, $ = () => {
2232
+ for (; C.length; ) {
2233
+ const d = C.shift();
2446
2234
  P(d.clientMsgId, d.text);
2447
2235
  }
2448
- for (; A.length; ) {
2449
- const d = A.shift();
2236
+ for (; T.length; ) {
2237
+ const d = T.shift();
2450
2238
  P(d.clientMsgId, d.text);
2451
2239
  }
2452
- }, q = (d) => {
2240
+ }, _ = (d) => {
2453
2241
  g.send({ type: "fetchPrekey", targetUserId: d });
2454
- }, X = s.i18n ?? {}, k = ["ar", "he", "fa", "ur"], E = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2455
- k.includes(E) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2456
- const S = new Kt(s.el, e, {
2242
+ }, k = s.i18n ?? {}, E = ["ar", "he", "fa", "ur"], Y = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2243
+ E.includes(Y) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2244
+ const K = new At(s.el, e, {
2457
2245
  onSend(d) {
2458
2246
  if (!o) return;
2459
- const f = `cm_${Math.random().toString(36).slice(2)}`;
2460
- t.addOptimistic(f, { kind: "text", text: d }), S.render(t), t.e2e ? b.ready ? P(f, d) : K ? A.push({ clientMsgId: f, text: d }) : (U.push({ clientMsgId: f, text: d }), t.assignedAgentId && q(t.assignedAgentId)) : (n.add({ clientMsgId: f, content: { kind: "text", text: d }, ts: Date.now() }), g.send({ type: "send", conversationId: o, clientMsgId: f, content: { kind: "text", text: d } }));
2247
+ const u = `cm_${Math.random().toString(36).slice(2)}`;
2248
+ t.addOptimistic(u, { kind: "text", text: d }), K.render(t), t.e2e ? b.ready ? P(u, d) : A ? T.push({ clientMsgId: u, text: d }) : (C.push({ clientMsgId: u, text: d }), t.assignedAgentId && _(t.assignedAgentId)) : (n.add({ clientMsgId: u, content: { kind: "text", text: d }, ts: Date.now() }), g.send({ type: "send", conversationId: o, clientMsgId: u, content: { kind: "text", text: d } }));
2461
2249
  },
2462
2250
  async onAttach(d) {
2463
2251
  if (!o) return;
2464
- const T = `${s.url.replace(/^ws/, "http").replace(/\/ws$/, "")}/upload?name=${encodeURIComponent(d.name)}`, C = `cm_${Math.random().toString(36).slice(2)}`;
2465
- t.addOptimistic(C, { kind: "text", text: `📎 Uploading ${d.name}…` }), S.render(t);
2252
+ const B = `${s.url.replace(/^ws/, "http").replace(/\/ws$/, "")}/upload?name=${encodeURIComponent(d.name)}`, I = `cm_${Math.random().toString(36).slice(2)}`;
2253
+ t.addOptimistic(I, { kind: "text", text: `📎 Uploading ${d.name}…` }), K.render(t);
2466
2254
  try {
2467
- const L = await fetch(T, {
2255
+ const z = await fetch(B, {
2468
2256
  method: "POST",
2469
2257
  headers: { "content-type": d.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
2470
2258
  body: d
2471
2259
  });
2472
- if (!L.ok) throw new Error(`Upload failed: ${L.status}`);
2473
- const { url: F, name: Ie, mime: Ee, size: Ue } = await L.json();
2474
- g.send({ type: "send", conversationId: o, clientMsgId: C, content: { kind: "attachment", url: F, name: Ie, mime: Ee, size: Ue } });
2475
- } catch (L) {
2476
- t.addOptimistic(C, { kind: "text", text: `⚠️ Upload failed: ${L.message}` }), S.render(t);
2260
+ if (!z.ok) throw new Error(`Upload failed: ${z.status}`);
2261
+ const { url: R, name: ve, mime: ke, size: Se } = await z.json();
2262
+ g.send({ type: "send", conversationId: o, clientMsgId: I, content: { kind: "attachment", url: R, name: ve, mime: ke, size: Se } });
2263
+ } catch (z) {
2264
+ t.addOptimistic(I, { kind: "text", text: `⚠️ Upload failed: ${z.message}` }), K.render(t);
2477
2265
  }
2478
2266
  },
2479
- onInvoke(d, f) {
2480
- o && g.send({ type: "invoke", conversationId: o, actionId: d, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...f ? { inputs: f } : {} });
2267
+ onInvoke(d, u) {
2268
+ o && g.send({ type: "invoke", conversationId: o, actionId: d, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...u ? { inputs: u } : {} });
2481
2269
  },
2482
2270
  onTyping(d) {
2483
2271
  o && g.send({ type: "typing", conversationId: o, isTyping: d });
@@ -2490,19 +2278,19 @@ function qt(s) {
2490
2278
  const d = t.messages()[0];
2491
2279
  d && g.send({ type: "history", conversationId: o, beforeSeq: d.seq, limit: 20 });
2492
2280
  },
2493
- onEdit(d, f) {
2494
- o && g.send({ type: "edit", conversationId: o, messageId: d, content: { kind: "text", text: f } });
2281
+ onEdit(d, u) {
2282
+ o && g.send({ type: "edit", conversationId: o, messageId: d, content: { kind: "text", text: u } });
2495
2283
  },
2496
2284
  onDelete(d) {
2497
2285
  o && g.send({ type: "delete", conversationId: o, messageId: d });
2498
2286
  },
2499
- onReact(d, f, y) {
2500
- o && g.send({ type: "react", conversationId: o, messageId: d, emoji: f, remove: y });
2287
+ onReact(d, u, y) {
2288
+ o && g.send({ type: "react", conversationId: o, messageId: d, emoji: u, remove: y });
2501
2289
  },
2502
2290
  onCsat(d) {
2503
2291
  if (!o) return;
2504
- const f = s.url.replace(/^ws/, "http").replace(/\/+$/, "").replace(/:\d+$/, (y) => y);
2505
- fetch(`${f}/conversations/${o}/csat`, {
2292
+ const u = s.url.replace(/^ws/, "http").replace(/\/+$/, "").replace(/:\d+$/, (y) => y);
2293
+ fetch(`${u}/conversations/${o}/csat`, {
2506
2294
  method: "POST",
2507
2295
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${e}` },
2508
2296
  body: JSON.stringify({ score: d })
@@ -2517,152 +2305,110 @@ function qt(s) {
2517
2305
  },
2518
2306
  ...s.translateLang ? {
2519
2307
  async onTranslate(d) {
2520
- const f = s.url.replace(/^ws/, "http").replace(/\/+$/, "");
2308
+ const u = s.url.replace(/^ws/, "http").replace(/\/+$/, "");
2521
2309
  try {
2522
- const y = await fetch(`${f}/translate`, {
2310
+ const y = await fetch(`${u}/translate`, {
2523
2311
  method: "POST",
2524
2312
  headers: { "content-type": "application/json", authorization: `Bearer ${e}` },
2525
2313
  body: JSON.stringify({ text: d, targetLang: s.translateLang })
2526
2314
  });
2527
2315
  if (!y.ok) return null;
2528
- const { translated: T } = await y.json();
2529
- return T;
2316
+ const { translated: B } = await y.json();
2317
+ return B;
2530
2318
  } catch {
2531
2319
  return null;
2532
2320
  }
2533
2321
  }
2534
- } : {},
2535
- ...s.showChatList ? {
2536
- async onListChats() {
2537
- const d = Ce(s.url);
2538
- try {
2539
- const f = await fetch(`${d}/conversations/mine?profileId=${encodeURIComponent(s.profileId)}`, {
2540
- headers: { authorization: `Bearer ${e}` }
2541
- });
2542
- return f.ok ? (await f.json()).conversations ?? [] : [];
2543
- } catch {
2544
- return [];
2545
- }
2546
- },
2547
- onSwitchChat(d) {
2548
- if (!d.id || d.id === "__new__") return;
2549
- g == null || g.close(), o = void 0, r = !1, t = new de(e);
2550
- const f = d.subjectId ? `${e}::${d.subjectId}` : e, y = new fe(f);
2551
- for (const C of y.load()) t.addOptimistic(C.clientMsgId, C.content);
2552
- const T = {
2553
- type: "open",
2554
- profileId: s.profileId,
2555
- ...d.subjectId ? { subjectId: d.subjectId } : {},
2556
- ...typeof location < "u" ? { pageUrl: location.href } : {},
2557
- ...typeof document < "u" && document.title ? { pageTitle: document.title } : {}
2558
- };
2559
- g = new he({
2560
- url: s.url,
2561
- token: e,
2562
- open: T,
2563
- getCursor: () => t.highestSeq(),
2564
- onStatusChange: (C) => S.setConnStatus(C),
2565
- onFrame(C) {
2566
- if (C.type === "opened") {
2567
- const L = o === void 0;
2568
- o = C.conversation.id, L && (ge(s.url, e, o, t, S), S.showChatScreen());
2569
- }
2570
- (async () => (t.apply(C), S.render(t), o && S.setSeenSeq(o, t.highestSeq())))();
2571
- }
2572
- }), g.connect(), S.render(t);
2573
- }
2574
2322
  } : {}
2575
2323
  }, {
2576
2324
  ...s.subject ? { subject: s.subject } : {},
2577
2325
  ...s.quickReplies ? { quickReplies: s.quickReplies } : {},
2578
2326
  ...s.accent ? { accent: s.accent } : {},
2579
- ...(H = s.user) != null && H.name || (R = s.user) != null && R.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2580
- i18n: X,
2581
- // Start directly on chat screen when a specific conversation is known upfront
2582
- ...s.showChatList && s.subjectId ? { startOnChat: !0 } : {}
2583
- }), Y = {
2327
+ ...(se = s.user) != null && se.name || (oe = s.user) != null && oe.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2328
+ i18n: k
2329
+ }), be = {
2584
2330
  type: "open",
2585
2331
  profileId: s.profileId,
2586
2332
  ...s.subjectId ? { subjectId: s.subjectId } : {},
2587
- // Auto-capture the page context so agents know where the guest is browsing.
2588
- // This is pure display metadata — it never affects identity or access.
2589
2333
  ...typeof location < "u" ? { pageUrl: location.href } : {},
2590
- ...typeof document < "u" && document.title ? { pageTitle: document.title } : {}
2591
- }, z = (d) => {
2592
- const f = s.user;
2593
- if (!f || !f.name && !f.email && !f.avatar && !f.meta) return;
2334
+ ...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
2335
+ // Pass subject display info so the server can persist it to the Subject record.
2336
+ // This is how listingTitle and listingMeta get saved without a separate API call.
2337
+ ...(re = s.subject) != null && re.title ? { subjectTitle: s.subject.title } : {},
2338
+ ...(ae = s.subject) != null && ae.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2339
+ }, me = (d) => {
2340
+ const u = s.user;
2341
+ if (!u || !u.name && !u.email && !u.avatar && !u.meta) return;
2594
2342
  const y = [];
2595
- if (f.name && y.push(`Name: ${f.name}`), f.email && y.push(`Email: ${f.email}`), f.avatar && y.push(`Avatar: ${f.avatar}`), f.meta) for (const [T, C] of Object.entries(f.meta)) y.push(`${T}: ${C}`);
2343
+ if (u.name && y.push(`Name: ${u.name}`), u.email && y.push(`Email: ${u.email}`), u.avatar && y.push(`Avatar: ${u.avatar}`), u.meta) for (const [B, I] of Object.entries(u.meta)) y.push(`${B}: ${I}`);
2596
2344
  g.send({ type: "note", conversationId: d, clientMsgId: `ui_${Date.now()}`, text: `[User info]
2597
2345
  ${y.join(`
2598
2346
  `)}` });
2599
2347
  };
2600
- return g = new he({
2348
+ return g = new ut({
2601
2349
  url: s.url,
2602
2350
  token: e,
2603
- open: Y,
2351
+ open: be,
2604
2352
  getCursor: () => t.highestSeq(),
2605
- onStatusChange: (d) => S.setConnStatus(d),
2353
+ onStatusChange: (d) => K.setConnStatus(d),
2606
2354
  onFrame(d) {
2607
2355
  if (d.type === "opened") {
2608
- const f = o === void 0;
2609
- if (o = d.conversation.id, !r) {
2610
- r = !0;
2356
+ const u = o === void 0;
2357
+ if (o = d.conversation.id, !c) {
2358
+ c = !0;
2611
2359
  for (const y of n.load())
2612
2360
  g.send({ type: "send", conversationId: o, clientMsgId: y.clientMsgId, content: y.content });
2613
2361
  }
2614
- f && (ge(s.url, e, o, t, S), d.conversation.lastSeq === 0 && z(o), s.showChatList && s.subjectId && S.showChatScreen(), S.refreshList());
2362
+ u && (Ue(s.url, e, o, t, K), d.conversation.lastSeq === 0 && me(o));
2615
2363
  }
2616
2364
  if (d.type === "ack" && n.remove(d.clientMsgId), d.type === "prekeyBundle") {
2617
- d.bundle && (K = !0, b.x3dhSendTo(d.bundle).then((f) => {
2618
- const y = [...U.splice(0), ...A.splice(0)];
2619
- for (const T of y) D(T.clientMsgId, T.text, f);
2620
- S.render(t);
2365
+ d.bundle && (A = !0, b.x3dhSendTo(d.bundle).then((u) => {
2366
+ const y = [...C.splice(0), ...T.splice(0)];
2367
+ for (const B of y) D(B.clientMsgId, B.text, u);
2368
+ K.render(t);
2621
2369
  }));
2622
2370
  return;
2623
2371
  }
2624
2372
  if (d.type === "message" && t.e2e) {
2625
- const f = Et(d.message.content);
2626
- if (f && !b.ready) {
2627
- b.x3dhReceiveFrom(f.x3dhIK, f.x3dhEK, f.x3dhSPK).then(async () => {
2628
- await b.openFrame(d), t.apply(d), S.render(t);
2373
+ const u = Ut(d.message.content);
2374
+ if (u && !b.ready) {
2375
+ b.x3dhReceiveFrom(u.x3dhIK, u.x3dhEK, u.x3dhSPK).then(async () => {
2376
+ await b.openFrame(d), t.apply(d), K.render(t);
2629
2377
  });
2630
2378
  return;
2631
2379
  }
2632
2380
  }
2633
2381
  if (d.type === "peerkey") {
2634
2382
  b.onPeerKey(d.key).then(() => {
2635
- _(), S.render(t);
2383
+ $(), K.render(t);
2636
2384
  });
2637
2385
  return;
2638
2386
  }
2639
2387
  (async () => {
2640
- if (t.e2e && await b.openFrame(d), t.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (s.showChatList && S.isInChatScreen() || h(), p()), t.e2e && o && !v) {
2388
+ if (t.e2e && await b.openFrame(d), t.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (h(), p()), t.e2e && o && !v) {
2641
2389
  v = !0;
2642
- const f = await b.initX3DH();
2643
- g.send({ type: "uploadPrekeys", ...f });
2390
+ const u = await b.initX3DH();
2391
+ g.send({ type: "uploadPrekeys", ...u });
2644
2392
  const y = await b.begin();
2645
2393
  g.send({ type: "pubkey", conversationId: o, key: y });
2646
2394
  }
2647
- S.render(t), o && S.setSeenSeq(o, t.highestSeq());
2395
+ K.render(t);
2648
2396
  })();
2649
2397
  }
2650
- }), s.showChatList && S.initSeenSeq(`${s.profileId}_${e.slice(-8)}`), s.showChatList && !s.subjectId ? (l = { close: () => {
2651
- w == null || w.remove(), S.destroy();
2652
- } }, l) : (g.connect(), S.render(t), l = { close: () => {
2653
- g.close(), w == null || w.remove(), S.destroy();
2654
- } }, l);
2398
+ }), g.connect(), K.render(t), l = { close: () => {
2399
+ g.close(), x == null || x.remove(), K.destroy();
2400
+ } }, l;
2655
2401
  }
2656
2402
  export {
2657
- de as ChatStore,
2658
- he as ConnectionManager,
2659
- It as E2ESession,
2660
- fe as PersistentOutbox,
2661
- Kt as Renderer,
2662
- _t as asConversationId,
2663
- Et as extractX3DHInit,
2664
- Ce as httpBaseFromWsUrl,
2665
- qt as mount,
2666
- ge as restoreHistory
2403
+ pt as ChatStore,
2404
+ ut as ConnectionManager,
2405
+ Et as E2ESession,
2406
+ xt as PersistentOutbox,
2407
+ At as Renderer,
2408
+ Dt as asConversationId,
2409
+ Ut as extractX3DHInit,
2410
+ Rt as httpBaseFromWsUrl,
2411
+ $t as mount,
2412
+ Ue as restoreHistory
2667
2413
  };
2668
2414
  //# sourceMappingURL=index.js.map