@paramms/chat-widget 1.0.7 → 1.0.9
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/chatlist.d.ts +4 -0
- package/dist/chatlist.js +1 -1
- package/dist/chatlist.js.map +1 -1
- package/dist/index.js +167 -162
- package/dist/index.js.map +1 -1
- package/dist/protocol/entities.d.ts +3 -0
- package/dist/protocol/frames.d.ts +2 -0
- package/dist/react.d.ts +70 -16
- package/dist/react.js +307 -114
- package/dist/react.js.map +1 -1
- package/dist/uid.js +63 -0
- package/dist/uid.js.map +1 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var r = (s, e, t) =>
|
|
4
|
-
import { p as
|
|
5
|
-
import { h as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
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) {
|
|
8
8
|
const e = s.length;
|
|
9
9
|
let t = 0, i = 0;
|
|
10
10
|
for (; i < e; ) {
|
|
@@ -26,7 +26,7 @@ function Ee(s) {
|
|
|
26
26
|
}
|
|
27
27
|
return t;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function Pe(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 Ue(s, e, t) {
|
|
|
48
48
|
e[n++] = c & 63 | 128;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
function
|
|
53
|
-
|
|
51
|
+
const Be = new TextEncoder(), Ke = 50;
|
|
52
|
+
function Ae(s, e, t) {
|
|
53
|
+
Be.encodeInto(s, e.subarray(t));
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
s.length >
|
|
55
|
+
function ze(s, e, t) {
|
|
56
|
+
s.length > Ke ? Ae(s, e, t) : Pe(s, e, t);
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
function
|
|
58
|
+
const Le = 4096;
|
|
59
|
+
function ue(s, e, t) {
|
|
60
60
|
let i = e;
|
|
61
61
|
const n = i + t, o = [];
|
|
62
62
|
let c = "";
|
|
@@ -76,17 +76,17 @@ function he(s, e, t) {
|
|
|
76
76
|
w > 65535 && (w -= 65536, o.push(w >>> 10 & 1023 | 55296), w = 56320 | w & 1023), o.push(w);
|
|
77
77
|
} else
|
|
78
78
|
o.push(l);
|
|
79
|
-
o.length >=
|
|
79
|
+
o.length >= Le && (c += String.fromCharCode(...o), o.length = 0);
|
|
80
80
|
}
|
|
81
81
|
return o.length > 0 && (c += String.fromCharCode(...o)), c;
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const Me = new TextDecoder(), De = 200;
|
|
84
|
+
function $e(s, e, t) {
|
|
85
85
|
const i = s.subarray(e, e + t);
|
|
86
|
-
return
|
|
86
|
+
return Me.decode(i);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
return t >
|
|
88
|
+
function _e(s, e, t) {
|
|
89
|
+
return t > De ? $e(s, e, t) : ue(s, e, t);
|
|
90
90
|
}
|
|
91
91
|
class N {
|
|
92
92
|
constructor(e, t) {
|
|
@@ -107,26 +107,26 @@ class U extends Error {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
const F = 4294967295;
|
|
110
|
-
function
|
|
110
|
+
function He(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
|
|
114
|
+
function fe(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
|
|
118
|
+
function we(s, e) {
|
|
119
119
|
const t = s.getInt32(e), i = s.getUint32(e + 4);
|
|
120
120
|
return t * 4294967296 + i;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function Re(s, e) {
|
|
123
123
|
const t = s.getUint32(e), i = s.getUint32(e + 4);
|
|
124
124
|
return t * 4294967296 + i;
|
|
125
125
|
}
|
|
126
|
-
const
|
|
127
|
-
function
|
|
128
|
-
if (s >= 0 && e >= 0 && s <=
|
|
129
|
-
if (e === 0 && s <=
|
|
126
|
+
const Fe = -1, qe = 4294967296 - 1, je = 17179869184 - 1;
|
|
127
|
+
function Oe({ sec: s, nsec: e }) {
|
|
128
|
+
if (s >= 0 && e >= 0 && s <= je)
|
|
129
|
+
if (e === 0 && s <= qe) {
|
|
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 qe({ 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),
|
|
138
|
+
return i.setUint32(0, e), fe(i, 4, s), t;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Ne(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
|
|
148
|
+
function Ve(s) {
|
|
149
149
|
if (s instanceof Date) {
|
|
150
|
-
const e =
|
|
151
|
-
return
|
|
150
|
+
const e = Ne(s);
|
|
151
|
+
return Oe(e);
|
|
152
152
|
} else
|
|
153
153
|
return null;
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function We(s) {
|
|
156
156
|
const e = new DataView(s.buffer, s.byteOffset, s.byteLength);
|
|
157
157
|
switch (s.byteLength) {
|
|
158
158
|
case 4:
|
|
@@ -162,21 +162,21 @@ function Ne(s) {
|
|
|
162
162
|
return { sec: n, nsec: o };
|
|
163
163
|
}
|
|
164
164
|
case 12: {
|
|
165
|
-
const t =
|
|
165
|
+
const t = we(e, 4), i = e.getUint32(0);
|
|
166
166
|
return { sec: t, nsec: i };
|
|
167
167
|
}
|
|
168
168
|
default:
|
|
169
169
|
throw new U(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
const e =
|
|
172
|
+
function Xe(s) {
|
|
173
|
+
const e = We(s);
|
|
174
174
|
return new Date(e.sec * 1e3 + e.nsec / 1e6);
|
|
175
175
|
}
|
|
176
|
-
const
|
|
177
|
-
type:
|
|
178
|
-
encode:
|
|
179
|
-
decode:
|
|
176
|
+
const Ye = {
|
|
177
|
+
type: Fe,
|
|
178
|
+
encode: Ve,
|
|
179
|
+
decode: Xe
|
|
180
180
|
}, X = class X {
|
|
181
181
|
constructor() {
|
|
182
182
|
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
|
@@ -189,7 +189,7 @@ const We = {
|
|
|
189
189
|
// custom extensions
|
|
190
190
|
r(this, "encoders", []);
|
|
191
191
|
r(this, "decoders", []);
|
|
192
|
-
this.register(
|
|
192
|
+
this.register(Ye);
|
|
193
193
|
}
|
|
194
194
|
register({ type: e, encode: t, decode: i }) {
|
|
195
195
|
if (e >= 0)
|
|
@@ -229,13 +229,13 @@ const We = {
|
|
|
229
229
|
};
|
|
230
230
|
r(X, "defaultCodec", new X());
|
|
231
231
|
let V = X;
|
|
232
|
-
function
|
|
232
|
+
function Je(s) {
|
|
233
233
|
return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
|
|
234
234
|
}
|
|
235
235
|
function Z(s) {
|
|
236
|
-
return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) :
|
|
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);
|
|
237
237
|
}
|
|
238
|
-
const
|
|
238
|
+
const Ge = 100, Ze = 2048;
|
|
239
239
|
class te {
|
|
240
240
|
constructor(e) {
|
|
241
241
|
r(this, "extensionCodec");
|
|
@@ -251,7 +251,7 @@ class te {
|
|
|
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) ?? 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) ??
|
|
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);
|
|
255
255
|
}
|
|
256
256
|
clone() {
|
|
257
257
|
return new te({
|
|
@@ -336,8 +336,8 @@ class te {
|
|
|
336
336
|
throw new Error(`Too long string: ${e} bytes in UTF-8`);
|
|
337
337
|
}
|
|
338
338
|
encodeString(e) {
|
|
339
|
-
const i =
|
|
340
|
-
this.ensureBufferSizeToWrite(5 + i), this.writeStringHeader(i),
|
|
339
|
+
const i = Te(e);
|
|
340
|
+
this.ensureBufferSizeToWrite(5 + i), this.writeStringHeader(i), ze(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);
|
|
@@ -459,10 +459,10 @@ class te {
|
|
|
459
459
|
this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
|
|
460
460
|
}
|
|
461
461
|
writeU64(e) {
|
|
462
|
-
this.ensureBufferSizeToWrite(8),
|
|
462
|
+
this.ensureBufferSizeToWrite(8), He(this.view, this.pos, e), this.pos += 8;
|
|
463
463
|
}
|
|
464
464
|
writeI64(e) {
|
|
465
|
-
this.ensureBufferSizeToWrite(8),
|
|
465
|
+
this.ensureBufferSizeToWrite(8), fe(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 te {
|
|
|
471
471
|
this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
|
-
function
|
|
474
|
+
function Qe(s, e) {
|
|
475
475
|
return new te(e).encodeSharedRef(s);
|
|
476
476
|
}
|
|
477
477
|
function J(s) {
|
|
478
478
|
return `${s < 0 ? "-" : ""}0x${Math.abs(s).toString(16).padStart(2, "0")}`;
|
|
479
479
|
}
|
|
480
|
-
const
|
|
481
|
-
class
|
|
482
|
-
constructor(e =
|
|
480
|
+
const et = 16, tt = 16;
|
|
481
|
+
class it {
|
|
482
|
+
constructor(e = et, t = tt) {
|
|
483
483
|
r(this, "hit", 0);
|
|
484
484
|
r(this, "miss", 0);
|
|
485
485
|
r(this, "caches");
|
|
@@ -512,16 +512,16 @@ class et {
|
|
|
512
512
|
if (n != null)
|
|
513
513
|
return this.hit++, n;
|
|
514
514
|
this.miss++;
|
|
515
|
-
const o =
|
|
515
|
+
const o = ue(e, t, i), c = Uint8Array.prototype.slice.call(e, t, t + i);
|
|
516
516
|
return this.store(c, o), o;
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
-
const Q = "array", j = "map_key",
|
|
519
|
+
const Q = "array", j = "map_key", xe = "map_value", nt = (s) => {
|
|
520
520
|
if (typeof s == "string" || typeof s == "number")
|
|
521
521
|
return s;
|
|
522
522
|
throw new U("The type of key must be string or number but " + typeof s);
|
|
523
523
|
};
|
|
524
|
-
class
|
|
524
|
+
class st {
|
|
525
525
|
constructor() {
|
|
526
526
|
r(this, "stack", []);
|
|
527
527
|
r(this, "stackHeadPosition", -1);
|
|
@@ -562,7 +562,7 @@ class it {
|
|
|
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 === j || e.type ===
|
|
565
|
+
if (e.type === j || e.type === xe) {
|
|
566
566
|
const i = e;
|
|
567
567
|
i.size = 0, i.map = void 0, i.readCount = 0, i.type = void 0;
|
|
568
568
|
}
|
|
@@ -572,14 +572,14 @@ class it {
|
|
|
572
572
|
this.stack.length = 0, this.stackHeadPosition = -1;
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
|
-
const q = -1, ie = new DataView(new ArrayBuffer(0)),
|
|
575
|
+
const q = -1, ie = new DataView(new ArrayBuffer(0)), ot = new Uint8Array(ie.buffer);
|
|
576
576
|
try {
|
|
577
577
|
ie.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
|
|
582
|
+
const ce = new RangeError("Insufficient data"), rt = new it();
|
|
583
583
|
class ne {
|
|
584
584
|
constructor(e) {
|
|
585
585
|
r(this, "extensionCodec");
|
|
@@ -596,11 +596,11 @@ class ne {
|
|
|
596
596
|
r(this, "totalPos", 0);
|
|
597
597
|
r(this, "pos", 0);
|
|
598
598
|
r(this, "view", ie);
|
|
599
|
-
r(this, "bytes",
|
|
599
|
+
r(this, "bytes", ot);
|
|
600
600
|
r(this, "headByte", q);
|
|
601
|
-
r(this, "stack", new
|
|
601
|
+
r(this, "stack", new st());
|
|
602
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 :
|
|
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;
|
|
604
604
|
}
|
|
605
605
|
clone() {
|
|
606
606
|
return new ne({
|
|
@@ -859,7 +859,7 @@ class ne {
|
|
|
859
859
|
else if (n.type === j) {
|
|
860
860
|
if (t === "__proto__")
|
|
861
861
|
throw new U("The key __proto__ is not allowed");
|
|
862
|
-
n.key = this.mapKeyConverter(t), n.type =
|
|
862
|
+
n.key = this.mapKeyConverter(t), n.type = xe;
|
|
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);
|
|
@@ -912,10 +912,10 @@ class ne {
|
|
|
912
912
|
if (e > this.maxStrLength)
|
|
913
913
|
throw new U(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
|
|
914
914
|
if (this.bytes.byteLength < this.pos + t + e)
|
|
915
|
-
throw
|
|
915
|
+
throw ce;
|
|
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 =
|
|
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;
|
|
919
919
|
}
|
|
920
920
|
stateIsMapKey() {
|
|
921
921
|
return this.stack.length > 0 ? this.stack.top().type === j : !1;
|
|
@@ -927,7 +927,7 @@ class ne {
|
|
|
927
927
|
if (e > this.maxBinLength)
|
|
928
928
|
throw new U(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
|
|
929
929
|
if (!this.hasRemaining(e + t))
|
|
930
|
-
throw
|
|
930
|
+
throw ce;
|
|
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 ne {
|
|
|
975
975
|
return this.pos += 4, e;
|
|
976
976
|
}
|
|
977
977
|
readU64() {
|
|
978
|
-
const e =
|
|
978
|
+
const e = Re(this.view, this.pos);
|
|
979
979
|
return this.pos += 8, e;
|
|
980
980
|
}
|
|
981
981
|
readI64() {
|
|
982
|
-
const e =
|
|
982
|
+
const e = we(this.view, this.pos);
|
|
983
983
|
return this.pos += 8, e;
|
|
984
984
|
}
|
|
985
985
|
readU64AsBigInt() {
|
|
@@ -999,10 +999,10 @@ class ne {
|
|
|
999
999
|
return this.pos += 8, e;
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1002
|
+
function at(s, e) {
|
|
1003
1003
|
return new ne(e).decode(s);
|
|
1004
1004
|
}
|
|
1005
|
-
const
|
|
1005
|
+
const ct = /* @__PURE__ */ new Set([
|
|
1006
1006
|
"auth",
|
|
1007
1007
|
"open",
|
|
1008
1008
|
"send",
|
|
@@ -1019,22 +1019,22 @@ const rt = /* @__PURE__ */ new Set([
|
|
|
1019
1019
|
"annotate",
|
|
1020
1020
|
"annotate_clear"
|
|
1021
1021
|
]);
|
|
1022
|
-
function
|
|
1023
|
-
return
|
|
1022
|
+
function dt(s) {
|
|
1023
|
+
return ct.has(s.type);
|
|
1024
1024
|
}
|
|
1025
|
-
function
|
|
1026
|
-
return
|
|
1025
|
+
function lt(s) {
|
|
1026
|
+
return Qe(s);
|
|
1027
1027
|
}
|
|
1028
|
-
function
|
|
1028
|
+
function ht(s) {
|
|
1029
1029
|
let e;
|
|
1030
1030
|
try {
|
|
1031
|
-
e =
|
|
1031
|
+
e = at(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
|
|
1037
|
+
class pt {
|
|
1038
1038
|
constructor(e) {
|
|
1039
1039
|
r(this, "conversationId");
|
|
1040
1040
|
r(this, "state", "");
|
|
@@ -1180,10 +1180,10 @@ class lt {
|
|
|
1180
1180
|
}
|
|
1181
1181
|
markOwnStatus(e, t) {
|
|
1182
1182
|
for (const [i, n] of this.byId)
|
|
1183
|
-
n.senderId === this.me && n.seq > 0 && n.seq <= e &&
|
|
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);
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
function
|
|
1186
|
+
function de(s) {
|
|
1187
1187
|
switch (s) {
|
|
1188
1188
|
case "read":
|
|
1189
1189
|
return 3;
|
|
@@ -1195,7 +1195,7 @@ function ae(s) {
|
|
|
1195
1195
|
return 0;
|
|
1196
1196
|
}
|
|
1197
1197
|
}
|
|
1198
|
-
class
|
|
1198
|
+
class ut {
|
|
1199
1199
|
constructor(e) {
|
|
1200
1200
|
r(this, "socket", null);
|
|
1201
1201
|
r(this, "state", "idle");
|
|
@@ -1210,12 +1210,12 @@ class ht {
|
|
|
1210
1210
|
var i, n;
|
|
1211
1211
|
if (this.state === "connecting" || this.state === "open") return;
|
|
1212
1212
|
this.stopped = !1, this.state = "connecting", this.authed = !1, (n = (i = this.opts).onStatusChange) == null || n.call(i, this.attempt > 0 ? "reconnecting" : "connecting");
|
|
1213
|
-
const t = (this.opts.socketFactory ??
|
|
1213
|
+
const t = (this.opts.socketFactory ?? ft)(this.opts.url);
|
|
1214
1214
|
t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
|
|
1215
1215
|
this.raw({ type: "auth", token: this.opts.token });
|
|
1216
1216
|
}, t.onmessage = (o) => {
|
|
1217
|
-
const c =
|
|
1218
|
-
!c ||
|
|
1217
|
+
const c = ht(new Uint8Array(o.data));
|
|
1218
|
+
!c || dt(c) || this.handle(c);
|
|
1219
1219
|
}, t.onclose = () => this.onClosed(), t.onerror = () => {
|
|
1220
1220
|
try {
|
|
1221
1221
|
t.close();
|
|
@@ -1254,7 +1254,7 @@ class ht {
|
|
|
1254
1254
|
raw(e) {
|
|
1255
1255
|
var t;
|
|
1256
1256
|
try {
|
|
1257
|
-
(t = this.socket) == null || t.send(
|
|
1257
|
+
(t = this.socket) == null || t.send(lt(e));
|
|
1258
1258
|
} catch {
|
|
1259
1259
|
this.outbox.push(e);
|
|
1260
1260
|
}
|
|
@@ -1269,11 +1269,11 @@ class ht {
|
|
|
1269
1269
|
this.attempt++, this.timer = setTimeout(() => this.connect(), i);
|
|
1270
1270
|
}
|
|
1271
1271
|
}
|
|
1272
|
-
function
|
|
1272
|
+
function ft(s) {
|
|
1273
1273
|
return new WebSocket(s);
|
|
1274
1274
|
}
|
|
1275
|
-
const
|
|
1276
|
-
class
|
|
1275
|
+
const le = 200, wt = 7 * 864e5;
|
|
1276
|
+
class xt {
|
|
1277
1277
|
constructor(e) {
|
|
1278
1278
|
r(this, "key");
|
|
1279
1279
|
this.key = `ocw_outbox_${e}`;
|
|
@@ -1283,7 +1283,7 @@ class ft {
|
|
|
1283
1283
|
try {
|
|
1284
1284
|
const e = localStorage.getItem(this.key);
|
|
1285
1285
|
if (!e) return [];
|
|
1286
|
-
const t = JSON.parse(e), i = Date.now() -
|
|
1286
|
+
const t = JSON.parse(e), i = Date.now() - wt, n = t.filter((o) => o.ts >= i);
|
|
1287
1287
|
return n.length !== t.length && this.save(n), n;
|
|
1288
1288
|
} catch {
|
|
1289
1289
|
return [];
|
|
@@ -1292,7 +1292,7 @@ class ft {
|
|
|
1292
1292
|
add(e) {
|
|
1293
1293
|
try {
|
|
1294
1294
|
const t = this.load();
|
|
1295
|
-
t.push(e), this.save(t.length >
|
|
1295
|
+
t.push(e), this.save(t.length > le ? t.slice(t.length - le) : t);
|
|
1296
1296
|
} catch {
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
@@ -1333,7 +1333,7 @@ async function M(s) {
|
|
|
1333
1333
|
async function H(s) {
|
|
1334
1334
|
return S().importKey("raw", ee(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
|
|
1335
1335
|
}
|
|
1336
|
-
async function
|
|
1336
|
+
async function yt(s, e) {
|
|
1337
1337
|
const t = await H(e);
|
|
1338
1338
|
return S().deriveKey(
|
|
1339
1339
|
{ name: "ECDH", public: t },
|
|
@@ -1343,15 +1343,15 @@ async function wt(s, e) {
|
|
|
1343
1343
|
["encrypt", "decrypt"]
|
|
1344
1344
|
);
|
|
1345
1345
|
}
|
|
1346
|
-
async function
|
|
1346
|
+
async function gt(s, e) {
|
|
1347
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
1348
|
return { ct: W(n), iv: W(t) };
|
|
1349
1349
|
}
|
|
1350
|
-
async function
|
|
1350
|
+
async function bt(s, e, t) {
|
|
1351
1351
|
const i = await S().decrypt({ name: "AES-GCM", iv: ee(t) }, s, ee(e));
|
|
1352
1352
|
return new TextDecoder().decode(i);
|
|
1353
1353
|
}
|
|
1354
|
-
async function
|
|
1354
|
+
async function mt(s) {
|
|
1355
1355
|
var t, i;
|
|
1356
1356
|
try {
|
|
1357
1357
|
const n = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
|
|
@@ -1369,11 +1369,11 @@ async function gt(s) {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
return e;
|
|
1371
1371
|
}
|
|
1372
|
-
async function
|
|
1372
|
+
async function vt(s, e) {
|
|
1373
1373
|
const t = await S().exportKey("raw", e), i = await S().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
|
|
1374
1374
|
return W(i);
|
|
1375
1375
|
}
|
|
1376
|
-
async function
|
|
1376
|
+
async function kt() {
|
|
1377
1377
|
const s = await O(), e = await S().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
|
|
1378
1378
|
return {
|
|
1379
1379
|
ecdhKP: s,
|
|
@@ -1382,7 +1382,7 @@ async function mt() {
|
|
|
1382
1382
|
sigPublicKeyB64: await M(e.publicKey)
|
|
1383
1383
|
};
|
|
1384
1384
|
}
|
|
1385
|
-
async function
|
|
1385
|
+
async function he(s) {
|
|
1386
1386
|
var t, i;
|
|
1387
1387
|
try {
|
|
1388
1388
|
const n = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
|
|
@@ -1397,7 +1397,7 @@ async function de(s) {
|
|
|
1397
1397
|
}
|
|
1398
1398
|
} catch {
|
|
1399
1399
|
}
|
|
1400
|
-
const e = await
|
|
1400
|
+
const e = await kt();
|
|
1401
1401
|
try {
|
|
1402
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
1403
|
(i = globalThis.localStorage) == null || i.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: n, ecdhPriv: o, ecdsaPub: c, ecdsaPriv: l }));
|
|
@@ -1405,25 +1405,25 @@ async function de(s) {
|
|
|
1405
1405
|
}
|
|
1406
1406
|
return e;
|
|
1407
1407
|
}
|
|
1408
|
-
async function
|
|
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 =
|
|
1410
|
-
return { sharedKey: await
|
|
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 };
|
|
1411
1411
|
}
|
|
1412
|
-
async function
|
|
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 =
|
|
1414
|
-
return
|
|
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);
|
|
1415
1415
|
}
|
|
1416
1416
|
async function L(s, e) {
|
|
1417
1417
|
return S().deriveBits({ name: "ECDH", public: e }, s, 256);
|
|
1418
1418
|
}
|
|
1419
|
-
function
|
|
1419
|
+
function ye(...s) {
|
|
1420
1420
|
const e = s.reduce((n, o) => n + o.byteLength, 0), t = new Uint8Array(e);
|
|
1421
1421
|
let i = 0;
|
|
1422
1422
|
for (const n of s)
|
|
1423
1423
|
t.set(new Uint8Array(n), i), i += n.byteLength;
|
|
1424
1424
|
return t.buffer;
|
|
1425
1425
|
}
|
|
1426
|
-
async function
|
|
1426
|
+
async function ge(s) {
|
|
1427
1427
|
const e = await S().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
|
|
1428
1428
|
return S().deriveKey(
|
|
1429
1429
|
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info: new TextEncoder().encode("ObjectChat X3DH v1") },
|
|
@@ -1433,8 +1433,8 @@ async function xe(s) {
|
|
|
1433
1433
|
["encrypt", "decrypt"]
|
|
1434
1434
|
);
|
|
1435
1435
|
}
|
|
1436
|
-
const
|
|
1437
|
-
class
|
|
1436
|
+
const Ct = 20;
|
|
1437
|
+
class Et {
|
|
1438
1438
|
constructor(e) {
|
|
1439
1439
|
// Live ECDH mode state
|
|
1440
1440
|
r(this, "kp");
|
|
@@ -1455,19 +1455,19 @@ class It {
|
|
|
1455
1455
|
}
|
|
1456
1456
|
/** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
|
|
1457
1457
|
async begin() {
|
|
1458
|
-
return this.kp = await
|
|
1458
|
+
return this.kp = await mt(this.storageKey), M(this.kp.publicKey);
|
|
1459
1459
|
}
|
|
1460
1460
|
/** Live ECDH mode: A peer published their key — derive the shared secret. */
|
|
1461
1461
|
async onPeerKey(e) {
|
|
1462
|
-
this.kp && (this.shared = await
|
|
1462
|
+
this.kp && (this.shared = await yt(this.kp.privateKey, e));
|
|
1463
1463
|
}
|
|
1464
1464
|
// ── X3DH async mode ────────────────────────────────────────────────────────
|
|
1465
1465
|
/** X3DH: Generate identity key, signed prekey, and OTP prekeys.
|
|
1466
1466
|
* Returns the upload frame payload the caller should send to the server. */
|
|
1467
1467
|
async initX3DH() {
|
|
1468
|
-
this.identityKP = await
|
|
1469
|
-
for (let n = 0; n <
|
|
1470
|
-
const e = await M(this.signedPreKP.publicKey), t = await
|
|
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)));
|
|
1471
1471
|
return {
|
|
1472
1472
|
identityKey: this.identityKP.publicKeyB64,
|
|
1473
1473
|
signedPrekey: e,
|
|
@@ -1479,8 +1479,8 @@ class It {
|
|
|
1479
1479
|
/** X3DH sender: given a recipient's prekey bundle, derive the shared key and
|
|
1480
1480
|
* return the init message fields to embed in the first encrypted message. */
|
|
1481
1481
|
async x3dhSendTo(e) {
|
|
1482
|
-
this.identityKP || (this.identityKP = await
|
|
1483
|
-
const { sharedKey: t, ephemeralPublicKey: i } = await
|
|
1482
|
+
this.identityKP || (this.identityKP = await he(this.storageKey));
|
|
1483
|
+
const { sharedKey: t, ephemeralPublicKey: i } = await St(this.identityKP.ecdhKP, e);
|
|
1484
1484
|
return this.x3dhShared = t, { ephemeralKey: i, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
|
|
1485
1485
|
}
|
|
1486
1486
|
/** X3DH recipient: given an init message's sender IK + EK + SPK ID, derive the shared key. */
|
|
@@ -1490,7 +1490,7 @@ class It {
|
|
|
1490
1490
|
return;
|
|
1491
1491
|
}
|
|
1492
1492
|
const n = this.otpKeys.shift();
|
|
1493
|
-
this.x3dhShared = await
|
|
1493
|
+
this.x3dhShared = await It(this.identityKP.ecdhKP, this.signedPreKP, e, t, n);
|
|
1494
1494
|
}
|
|
1495
1495
|
/** Flush pending X3DH derivation after initX3DH() completes. */
|
|
1496
1496
|
async flushPendingX3DH() {
|
|
@@ -1503,7 +1503,7 @@ class It {
|
|
|
1503
1503
|
async sealText(e, t) {
|
|
1504
1504
|
const i = this.x3dhShared ?? this.shared;
|
|
1505
1505
|
if (!i) throw new Error("secure channel not ready");
|
|
1506
|
-
const { ct: n, iv: o } = await
|
|
1506
|
+
const { ct: n, iv: o } = await gt(i, e);
|
|
1507
1507
|
return {
|
|
1508
1508
|
kind: "text",
|
|
1509
1509
|
text: n,
|
|
@@ -1518,7 +1518,7 @@ class It {
|
|
|
1518
1518
|
const t = this.x3dhShared ?? this.shared;
|
|
1519
1519
|
if (!t) return { kind: "text", text: "🔒 encrypted" };
|
|
1520
1520
|
try {
|
|
1521
|
-
return { kind: "text", text: await
|
|
1521
|
+
return { kind: "text", text: await bt(t, e.text, e.iv) };
|
|
1522
1522
|
} catch {
|
|
1523
1523
|
return { kind: "text", text: "🔒 unable to decrypt" };
|
|
1524
1524
|
}
|
|
@@ -1530,12 +1530,12 @@ class It {
|
|
|
1530
1530
|
for (const t of e.messages) t.content = await this.openContent(t.content);
|
|
1531
1531
|
}
|
|
1532
1532
|
}
|
|
1533
|
-
function
|
|
1533
|
+
function Ut(s) {
|
|
1534
1534
|
if (s.kind !== "text" || !s.enc) return null;
|
|
1535
1535
|
const e = s;
|
|
1536
1536
|
return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
|
|
1537
1537
|
}
|
|
1538
|
-
const
|
|
1538
|
+
const pe = "objectchat-widget-styles", Tt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Pt = `
|
|
1539
1539
|
.ocw { --ocw-accent:#f5713c; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
|
|
1540
1540
|
position:relative;
|
|
1541
1541
|
display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
|
|
@@ -1644,8 +1644,9 @@ const le = "objectchat-widget-styles", Et = ["👍", "❤️", "😂", "😮", "
|
|
|
1644
1644
|
.ocw-typing-dot:nth-child(2) { animation-delay:.2s; }
|
|
1645
1645
|
.ocw-typing-dot:nth-child(3) { animation-delay:.4s; }
|
|
1646
1646
|
@keyframes ocw-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }
|
|
1647
|
-
.ocw-quick { display:flex; gap:8px; padding:8px 12px
|
|
1648
|
-
.ocw-quick
|
|
1647
|
+
.ocw-quick { display:flex; gap:8px; padding:8px 12px 6px; overflow-x:auto; scrollbar-width:none; flex-shrink:0; }
|
|
1648
|
+
.ocw-quick::-webkit-scrollbar { display:none; }
|
|
1649
|
+
.ocw-quick button { flex:none; border:1px solid #e3ded7; background:#fff; border-radius:999px; padding:7px 14px; font-size:13px; cursor:pointer; color:#444; white-space:nowrap; transition:border-color .12s,color .12s; }
|
|
1649
1650
|
.ocw-quick button:hover { border-color:var(--ocw-accent); color:var(--ocw-accent); }
|
|
1650
1651
|
.ocw-form-host:empty { display:none; }
|
|
1651
1652
|
.ocw-form { margin:6px 12px 0; padding:12px; background:var(--ocw-card); border:1px solid var(--ocw-line); border-radius:14px; }
|
|
@@ -1693,16 +1694,16 @@ const le = "objectchat-widget-styles", Et = ["👍", "❤️", "😂", "😮", "
|
|
|
1693
1694
|
.ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
|
|
1694
1695
|
.ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
|
|
1695
1696
|
`;
|
|
1696
|
-
function
|
|
1697
|
-
if (typeof document > "u" || document.getElementById(
|
|
1697
|
+
function Bt() {
|
|
1698
|
+
if (typeof document > "u" || document.getElementById(pe)) return;
|
|
1698
1699
|
const s = document.createElement("style");
|
|
1699
|
-
s.id =
|
|
1700
|
+
s.id = pe, s.textContent = Pt, document.head.appendChild(s);
|
|
1700
1701
|
}
|
|
1701
1702
|
function a(s, e, t) {
|
|
1702
1703
|
const i = document.createElement(s);
|
|
1703
1704
|
return e && (i.className = e), t !== void 0 && (i.textContent = t), i;
|
|
1704
1705
|
}
|
|
1705
|
-
function
|
|
1706
|
+
function Kt(s) {
|
|
1706
1707
|
try {
|
|
1707
1708
|
return new Date(s).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
1708
1709
|
} catch {
|
|
@@ -1726,7 +1727,7 @@ function G(s) {
|
|
|
1726
1727
|
return `📅 ${s.title} — ${new Date(s.startIso).toLocaleString()}`;
|
|
1727
1728
|
}
|
|
1728
1729
|
}
|
|
1729
|
-
class
|
|
1730
|
+
class At {
|
|
1730
1731
|
/** Last seq the guest has seen per conversationId — used to compute unread badges. */
|
|
1731
1732
|
constructor(e, t, i, n = {}) {
|
|
1732
1733
|
r(this, "scroll");
|
|
@@ -1760,7 +1761,7 @@ class Bt {
|
|
|
1760
1761
|
r(this, "showingTranslation", /* @__PURE__ */ new Set());
|
|
1761
1762
|
r(this, "subjectBuilt", !1);
|
|
1762
1763
|
var b, v, C, T, A, P, D, $, _;
|
|
1763
|
-
this.root = e, this.me = t, this.h = i, this.cfg = n,
|
|
1764
|
+
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);
|
|
1764
1765
|
const o = a("div", "ocw-head"), c = a("div", "ocw-avatar");
|
|
1765
1766
|
if ((b = n.userInfo) != null && b.avatar) {
|
|
1766
1767
|
const k = document.createElement("img");
|
|
@@ -1776,7 +1777,9 @@ class Bt {
|
|
|
1776
1777
|
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");
|
|
1777
1778
|
for (const k of n.quickReplies ?? []) {
|
|
1778
1779
|
const E = a("button", void 0, k);
|
|
1779
|
-
E.addEventListener("click", () =>
|
|
1780
|
+
E.addEventListener("click", () => {
|
|
1781
|
+
this.h.onSend(k), this.quick.style.display = "none";
|
|
1782
|
+
}), this.quick.append(E);
|
|
1780
1783
|
}
|
|
1781
1784
|
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
1785
|
const f = a("button", "ocw-sendbtn", (($ = n.i18n) == null ? void 0 : $.send) ?? "➤");
|
|
@@ -2104,7 +2107,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
|
|
|
2104
2107
|
}), p.append(T);
|
|
2105
2108
|
}
|
|
2106
2109
|
const g = a("button", "ocw-react-btn", "+"), b = a("div", "ocw-react-picker");
|
|
2107
|
-
for (const v of
|
|
2110
|
+
for (const v of Tt) {
|
|
2108
2111
|
const C = a("button", void 0, v);
|
|
2109
2112
|
C.addEventListener("click", (T) => {
|
|
2110
2113
|
var P, D, $, _;
|
|
@@ -2119,15 +2122,15 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
|
|
|
2119
2122
|
b.style.display = "none";
|
|
2120
2123
|
}, { once: !0 }), p.append(g), h.append(p, b), c.append(h);
|
|
2121
2124
|
} 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",
|
|
2125
|
+
const m = a("div", "ocw-time ocw-meta", Kt(e.ts));
|
|
2123
2126
|
if (i && e.status) {
|
|
2124
|
-
const h = a("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`,
|
|
2127
|
+
const h = a("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, zt(e.status));
|
|
2125
2128
|
m.append(h);
|
|
2126
2129
|
}
|
|
2127
2130
|
return i && e.seq > 0 && t.lastReadByOthers >= e.seq && m.append(a("span", "ocw-seen", " · Seen")), c.append(m), o.append(c), o;
|
|
2128
2131
|
}
|
|
2129
2132
|
}
|
|
2130
|
-
function
|
|
2133
|
+
function zt(s) {
|
|
2131
2134
|
switch (s) {
|
|
2132
2135
|
case "read":
|
|
2133
2136
|
return "✓✓";
|
|
@@ -2139,11 +2142,11 @@ function Kt(s) {
|
|
|
2139
2142
|
return "🕓";
|
|
2140
2143
|
}
|
|
2141
2144
|
}
|
|
2142
|
-
function
|
|
2143
|
-
var se, oe;
|
|
2144
|
-
const e = s.token ??
|
|
2145
|
-
let t = new
|
|
2146
|
-
const i = s.subjectId ? `${e}::${s.subjectId}` : e, n = new
|
|
2145
|
+
function $t(s) {
|
|
2146
|
+
var se, oe, re, ae;
|
|
2147
|
+
const e = s.token ?? Ee();
|
|
2148
|
+
let t = new pt(e);
|
|
2149
|
+
const i = s.subjectId ? `${e}::${s.subjectId}` : e, n = new xt(i);
|
|
2147
2150
|
let o, c = !1, l = null;
|
|
2148
2151
|
!s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
|
|
2149
2152
|
for (const d of n.load()) t.addOptimistic(d.clientMsgId, d.content);
|
|
@@ -2216,7 +2219,7 @@ function Mt(s) {
|
|
|
2216
2219
|
}
|
|
2217
2220
|
};
|
|
2218
2221
|
let g;
|
|
2219
|
-
const b = new
|
|
2222
|
+
const b = new Et(`ocw-e2e-${s.profileId}`);
|
|
2220
2223
|
let v = !1;
|
|
2221
2224
|
const C = [], T = [];
|
|
2222
2225
|
let A = !1;
|
|
@@ -2241,7 +2244,7 @@ function Mt(s) {
|
|
|
2241
2244
|
g.send({ type: "fetchPrekey", targetUserId: d });
|
|
2242
2245
|
}, k = s.i18n ?? {}, E = ["ar", "he", "fa", "ur"], Y = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
|
|
2243
2246
|
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
|
|
2247
|
+
const K = new At(s.el, e, {
|
|
2245
2248
|
onSend(d) {
|
|
2246
2249
|
if (!o) return;
|
|
2247
2250
|
const u = `cm_${Math.random().toString(36).slice(2)}`;
|
|
@@ -2258,8 +2261,8 @@ function Mt(s) {
|
|
|
2258
2261
|
body: d
|
|
2259
2262
|
});
|
|
2260
2263
|
if (!z.ok) throw new Error(`Upload failed: ${z.status}`);
|
|
2261
|
-
const { url: R, name:
|
|
2262
|
-
g.send({ type: "send", conversationId: o, clientMsgId: I, content: { kind: "attachment", url: R, name:
|
|
2264
|
+
const { url: R, name: ve, mime: ke, size: Se } = await z.json();
|
|
2265
|
+
g.send({ type: "send", conversationId: o, clientMsgId: I, content: { kind: "attachment", url: R, name: ve, mime: ke, size: Se } });
|
|
2263
2266
|
} catch (z) {
|
|
2264
2267
|
t.addOptimistic(I, { kind: "text", text: `⚠️ Upload failed: ${z.message}` }), K.render(t);
|
|
2265
2268
|
}
|
|
@@ -2326,15 +2329,17 @@ function Mt(s) {
|
|
|
2326
2329
|
...s.accent ? { accent: s.accent } : {},
|
|
2327
2330
|
...(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
2331
|
i18n: k
|
|
2329
|
-
}),
|
|
2332
|
+
}), be = {
|
|
2330
2333
|
type: "open",
|
|
2331
2334
|
profileId: s.profileId,
|
|
2332
2335
|
...s.subjectId ? { subjectId: s.subjectId } : {},
|
|
2333
|
-
// Auto-capture the page context so agents know where the guest is browsing.
|
|
2334
|
-
// This is pure display metadata — it never affects identity or access.
|
|
2335
2336
|
...typeof location < "u" ? { pageUrl: location.href } : {},
|
|
2336
|
-
...typeof document < "u" && document.title ? { pageTitle: document.title } : {}
|
|
2337
|
-
|
|
2337
|
+
...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
|
|
2338
|
+
// Pass subject display info so the server can persist it to the Subject record.
|
|
2339
|
+
// This is how listingTitle and listingMeta get saved without a separate API call.
|
|
2340
|
+
...(re = s.subject) != null && re.title ? { subjectTitle: s.subject.title } : {},
|
|
2341
|
+
...(ae = s.subject) != null && ae.subtitle ? { subjectMeta: s.subject.subtitle } : {}
|
|
2342
|
+
}, me = (d) => {
|
|
2338
2343
|
const u = s.user;
|
|
2339
2344
|
if (!u || !u.name && !u.email && !u.avatar && !u.meta) return;
|
|
2340
2345
|
const y = [];
|
|
@@ -2343,10 +2348,10 @@ function Mt(s) {
|
|
|
2343
2348
|
${y.join(`
|
|
2344
2349
|
`)}` });
|
|
2345
2350
|
};
|
|
2346
|
-
return g = new
|
|
2351
|
+
return g = new ut({
|
|
2347
2352
|
url: s.url,
|
|
2348
2353
|
token: e,
|
|
2349
|
-
open:
|
|
2354
|
+
open: be,
|
|
2350
2355
|
getCursor: () => t.highestSeq(),
|
|
2351
2356
|
onStatusChange: (d) => K.setConnStatus(d),
|
|
2352
2357
|
onFrame(d) {
|
|
@@ -2357,7 +2362,7 @@ ${y.join(`
|
|
|
2357
2362
|
for (const y of n.load())
|
|
2358
2363
|
g.send({ type: "send", conversationId: o, clientMsgId: y.clientMsgId, content: y.content });
|
|
2359
2364
|
}
|
|
2360
|
-
u && (
|
|
2365
|
+
u && (Ue(s.url, e, o, t, K), d.conversation.lastSeq === 0 && me(o));
|
|
2361
2366
|
}
|
|
2362
2367
|
if (d.type === "ack" && n.remove(d.clientMsgId), d.type === "prekeyBundle") {
|
|
2363
2368
|
d.bundle && (A = !0, b.x3dhSendTo(d.bundle).then((u) => {
|
|
@@ -2368,7 +2373,7 @@ ${y.join(`
|
|
|
2368
2373
|
return;
|
|
2369
2374
|
}
|
|
2370
2375
|
if (d.type === "message" && t.e2e) {
|
|
2371
|
-
const u =
|
|
2376
|
+
const u = Ut(d.message.content);
|
|
2372
2377
|
if (u && !b.ready) {
|
|
2373
2378
|
b.x3dhReceiveFrom(u.x3dhIK, u.x3dhEK, u.x3dhSPK).then(async () => {
|
|
2374
2379
|
await b.openFrame(d), t.apply(d), K.render(t);
|
|
@@ -2398,15 +2403,15 @@ ${y.join(`
|
|
|
2398
2403
|
} }, l;
|
|
2399
2404
|
}
|
|
2400
2405
|
export {
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2406
|
+
pt as ChatStore,
|
|
2407
|
+
ut as ConnectionManager,
|
|
2408
|
+
Et as E2ESession,
|
|
2409
|
+
xt as PersistentOutbox,
|
|
2410
|
+
At as Renderer,
|
|
2411
|
+
Dt as asConversationId,
|
|
2412
|
+
Ut as extractX3DHInit,
|
|
2413
|
+
Rt as httpBaseFromWsUrl,
|
|
2414
|
+
$t as mount,
|
|
2415
|
+
Ue as restoreHistory
|
|
2411
2416
|
};
|
|
2412
2417
|
//# sourceMappingURL=index.js.map
|