@ada-cx/messaging-bridge 1.3.0 → 1.3.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 +42 -3
- package/dist-npm/contract/state-keys.d.ts +1 -0
- package/dist-npm/contract/types.d.ts +4 -0
- package/dist-npm/{loader-CfCnvaTU.js → loader-BjjKuT42.js} +115 -18
- package/dist-npm/loader-BjjKuT42.js.map +1 -0
- package/dist-npm/npm/index.d.ts +1 -1
- package/dist-npm/npm/index.js +2 -2
- package/dist-npm/npm/loader.d.ts +9 -3
- package/dist-npm/npm/react.d.ts +1 -1
- package/dist-npm/npm/react.js +2 -2
- package/dist-npm/npm/testing.js +503 -474
- package/dist-npm/npm/testing.js.map +1 -1
- package/dist-npm/shared-utils/file-upload.d.ts +7 -1
- package/package.json +1 -1
- package/dist-npm/loader-CfCnvaTU.js.map +0 -1
package/dist-npm/npm/testing.js
CHANGED
|
@@ -1,482 +1,511 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region ../../shared/utils/src/browser-polyfills.ts
|
|
2
|
+
var e = Object.prototype.hasOwnProperty;
|
|
3
|
+
function t(e, t, n) {
|
|
4
|
+
Object.defineProperty(e, t, {
|
|
5
|
+
value: n,
|
|
6
|
+
configurable: !0,
|
|
7
|
+
writable: !0
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
Object.hasOwn || t(Object, "hasOwn", (t, n) => {
|
|
11
|
+
if (t == null) throw TypeError("ada browser-polyfills: Cannot convert undefined or null to object");
|
|
12
|
+
return e.call(Object(t), n);
|
|
13
|
+
});
|
|
14
|
+
function n(e) {
|
|
15
|
+
let t = Math.trunc(Number(this.length)) || 0, n = Math.trunc(Number(e)) || 0;
|
|
16
|
+
return n < 0 && (n += t), n < 0 || n >= t ? void 0 : this[n];
|
|
17
|
+
}
|
|
18
|
+
function r(e) {
|
|
19
|
+
let t = String(this), n = t.length, r = Math.trunc(Number(e)) || 0;
|
|
20
|
+
return r < 0 && (r += n), r < 0 || r >= n ? void 0 : t.charAt(r);
|
|
21
|
+
}
|
|
22
|
+
var i = [
|
|
23
|
+
globalThis.Int8Array,
|
|
24
|
+
globalThis.Uint8Array,
|
|
25
|
+
globalThis.Uint8ClampedArray,
|
|
26
|
+
globalThis.Int16Array,
|
|
27
|
+
globalThis.Uint16Array,
|
|
28
|
+
globalThis.Int32Array,
|
|
29
|
+
globalThis.Uint32Array,
|
|
30
|
+
globalThis.Float32Array,
|
|
31
|
+
globalThis.Float64Array,
|
|
32
|
+
globalThis.BigInt64Array,
|
|
33
|
+
globalThis.BigUint64Array
|
|
34
|
+
].filter(Boolean);
|
|
35
|
+
Array.prototype.at || t(Array.prototype, "at", n), String.prototype.at || t(String.prototype, "at", r);
|
|
36
|
+
for (let e of i) {
|
|
37
|
+
let r = e.prototype;
|
|
38
|
+
r.at || t(r, "at", n);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/contract/operations.ts
|
|
42
|
+
var a = 400, o = 5e3, s = class extends Error {
|
|
43
|
+
constructor(e = "The bridge client was destroyed.") {
|
|
44
|
+
super(e), this.name = "BridgeClientDestroyedError";
|
|
45
|
+
}
|
|
46
|
+
static is(e) {
|
|
47
|
+
return e instanceof Error && e.name === "BridgeClientDestroyedError";
|
|
48
|
+
}
|
|
8
49
|
};
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
50
|
+
function c() {
|
|
51
|
+
let e = typeof crypto > "u" ? void 0 : crypto;
|
|
52
|
+
if (typeof e?.randomUUID == "function") return e.randomUUID();
|
|
53
|
+
let t = new Uint8Array(16);
|
|
54
|
+
if (typeof e?.getRandomValues == "function") e.getRandomValues(t);
|
|
55
|
+
else for (let e = 0; e < t.length; e += 1) t[e] = Math.floor(Math.random() * 256);
|
|
56
|
+
t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
|
|
57
|
+
let n = Array.from(t, (e) => e.toString(16).padStart(2, "0"));
|
|
58
|
+
return `${n.slice(0, 4).join("")}-${n.slice(4, 6).join("")}-${n.slice(6, 8).join("")}-${n.slice(8, 10).join("")}-${n.slice(10).join("")}`;
|
|
18
59
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
60
|
+
function l(e, t, n, r) {
|
|
61
|
+
return new Promise((i, a) => {
|
|
62
|
+
if (t.isDisposed()) {
|
|
63
|
+
a(new s());
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let o = !1, c = null, l = null, u = (e) => {
|
|
67
|
+
d({ error: e });
|
|
68
|
+
}, d = (e) => {
|
|
69
|
+
o || (o = !0, t.unregister(u), c?.(), l !== null && clearTimeout(l), "value" in e ? i(e.value) : a(e.error));
|
|
70
|
+
}, f = () => {
|
|
71
|
+
let t = n(e.getState());
|
|
72
|
+
t && d(t);
|
|
73
|
+
};
|
|
74
|
+
f(), !o && (t.register(u), c = e.subscribe(f), r?.timeoutMs !== void 0 && (l = setTimeout(() => {
|
|
75
|
+
d({ error: /* @__PURE__ */ Error(`Bridge operation timed out after ${r.timeoutMs}ms.`) });
|
|
76
|
+
}, r.timeoutMs)));
|
|
77
|
+
});
|
|
38
78
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
79
|
+
function u(e) {
|
|
80
|
+
function t(t, n, r) {
|
|
81
|
+
let i = r?.equals ?? Object.is, a = t(e.getState());
|
|
82
|
+
return r?.emitInitial === !0 && n(a, void 0), e.subscribe(() => {
|
|
83
|
+
let r = t(e.getState());
|
|
84
|
+
if (i(r, a)) return;
|
|
85
|
+
let o = a;
|
|
86
|
+
a = r, n(r, o);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function n(e, n, r) {
|
|
90
|
+
return t((t) => t?.[e], n, r);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
subscribeKey: n,
|
|
94
|
+
select: t
|
|
95
|
+
};
|
|
57
96
|
}
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return {
|
|
405
|
-
operations: D,
|
|
406
|
-
dispose() {
|
|
407
|
-
if (!s) {
|
|
408
|
-
s = !0, C(), S?.(), S = null;
|
|
409
|
-
for (const e of [...i]) e(new B());
|
|
410
|
-
i.clear();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
};
|
|
97
|
+
function d(e) {
|
|
98
|
+
let t = !1, n = {
|
|
99
|
+
getState: () => e.getState(),
|
|
100
|
+
subscribe: (n) => t ? () => {} : e.subscribe(n),
|
|
101
|
+
sendEvent: (n, ...r) => {
|
|
102
|
+
t || e.sendEvent(n, ...r);
|
|
103
|
+
}
|
|
104
|
+
}, r = /* @__PURE__ */ new Set(), i = {
|
|
105
|
+
isDisposed: () => t,
|
|
106
|
+
register: (e) => {
|
|
107
|
+
r.add(e);
|
|
108
|
+
},
|
|
109
|
+
unregister: (e) => {
|
|
110
|
+
r.delete(e);
|
|
111
|
+
}
|
|
112
|
+
}, u = "", d = "", f = null, p = null, m = null;
|
|
113
|
+
function h() {
|
|
114
|
+
u = "", d = "", f !== null && (clearTimeout(f), f = null);
|
|
115
|
+
}
|
|
116
|
+
function g() {
|
|
117
|
+
if (m) return;
|
|
118
|
+
let e = n.getState()?.["chat.conversationId"] ?? null;
|
|
119
|
+
m = n.subscribe(() => {
|
|
120
|
+
let t = n.getState()?.["chat.conversationId"] ?? null;
|
|
121
|
+
t !== e && (e = t, h(), p = t);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function _() {
|
|
125
|
+
f === null && (f = setTimeout(() => {
|
|
126
|
+
f = null, u > d && (d = u, n.sendEvent("chat.messages.read", {
|
|
127
|
+
cursor: u,
|
|
128
|
+
...p ? { conversationId: p } : {}
|
|
129
|
+
}));
|
|
130
|
+
}, a));
|
|
131
|
+
}
|
|
132
|
+
let v = 0, y = {
|
|
133
|
+
sendMessage(e, t) {
|
|
134
|
+
let r = typeof e == "string" ? e.trim() : "", a = t?.secret === !0, o = c(), s = null, u = null;
|
|
135
|
+
if (r) {
|
|
136
|
+
let e = n.getState();
|
|
137
|
+
s = e?.["chat.error"] ?? null, u = e?.["chat.error.seq"] ?? null, n.sendEvent("chat.message.send", {
|
|
138
|
+
body: r,
|
|
139
|
+
messageType: a ? "secret" : "text",
|
|
140
|
+
tempMessageUuid: o
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
tempMessageUuid: o,
|
|
145
|
+
settled(e) {
|
|
146
|
+
return r ? a ? l(n, i, () => void 0, e) : l(n, i, (e) => {
|
|
147
|
+
let t = (e?.["chat.messages"] ?? []).find((e) => e.clientKey === o);
|
|
148
|
+
if (t) return { value: t };
|
|
149
|
+
let n = e?.["chat.error"] ?? null;
|
|
150
|
+
if (e !== null && "chat.error.clientKey" in e) return n !== null && e["chat.error.clientKey"] === o ? { error: Error(n) } : void 0;
|
|
151
|
+
let r = e?.["chat.error.seq"];
|
|
152
|
+
if (typeof r == "number") {
|
|
153
|
+
if (u === null) {
|
|
154
|
+
u = r;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
return n !== null && r !== u ? { error: Error(n) } : void 0;
|
|
158
|
+
}
|
|
159
|
+
if (n === null) {
|
|
160
|
+
s = null;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (n !== s) return { error: Error(n) };
|
|
164
|
+
}, e) : Promise.reject(/* @__PURE__ */ Error("sendMessage requires a non-empty body."));
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
retryMessage(e) {
|
|
169
|
+
n.sendEvent("chat.message.retry", { message: {
|
|
170
|
+
id: e,
|
|
171
|
+
type: "text"
|
|
172
|
+
} });
|
|
173
|
+
},
|
|
174
|
+
canRetryMessage(e) {
|
|
175
|
+
let t = n.getState();
|
|
176
|
+
return e.type === "text" && e.isRetryable === !0 && t?.["zendesk.sdk.disconnected"] !== !0 && (e.conversationId == null || e.conversationId === (t?.["chat.conversationId"] ?? null));
|
|
177
|
+
},
|
|
178
|
+
selectQuickReply(e, t) {
|
|
179
|
+
n.sendEvent("chat.quickReply.select", {
|
|
180
|
+
label: e.label,
|
|
181
|
+
target: e.target,
|
|
182
|
+
buttonType: e.buttonType,
|
|
183
|
+
...e.value === void 0 ? {} : { value: e.value },
|
|
184
|
+
messageId: t
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
selectOption(e, t) {
|
|
188
|
+
n.sendEvent("chat.option.select", {
|
|
189
|
+
optionId: e.id,
|
|
190
|
+
optionLabel: e.label || e.id,
|
|
191
|
+
messageId: t
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
submitListSelection(e) {
|
|
195
|
+
let t = n.getState()?.["conversation.stateData.listSelection"];
|
|
196
|
+
t && n.sendEvent("chat.selectableList.submit", {
|
|
197
|
+
selectedIds: e,
|
|
198
|
+
dataId: t.dataId
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
cancelListSelection(e) {
|
|
202
|
+
let t = n.getState()?.["conversation.stateData.listSelection"];
|
|
203
|
+
t?.cancelCaptureResponseId && n.sendEvent("listSelection.cancel", {
|
|
204
|
+
cancelResponseId: t.cancelCaptureResponseId,
|
|
205
|
+
cancelLabel: e ?? t.cancelCaptureLabel,
|
|
206
|
+
dataId: t.dataId
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
submitCapture(e) {
|
|
210
|
+
let t = n.getState()?.["conversation.stateData.capture"];
|
|
211
|
+
if (!t) return { settled: () => Promise.reject(/* @__PURE__ */ Error("No capture field is active.")) };
|
|
212
|
+
let r = t.dataId, a = c();
|
|
213
|
+
n.sendEvent("capture.submit", {
|
|
214
|
+
value: e,
|
|
215
|
+
dataId: r,
|
|
216
|
+
submitId: a
|
|
217
|
+
});
|
|
218
|
+
let o = !1;
|
|
219
|
+
return { settled: (e) => l(n, i, (e) => {
|
|
220
|
+
let t = e?.["conversation.stateData.capture"] ?? null;
|
|
221
|
+
if (!t || t.dataId !== r) return { value: { ok: !0 } };
|
|
222
|
+
let n = t.lastSubmitFailure;
|
|
223
|
+
if (n && n.submitId === a) return { value: {
|
|
224
|
+
ok: !1,
|
|
225
|
+
message: n.message
|
|
226
|
+
} };
|
|
227
|
+
if (t.isSubmitting === !0) {
|
|
228
|
+
o = !0;
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (o) return t.validationErrorMessage ? { value: {
|
|
232
|
+
ok: !1,
|
|
233
|
+
message: t.validationErrorMessage
|
|
234
|
+
} } : { value: { ok: !0 } };
|
|
235
|
+
}, e) };
|
|
236
|
+
},
|
|
237
|
+
cancelCapture(e) {
|
|
238
|
+
let t = n.getState()?.["conversation.stateData.capture"];
|
|
239
|
+
t?.cancelCaptureResponseId && n.sendEvent("capture.cancel", {
|
|
240
|
+
cancelResponseId: t.cancelCaptureResponseId,
|
|
241
|
+
cancelLabel: e ?? t.cancelCaptureLabel,
|
|
242
|
+
dataId: t.dataId
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
addReaction(e, t) {
|
|
246
|
+
n.sendEvent("chat.message.reaction.add", {
|
|
247
|
+
messageId: e,
|
|
248
|
+
reaction: t
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
reportLinkClick(e, t) {
|
|
252
|
+
n.sendEvent("chat.link.click", {
|
|
253
|
+
messageId: e,
|
|
254
|
+
...t?.navigateInHost === void 0 ? {} : { navigateInHost: t.navigateInHost }
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
markRead(e, t) {
|
|
258
|
+
if (typeof e != "string" || e === "") return;
|
|
259
|
+
g();
|
|
260
|
+
let r = t?.conversationId ?? n.getState()?.["chat.conversationId"] ?? null;
|
|
261
|
+
r !== p && (h(), p = r), e > u && (u = e, _());
|
|
262
|
+
},
|
|
263
|
+
loadOlderMessages() {
|
|
264
|
+
let e = n.getState();
|
|
265
|
+
e?.["chat.canLoadMore"] !== !0 || e["chat.loadingPreviousMessages"] === !0 || n.sendEvent("chat.logs.loadMore");
|
|
266
|
+
},
|
|
267
|
+
onHistoryLoaded(e) {
|
|
268
|
+
let t = n.getState()?.["chat.recentMessagesLoadSeq"] ?? 0;
|
|
269
|
+
return n.subscribe(() => {
|
|
270
|
+
let r = n.getState()?.["chat.recentMessagesLoadSeq"] ?? 0;
|
|
271
|
+
r > t ? (t = r, e(r)) : r < t && (t = r);
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
submitCsat(e, t) {
|
|
275
|
+
let { surveyType: r, partial: a, conversationId: o } = t, s = n.getState()?.["csat.submitSuccess.seq"] ?? 0, c = n.getState()?.["csat.submitError"] ?? null, u = n.getState()?.["csat.submitError.seq"] ?? null;
|
|
276
|
+
n.sendEvent("csat.submit", {
|
|
277
|
+
data: e,
|
|
278
|
+
surveyType: r,
|
|
279
|
+
...a === void 0 ? {} : { partial: a },
|
|
280
|
+
...o == null ? {} : { conversationId: o }
|
|
281
|
+
});
|
|
282
|
+
let d = (e) => o == null || (e ?? null) === o;
|
|
283
|
+
return { settled: (e) => l(n, i, (e) => {
|
|
284
|
+
if ((e?.["csat.submitSuccess.seq"] ?? 0) > s && e?.["csat.submitSuccess.surveyType"] === r && d(e?.["csat.submitSuccess.conversationId"])) return { value: { ok: !0 } };
|
|
285
|
+
let t = e?.["csat.submitError"] ?? null, n = e?.["csat.submitError.seq"];
|
|
286
|
+
if (typeof n == "number") {
|
|
287
|
+
if (u === null) {
|
|
288
|
+
u = n;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
return t !== null && n !== u && e?.["csat.submitErrorSurveyType"] === r && d(e?.["csat.submitErrorConversationId"]) ? { value: {
|
|
292
|
+
ok: !1,
|
|
293
|
+
message: t
|
|
294
|
+
} } : void 0;
|
|
295
|
+
}
|
|
296
|
+
if (t === null) {
|
|
297
|
+
c = null;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (t !== c && e?.["csat.submitErrorSurveyType"] === r && d(e?.["csat.submitErrorConversationId"])) return { value: {
|
|
301
|
+
ok: !1,
|
|
302
|
+
message: t
|
|
303
|
+
} };
|
|
304
|
+
}, e) };
|
|
305
|
+
},
|
|
306
|
+
trackCsatShown(e, t) {
|
|
307
|
+
n.sendEvent("csat.shown", {
|
|
308
|
+
surveyType: e,
|
|
309
|
+
...t == null ? {} : { conversationId: t }
|
|
310
|
+
});
|
|
311
|
+
},
|
|
312
|
+
checkEndChatEligibility(e) {
|
|
313
|
+
let t = n.getState()?.["csat.endChatEligibility.seq"] ?? 0;
|
|
314
|
+
return n.sendEvent("csat.checkEndChatEligibility"), l(n, i, (e) => {
|
|
315
|
+
if (!((e?.["csat.endChatEligibility.seq"] ?? 0) <= t)) return { value: {
|
|
316
|
+
eligible: e?.["csat.endChatEligible"] ?? null,
|
|
317
|
+
surveyTarget: e?.["csat.endChatSurveyTarget"] ?? null
|
|
318
|
+
} };
|
|
319
|
+
}, e);
|
|
320
|
+
},
|
|
321
|
+
skipCsatAndEndChat() {
|
|
322
|
+
n.sendEvent("endChat.skipCsat");
|
|
323
|
+
},
|
|
324
|
+
endLiveChat() {
|
|
325
|
+
n.sendEvent("endChat.endLiveChat");
|
|
326
|
+
},
|
|
327
|
+
startNewConversation(e) {
|
|
328
|
+
if (n.getState()?.["app.conversationStartPending"] === !0) return !1;
|
|
329
|
+
let t = Date.now();
|
|
330
|
+
return t < v ? !1 : (v = t + (e?.cooldownMs ?? o), n.sendEvent("app.startNewConversation"), !0);
|
|
331
|
+
},
|
|
332
|
+
resetApp() {
|
|
333
|
+
n.sendEvent("app.reset");
|
|
334
|
+
},
|
|
335
|
+
notifyComposerChanged(e) {
|
|
336
|
+
e?.secret === !0 || n.getState()?.["ui.secretMessage.isOpen"] === !0 || n.sendEvent("ui.composer.textChanged");
|
|
337
|
+
},
|
|
338
|
+
toggleSecretMessage(e) {
|
|
339
|
+
n.sendEvent("ui.secretMessage.toggle", { open: e });
|
|
340
|
+
},
|
|
341
|
+
startFileUpload(e) {
|
|
342
|
+
let t = c();
|
|
343
|
+
return n.sendEvent("file.upload.start", {
|
|
344
|
+
file: e,
|
|
345
|
+
uploadId: t
|
|
346
|
+
}), {
|
|
347
|
+
uploadId: t,
|
|
348
|
+
retry() {
|
|
349
|
+
n.sendEvent("file.upload.retry", {
|
|
350
|
+
file: e,
|
|
351
|
+
uploadId: t
|
|
352
|
+
});
|
|
353
|
+
},
|
|
354
|
+
dismissError() {
|
|
355
|
+
n.sendEvent("file.upload.errorDismiss");
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
},
|
|
359
|
+
setLanguage(e) {
|
|
360
|
+
n.sendEvent("settings.language.change", { language: e });
|
|
361
|
+
},
|
|
362
|
+
emailTranscript(e, t) {
|
|
363
|
+
let r = typeof e == "string" ? e.trim() : "";
|
|
364
|
+
return r ? (n.sendEvent("settings.transcript.email.send", { email: r }), b("transcript.email.status", t, r)) : Promise.reject(/* @__PURE__ */ Error("emailTranscript requires a non-empty email."));
|
|
365
|
+
},
|
|
366
|
+
downloadTranscript(e) {
|
|
367
|
+
return n.sendEvent("settings.transcript.download.request"), b("transcript.download.status", e);
|
|
368
|
+
},
|
|
369
|
+
setAlertSound(e) {
|
|
370
|
+
n.sendEvent("settings.alertSound.toggle", { enabled: e });
|
|
371
|
+
},
|
|
372
|
+
requestNotificationPermission() {
|
|
373
|
+
n.sendEvent("settings.notifications.requestPermission");
|
|
374
|
+
},
|
|
375
|
+
setTheme(e) {
|
|
376
|
+
n.sendEvent("appearance.setTheme", { theme: e });
|
|
377
|
+
},
|
|
378
|
+
setTextSize(e) {
|
|
379
|
+
n.sendEvent("appearance.setTextSize", { textSize: e });
|
|
380
|
+
},
|
|
381
|
+
close() {
|
|
382
|
+
n.sendEvent("ui.closeButton.click");
|
|
383
|
+
},
|
|
384
|
+
minimize() {
|
|
385
|
+
n.sendEvent("ui.minimizeButton.click");
|
|
386
|
+
},
|
|
387
|
+
dismissToast() {
|
|
388
|
+
n.sendEvent("ui.toast.dismiss");
|
|
389
|
+
},
|
|
390
|
+
dismissError() {
|
|
391
|
+
n.sendEvent("chat.error.dismiss");
|
|
392
|
+
},
|
|
393
|
+
setHostViewportExpanded(e) {
|
|
394
|
+
n.sendEvent("ui.hostViewport.set", { expanded: e });
|
|
395
|
+
},
|
|
396
|
+
retryAfterOutage() {
|
|
397
|
+
n.sendEvent("outage.retry");
|
|
398
|
+
},
|
|
399
|
+
reportAppError(e, t) {
|
|
400
|
+
let r = e instanceof Error ? e : null;
|
|
401
|
+
n.sendEvent("app.error.report", {
|
|
402
|
+
message: r?.message ?? String(e),
|
|
403
|
+
stack: r?.stack ?? "",
|
|
404
|
+
componentStack: t ?? ""
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
function b(e, t, r) {
|
|
409
|
+
let a = `${e}.seq`, o = n.getState()?.[e] ?? "idle", s = n.getState()?.[a] ?? null, c = n.getState()?.["transcript.email.conflict.seq"] ?? null;
|
|
410
|
+
return l(n, i, (t) => {
|
|
411
|
+
if (r !== void 0) {
|
|
412
|
+
let e = t?.["transcript.email.conflict.seq"];
|
|
413
|
+
if (typeof e == "number") {
|
|
414
|
+
if (c === null) c = e;
|
|
415
|
+
else if (e !== c && t?.["transcript.email.conflict.email"] === r) return { error: /* @__PURE__ */ Error("emailTranscript was rejected: a request for a different address is already in flight. The in-flight email still completes with its own outcome.") };
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
let n = t?.[e] ?? "idle", i = t?.[a];
|
|
419
|
+
if (typeof i == "number") {
|
|
420
|
+
if (s === null) {
|
|
421
|
+
s = i;
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
return i === s ? void 0 : n === "success" ? { value: void 0 } : n === "error" ? { error: /* @__PURE__ */ Error(`${e} reported an error.`) } : void 0;
|
|
425
|
+
}
|
|
426
|
+
let l = o;
|
|
427
|
+
if (o = n, l === "pending") {
|
|
428
|
+
if (n === "success") return { value: void 0 };
|
|
429
|
+
if (n === "error") return { error: /* @__PURE__ */ Error(`${e} reported an error.`) };
|
|
430
|
+
}
|
|
431
|
+
}, t);
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
operations: y,
|
|
435
|
+
dispose() {
|
|
436
|
+
if (!t) {
|
|
437
|
+
t = !0, h(), m?.(), m = null;
|
|
438
|
+
for (let e of [...r]) e(new s());
|
|
439
|
+
r.clear();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
};
|
|
414
443
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/npm/testing.ts
|
|
446
|
+
function f(e = null) {
|
|
447
|
+
let t = e, n = !1, r = /* @__PURE__ */ new Set(), i = [];
|
|
448
|
+
function a() {
|
|
449
|
+
for (let e of [...r]) try {
|
|
450
|
+
e();
|
|
451
|
+
} catch (e) {
|
|
452
|
+
console.error("[AdaMessaging] Bridge subscriber threw:", e);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function o() {
|
|
456
|
+
return t;
|
|
457
|
+
}
|
|
458
|
+
function s(e) {
|
|
459
|
+
return r.add(e), () => {
|
|
460
|
+
r.delete(e);
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function c(e, ...t) {
|
|
464
|
+
n || i.push({
|
|
465
|
+
event: e,
|
|
466
|
+
payload: t[0]
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
let l = {
|
|
470
|
+
getState: o,
|
|
471
|
+
subscribe: s,
|
|
472
|
+
sendEvent: c
|
|
473
|
+
}, f = u(l), p = d(l);
|
|
474
|
+
return {
|
|
475
|
+
getState: o,
|
|
476
|
+
subscribe: s,
|
|
477
|
+
sendEvent: c,
|
|
478
|
+
subscribeKey: f.subscribeKey,
|
|
479
|
+
select: f.select,
|
|
480
|
+
operations: p.operations,
|
|
481
|
+
destroy() {
|
|
482
|
+
n = !0, p.dispose(), t = null, r.clear();
|
|
483
|
+
},
|
|
484
|
+
setState(e) {
|
|
485
|
+
t = e, a();
|
|
486
|
+
},
|
|
487
|
+
updateState(e) {
|
|
488
|
+
t = {
|
|
489
|
+
"chat.error.clientKey": null,
|
|
490
|
+
...t ?? {},
|
|
491
|
+
...e
|
|
492
|
+
}, a();
|
|
493
|
+
},
|
|
494
|
+
get sentEvents() {
|
|
495
|
+
return [...i];
|
|
496
|
+
},
|
|
497
|
+
clearSentEvents() {
|
|
498
|
+
i.length = 0;
|
|
499
|
+
},
|
|
500
|
+
get subscriberCount() {
|
|
501
|
+
return r.size;
|
|
502
|
+
},
|
|
503
|
+
get destroyed() {
|
|
504
|
+
return n;
|
|
505
|
+
}
|
|
506
|
+
};
|
|
477
507
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
};
|
|
508
|
+
//#endregion
|
|
509
|
+
export { f as createMockBridgeClient };
|
|
481
510
|
|
|
482
511
|
//# sourceMappingURL=testing.js.map
|