@flowengage/react-chatbot 5.0.23 → 5.0.24
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.
|
@@ -26581,22 +26581,26 @@ function VD(e) {
|
|
|
26581
26581
|
//#endregion
|
|
26582
26582
|
//#region src/components/AvatarImageOrInitials.jsx
|
|
26583
26583
|
function HD({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
|
|
26584
|
-
let [i, a] = m(
|
|
26584
|
+
let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
|
|
26585
26585
|
return c(() => {
|
|
26586
|
-
|
|
26587
|
-
|
|
26588
|
-
|
|
26589
|
-
alt: "",
|
|
26590
|
-
onLoad: () => s(!0),
|
|
26591
|
-
onError: () => a(!0),
|
|
26592
|
-
style: {
|
|
26593
|
-
...n,
|
|
26594
|
-
display: o ? void 0 : "none"
|
|
26586
|
+
if (!o) {
|
|
26587
|
+
a(null);
|
|
26588
|
+
return;
|
|
26595
26589
|
}
|
|
26596
|
-
|
|
26597
|
-
|
|
26598
|
-
|
|
26599
|
-
|
|
26590
|
+
a(null);
|
|
26591
|
+
let e = !1, t = new window.Image();
|
|
26592
|
+
return t.onload = () => {
|
|
26593
|
+
e || a(o);
|
|
26594
|
+
}, t.onerror = () => {
|
|
26595
|
+
e || a(null);
|
|
26596
|
+
}, t.src = o, () => {
|
|
26597
|
+
e = !0;
|
|
26598
|
+
};
|
|
26599
|
+
}, [o]), i ? /* @__PURE__ */ g("img", {
|
|
26600
|
+
src: i,
|
|
26601
|
+
alt: "",
|
|
26602
|
+
style: n
|
|
26603
|
+
}) : /* @__PURE__ */ g("span", {
|
|
26600
26604
|
style: r,
|
|
26601
26605
|
children: VD(t)
|
|
26602
26606
|
});
|
|
@@ -26604,7 +26608,7 @@ function HD({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
|
|
|
26604
26608
|
//#endregion
|
|
26605
26609
|
//#region src/components/MessageList.jsx
|
|
26606
26610
|
function UD({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: o = null, agentDisplayName: s = "Agent", botAvatarNode: l = null }) {
|
|
26607
|
-
let u = p(null), [d, f] = m(null), [v, y] = m(null), b = p(e.length), x = p(!0), S = (e) => {
|
|
26611
|
+
let u = p(null), [d, f] = m(null), [v, y] = m(null), b = p(e.length), x = p(!0), S = p(null), C = (e) => {
|
|
26608
26612
|
if (!e) return "just now";
|
|
26609
26613
|
let t = /* @__PURE__ */ new Date(), n = new Date(e), r = Math.max(0, Math.floor((t - n) / 1e3));
|
|
26610
26614
|
if (r < 60) return "just now";
|
|
@@ -26617,7 +26621,7 @@ function UD({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
26617
26621
|
};
|
|
26618
26622
|
return c(() => {
|
|
26619
26623
|
if (x.current) {
|
|
26620
|
-
x.current = !1, b.current = e.length;
|
|
26624
|
+
x.current = !1, b.current = e.length, S.current && (S.current.scrollTop = S.current.scrollHeight);
|
|
26621
26625
|
return;
|
|
26622
26626
|
}
|
|
26623
26627
|
let n = e.length > b.current;
|
|
@@ -26628,6 +26632,7 @@ function UD({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
26628
26632
|
n,
|
|
26629
26633
|
r
|
|
26630
26634
|
]), /* @__PURE__ */ _("div", {
|
|
26635
|
+
ref: S,
|
|
26631
26636
|
style: {
|
|
26632
26637
|
flex: 1,
|
|
26633
26638
|
overflowY: "auto",
|
|
@@ -26972,7 +26977,7 @@ function UD({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
26972
26977
|
color: "#9ca3af",
|
|
26973
26978
|
fontWeight: 500
|
|
26974
26979
|
},
|
|
26975
|
-
children:
|
|
26980
|
+
children: C(e.timestamp || e.createdAt)
|
|
26976
26981
|
}), /* @__PURE__ */ g("span", {
|
|
26977
26982
|
style: {
|
|
26978
26983
|
fontSize: "10px",
|
|
@@ -29964,11 +29969,11 @@ function kk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
29964
29969
|
});
|
|
29965
29970
|
}
|
|
29966
29971
|
function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i, siteId: a, apiBaseUrl: s, chatId: l, historyRef: u, onMessageSync: d, voiceEndCounter: f }) {
|
|
29967
|
-
let [h, v] = m("idle"), [y, b] = m(!1), [x, S] = m(!1), C = p(null), w = p(""), T = p(async () => {}), ee = p(!1), te = p(!1), ne = p(!1), re = p(!1), E = p("minimized"), ie = p(null), ae = p(null), oe = p(null), D = o((e = "minimized") => {
|
|
29972
|
+
let [h, v] = m("idle"), [y, b] = m(!1), [x, S] = m(!1), C = p(null), w = p(""), T = p(async () => {}), ee = p(!1), te = p(!1), ne = p(!1), re = p(!1), E = p("minimized"), ie = p(null), ae = p(null), oe = p(null), D = p(0), se = o((e = "minimized") => {
|
|
29968
29973
|
E.current = e, re.current = !0, queueMicrotask(() => {
|
|
29969
29974
|
ee.current || (ee.current = !0, T.current?.());
|
|
29970
29975
|
});
|
|
29971
|
-
}, [u]),
|
|
29976
|
+
}, [u]), ce = o(async (e) => {
|
|
29972
29977
|
re.current = !0;
|
|
29973
29978
|
try {
|
|
29974
29979
|
await C.current?.endSession?.();
|
|
@@ -29998,10 +30003,10 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
29998
30003
|
l,
|
|
29999
30004
|
s
|
|
30000
30005
|
]);
|
|
30001
|
-
return T.current = () =>
|
|
30006
|
+
return T.current = () => ce(E.current === "chat" ? t : n), c(() => {
|
|
30002
30007
|
te.current = y;
|
|
30003
30008
|
}, [y]), c(() => {
|
|
30004
|
-
f &&
|
|
30009
|
+
f && se("chat");
|
|
30005
30010
|
}, [f]), c(() => {
|
|
30006
30011
|
let e = !1, i = null;
|
|
30007
30012
|
return (async () => {
|
|
@@ -30040,7 +30045,7 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30040
30045
|
apiBaseUrl: s || null,
|
|
30041
30046
|
getLastUserVoiceText: () => w.current,
|
|
30042
30047
|
requestEndSession: () => {
|
|
30043
|
-
|
|
30048
|
+
se();
|
|
30044
30049
|
}
|
|
30045
30050
|
})), n = a ? je(a) : null, o = !!n?.transcript, c = !!(a && Ve(a)), d = typeof window < "u" ? window.location.pathname : "/", f = typeof document < "u" ? document.title : "", p = d === "/" || d === "", m = null;
|
|
30046
30051
|
try {
|
|
@@ -30091,7 +30096,15 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30091
30096
|
let e = lO(u.current);
|
|
30092
30097
|
e && Ae(a, e);
|
|
30093
30098
|
} catch {}
|
|
30094
|
-
Ek(n, r)
|
|
30099
|
+
if (Ek(n, r)) {
|
|
30100
|
+
se("minimized");
|
|
30101
|
+
return;
|
|
30102
|
+
}
|
|
30103
|
+
te.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r) && (D.current += 1, D.current >= 3) && (u.current = [...u.current, {
|
|
30104
|
+
sender: "bot",
|
|
30105
|
+
message: "Looks like you are no longer active. I'm ending the session — you can resume it later when you want.",
|
|
30106
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
30107
|
+
}], se("minimized"));
|
|
30095
30108
|
}
|
|
30096
30109
|
},
|
|
30097
30110
|
onError: (t) => {
|
|
@@ -30104,7 +30117,7 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30104
30117
|
try {
|
|
30105
30118
|
C.current?.setMicMuted?.(!0);
|
|
30106
30119
|
} catch {}
|
|
30107
|
-
b(!0), v("error"),
|
|
30120
|
+
b(!0), v("error"), se("chat");
|
|
30108
30121
|
}
|
|
30109
30122
|
},
|
|
30110
30123
|
onDisconnect: (t) => {
|
|
@@ -30121,7 +30134,7 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30121
30134
|
try {
|
|
30122
30135
|
C.current?.setMicMuted?.(!0);
|
|
30123
30136
|
} catch {}
|
|
30124
|
-
b(!0),
|
|
30137
|
+
b(!0), se("chat");
|
|
30125
30138
|
}
|
|
30126
30139
|
});
|
|
30127
30140
|
if (e) {
|
|
@@ -30165,7 +30178,7 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30165
30178
|
r,
|
|
30166
30179
|
a,
|
|
30167
30180
|
s,
|
|
30168
|
-
|
|
30181
|
+
se
|
|
30169
30182
|
]), c(() => {
|
|
30170
30183
|
if (!x) return;
|
|
30171
30184
|
let e = (e) => {
|
|
@@ -30245,12 +30258,12 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30245
30258
|
onClick: async () => {
|
|
30246
30259
|
if (C.current) try {
|
|
30247
30260
|
if (y) {
|
|
30248
|
-
await C.current.setMicMuted?.(!1), b(!1);
|
|
30261
|
+
D.current = 0, await C.current.setMicMuted?.(!1), b(!1);
|
|
30249
30262
|
try {
|
|
30250
30263
|
C.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
30251
30264
|
} catch {}
|
|
30252
30265
|
} else {
|
|
30253
|
-
await C.current.setMicMuted?.(!0), b(!0);
|
|
30266
|
+
D.current = 0, await C.current.setMicMuted?.(!0), b(!0);
|
|
30254
30267
|
try {
|
|
30255
30268
|
C.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
|
|
30256
30269
|
} catch {}
|
|
@@ -30351,7 +30364,7 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30351
30364
|
children: [
|
|
30352
30365
|
/* @__PURE__ */ _("button", {
|
|
30353
30366
|
onClick: () => {
|
|
30354
|
-
S(!1), E.current = "chat",
|
|
30367
|
+
S(!1), E.current = "chat", ce(t);
|
|
30355
30368
|
},
|
|
30356
30369
|
style: {
|
|
30357
30370
|
display: "flex",
|
|
@@ -30380,7 +30393,7 @@ function Ak({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
|
|
|
30380
30393
|
}),
|
|
30381
30394
|
/* @__PURE__ */ _("button", {
|
|
30382
30395
|
onClick: () => {
|
|
30383
|
-
S(!1), E.current = "minimized",
|
|
30396
|
+
S(!1), E.current = "minimized", ce(n);
|
|
30384
30397
|
},
|
|
30385
30398
|
style: {
|
|
30386
30399
|
display: "flex",
|