@paramms/chat-widget 1.0.25 → 1.0.26
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/connection.d.ts +2 -1
- package/dist/embed.d.ts +35 -0
- package/dist/embed.js +166 -0
- package/dist/embed.js.map +1 -0
- package/dist/index.js +226 -199
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var De = Object.defineProperty;
|
|
2
2
|
var _e = (s, e, t) => e in s ? De(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var a = (s, e, t) => _e(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { p as $e, r as
|
|
5
|
-
import { h as
|
|
6
|
-
const
|
|
4
|
+
import { p as $e, r as Re, a as He } from "./uid.js";
|
|
5
|
+
import { h as nn } from "./uid.js";
|
|
6
|
+
const Gt = (s) => s;
|
|
7
7
|
function Fe(s) {
|
|
8
8
|
const e = s.length;
|
|
9
9
|
let t = 0, n = 0;
|
|
@@ -36,8 +36,8 @@ function je(s, e, t) {
|
|
|
36
36
|
e[i++] = r >> 6 & 31 | 192;
|
|
37
37
|
else {
|
|
38
38
|
if (r >= 55296 && r <= 56319 && o < n) {
|
|
39
|
-
const
|
|
40
|
-
(
|
|
39
|
+
const p = s.charCodeAt(o);
|
|
40
|
+
(p & 64512) === 56320 && (++o, r = ((r & 1023) << 10) + (p & 1023) + 65536);
|
|
41
41
|
}
|
|
42
42
|
r & 4294901760 ? (e[i++] = r >> 18 & 7 | 240, e[i++] = r >> 12 & 63 | 128, e[i++] = r >> 6 & 63 | 128) : (e[i++] = r >> 12 & 15 | 224, e[i++] = r >> 6 & 63 | 128);
|
|
43
43
|
}
|
|
@@ -61,21 +61,21 @@ function ke(s, e, t) {
|
|
|
61
61
|
const i = n + t, o = [];
|
|
62
62
|
let r = "";
|
|
63
63
|
for (; n < i; ) {
|
|
64
|
-
const
|
|
65
|
-
if (!(
|
|
66
|
-
o.push(
|
|
67
|
-
else if ((
|
|
64
|
+
const p = s[n++];
|
|
65
|
+
if (!(p & 128))
|
|
66
|
+
o.push(p);
|
|
67
|
+
else if ((p & 224) === 192) {
|
|
68
68
|
const w = s[n++] & 63;
|
|
69
|
-
o.push((
|
|
70
|
-
} else if ((
|
|
69
|
+
o.push((p & 31) << 6 | w);
|
|
70
|
+
} else if ((p & 240) === 224) {
|
|
71
71
|
const w = s[n++] & 63, d = s[n++] & 63;
|
|
72
|
-
o.push((
|
|
73
|
-
} else if ((
|
|
72
|
+
o.push((p & 31) << 12 | w << 6 | d);
|
|
73
|
+
} else if ((p & 248) === 240) {
|
|
74
74
|
const w = s[n++] & 63, d = s[n++] & 63, v = s[n++] & 63;
|
|
75
|
-
let x = (
|
|
75
|
+
let x = (p & 7) << 18 | w << 12 | d << 6 | v;
|
|
76
76
|
x > 65535 && (x -= 65536, o.push(x >>> 10 & 1023 | 55296), x = 56320 | x & 1023), o.push(x);
|
|
77
77
|
} else
|
|
78
|
-
o.push(
|
|
78
|
+
o.push(p);
|
|
79
79
|
o.length >= We && (r += String.fromCharCode(...o), o.length = 0);
|
|
80
80
|
}
|
|
81
81
|
return o.length > 0 && (r += String.fromCharCode(...o)), r;
|
|
@@ -107,7 +107,7 @@ class z extends Error {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
const q = 4294967295;
|
|
110
|
-
function
|
|
110
|
+
function Ze(s, e, t) {
|
|
111
111
|
const n = t / 4294967296, i = t;
|
|
112
112
|
s.setUint32(e, n), s.setUint32(e + 4, i);
|
|
113
113
|
}
|
|
@@ -119,7 +119,7 @@ function Ie(s, e) {
|
|
|
119
119
|
const t = s.getInt32(e), n = s.getUint32(e + 4);
|
|
120
120
|
return t * 4294967296 + n;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function Qe(s, e) {
|
|
123
123
|
const t = s.getUint32(e), n = s.getUint32(e + 4);
|
|
124
124
|
return t * 4294967296 + n;
|
|
125
125
|
}
|
|
@@ -228,7 +228,7 @@ const ct = {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
a(te, "defaultCodec", new te());
|
|
231
|
-
let
|
|
231
|
+
let Q = te;
|
|
232
232
|
function dt(s) {
|
|
233
233
|
return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
|
|
234
234
|
}
|
|
@@ -251,7 +251,7 @@ class ce {
|
|
|
251
251
|
a(this, "view");
|
|
252
252
|
a(this, "bytes");
|
|
253
253
|
a(this, "entered", !1);
|
|
254
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
254
|
+
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Q.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? lt, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? ht, 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 ce({
|
|
@@ -459,7 +459,7 @@ class ce {
|
|
|
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), Ze(this.view, this.pos, e), this.pos += 8;
|
|
463
463
|
}
|
|
464
464
|
writeI64(e) {
|
|
465
465
|
this.ensureBufferSizeToWrite(8), Se(this.view, this.pos, e), this.pos += 8;
|
|
@@ -496,8 +496,8 @@ class wt {
|
|
|
496
496
|
const i = this.caches[n - 1];
|
|
497
497
|
e: for (const o of i) {
|
|
498
498
|
const r = o.bytes;
|
|
499
|
-
for (let
|
|
500
|
-
if (r[
|
|
499
|
+
for (let p = 0; p < n; p++)
|
|
500
|
+
if (r[p] !== e[t + p])
|
|
501
501
|
continue e;
|
|
502
502
|
return o.str;
|
|
503
503
|
}
|
|
@@ -600,7 +600,7 @@ class le {
|
|
|
600
600
|
a(this, "headByte", O);
|
|
601
601
|
a(this, "stack", new yt());
|
|
602
602
|
a(this, "entered", !1);
|
|
603
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
603
|
+
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Q.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? q, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? q, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? q, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? q, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? q, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : bt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? xt;
|
|
604
604
|
}
|
|
605
605
|
clone() {
|
|
606
606
|
return new le({
|
|
@@ -673,10 +673,10 @@ class le {
|
|
|
673
673
|
try {
|
|
674
674
|
this.entered = !0;
|
|
675
675
|
let t = !1, n;
|
|
676
|
-
for await (const
|
|
676
|
+
for await (const p of e) {
|
|
677
677
|
if (t)
|
|
678
678
|
throw this.entered = !1, this.createExtraByteError(this.totalPos);
|
|
679
|
-
this.appendBuffer(
|
|
679
|
+
this.appendBuffer(p);
|
|
680
680
|
try {
|
|
681
681
|
n = this.doDecodeSync(), t = !0;
|
|
682
682
|
} catch (w) {
|
|
@@ -975,7 +975,7 @@ class le {
|
|
|
975
975
|
return this.pos += 4, e;
|
|
976
976
|
}
|
|
977
977
|
readU64() {
|
|
978
|
-
const e =
|
|
978
|
+
const e = Qe(this.view, this.pos);
|
|
979
979
|
return this.pos += 8, e;
|
|
980
980
|
}
|
|
981
981
|
readI64() {
|
|
@@ -1203,6 +1203,7 @@ class Et {
|
|
|
1203
1203
|
a(this, "socket", null);
|
|
1204
1204
|
a(this, "state", "idle");
|
|
1205
1205
|
a(this, "authed", !1);
|
|
1206
|
+
a(this, "everAuthed", !1);
|
|
1206
1207
|
a(this, "attempt", 0);
|
|
1207
1208
|
a(this, "outbox", []);
|
|
1208
1209
|
a(this, "stopped", !1);
|
|
@@ -1213,7 +1214,7 @@ class Et {
|
|
|
1213
1214
|
var n, i;
|
|
1214
1215
|
if (this.state === "connecting" || this.state === "open") return;
|
|
1215
1216
|
this.stopped = !1, this.state = "connecting", this.authed = !1, (i = (n = this.opts).onStatusChange) == null || i.call(n, this.attempt > 0 ? "reconnecting" : "connecting");
|
|
1216
|
-
const t = (this.opts.socketFactory ??
|
|
1217
|
+
const t = (this.opts.socketFactory ?? Bt)(this.opts.url);
|
|
1217
1218
|
t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
|
|
1218
1219
|
this.raw({ type: "auth", token: this.opts.token });
|
|
1219
1220
|
}, t.onmessage = (o) => {
|
|
@@ -1246,8 +1247,17 @@ class Et {
|
|
|
1246
1247
|
}
|
|
1247
1248
|
}
|
|
1248
1249
|
handle(e) {
|
|
1249
|
-
var t, n;
|
|
1250
|
-
e.type === "authed" && (this.attempt = 0, this.state = "open", this.authed = !0, (n = (t = this.opts).onStatusChange) == null || n.call(t, "open"), this.raw(this.opts.open), this.flush()), e.type === "opened" && this.raw({ type: "sync", conversationId: e.conversation.id, sinceSeq: this.opts.getCursor() }),
|
|
1250
|
+
var t, n, i, o, r;
|
|
1251
|
+
if (e.type === "authed" && (this.attempt = 0, this.state = "open", this.authed = !0, this.everAuthed = !0, (n = (t = this.opts).onStatusChange) == null || n.call(t, "open"), this.raw(this.opts.open), this.flush()), e.type === "opened" && this.raw({ type: "sync", conversationId: e.conversation.id, sinceSeq: this.opts.getCursor() }), e.type === "error" && Tt.has(e.code)) {
|
|
1252
|
+
this.stopped = !0;
|
|
1253
|
+
try {
|
|
1254
|
+
(i = this.socket) == null || i.close();
|
|
1255
|
+
} catch {
|
|
1256
|
+
}
|
|
1257
|
+
this.state = "closed", (r = (o = this.opts).onStatusChange) == null || r.call(o, "error", Ut(e.code)), this.opts.onFrame(e);
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
this.opts.onFrame(e);
|
|
1251
1261
|
}
|
|
1252
1262
|
flush() {
|
|
1253
1263
|
const e = this.outbox;
|
|
@@ -1263,20 +1273,34 @@ class Et {
|
|
|
1263
1273
|
}
|
|
1264
1274
|
}
|
|
1265
1275
|
onClosed() {
|
|
1276
|
+
var i, o;
|
|
1266
1277
|
if (this.authed = !1, this.socket = null, this.stopped) {
|
|
1267
1278
|
this.state = "closed";
|
|
1268
1279
|
return;
|
|
1269
1280
|
}
|
|
1270
1281
|
this.state = "idle";
|
|
1271
1282
|
const e = this.opts.backoffBaseMs ?? 500, t = this.opts.backoffMaxMs ?? 15e3, n = Math.min(t, e * 2 ** this.attempt) * (0.5 + Math.random() * 0.5);
|
|
1272
|
-
this.attempt++, this.timer = setTimeout(() => this.connect(), n);
|
|
1283
|
+
this.attempt++, this.attempt >= 3 && !this.everAuthed && ((o = (i = this.opts).onStatusChange) == null || o.call(i, "reconnecting", "Can't reach chat — retrying…")), this.timer = setTimeout(() => this.connect(), n);
|
|
1273
1284
|
}
|
|
1274
1285
|
}
|
|
1275
|
-
|
|
1286
|
+
const Tt = /* @__PURE__ */ new Set(["UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND"]);
|
|
1287
|
+
function Ut(s) {
|
|
1288
|
+
switch (s) {
|
|
1289
|
+
case "UNAUTHORIZED":
|
|
1290
|
+
return "Chat unavailable — sign-in/token was rejected";
|
|
1291
|
+
case "FORBIDDEN":
|
|
1292
|
+
return "Chat unavailable";
|
|
1293
|
+
case "NOT_FOUND":
|
|
1294
|
+
return "This chat isn't available";
|
|
1295
|
+
default:
|
|
1296
|
+
return "Chat unavailable";
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
function Bt(s) {
|
|
1276
1300
|
return new WebSocket(s);
|
|
1277
1301
|
}
|
|
1278
|
-
const ge = 200,
|
|
1279
|
-
class
|
|
1302
|
+
const ge = 200, Pt = 7 * 864e5;
|
|
1303
|
+
class At {
|
|
1280
1304
|
constructor(e) {
|
|
1281
1305
|
a(this, "key");
|
|
1282
1306
|
this.key = `ocw_outbox_${e}`;
|
|
@@ -1286,7 +1310,7 @@ class Pt {
|
|
|
1286
1310
|
try {
|
|
1287
1311
|
const e = localStorage.getItem(this.key);
|
|
1288
1312
|
if (!e) return [];
|
|
1289
|
-
const t = JSON.parse(e), n = Date.now() -
|
|
1313
|
+
const t = JSON.parse(e), n = Date.now() - Pt, i = t.filter((o) => o.ts >= n);
|
|
1290
1314
|
return i.length !== t.length && this.save(i), i;
|
|
1291
1315
|
} catch {
|
|
1292
1316
|
return [];
|
|
@@ -1336,7 +1360,7 @@ async function _(s) {
|
|
|
1336
1360
|
async function F(s) {
|
|
1337
1361
|
return C().importKey("raw", ae(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
|
|
1338
1362
|
}
|
|
1339
|
-
async function
|
|
1363
|
+
async function Kt(s, e) {
|
|
1340
1364
|
const t = await F(e);
|
|
1341
1365
|
return C().deriveKey(
|
|
1342
1366
|
{ name: "ECDH", public: t },
|
|
@@ -1346,21 +1370,21 @@ async function Bt(s, e) {
|
|
|
1346
1370
|
["encrypt", "decrypt"]
|
|
1347
1371
|
);
|
|
1348
1372
|
}
|
|
1349
|
-
async function
|
|
1373
|
+
async function zt(s, e) {
|
|
1350
1374
|
const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), n = new TextEncoder().encode(e), i = await C().encrypt({ name: "AES-GCM", iv: t }, s, n);
|
|
1351
1375
|
return { ct: ee(i), iv: ee(t) };
|
|
1352
1376
|
}
|
|
1353
|
-
async function
|
|
1377
|
+
async function Lt(s, e, t) {
|
|
1354
1378
|
const n = await C().decrypt({ name: "AES-GCM", iv: ae(t) }, s, ae(e));
|
|
1355
1379
|
return new TextDecoder().decode(n);
|
|
1356
1380
|
}
|
|
1357
|
-
async function
|
|
1381
|
+
async function Mt(s) {
|
|
1358
1382
|
var t, n;
|
|
1359
1383
|
try {
|
|
1360
1384
|
const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
|
|
1361
1385
|
if (i) {
|
|
1362
|
-
const { pub: o, priv: r } = JSON.parse(i),
|
|
1363
|
-
return { publicKey:
|
|
1386
|
+
const { pub: o, priv: r } = JSON.parse(i), p = await C().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await C().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
|
|
1387
|
+
return { publicKey: p, privateKey: w };
|
|
1364
1388
|
}
|
|
1365
1389
|
} catch {
|
|
1366
1390
|
}
|
|
@@ -1372,11 +1396,11 @@ async function zt(s) {
|
|
|
1372
1396
|
}
|
|
1373
1397
|
return e;
|
|
1374
1398
|
}
|
|
1375
|
-
async function
|
|
1399
|
+
async function Dt(s, e) {
|
|
1376
1400
|
const t = await C().exportKey("raw", e), n = await C().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
|
|
1377
1401
|
return ee(n);
|
|
1378
1402
|
}
|
|
1379
|
-
async function
|
|
1403
|
+
async function _t() {
|
|
1380
1404
|
const s = await V(), e = await C().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
|
|
1381
1405
|
return {
|
|
1382
1406
|
ecdhKP: s,
|
|
@@ -1390,9 +1414,9 @@ async function be(s) {
|
|
|
1390
1414
|
try {
|
|
1391
1415
|
const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
|
|
1392
1416
|
if (i) {
|
|
1393
|
-
const o = JSON.parse(i), r = await C().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []),
|
|
1417
|
+
const o = JSON.parse(i), r = await C().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), p = await C().importKey("jwk", o.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await C().importKey("jwk", o.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), d = await C().importKey("jwk", o.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
|
|
1394
1418
|
return {
|
|
1395
|
-
ecdhKP: { publicKey: r, privateKey:
|
|
1419
|
+
ecdhKP: { publicKey: r, privateKey: p },
|
|
1396
1420
|
ecdsaKP: { publicKey: w, privateKey: d },
|
|
1397
1421
|
publicKeyB64: await _(r),
|
|
1398
1422
|
sigPublicKeyB64: await _(w)
|
|
@@ -1400,20 +1424,20 @@ async function be(s) {
|
|
|
1400
1424
|
}
|
|
1401
1425
|
} catch {
|
|
1402
1426
|
}
|
|
1403
|
-
const e = await
|
|
1427
|
+
const e = await _t();
|
|
1404
1428
|
try {
|
|
1405
|
-
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),
|
|
1406
|
-
(n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: o, ecdsaPub: r, ecdsaPriv:
|
|
1429
|
+
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), p = await C().exportKey("jwk", e.ecdsaKP.privateKey);
|
|
1430
|
+
(n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: o, ecdsaPub: r, ecdsaPriv: p }));
|
|
1407
1431
|
} catch {
|
|
1408
1432
|
}
|
|
1409
1433
|
return e;
|
|
1410
1434
|
}
|
|
1411
|
-
async function
|
|
1412
|
-
const t = await V(), n = await _(t.publicKey), i = await F(e.identityKey), o = await F(e.signedPrekey), r = e.oneTimePrekey ? await F(e.oneTimePrekey) : null,
|
|
1435
|
+
async function $t(s, e) {
|
|
1436
|
+
const t = await V(), n = await _(t.publicKey), i = await F(e.identityKey), o = await F(e.signedPrekey), r = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, p = await D(s.privateKey, o), w = await D(t.privateKey, i), d = await D(t.privateKey, o), v = r ? await D(t.privateKey, r) : null, x = Ee(p, w, d, ...v ? [v] : []);
|
|
1413
1437
|
return { sharedKey: await Te(x), ephemeralPublicKey: n };
|
|
1414
1438
|
}
|
|
1415
|
-
async function
|
|
1416
|
-
const o = await F(t), r = await F(n),
|
|
1439
|
+
async function Rt(s, e, t, n, i) {
|
|
1440
|
+
const o = await F(t), r = await F(n), p = await D(e.privateKey, o), w = await D(s.privateKey, r), d = await D(e.privateKey, r), v = i ? await D(i.privateKey, r) : null, x = Ee(p, w, d, ...v ? [v] : []);
|
|
1417
1441
|
return Te(x);
|
|
1418
1442
|
}
|
|
1419
1443
|
async function D(s, e) {
|
|
@@ -1436,8 +1460,8 @@ async function Te(s) {
|
|
|
1436
1460
|
["encrypt", "decrypt"]
|
|
1437
1461
|
);
|
|
1438
1462
|
}
|
|
1439
|
-
const
|
|
1440
|
-
class
|
|
1463
|
+
const Ht = 20;
|
|
1464
|
+
class Ft {
|
|
1441
1465
|
constructor(e) {
|
|
1442
1466
|
// Live ECDH mode state
|
|
1443
1467
|
a(this, "kp");
|
|
@@ -1458,19 +1482,19 @@ class Ht {
|
|
|
1458
1482
|
}
|
|
1459
1483
|
/** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
|
|
1460
1484
|
async begin() {
|
|
1461
|
-
return this.kp = await
|
|
1485
|
+
return this.kp = await Mt(this.storageKey), _(this.kp.publicKey);
|
|
1462
1486
|
}
|
|
1463
1487
|
/** Live ECDH mode: A peer published their key — derive the shared secret. */
|
|
1464
1488
|
async onPeerKey(e) {
|
|
1465
|
-
this.kp && (this.shared = await
|
|
1489
|
+
this.kp && (this.shared = await Kt(this.kp.privateKey, e));
|
|
1466
1490
|
}
|
|
1467
1491
|
// ── X3DH async mode ────────────────────────────────────────────────────────
|
|
1468
1492
|
/** X3DH: Generate identity key, signed prekey, and OTP prekeys.
|
|
1469
1493
|
* Returns the upload frame payload the caller should send to the server. */
|
|
1470
1494
|
async initX3DH() {
|
|
1471
1495
|
this.identityKP = await be(this.storageKey), this.signedPreKP = await V(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1472
|
-
for (let i = 0; i <
|
|
1473
|
-
const e = await _(this.signedPreKP.publicKey), t = await
|
|
1496
|
+
for (let i = 0; i < Ht; i++) this.otpKeys.push(await V());
|
|
1497
|
+
const e = await _(this.signedPreKP.publicKey), t = await Dt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => _(i.publicKey)));
|
|
1474
1498
|
return {
|
|
1475
1499
|
identityKey: this.identityKP.publicKeyB64,
|
|
1476
1500
|
signedPrekey: e,
|
|
@@ -1483,7 +1507,7 @@ class Ht {
|
|
|
1483
1507
|
* return the init message fields to embed in the first encrypted message. */
|
|
1484
1508
|
async x3dhSendTo(e) {
|
|
1485
1509
|
this.identityKP || (this.identityKP = await be(this.storageKey));
|
|
1486
|
-
const { sharedKey: t, ephemeralPublicKey: n } = await
|
|
1510
|
+
const { sharedKey: t, ephemeralPublicKey: n } = await $t(this.identityKP.ecdhKP, e);
|
|
1487
1511
|
return this.x3dhShared = t, { ephemeralKey: n, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
|
|
1488
1512
|
}
|
|
1489
1513
|
/** X3DH recipient: given an init message's sender IK + EK + SPK ID, derive the shared key. */
|
|
@@ -1493,7 +1517,7 @@ class Ht {
|
|
|
1493
1517
|
return;
|
|
1494
1518
|
}
|
|
1495
1519
|
const i = this.otpKeys.shift();
|
|
1496
|
-
this.x3dhShared = await
|
|
1520
|
+
this.x3dhShared = await Rt(this.identityKP.ecdhKP, this.signedPreKP, e, t, i);
|
|
1497
1521
|
}
|
|
1498
1522
|
/** Flush pending X3DH derivation after initX3DH() completes. */
|
|
1499
1523
|
async flushPendingX3DH() {
|
|
@@ -1506,7 +1530,7 @@ class Ht {
|
|
|
1506
1530
|
async sealText(e, t) {
|
|
1507
1531
|
const n = this.x3dhShared ?? this.shared;
|
|
1508
1532
|
if (!n) throw new Error("secure channel not ready");
|
|
1509
|
-
const { ct: i, iv: o } = await
|
|
1533
|
+
const { ct: i, iv: o } = await zt(n, e);
|
|
1510
1534
|
return {
|
|
1511
1535
|
kind: "text",
|
|
1512
1536
|
text: i,
|
|
@@ -1521,7 +1545,7 @@ class Ht {
|
|
|
1521
1545
|
const t = this.x3dhShared ?? this.shared;
|
|
1522
1546
|
if (!t) return { kind: "text", text: "🔒 encrypted" };
|
|
1523
1547
|
try {
|
|
1524
|
-
return { kind: "text", text: await
|
|
1548
|
+
return { kind: "text", text: await Lt(t, e.text, e.iv) };
|
|
1525
1549
|
} catch {
|
|
1526
1550
|
return { kind: "text", text: "🔒 unable to decrypt" };
|
|
1527
1551
|
}
|
|
@@ -1533,12 +1557,12 @@ class Ht {
|
|
|
1533
1557
|
for (const t of e.messages) t.content = await this.openContent(t.content);
|
|
1534
1558
|
}
|
|
1535
1559
|
}
|
|
1536
|
-
function
|
|
1560
|
+
function jt(s) {
|
|
1537
1561
|
if (s.kind !== "text" || !s.enc) return null;
|
|
1538
1562
|
const e = s;
|
|
1539
1563
|
return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
|
|
1540
1564
|
}
|
|
1541
|
-
const me = "objectchat-widget-styles",
|
|
1565
|
+
const me = "objectchat-widget-styles", qt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Ot = `
|
|
1542
1566
|
.ocw { --ocw-accent:#4F63F5; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
|
|
1543
1567
|
position:relative;
|
|
1544
1568
|
display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
|
|
@@ -1623,6 +1647,7 @@ const me = "objectchat-widget-styles", Ft = ["👍", "❤️", "😂", "😮", "
|
|
|
1623
1647
|
.ocw-appt-btn-sec { background:#fff; color:var(--ocw-accent); border:1px solid var(--ocw-accent); }
|
|
1624
1648
|
.ocw-conn-status { font-size:10px; color:var(--ocw-mut); margin-left:4px; }
|
|
1625
1649
|
.ocw-conn-status.warn { color:#e67e22; }
|
|
1650
|
+
.ocw-conn-status.err { color:#c0392b; font-weight:600; }
|
|
1626
1651
|
.ocw-load-more { display:block; width:100%; background:none; border:1px solid #e3ded7; border-radius:10px; padding:6px 0; font-size:12px; color:var(--ocw-mut); cursor:pointer; margin-bottom:8px; }
|
|
1627
1652
|
.ocw-load-more:hover { border-color:var(--ocw-accent); color:var(--ocw-accent); }
|
|
1628
1653
|
.ocw-offline { margin:20px 14px; padding:20px; background:#fff; border:1px solid #e3ded7; border-radius:16px; text-align:center; }
|
|
@@ -1697,16 +1722,16 @@ const me = "objectchat-widget-styles", Ft = ["👍", "❤️", "😂", "😮", "
|
|
|
1697
1722
|
.ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
|
|
1698
1723
|
.ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
|
|
1699
1724
|
`;
|
|
1700
|
-
function
|
|
1725
|
+
function Nt() {
|
|
1701
1726
|
if (typeof document > "u" || document.getElementById(me)) return;
|
|
1702
1727
|
const s = document.createElement("style");
|
|
1703
|
-
s.id = me, s.textContent =
|
|
1728
|
+
s.id = me, s.textContent = Ot, document.head.appendChild(s);
|
|
1704
1729
|
}
|
|
1705
1730
|
function c(s, e, t) {
|
|
1706
1731
|
const n = document.createElement(s);
|
|
1707
1732
|
return e && (n.className = e), t !== void 0 && (n.textContent = t), n;
|
|
1708
1733
|
}
|
|
1709
|
-
function
|
|
1734
|
+
function Vt(s) {
|
|
1710
1735
|
try {
|
|
1711
1736
|
return new Date(s).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
1712
1737
|
} catch {
|
|
@@ -1730,7 +1755,7 @@ function se(s) {
|
|
|
1730
1755
|
return `📅 ${s.title} — ${new Date(s.startIso).toLocaleString()}`;
|
|
1731
1756
|
}
|
|
1732
1757
|
}
|
|
1733
|
-
class
|
|
1758
|
+
class Wt {
|
|
1734
1759
|
/** Last seq the guest has seen per conversationId — used to compute unread badges. */
|
|
1735
1760
|
constructor(e, t, n, i = {}) {
|
|
1736
1761
|
a(this, "scroll");
|
|
@@ -1763,8 +1788,8 @@ class Nt {
|
|
|
1763
1788
|
a(this, "translationCache", /* @__PURE__ */ new Map());
|
|
1764
1789
|
a(this, "showingTranslation", /* @__PURE__ */ new Set());
|
|
1765
1790
|
a(this, "subjectBuilt", !1);
|
|
1766
|
-
var m, g, U,
|
|
1767
|
-
this.root = e, this.me = t, this.h = n, this.cfg = i,
|
|
1791
|
+
var m, g, U, A, B, K, b, S, M;
|
|
1792
|
+
this.root = e, this.me = t, this.h = n, this.cfg = i, Nt(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
|
|
1768
1793
|
const o = c("div", "ocw-head"), r = c("div", "ocw-avatar");
|
|
1769
1794
|
if ((m = i.userInfo) != null && m.avatar) {
|
|
1770
1795
|
const k = document.createElement("img");
|
|
@@ -1772,8 +1797,8 @@ class Nt {
|
|
|
1772
1797
|
} else
|
|
1773
1798
|
r.textContent = (g = i.userInfo) != null && g.name ? i.userInfo.name[0].toUpperCase() : "🧑";
|
|
1774
1799
|
o.append(r);
|
|
1775
|
-
const
|
|
1776
|
-
this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((
|
|
1800
|
+
const p = c("div", "ocw-head-main");
|
|
1801
|
+
this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((A = i.subject) == null ? void 0 : A.title) ?? ""), p.append(this.headerName), (B = i.subject) != null && B.subtitle && p.append(c("div", "ocw-head-meta", i.subject.subtitle)), o.append(p), this.statusBadge = c("span", "ocw-badge", ((K = i.subject) == null ? void 0 : K.status) ?? ""), (b = i.subject) != null && b.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", () => {
|
|
1777
1802
|
this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
|
|
1778
1803
|
}), o.append(this.cobrowseBtn), 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");
|
|
1779
1804
|
const w = c("div", "ocw-typing-bubble");
|
|
@@ -1847,7 +1872,7 @@ class Nt {
|
|
|
1847
1872
|
const f = (d = this.cfg.subject) == null ? void 0 : d.ownerLabel;
|
|
1848
1873
|
f && (this.headerName.textContent = f);
|
|
1849
1874
|
}
|
|
1850
|
-
this.chips.replaceChildren();
|
|
1875
|
+
this.quick.style.display = e.messages().length === 0 ? "flex" : "none", this.chips.replaceChildren();
|
|
1851
1876
|
const t = e.visibleActions();
|
|
1852
1877
|
this.chips.style.display = t.length ? "flex" : "none";
|
|
1853
1878
|
for (const f of t) this.chips.append(this.chipEl(f));
|
|
@@ -1862,21 +1887,23 @@ class Nt {
|
|
|
1862
1887
|
i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - n + i : this.scroll.scrollTop = this.scroll.scrollHeight, o > 0 && this.h.onReadUpTo(o);
|
|
1863
1888
|
const r = [...e.typing];
|
|
1864
1889
|
this.typing.classList.toggle("active", r.length > 0);
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1890
|
+
const p = this.typing.querySelector(".ocw-typing-bubble");
|
|
1891
|
+
p && p.setAttribute("aria-label", r.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block", e.offline ? (this.offlinePanel.style.display === "none" && this.buildOfflinePanel(e.offlineMessage), this.offlinePanel.style.display = "block", (v = this.root.querySelector(".ocw-input")) == null || v.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (x = this.root.querySelector(".ocw-input")) == null || x.style.removeProperty("display"));
|
|
1867
1892
|
const w = ["resolved", "closed", "sold", "issued", "checked_out"];
|
|
1868
1893
|
this.h.onCsat && !this.csatSubmitted && w.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
|
|
1869
1894
|
}
|
|
1870
|
-
setConnStatus(e) {
|
|
1895
|
+
setConnStatus(e, t) {
|
|
1871
1896
|
if (e === "open") {
|
|
1872
1897
|
this.connStatus.style.display = "none";
|
|
1873
1898
|
return;
|
|
1874
1899
|
}
|
|
1875
|
-
this.connStatus.style.display = ""
|
|
1900
|
+
this.connStatus.style.display = "";
|
|
1901
|
+
const n = e === "error";
|
|
1902
|
+
this.connStatus.className = `ocw-conn-status${n ? " err" : e === "reconnecting" ? " warn" : ""}`, this.connStatus.textContent = n ? `⚠ ${t ?? "Chat unavailable"}` : e === "reconnecting" ? t ?? "↻ reconnecting…" : "● connecting…";
|
|
1876
1903
|
}
|
|
1877
1904
|
buildOfflinePanel(e) {
|
|
1878
|
-
var
|
|
1879
|
-
this.offlinePanel.replaceChildren(), this.offlinePanel.append(c("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(c("div", "ocw-offline-title", ((
|
|
1905
|
+
var p;
|
|
1906
|
+
this.offlinePanel.replaceChildren(), this.offlinePanel.append(c("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(c("div", "ocw-offline-title", ((p = this.cfg.i18n) == null ? void 0 : p.offline) ?? "We're offline right now")), this.offlinePanel.append(c("div", "ocw-offline-msg", e || "Leave your details and we'll get back to you soon."));
|
|
1880
1907
|
const t = c("div", "ocw-offline-form"), n = c("input", "ocw-offline-input");
|
|
1881
1908
|
n.placeholder = "Your name", n.type = "text";
|
|
1882
1909
|
const i = c("input", "ocw-offline-input");
|
|
@@ -1933,7 +1960,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
1933
1960
|
bindCobrowsePointerEvents() {
|
|
1934
1961
|
let e = !1, t = [];
|
|
1935
1962
|
const n = (r) => {
|
|
1936
|
-
const
|
|
1963
|
+
const p = this.cobrowseCanvas.getBoundingClientRect(), w = p.width > 0 ? (r.clientX - p.left) / p.width : 0, d = p.height > 0 ? (r.clientY - p.top) / p.height : 0;
|
|
1937
1964
|
return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0, d)) };
|
|
1938
1965
|
}, i = 6e-3;
|
|
1939
1966
|
this.cobrowseCanvas.addEventListener("pointerdown", (r) => {
|
|
@@ -1942,9 +1969,9 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
1942
1969
|
e && (t.push(n(r)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: i }));
|
|
1943
1970
|
});
|
|
1944
1971
|
const o = (r) => {
|
|
1945
|
-
var
|
|
1972
|
+
var p, w;
|
|
1946
1973
|
if (e) {
|
|
1947
|
-
e = !1, t.length > 1 && ((w = (
|
|
1974
|
+
e = !1, t.length > 1 && ((w = (p = this.h).onAnnotate) == null || w.call(p, { id: `an_${Date.now()}_${Math.random().toString(36).slice(2)}`, points: t, color: this.cobrowseColor, width: i })), t = [];
|
|
1948
1975
|
try {
|
|
1949
1976
|
this.cobrowseCanvas.releasePointerCapture(r.pointerId);
|
|
1950
1977
|
} catch {
|
|
@@ -1959,8 +1986,8 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
1959
1986
|
if (!i) return;
|
|
1960
1987
|
this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(c("div", "ocw-subject-title", i)), n != null && n.subtitle && this.subjectCard.append(c("div", "ocw-subject-sub", n.subtitle));
|
|
1961
1988
|
const o = c("div", "ocw-tags");
|
|
1962
|
-
if (t) for (const [
|
|
1963
|
-
else for (const
|
|
1989
|
+
if (t) for (const [p, w] of Object.entries(t.fields)) o.append(c("span", "ocw-tag", `${p}: ${w}`));
|
|
1990
|
+
else for (const p of (n == null ? void 0 : n.tags) ?? []) o.append(c("span", "ocw-tag", p));
|
|
1964
1991
|
o.childNodes.length && this.subjectCard.append(o);
|
|
1965
1992
|
const r = (t == null ? void 0 : t.state) ?? (n == null ? void 0 : n.status);
|
|
1966
1993
|
r && (this.statusBadge.textContent = r, this.statusBadge.style.display = "inline-flex");
|
|
@@ -1977,25 +2004,25 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
1977
2004
|
return new Promise((t) => {
|
|
1978
2005
|
const n = c("div", "ocw-modal"), i = c("div", "ocw-modal-card");
|
|
1979
2006
|
i.append(c("div", "ocw-modal-title", e)), i.append(c("div", "ocw-modal-body", `Confirm “${e}”?`));
|
|
1980
|
-
const o = c("div", "ocw-modal-actions"), r = c("button", "ocw-modal-cancel", "Cancel"),
|
|
2007
|
+
const o = c("div", "ocw-modal-actions"), r = c("button", "ocw-modal-cancel", "Cancel"), p = c("button", "ocw-modal-ok", "Confirm"), w = (d) => {
|
|
1981
2008
|
n.remove(), t(d);
|
|
1982
2009
|
};
|
|
1983
|
-
r.addEventListener("click", () => w(!1)),
|
|
2010
|
+
r.addEventListener("click", () => w(!1)), p.addEventListener("click", () => w(!0)), n.addEventListener("click", (d) => {
|
|
1984
2011
|
d.target === n && w(!1);
|
|
1985
|
-
}), o.append(r,
|
|
2012
|
+
}), o.append(r, p), i.append(o), n.append(i), this.root.append(n), p.focus();
|
|
1986
2013
|
});
|
|
1987
2014
|
}
|
|
1988
2015
|
/** Inline form for a form-effect action: typed inputs (date picker, number,
|
|
1989
2016
|
* text) rendered above the composer — no browser prompts. */
|
|
1990
2017
|
openForm(e) {
|
|
1991
|
-
var
|
|
2018
|
+
var p, w;
|
|
1992
2019
|
this.formHost.replaceChildren();
|
|
1993
2020
|
const t = c("div", "ocw-form");
|
|
1994
2021
|
t.append(c("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
|
|
1995
2022
|
const n = /* @__PURE__ */ new Map();
|
|
1996
2023
|
for (const d of e.input ?? []) {
|
|
1997
2024
|
const v = c("label", "ocw-form-row");
|
|
1998
|
-
if (v.append(c("span", "ocw-form-lbl", d.label)), d.type === "select" && ((
|
|
2025
|
+
if (v.append(c("span", "ocw-form-lbl", d.label)), d.type === "select" && ((p = d.options) != null && p.length)) {
|
|
1999
2026
|
const x = c("select", "ocw-form-input");
|
|
2000
2027
|
d.required || x.append(c("option", void 0, "— select —"));
|
|
2001
2028
|
for (const f of d.options) {
|
|
@@ -2030,7 +2057,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2030
2057
|
}
|
|
2031
2058
|
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" : ""}`);
|
|
2032
2059
|
!n && !i && o.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
|
|
2033
|
-
const r = c("div"),
|
|
2060
|
+
const r = c("div"), p = c("div", "ocw-bubble-wrap");
|
|
2034
2061
|
if (e.replyToId) {
|
|
2035
2062
|
const f = c("div", "ocw-reply-to", "↩ replying to a message");
|
|
2036
2063
|
f.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", r.append(f);
|
|
@@ -2056,7 +2083,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2056
2083
|
g.href = f.icalUrl, g.download = `${f.title}.ics`, g.className = "ocw-appt-btn ocw-appt-btn-sec", g.textContent = "🍎 Apple / iCal", I.append(m, g), u.append(I), w.append(u);
|
|
2057
2084
|
} else
|
|
2058
2085
|
d = document.createTextNode(se(e.content)), w.append(d), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
|
|
2059
|
-
if (
|
|
2086
|
+
if (p.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && d) {
|
|
2060
2087
|
const f = e.content.text;
|
|
2061
2088
|
if (f.trim()) {
|
|
2062
2089
|
const u = c("button", "ocw-translate-btn", "🌐");
|
|
@@ -2079,7 +2106,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2079
2106
|
}
|
|
2080
2107
|
this.translationCache.set(e.id, g), this.showingTranslation.add(e.id), d.textContent = g, u.textContent = "↩", u.title = "Show original";
|
|
2081
2108
|
});
|
|
2082
|
-
}),
|
|
2109
|
+
}), p.append(u);
|
|
2083
2110
|
}
|
|
2084
2111
|
}
|
|
2085
2112
|
if (n && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
|
|
@@ -2092,14 +2119,14 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2092
2119
|
g.value = m, g.rows = Math.min(4, Math.ceil(m.length / 40) + 1), g.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
|
|
2093
2120
|
const U = c("button", "ocw-form-submit", "Save");
|
|
2094
2121
|
U.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
|
|
2095
|
-
const
|
|
2096
|
-
|
|
2097
|
-
const
|
|
2098
|
-
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2122
|
+
const A = c("button", "ocw-form-cancel", "Cancel");
|
|
2123
|
+
A.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
|
|
2124
|
+
const B = c("div");
|
|
2125
|
+
B.style.cssText = "display:flex;gap:6px;justify-content:flex-end", B.append(A, U);
|
|
2126
|
+
const K = c("div");
|
|
2127
|
+
K.append(g, B), w.replaceChildren(K), g.focus(), g.select();
|
|
2101
2128
|
const b = () => w.replaceChildren(d ?? document.createTextNode(m));
|
|
2102
|
-
|
|
2129
|
+
A.addEventListener("click", b), U.addEventListener("click", () => {
|
|
2103
2130
|
const S = g.value.trim();
|
|
2104
2131
|
S && S !== m && this.h.onEdit(e.id, S), b();
|
|
2105
2132
|
}), g.addEventListener("keydown", (S) => {
|
|
@@ -2113,26 +2140,26 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2113
2140
|
I.stopPropagation(), this.h.onDelete(e.id);
|
|
2114
2141
|
}), f.append(u);
|
|
2115
2142
|
}
|
|
2116
|
-
|
|
2143
|
+
p.append(f);
|
|
2117
2144
|
}
|
|
2118
|
-
if (r.append(
|
|
2145
|
+
if (r.append(p), this.h.onReact && !e.deletedAt && e.seq > 0) {
|
|
2119
2146
|
const f = c("div", "ocw-react-wrap"), u = c("div", "ocw-react");
|
|
2120
2147
|
if (e.reactions && Object.keys(e.reactions).length)
|
|
2121
2148
|
for (const [g, U] of Object.entries(e.reactions)) {
|
|
2122
|
-
const
|
|
2123
|
-
|
|
2124
|
-
var
|
|
2125
|
-
return (
|
|
2126
|
-
}), u.append(
|
|
2149
|
+
const A = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${g} ${U.length}`);
|
|
2150
|
+
A.addEventListener("click", () => {
|
|
2151
|
+
var B, K;
|
|
2152
|
+
return (K = (B = this.h).onReact) == null ? void 0 : K.call(B, e.id, g, U.includes(this.me));
|
|
2153
|
+
}), u.append(A);
|
|
2127
2154
|
}
|
|
2128
2155
|
const I = c("button", "ocw-react-btn", "+"), m = c("div", "ocw-react-picker");
|
|
2129
|
-
for (const g of
|
|
2156
|
+
for (const g of qt) {
|
|
2130
2157
|
const U = c("button", void 0, g);
|
|
2131
|
-
U.addEventListener("click", (
|
|
2132
|
-
var
|
|
2133
|
-
|
|
2134
|
-
const
|
|
2135
|
-
(M = (S = this.h).onReact) == null || M.call(S, e.id, g, !!
|
|
2158
|
+
U.addEventListener("click", (A) => {
|
|
2159
|
+
var K, b, S, M;
|
|
2160
|
+
A.stopPropagation();
|
|
2161
|
+
const B = (b = (K = e.reactions) == null ? void 0 : K[g]) == null ? void 0 : b.includes(this.me);
|
|
2162
|
+
(M = (S = this.h).onReact) == null || M.call(S, e.id, g, !!B), m.style.display = "none";
|
|
2136
2163
|
}), m.append(U);
|
|
2137
2164
|
}
|
|
2138
2165
|
m.style.display = "none", I.addEventListener("click", (g) => {
|
|
@@ -2141,15 +2168,15 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
|
|
|
2141
2168
|
m.style.display = "none";
|
|
2142
2169
|
}, { once: !0 }), u.append(I), f.append(u, m), r.append(f);
|
|
2143
2170
|
} else e.reactions && Object.keys(e.reactions).length && r.append(c("div", "ocw-react", Object.entries(e.reactions).map(([f, u]) => `${f}${u.length}`).join(" ")));
|
|
2144
|
-
const v = c("div", "ocw-time ocw-meta",
|
|
2171
|
+
const v = c("div", "ocw-time ocw-meta", Vt(e.ts));
|
|
2145
2172
|
if (n && e.status) {
|
|
2146
|
-
const f = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`,
|
|
2173
|
+
const f = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Xt(e.status));
|
|
2147
2174
|
v.append(f);
|
|
2148
2175
|
}
|
|
2149
2176
|
return n && e.seq > 0 && t.lastReadByOthers >= e.seq && v.append(c("span", "ocw-seen", " · Seen")), r.append(v), o.append(r), o;
|
|
2150
2177
|
}
|
|
2151
2178
|
}
|
|
2152
|
-
function
|
|
2179
|
+
function Xt(s) {
|
|
2153
2180
|
switch (s) {
|
|
2154
2181
|
case "read":
|
|
2155
2182
|
return "✓✓";
|
|
@@ -2161,28 +2188,28 @@ function Vt(s) {
|
|
|
2161
2188
|
return "🕓";
|
|
2162
2189
|
}
|
|
2163
2190
|
}
|
|
2164
|
-
const
|
|
2191
|
+
const R = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
|
|
2165
2192
|
function ve(s) {
|
|
2166
2193
|
return `relay-launcher::${s.profileId}::${s.subjectId ?? ""}`;
|
|
2167
2194
|
}
|
|
2168
|
-
function
|
|
2195
|
+
function Zt(s) {
|
|
2169
2196
|
var e;
|
|
2170
|
-
(e =
|
|
2197
|
+
(e = R.get(s)) == null || e.close(), R.delete(s);
|
|
2171
2198
|
}
|
|
2172
|
-
function
|
|
2199
|
+
function Qt(s) {
|
|
2173
2200
|
var he, pe, ue, fe, we;
|
|
2174
|
-
|
|
2175
|
-
const e = $e(), t = s.token ?? s.userId ?? e, n = t !== e ? e : void 0, { wsUrl: i, httpBase: o } =
|
|
2201
|
+
R.has(s.el) && (R.get(s.el).close(), R.delete(s.el)), s.launcher && ((he = Z.get(ve(s))) == null || he.close());
|
|
2202
|
+
const e = $e(), t = s.token ?? s.userId ?? e, n = t !== e ? e : void 0, { wsUrl: i, httpBase: o } = Re(s.url, s.apiUrl);
|
|
2176
2203
|
let r = new Ct(t);
|
|
2177
|
-
const
|
|
2204
|
+
const p = s.subjectId ? `${t}::${s.subjectId}` : t, w = new At(p);
|
|
2178
2205
|
let d, v = !1, x = null, f = null;
|
|
2179
2206
|
!s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
|
|
2180
2207
|
for (const l of w.load()) r.addOptimistic(l.clientMsgId, l.content);
|
|
2181
2208
|
let u = null, I = null, m = 0, g = !s.launcher;
|
|
2182
2209
|
if (s.launcher) {
|
|
2183
|
-
const
|
|
2184
|
-
u = document.createElement("div"), u.style.cssText = `position:fixed;${
|
|
2185
|
-
const y = document.createElement("div"), E = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null,
|
|
2210
|
+
const h = (s.position ?? "bottom-right").includes("right");
|
|
2211
|
+
u = document.createElement("div"), u.style.cssText = `position:fixed;${h ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${h ? "flex-end" : "flex-start"};gap:12px`;
|
|
2212
|
+
const y = document.createElement("div"), E = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, H = ($) => {
|
|
2186
2213
|
y.style.cssText = $ ? [
|
|
2187
2214
|
"position:fixed",
|
|
2188
2215
|
"inset:0",
|
|
@@ -2206,28 +2233,28 @@ function Gt(s) {
|
|
|
2206
2233
|
"display:none",
|
|
2207
2234
|
"flex-direction:column",
|
|
2208
2235
|
"background:#fff",
|
|
2209
|
-
"transform-origin:bottom " + (
|
|
2236
|
+
"transform-origin:bottom " + (h ? "right" : "left"),
|
|
2210
2237
|
"transition:opacity .18s,transform .18s",
|
|
2211
2238
|
"opacity:0",
|
|
2212
2239
|
"transform:scale(.95)"
|
|
2213
2240
|
].join(";");
|
|
2214
2241
|
};
|
|
2215
|
-
|
|
2216
|
-
const Y = ($) =>
|
|
2242
|
+
H((E == null ? void 0 : E.matches) ?? !1);
|
|
2243
|
+
const Y = ($) => H($.matches);
|
|
2217
2244
|
E == null || E.addEventListener("change", Y), x = E, f = Y, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
|
|
2218
|
-
const
|
|
2219
|
-
|
|
2245
|
+
const P = document.createElement("button");
|
|
2246
|
+
P.style.cssText = [
|
|
2220
2247
|
"width:56px;height:56px;border-radius:50%",
|
|
2221
2248
|
`background:${s.accent ?? "#4F63F5"}`,
|
|
2222
2249
|
"color:#fff;border:none;font-size:24px;cursor:pointer",
|
|
2223
2250
|
"box-shadow:0 4px 16px rgba(0,0,0,.25)",
|
|
2224
2251
|
"position:relative;flex:none",
|
|
2225
2252
|
"transition:transform .15s"
|
|
2226
|
-
].join(";"),
|
|
2227
|
-
|
|
2228
|
-
},
|
|
2229
|
-
|
|
2230
|
-
}, I = document.createElement("span"), I.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",
|
|
2253
|
+
].join(";"), P.textContent = "💬", P.onmouseenter = () => {
|
|
2254
|
+
P.style.transform = "scale(1.08)";
|
|
2255
|
+
}, P.onmouseleave = () => {
|
|
2256
|
+
P.style.transform = "scale(1)";
|
|
2257
|
+
}, I = document.createElement("span"), I.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", P.append(I), u.append(y, P), document.body.append(u);
|
|
2231
2258
|
const J = ($) => {
|
|
2232
2259
|
$ ? (y.style.display = "flex", requestAnimationFrame(() => {
|
|
2233
2260
|
y.style.opacity = "1", y.style.transform = "scale(1)";
|
|
@@ -2235,40 +2262,40 @@ function Gt(s) {
|
|
|
2235
2262
|
g || (y.style.display = "none");
|
|
2236
2263
|
}, 180));
|
|
2237
2264
|
};
|
|
2238
|
-
|
|
2239
|
-
g = !g, J(g),
|
|
2265
|
+
P.addEventListener("click", () => {
|
|
2266
|
+
g = !g, J(g), P.textContent = g ? "✕" : "💬", P.append(I), g && (m = 0, I && (I.style.display = "none"));
|
|
2240
2267
|
}), document.addEventListener("keydown", ($) => {
|
|
2241
|
-
$.key === "Escape" && g && (g = !1, J(!1),
|
|
2268
|
+
$.key === "Escape" && g && (g = !1, J(!1), P.textContent = "💬", P.append(I));
|
|
2242
2269
|
});
|
|
2243
2270
|
}
|
|
2244
2271
|
const U = () => {
|
|
2245
2272
|
g || (m++, I && (I.textContent = String(m), I.style.display = "flex"));
|
|
2246
|
-
},
|
|
2273
|
+
}, A = () => {
|
|
2247
2274
|
try {
|
|
2248
|
-
const l = new AudioContext(),
|
|
2249
|
-
|
|
2275
|
+
const l = new AudioContext(), h = l.createOscillator(), y = l.createGain();
|
|
2276
|
+
h.connect(y), y.connect(l.destination), h.frequency.setValueAtTime(880, l.currentTime), h.frequency.exponentialRampToValueAtTime(440, l.currentTime + 0.15), y.gain.setValueAtTime(0.3, l.currentTime), y.gain.exponentialRampToValueAtTime(1e-3, l.currentTime + 0.3), h.start(), h.stop(l.currentTime + 0.3);
|
|
2250
2277
|
} catch {
|
|
2251
2278
|
}
|
|
2252
|
-
},
|
|
2253
|
-
for (;
|
|
2254
|
-
const
|
|
2255
|
-
w.add({ clientMsgId:
|
|
2279
|
+
}, B = [], K = (l) => {
|
|
2280
|
+
for (; B.length; ) {
|
|
2281
|
+
const h = B.shift();
|
|
2282
|
+
w.add({ clientMsgId: h.clientMsgId, content: h.content, ts: Date.now() }), b.send({ type: "send", conversationId: l, clientMsgId: h.clientMsgId, content: h.content });
|
|
2256
2283
|
}
|
|
2257
2284
|
};
|
|
2258
2285
|
let b;
|
|
2259
|
-
const S = new
|
|
2286
|
+
const S = new Ft(`ocw-e2e-${s.profileId}`);
|
|
2260
2287
|
let M = !1;
|
|
2261
2288
|
const k = [], T = [];
|
|
2262
2289
|
let W = !1;
|
|
2263
|
-
const ne = (l,
|
|
2264
|
-
S.sealText(
|
|
2290
|
+
const ne = (l, h) => {
|
|
2291
|
+
S.sealText(h).then((y) => {
|
|
2265
2292
|
d && b.send({ type: "send", conversationId: d, clientMsgId: l, content: y });
|
|
2266
2293
|
});
|
|
2267
|
-
}, Ue = (l,
|
|
2268
|
-
S.sealText(
|
|
2294
|
+
}, Ue = (l, h, y) => {
|
|
2295
|
+
S.sealText(h, y).then((E) => {
|
|
2269
2296
|
d && b.send({ type: "send", conversationId: d, clientMsgId: l, content: E });
|
|
2270
2297
|
});
|
|
2271
|
-
},
|
|
2298
|
+
}, Be = () => {
|
|
2272
2299
|
for (; k.length; ) {
|
|
2273
2300
|
const l = k.shift();
|
|
2274
2301
|
ne(l.clientMsgId, l.text);
|
|
@@ -2277,37 +2304,37 @@ function Gt(s) {
|
|
|
2277
2304
|
const l = T.shift();
|
|
2278
2305
|
ne(l.clientMsgId, l.text);
|
|
2279
2306
|
}
|
|
2280
|
-
},
|
|
2307
|
+
}, Pe = (l) => {
|
|
2281
2308
|
b.send({ type: "fetchPrekey", targetUserId: l });
|
|
2282
|
-
},
|
|
2283
|
-
|
|
2284
|
-
const L = new
|
|
2309
|
+
}, Ae = s.i18n ?? {}, Ke = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
|
|
2310
|
+
Ke.includes(ze) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
|
|
2311
|
+
const L = new Wt(s.el, t, {
|
|
2285
2312
|
onSend(l) {
|
|
2286
|
-
const
|
|
2287
|
-
r.addOptimistic(
|
|
2313
|
+
const h = `cm_${Math.random().toString(36).slice(2)}`, y = { kind: "text", text: l };
|
|
2314
|
+
r.addOptimistic(h, y), L.render(r), r.e2e ? S.ready ? ne(h, l) : W ? T.push({ clientMsgId: h, text: l }) : (k.push({ clientMsgId: h, text: l }), r.assignedAgentId && Pe(r.assignedAgentId)) : d ? (w.add({ clientMsgId: h, content: y, ts: Date.now() }), b.send({ type: "send", conversationId: d, clientMsgId: h, content: y })) : B.push({ clientMsgId: h, content: y });
|
|
2288
2315
|
},
|
|
2289
2316
|
async onAttach(l) {
|
|
2290
2317
|
if (!d) return;
|
|
2291
|
-
const
|
|
2318
|
+
const h = `${o}/upload?name=${encodeURIComponent(l.name)}`, y = `cm_${Math.random().toString(36).slice(2)}`;
|
|
2292
2319
|
r.addOptimistic(y, { kind: "text", text: `📎 Uploading ${l.name}…` }), L.render(r);
|
|
2293
2320
|
try {
|
|
2294
|
-
const E = await fetch(
|
|
2321
|
+
const E = await fetch(h, {
|
|
2295
2322
|
method: "POST",
|
|
2296
2323
|
headers: { "content-type": l.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
|
|
2297
2324
|
body: l
|
|
2298
2325
|
});
|
|
2299
2326
|
if (!E.ok) throw new Error(`Upload failed: ${E.status}`);
|
|
2300
|
-
const { url:
|
|
2301
|
-
b.send({ type: "send", conversationId: d, clientMsgId: y, content: { kind: "attachment", url:
|
|
2327
|
+
const { url: H, name: Y, mime: P, size: J } = await E.json();
|
|
2328
|
+
b.send({ type: "send", conversationId: d, clientMsgId: y, content: { kind: "attachment", url: H, name: Y, mime: P, size: J } });
|
|
2302
2329
|
} catch (E) {
|
|
2303
2330
|
r.addOptimistic(y, { kind: "text", text: `⚠️ Upload failed: ${E.message}` }), L.render(r);
|
|
2304
2331
|
}
|
|
2305
2332
|
},
|
|
2306
|
-
onInvoke(l,
|
|
2307
|
-
d && b.send({ type: "invoke", conversationId: d, actionId: l, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...
|
|
2333
|
+
onInvoke(l, h) {
|
|
2334
|
+
d && b.send({ type: "invoke", conversationId: d, actionId: l, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...h ? { inputs: h } : {} });
|
|
2308
2335
|
},
|
|
2309
|
-
onTyping(l,
|
|
2310
|
-
d && b.send({ type: "typing", conversationId: d, isTyping: l, ...
|
|
2336
|
+
onTyping(l, h) {
|
|
2337
|
+
d && b.send({ type: "typing", conversationId: d, isTyping: l, ...h ? { preview: h } : {} });
|
|
2311
2338
|
},
|
|
2312
2339
|
onReadUpTo(l) {
|
|
2313
2340
|
d && b.send({ type: "read", conversationId: d, seq: l });
|
|
@@ -2317,14 +2344,14 @@ function Gt(s) {
|
|
|
2317
2344
|
const l = r.messages()[0];
|
|
2318
2345
|
l && b.send({ type: "history", conversationId: d, beforeSeq: l.seq, limit: 20 });
|
|
2319
2346
|
},
|
|
2320
|
-
onEdit(l,
|
|
2321
|
-
d && b.send({ type: "edit", conversationId: d, messageId: l, content: { kind: "text", text:
|
|
2347
|
+
onEdit(l, h) {
|
|
2348
|
+
d && b.send({ type: "edit", conversationId: d, messageId: l, content: { kind: "text", text: h } });
|
|
2322
2349
|
},
|
|
2323
2350
|
onDelete(l) {
|
|
2324
2351
|
d && b.send({ type: "delete", conversationId: d, messageId: l });
|
|
2325
2352
|
},
|
|
2326
|
-
onReact(l,
|
|
2327
|
-
d && b.send({ type: "react", conversationId: d, messageId: l, emoji:
|
|
2353
|
+
onReact(l, h, y) {
|
|
2354
|
+
d && b.send({ type: "react", conversationId: d, messageId: l, emoji: h, remove: y });
|
|
2328
2355
|
},
|
|
2329
2356
|
onCsat(l) {
|
|
2330
2357
|
d && fetch(`${o}/conversations/${d}/csat`, {
|
|
@@ -2343,13 +2370,13 @@ function Gt(s) {
|
|
|
2343
2370
|
...s.translateLang ? {
|
|
2344
2371
|
async onTranslate(l) {
|
|
2345
2372
|
try {
|
|
2346
|
-
const
|
|
2373
|
+
const h = await fetch(`${o}/translate`, {
|
|
2347
2374
|
method: "POST",
|
|
2348
2375
|
headers: { "content-type": "application/json", authorization: `Bearer ${t}` },
|
|
2349
2376
|
body: JSON.stringify({ text: l, targetLang: s.translateLang })
|
|
2350
2377
|
});
|
|
2351
|
-
if (!
|
|
2352
|
-
const { translated: y } = await
|
|
2378
|
+
if (!h.ok) return null;
|
|
2379
|
+
const { translated: y } = await h.json();
|
|
2353
2380
|
return y;
|
|
2354
2381
|
} catch {
|
|
2355
2382
|
return null;
|
|
@@ -2361,7 +2388,7 @@ function Gt(s) {
|
|
|
2361
2388
|
...s.quickReplies ? { quickReplies: s.quickReplies } : {},
|
|
2362
2389
|
...s.accent ? { accent: s.accent } : {},
|
|
2363
2390
|
...(pe = s.user) != null && pe.name || (ue = s.user) != null && ue.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
|
|
2364
|
-
i18n:
|
|
2391
|
+
i18n: Ae
|
|
2365
2392
|
}), Le = {
|
|
2366
2393
|
type: "open",
|
|
2367
2394
|
profileId: s.profileId,
|
|
@@ -2374,10 +2401,10 @@ function Gt(s) {
|
|
|
2374
2401
|
...(fe = s.subject) != null && fe.title ? { subjectTitle: s.subject.title } : {},
|
|
2375
2402
|
...(we = s.subject) != null && we.subtitle ? { subjectMeta: s.subject.subtitle } : {}
|
|
2376
2403
|
}, Me = (l) => {
|
|
2377
|
-
const
|
|
2378
|
-
if (!
|
|
2404
|
+
const h = s.user;
|
|
2405
|
+
if (!h || !h.name && !h.email && !h.avatar && !h.meta) return;
|
|
2379
2406
|
const y = [];
|
|
2380
|
-
if (
|
|
2407
|
+
if (h.name && y.push(`Name: ${h.name}`), h.email && y.push(`Email: ${h.email}`), h.avatar && y.push(`Avatar: ${h.avatar}`), h.meta) for (const [E, H] of Object.entries(h.meta)) y.push(`${E}: ${H}`);
|
|
2381
2408
|
b.send({ type: "note", conversationId: l, clientMsgId: `ui_${Date.now()}`, text: `[User info]
|
|
2382
2409
|
${y.join(`
|
|
2383
2410
|
`)}` });
|
|
@@ -2387,29 +2414,29 @@ ${y.join(`
|
|
|
2387
2414
|
token: t,
|
|
2388
2415
|
open: Le,
|
|
2389
2416
|
getCursor: () => r.highestSeq(),
|
|
2390
|
-
onStatusChange: (l) => L.setConnStatus(l),
|
|
2417
|
+
onStatusChange: (l, h) => L.setConnStatus(l, h),
|
|
2391
2418
|
onFrame(l) {
|
|
2392
2419
|
if (l.type === "opened") {
|
|
2393
|
-
const
|
|
2420
|
+
const h = d === void 0;
|
|
2394
2421
|
if (d = l.conversation.id, !v) {
|
|
2395
2422
|
v = !0;
|
|
2396
2423
|
for (const y of w.load())
|
|
2397
2424
|
b.send({ type: "send", conversationId: d, clientMsgId: y.clientMsgId, content: y.content });
|
|
2398
2425
|
}
|
|
2399
|
-
|
|
2426
|
+
He(i, t, d, r, L, o), B.length && K(d), h && l.conversation.lastSeq === 0 && Me(d);
|
|
2400
2427
|
}
|
|
2401
2428
|
if (l.type === "ack" && w.remove(l.clientMsgId), l.type === "prekeyBundle") {
|
|
2402
|
-
l.bundle && (W = !0, S.x3dhSendTo(l.bundle).then((
|
|
2429
|
+
l.bundle && (W = !0, S.x3dhSendTo(l.bundle).then((h) => {
|
|
2403
2430
|
const y = [...k.splice(0), ...T.splice(0)];
|
|
2404
|
-
for (const E of y) Ue(E.clientMsgId, E.text,
|
|
2431
|
+
for (const E of y) Ue(E.clientMsgId, E.text, h);
|
|
2405
2432
|
L.render(r);
|
|
2406
2433
|
}));
|
|
2407
2434
|
return;
|
|
2408
2435
|
}
|
|
2409
2436
|
if (l.type === "message" && r.e2e) {
|
|
2410
|
-
const
|
|
2411
|
-
if (
|
|
2412
|
-
S.x3dhReceiveFrom(
|
|
2437
|
+
const h = jt(l.message.content);
|
|
2438
|
+
if (h && !S.ready) {
|
|
2439
|
+
S.x3dhReceiveFrom(h.x3dhIK, h.x3dhEK, h.x3dhSPK).then(async () => {
|
|
2413
2440
|
await S.openFrame(l), r.apply(l), L.render(r);
|
|
2414
2441
|
});
|
|
2415
2442
|
return;
|
|
@@ -2417,15 +2444,15 @@ ${y.join(`
|
|
|
2417
2444
|
}
|
|
2418
2445
|
if (l.type === "peerkey") {
|
|
2419
2446
|
S.onPeerKey(l.key).then(() => {
|
|
2420
|
-
|
|
2447
|
+
Be(), L.render(r);
|
|
2421
2448
|
});
|
|
2422
2449
|
return;
|
|
2423
2450
|
}
|
|
2424
2451
|
(async () => {
|
|
2425
|
-
if (r.e2e && await S.openFrame(l), r.apply(l), l.type === "message" && l.message.senderId !== t && !l.message.internal && (U(),
|
|
2452
|
+
if (r.e2e && await S.openFrame(l), r.apply(l), l.type === "message" && l.message.senderId !== t && !l.message.internal && (U(), A()), r.e2e && d && !M) {
|
|
2426
2453
|
M = !0;
|
|
2427
|
-
const
|
|
2428
|
-
b.send({ type: "uploadPrekeys", ...
|
|
2454
|
+
const h = await S.initX3DH();
|
|
2455
|
+
b.send({ type: "uploadPrekeys", ...h });
|
|
2429
2456
|
const y = await S.begin();
|
|
2430
2457
|
b.send({ type: "pubkey", conversationId: d, key: y });
|
|
2431
2458
|
}
|
|
@@ -2434,22 +2461,22 @@ ${y.join(`
|
|
|
2434
2461
|
}
|
|
2435
2462
|
}), b.connect(), L.render(r);
|
|
2436
2463
|
const j = s.launcher ? ve(s) : null, X = { close: () => {
|
|
2437
|
-
b.close(), u == null || u.remove(), L.destroy(), x && f && x.removeEventListener("change", f),
|
|
2464
|
+
b.close(), u == null || u.remove(), L.destroy(), x && f && x.removeEventListener("change", f), R.delete(s.el), j && Z.get(j) === X && Z.delete(j);
|
|
2438
2465
|
} };
|
|
2439
|
-
return
|
|
2466
|
+
return R.set(s.el, X), j && Z.set(j, X), X;
|
|
2440
2467
|
}
|
|
2441
2468
|
export {
|
|
2442
2469
|
Ct as ChatStore,
|
|
2443
2470
|
Et as ConnectionManager,
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2471
|
+
Ft as E2ESession,
|
|
2472
|
+
At as PersistentOutbox,
|
|
2473
|
+
Wt as Renderer,
|
|
2474
|
+
Gt as asConversationId,
|
|
2475
|
+
jt as extractX3DHInit,
|
|
2476
|
+
nn as httpBaseFromWsUrl,
|
|
2477
|
+
Qt as mount,
|
|
2478
|
+
Re as resolveRelayUrls,
|
|
2479
|
+
He as restoreHistory,
|
|
2480
|
+
Zt as unmount
|
|
2454
2481
|
};
|
|
2455
2482
|
//# sourceMappingURL=index.js.map
|