@paramms/chat-widget 1.0.2 → 1.0.3
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/README.md +74 -0
- package/dist/index.js +375 -345
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (s, e, t) =>
|
|
1
|
+
var Ue = Object.defineProperty;
|
|
2
|
+
var Te = (s, e, t) => e in s ? Ue(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var a = (s, e, t) => Te(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
const Dt = (s) => s;
|
|
5
|
-
function
|
|
5
|
+
function Be(s) {
|
|
6
6
|
const e = s.length;
|
|
7
7
|
let t = 0, n = 0;
|
|
8
8
|
for (; n < e; ) {
|
|
@@ -24,7 +24,7 @@ function Ie(s) {
|
|
|
24
24
|
}
|
|
25
25
|
return t;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function Ae(s, e, t) {
|
|
28
28
|
const n = s.length;
|
|
29
29
|
let i = t, o = 0;
|
|
30
30
|
for (; o < n; ) {
|
|
@@ -46,15 +46,15 @@ function Ee(s, e, t) {
|
|
|
46
46
|
e[i++] = r & 63 | 128;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
function
|
|
51
|
-
|
|
49
|
+
const Pe = new TextEncoder(), Ke = 50;
|
|
50
|
+
function Le(s, e, t) {
|
|
51
|
+
Pe.encodeInto(s, e.subarray(t));
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
s.length >
|
|
53
|
+
function ze(s, e, t) {
|
|
54
|
+
s.length > Ke ? Le(s, e, t) : Ae(s, e, t);
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
function
|
|
56
|
+
const Me = 4096;
|
|
57
|
+
function ge(s, e, t) {
|
|
58
58
|
let n = e;
|
|
59
59
|
const i = n + t, o = [];
|
|
60
60
|
let r = "";
|
|
@@ -74,57 +74,57 @@ function pe(s, e, t) {
|
|
|
74
74
|
x > 65535 && (x -= 65536, o.push(x >>> 10 & 1023 | 55296), x = 56320 | x & 1023), o.push(x);
|
|
75
75
|
} else
|
|
76
76
|
o.push(d);
|
|
77
|
-
o.length >=
|
|
77
|
+
o.length >= Me && (r += String.fromCharCode(...o), o.length = 0);
|
|
78
78
|
}
|
|
79
79
|
return o.length > 0 && (r += String.fromCharCode(...o)), r;
|
|
80
80
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
81
|
+
const $e = new TextDecoder(), De = 200;
|
|
82
|
+
function _e(s, e, t) {
|
|
83
83
|
const n = s.subarray(e, e + t);
|
|
84
|
-
return
|
|
84
|
+
return $e.decode(n);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
return t >
|
|
86
|
+
function qe(s, e, t) {
|
|
87
|
+
return t > De ? _e(s, e, t) : ge(s, e, t);
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class Y {
|
|
90
90
|
constructor(e, t) {
|
|
91
91
|
a(this, "type");
|
|
92
92
|
a(this, "data");
|
|
93
93
|
this.type = e, this.data = t;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
class
|
|
96
|
+
class T extends Error {
|
|
97
97
|
constructor(e) {
|
|
98
98
|
super(e);
|
|
99
|
-
const t = Object.create(
|
|
99
|
+
const t = Object.create(T.prototype);
|
|
100
100
|
Object.setPrototypeOf(this, t), Object.defineProperty(this, "name", {
|
|
101
101
|
configurable: !0,
|
|
102
102
|
enumerable: !1,
|
|
103
|
-
value:
|
|
103
|
+
value: T.name
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
function
|
|
107
|
+
const j = 4294967295;
|
|
108
|
+
function He(s, e, t) {
|
|
109
109
|
const n = t / 4294967296, i = t;
|
|
110
110
|
s.setUint32(e, n), s.setUint32(e + 4, i);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function ye(s, e, t) {
|
|
113
113
|
const n = Math.floor(t / 4294967296), i = t;
|
|
114
114
|
s.setUint32(e, n), s.setUint32(e + 4, i);
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function be(s, e) {
|
|
117
117
|
const t = s.getInt32(e), n = s.getUint32(e + 4);
|
|
118
118
|
return t * 4294967296 + n;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Re(s, e) {
|
|
121
121
|
const t = s.getUint32(e), n = s.getUint32(e + 4);
|
|
122
122
|
return t * 4294967296 + n;
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
function
|
|
126
|
-
if (s >= 0 && e >= 0 && s <=
|
|
127
|
-
if (e === 0 && s <=
|
|
124
|
+
const Fe = -1, je = 4294967296 - 1, Oe = 17179869184 - 1;
|
|
125
|
+
function Ne({ sec: s, nsec: e }) {
|
|
126
|
+
if (s >= 0 && e >= 0 && s <= Oe)
|
|
127
|
+
if (e === 0 && s <= je) {
|
|
128
128
|
const t = new Uint8Array(4);
|
|
129
129
|
return new DataView(t.buffer).setUint32(0, s), t;
|
|
130
130
|
} else {
|
|
@@ -133,24 +133,24 @@ function He({ sec: s, nsec: e }) {
|
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
135
|
const t = new Uint8Array(12), n = new DataView(t.buffer);
|
|
136
|
-
return n.setUint32(0, e),
|
|
136
|
+
return n.setUint32(0, e), ye(n, 4, s), t;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function We(s) {
|
|
140
140
|
const e = s.getTime(), t = Math.floor(e / 1e3), n = (e - t * 1e3) * 1e6, i = Math.floor(n / 1e9);
|
|
141
141
|
return {
|
|
142
142
|
sec: t + i,
|
|
143
143
|
nsec: n - i * 1e9
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function Ve(s) {
|
|
147
147
|
if (s instanceof Date) {
|
|
148
|
-
const e =
|
|
149
|
-
return
|
|
148
|
+
const e = We(s);
|
|
149
|
+
return Ne(e);
|
|
150
150
|
} else
|
|
151
151
|
return null;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function Xe(s) {
|
|
154
154
|
const e = new DataView(s.buffer, s.byteOffset, s.byteLength);
|
|
155
155
|
switch (s.byteLength) {
|
|
156
156
|
case 4:
|
|
@@ -160,22 +160,22 @@ function Oe(s) {
|
|
|
160
160
|
return { sec: i, nsec: o };
|
|
161
161
|
}
|
|
162
162
|
case 12: {
|
|
163
|
-
const t =
|
|
163
|
+
const t = be(e, 4), n = e.getUint32(0);
|
|
164
164
|
return { sec: t, nsec: n };
|
|
165
165
|
}
|
|
166
166
|
default:
|
|
167
|
-
throw new
|
|
167
|
+
throw new T(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const e =
|
|
170
|
+
function Ye(s) {
|
|
171
|
+
const e = Xe(s);
|
|
172
172
|
return new Date(e.sec * 1e3 + e.nsec / 1e6);
|
|
173
173
|
}
|
|
174
|
-
const
|
|
175
|
-
type:
|
|
176
|
-
encode:
|
|
177
|
-
decode:
|
|
178
|
-
},
|
|
174
|
+
const Je = {
|
|
175
|
+
type: Fe,
|
|
176
|
+
encode: Ve,
|
|
177
|
+
decode: Ye
|
|
178
|
+
}, Z = class Z {
|
|
179
179
|
constructor() {
|
|
180
180
|
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
|
181
181
|
// this will make type errors a lot more clear
|
|
@@ -187,7 +187,7 @@ const We = {
|
|
|
187
187
|
// custom extensions
|
|
188
188
|
a(this, "encoders", []);
|
|
189
189
|
a(this, "decoders", []);
|
|
190
|
-
this.register(
|
|
190
|
+
this.register(Je);
|
|
191
191
|
}
|
|
192
192
|
register({ type: e, encode: t, decode: n }) {
|
|
193
193
|
if (e >= 0)
|
|
@@ -204,7 +204,7 @@ const We = {
|
|
|
204
204
|
const o = i(e, t);
|
|
205
205
|
if (o != null) {
|
|
206
206
|
const r = -1 - n;
|
|
207
|
-
return new
|
|
207
|
+
return new Y(r, o);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -214,27 +214,27 @@ const We = {
|
|
|
214
214
|
const o = i(e, t);
|
|
215
215
|
if (o != null) {
|
|
216
216
|
const r = n;
|
|
217
|
-
return new
|
|
217
|
+
return new Y(r, o);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
return e instanceof
|
|
221
|
+
return e instanceof Y ? e : null;
|
|
222
222
|
}
|
|
223
223
|
decode(e, t, n) {
|
|
224
224
|
const i = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
|
|
225
|
-
return i ? i(e, t, n) : new
|
|
225
|
+
return i ? i(e, t, n) : new Y(t, e);
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
|
-
a(
|
|
229
|
-
let
|
|
230
|
-
function
|
|
228
|
+
a(Z, "defaultCodec", new Z());
|
|
229
|
+
let J = Z;
|
|
230
|
+
function Ge(s) {
|
|
231
231
|
return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) :
|
|
233
|
+
function te(s) {
|
|
234
|
+
return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) : Ge(s) ? new Uint8Array(s) : Uint8Array.from(s);
|
|
235
235
|
}
|
|
236
|
-
const
|
|
237
|
-
class
|
|
236
|
+
const Ze = 100, Qe = 2048;
|
|
237
|
+
class se {
|
|
238
238
|
constructor(e) {
|
|
239
239
|
a(this, "extensionCodec");
|
|
240
240
|
a(this, "context");
|
|
@@ -249,10 +249,10 @@ class ne {
|
|
|
249
249
|
a(this, "view");
|
|
250
250
|
a(this, "bytes");
|
|
251
251
|
a(this, "entered", !1);
|
|
252
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
252
|
+
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? J.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) ?? Ze, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? Qe, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
|
|
253
253
|
}
|
|
254
254
|
clone() {
|
|
255
|
-
return new
|
|
255
|
+
return new se({
|
|
256
256
|
extensionCodec: this.extensionCodec,
|
|
257
257
|
context: this.context,
|
|
258
258
|
useBigInt64: this.useBigInt64,
|
|
@@ -334,8 +334,8 @@ class ne {
|
|
|
334
334
|
throw new Error(`Too long string: ${e} bytes in UTF-8`);
|
|
335
335
|
}
|
|
336
336
|
encodeString(e) {
|
|
337
|
-
const n =
|
|
338
|
-
this.ensureBufferSizeToWrite(5 + n), this.writeStringHeader(n),
|
|
337
|
+
const n = Be(e);
|
|
338
|
+
this.ensureBufferSizeToWrite(5 + n), this.writeStringHeader(n), ze(e, this.bytes, this.pos), this.pos += n;
|
|
339
339
|
}
|
|
340
340
|
encodeObject(e, t) {
|
|
341
341
|
const n = this.extensionCodec.tryToEncode(e, this.context);
|
|
@@ -360,7 +360,7 @@ class ne {
|
|
|
360
360
|
this.writeU8(198), this.writeU32(t);
|
|
361
361
|
else
|
|
362
362
|
throw new Error(`Too large binary: ${t}`);
|
|
363
|
-
const n =
|
|
363
|
+
const n = te(e);
|
|
364
364
|
this.writeU8a(n);
|
|
365
365
|
}
|
|
366
366
|
encodeArray(e, t) {
|
|
@@ -457,10 +457,10 @@ class ne {
|
|
|
457
457
|
this.ensureBufferSizeToWrite(8), this.view.setFloat64(this.pos, e), this.pos += 8;
|
|
458
458
|
}
|
|
459
459
|
writeU64(e) {
|
|
460
|
-
this.ensureBufferSizeToWrite(8),
|
|
460
|
+
this.ensureBufferSizeToWrite(8), He(this.view, this.pos, e), this.pos += 8;
|
|
461
461
|
}
|
|
462
462
|
writeI64(e) {
|
|
463
|
-
this.ensureBufferSizeToWrite(8),
|
|
463
|
+
this.ensureBufferSizeToWrite(8), ye(this.view, this.pos, e), this.pos += 8;
|
|
464
464
|
}
|
|
465
465
|
writeBigUint64(e) {
|
|
466
466
|
this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
|
|
@@ -469,15 +469,15 @@ class ne {
|
|
|
469
469
|
this.ensureBufferSizeToWrite(8), this.view.setBigInt64(this.pos, e), this.pos += 8;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
function
|
|
473
|
-
return new
|
|
472
|
+
function et(s, e) {
|
|
473
|
+
return new se(e).encodeSharedRef(s);
|
|
474
474
|
}
|
|
475
|
-
function
|
|
475
|
+
function Q(s) {
|
|
476
476
|
return `${s < 0 ? "-" : ""}0x${Math.abs(s).toString(16).padStart(2, "0")}`;
|
|
477
477
|
}
|
|
478
|
-
const
|
|
479
|
-
class
|
|
480
|
-
constructor(e =
|
|
478
|
+
const tt = 16, it = 16;
|
|
479
|
+
class nt {
|
|
480
|
+
constructor(e = tt, t = it) {
|
|
481
481
|
a(this, "hit", 0);
|
|
482
482
|
a(this, "miss", 0);
|
|
483
483
|
a(this, "caches");
|
|
@@ -510,16 +510,16 @@ class Qe {
|
|
|
510
510
|
if (i != null)
|
|
511
511
|
return this.hit++, i;
|
|
512
512
|
this.miss++;
|
|
513
|
-
const o =
|
|
513
|
+
const o = ge(e, t, n), r = Uint8Array.prototype.slice.call(e, t, t + n);
|
|
514
514
|
return this.store(r, o), o;
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
const
|
|
517
|
+
const ie = "array", N = "map_key", me = "map_value", st = (s) => {
|
|
518
518
|
if (typeof s == "string" || typeof s == "number")
|
|
519
519
|
return s;
|
|
520
|
-
throw new
|
|
520
|
+
throw new T("The type of key must be string or number but " + typeof s);
|
|
521
521
|
};
|
|
522
|
-
class
|
|
522
|
+
class ot {
|
|
523
523
|
constructor() {
|
|
524
524
|
a(this, "stack", []);
|
|
525
525
|
a(this, "stackHeadPosition", -1);
|
|
@@ -532,11 +532,11 @@ class tt {
|
|
|
532
532
|
}
|
|
533
533
|
pushArrayState(e) {
|
|
534
534
|
const t = this.getUninitializedStateFromPool();
|
|
535
|
-
t.type =
|
|
535
|
+
t.type = ie, t.position = 0, t.size = e, t.array = new Array(e);
|
|
536
536
|
}
|
|
537
537
|
pushMapState(e) {
|
|
538
538
|
const t = this.getUninitializedStateFromPool();
|
|
539
|
-
t.type =
|
|
539
|
+
t.type = N, t.readCount = 0, t.size = e, t.map = {};
|
|
540
540
|
}
|
|
541
541
|
getUninitializedStateFromPool() {
|
|
542
542
|
if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
|
|
@@ -556,11 +556,11 @@ class tt {
|
|
|
556
556
|
release(e) {
|
|
557
557
|
if (this.stack[this.stackHeadPosition] !== e)
|
|
558
558
|
throw new Error("Invalid stack state. Released state is not on top of the stack.");
|
|
559
|
-
if (e.type ===
|
|
559
|
+
if (e.type === ie) {
|
|
560
560
|
const n = e;
|
|
561
561
|
n.size = 0, n.array = void 0, n.position = 0, n.type = void 0;
|
|
562
562
|
}
|
|
563
|
-
if (e.type ===
|
|
563
|
+
if (e.type === N || e.type === me) {
|
|
564
564
|
const n = e;
|
|
565
565
|
n.size = 0, n.map = void 0, n.readCount = 0, n.type = void 0;
|
|
566
566
|
}
|
|
@@ -570,15 +570,15 @@ class tt {
|
|
|
570
570
|
this.stack.length = 0, this.stackHeadPosition = -1;
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
const
|
|
573
|
+
const O = -1, oe = new DataView(new ArrayBuffer(0)), rt = new Uint8Array(oe.buffer);
|
|
574
574
|
try {
|
|
575
|
-
|
|
575
|
+
oe.getInt8(0);
|
|
576
576
|
} catch (s) {
|
|
577
577
|
if (!(s instanceof RangeError))
|
|
578
578
|
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
|
|
579
579
|
}
|
|
580
|
-
const
|
|
581
|
-
class
|
|
580
|
+
const ae = new RangeError("Insufficient data"), at = new nt();
|
|
581
|
+
class re {
|
|
582
582
|
constructor(e) {
|
|
583
583
|
a(this, "extensionCodec");
|
|
584
584
|
a(this, "context");
|
|
@@ -593,15 +593,15 @@ class oe {
|
|
|
593
593
|
a(this, "mapKeyConverter");
|
|
594
594
|
a(this, "totalPos", 0);
|
|
595
595
|
a(this, "pos", 0);
|
|
596
|
-
a(this, "view",
|
|
597
|
-
a(this, "bytes",
|
|
598
|
-
a(this, "headByte",
|
|
599
|
-
a(this, "stack", new
|
|
596
|
+
a(this, "view", oe);
|
|
597
|
+
a(this, "bytes", rt);
|
|
598
|
+
a(this, "headByte", O);
|
|
599
|
+
a(this, "stack", new ot());
|
|
600
600
|
a(this, "entered", !1);
|
|
601
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
601
|
+
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? J.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 : at, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? st;
|
|
602
602
|
}
|
|
603
603
|
clone() {
|
|
604
|
-
return new
|
|
604
|
+
return new re({
|
|
605
605
|
extensionCodec: this.extensionCodec,
|
|
606
606
|
context: this.context,
|
|
607
607
|
useBigInt64: this.useBigInt64,
|
|
@@ -615,17 +615,17 @@ class oe {
|
|
|
615
615
|
});
|
|
616
616
|
}
|
|
617
617
|
reinitializeState() {
|
|
618
|
-
this.totalPos = 0, this.headByte =
|
|
618
|
+
this.totalPos = 0, this.headByte = O, this.stack.reset();
|
|
619
619
|
}
|
|
620
620
|
setBuffer(e) {
|
|
621
|
-
const t =
|
|
621
|
+
const t = te(e);
|
|
622
622
|
this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
|
|
623
623
|
}
|
|
624
624
|
appendBuffer(e) {
|
|
625
|
-
if (this.headByte ===
|
|
625
|
+
if (this.headByte === O && !this.hasRemaining(1))
|
|
626
626
|
this.setBuffer(e);
|
|
627
627
|
else {
|
|
628
|
-
const t = this.bytes.subarray(this.pos), n =
|
|
628
|
+
const t = this.bytes.subarray(this.pos), n = te(e), i = new Uint8Array(t.length + n.length);
|
|
629
629
|
i.set(t), i.set(n, t.length), this.setBuffer(i);
|
|
630
630
|
}
|
|
631
631
|
}
|
|
@@ -689,7 +689,7 @@ class oe {
|
|
|
689
689
|
return n;
|
|
690
690
|
}
|
|
691
691
|
const { headByte: i, pos: o, totalPos: r } = this;
|
|
692
|
-
throw new RangeError(`Insufficient data in parsing ${
|
|
692
|
+
throw new RangeError(`Insufficient data in parsing ${Q(i)} at ${r} (${o} in the current buffer)`);
|
|
693
693
|
} finally {
|
|
694
694
|
this.entered = !1;
|
|
695
695
|
}
|
|
@@ -844,25 +844,25 @@ class oe {
|
|
|
844
844
|
const i = this.lookU32();
|
|
845
845
|
t = this.decodeExtension(i, 4);
|
|
846
846
|
} else
|
|
847
|
-
throw new
|
|
847
|
+
throw new T(`Unrecognized type byte: ${Q(e)}`);
|
|
848
848
|
this.complete();
|
|
849
849
|
const n = this.stack;
|
|
850
850
|
for (; n.length > 0; ) {
|
|
851
851
|
const i = n.top();
|
|
852
|
-
if (i.type ===
|
|
852
|
+
if (i.type === ie)
|
|
853
853
|
if (i.array[i.position] = t, i.position++, i.position === i.size)
|
|
854
854
|
t = i.array, n.release(i);
|
|
855
855
|
else
|
|
856
856
|
continue e;
|
|
857
|
-
else if (i.type ===
|
|
857
|
+
else if (i.type === N) {
|
|
858
858
|
if (t === "__proto__")
|
|
859
|
-
throw new
|
|
860
|
-
i.key = this.mapKeyConverter(t), i.type =
|
|
859
|
+
throw new T("The key __proto__ is not allowed");
|
|
860
|
+
i.key = this.mapKeyConverter(t), i.type = me;
|
|
861
861
|
continue e;
|
|
862
862
|
} else if (i.map[i.key] = t, i.readCount++, i.readCount === i.size)
|
|
863
863
|
t = i.map, n.release(i);
|
|
864
864
|
else {
|
|
865
|
-
i.key = null, i.type =
|
|
865
|
+
i.key = null, i.type = N;
|
|
866
866
|
continue e;
|
|
867
867
|
}
|
|
868
868
|
}
|
|
@@ -870,10 +870,10 @@ class oe {
|
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
872
|
readHeadByte() {
|
|
873
|
-
return this.headByte ===
|
|
873
|
+
return this.headByte === O && (this.headByte = this.readU8()), this.headByte;
|
|
874
874
|
}
|
|
875
875
|
complete() {
|
|
876
|
-
this.headByte =
|
|
876
|
+
this.headByte = O;
|
|
877
877
|
}
|
|
878
878
|
readArraySize() {
|
|
879
879
|
const e = this.readHeadByte();
|
|
@@ -885,18 +885,18 @@ class oe {
|
|
|
885
885
|
default: {
|
|
886
886
|
if (e < 160)
|
|
887
887
|
return e - 144;
|
|
888
|
-
throw new
|
|
888
|
+
throw new T(`Unrecognized array type byte: ${Q(e)}`);
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
892
|
pushMapState(e) {
|
|
893
893
|
if (e > this.maxMapLength)
|
|
894
|
-
throw new
|
|
894
|
+
throw new T(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);
|
|
895
895
|
this.stack.pushMapState(e);
|
|
896
896
|
}
|
|
897
897
|
pushArrayState(e) {
|
|
898
898
|
if (e > this.maxArrayLength)
|
|
899
|
-
throw new
|
|
899
|
+
throw new T(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);
|
|
900
900
|
this.stack.pushArrayState(e);
|
|
901
901
|
}
|
|
902
902
|
decodeString(e, t) {
|
|
@@ -908,30 +908,30 @@ class oe {
|
|
|
908
908
|
decodeUtf8String(e, t) {
|
|
909
909
|
var o;
|
|
910
910
|
if (e > this.maxStrLength)
|
|
911
|
-
throw new
|
|
911
|
+
throw new T(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
|
|
912
912
|
if (this.bytes.byteLength < this.pos + t + e)
|
|
913
|
-
throw
|
|
913
|
+
throw ae;
|
|
914
914
|
const n = this.pos + t;
|
|
915
915
|
let i;
|
|
916
|
-
return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, n, e) : i =
|
|
916
|
+
return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, n, e) : i = qe(this.bytes, n, e), this.pos += t + e, i;
|
|
917
917
|
}
|
|
918
918
|
stateIsMapKey() {
|
|
919
|
-
return this.stack.length > 0 ? this.stack.top().type ===
|
|
919
|
+
return this.stack.length > 0 ? this.stack.top().type === N : !1;
|
|
920
920
|
}
|
|
921
921
|
/**
|
|
922
922
|
* @throws {@link RangeError}
|
|
923
923
|
*/
|
|
924
924
|
decodeBinary(e, t) {
|
|
925
925
|
if (e > this.maxBinLength)
|
|
926
|
-
throw new
|
|
926
|
+
throw new T(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
|
|
927
927
|
if (!this.hasRemaining(e + t))
|
|
928
|
-
throw
|
|
928
|
+
throw ae;
|
|
929
929
|
const n = this.pos + t, i = this.bytes.subarray(n, n + e);
|
|
930
930
|
return this.pos += t + e, i;
|
|
931
931
|
}
|
|
932
932
|
decodeExtension(e, t) {
|
|
933
933
|
if (e > this.maxExtLength)
|
|
934
|
-
throw new
|
|
934
|
+
throw new T(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);
|
|
935
935
|
const n = this.view.getInt8(this.pos + t), i = this.decodeBinary(
|
|
936
936
|
e,
|
|
937
937
|
t + 1
|
|
@@ -973,11 +973,11 @@ class oe {
|
|
|
973
973
|
return this.pos += 4, e;
|
|
974
974
|
}
|
|
975
975
|
readU64() {
|
|
976
|
-
const e =
|
|
976
|
+
const e = Re(this.view, this.pos);
|
|
977
977
|
return this.pos += 8, e;
|
|
978
978
|
}
|
|
979
979
|
readI64() {
|
|
980
|
-
const e =
|
|
980
|
+
const e = be(this.view, this.pos);
|
|
981
981
|
return this.pos += 8, e;
|
|
982
982
|
}
|
|
983
983
|
readU64AsBigInt() {
|
|
@@ -997,10 +997,10 @@ class oe {
|
|
|
997
997
|
return this.pos += 8, e;
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
|
-
function
|
|
1001
|
-
return new
|
|
1000
|
+
function ct(s, e) {
|
|
1001
|
+
return new re(e).decode(s);
|
|
1002
1002
|
}
|
|
1003
|
-
const
|
|
1003
|
+
const dt = /* @__PURE__ */ new Set([
|
|
1004
1004
|
"auth",
|
|
1005
1005
|
"open",
|
|
1006
1006
|
"send",
|
|
@@ -1017,22 +1017,22 @@ const ot = /* @__PURE__ */ new Set([
|
|
|
1017
1017
|
"annotate",
|
|
1018
1018
|
"annotate_clear"
|
|
1019
1019
|
]);
|
|
1020
|
-
function
|
|
1021
|
-
return
|
|
1020
|
+
function lt(s) {
|
|
1021
|
+
return dt.has(s.type);
|
|
1022
1022
|
}
|
|
1023
|
-
function
|
|
1024
|
-
return
|
|
1023
|
+
function ht(s) {
|
|
1024
|
+
return et(s);
|
|
1025
1025
|
}
|
|
1026
|
-
function
|
|
1026
|
+
function pt(s) {
|
|
1027
1027
|
let e;
|
|
1028
1028
|
try {
|
|
1029
|
-
e =
|
|
1029
|
+
e = ct(s);
|
|
1030
1030
|
} catch {
|
|
1031
1031
|
return null;
|
|
1032
1032
|
}
|
|
1033
1033
|
return typeof e != "object" || e === null || typeof e.type != "string" ? null : e;
|
|
1034
1034
|
}
|
|
1035
|
-
class
|
|
1035
|
+
class ce {
|
|
1036
1036
|
constructor(e) {
|
|
1037
1037
|
a(this, "conversationId");
|
|
1038
1038
|
a(this, "state", "");
|
|
@@ -1178,10 +1178,10 @@ class dt {
|
|
|
1178
1178
|
}
|
|
1179
1179
|
markOwnStatus(e, t) {
|
|
1180
1180
|
for (const [n, i] of this.byId)
|
|
1181
|
-
i.senderId === this.me && i.seq > 0 && i.seq <= e &&
|
|
1181
|
+
i.senderId === this.me && i.seq > 0 && i.seq <= e && de(t) > de(i.status) && (this.byId.set(n, { ...i, status: t }), this._sorted = null);
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
1184
|
-
function
|
|
1184
|
+
function de(s) {
|
|
1185
1185
|
switch (s) {
|
|
1186
1186
|
case "read":
|
|
1187
1187
|
return 3;
|
|
@@ -1193,7 +1193,7 @@ function ae(s) {
|
|
|
1193
1193
|
return 0;
|
|
1194
1194
|
}
|
|
1195
1195
|
}
|
|
1196
|
-
class
|
|
1196
|
+
class le {
|
|
1197
1197
|
constructor(e) {
|
|
1198
1198
|
a(this, "socket", null);
|
|
1199
1199
|
a(this, "state", "idle");
|
|
@@ -1208,12 +1208,12 @@ class lt {
|
|
|
1208
1208
|
var n, i;
|
|
1209
1209
|
if (this.state === "connecting" || this.state === "open") return;
|
|
1210
1210
|
this.stopped = !1, this.state = "connecting", this.authed = !1, (i = (n = this.opts).onStatusChange) == null || i.call(n, this.attempt > 0 ? "reconnecting" : "connecting");
|
|
1211
|
-
const t = (this.opts.socketFactory ??
|
|
1211
|
+
const t = (this.opts.socketFactory ?? ft)(this.opts.url);
|
|
1212
1212
|
t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
|
|
1213
1213
|
this.raw({ type: "auth", token: this.opts.token });
|
|
1214
1214
|
}, t.onmessage = (o) => {
|
|
1215
|
-
const r =
|
|
1216
|
-
!r ||
|
|
1215
|
+
const r = pt(new Uint8Array(o.data));
|
|
1216
|
+
!r || lt(r) || this.handle(r);
|
|
1217
1217
|
}, t.onclose = () => this.onClosed(), t.onerror = () => {
|
|
1218
1218
|
try {
|
|
1219
1219
|
t.close();
|
|
@@ -1252,7 +1252,7 @@ class lt {
|
|
|
1252
1252
|
raw(e) {
|
|
1253
1253
|
var t;
|
|
1254
1254
|
try {
|
|
1255
|
-
(t = this.socket) == null || t.send(
|
|
1255
|
+
(t = this.socket) == null || t.send(ht(e));
|
|
1256
1256
|
} catch {
|
|
1257
1257
|
this.outbox.push(e);
|
|
1258
1258
|
}
|
|
@@ -1267,11 +1267,11 @@ class lt {
|
|
|
1267
1267
|
this.attempt++, this.timer = setTimeout(() => this.connect(), n);
|
|
1268
1268
|
}
|
|
1269
1269
|
}
|
|
1270
|
-
function
|
|
1270
|
+
function ft(s) {
|
|
1271
1271
|
return new WebSocket(s);
|
|
1272
1272
|
}
|
|
1273
|
-
const
|
|
1274
|
-
class
|
|
1273
|
+
const he = 200, ut = 7 * 864e5;
|
|
1274
|
+
class pe {
|
|
1275
1275
|
constructor(e) {
|
|
1276
1276
|
a(this, "key");
|
|
1277
1277
|
this.key = `ocw_outbox_${e}`;
|
|
@@ -1281,7 +1281,7 @@ class ft {
|
|
|
1281
1281
|
try {
|
|
1282
1282
|
const e = localStorage.getItem(this.key);
|
|
1283
1283
|
if (!e) return [];
|
|
1284
|
-
const t = JSON.parse(e), n = Date.now() -
|
|
1284
|
+
const t = JSON.parse(e), n = Date.now() - ut, i = t.filter((o) => o.ts >= n);
|
|
1285
1285
|
return i.length !== t.length && this.save(i), i;
|
|
1286
1286
|
} catch {
|
|
1287
1287
|
return [];
|
|
@@ -1290,7 +1290,7 @@ class ft {
|
|
|
1290
1290
|
add(e) {
|
|
1291
1291
|
try {
|
|
1292
1292
|
const t = this.load();
|
|
1293
|
-
t.push(e), this.save(t.length >
|
|
1293
|
+
t.push(e), this.save(t.length > he ? t.slice(t.length - he) : t);
|
|
1294
1294
|
} catch {
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
@@ -1309,31 +1309,31 @@ class ft {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
|
-
const
|
|
1313
|
-
function
|
|
1312
|
+
const C = () => globalThis.crypto.subtle;
|
|
1313
|
+
function G(s) {
|
|
1314
1314
|
const e = s instanceof Uint8Array ? s : new Uint8Array(s);
|
|
1315
1315
|
let t = "";
|
|
1316
1316
|
for (const n of e) t += String.fromCharCode(n);
|
|
1317
1317
|
return btoa(t);
|
|
1318
1318
|
}
|
|
1319
|
-
function
|
|
1319
|
+
function ne(s) {
|
|
1320
1320
|
const e = atob(s), t = new ArrayBuffer(e.length), n = new Uint8Array(t);
|
|
1321
1321
|
for (let i = 0; i < e.length; i++) n[i] = e.charCodeAt(i);
|
|
1322
1322
|
return n;
|
|
1323
1323
|
}
|
|
1324
|
-
async function
|
|
1325
|
-
const s = await
|
|
1324
|
+
async function W() {
|
|
1325
|
+
const s = await C().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
|
|
1326
1326
|
return { publicKey: s.publicKey, privateKey: s.privateKey };
|
|
1327
1327
|
}
|
|
1328
1328
|
async function M(s) {
|
|
1329
|
-
return
|
|
1329
|
+
return G(await C().exportKey("raw", s));
|
|
1330
1330
|
}
|
|
1331
|
-
async function
|
|
1332
|
-
return
|
|
1331
|
+
async function R(s) {
|
|
1332
|
+
return C().importKey("raw", ne(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
|
|
1333
1333
|
}
|
|
1334
|
-
async function
|
|
1335
|
-
const t = await
|
|
1336
|
-
return
|
|
1334
|
+
async function wt(s, e) {
|
|
1335
|
+
const t = await R(e);
|
|
1336
|
+
return C().deriveKey(
|
|
1337
1337
|
{ name: "ECDH", public: t },
|
|
1338
1338
|
s,
|
|
1339
1339
|
{ name: "AES-GCM", length: 256 },
|
|
@@ -1341,38 +1341,38 @@ async function ut(s, e) {
|
|
|
1341
1341
|
["encrypt", "decrypt"]
|
|
1342
1342
|
);
|
|
1343
1343
|
}
|
|
1344
|
-
async function
|
|
1345
|
-
const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), n = new TextEncoder().encode(e), i = await
|
|
1346
|
-
return { ct:
|
|
1344
|
+
async function xt(s, e) {
|
|
1345
|
+
const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), n = new TextEncoder().encode(e), i = await C().encrypt({ name: "AES-GCM", iv: t }, s, n);
|
|
1346
|
+
return { ct: G(i), iv: G(t) };
|
|
1347
1347
|
}
|
|
1348
|
-
async function
|
|
1349
|
-
const n = await
|
|
1348
|
+
async function gt(s, e, t) {
|
|
1349
|
+
const n = await C().decrypt({ name: "AES-GCM", iv: ne(t) }, s, ne(e));
|
|
1350
1350
|
return new TextDecoder().decode(n);
|
|
1351
1351
|
}
|
|
1352
|
-
async function
|
|
1352
|
+
async function yt(s) {
|
|
1353
1353
|
var t, n;
|
|
1354
1354
|
try {
|
|
1355
1355
|
const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
|
|
1356
1356
|
if (i) {
|
|
1357
|
-
const { pub: o, priv: r } = JSON.parse(i), d = await
|
|
1357
|
+
const { pub: o, priv: r } = JSON.parse(i), d = await C().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), u = await C().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
|
|
1358
1358
|
return { publicKey: d, privateKey: u };
|
|
1359
1359
|
}
|
|
1360
1360
|
} catch {
|
|
1361
1361
|
}
|
|
1362
|
-
const e = await
|
|
1362
|
+
const e = await W();
|
|
1363
1363
|
try {
|
|
1364
|
-
const i = await
|
|
1364
|
+
const i = await C().exportKey("jwk", e.publicKey), o = await C().exportKey("jwk", e.privateKey);
|
|
1365
1365
|
(n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv: o }));
|
|
1366
1366
|
} catch {
|
|
1367
1367
|
}
|
|
1368
1368
|
return e;
|
|
1369
1369
|
}
|
|
1370
|
-
async function
|
|
1371
|
-
const t = await
|
|
1372
|
-
return
|
|
1370
|
+
async function bt(s, e) {
|
|
1371
|
+
const t = await C().exportKey("raw", e), n = await C().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
|
|
1372
|
+
return G(n);
|
|
1373
1373
|
}
|
|
1374
|
-
async function
|
|
1375
|
-
const s = await
|
|
1374
|
+
async function mt() {
|
|
1375
|
+
const s = await W(), e = await C().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
|
|
1376
1376
|
return {
|
|
1377
1377
|
ecdhKP: s,
|
|
1378
1378
|
ecdsaKP: { publicKey: e.publicKey, privateKey: e.privateKey },
|
|
@@ -1380,12 +1380,12 @@ async function bt() {
|
|
|
1380
1380
|
sigPublicKeyB64: await M(e.publicKey)
|
|
1381
1381
|
};
|
|
1382
1382
|
}
|
|
1383
|
-
async function
|
|
1383
|
+
async function fe(s) {
|
|
1384
1384
|
var t, n;
|
|
1385
1385
|
try {
|
|
1386
1386
|
const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
|
|
1387
1387
|
if (i) {
|
|
1388
|
-
const o = JSON.parse(i), r = await
|
|
1388
|
+
const o = JSON.parse(i), r = await C().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), d = await C().importKey("jwk", o.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), u = await C().importKey("jwk", o.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), w = await C().importKey("jwk", o.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
|
|
1389
1389
|
return {
|
|
1390
1390
|
ecdhKP: { publicKey: r, privateKey: d },
|
|
1391
1391
|
ecdsaKP: { publicKey: u, privateKey: w },
|
|
@@ -1395,35 +1395,35 @@ async function de(s) {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
} catch {
|
|
1397
1397
|
}
|
|
1398
|
-
const e = await
|
|
1398
|
+
const e = await mt();
|
|
1399
1399
|
try {
|
|
1400
|
-
const i = await
|
|
1400
|
+
const i = await C().exportKey("jwk", e.ecdhKP.publicKey), o = await C().exportKey("jwk", e.ecdhKP.privateKey), r = await C().exportKey("jwk", e.ecdsaKP.publicKey), d = await C().exportKey("jwk", e.ecdsaKP.privateKey);
|
|
1401
1401
|
(n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: o, ecdsaPub: r, ecdsaPriv: d }));
|
|
1402
1402
|
} catch {
|
|
1403
1403
|
}
|
|
1404
1404
|
return e;
|
|
1405
1405
|
}
|
|
1406
|
-
async function
|
|
1407
|
-
const t = await
|
|
1408
|
-
return { sharedKey: await
|
|
1406
|
+
async function vt(s, e) {
|
|
1407
|
+
const t = await W(), n = await M(t.publicKey), i = await R(e.identityKey), o = await R(e.signedPrekey), r = e.oneTimePrekey ? await R(e.oneTimePrekey) : null, d = await z(s.privateKey, o), u = await z(t.privateKey, i), w = await z(t.privateKey, o), y = r ? await z(t.privateKey, r) : null, x = ve(d, u, w, ...y ? [y] : []);
|
|
1408
|
+
return { sharedKey: await ke(x), ephemeralPublicKey: n };
|
|
1409
1409
|
}
|
|
1410
|
-
async function
|
|
1411
|
-
const o = await
|
|
1412
|
-
return
|
|
1410
|
+
async function kt(s, e, t, n, i) {
|
|
1411
|
+
const o = await R(t), r = await R(n), d = await z(e.privateKey, o), u = await z(s.privateKey, r), w = await z(e.privateKey, r), y = i ? await z(i.privateKey, r) : null, x = ve(d, u, w, ...y ? [y] : []);
|
|
1412
|
+
return ke(x);
|
|
1413
1413
|
}
|
|
1414
1414
|
async function z(s, e) {
|
|
1415
|
-
return
|
|
1415
|
+
return C().deriveBits({ name: "ECDH", public: e }, s, 256);
|
|
1416
1416
|
}
|
|
1417
|
-
function
|
|
1417
|
+
function ve(...s) {
|
|
1418
1418
|
const e = s.reduce((i, o) => i + o.byteLength, 0), t = new Uint8Array(e);
|
|
1419
1419
|
let n = 0;
|
|
1420
1420
|
for (const i of s)
|
|
1421
1421
|
t.set(new Uint8Array(i), n), n += i.byteLength;
|
|
1422
1422
|
return t.buffer;
|
|
1423
1423
|
}
|
|
1424
|
-
async function
|
|
1425
|
-
const e = await
|
|
1426
|
-
return
|
|
1424
|
+
async function ke(s) {
|
|
1425
|
+
const e = await C().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
|
|
1426
|
+
return C().deriveKey(
|
|
1427
1427
|
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info: new TextEncoder().encode("ObjectChat X3DH v1") },
|
|
1428
1428
|
e,
|
|
1429
1429
|
{ name: "AES-GCM", length: 256 },
|
|
@@ -1431,8 +1431,8 @@ async function ge(s) {
|
|
|
1431
1431
|
["encrypt", "decrypt"]
|
|
1432
1432
|
);
|
|
1433
1433
|
}
|
|
1434
|
-
const
|
|
1435
|
-
class
|
|
1434
|
+
const St = 20;
|
|
1435
|
+
class Ct {
|
|
1436
1436
|
constructor(e) {
|
|
1437
1437
|
// Live ECDH mode state
|
|
1438
1438
|
a(this, "kp");
|
|
@@ -1453,19 +1453,19 @@ class St {
|
|
|
1453
1453
|
}
|
|
1454
1454
|
/** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
|
|
1455
1455
|
async begin() {
|
|
1456
|
-
return this.kp = await
|
|
1456
|
+
return this.kp = await yt(this.storageKey), M(this.kp.publicKey);
|
|
1457
1457
|
}
|
|
1458
1458
|
/** Live ECDH mode: A peer published their key — derive the shared secret. */
|
|
1459
1459
|
async onPeerKey(e) {
|
|
1460
|
-
this.kp && (this.shared = await
|
|
1460
|
+
this.kp && (this.shared = await wt(this.kp.privateKey, e));
|
|
1461
1461
|
}
|
|
1462
1462
|
// ── X3DH async mode ────────────────────────────────────────────────────────
|
|
1463
1463
|
/** X3DH: Generate identity key, signed prekey, and OTP prekeys.
|
|
1464
1464
|
* Returns the upload frame payload the caller should send to the server. */
|
|
1465
1465
|
async initX3DH() {
|
|
1466
|
-
this.identityKP = await
|
|
1467
|
-
for (let i = 0; i <
|
|
1468
|
-
const e = await M(this.signedPreKP.publicKey), t = await
|
|
1466
|
+
this.identityKP = await fe(this.storageKey), this.signedPreKP = await W(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1467
|
+
for (let i = 0; i < St; i++) this.otpKeys.push(await W());
|
|
1468
|
+
const e = await M(this.signedPreKP.publicKey), t = await bt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => M(i.publicKey)));
|
|
1469
1469
|
return {
|
|
1470
1470
|
identityKey: this.identityKP.publicKeyB64,
|
|
1471
1471
|
signedPrekey: e,
|
|
@@ -1477,8 +1477,8 @@ class St {
|
|
|
1477
1477
|
/** X3DH sender: given a recipient's prekey bundle, derive the shared key and
|
|
1478
1478
|
* return the init message fields to embed in the first encrypted message. */
|
|
1479
1479
|
async x3dhSendTo(e) {
|
|
1480
|
-
this.identityKP || (this.identityKP = await
|
|
1481
|
-
const { sharedKey: t, ephemeralPublicKey: n } = await
|
|
1480
|
+
this.identityKP || (this.identityKP = await fe(this.storageKey));
|
|
1481
|
+
const { sharedKey: t, ephemeralPublicKey: n } = await vt(this.identityKP.ecdhKP, e);
|
|
1482
1482
|
return this.x3dhShared = t, { ephemeralKey: n, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
|
|
1483
1483
|
}
|
|
1484
1484
|
/** X3DH recipient: given an init message's sender IK + EK + SPK ID, derive the shared key. */
|
|
@@ -1488,7 +1488,7 @@ class St {
|
|
|
1488
1488
|
return;
|
|
1489
1489
|
}
|
|
1490
1490
|
const i = this.otpKeys.shift();
|
|
1491
|
-
this.x3dhShared = await
|
|
1491
|
+
this.x3dhShared = await kt(this.identityKP.ecdhKP, this.signedPreKP, e, t, i);
|
|
1492
1492
|
}
|
|
1493
1493
|
/** Flush pending X3DH derivation after initX3DH() completes. */
|
|
1494
1494
|
async flushPendingX3DH() {
|
|
@@ -1501,7 +1501,7 @@ class St {
|
|
|
1501
1501
|
async sealText(e, t) {
|
|
1502
1502
|
const n = this.x3dhShared ?? this.shared;
|
|
1503
1503
|
if (!n) throw new Error("secure channel not ready");
|
|
1504
|
-
const { ct: i, iv: o } = await
|
|
1504
|
+
const { ct: i, iv: o } = await xt(n, e);
|
|
1505
1505
|
return {
|
|
1506
1506
|
kind: "text",
|
|
1507
1507
|
text: i,
|
|
@@ -1516,7 +1516,7 @@ class St {
|
|
|
1516
1516
|
const t = this.x3dhShared ?? this.shared;
|
|
1517
1517
|
if (!t) return { kind: "text", text: "🔒 encrypted" };
|
|
1518
1518
|
try {
|
|
1519
|
-
return { kind: "text", text: await
|
|
1519
|
+
return { kind: "text", text: await gt(t, e.text, e.iv) };
|
|
1520
1520
|
} catch {
|
|
1521
1521
|
return { kind: "text", text: "🔒 unable to decrypt" };
|
|
1522
1522
|
}
|
|
@@ -1528,12 +1528,12 @@ class St {
|
|
|
1528
1528
|
for (const t of e.messages) t.content = await this.openContent(t.content);
|
|
1529
1529
|
}
|
|
1530
1530
|
}
|
|
1531
|
-
function
|
|
1531
|
+
function It(s) {
|
|
1532
1532
|
if (s.kind !== "text" || !s.enc) return null;
|
|
1533
1533
|
const e = s;
|
|
1534
1534
|
return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
|
|
1535
1535
|
}
|
|
1536
|
-
const
|
|
1536
|
+
const ue = "objectchat-widget-styles", Et = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Ut = `
|
|
1537
1537
|
.ocw { --ocw-accent:#f5713c; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
|
|
1538
1538
|
position:relative;
|
|
1539
1539
|
display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
|
|
@@ -1732,27 +1732,27 @@ const le = "objectchat-widget-styles", It = ["👍", "❤️", "😂", "😮", "
|
|
|
1732
1732
|
.ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
|
|
1733
1733
|
.ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
|
|
1734
1734
|
`;
|
|
1735
|
-
function
|
|
1736
|
-
if (typeof document > "u" || document.getElementById(
|
|
1735
|
+
function Tt() {
|
|
1736
|
+
if (typeof document > "u" || document.getElementById(ue)) return;
|
|
1737
1737
|
const s = document.createElement("style");
|
|
1738
|
-
s.id =
|
|
1738
|
+
s.id = ue, s.textContent = Ut, document.head.appendChild(s);
|
|
1739
1739
|
}
|
|
1740
1740
|
function c(s, e, t) {
|
|
1741
1741
|
const n = document.createElement(s);
|
|
1742
1742
|
return e && (n.className = e), t !== void 0 && (n.textContent = t), n;
|
|
1743
1743
|
}
|
|
1744
|
-
function
|
|
1744
|
+
function Bt(s) {
|
|
1745
1745
|
try {
|
|
1746
1746
|
return new Date(s).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
1747
1747
|
} catch {
|
|
1748
1748
|
return "";
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
|
-
function
|
|
1751
|
+
function At(s) {
|
|
1752
1752
|
const e = Math.floor((Date.now() - s) / 1e3);
|
|
1753
1753
|
return e < 60 ? "now" : e < 3600 ? `${Math.floor(e / 60)}m` : e < 86400 ? `${Math.floor(e / 3600)}h` : `${Math.floor(e / 86400)}d`;
|
|
1754
1754
|
}
|
|
1755
|
-
function
|
|
1755
|
+
function ee(s) {
|
|
1756
1756
|
var e;
|
|
1757
1757
|
switch (s.kind) {
|
|
1758
1758
|
case "text":
|
|
@@ -1769,7 +1769,7 @@ function Q(s) {
|
|
|
1769
1769
|
return `📅 ${s.title} — ${new Date(s.startIso).toLocaleString()}`;
|
|
1770
1770
|
}
|
|
1771
1771
|
}
|
|
1772
|
-
class
|
|
1772
|
+
class Pt {
|
|
1773
1773
|
constructor(e, t, n, i = {}) {
|
|
1774
1774
|
a(this, "scroll");
|
|
1775
1775
|
a(this, "chips");
|
|
@@ -1815,27 +1815,27 @@ class At {
|
|
|
1815
1815
|
/** Fetch the list and re-render it. Called on mount and after switching chats. */
|
|
1816
1816
|
a(this, "destroyed", !1);
|
|
1817
1817
|
a(this, "subjectBuilt", !1);
|
|
1818
|
-
var k,
|
|
1819
|
-
this.root = e, this.me = t, this.h = n, this.cfg = i,
|
|
1818
|
+
var k, m, U, A, B, P, $, D, _, V;
|
|
1819
|
+
this.root = e, this.me = t, this.h = n, this.cfg = i, Tt(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
|
|
1820
1820
|
const o = c("div", "ocw-head"), r = c("div", "ocw-avatar");
|
|
1821
1821
|
if ((k = i.userInfo) != null && k.avatar) {
|
|
1822
1822
|
const S = document.createElement("img");
|
|
1823
1823
|
S.src = i.userInfo.avatar, S.alt = i.userInfo.name ?? "You", S.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", r.append(S);
|
|
1824
1824
|
} else
|
|
1825
|
-
r.textContent = (
|
|
1825
|
+
r.textContent = (m = i.userInfo) != null && m.name ? i.userInfo.name[0].toUpperCase() : "🧑";
|
|
1826
1826
|
o.append(r);
|
|
1827
1827
|
const d = c("div", "ocw-head-main");
|
|
1828
|
-
this.headerName = c("div", "ocw-head-name", ((
|
|
1828
|
+
this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((A = i.subject) == null ? void 0 : A.title) ?? ""), d.append(this.headerName), (B = i.subject) != null && B.subtitle && d.append(c("div", "ocw-head-meta", i.subject.subtitle)), o.append(d), this.statusBadge = c("span", "ocw-badge", ((P = i.subject) == null ? void 0 : P.status) ?? ""), ($ = i.subject) != null && $.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = c("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = c("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.append(this.connStatus), this.cobrowseBtn = c("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
|
|
1829
1829
|
this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
|
|
1830
1830
|
}), o.append(this.cobrowseBtn), this.h.onListChats && (this.backBtn = c("button", "ocw-chat-back", "←"), this.backBtn.addEventListener("click", () => this.showListScreen()), o.prepend(this.backBtn)), o.append(c("button", "ocw-menu", "⋯")), this.chips = c("div", "ocw-chiprow"), this.scroll = c("div", "ocw-scroll"), this.subjectCard = c("div", "ocw-subject"), this.typing = c("div", "ocw-typing");
|
|
1831
1831
|
const u = c("div", "ocw-typing-bubble");
|
|
1832
1832
|
u.append(c("div", "ocw-typing-dot"), c("div", "ocw-typing-dot"), c("div", "ocw-typing-dot")), this.typing.append(c("div", "ocw-dot", "🧑"), u), this.quick = c("div", "ocw-quick");
|
|
1833
1833
|
for (const S of i.quickReplies ?? []) {
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1834
|
+
const b = c("button", void 0, S);
|
|
1835
|
+
b.addEventListener("click", () => this.h.onSend(S)), this.quick.append(b);
|
|
1836
1836
|
}
|
|
1837
1837
|
this.formHost = c("div", "ocw-form-host"), this.csatPanel = c("div", "ocw-csat"), this.csatPanel.style.display = "none", this.offlinePanel = c("div", "ocw-offline"), this.offlinePanel.style.display = "none", this.input = c("textarea", void 0), this.input.rows = 1, this.input.placeholder = "Message…";
|
|
1838
|
-
const w = c("button", "ocw-sendbtn", ((
|
|
1838
|
+
const w = c("button", "ocw-sendbtn", ((D = i.i18n) == null ? void 0 : D.send) ?? "➤");
|
|
1839
1839
|
w.addEventListener("click", () => this.flushSend()), this.input.addEventListener("keydown", (S) => {
|
|
1840
1840
|
S.isComposing || S.keyCode === 229 || (S.key === "Enter" && !S.shiftKey ? (S.preventDefault(), this.flushSend()) : this.signalTyping());
|
|
1841
1841
|
});
|
|
@@ -1849,35 +1849,35 @@ class At {
|
|
|
1849
1849
|
const p = c("div", "ocw-input");
|
|
1850
1850
|
p.append(y, x, this.input, w);
|
|
1851
1851
|
const h = c("div", "ocw-footer");
|
|
1852
|
-
if (h.innerHTML = ((
|
|
1853
|
-
const S = c("div", "ocw-screen ocw-screen-list"),
|
|
1854
|
-
|
|
1852
|
+
if (h.innerHTML = ((_ = i.i18n) == null ? void 0 : _.poweredBy) !== void 0 ? i.i18n.poweredBy : 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = h, this.h.onListChats) {
|
|
1853
|
+
const S = c("div", "ocw-screen ocw-screen-list"), b = c("div", "ocw-cl-head");
|
|
1854
|
+
b.append(c("span", "ocw-cl-title", "Messages"));
|
|
1855
1855
|
const q = c("button", "ocw-cl-new", "+");
|
|
1856
1856
|
q.title = "New conversation", q.addEventListener("click", () => {
|
|
1857
1857
|
var f, g;
|
|
1858
1858
|
(g = (f = this.h).onSwitchChat) == null || g.call(f, { id: "__new__", state: "open", updatedAt: Date.now() });
|
|
1859
|
-
}),
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1859
|
+
}), b.append(q);
|
|
1860
|
+
const X = c("div", "ocw-cl-search-wrap"), K = c("input", "ocw-cl-search");
|
|
1861
|
+
K.placeholder = "🔍 Search", K.type = "search", K.addEventListener("input", () => this.renderListRows(this.allEntries, K.value.trim().toLowerCase())), X.append(K);
|
|
1862
|
+
const H = c("div", "ocw-cl-body-scroll");
|
|
1863
|
+
H.append(c("div", "ocw-cl-section", "Loading…")), S.append(b, X, H), e.append(S), this.listScreen = S, this.listBody = H, this.listSearch = K;
|
|
1864
1864
|
const l = c("div", "ocw-screen ocw-screen-chat");
|
|
1865
|
-
l.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, p, this.footer), e.append(l), this.chatScreen = l, i.startOnChat ? (this.inChatScreen = !0, this.listScreen.classList.add("hidden"), this.chatScreen.classList.add("visible"), (
|
|
1865
|
+
l.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, p, this.footer), e.append(l), this.chatScreen = l, i.startOnChat ? (this.inChatScreen = !0, this.listScreen.classList.add("hidden"), this.chatScreen.classList.add("visible"), (V = this.backBtn) == null || V.classList.add("show")) : this.inChatScreen = !1, this.refreshList();
|
|
1866
1866
|
} else
|
|
1867
1867
|
e.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, p, this.footer);
|
|
1868
1868
|
this.cobrowseCanvas = c("canvas", "ocw-cobrowse-canvas"), this.cobrowseToolbar = c("div", "ocw-cobrowse-toolbar");
|
|
1869
1869
|
for (const S of ["#f5713c", "#1c1b1a", "#2563eb", "#16a34a", "#dc2626"]) {
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1870
|
+
const b = c("button", "ocw-cobrowse-swatch");
|
|
1871
|
+
b.style.background = S, b.type = "button", S === this.cobrowseColor && b.classList.add("sel"), b.addEventListener("click", () => {
|
|
1872
1872
|
this.cobrowseColor = S;
|
|
1873
1873
|
for (const q of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) q.classList.remove("sel");
|
|
1874
|
-
|
|
1875
|
-
}), this.cobrowseToolbar.append(
|
|
1874
|
+
b.classList.add("sel");
|
|
1875
|
+
}), this.cobrowseToolbar.append(b);
|
|
1876
1876
|
}
|
|
1877
1877
|
const v = c("button", "ocw-cobrowse-clear", "Clear");
|
|
1878
1878
|
v.addEventListener("click", () => {
|
|
1879
|
-
var S,
|
|
1880
|
-
return (
|
|
1879
|
+
var S, b;
|
|
1880
|
+
return (b = (S = this.h).onAnnotateClear) == null ? void 0 : b.call(S);
|
|
1881
1881
|
}), this.cobrowseToolbar.append(v), this.cobrowseHint = c("div", "ocw-cobrowse-hint", "🖍 Draw to point things out — visible to both sides"), e.append(this.cobrowseCanvas, this.cobrowseToolbar, this.cobrowseHint), this.bindCobrowsePointerEvents();
|
|
1882
1882
|
}
|
|
1883
1883
|
/** Returns the scroll container so history.ts can attach scroll listeners. */
|
|
@@ -1962,9 +1962,9 @@ class At {
|
|
|
1962
1962
|
}, p = e.lastMessage ?? x[e.state] ?? e.state;
|
|
1963
1963
|
y.append(c("div", "ocw-cl-preview", p)), d.append(y);
|
|
1964
1964
|
const h = c("div", "ocw-cl-right");
|
|
1965
|
-
return h.append(c("div", "ocw-cl-time",
|
|
1966
|
-
var k,
|
|
1967
|
-
n > 0 && this.seenSeq.set(e.id, n), this.activeChatId = e.id, this.showChatScreen(), (
|
|
1965
|
+
return h.append(c("div", "ocw-cl-time", At(e.updatedAt))), i > 0 && h.append(c("div", "ocw-cl-badge", String(i > 99 ? "99+" : i))), d.append(h), d.addEventListener("click", () => {
|
|
1966
|
+
var k, m;
|
|
1967
|
+
n > 0 && this.seenSeq.set(e.id, n), this.activeChatId = e.id, this.showChatScreen(), (m = (k = this.h).onSwitchChat) == null || m.call(k, e);
|
|
1968
1968
|
}), d;
|
|
1969
1969
|
}
|
|
1970
1970
|
/** Returns true when the chat screen is visible (not the list). */
|
|
@@ -2173,7 +2173,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2173
2173
|
var x;
|
|
2174
2174
|
if (e.senderRole === "system") {
|
|
2175
2175
|
const p = c("div", "ocw-sys");
|
|
2176
|
-
return p.textContent = e.deletedAt ? "message deleted" :
|
|
2176
|
+
return p.textContent = e.deletedAt ? "message deleted" : ee(e.content), p;
|
|
2177
2177
|
}
|
|
2178
2178
|
const n = e.senderId === this.me, i = !!e.internal, o = c("div", `ocw-row ${i ? "ocw-note mine" : n ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
|
|
2179
2179
|
!n && !i && o.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
|
|
@@ -2199,10 +2199,10 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2199
2199
|
h.append(c("div", "ocw-appt-title", `📅 ${p.title}`)), h.append(c("div", "ocw-appt-time", new Date(p.startIso).toLocaleString() + " – " + new Date(p.endIso).toLocaleTimeString())), p.location && h.append(c("div", "ocw-appt-loc", `📍 ${p.location}`)), p.description && h.append(c("div", "ocw-appt-desc", p.description));
|
|
2200
2200
|
const v = c("div", "ocw-appt-links"), k = document.createElement("a");
|
|
2201
2201
|
k.href = p.googleUrl, k.target = "_blank", k.rel = "noopener", k.className = "ocw-appt-btn", k.textContent = "📅 Add to Google Calendar";
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2202
|
+
const m = document.createElement("a");
|
|
2203
|
+
m.href = p.icalUrl, m.download = `${p.title}.ics`, m.className = "ocw-appt-btn ocw-appt-btn-sec", m.textContent = "🍎 Apple / iCal", v.append(k, m), h.append(v), u.append(h);
|
|
2204
2204
|
} else
|
|
2205
|
-
w = document.createTextNode(
|
|
2205
|
+
w = document.createTextNode(ee(e.content)), u.append(w), e.editedAt && u.append(c("span", "ocw-edited", "(edited)"));
|
|
2206
2206
|
if (d.append(u), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && w) {
|
|
2207
2207
|
const p = e.content.text;
|
|
2208
2208
|
if (p.trim()) {
|
|
@@ -2217,14 +2217,14 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2217
2217
|
this.showingTranslation.add(e.id), w.textContent = k, h.textContent = "↩", h.title = "Show original";
|
|
2218
2218
|
return;
|
|
2219
2219
|
}
|
|
2220
|
-
h.textContent = "⏳", this.h.onTranslate(p).then((
|
|
2221
|
-
if (
|
|
2220
|
+
h.textContent = "⏳", this.h.onTranslate(p).then((m) => {
|
|
2221
|
+
if (m === null) {
|
|
2222
2222
|
h.textContent = "⚠️", h.title = "Translation unavailable", setTimeout(() => {
|
|
2223
2223
|
h.textContent = "🌐", h.title = "Translate";
|
|
2224
2224
|
}, 1500);
|
|
2225
2225
|
return;
|
|
2226
2226
|
}
|
|
2227
|
-
this.translationCache.set(e.id,
|
|
2227
|
+
this.translationCache.set(e.id, m), this.showingTranslation.add(e.id), w.textContent = m, h.textContent = "↩", h.title = "Show original";
|
|
2228
2228
|
});
|
|
2229
2229
|
}), d.append(h);
|
|
2230
2230
|
}
|
|
@@ -2235,8 +2235,8 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2235
2235
|
const h = c("button", void 0, "✏️");
|
|
2236
2236
|
h.title = "Edit", h.addEventListener("click", (v) => {
|
|
2237
2237
|
v.stopPropagation();
|
|
2238
|
-
const k =
|
|
2239
|
-
|
|
2238
|
+
const k = ee(e.content), m = prompt("Edit message:", k);
|
|
2239
|
+
m !== null && m.trim() && m !== k && this.h.onEdit(e.id, m.trim());
|
|
2240
2240
|
}), p.append(h);
|
|
2241
2241
|
}
|
|
2242
2242
|
if (this.h.onDelete) {
|
|
@@ -2250,38 +2250,38 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2250
2250
|
if (r.append(d), this.h.onReact && !e.deletedAt && e.seq > 0) {
|
|
2251
2251
|
const p = c("div", "ocw-react-wrap"), h = c("div", "ocw-react");
|
|
2252
2252
|
if (e.reactions && Object.keys(e.reactions).length)
|
|
2253
|
-
for (const [
|
|
2254
|
-
const
|
|
2255
|
-
|
|
2256
|
-
var
|
|
2257
|
-
return (
|
|
2258
|
-
}), h.append(
|
|
2253
|
+
for (const [m, U] of Object.entries(e.reactions)) {
|
|
2254
|
+
const A = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${m} ${U.length}`);
|
|
2255
|
+
A.addEventListener("click", () => {
|
|
2256
|
+
var B, P;
|
|
2257
|
+
return (P = (B = this.h).onReact) == null ? void 0 : P.call(B, e.id, m, U.includes(this.me));
|
|
2258
|
+
}), h.append(A);
|
|
2259
2259
|
}
|
|
2260
2260
|
const v = c("button", "ocw-react-btn", "+"), k = c("div", "ocw-react-picker");
|
|
2261
|
-
for (const
|
|
2262
|
-
const
|
|
2263
|
-
|
|
2264
|
-
var
|
|
2265
|
-
|
|
2266
|
-
const
|
|
2267
|
-
(
|
|
2268
|
-
}), k.append(
|
|
2261
|
+
for (const m of Et) {
|
|
2262
|
+
const U = c("button", void 0, m);
|
|
2263
|
+
U.addEventListener("click", (A) => {
|
|
2264
|
+
var P, $, D, _;
|
|
2265
|
+
A.stopPropagation();
|
|
2266
|
+
const B = ($ = (P = e.reactions) == null ? void 0 : P[m]) == null ? void 0 : $.includes(this.me);
|
|
2267
|
+
(_ = (D = this.h).onReact) == null || _.call(D, e.id, m, !!B), k.style.display = "none";
|
|
2268
|
+
}), k.append(U);
|
|
2269
2269
|
}
|
|
2270
|
-
k.style.display = "none", v.addEventListener("click", (
|
|
2271
|
-
|
|
2270
|
+
k.style.display = "none", v.addEventListener("click", (m) => {
|
|
2271
|
+
m.stopPropagation(), k.style.display = k.style.display === "none" ? "flex" : "none";
|
|
2272
2272
|
}), document.addEventListener("click", () => {
|
|
2273
2273
|
k.style.display = "none";
|
|
2274
2274
|
}, { once: !0 }), h.append(v), p.append(h, k), r.append(p);
|
|
2275
2275
|
} else e.reactions && Object.keys(e.reactions).length && r.append(c("div", "ocw-react", Object.entries(e.reactions).map(([p, h]) => `${p}${h.length}`).join(" ")));
|
|
2276
|
-
const y = c("div", "ocw-time ocw-meta",
|
|
2276
|
+
const y = c("div", "ocw-time ocw-meta", Bt(e.ts));
|
|
2277
2277
|
if (n && e.status) {
|
|
2278
|
-
const p = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`,
|
|
2278
|
+
const p = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Kt(e.status));
|
|
2279
2279
|
y.append(p);
|
|
2280
2280
|
}
|
|
2281
2281
|
return n && e.seq > 0 && t.lastReadByOthers >= e.seq && y.append(c("span", "ocw-seen", " · Seen")), r.append(y), o.append(r), o;
|
|
2282
2282
|
}
|
|
2283
2283
|
}
|
|
2284
|
-
function
|
|
2284
|
+
function Kt(s) {
|
|
2285
2285
|
switch (s) {
|
|
2286
2286
|
case "read":
|
|
2287
2287
|
return "✓✓";
|
|
@@ -2293,19 +2293,19 @@ function Pt(s) {
|
|
|
2293
2293
|
return "🕓";
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
2296
|
-
const
|
|
2297
|
-
function
|
|
2296
|
+
const Lt = 20;
|
|
2297
|
+
function Se(s) {
|
|
2298
2298
|
return s.replace(/^ws/, "http").replace(/\/ws\/?$/, "");
|
|
2299
2299
|
}
|
|
2300
|
-
function
|
|
2300
|
+
function zt(s, e, t, n) {
|
|
2301
2301
|
const i = `beforeSeq=${t}&limit=${n}`;
|
|
2302
2302
|
return [
|
|
2303
2303
|
`${s}/conversations/${e}/messages?${i}`,
|
|
2304
2304
|
`${s}/conversations/${e}/history?${i}`
|
|
2305
2305
|
];
|
|
2306
2306
|
}
|
|
2307
|
-
async function
|
|
2308
|
-
for (const o of
|
|
2307
|
+
async function we(s, e, t, n, i = Lt) {
|
|
2308
|
+
for (const o of zt(s, e, n, i))
|
|
2309
2309
|
try {
|
|
2310
2310
|
const r = await fetch(o, { headers: { authorization: `Bearer ${t}` } });
|
|
2311
2311
|
if (!r.ok) continue;
|
|
@@ -2315,8 +2315,8 @@ async function he(s, e, t, n, i = Kt) {
|
|
|
2315
2315
|
}
|
|
2316
2316
|
return null;
|
|
2317
2317
|
}
|
|
2318
|
-
async function
|
|
2319
|
-
const o =
|
|
2318
|
+
async function xe(s, e, t, n, i) {
|
|
2319
|
+
const o = Se(s), r = await we(o, t, e, Number.MAX_SAFE_INTEGER);
|
|
2320
2320
|
if (!r || (r.messages.length ? (n.apply({ type: "sync", conversationId: t, messages: r.messages }), n.apply({ type: "history", conversationId: t, messages: [], hasMore: r.hasMore }), i.render(n)) : n.apply({ type: "history", conversationId: t, messages: [], hasMore: !1 }), !r.hasMore)) return;
|
|
2321
2321
|
let d = !1;
|
|
2322
2322
|
const u = async () => {
|
|
@@ -2327,7 +2327,7 @@ async function zt(s, e, t, n, i) {
|
|
|
2327
2327
|
d = !1;
|
|
2328
2328
|
return;
|
|
2329
2329
|
}
|
|
2330
|
-
const h = await
|
|
2330
|
+
const h = await we(o, t, e, p.seq);
|
|
2331
2331
|
h && (n.apply({ type: "history", conversationId: t, messages: h.messages, hasMore: h.hasMore }), i.render(n)), d = !1;
|
|
2332
2332
|
}, w = i.getScrollEl();
|
|
2333
2333
|
if (!w) return;
|
|
@@ -2351,25 +2351,40 @@ function Mt() {
|
|
|
2351
2351
|
return `g_${Math.random().toString(36).slice(2)}`;
|
|
2352
2352
|
}
|
|
2353
2353
|
}
|
|
2354
|
-
function
|
|
2355
|
-
var
|
|
2356
|
-
const e = s.token ?? Mt()
|
|
2354
|
+
function _t(s) {
|
|
2355
|
+
var K, H;
|
|
2356
|
+
const e = s.token ?? Mt();
|
|
2357
|
+
let t = new ce(e);
|
|
2358
|
+
const n = new pe(e);
|
|
2357
2359
|
let i, o = !1, r = null;
|
|
2358
|
-
!s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px")
|
|
2359
|
-
|
|
2360
|
+
if (!s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px"), s.subjectId)
|
|
2361
|
+
for (const l of n.load()) t.addOptimistic(l.clientMsgId, l.content);
|
|
2360
2362
|
let d = null, u = null, w = 0, y = !s.launcher;
|
|
2361
2363
|
if (s.launcher) {
|
|
2362
2364
|
const f = (s.position ?? "bottom-right").includes("right");
|
|
2363
2365
|
d = document.createElement("div"), d.style.cssText = `position:fixed;${f ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${f ? "flex-end" : "flex-start"};gap:12px`;
|
|
2364
|
-
const g = document.createElement("div");
|
|
2365
|
-
g.style.cssText = [
|
|
2366
|
+
const g = document.createElement("div"), I = typeof window < "u" && window.innerWidth < 480;
|
|
2367
|
+
g.style.cssText = I ? [
|
|
2368
|
+
"position:fixed",
|
|
2369
|
+
"inset:0",
|
|
2370
|
+
"width:100%",
|
|
2371
|
+
"height:100%",
|
|
2372
|
+
"border-radius:0",
|
|
2373
|
+
"overflow:hidden",
|
|
2374
|
+
"box-shadow:none",
|
|
2375
|
+
"display:none",
|
|
2376
|
+
"flex-direction:column",
|
|
2377
|
+
"background:#fff",
|
|
2378
|
+
"transition:opacity .18s",
|
|
2379
|
+
"opacity:0",
|
|
2380
|
+
"z-index:9998"
|
|
2381
|
+
].join(";") : [
|
|
2366
2382
|
"width:380px",
|
|
2367
2383
|
"height:600px",
|
|
2368
2384
|
"border-radius:16px",
|
|
2369
2385
|
"overflow:hidden",
|
|
2370
2386
|
"box-shadow:0 8px 40px rgba(0,0,0,.18)",
|
|
2371
2387
|
"display:none",
|
|
2372
|
-
// hidden until bubble clicked
|
|
2373
2388
|
"flex-direction:column",
|
|
2374
2389
|
"background:#fff",
|
|
2375
2390
|
"transform-origin:bottom " + (f ? "right" : "left"),
|
|
@@ -2377,30 +2392,30 @@ function $t(s) {
|
|
|
2377
2392
|
"opacity:0",
|
|
2378
2393
|
"transform:scale(.95)"
|
|
2379
2394
|
].join(";"), s.el.style.cssText = "width:100%;height:100%;overflow:hidden", g.append(s.el);
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2395
|
+
const E = document.createElement("button");
|
|
2396
|
+
E.style.cssText = [
|
|
2382
2397
|
"width:56px;height:56px;border-radius:50%",
|
|
2383
2398
|
`background:${s.accent ?? "#4F63F5"}`,
|
|
2384
2399
|
"color:#fff;border:none;font-size:24px;cursor:pointer",
|
|
2385
2400
|
"box-shadow:0 4px 16px rgba(0,0,0,.25)",
|
|
2386
2401
|
"position:relative;flex:none",
|
|
2387
2402
|
"transition:transform .15s"
|
|
2388
|
-
].join(";"),
|
|
2389
|
-
|
|
2390
|
-
},
|
|
2391
|
-
|
|
2392
|
-
}, u = document.createElement("span"), u.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center",
|
|
2393
|
-
const L = (
|
|
2394
|
-
|
|
2403
|
+
].join(";"), E.textContent = "💬", E.onmouseenter = () => {
|
|
2404
|
+
E.style.transform = "scale(1.08)";
|
|
2405
|
+
}, E.onmouseleave = () => {
|
|
2406
|
+
E.style.transform = "scale(1)";
|
|
2407
|
+
}, u = document.createElement("span"), u.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center", E.append(u), d.append(g, E), document.body.append(d);
|
|
2408
|
+
const L = (F) => {
|
|
2409
|
+
F ? (g.style.display = "flex", requestAnimationFrame(() => {
|
|
2395
2410
|
g.style.opacity = "1", g.style.transform = "scale(1)";
|
|
2396
2411
|
})) : (g.style.opacity = "0", g.style.transform = "scale(.95)", setTimeout(() => {
|
|
2397
2412
|
y || (g.style.display = "none");
|
|
2398
2413
|
}, 180));
|
|
2399
2414
|
};
|
|
2400
|
-
|
|
2401
|
-
y = !y, L(y),
|
|
2402
|
-
}), document.addEventListener("keydown", (
|
|
2403
|
-
|
|
2415
|
+
E.addEventListener("click", () => {
|
|
2416
|
+
y = !y, L(y), E.textContent = y ? "✕" : "💬", E.append(u), y && (w = 0, u && (u.style.display = "none"));
|
|
2417
|
+
}), document.addEventListener("keydown", (F) => {
|
|
2418
|
+
F.key === "Escape" && y && (y = !1, L(!1), E.textContent = "💬", E.append(u));
|
|
2404
2419
|
});
|
|
2405
2420
|
}
|
|
2406
2421
|
const x = () => {
|
|
@@ -2413,52 +2428,52 @@ function $t(s) {
|
|
|
2413
2428
|
}
|
|
2414
2429
|
};
|
|
2415
2430
|
let h;
|
|
2416
|
-
const v = new
|
|
2431
|
+
const v = new Ct(`ocw-e2e-${s.profileId}`);
|
|
2417
2432
|
let k = !1;
|
|
2418
|
-
const
|
|
2419
|
-
let
|
|
2420
|
-
const
|
|
2433
|
+
const m = [], U = [];
|
|
2434
|
+
let A = !1;
|
|
2435
|
+
const B = (l, f) => {
|
|
2421
2436
|
v.sealText(f).then((g) => {
|
|
2422
2437
|
i && h.send({ type: "send", conversationId: i, clientMsgId: l, content: g });
|
|
2423
2438
|
});
|
|
2424
|
-
},
|
|
2425
|
-
v.sealText(f, g).then((
|
|
2426
|
-
i && h.send({ type: "send", conversationId: i, clientMsgId: l, content:
|
|
2439
|
+
}, P = (l, f, g) => {
|
|
2440
|
+
v.sealText(f, g).then((I) => {
|
|
2441
|
+
i && h.send({ type: "send", conversationId: i, clientMsgId: l, content: I });
|
|
2427
2442
|
});
|
|
2428
2443
|
}, $ = () => {
|
|
2429
|
-
for (;
|
|
2430
|
-
const l =
|
|
2431
|
-
|
|
2444
|
+
for (; m.length; ) {
|
|
2445
|
+
const l = m.shift();
|
|
2446
|
+
B(l.clientMsgId, l.text);
|
|
2432
2447
|
}
|
|
2433
|
-
for (;
|
|
2434
|
-
const l =
|
|
2435
|
-
|
|
2448
|
+
for (; U.length; ) {
|
|
2449
|
+
const l = U.shift();
|
|
2450
|
+
B(l.clientMsgId, l.text);
|
|
2436
2451
|
}
|
|
2437
|
-
},
|
|
2452
|
+
}, D = (l) => {
|
|
2438
2453
|
h.send({ type: "fetchPrekey", targetUserId: l });
|
|
2439
|
-
},
|
|
2440
|
-
|
|
2441
|
-
const
|
|
2454
|
+
}, _ = s.i18n ?? {}, V = ["ar", "he", "fa", "ur"], S = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
|
|
2455
|
+
V.includes(S) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
|
|
2456
|
+
const b = new Pt(s.el, e, {
|
|
2442
2457
|
onSend(l) {
|
|
2443
2458
|
if (!i) return;
|
|
2444
2459
|
const f = `cm_${Math.random().toString(36).slice(2)}`;
|
|
2445
|
-
t.addOptimistic(f, { kind: "text", text: l }),
|
|
2460
|
+
t.addOptimistic(f, { kind: "text", text: l }), b.render(t), t.e2e ? v.ready ? B(f, l) : A ? U.push({ clientMsgId: f, text: l }) : (m.push({ clientMsgId: f, text: l }), t.assignedAgentId && D(t.assignedAgentId)) : (n.add({ clientMsgId: f, content: { kind: "text", text: l }, ts: Date.now() }), h.send({ type: "send", conversationId: i, clientMsgId: f, content: { kind: "text", text: l } }));
|
|
2446
2461
|
},
|
|
2447
2462
|
async onAttach(l) {
|
|
2448
2463
|
if (!i) return;
|
|
2449
|
-
const
|
|
2450
|
-
t.addOptimistic(
|
|
2464
|
+
const I = `${s.url.replace(/^ws/, "http").replace(/\/ws$/, "")}/upload?name=${encodeURIComponent(l.name)}`, E = `cm_${Math.random().toString(36).slice(2)}`;
|
|
2465
|
+
t.addOptimistic(E, { kind: "text", text: `📎 Uploading ${l.name}…` }), b.render(t);
|
|
2451
2466
|
try {
|
|
2452
|
-
const
|
|
2467
|
+
const L = await fetch(I, {
|
|
2453
2468
|
method: "POST",
|
|
2454
2469
|
headers: { "content-type": l.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
|
|
2455
2470
|
body: l
|
|
2456
2471
|
});
|
|
2457
|
-
if (!
|
|
2458
|
-
const { url:
|
|
2459
|
-
h.send({ type: "send", conversationId: i, clientMsgId:
|
|
2460
|
-
} catch (
|
|
2461
|
-
t.addOptimistic(
|
|
2472
|
+
if (!L.ok) throw new Error(`Upload failed: ${L.status}`);
|
|
2473
|
+
const { url: F, name: Ce, mime: Ie, size: Ee } = await L.json();
|
|
2474
|
+
h.send({ type: "send", conversationId: i, clientMsgId: E, content: { kind: "attachment", url: F, name: Ce, mime: Ie, size: Ee } });
|
|
2475
|
+
} catch (L) {
|
|
2476
|
+
t.addOptimistic(E, { kind: "text", text: `⚠️ Upload failed: ${L.message}` }), b.render(t);
|
|
2462
2477
|
}
|
|
2463
2478
|
},
|
|
2464
2479
|
onInvoke(l, f) {
|
|
@@ -2510,8 +2525,8 @@ function $t(s) {
|
|
|
2510
2525
|
body: JSON.stringify({ text: l, targetLang: s.translateLang })
|
|
2511
2526
|
});
|
|
2512
2527
|
if (!g.ok) return null;
|
|
2513
|
-
const { translated:
|
|
2514
|
-
return
|
|
2528
|
+
const { translated: I } = await g.json();
|
|
2529
|
+
return I;
|
|
2515
2530
|
} catch {
|
|
2516
2531
|
return null;
|
|
2517
2532
|
}
|
|
@@ -2519,7 +2534,7 @@ function $t(s) {
|
|
|
2519
2534
|
} : {},
|
|
2520
2535
|
...s.showChatList ? {
|
|
2521
2536
|
async onListChats() {
|
|
2522
|
-
const l =
|
|
2537
|
+
const l = Se(s.url);
|
|
2523
2538
|
try {
|
|
2524
2539
|
const f = await fetch(`${l}/conversations/mine?profileId=${encodeURIComponent(s.profileId)}`, {
|
|
2525
2540
|
headers: { authorization: `Bearer ${e}` }
|
|
@@ -2531,23 +2546,38 @@ function $t(s) {
|
|
|
2531
2546
|
},
|
|
2532
2547
|
onSwitchChat(l) {
|
|
2533
2548
|
if (!l.id || l.id === "__new__") return;
|
|
2534
|
-
|
|
2535
|
-
const
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2549
|
+
h == null || h.close(), i = void 0, o = !1, t = new ce(e);
|
|
2550
|
+
const f = new pe(e);
|
|
2551
|
+
for (const I of f.load()) t.addOptimistic(I.clientMsgId, I.content);
|
|
2552
|
+
const g = {
|
|
2553
|
+
type: "open",
|
|
2554
|
+
profileId: s.profileId,
|
|
2540
2555
|
...l.subjectId ? { subjectId: l.subjectId } : {},
|
|
2541
|
-
|
|
2542
|
-
|
|
2556
|
+
...typeof location < "u" ? { pageUrl: location.href } : {},
|
|
2557
|
+
...typeof document < "u" && document.title ? { pageTitle: document.title } : {}
|
|
2558
|
+
};
|
|
2559
|
+
h = new le({
|
|
2560
|
+
url: s.url,
|
|
2561
|
+
token: e,
|
|
2562
|
+
open: g,
|
|
2563
|
+
getCursor: () => t.highestSeq(),
|
|
2564
|
+
onStatusChange: (I) => b.setConnStatus(I),
|
|
2565
|
+
onFrame(I) {
|
|
2566
|
+
if (I.type === "opened") {
|
|
2567
|
+
const E = i === void 0;
|
|
2568
|
+
i = I.conversation.id, E && (xe(s.url, e, i, t, b), b.showChatScreen());
|
|
2569
|
+
}
|
|
2570
|
+
(async () => (t.apply(I), b.render(t), i && b.setSeenSeq(i, t.highestSeq())))();
|
|
2571
|
+
}
|
|
2572
|
+
}), h.connect(), b.render(t);
|
|
2543
2573
|
}
|
|
2544
2574
|
} : {}
|
|
2545
2575
|
}, {
|
|
2546
2576
|
...s.subject ? { subject: s.subject } : {},
|
|
2547
2577
|
...s.quickReplies ? { quickReplies: s.quickReplies } : {},
|
|
2548
2578
|
...s.accent ? { accent: s.accent } : {},
|
|
2549
|
-
...(
|
|
2550
|
-
i18n:
|
|
2579
|
+
...(K = s.user) != null && K.name || (H = s.user) != null && H.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
|
|
2580
|
+
i18n: _,
|
|
2551
2581
|
// Start directly on chat screen when a specific conversation is known upfront
|
|
2552
2582
|
...s.showChatList && s.subjectId ? { startOnChat: !0 } : {}
|
|
2553
2583
|
}), q = {
|
|
@@ -2558,21 +2588,21 @@ function $t(s) {
|
|
|
2558
2588
|
// This is pure display metadata — it never affects identity or access.
|
|
2559
2589
|
...typeof location < "u" ? { pageUrl: location.href } : {},
|
|
2560
2590
|
...typeof document < "u" && document.title ? { pageTitle: document.title } : {}
|
|
2561
|
-
},
|
|
2591
|
+
}, X = (l) => {
|
|
2562
2592
|
const f = s.user;
|
|
2563
2593
|
if (!f || !f.name && !f.email && !f.avatar && !f.meta) return;
|
|
2564
2594
|
const g = [];
|
|
2565
|
-
if (f.name && g.push(`Name: ${f.name}`), f.email && g.push(`Email: ${f.email}`), f.avatar && g.push(`Avatar: ${f.avatar}`), f.meta) for (const [
|
|
2595
|
+
if (f.name && g.push(`Name: ${f.name}`), f.email && g.push(`Email: ${f.email}`), f.avatar && g.push(`Avatar: ${f.avatar}`), f.meta) for (const [I, E] of Object.entries(f.meta)) g.push(`${I}: ${E}`);
|
|
2566
2596
|
h.send({ type: "note", conversationId: l, clientMsgId: `ui_${Date.now()}`, text: `[User info]
|
|
2567
2597
|
${g.join(`
|
|
2568
2598
|
`)}` });
|
|
2569
2599
|
};
|
|
2570
|
-
return h = new
|
|
2600
|
+
return h = new le({
|
|
2571
2601
|
url: s.url,
|
|
2572
2602
|
token: e,
|
|
2573
2603
|
open: q,
|
|
2574
2604
|
getCursor: () => t.highestSeq(),
|
|
2575
|
-
onStatusChange: (l) =>
|
|
2605
|
+
onStatusChange: (l) => b.setConnStatus(l),
|
|
2576
2606
|
onFrame(l) {
|
|
2577
2607
|
if (l.type === "opened") {
|
|
2578
2608
|
const f = i === void 0;
|
|
@@ -2581,58 +2611,58 @@ ${g.join(`
|
|
|
2581
2611
|
for (const g of n.load())
|
|
2582
2612
|
h.send({ type: "send", conversationId: i, clientMsgId: g.clientMsgId, content: g.content });
|
|
2583
2613
|
}
|
|
2584
|
-
f && (
|
|
2614
|
+
f && (xe(s.url, e, i, t, b), l.conversation.lastSeq === 0 && X(i), s.showChatList && s.subjectId && b.showChatScreen());
|
|
2585
2615
|
}
|
|
2586
2616
|
if (l.type === "ack" && n.remove(l.clientMsgId), l.type === "prekeyBundle") {
|
|
2587
|
-
l.bundle && (
|
|
2588
|
-
const g = [...
|
|
2589
|
-
for (const
|
|
2590
|
-
|
|
2617
|
+
l.bundle && (A = !0, v.x3dhSendTo(l.bundle).then((f) => {
|
|
2618
|
+
const g = [...m.splice(0), ...U.splice(0)];
|
|
2619
|
+
for (const I of g) P(I.clientMsgId, I.text, f);
|
|
2620
|
+
b.render(t);
|
|
2591
2621
|
}));
|
|
2592
2622
|
return;
|
|
2593
2623
|
}
|
|
2594
2624
|
if (l.type === "message" && t.e2e) {
|
|
2595
|
-
const f =
|
|
2625
|
+
const f = It(l.message.content);
|
|
2596
2626
|
if (f && !v.ready) {
|
|
2597
2627
|
v.x3dhReceiveFrom(f.x3dhIK, f.x3dhEK, f.x3dhSPK).then(async () => {
|
|
2598
|
-
await v.openFrame(l), t.apply(l),
|
|
2628
|
+
await v.openFrame(l), t.apply(l), b.render(t);
|
|
2599
2629
|
});
|
|
2600
2630
|
return;
|
|
2601
2631
|
}
|
|
2602
2632
|
}
|
|
2603
2633
|
if (l.type === "peerkey") {
|
|
2604
2634
|
v.onPeerKey(l.key).then(() => {
|
|
2605
|
-
$(),
|
|
2635
|
+
$(), b.render(t);
|
|
2606
2636
|
});
|
|
2607
2637
|
return;
|
|
2608
2638
|
}
|
|
2609
2639
|
(async () => {
|
|
2610
|
-
if (t.e2e && await v.openFrame(l), t.apply(l), l.type === "message" && l.message.senderId !== e && !l.message.internal && (s.showChatList &&
|
|
2640
|
+
if (t.e2e && await v.openFrame(l), t.apply(l), l.type === "message" && l.message.senderId !== e && !l.message.internal && (s.showChatList && b.isInChatScreen() || x(), p()), t.e2e && i && !k) {
|
|
2611
2641
|
k = !0;
|
|
2612
2642
|
const f = await v.initX3DH();
|
|
2613
2643
|
h.send({ type: "uploadPrekeys", ...f });
|
|
2614
2644
|
const g = await v.begin();
|
|
2615
2645
|
h.send({ type: "pubkey", conversationId: i, key: g });
|
|
2616
2646
|
}
|
|
2617
|
-
|
|
2647
|
+
b.render(t), i && b.setSeenSeq(i, t.highestSeq());
|
|
2618
2648
|
})();
|
|
2619
2649
|
}
|
|
2620
|
-
}), s.showChatList &&
|
|
2621
|
-
d == null || d.remove(),
|
|
2622
|
-
} }, r) : (h.connect(),
|
|
2623
|
-
h.close(), d == null || d.remove(),
|
|
2650
|
+
}), s.showChatList && b.initSeenSeq(`${s.profileId}_${e.slice(-8)}`), s.showChatList && !s.subjectId ? (r = { close: () => {
|
|
2651
|
+
d == null || d.remove(), b.destroy();
|
|
2652
|
+
} }, r) : (h.connect(), b.render(t), r = { close: () => {
|
|
2653
|
+
h.close(), d == null || d.remove(), b.destroy();
|
|
2624
2654
|
} }, r);
|
|
2625
2655
|
}
|
|
2626
2656
|
export {
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2657
|
+
ce as ChatStore,
|
|
2658
|
+
le as ConnectionManager,
|
|
2659
|
+
Ct as E2ESession,
|
|
2660
|
+
pe as PersistentOutbox,
|
|
2661
|
+
Pt as Renderer,
|
|
2632
2662
|
Dt as asConversationId,
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2663
|
+
It as extractX3DHInit,
|
|
2664
|
+
Se as httpBaseFromWsUrl,
|
|
2665
|
+
_t as mount,
|
|
2666
|
+
xe as restoreHistory
|
|
2637
2667
|
};
|
|
2638
2668
|
//# sourceMappingURL=index.js.map
|