@flowengage/react-chatbot 2.0.1 → 2.0.2
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/flowengage-embed.js +11 -11
- package/dist/flowengage-react-chatbot.cjs +10 -10
- package/dist/flowengage-react-chatbot.mjs +666 -398
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
17
17
|
}, T = (e) => x.call(e, "module.exports") ? e["module.exports"] : w(v({}, "__esModule", { value: !0 }), e), ee = (e) => {
|
|
18
18
|
if (!e || typeof e != "object") throw Error("FlowEngage config is required");
|
|
19
19
|
if (!e.siteId || typeof e.siteId != "string") throw Error("[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId=\"your-site-id\" /> or config={{ siteId: 'your-site-id' }}.");
|
|
20
|
-
let t = (e.apiBaseUrl || "https://be-flowengage.oslabs.app").replace(/\/+$/, "");
|
|
20
|
+
let t = (e.apiBaseUrl || "https://be-flowengage-stage.oslabs.app").replace(/\/+$/, "");
|
|
21
21
|
return {
|
|
22
22
|
siteId: e.siteId.trim(),
|
|
23
23
|
apiBaseUrl: t
|
|
@@ -286,6 +286,12 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
286
286
|
})
|
|
287
287
|
});
|
|
288
288
|
},
|
|
289
|
+
async getVisitorChatHistory() {
|
|
290
|
+
return i("/api/visitors/my-chats", { method: "GET" });
|
|
291
|
+
},
|
|
292
|
+
async getVisitorChatThread(e) {
|
|
293
|
+
return i(`/api/visitors/my-chats/${e}`, { method: "GET" });
|
|
294
|
+
},
|
|
289
295
|
async acceptCall(e, t) {
|
|
290
296
|
return i(`/api/calls/${e}/accept`, {
|
|
291
297
|
method: "POST",
|
|
@@ -356,82 +362,82 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
356
362
|
return navigator.sendBeacon(`${e}/api/ai/voice/sync`, o);
|
|
357
363
|
}
|
|
358
364
|
};
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
var
|
|
362
|
-
Object.keys(
|
|
363
|
-
|
|
365
|
+
}, D = Object.create(null);
|
|
366
|
+
D.open = "0", D.close = "1", D.ping = "2", D.pong = "3", D.message = "4", D.upgrade = "5", D.noop = "6";
|
|
367
|
+
var Oe = Object.create(null);
|
|
368
|
+
Object.keys(D).forEach((e) => {
|
|
369
|
+
Oe[D[e]] = e;
|
|
364
370
|
});
|
|
365
|
-
var
|
|
371
|
+
var ke = {
|
|
366
372
|
type: "error",
|
|
367
373
|
data: "parser error"
|
|
368
|
-
},
|
|
374
|
+
}, Ae = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", je = typeof ArrayBuffer == "function", Me = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Ne = ({ type: e, data: t }, n, r) => Ae && t instanceof Blob ? n ? r(t) : Pe(t, r) : je && (t instanceof ArrayBuffer || Me(t)) ? n ? r(t) : Pe(new Blob([t]), r) : r(D[e] + (t || "")), Pe = (e, t) => {
|
|
369
375
|
let n = new FileReader();
|
|
370
376
|
return n.onload = function() {
|
|
371
377
|
let e = n.result.split(",")[1];
|
|
372
378
|
t("b" + (e || ""));
|
|
373
379
|
}, n.readAsDataURL(e);
|
|
374
380
|
};
|
|
375
|
-
function
|
|
381
|
+
function Fe(e) {
|
|
376
382
|
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
377
383
|
}
|
|
378
|
-
var
|
|
379
|
-
function
|
|
380
|
-
if (
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
+
var Ie;
|
|
385
|
+
function Le(e, t) {
|
|
386
|
+
if (Ae && e.data instanceof Blob) return e.data.arrayBuffer().then(Fe).then(t);
|
|
387
|
+
if (je && (e.data instanceof ArrayBuffer || Me(e.data))) return t(Fe(e.data));
|
|
388
|
+
Ne(e, !1, (e) => {
|
|
389
|
+
Ie ||= new TextEncoder(), t(Ie.encode(e));
|
|
384
390
|
});
|
|
385
391
|
}
|
|
386
392
|
//#endregion
|
|
387
393
|
//#region node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
|
|
388
|
-
var
|
|
389
|
-
for (let e = 0; e < 64; e++)
|
|
390
|
-
var
|
|
394
|
+
var Re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ze = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
395
|
+
for (let e = 0; e < 64; e++) ze[Re.charCodeAt(e)] = e;
|
|
396
|
+
var O = (e) => {
|
|
391
397
|
let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
|
|
392
398
|
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
393
399
|
let l = new ArrayBuffer(t), u = new Uint8Array(l);
|
|
394
|
-
for (r = 0; r < n; r += 4) a =
|
|
400
|
+
for (r = 0; r < n; r += 4) a = ze[e.charCodeAt(r)], o = ze[e.charCodeAt(r + 1)], s = ze[e.charCodeAt(r + 2)], c = ze[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
|
|
395
401
|
return l;
|
|
396
|
-
},
|
|
402
|
+
}, Be = typeof ArrayBuffer == "function", Ve = (e, t) => {
|
|
397
403
|
if (typeof e != "string") return {
|
|
398
404
|
type: "message",
|
|
399
|
-
data:
|
|
405
|
+
data: Ue(e, t)
|
|
400
406
|
};
|
|
401
407
|
let n = e.charAt(0);
|
|
402
408
|
return n === "b" ? {
|
|
403
409
|
type: "message",
|
|
404
|
-
data:
|
|
405
|
-
} :
|
|
406
|
-
type:
|
|
410
|
+
data: He(e.substring(1), t)
|
|
411
|
+
} : Oe[n] ? e.length > 1 ? {
|
|
412
|
+
type: Oe[n],
|
|
407
413
|
data: e.substring(1)
|
|
408
|
-
} : { type:
|
|
409
|
-
},
|
|
414
|
+
} : { type: Oe[n] } : ke;
|
|
415
|
+
}, He = (e, t) => Be ? Ue(O(e), t) : {
|
|
410
416
|
base64: !0,
|
|
411
417
|
data: e
|
|
412
|
-
},
|
|
418
|
+
}, Ue = (e, t) => {
|
|
413
419
|
switch (t) {
|
|
414
420
|
case "blob": return e instanceof Blob ? e : new Blob([e]);
|
|
415
421
|
default: return e instanceof ArrayBuffer ? e : e.buffer;
|
|
416
422
|
}
|
|
417
|
-
},
|
|
423
|
+
}, We = "", Ge = (e, t) => {
|
|
418
424
|
let n = e.length, r = Array(n), i = 0;
|
|
419
425
|
e.forEach((e, a) => {
|
|
420
|
-
|
|
421
|
-
r[a] = e, ++i === n && t(r.join(
|
|
426
|
+
Ne(e, !1, (e) => {
|
|
427
|
+
r[a] = e, ++i === n && t(r.join(We));
|
|
422
428
|
});
|
|
423
429
|
});
|
|
424
|
-
},
|
|
425
|
-
let n = e.split(
|
|
430
|
+
}, Ke = (e, t) => {
|
|
431
|
+
let n = e.split(We), r = [];
|
|
426
432
|
for (let e = 0; e < n.length; e++) {
|
|
427
|
-
let i =
|
|
433
|
+
let i = Ve(n[e], t);
|
|
428
434
|
if (r.push(i), i.type === "error") break;
|
|
429
435
|
}
|
|
430
436
|
return r;
|
|
431
437
|
};
|
|
432
|
-
function
|
|
438
|
+
function qe() {
|
|
433
439
|
return new TransformStream({ transform(e, t) {
|
|
434
|
-
|
|
440
|
+
Le(e, (n) => {
|
|
435
441
|
let r = n.length, i;
|
|
436
442
|
if (r < 126) i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
|
|
437
443
|
else if (r < 65536) {
|
|
@@ -447,44 +453,44 @@ function Je() {
|
|
|
447
453
|
});
|
|
448
454
|
} });
|
|
449
455
|
}
|
|
450
|
-
var
|
|
451
|
-
function
|
|
456
|
+
var Je;
|
|
457
|
+
function Ye(e) {
|
|
452
458
|
return e.reduce((e, t) => e + t.length, 0);
|
|
453
459
|
}
|
|
454
|
-
function
|
|
460
|
+
function Xe(e, t) {
|
|
455
461
|
if (e[0].length === t) return e.shift();
|
|
456
462
|
let n = new Uint8Array(t), r = 0;
|
|
457
463
|
for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
|
|
458
464
|
return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
|
|
459
465
|
}
|
|
460
466
|
function Ze(e, t) {
|
|
461
|
-
|
|
467
|
+
Je ||= new TextDecoder();
|
|
462
468
|
let n = [], r = 0, i = -1, a = !1;
|
|
463
469
|
return new TransformStream({ transform(o, s) {
|
|
464
470
|
for (n.push(o);;) {
|
|
465
471
|
if (r === 0) {
|
|
466
|
-
if (
|
|
467
|
-
let e =
|
|
472
|
+
if (Ye(n) < 1) break;
|
|
473
|
+
let e = Xe(n, 1);
|
|
468
474
|
a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
|
|
469
475
|
} else if (r === 1) {
|
|
470
|
-
if (
|
|
471
|
-
let e =
|
|
476
|
+
if (Ye(n) < 2) break;
|
|
477
|
+
let e = Xe(n, 2);
|
|
472
478
|
i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
|
|
473
479
|
} else if (r === 2) {
|
|
474
|
-
if (
|
|
475
|
-
let e =
|
|
480
|
+
if (Ye(n) < 8) break;
|
|
481
|
+
let e = Xe(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
|
|
476
482
|
if (a > 2 ** 21 - 1) {
|
|
477
|
-
s.enqueue(
|
|
483
|
+
s.enqueue(ke);
|
|
478
484
|
break;
|
|
479
485
|
}
|
|
480
486
|
i = a * 2 ** 32 + t.getUint32(4), r = 3;
|
|
481
487
|
} else {
|
|
482
|
-
if (
|
|
483
|
-
let e =
|
|
484
|
-
s.enqueue(
|
|
488
|
+
if (Ye(n) < i) break;
|
|
489
|
+
let e = Xe(n, i);
|
|
490
|
+
s.enqueue(Ve(a ? e : Je.decode(e), t)), r = 0;
|
|
485
491
|
}
|
|
486
492
|
if (i === 0 || i > e) {
|
|
487
|
-
s.enqueue(
|
|
493
|
+
s.enqueue(ke);
|
|
488
494
|
break;
|
|
489
495
|
}
|
|
490
496
|
}
|
|
@@ -594,7 +600,7 @@ var ut = class extends Error {
|
|
|
594
600
|
this.readyState = "open", this.writable = !0, super.emitReserved("open");
|
|
595
601
|
}
|
|
596
602
|
onData(e) {
|
|
597
|
-
let t =
|
|
603
|
+
let t = Ve(e, this.socket.binaryType);
|
|
598
604
|
this.onPacket(t);
|
|
599
605
|
}
|
|
600
606
|
onPacket(e) {
|
|
@@ -646,7 +652,7 @@ var ut = class extends Error {
|
|
|
646
652
|
this._polling = !0, this.doPoll(), this.emitReserved("poll");
|
|
647
653
|
}
|
|
648
654
|
onData(e) {
|
|
649
|
-
|
|
655
|
+
Ke(e, this.socket.binaryType).forEach((e) => {
|
|
650
656
|
if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
|
|
651
657
|
this.onPacket(e);
|
|
652
658
|
}), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
@@ -658,7 +664,7 @@ var ut = class extends Error {
|
|
|
658
664
|
this.readyState === "open" ? e() : this.once("open", e);
|
|
659
665
|
}
|
|
660
666
|
write(e) {
|
|
661
|
-
this.writable = !1,
|
|
667
|
+
this.writable = !1, Ge(e, (e) => {
|
|
662
668
|
this.doWrite(e, () => {
|
|
663
669
|
this.writable = !0, this.emitReserved("drain");
|
|
664
670
|
});
|
|
@@ -814,7 +820,7 @@ var St = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
814
820
|
this.writable = !1;
|
|
815
821
|
for (let t = 0; t < e.length; t++) {
|
|
816
822
|
let n = e[t], r = t === e.length - 1;
|
|
817
|
-
|
|
823
|
+
Ne(n, this.supportsBinary, (e) => {
|
|
818
824
|
try {
|
|
819
825
|
this.doWrite(n, e);
|
|
820
826
|
} catch {}
|
|
@@ -856,7 +862,7 @@ var St = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
856
862
|
this.onError("webtransport error", e);
|
|
857
863
|
}), this._transport.ready.then(() => {
|
|
858
864
|
this._transport.createBidirectionalStream().then((e) => {
|
|
859
|
-
let t = Ze(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r =
|
|
865
|
+
let t = Ze(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = qe();
|
|
860
866
|
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
861
867
|
let i = () => {
|
|
862
868
|
n.read().then(({ done: e, value: t }) => {
|
|
@@ -2552,7 +2558,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2552
2558
|
let i = f(() => e ? {
|
|
2553
2559
|
...t || {},
|
|
2554
2560
|
siteId: e
|
|
2555
|
-
} : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ye().isOpen), [T, te] = m(ye().activeScreen), [ne, re] = m(ye().isHumanHandled), [E, se] = m(ye().agentName), [ce, fe] = m(ye().agentHeadshot), [pe, me] = m(() => xe(i?.siteId)), [he, Ce] = m(!1), [we,
|
|
2561
|
+
} : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ye().isOpen), [T, te] = m(ye().activeScreen), [ne, re] = m(ye().isHumanHandled), [E, se] = m(ye().agentName), [ce, fe] = m(ye().agentHeadshot), [pe, me] = m(() => xe(i?.siteId)), [he, Ce] = m(!1), [we, D] = m(!1), [Oe, ke] = m("idle"), [Ae, je] = m(!1), [Me, Ne] = m(!1), [Pe, Fe] = m(""), [Ie, Le] = m(!1), [Re, ze] = m(!1), [O, Be] = m(null), [Ve, He] = m(null), [Ue, We] = m("idle"), [Ge, Ke] = m(null), [qe, Je] = m(!1), [Ye, Xe] = m(""), Ze = p(!1), k = p(null), A = p(null), j = p(""), Qe = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), rt = p([]), it = p(null), at = p(null), ot = p(null), st = p(!1), ct = p(!1), lt = p(""), ut = p(E), dt = p([]), ft = p(!1), pt = p({
|
|
2556
2562
|
notifyRouteChange: () => {},
|
|
2557
2563
|
cleanup: () => {}
|
|
2558
2564
|
}), mt = o((e = {}) => {
|
|
@@ -2563,12 +2569,12 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2563
2569
|
return Number.isFinite(t) && t > 0 ? t : ae;
|
|
2564
2570
|
}, [i, _]);
|
|
2565
2571
|
c(() => {
|
|
2566
|
-
Qe.current =
|
|
2567
|
-
}, [
|
|
2572
|
+
Qe.current = O;
|
|
2573
|
+
}, [O]), c(() => {
|
|
2568
2574
|
ut.current = E;
|
|
2569
2575
|
}, [E]);
|
|
2570
2576
|
let gt = () => {
|
|
2571
|
-
|
|
2577
|
+
Xe("");
|
|
2572
2578
|
}, _t = o(() => {
|
|
2573
2579
|
ot.current &&= (window.clearTimeout(ot.current), null);
|
|
2574
2580
|
}, []), vt = (e) => {
|
|
@@ -2589,7 +2595,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2589
2595
|
hasLocalStream: !!et.current,
|
|
2590
2596
|
hasRemoteAudio: !!tt.current,
|
|
2591
2597
|
queuedIceCount: rt.current.length
|
|
2592
|
-
}), $e.current &&= ($e.current.close(), null), et.current &&= (et.current.getTracks().forEach((e) => e.stop()), null), tt.current &&= (tt.current.srcObject = null, tt.current.remove(), null), _t(), nt.current = null, rt.current = [], it.current = null, at.current = null, st.current = !1,
|
|
2598
|
+
}), $e.current &&= ($e.current.close(), null), et.current &&= (et.current.getTracks().forEach((e) => e.stop()), null), tt.current &&= (tt.current.srcObject = null, tt.current.remove(), null), _t(), nt.current = null, rt.current = [], it.current = null, at.current = null, st.current = !1, Je(!1), Be(null), He(null), We("idle"), Ke(null), console.log("[FlowEngageCall] cleanup:complete", {
|
|
2593
2599
|
reason: e,
|
|
2594
2600
|
chatId: j.current
|
|
2595
2601
|
});
|
|
@@ -2623,11 +2629,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2623
2629
|
isAcceptingHere: t,
|
|
2624
2630
|
isAlreadyActive: n,
|
|
2625
2631
|
isIncomingHere: r
|
|
2626
|
-
}), _t(),
|
|
2627
|
-
it.current = e.callId,
|
|
2632
|
+
}), _t(), Be(null), t || n) {
|
|
2633
|
+
it.current = e.callId, He(e.callId), We((e) => e === "connected" ? e : "connecting"), w(!0);
|
|
2628
2634
|
return;
|
|
2629
2635
|
}
|
|
2630
|
-
|
|
2636
|
+
We("idle");
|
|
2631
2637
|
}
|
|
2632
2638
|
}, St = (e = {}) => {
|
|
2633
2639
|
if (!e.callId) return;
|
|
@@ -2644,7 +2650,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2644
2650
|
yt();
|
|
2645
2651
|
return;
|
|
2646
2652
|
}
|
|
2647
|
-
at.current = null, nt.current = null, rt.current = [],
|
|
2653
|
+
at.current = null, nt.current = null, rt.current = [], Be(null), We("idle");
|
|
2648
2654
|
}
|
|
2649
2655
|
}, Ct = async (e = {}) => {
|
|
2650
2656
|
let t = $e.current, n = k.current, r = e.sdpOffer || e.offer?.sdp;
|
|
@@ -2756,19 +2762,19 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2756
2762
|
siteId: t.siteId
|
|
2757
2763
|
});
|
|
2758
2764
|
k.current = d, d.on("connect", () => {
|
|
2759
|
-
console.log("[FlowEngageProvider] socket connected"),
|
|
2765
|
+
console.log("[FlowEngageProvider] socket connected"), ke("connected");
|
|
2760
2766
|
}), d.on("disconnect", () => {
|
|
2761
|
-
console.log("[FlowEngageProvider] socket disconnected"),
|
|
2767
|
+
console.log("[FlowEngageProvider] socket disconnected"), ke("disconnected");
|
|
2762
2768
|
}), d.on("aiTyping", () => {
|
|
2763
|
-
console.log("[FlowEngageProvider] received aiTyping", { chatId: j.current }),
|
|
2769
|
+
console.log("[FlowEngageProvider] received aiTyping", { chatId: j.current }), D(!0);
|
|
2764
2770
|
}), d.on("ai:typing", () => {
|
|
2765
|
-
console.log("[FlowEngageProvider] received ai:typing", { chatId: j.current }),
|
|
2771
|
+
console.log("[FlowEngageProvider] received ai:typing", { chatId: j.current }), D(!0);
|
|
2766
2772
|
}), d.on("messageReceived", (e) => {
|
|
2767
2773
|
let t = e.message || e, n = {
|
|
2768
2774
|
...t,
|
|
2769
2775
|
message: Jn(t.message)
|
|
2770
2776
|
};
|
|
2771
|
-
|
|
2777
|
+
D(!1), Ce(!1), S((e) => [...e.filter((e) => !e.isPending), {
|
|
2772
2778
|
...n,
|
|
2773
2779
|
isPending: !1,
|
|
2774
2780
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -2786,7 +2792,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2786
2792
|
...t,
|
|
2787
2793
|
message: Jn(t.message)
|
|
2788
2794
|
};
|
|
2789
|
-
|
|
2795
|
+
D(!1), (n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && Ce(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
|
|
2790
2796
|
...n,
|
|
2791
2797
|
isPending: !1,
|
|
2792
2798
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -2834,7 +2840,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2834
2840
|
}));
|
|
2835
2841
|
};
|
|
2836
2842
|
d.on("agent:joined", f), d.on("agentJoined", f), d.on("agent:left", p), d.on("agentLeft", p), d.on("conversationEnded", (e) => {
|
|
2837
|
-
|
|
2843
|
+
ze(!0);
|
|
2838
2844
|
let t = e?.message || "This conversation has ended. Thank you for reaching out!";
|
|
2839
2845
|
S((e) => [...e, {
|
|
2840
2846
|
id: `conversation-ended-${Date.now()}`,
|
|
@@ -2845,9 +2851,9 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2845
2851
|
}]);
|
|
2846
2852
|
}), d.on("chat:history_update", (e) => {
|
|
2847
2853
|
let t = Yn(e.chat_history || []);
|
|
2848
|
-
S(t), t.length === 0 && (
|
|
2854
|
+
S(t), t.length === 0 && (ze(!1), re(!1), te("ai"), D(!1), Ce(!1));
|
|
2849
2855
|
}), d.on("conversation:reset", () => {
|
|
2850
|
-
S([]),
|
|
2856
|
+
S([]), ze(!1), re(!1), te("ai"), D(!1), Ce(!1);
|
|
2851
2857
|
}), d.on("typing:start", (e) => {
|
|
2852
2858
|
console.log("[FlowEngageProvider] received typing:start", {
|
|
2853
2859
|
chatId: e?.chatId || j.current,
|
|
@@ -2869,12 +2875,12 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2869
2875
|
callId: e.callId,
|
|
2870
2876
|
chatId: j.current,
|
|
2871
2877
|
agentName: t
|
|
2872
|
-
}), gt(), _t(), st.current = !1,
|
|
2878
|
+
}), gt(), _t(), st.current = !1, Be({
|
|
2873
2879
|
callId: e.callId,
|
|
2874
2880
|
from: e.from || "owner",
|
|
2875
2881
|
agentId: e.agentId || null,
|
|
2876
2882
|
agentName: t
|
|
2877
|
-
}), se((e) => $n([t, e], "Agent")),
|
|
2883
|
+
}), se((e) => $n([t, e], "Agent")), We("incoming"), Ke(null), w(!0);
|
|
2878
2884
|
}), d.on("call:offer", async (e = {}) => {
|
|
2879
2885
|
console.log("[FlowEngageProvider] received call:offer", {
|
|
2880
2886
|
callId: e.callId,
|
|
@@ -2965,24 +2971,24 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2965
2971
|
isPendingOfferHere: r,
|
|
2966
2972
|
isIncomingHere: i
|
|
2967
2973
|
}), !t && !n && !r) {
|
|
2968
|
-
i && (
|
|
2974
|
+
i && (Be(null), We("idle"));
|
|
2969
2975
|
return;
|
|
2970
2976
|
}
|
|
2971
|
-
st.current = !0, at.current = null, it.current = e.callId,
|
|
2977
|
+
st.current = !0, at.current = null, it.current = e.callId, He(e.callId), Be(null), We("connected"), Ke(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), w(!0);
|
|
2972
2978
|
}), d.on("call:unavailable", (e = {}) => {
|
|
2973
2979
|
console.warn("[FlowEngageCall] socket:event call:unavailable", {
|
|
2974
2980
|
chatId: e.chatId || j.current,
|
|
2975
2981
|
callId: e.callId,
|
|
2976
2982
|
reason: e.reason || e.message || null,
|
|
2977
2983
|
raw: e
|
|
2978
|
-
}), yt("socket:call_unavailable"),
|
|
2984
|
+
}), yt("socket:call_unavailable"), Xe(Xn(e, "This visitor is not available for a call right now.")), w(!0);
|
|
2979
2985
|
}), d.on("call:error", (e = {}) => {
|
|
2980
2986
|
console.error("[FlowEngageCall] socket:event call:error", {
|
|
2981
2987
|
chatId: e.chatId || j.current,
|
|
2982
2988
|
callId: e.callId,
|
|
2983
2989
|
reason: e.reason || e.message || null,
|
|
2984
2990
|
raw: e
|
|
2985
|
-
}), yt("socket:call_error"),
|
|
2991
|
+
}), yt("socket:call_error"), Xe(Xn(e, "We couldn't connect the call right now.")), w(!0);
|
|
2986
2992
|
}), d.on("visitor:navigate", async ({ url: e, section: t, highlight: n } = {}) => {
|
|
2987
2993
|
console.log("[FlowEngageProvider] visitor:navigate DISABLED — ignoring navigation to", e, {
|
|
2988
2994
|
section: t,
|
|
@@ -3020,11 +3026,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3020
3026
|
r,
|
|
3021
3027
|
a
|
|
3022
3028
|
]), c(() => () => {
|
|
3023
|
-
if (
|
|
3029
|
+
if (Ie && !ft.current && dt.current.length > 0) {
|
|
3024
3030
|
let e = j.current, t = dt.current, n = A.current;
|
|
3025
3031
|
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), ft.current = !0);
|
|
3026
3032
|
}
|
|
3027
|
-
}, [
|
|
3033
|
+
}, [Ie, _]), c(() => {
|
|
3028
3034
|
if (!A.current || !y || l !== "ready") return;
|
|
3029
3035
|
let e = window.setInterval(async () => {
|
|
3030
3036
|
try {
|
|
@@ -3039,9 +3045,9 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3039
3045
|
mt
|
|
3040
3046
|
]);
|
|
3041
3047
|
let wt = async () => {
|
|
3042
|
-
if (!(!
|
|
3043
|
-
gt(), at.current =
|
|
3044
|
-
callId:
|
|
3048
|
+
if (!(!O?.callId || !A.current || !k.current || !y)) {
|
|
3049
|
+
gt(), at.current = O.callId, _t(), console.log("[FlowEngageProvider] acceptCall started", {
|
|
3050
|
+
callId: O?.callId,
|
|
3045
3051
|
chatId: y,
|
|
3046
3052
|
socketConnected: !!k.current?.connected,
|
|
3047
3053
|
hasPendingOffer: !!nt.current
|
|
@@ -3049,7 +3055,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3049
3055
|
try {
|
|
3050
3056
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3051
3057
|
console.log("[FlowEngageProvider] microphone stream acquired", {
|
|
3052
|
-
callId:
|
|
3058
|
+
callId: O.callId,
|
|
3053
3059
|
chatId: y,
|
|
3054
3060
|
trackCount: e.getTracks().length
|
|
3055
3061
|
}), et.current = e;
|
|
@@ -3062,28 +3068,28 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3062
3068
|
}
|
|
3063
3069
|
let n = new RTCPeerConnection({ iceServers: t });
|
|
3064
3070
|
$e.current = n, console.log("[FlowEngageCall] peer-connection:created", {
|
|
3065
|
-
callId:
|
|
3071
|
+
callId: O.callId,
|
|
3066
3072
|
chatId: y,
|
|
3067
3073
|
iceServers: 1
|
|
3068
3074
|
}), n.onconnectionstatechange = () => {
|
|
3069
3075
|
let e = n.connectionState;
|
|
3070
3076
|
if (console.log("[FlowEngageProvider] peer connection state changed", {
|
|
3071
|
-
callId:
|
|
3077
|
+
callId: O.callId,
|
|
3072
3078
|
chatId: y,
|
|
3073
3079
|
connectionState: e,
|
|
3074
3080
|
iceConnectionState: n.iceConnectionState,
|
|
3075
3081
|
signalingState: n.signalingState
|
|
3076
3082
|
}), e === "connected") {
|
|
3077
3083
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3078
|
-
|
|
3084
|
+
We("connected"), Ke((t) => t || e), bt(e);
|
|
3079
3085
|
return;
|
|
3080
3086
|
}
|
|
3081
3087
|
if (e === "connecting") {
|
|
3082
|
-
|
|
3088
|
+
We((e) => e === "connected" ? e : "connecting");
|
|
3083
3089
|
return;
|
|
3084
3090
|
}
|
|
3085
3091
|
(e === "failed" || e === "disconnected" || e === "closed") && console.warn("[FlowEngageCall] peer-connection:terminal-state", {
|
|
3086
|
-
callId:
|
|
3092
|
+
callId: O.callId,
|
|
3087
3093
|
chatId: y,
|
|
3088
3094
|
connectionState: e,
|
|
3089
3095
|
iceConnectionState: n.iceConnectionState,
|
|
@@ -3092,22 +3098,22 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3092
3098
|
}, n.oniceconnectionstatechange = () => {
|
|
3093
3099
|
let e = n.iceConnectionState;
|
|
3094
3100
|
if (console.log("[FlowEngageProvider] ICE connection state changed", {
|
|
3095
|
-
callId:
|
|
3101
|
+
callId: O.callId,
|
|
3096
3102
|
chatId: y,
|
|
3097
3103
|
iceConnectionState: e,
|
|
3098
3104
|
connectionState: n.connectionState,
|
|
3099
3105
|
signalingState: n.signalingState
|
|
3100
3106
|
}), e === "connected" || e === "completed") {
|
|
3101
3107
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3102
|
-
|
|
3108
|
+
We("connected"), Ke((t) => t || e), bt(e);
|
|
3103
3109
|
return;
|
|
3104
3110
|
}
|
|
3105
3111
|
if (e === "checking" || e === "new") {
|
|
3106
|
-
|
|
3112
|
+
We((e) => e === "connected" ? e : "connecting");
|
|
3107
3113
|
return;
|
|
3108
3114
|
}
|
|
3109
3115
|
(e === "failed" || e === "disconnected" || e === "closed") && console.warn("[FlowEngageCall] ice-connection:terminal-state", {
|
|
3110
|
-
callId:
|
|
3116
|
+
callId: O.callId,
|
|
3111
3117
|
chatId: y,
|
|
3112
3118
|
iceConnectionState: e,
|
|
3113
3119
|
connectionState: n.connectionState,
|
|
@@ -3115,7 +3121,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3115
3121
|
});
|
|
3116
3122
|
}, n.onsignalingstatechange = () => {
|
|
3117
3123
|
console.log("[FlowEngageCall] signaling-state:changed", {
|
|
3118
|
-
callId:
|
|
3124
|
+
callId: O.callId,
|
|
3119
3125
|
chatId: y,
|
|
3120
3126
|
signalingState: n.signalingState,
|
|
3121
3127
|
connectionState: n.connectionState,
|
|
@@ -3123,13 +3129,13 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3123
3129
|
});
|
|
3124
3130
|
}, n.onicegatheringstatechange = () => {
|
|
3125
3131
|
console.log("[FlowEngageCall] ice-gathering-state:changed", {
|
|
3126
|
-
callId:
|
|
3132
|
+
callId: O.callId,
|
|
3127
3133
|
chatId: y,
|
|
3128
3134
|
iceGatheringState: n.iceGatheringState
|
|
3129
3135
|
});
|
|
3130
3136
|
}, e.getTracks().forEach((t) => {
|
|
3131
3137
|
console.log("[FlowEngageCall] local-track:added", {
|
|
3132
|
-
callId:
|
|
3138
|
+
callId: O.callId,
|
|
3133
3139
|
chatId: y,
|
|
3134
3140
|
kind: t.kind,
|
|
3135
3141
|
enabled: t.enabled,
|
|
@@ -3140,7 +3146,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3140
3146
|
}), n.onicecandidate = (e) => {
|
|
3141
3147
|
if (!e.candidate || !k.current?.connected) {
|
|
3142
3148
|
console.log("[FlowEngageProvider] local ICE candidate skipped", {
|
|
3143
|
-
callId:
|
|
3149
|
+
callId: O.callId,
|
|
3144
3150
|
chatId: y,
|
|
3145
3151
|
hasCandidate: !!e.candidate,
|
|
3146
3152
|
socketConnected: !!k.current?.connected
|
|
@@ -3149,11 +3155,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3149
3155
|
}
|
|
3150
3156
|
let t = e.candidate;
|
|
3151
3157
|
console.log("[FlowEngageProvider] emitting local ICE candidate", {
|
|
3152
|
-
callId:
|
|
3158
|
+
callId: O.callId,
|
|
3153
3159
|
chatId: y,
|
|
3154
3160
|
candidate: Qn(t)
|
|
3155
3161
|
}), k.current.emit("call:ice-candidate", {
|
|
3156
|
-
callId:
|
|
3162
|
+
callId: O.callId,
|
|
3157
3163
|
candidate: t.candidate,
|
|
3158
3164
|
sdpMid: t.sdpMid,
|
|
3159
3165
|
sdpMLineIndex: t.sdpMLineIndex,
|
|
@@ -3162,13 +3168,13 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3162
3168
|
});
|
|
3163
3169
|
}, n.ontrack = (e) => {
|
|
3164
3170
|
console.log("[FlowEngageProvider] remote audio track received", {
|
|
3165
|
-
callId:
|
|
3171
|
+
callId: O.callId,
|
|
3166
3172
|
chatId: y,
|
|
3167
3173
|
streamCount: e.streams?.length || 0
|
|
3168
3174
|
});
|
|
3169
3175
|
let [t] = e.streams || [], [n] = t?.getAudioTracks?.() || [];
|
|
3170
3176
|
if (console.log("[FlowEngageCall] remote-track:details", {
|
|
3171
|
-
callId:
|
|
3177
|
+
callId: O.callId,
|
|
3172
3178
|
chatId: y,
|
|
3173
3179
|
trackKind: e.track?.kind || null,
|
|
3174
3180
|
trackEnabled: e.track?.enabled ?? null,
|
|
@@ -3186,24 +3192,24 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3186
3192
|
let e = document.createElement("audio");
|
|
3187
3193
|
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {
|
|
3188
3194
|
console.log("[FlowEngageCall] remote-audio:onplay", {
|
|
3189
|
-
callId:
|
|
3195
|
+
callId: O.callId,
|
|
3190
3196
|
chatId: y
|
|
3191
3197
|
});
|
|
3192
3198
|
}, e.onpause = () => {
|
|
3193
3199
|
console.warn("[FlowEngageCall] remote-audio:onpause", {
|
|
3194
|
-
callId:
|
|
3200
|
+
callId: O.callId,
|
|
3195
3201
|
chatId: y,
|
|
3196
3202
|
currentTime: e.currentTime
|
|
3197
3203
|
});
|
|
3198
3204
|
}, e.onended = () => {
|
|
3199
3205
|
console.warn("[FlowEngageCall] remote-audio:onended", {
|
|
3200
|
-
callId:
|
|
3206
|
+
callId: O.callId,
|
|
3201
3207
|
chatId: y,
|
|
3202
3208
|
currentTime: e.currentTime
|
|
3203
3209
|
});
|
|
3204
3210
|
}, e.onerror = (t) => {
|
|
3205
3211
|
console.error("[FlowEngageCall] remote-audio:onerror", {
|
|
3206
|
-
callId:
|
|
3212
|
+
callId: O.callId,
|
|
3207
3213
|
chatId: y,
|
|
3208
3214
|
error: e.error ? {
|
|
3209
3215
|
code: e.error.code,
|
|
@@ -3214,16 +3220,16 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3214
3220
|
}, tt.current = e, document.body.appendChild(e);
|
|
3215
3221
|
}
|
|
3216
3222
|
tt.current.srcObject = e.streams[0];
|
|
3217
|
-
let r =
|
|
3223
|
+
let r = O?.callId, i = r && (at.current === r || it.current === r);
|
|
3218
3224
|
if (!st.current && i) {
|
|
3219
3225
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3220
|
-
|
|
3226
|
+
We("connected"), Ke((t) => t || e), it.current = r, He(r), bt(e);
|
|
3221
3227
|
}
|
|
3222
3228
|
tt.current.srcObject = t || null;
|
|
3223
3229
|
let a = tt.current.play?.();
|
|
3224
3230
|
a?.catch && a.catch((e) => {
|
|
3225
3231
|
console.error("[FlowEngageCall] remote-audio:play-failed", {
|
|
3226
|
-
callId:
|
|
3232
|
+
callId: O.callId,
|
|
3227
3233
|
chatId: y,
|
|
3228
3234
|
message: e?.message,
|
|
3229
3235
|
name: e?.name,
|
|
@@ -3233,72 +3239,72 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3233
3239
|
};
|
|
3234
3240
|
let r = nt.current;
|
|
3235
3241
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3236
|
-
callId: r.callId ||
|
|
3242
|
+
callId: r.callId || O.callId,
|
|
3237
3243
|
chatId: y
|
|
3238
3244
|
}), await Ct({
|
|
3239
3245
|
...r,
|
|
3240
|
-
callId: r.callId ||
|
|
3241
|
-
})), await A.current.acceptCall(
|
|
3242
|
-
callId:
|
|
3246
|
+
callId: r.callId || O.callId
|
|
3247
|
+
})), await A.current.acceptCall(O.callId, y), console.log("[FlowEngageProvider] acceptCall API succeeded", {
|
|
3248
|
+
callId: O.callId,
|
|
3243
3249
|
chatId: y
|
|
3244
|
-
}), it.current =
|
|
3250
|
+
}), it.current = O.callId, He(O.callId), We((e) => e === "connected" || st.current ? "connected" : "connecting"), Be(null), w(!0);
|
|
3245
3251
|
} catch (e) {
|
|
3246
3252
|
if (console.error("[FlowEngageProvider] acceptCall failed", e), at.current = null, yt("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3247
|
-
|
|
3253
|
+
Xe(Xn(e, "This visitor call is no longer available."));
|
|
3248
3254
|
return;
|
|
3249
3255
|
}
|
|
3250
3256
|
if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
|
|
3251
3257
|
try {
|
|
3252
|
-
await A.current.rejectCall(
|
|
3258
|
+
await A.current.rejectCall(O.callId, y);
|
|
3253
3259
|
} catch (e) {
|
|
3254
3260
|
console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
|
|
3255
3261
|
}
|
|
3256
|
-
|
|
3262
|
+
Xe("Microphone access was denied. Please allow microphone access to accept the call.");
|
|
3257
3263
|
return;
|
|
3258
3264
|
}
|
|
3259
|
-
|
|
3265
|
+
Xe("We couldn't connect the call right now. Please try again.");
|
|
3260
3266
|
}
|
|
3261
3267
|
}
|
|
3262
3268
|
}, Tt = async () => {
|
|
3263
|
-
if (!
|
|
3269
|
+
if (!O?.callId || !A.current || !y) {
|
|
3264
3270
|
yt("reject_call_without_server_context");
|
|
3265
3271
|
return;
|
|
3266
3272
|
}
|
|
3267
3273
|
_t(), gt();
|
|
3268
3274
|
try {
|
|
3269
|
-
await A.current.rejectCall(
|
|
3275
|
+
await A.current.rejectCall(O.callId, y);
|
|
3270
3276
|
} catch (e) {
|
|
3271
|
-
console.error("[FlowEngageProvider] rejectCall failed", e),
|
|
3277
|
+
console.error("[FlowEngageProvider] rejectCall failed", e), Xe(Xn(e, "We couldn't decline the call cleanly."));
|
|
3272
3278
|
} finally {
|
|
3273
3279
|
yt("reject_call_finally");
|
|
3274
3280
|
}
|
|
3275
3281
|
}, Et = p(Tt);
|
|
3276
3282
|
Et.current = Tt, c(() => {
|
|
3277
|
-
if (!
|
|
3283
|
+
if (!O?.callId || Ve) {
|
|
3278
3284
|
_t();
|
|
3279
3285
|
return;
|
|
3280
3286
|
}
|
|
3281
|
-
let e =
|
|
3287
|
+
let e = O.callId;
|
|
3282
3288
|
return _t(), ot.current = window.setTimeout(() => {
|
|
3283
3289
|
Qe.current?.callId === e && at.current !== e && it.current !== e && Et.current();
|
|
3284
3290
|
}, oe), () => {
|
|
3285
3291
|
ot.current &&= (window.clearTimeout(ot.current), null);
|
|
3286
3292
|
};
|
|
3287
3293
|
}, [
|
|
3288
|
-
|
|
3294
|
+
Ve,
|
|
3289
3295
|
_t,
|
|
3290
|
-
|
|
3296
|
+
O?.callId
|
|
3291
3297
|
]);
|
|
3292
3298
|
let Dt = async () => {
|
|
3293
|
-
if (!
|
|
3299
|
+
if (!Ve || !A.current || !y) {
|
|
3294
3300
|
yt("end_call_without_server_context");
|
|
3295
3301
|
return;
|
|
3296
3302
|
}
|
|
3297
3303
|
gt();
|
|
3298
3304
|
try {
|
|
3299
|
-
await A.current.endWebRTCCall(
|
|
3305
|
+
await A.current.endWebRTCCall(Ve, y);
|
|
3300
3306
|
} catch (e) {
|
|
3301
|
-
console.error("[FlowEngageProvider] endWebRTCCall failed", e),
|
|
3307
|
+
console.error("[FlowEngageProvider] endWebRTCCall failed", e), Xe(Xn(e, "The call ended locally, but the server could not be updated."));
|
|
3302
3308
|
} finally {
|
|
3303
3309
|
yt("end_call_finally");
|
|
3304
3310
|
}
|
|
@@ -3308,13 +3314,13 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3308
3314
|
console.warn("[FlowEngageProvider] no local audio tracks available for mute");
|
|
3309
3315
|
return;
|
|
3310
3316
|
}
|
|
3311
|
-
let r = !
|
|
3317
|
+
let r = !qe;
|
|
3312
3318
|
n.forEach((e) => {
|
|
3313
3319
|
e.enabled = !r;
|
|
3314
3320
|
}), console.log("[FlowEngageProvider] toggled local mute", {
|
|
3315
3321
|
nextMuted: r,
|
|
3316
3322
|
trackCount: n.length
|
|
3317
|
-
}),
|
|
3323
|
+
}), Je(r);
|
|
3318
3324
|
}, kt = async (e = {}) => {
|
|
3319
3325
|
let t = e.notifyChatInitiated === !0;
|
|
3320
3326
|
if (w(!0), !(!t || !A.current || !y || typeof window > "u")) {
|
|
@@ -3393,7 +3399,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3393
3399
|
text: t
|
|
3394
3400
|
}));
|
|
3395
3401
|
}, Pt = async (e, t = "", n = null, i = {}) => {
|
|
3396
|
-
if (!(typeof e == "string" && e.trim()) || !A.current || !y || l !== "ready" ||
|
|
3402
|
+
if (!(typeof e == "string" && e.trim()) || !A.current || !y || l !== "ready" || Re) return;
|
|
3397
3403
|
Mt();
|
|
3398
3404
|
let a = `pending-user-${Date.now()}`, o = {
|
|
3399
3405
|
id: a,
|
|
@@ -3422,19 +3428,19 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3422
3428
|
});
|
|
3423
3429
|
return;
|
|
3424
3430
|
}
|
|
3425
|
-
|
|
3431
|
+
je(!0);
|
|
3426
3432
|
try {
|
|
3427
3433
|
let a = await A.current.sendAiMessage(y, e, r, t, {
|
|
3428
3434
|
...n || {},
|
|
3429
3435
|
...pe ? { email: pe } : {}
|
|
3430
3436
|
}, i), o = a.chat_history || [];
|
|
3431
|
-
[...o].reverse().find((e) => e.sender === "bot" || e.sender === "assistant"), S(Yn(o)), re(!!a.is_human_handled), te(a.is_human_handled ? "agent" : "ai"),
|
|
3437
|
+
[...o].reverse().find((e) => e.sender === "bot" || e.sender === "assistant"), S(Yn(o)), re(!!a.is_human_handled), te(a.is_human_handled ? "agent" : "ai"), D(!1), await A.current.updateChatStatus(y, "messageSent");
|
|
3432
3438
|
} catch (e) {
|
|
3433
|
-
S((e) => e.filter((e) => e.id !== a)),
|
|
3434
|
-
|
|
3439
|
+
S((e) => e.filter((e) => e.id !== a)), D(!1), e.status === 429 ? (Ne(!0), Fe(e.message), window.setTimeout(() => {
|
|
3440
|
+
Ne(!1), Fe("");
|
|
3435
3441
|
}, ie)) : h(e);
|
|
3436
3442
|
} finally {
|
|
3437
|
-
|
|
3443
|
+
je(!1);
|
|
3438
3444
|
}
|
|
3439
3445
|
}, Ft = async (e) => {
|
|
3440
3446
|
if (!A.current || !e) throw Error("Upload is unavailable right now.");
|
|
@@ -3447,12 +3453,12 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3447
3453
|
} catch (e) {
|
|
3448
3454
|
console.error("[FlowEngageProvider] setVoiceMode failed", e);
|
|
3449
3455
|
}
|
|
3450
|
-
|
|
3456
|
+
Le(e), e && (ft.current = !1);
|
|
3451
3457
|
}
|
|
3452
3458
|
}, Lt = async (e) => {
|
|
3453
3459
|
if (ft.current) return;
|
|
3454
3460
|
if (ft.current = !0, !A.current || !y || !e?.length) {
|
|
3455
|
-
|
|
3461
|
+
Le(!1);
|
|
3456
3462
|
return;
|
|
3457
3463
|
}
|
|
3458
3464
|
let t = () => {
|
|
@@ -3476,11 +3482,11 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3476
3482
|
} catch {
|
|
3477
3483
|
t();
|
|
3478
3484
|
} finally {
|
|
3479
|
-
|
|
3485
|
+
Le(!1);
|
|
3480
3486
|
}
|
|
3481
3487
|
}, Rt = async () => {
|
|
3482
3488
|
if (!(!A.current || !y)) {
|
|
3483
|
-
|
|
3489
|
+
Ie && !ft.current && dt.current.length > 0 && await Lt(dt.current);
|
|
3484
3490
|
try {
|
|
3485
3491
|
await A.current.endConversation(y);
|
|
3486
3492
|
} catch {
|
|
@@ -3488,7 +3494,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3488
3494
|
await A.current.updateChatStatus(y, "ended");
|
|
3489
3495
|
} catch {}
|
|
3490
3496
|
}
|
|
3491
|
-
|
|
3497
|
+
ze(!0), S((e) => [...e, {
|
|
3492
3498
|
id: `conversation-ended-${Date.now()}`,
|
|
3493
3499
|
sender: "system",
|
|
3494
3500
|
message: "This conversation has ended. Thank you for reaching out!",
|
|
@@ -3498,15 +3504,15 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3498
3504
|
}
|
|
3499
3505
|
};
|
|
3500
3506
|
c(() => {
|
|
3501
|
-
if (
|
|
3502
|
-
let e = new Date(
|
|
3503
|
-
|
|
3507
|
+
if (Ue !== "connected" || !Ve || !y || !Ge || !ht) return;
|
|
3508
|
+
let e = new Date(Ge).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, ht * 1e3 - t), r = window.setTimeout(() => {
|
|
3509
|
+
Xe("The call ended because it reached the time limit."), Dt();
|
|
3504
3510
|
}, n);
|
|
3505
3511
|
return () => window.clearTimeout(r);
|
|
3506
3512
|
}, [
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3513
|
+
Ve,
|
|
3514
|
+
Ge,
|
|
3515
|
+
Ue,
|
|
3510
3516
|
y,
|
|
3511
3517
|
Dt,
|
|
3512
3518
|
ht
|
|
@@ -3527,7 +3533,7 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3527
3533
|
}, []);
|
|
3528
3534
|
let zt = o(() => {
|
|
3529
3535
|
let e = i?.siteId;
|
|
3530
|
-
_e(e), Ze.current = !0, k.current?.disconnect(), S([]), b(""), j.current = "",
|
|
3536
|
+
_e(e), Ze.current = !0, k.current?.disconnect(), S([]), b(""), j.current = "", ze(!1), re(!1), se(null), fe(null), s((e) => e + 1);
|
|
3531
3537
|
}, [i?.siteId]), Bt = f(() => ({
|
|
3532
3538
|
status: l,
|
|
3533
3539
|
error: d,
|
|
@@ -3543,18 +3549,18 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3543
3549
|
visitorEmail: pe,
|
|
3544
3550
|
isAgentTyping: he,
|
|
3545
3551
|
isAiTyping: we,
|
|
3546
|
-
connectionStatus:
|
|
3547
|
-
isLoading:
|
|
3548
|
-
isVoiceMode:
|
|
3549
|
-
isRateLimited:
|
|
3550
|
-
rateLimitMessage:
|
|
3551
|
-
isConversationEnded:
|
|
3552
|
-
incomingCall:
|
|
3553
|
-
activeCallId:
|
|
3554
|
-
callConnectionState:
|
|
3555
|
-
callConnectedAt:
|
|
3556
|
-
isCallMuted:
|
|
3557
|
-
webRTCError:
|
|
3552
|
+
connectionStatus: Oe,
|
|
3553
|
+
isLoading: Ae,
|
|
3554
|
+
isVoiceMode: Ie,
|
|
3555
|
+
isRateLimited: Me,
|
|
3556
|
+
rateLimitMessage: Pe,
|
|
3557
|
+
isConversationEnded: Re,
|
|
3558
|
+
incomingCall: O,
|
|
3559
|
+
activeCallId: Ve,
|
|
3560
|
+
callConnectionState: Ue,
|
|
3561
|
+
callConnectedAt: Ge,
|
|
3562
|
+
isCallMuted: qe,
|
|
3563
|
+
webRTCError: Ye,
|
|
3558
3564
|
language: r,
|
|
3559
3565
|
historyRef: dt,
|
|
3560
3566
|
hasSyncedRef: ft,
|
|
@@ -3579,6 +3585,8 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3579
3585
|
onMessageSync: Lt,
|
|
3580
3586
|
endConversation: Rt,
|
|
3581
3587
|
startNewChat: zt,
|
|
3588
|
+
getVisitorChatHistory: () => A.current?.getVisitorChatHistory?.(),
|
|
3589
|
+
getVisitorChatThread: (e) => A.current?.getVisitorChatThread?.(e),
|
|
3582
3590
|
acceptCall: wt,
|
|
3583
3591
|
rejectCall: Tt,
|
|
3584
3592
|
endWebRTCCall: Dt,
|
|
@@ -3598,18 +3606,18 @@ function tr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3598
3606
|
pe,
|
|
3599
3607
|
he,
|
|
3600
3608
|
we,
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3609
|
+
Oe,
|
|
3610
|
+
Ae,
|
|
3611
|
+
Ie,
|
|
3612
|
+
Me,
|
|
3613
|
+
Pe,
|
|
3614
|
+
Re,
|
|
3615
|
+
O,
|
|
3616
|
+
Ve,
|
|
3617
|
+
Ue,
|
|
3618
|
+
Ge,
|
|
3619
|
+
qe,
|
|
3620
|
+
Ye,
|
|
3613
3621
|
r,
|
|
3614
3622
|
At,
|
|
3615
3623
|
jt,
|
|
@@ -30040,16 +30048,34 @@ var VO = () => /* @__PURE__ */ g("div", {
|
|
|
30040
30048
|
} }, e))
|
|
30041
30049
|
})
|
|
30042
30050
|
});
|
|
30043
|
-
function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: w, isRateLimited: T, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: E, isUploadingAttachment: ie, requiresEmail: ae, emailInput: oe, setEmailInput: se, emailError: ce, replyContext: le, setReplyContext: ue, webRTCError: de, micError: fe, setMicError: pe, dismissCallError: me, activeCallId: he, isCallMuted: ge, toggleCallMute: _e, endWebRTCCall: ve, formatCallDuration: ye, callDurationSeconds: be, isCallMinimized: xe, onExpand: Se, onCollapse: Ce, onStartVoice: we, onNewChat: Te,
|
|
30044
|
-
let
|
|
30051
|
+
function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: w, isRateLimited: T, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: E, isUploadingAttachment: ie, requiresEmail: ae, emailInput: oe, setEmailInput: se, emailError: ce, replyContext: le, setReplyContext: ue, webRTCError: de, micError: fe, setMicError: pe, dismissCallError: me, activeCallId: he, isCallMuted: ge, toggleCallMute: _e, endWebRTCCall: ve, formatCallDuration: ye, callDurationSeconds: be, isCallMinimized: xe, onExpand: Se, onCollapse: Ce, onStartVoice: we, onNewChat: Te, onEndConversation: Ee, showPoweredBy: De, getVisitorChatHistory: D, getVisitorChatThread: Oe }) {
|
|
30052
|
+
let ke = l.length > 0, Ae = w || T || C, je = !!he, [Me, Ne] = m(!1), [Pe, Fe] = m(!1), [Ie, Le] = m([]), [Re, ze] = m(!1), [O, Be] = m(null), [Ve, He] = m([]), Ue = p(null), We = async () => {
|
|
30053
|
+
Ne(!1), Fe(!0), ze(!0), Be(null);
|
|
30054
|
+
try {
|
|
30055
|
+
let e = await D();
|
|
30056
|
+
e?.data && Le(e.data);
|
|
30057
|
+
} catch (e) {
|
|
30058
|
+
console.error(e);
|
|
30059
|
+
} finally {
|
|
30060
|
+
ze(!1);
|
|
30061
|
+
}
|
|
30062
|
+
}, Ge = async (e) => {
|
|
30063
|
+
Be(e);
|
|
30064
|
+
try {
|
|
30065
|
+
let t = await Oe(e.chatId);
|
|
30066
|
+
t?.data && He(t.data);
|
|
30067
|
+
} catch (e) {
|
|
30068
|
+
console.error(e);
|
|
30069
|
+
}
|
|
30070
|
+
};
|
|
30045
30071
|
return c(() => {
|
|
30046
|
-
if (!
|
|
30072
|
+
if (!Me) return;
|
|
30047
30073
|
let e = (e) => {
|
|
30048
30074
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
30049
|
-
|
|
30075
|
+
Ue.current && !Ue.current.contains(t) && Ne(!1);
|
|
30050
30076
|
};
|
|
30051
30077
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30052
|
-
}, [
|
|
30078
|
+
}, [Me]), /* @__PURE__ */ _("div", {
|
|
30053
30079
|
style: s ? {
|
|
30054
30080
|
"--flowengage-primary": n,
|
|
30055
30081
|
"--flowengage-accent": n,
|
|
@@ -30091,40 +30117,82 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30091
30117
|
flexShrink: 0
|
|
30092
30118
|
},
|
|
30093
30119
|
children: [
|
|
30094
|
-
/* @__PURE__ */
|
|
30095
|
-
onClick: Ce,
|
|
30120
|
+
/* @__PURE__ */ _("div", {
|
|
30096
30121
|
style: {
|
|
30097
|
-
width: "40px",
|
|
30098
|
-
height: "40px",
|
|
30099
|
-
background: "none",
|
|
30100
|
-
border: "none",
|
|
30101
|
-
cursor: "pointer",
|
|
30102
|
-
color: "#6b7280",
|
|
30103
30122
|
display: "flex",
|
|
30104
|
-
|
|
30105
|
-
|
|
30106
|
-
padding: "4px",
|
|
30107
|
-
borderRadius: "10px",
|
|
30108
|
-
transition: "color 0.15s ease",
|
|
30109
|
-
flexShrink: 0
|
|
30110
|
-
},
|
|
30111
|
-
onMouseEnter: (e) => {
|
|
30112
|
-
e.currentTarget.style.color = "#111827";
|
|
30113
|
-
},
|
|
30114
|
-
onMouseLeave: (e) => {
|
|
30115
|
-
e.currentTarget.style.color = "#6b7280";
|
|
30123
|
+
gap: "8px",
|
|
30124
|
+
alignItems: "center"
|
|
30116
30125
|
},
|
|
30117
|
-
children: /* @__PURE__ */ g("
|
|
30118
|
-
|
|
30119
|
-
|
|
30120
|
-
|
|
30121
|
-
|
|
30122
|
-
|
|
30123
|
-
|
|
30124
|
-
|
|
30125
|
-
|
|
30126
|
-
|
|
30127
|
-
|
|
30126
|
+
children: [/* @__PURE__ */ g("button", {
|
|
30127
|
+
onClick: Ce,
|
|
30128
|
+
style: {
|
|
30129
|
+
width: "40px",
|
|
30130
|
+
height: "40px",
|
|
30131
|
+
background: "none",
|
|
30132
|
+
border: "none",
|
|
30133
|
+
cursor: "pointer",
|
|
30134
|
+
color: "#6b7280",
|
|
30135
|
+
display: "flex",
|
|
30136
|
+
alignItems: "center",
|
|
30137
|
+
justifyContent: "center",
|
|
30138
|
+
padding: "4px",
|
|
30139
|
+
borderRadius: "10px",
|
|
30140
|
+
transition: "color 0.15s ease",
|
|
30141
|
+
flexShrink: 0
|
|
30142
|
+
},
|
|
30143
|
+
onMouseEnter: (e) => {
|
|
30144
|
+
e.currentTarget.style.color = "#111827";
|
|
30145
|
+
},
|
|
30146
|
+
onMouseLeave: (e) => {
|
|
30147
|
+
e.currentTarget.style.color = "#6b7280";
|
|
30148
|
+
},
|
|
30149
|
+
children: /* @__PURE__ */ g("svg", {
|
|
30150
|
+
width: "20",
|
|
30151
|
+
height: "20",
|
|
30152
|
+
viewBox: "0 0 24 24",
|
|
30153
|
+
fill: "none",
|
|
30154
|
+
stroke: "currentColor",
|
|
30155
|
+
strokeWidth: "2.2",
|
|
30156
|
+
strokeLinecap: "round",
|
|
30157
|
+
strokeLinejoin: "round",
|
|
30158
|
+
children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
|
|
30159
|
+
})
|
|
30160
|
+
}), D && /* @__PURE__ */ g("button", {
|
|
30161
|
+
onClick: We,
|
|
30162
|
+
title: "History",
|
|
30163
|
+
style: {
|
|
30164
|
+
width: "40px",
|
|
30165
|
+
height: "40px",
|
|
30166
|
+
background: "none",
|
|
30167
|
+
border: "none",
|
|
30168
|
+
cursor: "pointer",
|
|
30169
|
+
color: "#6b7280",
|
|
30170
|
+
display: "flex",
|
|
30171
|
+
alignItems: "center",
|
|
30172
|
+
justifyContent: "center",
|
|
30173
|
+
padding: "4px",
|
|
30174
|
+
borderRadius: "10px",
|
|
30175
|
+
transition: "color 0.15s ease",
|
|
30176
|
+
flexShrink: 0
|
|
30177
|
+
},
|
|
30178
|
+
onMouseEnter: (e) => {
|
|
30179
|
+
e.currentTarget.style.color = "#111827";
|
|
30180
|
+
},
|
|
30181
|
+
onMouseLeave: (e) => {
|
|
30182
|
+
e.currentTarget.style.color = "#6b7280";
|
|
30183
|
+
},
|
|
30184
|
+
children: /* @__PURE__ */ g("svg", {
|
|
30185
|
+
width: "18",
|
|
30186
|
+
height: "18",
|
|
30187
|
+
viewBox: "0 0 24 24",
|
|
30188
|
+
fill: "none",
|
|
30189
|
+
stroke: "currentColor",
|
|
30190
|
+
strokeWidth: "2",
|
|
30191
|
+
strokeLinecap: "round",
|
|
30192
|
+
strokeLinejoin: "round",
|
|
30193
|
+
children: /* @__PURE__ */ g("path", { d: "M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" })
|
|
30194
|
+
})
|
|
30195
|
+
})]
|
|
30128
30196
|
}),
|
|
30129
30197
|
/* @__PURE__ */ _("div", {
|
|
30130
30198
|
style: {
|
|
@@ -30187,10 +30255,10 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30187
30255
|
isolation: "isolate",
|
|
30188
30256
|
zIndex: 10
|
|
30189
30257
|
},
|
|
30190
|
-
ref:
|
|
30258
|
+
ref: Ue,
|
|
30191
30259
|
children: [/* @__PURE__ */ g("button", {
|
|
30192
30260
|
type: "button",
|
|
30193
|
-
onClick: () =>
|
|
30261
|
+
onClick: () => Ne((e) => !e),
|
|
30194
30262
|
style: {
|
|
30195
30263
|
width: "40px",
|
|
30196
30264
|
height: "40px",
|
|
@@ -30236,7 +30304,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30236
30304
|
})
|
|
30237
30305
|
]
|
|
30238
30306
|
})
|
|
30239
|
-
}),
|
|
30307
|
+
}), Me && /* @__PURE__ */ _("div", {
|
|
30240
30308
|
style: {
|
|
30241
30309
|
position: "absolute",
|
|
30242
30310
|
top: "34px",
|
|
@@ -30255,7 +30323,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30255
30323
|
/* @__PURE__ */ _("button", {
|
|
30256
30324
|
type: "button",
|
|
30257
30325
|
onClick: () => {
|
|
30258
|
-
|
|
30326
|
+
Ne(!1), we?.();
|
|
30259
30327
|
},
|
|
30260
30328
|
style: {
|
|
30261
30329
|
display: "flex",
|
|
@@ -30298,7 +30366,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30298
30366
|
/* @__PURE__ */ _("button", {
|
|
30299
30367
|
type: "button",
|
|
30300
30368
|
onClick: () => {
|
|
30301
|
-
|
|
30369
|
+
Ne(!1), Te?.();
|
|
30302
30370
|
},
|
|
30303
30371
|
style: {
|
|
30304
30372
|
display: "flex",
|
|
@@ -30331,7 +30399,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30331
30399
|
strokeLinecap: "round",
|
|
30332
30400
|
strokeLinejoin: "round",
|
|
30333
30401
|
children: [/* @__PURE__ */ g("path", { d: "M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7" }), /* @__PURE__ */ g("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })]
|
|
30334
|
-
}), "
|
|
30402
|
+
}), "Start new conversation"]
|
|
30335
30403
|
}),
|
|
30336
30404
|
/* @__PURE__ */ g("div", { style: {
|
|
30337
30405
|
height: "1px",
|
|
@@ -30341,7 +30409,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30341
30409
|
/* @__PURE__ */ _("button", {
|
|
30342
30410
|
type: "button",
|
|
30343
30411
|
onClick: () => {
|
|
30344
|
-
|
|
30412
|
+
Ne(!1), Ee ? Ee().catch(() => {}).finally(() => Te?.()) : Te?.();
|
|
30345
30413
|
},
|
|
30346
30414
|
style: {
|
|
30347
30415
|
display: "flex",
|
|
@@ -30373,13 +30441,26 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30373
30441
|
strokeWidth: "2",
|
|
30374
30442
|
strokeLinecap: "round",
|
|
30375
30443
|
strokeLinejoin: "round",
|
|
30376
|
-
children: [
|
|
30377
|
-
|
|
30378
|
-
|
|
30379
|
-
|
|
30380
|
-
|
|
30381
|
-
|
|
30382
|
-
|
|
30444
|
+
children: [
|
|
30445
|
+
/* @__PURE__ */ g("circle", {
|
|
30446
|
+
cx: "12",
|
|
30447
|
+
cy: "12",
|
|
30448
|
+
r: "10"
|
|
30449
|
+
}),
|
|
30450
|
+
/* @__PURE__ */ g("line", {
|
|
30451
|
+
x1: "15",
|
|
30452
|
+
y1: "9",
|
|
30453
|
+
x2: "9",
|
|
30454
|
+
y2: "15"
|
|
30455
|
+
}),
|
|
30456
|
+
/* @__PURE__ */ g("line", {
|
|
30457
|
+
x1: "9",
|
|
30458
|
+
y1: "9",
|
|
30459
|
+
x2: "15",
|
|
30460
|
+
y2: "15"
|
|
30461
|
+
})
|
|
30462
|
+
]
|
|
30463
|
+
}), "Close conversation"]
|
|
30383
30464
|
})
|
|
30384
30465
|
]
|
|
30385
30466
|
})]
|
|
@@ -30406,15 +30487,200 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30406
30487
|
onExpand: Se,
|
|
30407
30488
|
primaryColor: n
|
|
30408
30489
|
}),
|
|
30409
|
-
/* @__PURE__ */
|
|
30490
|
+
/* @__PURE__ */ _("div", {
|
|
30410
30491
|
style: {
|
|
30411
30492
|
flex: 1,
|
|
30412
30493
|
display: "flex",
|
|
30413
30494
|
flexDirection: "column",
|
|
30414
30495
|
minHeight: 0,
|
|
30415
|
-
background: "transparent"
|
|
30496
|
+
background: "transparent",
|
|
30497
|
+
position: "relative"
|
|
30416
30498
|
},
|
|
30417
|
-
children:
|
|
30499
|
+
children: [Pe ? /* @__PURE__ */ _("div", {
|
|
30500
|
+
style: {
|
|
30501
|
+
position: "absolute",
|
|
30502
|
+
inset: 0,
|
|
30503
|
+
background: "white",
|
|
30504
|
+
zIndex: 20,
|
|
30505
|
+
display: "flex",
|
|
30506
|
+
flexDirection: "column",
|
|
30507
|
+
animation: "fe-orb-fade-in 0.2s ease"
|
|
30508
|
+
},
|
|
30509
|
+
children: [/* @__PURE__ */ g("div", {
|
|
30510
|
+
style: {
|
|
30511
|
+
display: "flex",
|
|
30512
|
+
alignItems: "center",
|
|
30513
|
+
padding: "16px",
|
|
30514
|
+
borderBottom: "1px solid #f3f4f6",
|
|
30515
|
+
flexShrink: 0
|
|
30516
|
+
},
|
|
30517
|
+
children: O ? /* @__PURE__ */ _("button", {
|
|
30518
|
+
onClick: () => Be(null),
|
|
30519
|
+
style: {
|
|
30520
|
+
background: "none",
|
|
30521
|
+
border: "none",
|
|
30522
|
+
cursor: "pointer",
|
|
30523
|
+
display: "flex",
|
|
30524
|
+
alignItems: "center",
|
|
30525
|
+
color: "#6b7280"
|
|
30526
|
+
},
|
|
30527
|
+
children: [/* @__PURE__ */ g("svg", {
|
|
30528
|
+
width: "20",
|
|
30529
|
+
height: "20",
|
|
30530
|
+
viewBox: "0 0 24 24",
|
|
30531
|
+
fill: "none",
|
|
30532
|
+
stroke: "currentColor",
|
|
30533
|
+
strokeWidth: "2",
|
|
30534
|
+
strokeLinecap: "round",
|
|
30535
|
+
strokeLinejoin: "round",
|
|
30536
|
+
children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
|
|
30537
|
+
}), /* @__PURE__ */ g("span", {
|
|
30538
|
+
style: {
|
|
30539
|
+
marginLeft: "8px",
|
|
30540
|
+
fontWeight: 500,
|
|
30541
|
+
fontSize: "15px"
|
|
30542
|
+
},
|
|
30543
|
+
children: "Back to List"
|
|
30544
|
+
})]
|
|
30545
|
+
}) : /* @__PURE__ */ _("button", {
|
|
30546
|
+
onClick: () => Fe(!1),
|
|
30547
|
+
style: {
|
|
30548
|
+
background: "none",
|
|
30549
|
+
border: "none",
|
|
30550
|
+
cursor: "pointer",
|
|
30551
|
+
display: "flex",
|
|
30552
|
+
alignItems: "center",
|
|
30553
|
+
color: "#6b7280"
|
|
30554
|
+
},
|
|
30555
|
+
children: [/* @__PURE__ */ g("svg", {
|
|
30556
|
+
width: "20",
|
|
30557
|
+
height: "20",
|
|
30558
|
+
viewBox: "0 0 24 24",
|
|
30559
|
+
fill: "none",
|
|
30560
|
+
stroke: "currentColor",
|
|
30561
|
+
strokeWidth: "2",
|
|
30562
|
+
strokeLinecap: "round",
|
|
30563
|
+
strokeLinejoin: "round",
|
|
30564
|
+
children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
|
|
30565
|
+
}), /* @__PURE__ */ g("span", {
|
|
30566
|
+
style: {
|
|
30567
|
+
marginLeft: "8px",
|
|
30568
|
+
fontWeight: 500,
|
|
30569
|
+
fontSize: "15px"
|
|
30570
|
+
},
|
|
30571
|
+
children: "Return to Chat"
|
|
30572
|
+
})]
|
|
30573
|
+
})
|
|
30574
|
+
}), /* @__PURE__ */ g("div", {
|
|
30575
|
+
style: {
|
|
30576
|
+
flex: 1,
|
|
30577
|
+
overflowY: "auto",
|
|
30578
|
+
position: "relative"
|
|
30579
|
+
},
|
|
30580
|
+
children: Re && !O ? /* @__PURE__ */ g("div", {
|
|
30581
|
+
style: {
|
|
30582
|
+
padding: "40px 20px",
|
|
30583
|
+
textAlign: "center",
|
|
30584
|
+
color: "#6b7280",
|
|
30585
|
+
fontSize: "14px"
|
|
30586
|
+
},
|
|
30587
|
+
children: "Loading past conversations..."
|
|
30588
|
+
}) : O ? /* @__PURE__ */ _("div", {
|
|
30589
|
+
style: { padding: "20px 16px" },
|
|
30590
|
+
children: [
|
|
30591
|
+
Ve.length === 0 ? /* @__PURE__ */ g("div", {
|
|
30592
|
+
style: {
|
|
30593
|
+
color: "#9ca3af",
|
|
30594
|
+
textAlign: "center",
|
|
30595
|
+
marginTop: "20px",
|
|
30596
|
+
fontSize: "14px"
|
|
30597
|
+
},
|
|
30598
|
+
children: "No messages"
|
|
30599
|
+
}) : null,
|
|
30600
|
+
Ve.map((e, t) => /* @__PURE__ */ g("div", {
|
|
30601
|
+
style: {
|
|
30602
|
+
marginBottom: "16px",
|
|
30603
|
+
display: "flex",
|
|
30604
|
+
justifyContent: e.sender === "user" ? "flex-end" : "flex-start"
|
|
30605
|
+
},
|
|
30606
|
+
children: /* @__PURE__ */ g("div", {
|
|
30607
|
+
style: {
|
|
30608
|
+
maxWidth: "85%",
|
|
30609
|
+
background: e.sender === "user" ? n : "#f3f4f6",
|
|
30610
|
+
color: e.sender === "user" ? "white" : "#111827",
|
|
30611
|
+
padding: "10px 14px",
|
|
30612
|
+
borderRadius: "14px",
|
|
30613
|
+
fontSize: "15px",
|
|
30614
|
+
lineHeight: 1.4,
|
|
30615
|
+
wordBreak: "break-word"
|
|
30616
|
+
},
|
|
30617
|
+
children: e.content
|
|
30618
|
+
})
|
|
30619
|
+
}, e._id || t)),
|
|
30620
|
+
Ve.length > 0 && /* @__PURE__ */ g("div", {
|
|
30621
|
+
style: {
|
|
30622
|
+
textAlign: "center",
|
|
30623
|
+
color: "#9ca3af",
|
|
30624
|
+
fontSize: "12px",
|
|
30625
|
+
marginTop: "32px",
|
|
30626
|
+
paddingBottom: "20px"
|
|
30627
|
+
},
|
|
30628
|
+
children: "— This conversation is closed —"
|
|
30629
|
+
})
|
|
30630
|
+
]
|
|
30631
|
+
}) : Ie.length > 0 ? /* @__PURE__ */ g("div", { children: Ie.map((e) => /* @__PURE__ */ _("div", {
|
|
30632
|
+
onClick: () => Ge(e),
|
|
30633
|
+
style: {
|
|
30634
|
+
padding: "16px 20px",
|
|
30635
|
+
borderBottom: "1px solid #f3f4f6",
|
|
30636
|
+
cursor: "pointer",
|
|
30637
|
+
transition: "background 0.15s ease"
|
|
30638
|
+
},
|
|
30639
|
+
onMouseEnter: (e) => e.currentTarget.style.background = "#f9fafb",
|
|
30640
|
+
onMouseLeave: (e) => e.currentTarget.style.background = "white",
|
|
30641
|
+
children: [/* @__PURE__ */ _("div", {
|
|
30642
|
+
style: {
|
|
30643
|
+
fontSize: "12px",
|
|
30644
|
+
color: "#6b7280",
|
|
30645
|
+
marginBottom: "6px",
|
|
30646
|
+
fontWeight: 500
|
|
30647
|
+
},
|
|
30648
|
+
children: [
|
|
30649
|
+
new Date(e.createdAt).toLocaleDateString(void 0, {
|
|
30650
|
+
month: "short",
|
|
30651
|
+
day: "numeric"
|
|
30652
|
+
}),
|
|
30653
|
+
" at ",
|
|
30654
|
+
new Date(e.createdAt).toLocaleTimeString([], {
|
|
30655
|
+
hour: "2-digit",
|
|
30656
|
+
minute: "2-digit"
|
|
30657
|
+
})
|
|
30658
|
+
]
|
|
30659
|
+
}), /* @__PURE__ */ g("div", {
|
|
30660
|
+
style: {
|
|
30661
|
+
fontSize: "14.5px",
|
|
30662
|
+
color: "#111827",
|
|
30663
|
+
opacity: .9,
|
|
30664
|
+
overflow: "hidden",
|
|
30665
|
+
textOverflow: "ellipsis",
|
|
30666
|
+
display: "-webkit-box",
|
|
30667
|
+
WebkitLineClamp: 2,
|
|
30668
|
+
WebkitBoxOrient: "vertical",
|
|
30669
|
+
lineHeight: 1.4
|
|
30670
|
+
},
|
|
30671
|
+
children: e.message || "Conversation"
|
|
30672
|
+
})]
|
|
30673
|
+
}, e.chatId)) }) : /* @__PURE__ */ g("div", {
|
|
30674
|
+
style: {
|
|
30675
|
+
padding: "40px 20px",
|
|
30676
|
+
textAlign: "center",
|
|
30677
|
+
color: "#9ca3af",
|
|
30678
|
+
fontSize: "14px"
|
|
30679
|
+
},
|
|
30680
|
+
children: "No previous chats found."
|
|
30681
|
+
})
|
|
30682
|
+
})]
|
|
30683
|
+
}) : null, ke ? /* @__PURE__ */ g(sD, {
|
|
30418
30684
|
chatHistory: l,
|
|
30419
30685
|
isAiTyping: u,
|
|
30420
30686
|
isLoading: w,
|
|
@@ -30485,7 +30751,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30485
30751
|
}, e.id))
|
|
30486
30752
|
})
|
|
30487
30753
|
]
|
|
30488
|
-
})
|
|
30754
|
+
})]
|
|
30489
30755
|
}),
|
|
30490
30756
|
/* @__PURE__ */ g("div", {
|
|
30491
30757
|
style: {
|
|
@@ -30500,11 +30766,11 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30500
30766
|
setInput: x,
|
|
30501
30767
|
onSubmit: S,
|
|
30502
30768
|
isConversationEnded: C,
|
|
30503
|
-
callUiActive:
|
|
30769
|
+
callUiActive: je,
|
|
30504
30770
|
handleToggleVoice: we,
|
|
30505
30771
|
showVoiceToggle: f === "agent",
|
|
30506
30772
|
activeScreen: f,
|
|
30507
|
-
inputDisabled:
|
|
30773
|
+
inputDisabled: Ae,
|
|
30508
30774
|
replyContext: le,
|
|
30509
30775
|
clearReplyContext: () => ue(null),
|
|
30510
30776
|
onFileSelect: ne,
|
|
@@ -30526,7 +30792,7 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30526
30792
|
padding: "12px 20px 18px",
|
|
30527
30793
|
pointerEvents: "none"
|
|
30528
30794
|
},
|
|
30529
|
-
children:
|
|
30795
|
+
children: De && /* @__PURE__ */ _("span", {
|
|
30530
30796
|
style: {
|
|
30531
30797
|
fontSize: "11px",
|
|
30532
30798
|
color: "#9ca3af",
|
|
@@ -30546,196 +30812,196 @@ function HO({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
30546
30812
|
});
|
|
30547
30813
|
}
|
|
30548
30814
|
function UO() {
|
|
30549
|
-
let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, historyRef: ie, onMessageSync: ae, sendMessage: oe, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: fe, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se } = gn();
|
|
30815
|
+
let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, historyRef: ie, onMessageSync: ae, sendMessage: oe, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: fe, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se, getVisitorChatHistory: Ce, getVisitorChatThread: we } = gn();
|
|
30550
30816
|
c(() => {
|
|
30551
30817
|
try {
|
|
30552
30818
|
Vn();
|
|
30553
30819
|
} catch {}
|
|
30554
30820
|
}, []);
|
|
30555
|
-
let
|
|
30556
|
-
...
|
|
30557
|
-
...
|
|
30558
|
-
},
|
|
30559
|
-
...
|
|
30560
|
-
...
|
|
30561
|
-
},
|
|
30562
|
-
...
|
|
30563
|
-
...
|
|
30564
|
-
},
|
|
30821
|
+
let Te = t?.widgetSettings || {}, Ee = n?.widgetSettings || {}, De = {
|
|
30822
|
+
...Te.branding || {},
|
|
30823
|
+
...Ee.branding || {}
|
|
30824
|
+
}, D = {
|
|
30825
|
+
...Te.theme || {},
|
|
30826
|
+
...Ee.theme || {}
|
|
30827
|
+
}, Oe = {
|
|
30828
|
+
...Te.features || {},
|
|
30829
|
+
...Ee.features || {}
|
|
30830
|
+
}, ke = Oe.voice !== !1, Ae = Array.isArray(D.orbColors) && D.orbColors.length > 0 ? D.orbColors : null, je = Ae?.[0] || D.primaryColor || "#3B82F6", Me = D.position || "bottom-right", Ne = De.fallbackAgentName || "Agent", Pe = jO(Ae ?? D.chatBgColors), Fe = De.logo || De.logoUrl || null, Ie = E || "en", Le = Te.recommendations?.[Ie] || [], Re = (Ee.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
30565
30831
|
id: e.key || `qr-${t}`,
|
|
30566
30832
|
label: e.label,
|
|
30567
30833
|
message: e.label,
|
|
30568
30834
|
text: e.label
|
|
30569
|
-
})),
|
|
30570
|
-
entryPrompt:
|
|
30571
|
-
yesLabel:
|
|
30572
|
-
laterLabel:
|
|
30573
|
-
connectionTitle:
|
|
30574
|
-
voiceLabel:
|
|
30575
|
-
textLabel:
|
|
30576
|
-
chatTitle:
|
|
30577
|
-
introGreeting:
|
|
30578
|
-
inputPlaceholder:
|
|
30579
|
-
analysingLabel:
|
|
30580
|
-
},
|
|
30835
|
+
})), ze = Array.isArray(De.quickChatOptions) && De.quickChatOptions.length > 0 ? De.quickChatOptions : Re, O = De.hideWatermark === !0 ? !1 : De.showPoweredBy !== !1, Be = De.chatbotEnabled !== !1 && D.chatbotEnabled !== !1, Ve = Te.greetings?.[E] || Ee.greetings?.[E] || De.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", He = {
|
|
30836
|
+
entryPrompt: De.entryPrompt || "Do you want to explore in a new way?",
|
|
30837
|
+
yesLabel: De.yesLabel || "Yes",
|
|
30838
|
+
laterLabel: De.laterLabel || "Later",
|
|
30839
|
+
connectionTitle: De.connectionTitle || "How would you like to connect?",
|
|
30840
|
+
voiceLabel: De.voiceLabel || "Voice",
|
|
30841
|
+
textLabel: De.textLabel || "Text",
|
|
30842
|
+
chatTitle: De.headerName || "Chat with FlowEngage",
|
|
30843
|
+
introGreeting: Ve,
|
|
30844
|
+
inputPlaceholder: De.inputPlaceholder || "Type your message",
|
|
30845
|
+
analysingLabel: De.analysingLabel || "analysing..."
|
|
30846
|
+
}, Ue = Ee.elevenLabsAgentId || t?.elevenLabsAgentId || null, We = t?.siteId || n?.siteId || null, Ge = t?.apiBaseUrl || "", Ke = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
|
|
30581
30847
|
l,
|
|
30582
30848
|
t?.ownerName,
|
|
30583
30849
|
t?.websiteName
|
|
30584
|
-
]),
|
|
30850
|
+
]), qe = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Je = r.some((e) => e.sender === "user"), Ye = f(() => {
|
|
30585
30851
|
let e = r.findIndex((e) => e.sender === "user");
|
|
30586
30852
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
30587
|
-
}, [r]),
|
|
30853
|
+
}, [r]), Xe = !h && Je && Ye, Ze = !!(Ee._dashboardLivePreview || Te._dashboardLivePreview), [k, A] = m(() => Ze ? "text_chat" : "entry_prompt"), [j, Qe] = m(""), [$e, et] = m(null), [tt, nt] = m(h || ""), [rt, it] = m(""), [at, ot] = m(0), [st, ct] = m(null), [lt, ut] = m(null), [dt, ft] = m(""), [pt, mt] = m(!1), [ht, gt] = m(!1), _t = p(null), vt = p(!1);
|
|
30588
30854
|
d(() => {
|
|
30589
|
-
if (!(e !== "ready" ||
|
|
30590
|
-
if (
|
|
30591
|
-
|
|
30855
|
+
if (!(e !== "ready" || vt.current)) {
|
|
30856
|
+
if (vt.current = !0, pe(We) || !ke) {
|
|
30857
|
+
A("minimized_orb");
|
|
30592
30858
|
return;
|
|
30593
30859
|
}
|
|
30594
30860
|
try {
|
|
30595
30861
|
let { shouldResumeVoice: e } = qn();
|
|
30596
|
-
e &&
|
|
30862
|
+
e && A("connection_modal");
|
|
30597
30863
|
} catch {}
|
|
30598
30864
|
}
|
|
30599
30865
|
}, [e, r]);
|
|
30600
|
-
let [
|
|
30866
|
+
let [yt, bt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
|
|
30601
30867
|
c(() => {
|
|
30602
|
-
let e = window.matchMedia("(max-width: 640px)"), t = (e) =>
|
|
30868
|
+
let e = window.matchMedia("(max-width: 640px)"), t = (e) => bt(e.matches);
|
|
30603
30869
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
30604
30870
|
}, []), c(() => {
|
|
30605
|
-
|
|
30871
|
+
nt(h || ""), h && it("");
|
|
30606
30872
|
}, [h]);
|
|
30607
|
-
let
|
|
30608
|
-
|
|
30609
|
-
}, []),
|
|
30873
|
+
let xt = o(() => {
|
|
30874
|
+
ut(null), ft("");
|
|
30875
|
+
}, []), St = o((e) => {
|
|
30610
30876
|
let t = nD(e);
|
|
30611
30877
|
if (t) {
|
|
30612
|
-
|
|
30878
|
+
ut(null), ft(t);
|
|
30613
30879
|
return;
|
|
30614
30880
|
}
|
|
30615
|
-
|
|
30881
|
+
ut(e), ft("");
|
|
30616
30882
|
}, []);
|
|
30617
30883
|
c(() => {
|
|
30618
30884
|
if (!te || ee !== "connected") {
|
|
30619
|
-
|
|
30885
|
+
ot(0);
|
|
30620
30886
|
return;
|
|
30621
30887
|
}
|
|
30622
30888
|
let e = () => {
|
|
30623
30889
|
let e = new Date(te).getTime();
|
|
30624
|
-
isNaN(e) ||
|
|
30890
|
+
isNaN(e) || ot(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
|
|
30625
30891
|
};
|
|
30626
30892
|
e();
|
|
30627
30893
|
let t = window.setInterval(e, 1e3);
|
|
30628
30894
|
return () => window.clearInterval(t);
|
|
30629
30895
|
}, [te, ee]);
|
|
30630
|
-
let
|
|
30631
|
-
|
|
30632
|
-
}, []),
|
|
30633
|
-
|
|
30896
|
+
let Ct = o(() => {
|
|
30897
|
+
A("call_screen"), gt(!1);
|
|
30898
|
+
}, []), wt = o(() => {
|
|
30899
|
+
A("text_chat"), gt(!0);
|
|
30634
30900
|
}, []);
|
|
30635
30901
|
c(() => {
|
|
30636
30902
|
let e = w?.callId || T || null;
|
|
30637
30903
|
if (!e) {
|
|
30638
|
-
|
|
30904
|
+
_t.current = null;
|
|
30639
30905
|
return;
|
|
30640
30906
|
}
|
|
30641
30907
|
if (w?.callId || ee === "connecting" || ee === "connected") {
|
|
30642
|
-
if (
|
|
30643
|
-
|
|
30908
|
+
if (k === "minimized_orb" && ht && T && !w?.callId) {
|
|
30909
|
+
_t.current = e;
|
|
30644
30910
|
return;
|
|
30645
30911
|
}
|
|
30646
|
-
!(!i ||
|
|
30912
|
+
!(!i || k === "minimized_orb" || k === "voice_mode") && _t.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
|
|
30647
30913
|
forcedKey: e,
|
|
30648
30914
|
isOpen: i,
|
|
30649
|
-
surface:
|
|
30915
|
+
surface: k,
|
|
30650
30916
|
hasIncomingCall: !!w?.callId,
|
|
30651
30917
|
activeCallId: T,
|
|
30652
30918
|
callConnectionState: ee
|
|
30653
|
-
}),
|
|
30919
|
+
}), _t.current = e, k === "voice_mode" && ue?.(!1), ce?.(), Ct());
|
|
30654
30920
|
}
|
|
30655
30921
|
}, [
|
|
30656
30922
|
T,
|
|
30657
30923
|
ee,
|
|
30658
|
-
|
|
30924
|
+
Ct,
|
|
30659
30925
|
w?.callId,
|
|
30660
30926
|
i,
|
|
30661
30927
|
ce,
|
|
30662
30928
|
ue,
|
|
30663
|
-
|
|
30929
|
+
k
|
|
30664
30930
|
]), c(() => {
|
|
30665
|
-
!w && !T &&
|
|
30931
|
+
!w && !T && k === "call_screen" && A("text_chat");
|
|
30666
30932
|
}, [
|
|
30667
30933
|
w,
|
|
30668
30934
|
T,
|
|
30669
|
-
|
|
30935
|
+
k
|
|
30670
30936
|
]), c(() => {
|
|
30671
|
-
!T &&
|
|
30672
|
-
}, [T,
|
|
30937
|
+
!T && ht && gt(!1);
|
|
30938
|
+
}, [T, ht]), c(() => {
|
|
30673
30939
|
if (!s || C) {
|
|
30674
30940
|
Se?.(""), xe?.();
|
|
30675
30941
|
return;
|
|
30676
30942
|
}
|
|
30677
|
-
if (!
|
|
30943
|
+
if (!j.trim() || lt) {
|
|
30678
30944
|
Se?.("");
|
|
30679
30945
|
let e = window.setTimeout(() => xe?.(), 100);
|
|
30680
30946
|
return () => window.clearTimeout(e);
|
|
30681
30947
|
}
|
|
30682
30948
|
be?.();
|
|
30683
|
-
let e = window.setTimeout(() => Se?.(
|
|
30949
|
+
let e = window.setTimeout(() => Se?.(j), 120), t = window.setTimeout(() => xe?.(), 1200);
|
|
30684
30950
|
return () => {
|
|
30685
30951
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
30686
30952
|
};
|
|
30687
30953
|
}, [
|
|
30688
|
-
|
|
30689
|
-
|
|
30954
|
+
j,
|
|
30955
|
+
lt,
|
|
30690
30956
|
s,
|
|
30691
30957
|
C,
|
|
30692
30958
|
be,
|
|
30693
30959
|
xe,
|
|
30694
30960
|
Se
|
|
30695
30961
|
]);
|
|
30696
|
-
let
|
|
30962
|
+
let Tt = (e) => e ? {
|
|
30697
30963
|
replyTo: e.messageId || e.id || null,
|
|
30698
30964
|
replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
|
|
30699
30965
|
replyToSender: e.sender || null
|
|
30700
|
-
} : null,
|
|
30966
|
+
} : null, Et = async (e) => {
|
|
30701
30967
|
if (e.preventDefault(), C) return;
|
|
30702
|
-
if (
|
|
30703
|
-
let e =
|
|
30968
|
+
if (Xe) {
|
|
30969
|
+
let e = tt.trim().toLowerCase();
|
|
30704
30970
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
30705
|
-
|
|
30971
|
+
it("Please enter a valid email so we can continue helping you.");
|
|
30706
30972
|
return;
|
|
30707
30973
|
}
|
|
30708
|
-
await le(e),
|
|
30974
|
+
await le(e), it("");
|
|
30709
30975
|
return;
|
|
30710
30976
|
}
|
|
30711
|
-
let t =
|
|
30712
|
-
if (!
|
|
30713
|
-
if (
|
|
30977
|
+
let t = Tt($e);
|
|
30978
|
+
if (!j.trim() && !lt) return;
|
|
30979
|
+
if (lt) {
|
|
30714
30980
|
try {
|
|
30715
|
-
|
|
30716
|
-
let e = await se(
|
|
30717
|
-
|
|
30981
|
+
mt(!0), ft("");
|
|
30982
|
+
let e = await se(lt), n = e?.data || e, r = j.trim() || `Shared file: ${iD(lt)}`;
|
|
30983
|
+
Qe(""), et(null), xt(), await oe(r, "", t, {
|
|
30718
30984
|
type: "file",
|
|
30719
30985
|
metadata: {
|
|
30720
30986
|
fileUrl: n?.fileUrl,
|
|
30721
|
-
fileName: n?.fileName ||
|
|
30722
|
-
fileType: n?.fileType ||
|
|
30723
|
-
fileSize: n?.fileSize ||
|
|
30987
|
+
fileName: n?.fileName || lt.name,
|
|
30988
|
+
fileType: n?.fileType || lt.type,
|
|
30989
|
+
fileSize: n?.fileSize || lt.size
|
|
30724
30990
|
}
|
|
30725
30991
|
});
|
|
30726
30992
|
} catch (e) {
|
|
30727
|
-
|
|
30993
|
+
ft(e?.message || "Failed to upload the selected file.");
|
|
30728
30994
|
} finally {
|
|
30729
|
-
|
|
30995
|
+
mt(!1);
|
|
30730
30996
|
}
|
|
30731
30997
|
return;
|
|
30732
30998
|
}
|
|
30733
|
-
let n =
|
|
30734
|
-
|
|
30735
|
-
},
|
|
30999
|
+
let n = j.trim();
|
|
31000
|
+
Qe(""), et(null), await oe(n, "", t);
|
|
31001
|
+
}, Dt = (e) => {
|
|
30736
31002
|
let t = Math.floor(e / 60);
|
|
30737
31003
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
30738
|
-
},
|
|
31004
|
+
}, Ot = o(async (e) => {
|
|
30739
31005
|
if (C || b) return;
|
|
30740
31006
|
let t = e.message || e.label || e.text || "";
|
|
30741
31007
|
t.trim() && await oe(t.trim(), "");
|
|
@@ -30743,67 +31009,67 @@ function UO() {
|
|
|
30743
31009
|
C,
|
|
30744
31010
|
b,
|
|
30745
31011
|
oe
|
|
30746
|
-
]),
|
|
31012
|
+
]), kt = yt && k === "entry_prompt" ? { inset: 0 } : yt && k === "text_chat" ? {
|
|
30747
31013
|
left: 0,
|
|
30748
31014
|
right: 0,
|
|
30749
31015
|
bottom: 0
|
|
30750
|
-
} :
|
|
31016
|
+
} : yt && k === "call_screen" ? {
|
|
30751
31017
|
left: 0,
|
|
30752
31018
|
right: 0,
|
|
30753
31019
|
bottom: 0,
|
|
30754
31020
|
height: "90dvh",
|
|
30755
31021
|
overflow: "hidden",
|
|
30756
31022
|
borderRadius: "16px 16px 0 0"
|
|
30757
|
-
} :
|
|
31023
|
+
} : yt && k === "connection_modal" ? {
|
|
30758
31024
|
left: "28px",
|
|
30759
31025
|
right: "12px",
|
|
30760
31026
|
bottom: "12px"
|
|
30761
|
-
} :
|
|
31027
|
+
} : k === "call_screen" ? {
|
|
30762
31028
|
width: "min(350px, calc(100vw - 40px))",
|
|
30763
31029
|
height: "min(640px, calc(100vh - 120px))",
|
|
30764
31030
|
borderRadius: "22px",
|
|
30765
31031
|
overflow: "hidden",
|
|
30766
|
-
...
|
|
31032
|
+
...Me === "bottom-left" ? {
|
|
30767
31033
|
left: "1.5rem",
|
|
30768
31034
|
bottom: "1.5rem"
|
|
30769
31035
|
} : {
|
|
30770
31036
|
right: "1.5rem",
|
|
30771
31037
|
bottom: "1.5rem"
|
|
30772
31038
|
}
|
|
30773
|
-
} :
|
|
31039
|
+
} : Me === "bottom-left" ? {
|
|
30774
31040
|
left: "1.5rem",
|
|
30775
31041
|
bottom: "1.5rem"
|
|
30776
31042
|
} : {
|
|
30777
31043
|
right: "1.5rem",
|
|
30778
31044
|
bottom: "1.5rem"
|
|
30779
|
-
},
|
|
30780
|
-
ce({ notifyChatInitiated: !0 }), ue?.(!0),
|
|
30781
|
-
},
|
|
30782
|
-
ce({ notifyChatInitiated: !0 }), ue?.(!1),
|
|
30783
|
-
},
|
|
30784
|
-
ue?.(!1),
|
|
31045
|
+
}, At = () => A("minimized_orb"), jt = () => A("connection_modal"), Mt = () => {
|
|
31046
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
|
|
31047
|
+
}, Nt = () => {
|
|
31048
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!1), A("text_chat");
|
|
31049
|
+
}, Pt = () => {
|
|
31050
|
+
ue?.(!1), At();
|
|
30785
31051
|
};
|
|
30786
|
-
return e !== "ready" || !Be ||
|
|
31052
|
+
return e !== "ready" || !Be || Oe.chat === !1 ? null : /* @__PURE__ */ _("div", {
|
|
30787
31053
|
className: "flowengage-widget-root",
|
|
30788
31054
|
style: {
|
|
30789
31055
|
position: "fixed",
|
|
30790
31056
|
zIndex: 999999,
|
|
30791
|
-
...
|
|
31057
|
+
...kt
|
|
30792
31058
|
},
|
|
30793
31059
|
children: [
|
|
30794
|
-
|
|
30795
|
-
copy:
|
|
30796
|
-
orbColors:
|
|
30797
|
-
primaryColor:
|
|
31060
|
+
k === "entry_prompt" && /* @__PURE__ */ g(LO, {
|
|
31061
|
+
copy: He,
|
|
31062
|
+
orbColors: Ae,
|
|
31063
|
+
primaryColor: je,
|
|
30798
31064
|
onYes: () => {
|
|
30799
|
-
me(
|
|
31065
|
+
me(We), Mt();
|
|
30800
31066
|
},
|
|
30801
31067
|
onLater: () => {
|
|
30802
|
-
me(
|
|
31068
|
+
me(We), At();
|
|
30803
31069
|
},
|
|
30804
|
-
isMobile:
|
|
31070
|
+
isMobile: yt
|
|
30805
31071
|
}),
|
|
30806
|
-
|
|
31072
|
+
k === "minimized_orb" && /* @__PURE__ */ _(Wp.div, {
|
|
30807
31073
|
layoutId: "fe-main-orb",
|
|
30808
31074
|
initial: { scale: 94 / 50 },
|
|
30809
31075
|
animate: { scale: 1 },
|
|
@@ -30816,14 +31082,14 @@ function UO() {
|
|
|
30816
31082
|
transformOrigin: "bottom right",
|
|
30817
31083
|
display: "inline-flex",
|
|
30818
31084
|
flexDirection: "column",
|
|
30819
|
-
alignItems:
|
|
31085
|
+
alignItems: Me === "bottom-left" ? "flex-start" : "flex-end",
|
|
30820
31086
|
gap: "10px"
|
|
30821
31087
|
},
|
|
30822
|
-
children: [T &&
|
|
31088
|
+
children: [T && ht && /* @__PURE__ */ _("button", {
|
|
30823
31089
|
type: "button",
|
|
30824
|
-
onClick:
|
|
31090
|
+
onClick: Ct,
|
|
30825
31091
|
style: {
|
|
30826
|
-
maxWidth:
|
|
31092
|
+
maxWidth: yt ? "220px" : "240px",
|
|
30827
31093
|
padding: "10px 14px",
|
|
30828
31094
|
borderRadius: "18px",
|
|
30829
31095
|
border: "1px solid rgba(255,255,255,0.7)",
|
|
@@ -30864,105 +31130,107 @@ function UO() {
|
|
|
30864
31130
|
marginTop: "2px",
|
|
30865
31131
|
whiteSpace: "nowrap"
|
|
30866
31132
|
},
|
|
30867
|
-
children: ee === "connected" ? `${
|
|
31133
|
+
children: ee === "connected" ? `${Dt(at)} with ${Ke}` : `Tap to return to ${Ke}`
|
|
30868
31134
|
})]
|
|
30869
31135
|
})]
|
|
30870
31136
|
}), /* @__PURE__ */ g(IO, {
|
|
30871
31137
|
size: 50,
|
|
30872
|
-
orbColors:
|
|
30873
|
-
onClick: T &&
|
|
31138
|
+
orbColors: Ae,
|
|
31139
|
+
onClick: T && ht ? Ct : ke ? jt : Nt
|
|
30874
31140
|
})]
|
|
30875
31141
|
}),
|
|
30876
|
-
|
|
30877
|
-
copy:
|
|
30878
|
-
orbColors:
|
|
30879
|
-
primaryColor:
|
|
30880
|
-
onVoice:
|
|
30881
|
-
onText:
|
|
30882
|
-
onClose:
|
|
30883
|
-
isMobile:
|
|
31142
|
+
k === "connection_modal" && /* @__PURE__ */ g(RO, {
|
|
31143
|
+
copy: He,
|
|
31144
|
+
orbColors: Ae,
|
|
31145
|
+
primaryColor: je,
|
|
31146
|
+
onVoice: Mt,
|
|
31147
|
+
onText: Nt,
|
|
31148
|
+
onClose: At,
|
|
31149
|
+
isMobile: yt
|
|
30884
31150
|
}),
|
|
30885
|
-
|
|
30886
|
-
orbColors:
|
|
30887
|
-
onEnterChat:
|
|
30888
|
-
onEndChat:
|
|
30889
|
-
agentId:
|
|
30890
|
-
siteId:
|
|
30891
|
-
apiBaseUrl:
|
|
31151
|
+
k === "voice_mode" && /* @__PURE__ */ g(zO, {
|
|
31152
|
+
orbColors: Ae,
|
|
31153
|
+
onEnterChat: Nt,
|
|
31154
|
+
onEndChat: Pt,
|
|
31155
|
+
agentId: Ue,
|
|
31156
|
+
siteId: We,
|
|
31157
|
+
apiBaseUrl: Ge,
|
|
30892
31158
|
historyRef: ie,
|
|
30893
31159
|
onMessageSync: ae
|
|
30894
31160
|
}, "voice"),
|
|
30895
|
-
|
|
31161
|
+
k === "call_screen" && /* @__PURE__ */ g(TD, {
|
|
30896
31162
|
incomingCall: w,
|
|
30897
31163
|
activeCallId: T,
|
|
30898
31164
|
callConnectionState: ee,
|
|
30899
|
-
callDurationSeconds:
|
|
31165
|
+
callDurationSeconds: at,
|
|
30900
31166
|
isCallMuted: ne,
|
|
30901
|
-
agentName:
|
|
30902
|
-
agentHeadshot:
|
|
30903
|
-
fallbackAgentName:
|
|
31167
|
+
agentName: Ke,
|
|
31168
|
+
agentHeadshot: qe,
|
|
31169
|
+
fallbackAgentName: Ne,
|
|
30904
31170
|
acceptCall: he,
|
|
30905
31171
|
rejectCall: ge,
|
|
30906
31172
|
endWebRTCCall: _e,
|
|
30907
31173
|
toggleCallMute: ve,
|
|
30908
|
-
formatCallDuration:
|
|
30909
|
-
onMinimize:
|
|
30910
|
-
primaryColor:
|
|
30911
|
-
orbColors:
|
|
31174
|
+
formatCallDuration: Dt,
|
|
31175
|
+
onMinimize: wt,
|
|
31176
|
+
primaryColor: je,
|
|
31177
|
+
orbColors: Ae,
|
|
30912
31178
|
chatHistory: r
|
|
30913
31179
|
}),
|
|
30914
|
-
|
|
30915
|
-
copy:
|
|
30916
|
-
orbColors:
|
|
30917
|
-
primaryColor:
|
|
30918
|
-
chatBgGradient:
|
|
30919
|
-
logo:
|
|
30920
|
-
quickChatOptions:
|
|
30921
|
-
onQuickChatSelect:
|
|
30922
|
-
isMobile:
|
|
31180
|
+
k === "text_chat" && /* @__PURE__ */ g(HO, {
|
|
31181
|
+
copy: He,
|
|
31182
|
+
orbColors: Ae,
|
|
31183
|
+
primaryColor: je,
|
|
31184
|
+
chatBgGradient: Pe,
|
|
31185
|
+
logo: Fe,
|
|
31186
|
+
quickChatOptions: ze,
|
|
31187
|
+
onQuickChatSelect: Ot,
|
|
31188
|
+
isMobile: yt,
|
|
30923
31189
|
chatHistory: r,
|
|
30924
31190
|
isAiTyping: y,
|
|
30925
31191
|
isAgentTyping: v,
|
|
30926
31192
|
activeScreen: a,
|
|
30927
|
-
agentName:
|
|
30928
|
-
agentHeadshot:
|
|
30929
|
-
fallbackAgentName:
|
|
30930
|
-
input:
|
|
30931
|
-
setInput:
|
|
30932
|
-
onSubmit:
|
|
31193
|
+
agentName: Ke,
|
|
31194
|
+
agentHeadshot: qe,
|
|
31195
|
+
fallbackAgentName: Ne,
|
|
31196
|
+
input: j,
|
|
31197
|
+
setInput: Qe,
|
|
31198
|
+
onSubmit: Et,
|
|
30933
31199
|
isConversationEnded: C,
|
|
30934
31200
|
isLoading: b,
|
|
30935
31201
|
isRateLimited: x,
|
|
30936
31202
|
rateLimitMessage: S,
|
|
30937
|
-
selectedFile:
|
|
30938
|
-
onFileSelect:
|
|
30939
|
-
onRemoveSelectedFile:
|
|
30940
|
-
attachmentError:
|
|
30941
|
-
isUploadingAttachment:
|
|
30942
|
-
requiresEmail:
|
|
30943
|
-
emailInput:
|
|
30944
|
-
setEmailInput:
|
|
30945
|
-
emailError:
|
|
30946
|
-
replyContext:
|
|
30947
|
-
setReplyContext:
|
|
31203
|
+
selectedFile: lt,
|
|
31204
|
+
onFileSelect: St,
|
|
31205
|
+
onRemoveSelectedFile: xt,
|
|
31206
|
+
attachmentError: dt,
|
|
31207
|
+
isUploadingAttachment: pt,
|
|
31208
|
+
requiresEmail: Xe,
|
|
31209
|
+
emailInput: tt,
|
|
31210
|
+
setEmailInput: nt,
|
|
31211
|
+
emailError: rt,
|
|
31212
|
+
replyContext: $e,
|
|
31213
|
+
setReplyContext: et,
|
|
30948
31214
|
webRTCError: re,
|
|
30949
|
-
micError:
|
|
30950
|
-
setMicError:
|
|
31215
|
+
micError: st,
|
|
31216
|
+
setMicError: ct,
|
|
30951
31217
|
dismissCallError: ye,
|
|
30952
31218
|
activeCallId: T,
|
|
30953
31219
|
isCallMuted: ne,
|
|
30954
31220
|
toggleCallMute: ve,
|
|
30955
31221
|
endWebRTCCall: _e,
|
|
30956
|
-
formatCallDuration:
|
|
30957
|
-
callDurationSeconds:
|
|
30958
|
-
onCollapse:
|
|
30959
|
-
onStartVoice:
|
|
31222
|
+
formatCallDuration: Dt,
|
|
31223
|
+
callDurationSeconds: at,
|
|
31224
|
+
onCollapse: At,
|
|
31225
|
+
onStartVoice: Mt,
|
|
30960
31226
|
onNewChat: fe,
|
|
30961
31227
|
onEndConversation: de,
|
|
30962
|
-
onMinimize:
|
|
30963
|
-
onExpand:
|
|
30964
|
-
isCallMinimized:
|
|
30965
|
-
showPoweredBy:
|
|
31228
|
+
onMinimize: wt,
|
|
31229
|
+
onExpand: Ct,
|
|
31230
|
+
isCallMinimized: ht && !!T,
|
|
31231
|
+
showPoweredBy: O,
|
|
31232
|
+
getVisitorChatHistory: Ce,
|
|
31233
|
+
getVisitorChatThread: we
|
|
30966
31234
|
}),
|
|
30967
31235
|
/* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
|
|
30968
31236
|
]
|