@paramms/chat-widget 1.0.22 → 1.0.24

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,10 +1,10 @@
1
- var Be = Object.defineProperty;
2
- var Ke = (s, e, t) => e in s ? Be(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var r = (s, e, t) => Ke(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { p as Ae, r as ze, a as Le } from "./uid.js";
5
- import { h as Xt } from "./uid.js";
6
- const qt = (s) => s;
7
- function Me(s) {
1
+ var Le = Object.defineProperty;
2
+ var Me = (s, e, t) => e in s ? Le(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var r = (s, e, t) => Me(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { p as De, r as _e, a as $e } from "./uid.js";
5
+ import { h as Qt } from "./uid.js";
6
+ const Wt = (s) => s;
7
+ function He(s) {
8
8
  const e = s.length;
9
9
  let t = 0, i = 0;
10
10
  for (; i < e; ) {
@@ -26,7 +26,7 @@ function Me(s) {
26
26
  }
27
27
  return t;
28
28
  }
29
- function De(s, e, t) {
29
+ function Re(s, e, t) {
30
30
  const i = s.length;
31
31
  let n = t, o = 0;
32
32
  for (; o < i; ) {
@@ -48,15 +48,15 @@ function De(s, e, t) {
48
48
  e[n++] = a & 63 | 128;
49
49
  }
50
50
  }
51
- const _e = new TextEncoder(), $e = 50;
52
- function He(s, e, t) {
53
- _e.encodeInto(s, e.subarray(t));
51
+ const Fe = new TextEncoder(), je = 50;
52
+ function qe(s, e, t) {
53
+ Fe.encodeInto(s, e.subarray(t));
54
54
  }
55
- function Re(s, e, t) {
56
- s.length > $e ? He(s, e, t) : De(s, e, t);
55
+ function Oe(s, e, t) {
56
+ s.length > je ? qe(s, e, t) : Re(s, e, t);
57
57
  }
58
- const Fe = 4096;
59
- function ye(s, e, t) {
58
+ const Ne = 4096;
59
+ function ve(s, e, t) {
60
60
  let i = e;
61
61
  const n = i + t, o = [];
62
62
  let a = "";
@@ -76,19 +76,19 @@ function ye(s, e, t) {
76
76
  f > 65535 && (f -= 65536, o.push(f >>> 10 & 1023 | 55296), f = 56320 | f & 1023), o.push(f);
77
77
  } else
78
78
  o.push(d);
79
- o.length >= Fe && (a += String.fromCharCode(...o), o.length = 0);
79
+ o.length >= Ne && (a += String.fromCharCode(...o), o.length = 0);
80
80
  }
81
81
  return o.length > 0 && (a += String.fromCharCode(...o)), a;
82
82
  }
83
- const je = new TextDecoder(), qe = 200;
84
- function Oe(s, e, t) {
83
+ const Ve = new TextDecoder(), We = 200;
84
+ function Xe(s, e, t) {
85
85
  const i = s.subarray(e, e + t);
86
- return je.decode(i);
86
+ return Ve.decode(i);
87
87
  }
88
- function Ne(s, e, t) {
89
- return t > qe ? Oe(s, e, t) : ye(s, e, t);
88
+ function Ye(s, e, t) {
89
+ return t > We ? Xe(s, e, t) : ve(s, e, t);
90
90
  }
91
- class X {
91
+ class J {
92
92
  constructor(e, t) {
93
93
  r(this, "type");
94
94
  r(this, "data");
@@ -106,27 +106,27 @@ class z extends Error {
106
106
  });
107
107
  }
108
108
  }
109
- const j = 4294967295;
110
- function Ve(s, e, t) {
109
+ const q = 4294967295;
110
+ function Je(s, e, t) {
111
111
  const i = t / 4294967296, n = t;
112
112
  s.setUint32(e, i), s.setUint32(e + 4, n);
113
113
  }
114
- function ge(s, e, t) {
114
+ function ke(s, e, t) {
115
115
  const i = Math.floor(t / 4294967296), n = t;
116
116
  s.setUint32(e, i), s.setUint32(e + 4, n);
117
117
  }
118
- function be(s, e) {
118
+ function Se(s, e) {
119
119
  const t = s.getInt32(e), i = s.getUint32(e + 4);
120
120
  return t * 4294967296 + i;
121
121
  }
122
- function We(s, e) {
122
+ function Ge(s, e) {
123
123
  const t = s.getUint32(e), i = s.getUint32(e + 4);
124
124
  return t * 4294967296 + i;
125
125
  }
126
- const Xe = -1, Ye = 4294967296 - 1, Je = 17179869184 - 1;
127
- function Ge({ sec: s, nsec: e }) {
128
- if (s >= 0 && e >= 0 && s <= Je)
129
- if (e === 0 && s <= Ye) {
126
+ const Qe = -1, Ze = 4294967296 - 1, et = 17179869184 - 1;
127
+ function tt({ sec: s, nsec: e }) {
128
+ if (s >= 0 && e >= 0 && s <= et)
129
+ if (e === 0 && s <= Ze) {
130
130
  const t = new Uint8Array(4);
131
131
  return new DataView(t.buffer).setUint32(0, s), t;
132
132
  } else {
@@ -135,24 +135,24 @@ function Ge({ sec: s, nsec: e }) {
135
135
  }
136
136
  else {
137
137
  const t = new Uint8Array(12), i = new DataView(t.buffer);
138
- return i.setUint32(0, e), ge(i, 4, s), t;
138
+ return i.setUint32(0, e), ke(i, 4, s), t;
139
139
  }
140
140
  }
141
- function Qe(s) {
141
+ function nt(s) {
142
142
  const e = s.getTime(), t = Math.floor(e / 1e3), i = (e - t * 1e3) * 1e6, n = Math.floor(i / 1e9);
143
143
  return {
144
144
  sec: t + n,
145
145
  nsec: i - n * 1e9
146
146
  };
147
147
  }
148
- function Ze(s) {
148
+ function it(s) {
149
149
  if (s instanceof Date) {
150
- const e = Qe(s);
151
- return Ge(e);
150
+ const e = nt(s);
151
+ return tt(e);
152
152
  } else
153
153
  return null;
154
154
  }
155
- function et(s) {
155
+ function st(s) {
156
156
  const e = new DataView(s.buffer, s.byteOffset, s.byteLength);
157
157
  switch (s.byteLength) {
158
158
  case 4:
@@ -162,22 +162,22 @@ function et(s) {
162
162
  return { sec: n, nsec: o };
163
163
  }
164
164
  case 12: {
165
- const t = be(e, 4), i = e.getUint32(0);
165
+ const t = Se(e, 4), i = e.getUint32(0);
166
166
  return { sec: t, nsec: i };
167
167
  }
168
168
  default:
169
169
  throw new z(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`);
170
170
  }
171
171
  }
172
- function tt(s) {
173
- const e = et(s);
172
+ function ot(s) {
173
+ const e = st(s);
174
174
  return new Date(e.sec * 1e3 + e.nsec / 1e6);
175
175
  }
176
- const nt = {
177
- type: Xe,
178
- encode: Ze,
179
- decode: tt
180
- }, G = class G {
176
+ const rt = {
177
+ type: Qe,
178
+ encode: it,
179
+ decode: ot
180
+ }, ee = class ee {
181
181
  constructor() {
182
182
  // ensures ExtensionCodecType<X> matches ExtensionCodec<X>
183
183
  // this will make type errors a lot more clear
@@ -189,7 +189,7 @@ const nt = {
189
189
  // custom extensions
190
190
  r(this, "encoders", []);
191
191
  r(this, "decoders", []);
192
- this.register(nt);
192
+ this.register(rt);
193
193
  }
194
194
  register({ type: e, encode: t, decode: i }) {
195
195
  if (e >= 0)
@@ -206,7 +206,7 @@ const nt = {
206
206
  const o = n(e, t);
207
207
  if (o != null) {
208
208
  const a = -1 - i;
209
- return new X(a, o);
209
+ return new J(a, o);
210
210
  }
211
211
  }
212
212
  }
@@ -216,27 +216,27 @@ const nt = {
216
216
  const o = n(e, t);
217
217
  if (o != null) {
218
218
  const a = i;
219
- return new X(a, o);
219
+ return new J(a, o);
220
220
  }
221
221
  }
222
222
  }
223
- return e instanceof X ? e : null;
223
+ return e instanceof J ? e : null;
224
224
  }
225
225
  decode(e, t, i) {
226
226
  const n = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
227
- return n ? n(e, t, i) : new X(t, e);
227
+ return n ? n(e, t, i) : new J(t, e);
228
228
  }
229
229
  };
230
- r(G, "defaultCodec", new G());
231
- let Y = G;
232
- function it(s) {
230
+ r(ee, "defaultCodec", new ee());
231
+ let Q = ee;
232
+ function at(s) {
233
233
  return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
234
234
  }
235
- function te(s) {
236
- return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) : it(s) ? new Uint8Array(s) : Uint8Array.from(s);
235
+ function se(s) {
236
+ return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) : at(s) ? new Uint8Array(s) : Uint8Array.from(s);
237
237
  }
238
- const st = 100, ot = 2048;
239
- class se {
238
+ const ct = 100, dt = 2048;
239
+ class ae {
240
240
  constructor(e) {
241
241
  r(this, "extensionCodec");
242
242
  r(this, "context");
@@ -251,10 +251,10 @@ class se {
251
251
  r(this, "view");
252
252
  r(this, "bytes");
253
253
  r(this, "entered", !1);
254
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? st, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? ot, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
254
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Q.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) ?? ct, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? dt, 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);
255
255
  }
256
256
  clone() {
257
- return new se({
257
+ return new ae({
258
258
  extensionCodec: this.extensionCodec,
259
259
  context: this.context,
260
260
  useBigInt64: this.useBigInt64,
@@ -336,8 +336,8 @@ class se {
336
336
  throw new Error(`Too long string: ${e} bytes in UTF-8`);
337
337
  }
338
338
  encodeString(e) {
339
- const i = Me(e);
340
- this.ensureBufferSizeToWrite(5 + i), this.writeStringHeader(i), Re(e, this.bytes, this.pos), this.pos += i;
339
+ const i = He(e);
340
+ this.ensureBufferSizeToWrite(5 + i), this.writeStringHeader(i), Oe(e, this.bytes, this.pos), this.pos += i;
341
341
  }
342
342
  encodeObject(e, t) {
343
343
  const i = this.extensionCodec.tryToEncode(e, this.context);
@@ -362,7 +362,7 @@ class se {
362
362
  this.writeU8(198), this.writeU32(t);
363
363
  else
364
364
  throw new Error(`Too large binary: ${t}`);
365
- const i = te(e);
365
+ const i = se(e);
366
366
  this.writeU8a(i);
367
367
  }
368
368
  encodeArray(e, t) {
@@ -459,10 +459,10 @@ class se {
459
459
  this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
460
460
  }
461
461
  writeU64(e) {
462
- this.ensureBufferSizeToWrite(8), Ve(this.view, this.pos, e), this.pos += 8;
462
+ this.ensureBufferSizeToWrite(8), Je(this.view, this.pos, e), this.pos += 8;
463
463
  }
464
464
  writeI64(e) {
465
- this.ensureBufferSizeToWrite(8), ge(this.view, this.pos, e), this.pos += 8;
465
+ this.ensureBufferSizeToWrite(8), ke(this.view, this.pos, e), this.pos += 8;
466
466
  }
467
467
  writeBigUint64(e) {
468
468
  this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
@@ -471,15 +471,15 @@ class se {
471
471
  this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
472
472
  }
473
473
  }
474
- function rt(s, e) {
475
- return new se(e).encodeSharedRef(s);
474
+ function lt(s, e) {
475
+ return new ae(e).encodeSharedRef(s);
476
476
  }
477
- function Z(s) {
477
+ function ne(s) {
478
478
  return `${s < 0 ? "-" : ""}0x${Math.abs(s).toString(16).padStart(2, "0")}`;
479
479
  }
480
- const at = 16, ct = 16;
481
- class dt {
482
- constructor(e = at, t = ct) {
480
+ const ht = 16, pt = 16;
481
+ class ut {
482
+ constructor(e = ht, t = pt) {
483
483
  r(this, "hit", 0);
484
484
  r(this, "miss", 0);
485
485
  r(this, "caches");
@@ -512,16 +512,16 @@ class dt {
512
512
  if (n != null)
513
513
  return this.hit++, n;
514
514
  this.miss++;
515
- const o = ye(e, t, i), a = Uint8Array.prototype.slice.call(e, t, t + i);
515
+ const o = ve(e, t, i), a = Uint8Array.prototype.slice.call(e, t, t + i);
516
516
  return this.store(a, o), o;
517
517
  }
518
518
  }
519
- const ne = "array", O = "map_key", me = "map_value", lt = (s) => {
519
+ const oe = "array", N = "map_key", Ie = "map_value", ft = (s) => {
520
520
  if (typeof s == "string" || typeof s == "number")
521
521
  return s;
522
522
  throw new z("The type of key must be string or number but " + typeof s);
523
523
  };
524
- class ht {
524
+ class wt {
525
525
  constructor() {
526
526
  r(this, "stack", []);
527
527
  r(this, "stackHeadPosition", -1);
@@ -534,11 +534,11 @@ class ht {
534
534
  }
535
535
  pushArrayState(e) {
536
536
  const t = this.getUninitializedStateFromPool();
537
- t.type = ne, t.position = 0, t.size = e, t.array = new Array(e);
537
+ t.type = oe, t.position = 0, t.size = e, t.array = new Array(e);
538
538
  }
539
539
  pushMapState(e) {
540
540
  const t = this.getUninitializedStateFromPool();
541
- t.type = O, t.readCount = 0, t.size = e, t.map = {};
541
+ t.type = N, t.readCount = 0, t.size = e, t.map = {};
542
542
  }
543
543
  getUninitializedStateFromPool() {
544
544
  if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
@@ -558,11 +558,11 @@ class ht {
558
558
  release(e) {
559
559
  if (this.stack[this.stackHeadPosition] !== e)
560
560
  throw new Error("Invalid stack state. Released state is not on top of the stack.");
561
- if (e.type === ne) {
561
+ if (e.type === oe) {
562
562
  const i = e;
563
563
  i.size = 0, i.array = void 0, i.position = 0, i.type = void 0;
564
564
  }
565
- if (e.type === O || e.type === me) {
565
+ if (e.type === N || e.type === Ie) {
566
566
  const i = e;
567
567
  i.size = 0, i.map = void 0, i.readCount = 0, i.type = void 0;
568
568
  }
@@ -572,15 +572,15 @@ class ht {
572
572
  this.stack.length = 0, this.stackHeadPosition = -1;
573
573
  }
574
574
  }
575
- const q = -1, oe = new DataView(new ArrayBuffer(0)), pt = new Uint8Array(oe.buffer);
575
+ const O = -1, ce = new DataView(new ArrayBuffer(0)), xt = new Uint8Array(ce.buffer);
576
576
  try {
577
- oe.getInt8(0);
577
+ ce.getInt8(0);
578
578
  } catch (s) {
579
579
  if (!(s instanceof RangeError))
580
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");
581
581
  }
582
- const pe = new RangeError("Insufficient data"), ut = new dt();
583
- class re {
582
+ const we = new RangeError("Insufficient data"), yt = new ut();
583
+ class de {
584
584
  constructor(e) {
585
585
  r(this, "extensionCodec");
586
586
  r(this, "context");
@@ -595,15 +595,15 @@ class re {
595
595
  r(this, "mapKeyConverter");
596
596
  r(this, "totalPos", 0);
597
597
  r(this, "pos", 0);
598
- r(this, "view", oe);
599
- r(this, "bytes", pt);
600
- r(this, "headByte", q);
601
- r(this, "stack", new ht());
598
+ r(this, "view", ce);
599
+ r(this, "bytes", xt);
600
+ r(this, "headByte", O);
601
+ r(this, "stack", new wt());
602
602
  r(this, "entered", !1);
603
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? j, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? j, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? j, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? j, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? j, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : ut, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? lt;
603
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Q.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? q, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? q, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? q, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? q, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? q, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : yt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? ft;
604
604
  }
605
605
  clone() {
606
- return new re({
606
+ return new de({
607
607
  extensionCodec: this.extensionCodec,
608
608
  context: this.context,
609
609
  useBigInt64: this.useBigInt64,
@@ -617,17 +617,17 @@ class re {
617
617
  });
618
618
  }
619
619
  reinitializeState() {
620
- this.totalPos = 0, this.headByte = q, this.stack.reset();
620
+ this.totalPos = 0, this.headByte = O, this.stack.reset();
621
621
  }
622
622
  setBuffer(e) {
623
- const t = te(e);
623
+ const t = se(e);
624
624
  this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
625
625
  }
626
626
  appendBuffer(e) {
627
- if (this.headByte === q && !this.hasRemaining(1))
627
+ if (this.headByte === O && !this.hasRemaining(1))
628
628
  this.setBuffer(e);
629
629
  else {
630
- const t = this.bytes.subarray(this.pos), i = te(e), n = new Uint8Array(t.length + i.length);
630
+ const t = this.bytes.subarray(this.pos), i = se(e), n = new Uint8Array(t.length + i.length);
631
631
  n.set(t), n.set(i, t.length), this.setBuffer(n);
632
632
  }
633
633
  }
@@ -691,7 +691,7 @@ class re {
691
691
  return i;
692
692
  }
693
693
  const { headByte: n, pos: o, totalPos: a } = this;
694
- throw new RangeError(`Insufficient data in parsing ${Z(n)} at ${a} (${o} in the current buffer)`);
694
+ throw new RangeError(`Insufficient data in parsing ${ne(n)} at ${a} (${o} in the current buffer)`);
695
695
  } finally {
696
696
  this.entered = !1;
697
697
  }
@@ -846,25 +846,25 @@ class re {
846
846
  const n = this.lookU32();
847
847
  t = this.decodeExtension(n, 4);
848
848
  } else
849
- throw new z(`Unrecognized type byte: ${Z(e)}`);
849
+ throw new z(`Unrecognized type byte: ${ne(e)}`);
850
850
  this.complete();
851
851
  const i = this.stack;
852
852
  for (; i.length > 0; ) {
853
853
  const n = i.top();
854
- if (n.type === ne)
854
+ if (n.type === oe)
855
855
  if (n.array[n.position] = t, n.position++, n.position === n.size)
856
856
  t = n.array, i.release(n);
857
857
  else
858
858
  continue e;
859
- else if (n.type === O) {
859
+ else if (n.type === N) {
860
860
  if (t === "__proto__")
861
861
  throw new z("The key __proto__ is not allowed");
862
- n.key = this.mapKeyConverter(t), n.type = me;
862
+ n.key = this.mapKeyConverter(t), n.type = Ie;
863
863
  continue e;
864
864
  } else if (n.map[n.key] = t, n.readCount++, n.readCount === n.size)
865
865
  t = n.map, i.release(n);
866
866
  else {
867
- n.key = null, n.type = O;
867
+ n.key = null, n.type = N;
868
868
  continue e;
869
869
  }
870
870
  }
@@ -872,10 +872,10 @@ class re {
872
872
  }
873
873
  }
874
874
  readHeadByte() {
875
- return this.headByte === q && (this.headByte = this.readU8()), this.headByte;
875
+ return this.headByte === O && (this.headByte = this.readU8()), this.headByte;
876
876
  }
877
877
  complete() {
878
- this.headByte = q;
878
+ this.headByte = O;
879
879
  }
880
880
  readArraySize() {
881
881
  const e = this.readHeadByte();
@@ -887,7 +887,7 @@ class re {
887
887
  default: {
888
888
  if (e < 160)
889
889
  return e - 144;
890
- throw new z(`Unrecognized array type byte: ${Z(e)}`);
890
+ throw new z(`Unrecognized array type byte: ${ne(e)}`);
891
891
  }
892
892
  }
893
893
  }
@@ -912,13 +912,13 @@ class re {
912
912
  if (e > this.maxStrLength)
913
913
  throw new z(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
914
914
  if (this.bytes.byteLength < this.pos + t + e)
915
- throw pe;
915
+ throw we;
916
916
  const i = this.pos + t;
917
917
  let n;
918
- return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? n = this.keyDecoder.decode(this.bytes, i, e) : n = Ne(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 = Ye(this.bytes, i, e), this.pos += t + e, n;
919
919
  }
920
920
  stateIsMapKey() {
921
- return this.stack.length > 0 ? this.stack.top().type === O : !1;
921
+ return this.stack.length > 0 ? this.stack.top().type === N : !1;
922
922
  }
923
923
  /**
924
924
  * @throws {@link RangeError}
@@ -927,7 +927,7 @@ class re {
927
927
  if (e > this.maxBinLength)
928
928
  throw new z(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
929
929
  if (!this.hasRemaining(e + t))
930
- throw pe;
930
+ throw we;
931
931
  const i = this.pos + t, n = this.bytes.subarray(i, i + e);
932
932
  return this.pos += t + e, n;
933
933
  }
@@ -975,11 +975,11 @@ class re {
975
975
  return this.pos += 4, e;
976
976
  }
977
977
  readU64() {
978
- const e = We(this.view, this.pos);
978
+ const e = Ge(this.view, this.pos);
979
979
  return this.pos += 8, e;
980
980
  }
981
981
  readI64() {
982
- const e = be(this.view, this.pos);
982
+ const e = Se(this.view, this.pos);
983
983
  return this.pos += 8, e;
984
984
  }
985
985
  readU64AsBigInt() {
@@ -999,10 +999,10 @@ class re {
999
999
  return this.pos += 8, e;
1000
1000
  }
1001
1001
  }
1002
- function ft(s, e) {
1003
- return new re(e).decode(s);
1002
+ function gt(s, e) {
1003
+ return new de(e).decode(s);
1004
1004
  }
1005
- const wt = /* @__PURE__ */ new Set([
1005
+ const bt = /* @__PURE__ */ new Set([
1006
1006
  "auth",
1007
1007
  "open",
1008
1008
  "send",
@@ -1019,22 +1019,22 @@ const wt = /* @__PURE__ */ new Set([
1019
1019
  "annotate",
1020
1020
  "annotate_clear"
1021
1021
  ]);
1022
- function xt(s) {
1023
- return wt.has(s.type);
1022
+ function mt(s) {
1023
+ return bt.has(s.type);
1024
1024
  }
1025
- function yt(s) {
1026
- return rt(s);
1025
+ function vt(s) {
1026
+ return lt(s);
1027
1027
  }
1028
- function gt(s) {
1028
+ function kt(s) {
1029
1029
  let e;
1030
1030
  try {
1031
- e = ft(s);
1031
+ e = gt(s);
1032
1032
  } catch {
1033
1033
  return null;
1034
1034
  }
1035
1035
  return typeof e != "object" || e === null || typeof e.type != "string" ? null : e;
1036
1036
  }
1037
- class bt {
1037
+ class St {
1038
1038
  constructor(e) {
1039
1039
  r(this, "conversationId");
1040
1040
  r(this, "state", "");
@@ -1179,14 +1179,14 @@ class bt {
1179
1179
  this.byId.set(e.id, t ? { ...t, ...e } : e), e.seq > this._maxSeq && (this._maxSeq = e.seq), this._sorted = null;
1180
1180
  }
1181
1181
  markOwnStatus(e, t) {
1182
- const i = ue(t);
1182
+ const i = xe(t);
1183
1183
  let n = !1;
1184
1184
  for (const [o, a] of this.byId)
1185
- a.senderId !== this.me || a.seq <= 0 || a.seq > e || ue(a.status) >= i || (this.byId.set(o, { ...a, status: t }), n = !0);
1185
+ a.senderId !== this.me || a.seq <= 0 || a.seq > e || xe(a.status) >= i || (this.byId.set(o, { ...a, status: t }), n = !0);
1186
1186
  n && (this._sorted = null);
1187
1187
  }
1188
1188
  }
1189
- function ue(s) {
1189
+ function xe(s) {
1190
1190
  switch (s) {
1191
1191
  case "read":
1192
1192
  return 3;
@@ -1198,7 +1198,7 @@ function ue(s) {
1198
1198
  return 0;
1199
1199
  }
1200
1200
  }
1201
- class mt {
1201
+ class It {
1202
1202
  constructor(e) {
1203
1203
  r(this, "socket", null);
1204
1204
  r(this, "state", "idle");
@@ -1213,12 +1213,12 @@ class mt {
1213
1213
  var i, n;
1214
1214
  if (this.state === "connecting" || this.state === "open") return;
1215
1215
  this.stopped = !1, this.state = "connecting", this.authed = !1, (n = (i = this.opts).onStatusChange) == null || n.call(i, this.attempt > 0 ? "reconnecting" : "connecting");
1216
- const t = (this.opts.socketFactory ?? vt)(this.opts.url);
1216
+ const t = (this.opts.socketFactory ?? Ct)(this.opts.url);
1217
1217
  t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
1218
1218
  this.raw({ type: "auth", token: this.opts.token });
1219
1219
  }, t.onmessage = (o) => {
1220
- const a = gt(new Uint8Array(o.data));
1221
- !a || xt(a) || this.handle(a);
1220
+ const a = kt(new Uint8Array(o.data));
1221
+ !a || mt(a) || this.handle(a);
1222
1222
  }, t.onclose = () => this.onClosed(), t.onerror = () => {
1223
1223
  try {
1224
1224
  t.close();
@@ -1257,7 +1257,7 @@ class mt {
1257
1257
  raw(e) {
1258
1258
  var t;
1259
1259
  try {
1260
- (t = this.socket) == null || t.send(yt(e));
1260
+ (t = this.socket) == null || t.send(vt(e));
1261
1261
  } catch {
1262
1262
  this.outbox.push(e);
1263
1263
  }
@@ -1272,11 +1272,11 @@ class mt {
1272
1272
  this.attempt++, this.timer = setTimeout(() => this.connect(), i);
1273
1273
  }
1274
1274
  }
1275
- function vt(s) {
1275
+ function Ct(s) {
1276
1276
  return new WebSocket(s);
1277
1277
  }
1278
- const fe = 200, kt = 7 * 864e5;
1279
- class St {
1278
+ const ye = 200, Et = 7 * 864e5;
1279
+ class Tt {
1280
1280
  constructor(e) {
1281
1281
  r(this, "key");
1282
1282
  this.key = `ocw_outbox_${e}`;
@@ -1286,7 +1286,7 @@ class St {
1286
1286
  try {
1287
1287
  const e = localStorage.getItem(this.key);
1288
1288
  if (!e) return [];
1289
- const t = JSON.parse(e), i = Date.now() - kt, n = t.filter((o) => o.ts >= i);
1289
+ const t = JSON.parse(e), i = Date.now() - Et, n = t.filter((o) => o.ts >= i);
1290
1290
  return n.length !== t.length && this.save(n), n;
1291
1291
  } catch {
1292
1292
  return [];
@@ -1295,7 +1295,7 @@ class St {
1295
1295
  add(e) {
1296
1296
  try {
1297
1297
  const t = this.load();
1298
- t.push(e), this.save(t.length > fe ? t.slice(t.length - fe) : t);
1298
+ t.push(e), this.save(t.length > ye ? t.slice(t.length - ye) : t);
1299
1299
  } catch {
1300
1300
  }
1301
1301
  }
@@ -1315,28 +1315,28 @@ class St {
1315
1315
  }
1316
1316
  }
1317
1317
  const I = () => globalThis.crypto.subtle;
1318
- function J(s) {
1318
+ function Z(s) {
1319
1319
  const e = s instanceof Uint8Array ? s : new Uint8Array(s);
1320
1320
  let t = "";
1321
1321
  for (const i of e) t += String.fromCharCode(i);
1322
1322
  return btoa(t);
1323
1323
  }
1324
- function ie(s) {
1324
+ function re(s) {
1325
1325
  const e = atob(s), t = new ArrayBuffer(e.length), i = new Uint8Array(t);
1326
1326
  for (let n = 0; n < e.length; n++) i[n] = e.charCodeAt(n);
1327
1327
  return i;
1328
1328
  }
1329
- async function N() {
1329
+ async function V() {
1330
1330
  const s = await I().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1331
1331
  return { publicKey: s.publicKey, privateKey: s.privateKey };
1332
1332
  }
1333
1333
  async function _(s) {
1334
- return J(await I().exportKey("raw", s));
1334
+ return Z(await I().exportKey("raw", s));
1335
1335
  }
1336
1336
  async function F(s) {
1337
- return I().importKey("raw", ie(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1337
+ return I().importKey("raw", re(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1338
1338
  }
1339
- async function It(s, e) {
1339
+ async function Ut(s, e) {
1340
1340
  const t = await F(e);
1341
1341
  return I().deriveKey(
1342
1342
  { name: "ECDH", public: t },
@@ -1346,15 +1346,15 @@ async function It(s, e) {
1346
1346
  ["encrypt", "decrypt"]
1347
1347
  );
1348
1348
  }
1349
- async function Ct(s, e) {
1349
+ async function Pt(s, e) {
1350
1350
  const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), i = new TextEncoder().encode(e), n = await I().encrypt({ name: "AES-GCM", iv: t }, s, i);
1351
- return { ct: J(n), iv: J(t) };
1351
+ return { ct: Z(n), iv: Z(t) };
1352
1352
  }
1353
- async function Et(s, e, t) {
1354
- const i = await I().decrypt({ name: "AES-GCM", iv: ie(t) }, s, ie(e));
1353
+ async function Bt(s, e, t) {
1354
+ const i = await I().decrypt({ name: "AES-GCM", iv: re(t) }, s, re(e));
1355
1355
  return new TextDecoder().decode(i);
1356
1356
  }
1357
- async function Tt(s) {
1357
+ async function Kt(s) {
1358
1358
  var t, i;
1359
1359
  try {
1360
1360
  const n = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
@@ -1364,7 +1364,7 @@ async function Tt(s) {
1364
1364
  }
1365
1365
  } catch {
1366
1366
  }
1367
- const e = await N();
1367
+ const e = await V();
1368
1368
  try {
1369
1369
  const n = await I().exportKey("jwk", e.publicKey), o = await I().exportKey("jwk", e.privateKey);
1370
1370
  (i = globalThis.localStorage) == null || i.setItem(s, JSON.stringify({ pub: n, priv: o }));
@@ -1372,12 +1372,12 @@ async function Tt(s) {
1372
1372
  }
1373
1373
  return e;
1374
1374
  }
1375
- async function Ut(s, e) {
1375
+ async function At(s, e) {
1376
1376
  const t = await I().exportKey("raw", e), i = await I().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
1377
- return J(i);
1377
+ return Z(i);
1378
1378
  }
1379
- async function Pt() {
1380
- const s = await N(), e = await I().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1379
+ async function zt() {
1380
+ const s = await V(), e = await I().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1381
1381
  return {
1382
1382
  ecdhKP: s,
1383
1383
  ecdsaKP: { publicKey: e.publicKey, privateKey: e.privateKey },
@@ -1385,7 +1385,7 @@ async function Pt() {
1385
1385
  sigPublicKeyB64: await _(e.publicKey)
1386
1386
  };
1387
1387
  }
1388
- async function we(s) {
1388
+ async function ge(s) {
1389
1389
  var t, i;
1390
1390
  try {
1391
1391
  const n = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
@@ -1400,7 +1400,7 @@ async function we(s) {
1400
1400
  }
1401
1401
  } catch {
1402
1402
  }
1403
- const e = await Pt();
1403
+ const e = await zt();
1404
1404
  try {
1405
1405
  const n = await I().exportKey("jwk", e.ecdhKP.publicKey), o = await I().exportKey("jwk", e.ecdhKP.privateKey), a = await I().exportKey("jwk", e.ecdsaKP.publicKey), d = await I().exportKey("jwk", e.ecdsaKP.privateKey);
1406
1406
  (i = globalThis.localStorage) == null || i.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: n, ecdhPriv: o, ecdsaPub: a, ecdsaPriv: d }));
@@ -1408,25 +1408,25 @@ async function we(s) {
1408
1408
  }
1409
1409
  return e;
1410
1410
  }
1411
- async function Bt(s, e) {
1412
- const t = await N(), i = await _(t.publicKey), n = await F(e.identityKey), o = await F(e.signedPrekey), a = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, d = await D(s.privateKey, o), w = await D(t.privateKey, n), x = await D(t.privateKey, o), m = a ? await D(t.privateKey, a) : null, f = ve(d, w, x, ...m ? [m] : []);
1413
- return { sharedKey: await ke(f), ephemeralPublicKey: i };
1411
+ async function Lt(s, e) {
1412
+ const t = await V(), i = await _(t.publicKey), n = await F(e.identityKey), o = await F(e.signedPrekey), a = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, d = await D(s.privateKey, o), w = await D(t.privateKey, n), x = await D(t.privateKey, o), m = a ? await D(t.privateKey, a) : null, f = Ce(d, w, x, ...m ? [m] : []);
1413
+ return { sharedKey: await Ee(f), ephemeralPublicKey: i };
1414
1414
  }
1415
- async function Kt(s, e, t, i, n) {
1416
- const o = await F(t), a = await F(i), d = await D(e.privateKey, o), w = await D(s.privateKey, a), x = await D(e.privateKey, a), m = n ? await D(n.privateKey, a) : null, f = ve(d, w, x, ...m ? [m] : []);
1417
- return ke(f);
1415
+ async function Mt(s, e, t, i, n) {
1416
+ const o = await F(t), a = await F(i), d = await D(e.privateKey, o), w = await D(s.privateKey, a), x = await D(e.privateKey, a), m = n ? await D(n.privateKey, a) : null, f = Ce(d, w, x, ...m ? [m] : []);
1417
+ return Ee(f);
1418
1418
  }
1419
1419
  async function D(s, e) {
1420
1420
  return I().deriveBits({ name: "ECDH", public: e }, s, 256);
1421
1421
  }
1422
- function ve(...s) {
1422
+ function Ce(...s) {
1423
1423
  const e = s.reduce((n, o) => n + o.byteLength, 0), t = new Uint8Array(e);
1424
1424
  let i = 0;
1425
1425
  for (const n of s)
1426
1426
  t.set(new Uint8Array(n), i), i += n.byteLength;
1427
1427
  return t.buffer;
1428
1428
  }
1429
- async function ke(s) {
1429
+ async function Ee(s) {
1430
1430
  const e = await I().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
1431
1431
  return I().deriveKey(
1432
1432
  { name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info: new TextEncoder().encode("ObjectChat X3DH v1") },
@@ -1436,8 +1436,8 @@ async function ke(s) {
1436
1436
  ["encrypt", "decrypt"]
1437
1437
  );
1438
1438
  }
1439
- const At = 20;
1440
- class zt {
1439
+ const Dt = 20;
1440
+ class _t {
1441
1441
  constructor(e) {
1442
1442
  // Live ECDH mode state
1443
1443
  r(this, "kp");
@@ -1458,19 +1458,19 @@ class zt {
1458
1458
  }
1459
1459
  /** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
1460
1460
  async begin() {
1461
- return this.kp = await Tt(this.storageKey), _(this.kp.publicKey);
1461
+ return this.kp = await Kt(this.storageKey), _(this.kp.publicKey);
1462
1462
  }
1463
1463
  /** Live ECDH mode: A peer published their key — derive the shared secret. */
1464
1464
  async onPeerKey(e) {
1465
- this.kp && (this.shared = await It(this.kp.privateKey, e));
1465
+ this.kp && (this.shared = await Ut(this.kp.privateKey, e));
1466
1466
  }
1467
1467
  // ── X3DH async mode ────────────────────────────────────────────────────────
1468
1468
  /** X3DH: Generate identity key, signed prekey, and OTP prekeys.
1469
1469
  * Returns the upload frame payload the caller should send to the server. */
1470
1470
  async initX3DH() {
1471
- this.identityKP = await we(this.storageKey), this.signedPreKP = await N(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1472
- for (let n = 0; n < At; n++) this.otpKeys.push(await N());
1473
- const e = await _(this.signedPreKP.publicKey), t = await Ut(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), i = await Promise.all(this.otpKeys.map((n) => _(n.publicKey)));
1471
+ this.identityKP = await ge(this.storageKey), this.signedPreKP = await V(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1472
+ for (let n = 0; n < Dt; n++) this.otpKeys.push(await V());
1473
+ const e = await _(this.signedPreKP.publicKey), t = await At(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), i = await Promise.all(this.otpKeys.map((n) => _(n.publicKey)));
1474
1474
  return {
1475
1475
  identityKey: this.identityKP.publicKeyB64,
1476
1476
  signedPrekey: e,
@@ -1482,8 +1482,8 @@ class zt {
1482
1482
  /** X3DH sender: given a recipient's prekey bundle, derive the shared key and
1483
1483
  * return the init message fields to embed in the first encrypted message. */
1484
1484
  async x3dhSendTo(e) {
1485
- this.identityKP || (this.identityKP = await we(this.storageKey));
1486
- const { sharedKey: t, ephemeralPublicKey: i } = await Bt(this.identityKP.ecdhKP, e);
1485
+ this.identityKP || (this.identityKP = await ge(this.storageKey));
1486
+ const { sharedKey: t, ephemeralPublicKey: i } = await Lt(this.identityKP.ecdhKP, e);
1487
1487
  return this.x3dhShared = t, { ephemeralKey: i, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
1488
1488
  }
1489
1489
  /** X3DH recipient: given an init message's sender IK + EK + SPK ID, derive the shared key. */
@@ -1493,7 +1493,7 @@ class zt {
1493
1493
  return;
1494
1494
  }
1495
1495
  const n = this.otpKeys.shift();
1496
- this.x3dhShared = await Kt(this.identityKP.ecdhKP, this.signedPreKP, e, t, n);
1496
+ this.x3dhShared = await Mt(this.identityKP.ecdhKP, this.signedPreKP, e, t, n);
1497
1497
  }
1498
1498
  /** Flush pending X3DH derivation after initX3DH() completes. */
1499
1499
  async flushPendingX3DH() {
@@ -1506,7 +1506,7 @@ class zt {
1506
1506
  async sealText(e, t) {
1507
1507
  const i = this.x3dhShared ?? this.shared;
1508
1508
  if (!i) throw new Error("secure channel not ready");
1509
- const { ct: n, iv: o } = await Ct(i, e);
1509
+ const { ct: n, iv: o } = await Pt(i, e);
1510
1510
  return {
1511
1511
  kind: "text",
1512
1512
  text: n,
@@ -1521,7 +1521,7 @@ class zt {
1521
1521
  const t = this.x3dhShared ?? this.shared;
1522
1522
  if (!t) return { kind: "text", text: "🔒 encrypted" };
1523
1523
  try {
1524
- return { kind: "text", text: await Et(t, e.text, e.iv) };
1524
+ return { kind: "text", text: await Bt(t, e.text, e.iv) };
1525
1525
  } catch {
1526
1526
  return { kind: "text", text: "🔒 unable to decrypt" };
1527
1527
  }
@@ -1533,12 +1533,12 @@ class zt {
1533
1533
  for (const t of e.messages) t.content = await this.openContent(t.content);
1534
1534
  }
1535
1535
  }
1536
- function Lt(s) {
1536
+ function $t(s) {
1537
1537
  if (s.kind !== "text" || !s.enc) return null;
1538
1538
  const e = s;
1539
1539
  return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
1540
1540
  }
1541
- const xe = "objectchat-widget-styles", Mt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Dt = `
1541
+ const be = "objectchat-widget-styles", Ht = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Rt = `
1542
1542
  .ocw { --ocw-accent:#4F63F5; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
1543
1543
  position:relative;
1544
1544
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
@@ -1697,23 +1697,23 @@ const xe = "objectchat-widget-styles", Mt = ["👍", "❤️", "😂", "😮", "
1697
1697
  .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
1698
1698
  .ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
1699
1699
  `;
1700
- function _t() {
1701
- if (typeof document > "u" || document.getElementById(xe)) return;
1700
+ function Ft() {
1701
+ if (typeof document > "u" || document.getElementById(be)) return;
1702
1702
  const s = document.createElement("style");
1703
- s.id = xe, s.textContent = Dt, document.head.appendChild(s);
1703
+ s.id = be, s.textContent = Rt, document.head.appendChild(s);
1704
1704
  }
1705
1705
  function c(s, e, t) {
1706
1706
  const i = document.createElement(s);
1707
1707
  return e && (i.className = e), t !== void 0 && (i.textContent = t), i;
1708
1708
  }
1709
- function $t(s) {
1709
+ function jt(s) {
1710
1710
  try {
1711
1711
  return new Date(s).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
1712
1712
  } catch {
1713
1713
  return "";
1714
1714
  }
1715
1715
  }
1716
- function ee(s) {
1716
+ function ie(s) {
1717
1717
  var e;
1718
1718
  switch (s.kind) {
1719
1719
  case "text":
@@ -1730,7 +1730,7 @@ function ee(s) {
1730
1730
  return `📅 ${s.title} — ${new Date(s.startIso).toLocaleString()}`;
1731
1731
  }
1732
1732
  }
1733
- class Ht {
1733
+ class qt {
1734
1734
  /** Last seq the guest has seen per conversationId — used to compute unread badges. */
1735
1735
  constructor(e, t, i, n = {}) {
1736
1736
  r(this, "scroll");
@@ -1764,7 +1764,7 @@ class Ht {
1764
1764
  r(this, "showingTranslation", /* @__PURE__ */ new Set());
1765
1765
  r(this, "subjectBuilt", !1);
1766
1766
  var v, b, T, K, g, C, A, U, M;
1767
- this.root = e, this.me = t, this.h = i, this.cfg = n, _t(), e.replaceChildren(), e.classList.add("ocw"), n.accent && e.style.setProperty("--ocw-accent", n.accent);
1767
+ this.root = e, this.me = t, this.h = i, this.cfg = n, Ft(), e.replaceChildren(), e.classList.add("ocw"), n.accent && e.style.setProperty("--ocw-accent", n.accent);
1768
1768
  const o = c("div", "ocw-head"), a = c("div", "ocw-avatar");
1769
1769
  if ((v = n.userInfo) != null && v.avatar) {
1770
1770
  const k = document.createElement("img");
@@ -1804,7 +1804,7 @@ class Ht {
1804
1804
  const P = c("button", "ocw-cobrowse-swatch");
1805
1805
  P.style.background = k, P.type = "button", k === this.cobrowseColor && P.classList.add("sel"), P.addEventListener("click", () => {
1806
1806
  this.cobrowseColor = k;
1807
- for (const Q of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) Q.classList.remove("sel");
1807
+ for (const te of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) te.classList.remove("sel");
1808
1808
  P.classList.add("sel");
1809
1809
  }), this.cobrowseToolbar.append(P);
1810
1810
  }
@@ -2026,7 +2026,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2026
2026
  var f;
2027
2027
  if (e.senderRole === "system") {
2028
2028
  const h = c("div", "ocw-sys");
2029
- return h.textContent = e.deletedAt ? "message deleted" : ee(e.content), h;
2029
+ return h.textContent = e.deletedAt ? "message deleted" : ie(e.content), h;
2030
2030
  }
2031
2031
  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" : ""}`);
2032
2032
  !i && !n && o.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
@@ -2055,7 +2055,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2055
2055
  const b = document.createElement("a");
2056
2056
  b.href = h.icalUrl, b.download = `${h.title}.ics`, b.className = "ocw-appt-btn ocw-appt-btn-sec", b.textContent = "🍎 Apple / iCal", S.append(v, b), u.append(S), w.append(u);
2057
2057
  } else
2058
- x = document.createTextNode(ee(e.content)), w.append(x), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
2058
+ x = document.createTextNode(ie(e.content)), w.append(x), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
2059
2059
  if (d.append(w), !i && !n && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && x) {
2060
2060
  const h = e.content.text;
2061
2061
  if (h.trim()) {
@@ -2088,7 +2088,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2088
2088
  const u = c("button", void 0, "✏️");
2089
2089
  u.title = "Edit", u.addEventListener("click", (S) => {
2090
2090
  S.stopPropagation();
2091
- const v = ee(e.content), b = document.createElement("textarea");
2091
+ const v = ie(e.content), b = document.createElement("textarea");
2092
2092
  b.value = v, b.rows = Math.min(4, Math.ceil(v.length / 40) + 1), b.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
2093
2093
  const T = c("button", "ocw-form-submit", "Save");
2094
2094
  T.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
@@ -2126,7 +2126,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2126
2126
  }), u.append(K);
2127
2127
  }
2128
2128
  const S = c("button", "ocw-react-btn", "+"), v = c("div", "ocw-react-picker");
2129
- for (const b of Mt) {
2129
+ for (const b of Ht) {
2130
2130
  const T = c("button", void 0, b);
2131
2131
  T.addEventListener("click", (K) => {
2132
2132
  var C, A, U, M;
@@ -2141,15 +2141,15 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2141
2141
  v.style.display = "none";
2142
2142
  }, { once: !0 }), u.append(S), h.append(u, v), a.append(h);
2143
2143
  } else e.reactions && Object.keys(e.reactions).length && a.append(c("div", "ocw-react", Object.entries(e.reactions).map(([h, u]) => `${h}${u.length}`).join(" ")));
2144
- const m = c("div", "ocw-time ocw-meta", $t(e.ts));
2144
+ const m = c("div", "ocw-time ocw-meta", jt(e.ts));
2145
2145
  if (i && e.status) {
2146
- const h = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Rt(e.status));
2146
+ const h = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Ot(e.status));
2147
2147
  m.append(h);
2148
2148
  }
2149
2149
  return i && e.seq > 0 && t.lastReadByOthers >= e.seq && m.append(c("span", "ocw-seen", " · Seen")), a.append(m), o.append(a), o;
2150
2150
  }
2151
2151
  }
2152
- function Rt(s) {
2152
+ function Ot(s) {
2153
2153
  switch (s) {
2154
2154
  case "read":
2155
2155
  return "✓✓";
@@ -2161,17 +2161,20 @@ function Rt(s) {
2161
2161
  return "🕓";
2162
2162
  }
2163
2163
  }
2164
- const H = /* @__PURE__ */ new WeakMap();
2165
- function Ot(s) {
2164
+ const H = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new Map();
2165
+ function me(s) {
2166
+ return `relay-launcher::${s.profileId}::${s.subjectId ?? ""}`;
2167
+ }
2168
+ function Xt(s) {
2166
2169
  var e;
2167
2170
  (e = H.get(s)) == null || e.close(), H.delete(s);
2168
2171
  }
2169
- function Nt(s) {
2170
- var ce, de, le, he;
2171
- H.has(s.el) && (H.get(s.el).close(), H.delete(s.el));
2172
- const e = s.token ?? s.userId ?? Ae(), { wsUrl: t, httpBase: i } = ze(s.url, s.apiUrl);
2173
- let n = new bt(e);
2174
- const o = s.subjectId ? `${e}::${s.subjectId}` : e, a = new St(o);
2172
+ function Yt(s) {
2173
+ var le, he, pe, ue, fe;
2174
+ H.has(s.el) && (H.get(s.el).close(), H.delete(s.el)), s.launcher && ((le = G.get(me(s))) == null || le.close());
2175
+ const e = s.token ?? s.userId ?? De(), { wsUrl: t, httpBase: i } = _e(s.url, s.apiUrl);
2176
+ let n = new St(e);
2177
+ const o = s.subjectId ? `${e}::${s.subjectId}` : e, a = new Tt(o);
2175
2178
  let d, w = !1, x = null, m = null;
2176
2179
  !s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
2177
2180
  for (const l of a.load()) n.addOptimistic(l.clientMsgId, l.content);
@@ -2210,8 +2213,8 @@ function Nt(s) {
2210
2213
  ].join(";");
2211
2214
  };
2212
2215
  R((E == null ? void 0 : E.matches) ?? !1);
2213
- const V = ($) => R($.matches);
2214
- E == null || E.addEventListener("change", V), x = E, m = V, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2216
+ const X = ($) => R($.matches);
2217
+ E == null || E.addEventListener("change", X), x = E, m = X, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2215
2218
  const B = document.createElement("button");
2216
2219
  B.style.cssText = [
2217
2220
  "width:56px;height:56px;border-radius:50%",
@@ -2225,7 +2228,7 @@ function Nt(s) {
2225
2228
  }, B.onmouseleave = () => {
2226
2229
  B.style.transform = "scale(1)";
2227
2230
  }, h = document.createElement("span"), h.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center", B.append(h), f.append(y, B), document.body.append(f);
2228
- const W = ($) => {
2231
+ const Y = ($) => {
2229
2232
  $ ? (y.style.display = "flex", requestAnimationFrame(() => {
2230
2233
  y.style.opacity = "1", y.style.transform = "scale(1)";
2231
2234
  })) : (y.style.opacity = "0", y.style.transform = "scale(.95)", setTimeout(() => {
@@ -2233,9 +2236,9 @@ function Nt(s) {
2233
2236
  }, 180));
2234
2237
  };
2235
2238
  B.addEventListener("click", () => {
2236
- S = !S, W(S), B.textContent = S ? "✕" : "💬", B.append(h), S && (u = 0, h && (h.style.display = "none"));
2239
+ S = !S, Y(S), B.textContent = S ? "✕" : "💬", B.append(h), S && (u = 0, h && (h.style.display = "none"));
2237
2240
  }), document.addEventListener("keydown", ($) => {
2238
- $.key === "Escape" && S && (S = !1, W(!1), B.textContent = "💬", B.append(h));
2241
+ $.key === "Escape" && S && (S = !1, Y(!1), B.textContent = "💬", B.append(h));
2239
2242
  });
2240
2243
  }
2241
2244
  const v = () => {
@@ -2253,7 +2256,7 @@ function Nt(s) {
2253
2256
  }
2254
2257
  };
2255
2258
  let g;
2256
- const C = new zt(`ocw-e2e-${s.profileId}`);
2259
+ const C = new _t(`ocw-e2e-${s.profileId}`);
2257
2260
  let A = !1;
2258
2261
  const U = [], M = [];
2259
2262
  let k = !1;
@@ -2261,11 +2264,11 @@ function Nt(s) {
2261
2264
  C.sealText(p).then((y) => {
2262
2265
  d && g.send({ type: "send", conversationId: d, clientMsgId: l, content: y });
2263
2266
  });
2264
- }, Q = (l, p, y) => {
2267
+ }, te = (l, p, y) => {
2265
2268
  C.sealText(p, y).then((E) => {
2266
2269
  d && g.send({ type: "send", conversationId: d, clientMsgId: l, content: E });
2267
2270
  });
2268
- }, Se = () => {
2271
+ }, Te = () => {
2269
2272
  for (; U.length; ) {
2270
2273
  const l = U.shift();
2271
2274
  P(l.clientMsgId, l.text);
@@ -2274,14 +2277,14 @@ function Nt(s) {
2274
2277
  const l = M.shift();
2275
2278
  P(l.clientMsgId, l.text);
2276
2279
  }
2277
- }, Ie = (l) => {
2280
+ }, Ue = (l) => {
2278
2281
  g.send({ type: "fetchPrekey", targetUserId: l });
2279
- }, Ce = s.i18n ?? {}, Ee = ["ar", "he", "fa", "ur"], Te = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2280
- Ee.includes(Te) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2281
- const L = new Ht(s.el, e, {
2282
+ }, Pe = s.i18n ?? {}, Be = ["ar", "he", "fa", "ur"], Ke = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2283
+ Be.includes(Ke) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2284
+ const L = new qt(s.el, e, {
2282
2285
  onSend(l) {
2283
2286
  const p = `cm_${Math.random().toString(36).slice(2)}`, y = { kind: "text", text: l };
2284
- n.addOptimistic(p, y), L.render(n), n.e2e ? C.ready ? P(p, l) : k ? M.push({ clientMsgId: p, text: l }) : (U.push({ clientMsgId: p, text: l }), n.assignedAgentId && Ie(n.assignedAgentId)) : d ? (a.add({ clientMsgId: p, content: y, ts: Date.now() }), g.send({ type: "send", conversationId: d, clientMsgId: p, content: y })) : T.push({ clientMsgId: p, content: y });
2287
+ n.addOptimistic(p, y), L.render(n), n.e2e ? C.ready ? P(p, l) : k ? M.push({ clientMsgId: p, text: l }) : (U.push({ clientMsgId: p, text: l }), n.assignedAgentId && Ue(n.assignedAgentId)) : d ? (a.add({ clientMsgId: p, content: y, ts: Date.now() }), g.send({ type: "send", conversationId: d, clientMsgId: p, content: y })) : T.push({ clientMsgId: p, content: y });
2285
2288
  },
2286
2289
  async onAttach(l) {
2287
2290
  if (!d) return;
@@ -2294,8 +2297,8 @@ function Nt(s) {
2294
2297
  body: l
2295
2298
  });
2296
2299
  if (!E.ok) throw new Error(`Upload failed: ${E.status}`);
2297
- const { url: R, name: V, mime: B, size: W } = await E.json();
2298
- g.send({ type: "send", conversationId: d, clientMsgId: y, content: { kind: "attachment", url: R, name: V, mime: B, size: W } });
2300
+ const { url: R, name: X, mime: B, size: Y } = await E.json();
2301
+ g.send({ type: "send", conversationId: d, clientMsgId: y, content: { kind: "attachment", url: R, name: X, mime: B, size: Y } });
2299
2302
  } catch (E) {
2300
2303
  n.addOptimistic(y, { kind: "text", text: `⚠️ Upload failed: ${E.message}` }), L.render(n);
2301
2304
  }
@@ -2357,9 +2360,9 @@ function Nt(s) {
2357
2360
  ...s.subject ? { subject: s.subject } : {},
2358
2361
  ...s.quickReplies ? { quickReplies: s.quickReplies } : {},
2359
2362
  ...s.accent ? { accent: s.accent } : {},
2360
- ...(ce = s.user) != null && ce.name || (de = s.user) != null && de.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2361
- i18n: Ce
2362
- }), Ue = {
2363
+ ...(he = s.user) != null && he.name || (pe = s.user) != null && pe.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2364
+ i18n: Pe
2365
+ }), Ae = {
2363
2366
  type: "open",
2364
2367
  profileId: s.profileId,
2365
2368
  ...s.subjectId ? { subjectId: s.subjectId } : {},
@@ -2367,9 +2370,9 @@ function Nt(s) {
2367
2370
  ...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
2368
2371
  // Pass subject display info so the server can persist it to the Subject record.
2369
2372
  // This is how listingTitle and listingMeta get saved without a separate API call.
2370
- ...(le = s.subject) != null && le.title ? { subjectTitle: s.subject.title } : {},
2371
- ...(he = s.subject) != null && he.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2372
- }, Pe = (l) => {
2373
+ ...(ue = s.subject) != null && ue.title ? { subjectTitle: s.subject.title } : {},
2374
+ ...(fe = s.subject) != null && fe.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2375
+ }, ze = (l) => {
2373
2376
  const p = s.user;
2374
2377
  if (!p || !p.name && !p.email && !p.avatar && !p.meta) return;
2375
2378
  const y = [];
@@ -2378,10 +2381,10 @@ function Nt(s) {
2378
2381
  ${y.join(`
2379
2382
  `)}` });
2380
2383
  };
2381
- g = new mt({
2384
+ g = new It({
2382
2385
  url: t,
2383
2386
  token: e,
2384
- open: Ue,
2387
+ open: Ae,
2385
2388
  getCursor: () => n.highestSeq(),
2386
2389
  onStatusChange: (l) => L.setConnStatus(l),
2387
2390
  onFrame(l) {
@@ -2392,18 +2395,18 @@ ${y.join(`
2392
2395
  for (const y of a.load())
2393
2396
  g.send({ type: "send", conversationId: d, clientMsgId: y.clientMsgId, content: y.content });
2394
2397
  }
2395
- Le(t, e, d, n, L, i), T.length && K(d), p && l.conversation.lastSeq === 0 && Pe(d);
2398
+ $e(t, e, d, n, L, i), T.length && K(d), p && l.conversation.lastSeq === 0 && ze(d);
2396
2399
  }
2397
2400
  if (l.type === "ack" && a.remove(l.clientMsgId), l.type === "prekeyBundle") {
2398
2401
  l.bundle && (k = !0, C.x3dhSendTo(l.bundle).then((p) => {
2399
2402
  const y = [...U.splice(0), ...M.splice(0)];
2400
- for (const E of y) Q(E.clientMsgId, E.text, p);
2403
+ for (const E of y) te(E.clientMsgId, E.text, p);
2401
2404
  L.render(n);
2402
2405
  }));
2403
2406
  return;
2404
2407
  }
2405
2408
  if (l.type === "message" && n.e2e) {
2406
- const p = Lt(l.message.content);
2409
+ const p = $t(l.message.content);
2407
2410
  if (p && !C.ready) {
2408
2411
  C.x3dhReceiveFrom(p.x3dhIK, p.x3dhEK, p.x3dhSPK).then(async () => {
2409
2412
  await C.openFrame(l), n.apply(l), L.render(n);
@@ -2413,7 +2416,7 @@ ${y.join(`
2413
2416
  }
2414
2417
  if (l.type === "peerkey") {
2415
2418
  C.onPeerKey(l.key).then(() => {
2416
- Se(), L.render(n);
2419
+ Te(), L.render(n);
2417
2420
  });
2418
2421
  return;
2419
2422
  }
@@ -2429,23 +2432,23 @@ ${y.join(`
2429
2432
  })();
2430
2433
  }
2431
2434
  }), g.connect(), L.render(n);
2432
- const ae = { close: () => {
2433
- g.close(), f == null || f.remove(), L.destroy(), x && m && x.removeEventListener("change", m), H.delete(s.el);
2435
+ const j = s.launcher ? me(s) : null, W = { close: () => {
2436
+ g.close(), f == null || f.remove(), L.destroy(), x && m && x.removeEventListener("change", m), H.delete(s.el), j && G.get(j) === W && G.delete(j);
2434
2437
  } };
2435
- return H.set(s.el, ae), ae;
2438
+ return H.set(s.el, W), j && G.set(j, W), W;
2436
2439
  }
2437
2440
  export {
2438
- bt as ChatStore,
2439
- mt as ConnectionManager,
2440
- zt as E2ESession,
2441
- St as PersistentOutbox,
2442
- Ht as Renderer,
2443
- qt as asConversationId,
2444
- Lt as extractX3DHInit,
2445
- Xt as httpBaseFromWsUrl,
2446
- Nt as mount,
2447
- ze as resolveRelayUrls,
2448
- Le as restoreHistory,
2449
- Ot as unmount
2441
+ St as ChatStore,
2442
+ It as ConnectionManager,
2443
+ _t as E2ESession,
2444
+ Tt as PersistentOutbox,
2445
+ qt as Renderer,
2446
+ Wt as asConversationId,
2447
+ $t as extractX3DHInit,
2448
+ Qt as httpBaseFromWsUrl,
2449
+ Yt as mount,
2450
+ _e as resolveRelayUrls,
2451
+ $e as restoreHistory,
2452
+ Xt as unmount
2450
2453
  };
2451
2454
  //# sourceMappingURL=index.js.map