@flowengage/react-chatbot 1.2.3 → 1.2.4
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.
|
@@ -24,7 +24,7 @@ var d = Object.defineProperty, f = (e, t) => {
|
|
|
24
24
|
agentName: "flowengage.agentName",
|
|
25
25
|
agentHeadshot: "flowengage.agentHeadshot",
|
|
26
26
|
visitorEmail: "flowengage.visitorEmail"
|
|
27
|
-
}, h = 1e4,
|
|
27
|
+
}, h = 1e4, ee = 6e4, g = 480 * 60, te = 3e4, _ = typeof window < "u", ne = (e) => e ? `flowengage.visitorEmail.${e}` : null, re = () => {
|
|
28
28
|
if (!_) return "server-chat-id";
|
|
29
29
|
let e = window.localStorage.getItem(m.chatId);
|
|
30
30
|
if (e) return e;
|
|
@@ -2075,8 +2075,8 @@ function mn(e, t = {}) {
|
|
|
2075
2075
|
}
|
|
2076
2076
|
let p = o.length >= 3 ? o : l.slice(-22);
|
|
2077
2077
|
if (p.length === 0) return null;
|
|
2078
|
-
let m = null, h = -1,
|
|
2079
|
-
for (let e of
|
|
2078
|
+
let m = null, h = -1, ee = a.querySelectorAll("h1, h2, h3, h4, h5, h6, p, li, blockquote, article");
|
|
2079
|
+
for (let e of ee) {
|
|
2080
2080
|
if (Qt(e)) continue;
|
|
2081
2081
|
try {
|
|
2082
2082
|
if (e.closest("aside, nav, [role='navigation'], footer")) continue;
|
|
@@ -2255,7 +2255,7 @@ function An({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2255
2255
|
cleanup: () => {}
|
|
2256
2256
|
}), ut = a(() => {
|
|
2257
2257
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? c?.widgetSettings?.call?.maxDurationSeconds ?? c?.callMaxDurationSeconds, t = Number(e);
|
|
2258
|
-
return Number.isFinite(t) && t > 0 ? t :
|
|
2258
|
+
return Number.isFinite(t) && t > 0 ? t : g;
|
|
2259
2259
|
}, [c, _]);
|
|
2260
2260
|
i(() => {
|
|
2261
2261
|
Ye.current = S;
|
|
@@ -2963,7 +2963,7 @@ function An({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2963
2963
|
} catch (e) {
|
|
2964
2964
|
b((e) => e.filter((e) => e.id !== i)), Ee(!1), e.status === 429 ? (Me(!0), Pe(e.message), window.setTimeout(() => {
|
|
2965
2965
|
Me(!1), Pe("");
|
|
2966
|
-
},
|
|
2966
|
+
}, ee)) : h(e);
|
|
2967
2967
|
} finally {
|
|
2968
2968
|
Ae(!1);
|
|
2969
2969
|
}
|
|
@@ -3439,7 +3439,7 @@ function Gn(t) {
|
|
|
3439
3439
|
};
|
|
3440
3440
|
}
|
|
3441
3441
|
function Kn({ logoUrl: t, brandName: n, agentName: r, fallbackAgentName: i, activeScreen: a, branding: o, isConversationEnded: s, closeWidget: d, isInitial: f, botLabel: p = "AI", agentAvatarUrl: m = null, primaryColor: h = "#3B82F6" }) {
|
|
3442
|
-
let { state:
|
|
3442
|
+
let { state: ee, resolvedLogoUrl: g } = Gn(t), te = a === "agent", _ = r || i || o?.fallbackAgentName || "Agent";
|
|
3443
3443
|
return /* @__PURE__ */ u("div", {
|
|
3444
3444
|
style: {
|
|
3445
3445
|
display: "flex",
|
|
@@ -3487,7 +3487,7 @@ function Kn({ logoUrl: t, brandName: n, agentName: r, fallbackAgentName: i, acti
|
|
|
3487
3487
|
},
|
|
3488
3488
|
initialsSpanStyle: { lineHeight: 1 }
|
|
3489
3489
|
})
|
|
3490
|
-
}) : /* @__PURE__ */ u(c, { children: [
|
|
3490
|
+
}) : /* @__PURE__ */ u(c, { children: [ee !== "loading" && (ee === "error" || !g && !t ? /* @__PURE__ */ l("div", {
|
|
3491
3491
|
className: "flowengage-logo-fallback",
|
|
3492
3492
|
style: {
|
|
3493
3493
|
width: "44px",
|
|
@@ -3521,7 +3521,7 @@ function Kn({ logoUrl: t, brandName: n, agentName: r, fallbackAgentName: i, acti
|
|
|
3521
3521
|
background: "#fff"
|
|
3522
3522
|
},
|
|
3523
3523
|
children: /* @__PURE__ */ l(t, {})
|
|
3524
|
-
}) :
|
|
3524
|
+
}) : ee === "wide" ? /* @__PURE__ */ l("div", {
|
|
3525
3525
|
style: {
|
|
3526
3526
|
height: "36px",
|
|
3527
3527
|
maxWidth: "88px",
|
|
@@ -3536,7 +3536,7 @@ function Kn({ logoUrl: t, brandName: n, agentName: r, fallbackAgentName: i, acti
|
|
|
3536
3536
|
border: f ? "none" : "1px solid rgba(0,0,0,0.05)"
|
|
3537
3537
|
},
|
|
3538
3538
|
children: /* @__PURE__ */ l("img", {
|
|
3539
|
-
src:
|
|
3539
|
+
src: g,
|
|
3540
3540
|
alt: "Logo",
|
|
3541
3541
|
style: {
|
|
3542
3542
|
height: "100%",
|
|
@@ -3558,16 +3558,16 @@ function Kn({ logoUrl: t, brandName: n, agentName: r, fallbackAgentName: i, acti
|
|
|
3558
3558
|
background: "#fff"
|
|
3559
3559
|
},
|
|
3560
3560
|
children: /* @__PURE__ */ l("img", {
|
|
3561
|
-
src:
|
|
3561
|
+
src: g,
|
|
3562
3562
|
alt: "Logo",
|
|
3563
3563
|
style: {
|
|
3564
3564
|
width: "100%",
|
|
3565
3565
|
height: "100%",
|
|
3566
3566
|
objectFit: "contain",
|
|
3567
|
-
padding:
|
|
3567
|
+
padding: g.toLowerCase().includes(".svg") || g.startsWith("data:image/svg") ? 0 : "2px"
|
|
3568
3568
|
}
|
|
3569
3569
|
})
|
|
3570
|
-
})),
|
|
3570
|
+
})), ee === "loading" && /* @__PURE__ */ l("div", { style: {
|
|
3571
3571
|
width: "44px",
|
|
3572
3572
|
height: "44px",
|
|
3573
3573
|
borderRadius: "9999px",
|
|
@@ -3704,7 +3704,7 @@ function Zn({ chatHistory: e, isAiTyping: t, isAgentTyping: n, setReplyContext:
|
|
|
3704
3704
|
},
|
|
3705
3705
|
children: [
|
|
3706
3706
|
e.map((e) => {
|
|
3707
|
-
let t = e.sender === "system", n = e.sender === "user", i = e.sender === "ai" || e.sender === "bot", a = e.sender === "agent", o = e.isPending, f = e.agent_name || e.agentName || e.metadata?.agentName || d, m = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof c == "string" && c.trim() || null, h = qn(e.replyToContent || e.replyContext?.message || ""),
|
|
3707
|
+
let t = e.sender === "system", n = e.sender === "user", i = e.sender === "ai" || e.sender === "bot", a = e.sender === "agent", o = e.isPending, f = e.agent_name || e.agentName || e.metadata?.agentName || d, m = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof c == "string" && c.trim() || null, h = qn(e.replyToContent || e.replyContext?.message || ""), ee = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
|
|
3708
3708
|
return t ? /* @__PURE__ */ l("div", {
|
|
3709
3709
|
style: {
|
|
3710
3710
|
display: "flex",
|
|
@@ -3822,7 +3822,7 @@ function Zn({ chatHistory: e, isAiTyping: t, isAgentTyping: n, setReplyContext:
|
|
|
3822
3822
|
marginBottom: "2px",
|
|
3823
3823
|
fontWeight: 600
|
|
3824
3824
|
},
|
|
3825
|
-
children:
|
|
3825
|
+
children: ee
|
|
3826
3826
|
}), /* @__PURE__ */ l("div", {
|
|
3827
3827
|
style: {
|
|
3828
3828
|
display: "-webkit-box",
|
|
@@ -4019,7 +4019,7 @@ function er({ greetings: e, recommendations: t, onSendMessage: n }) {
|
|
|
4019
4019
|
//#endregion
|
|
4020
4020
|
//#region src/components/ChatInput.jsx
|
|
4021
4021
|
function tr({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: c, clearReplyContext: d, requiresEmail: f, emailInput: p, setEmailInput: m, emailError: h }) {
|
|
4022
|
-
let
|
|
4022
|
+
let ee = c?.sender === "user" ? "You" : c?.sender === "agent" ? "Agent" : "AI Assistant", g = f ? !!p?.trim() : !!e?.trim(), te = s || !g;
|
|
4023
4023
|
return /* @__PURE__ */ u("div", {
|
|
4024
4024
|
style: {
|
|
4025
4025
|
padding: "0 20px 4px",
|
|
@@ -4065,7 +4065,7 @@ function tr({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
4065
4065
|
fontWeight: 600,
|
|
4066
4066
|
color: "var(--flowengage-primary)"
|
|
4067
4067
|
},
|
|
4068
|
-
children: ["Replying to ",
|
|
4068
|
+
children: ["Replying to ", ee]
|
|
4069
4069
|
}), /* @__PURE__ */ l("div", {
|
|
4070
4070
|
style: {
|
|
4071
4071
|
overflow: "hidden",
|
|
@@ -4281,7 +4281,7 @@ var nr = ({ muted: e = !1 }) => /* @__PURE__ */ u("svg", {
|
|
|
4281
4281
|
title: s || n,
|
|
4282
4282
|
children: [r, !a && /* @__PURE__ */ l("span", { children: n })]
|
|
4283
4283
|
});
|
|
4284
|
-
function ir({ webRTCError: e, micError: t, setMicError: r, dismissCallError: s, incomingCall: d, rejectCall: f, acceptCall: p, activeCallId: m, callConnectionState: h, formatCallDuration:
|
|
4284
|
+
function ir({ webRTCError: e, micError: t, setMicError: r, dismissCallError: s, incomingCall: d, rejectCall: f, acceptCall: p, activeCallId: m, callConnectionState: h, formatCallDuration: ee, callDurationSeconds: g, endWebRTCCall: te, isCallMuted: _, toggleCallMute: ne, isAIVoiceActive: re, currentCallAgentName: ie, isRateLimited: ae, rateLimitMessage: oe }) {
|
|
4285
4285
|
let se = o(null), v = n(() => {
|
|
4286
4286
|
if (!se.current) return;
|
|
4287
4287
|
let { audioContext: e, oscillator: t, interval: n, toneTimeout: r } = se.current;
|
|
@@ -4397,7 +4397,7 @@ function ir({ webRTCError: e, micError: t, setMicError: r, dismissCallError: s,
|
|
|
4397
4397
|
})]
|
|
4398
4398
|
}), /* @__PURE__ */ l("div", {
|
|
4399
4399
|
className: "call-timer",
|
|
4400
|
-
children: g
|
|
4400
|
+
children: ee(g)
|
|
4401
4401
|
})]
|
|
4402
4402
|
}), /* @__PURE__ */ u("div", {
|
|
4403
4403
|
className: "call-actions connected",
|
|
@@ -9643,7 +9643,7 @@ function xs() {
|
|
|
9643
9643
|
} catch {}
|
|
9644
9644
|
}
|
|
9645
9645
|
}
|
|
9646
|
-
function
|
|
9646
|
+
function ee(e) {
|
|
9647
9647
|
var t = e;
|
|
9648
9648
|
if (typeof t == "string" && o.levels[t.toUpperCase()] !== void 0 && (t = o.levels[t.toUpperCase()]), typeof t == "number" && t >= 0 && t <= o.levels.SILENT) return t;
|
|
9649
9649
|
throw TypeError("log.setLevel() called with invalid level: " + e);
|
|
@@ -9658,9 +9658,9 @@ function xs() {
|
|
|
9658
9658
|
}, o.methodFactory = n || d, o.getLevel = function() {
|
|
9659
9659
|
return u ?? c ?? s;
|
|
9660
9660
|
}, o.setLevel = function(e, t) {
|
|
9661
|
-
return u =
|
|
9661
|
+
return u = ee(e), t !== !1 && p(u), l.call(o);
|
|
9662
9662
|
}, o.setDefaultLevel = function(e) {
|
|
9663
|
-
c =
|
|
9663
|
+
c = ee(e), m() || o.setLevel(e, !1);
|
|
9664
9664
|
}, o.resetLevel = function() {
|
|
9665
9665
|
u = null, h(), l.call(o);
|
|
9666
9666
|
}, o.enableAll = function(e) {
|
|
@@ -9668,10 +9668,10 @@ function xs() {
|
|
|
9668
9668
|
}, o.disableAll = function(e) {
|
|
9669
9669
|
o.setLevel(o.levels.SILENT, e);
|
|
9670
9670
|
}, o.rebuild = function() {
|
|
9671
|
-
if (a !== o && (s =
|
|
9672
|
-
}, s =
|
|
9673
|
-
var
|
|
9674
|
-
|
|
9671
|
+
if (a !== o && (s = ee(a.getLevel())), l.call(o), a === o) for (var e in i) i[e].rebuild();
|
|
9672
|
+
}, s = ee(a ? a.getLevel() : "WARN");
|
|
9673
|
+
var g = m();
|
|
9674
|
+
g != null && (u = ee(g)), l.call(o);
|
|
9675
9675
|
}
|
|
9676
9676
|
a = new f(), a.getLogger = function(e) {
|
|
9677
9677
|
if (typeof e != "symbol" && typeof e != "string" || e === "") throw TypeError("You must supply a name when creating a logger.");
|
|
@@ -9870,7 +9870,7 @@ function Rs() {
|
|
|
9870
9870
|
function a() {
|
|
9871
9871
|
a.init.call(this);
|
|
9872
9872
|
}
|
|
9873
|
-
Is.exports = a, Is.exports.once =
|
|
9873
|
+
Is.exports = a, Is.exports.once = g, a.EventEmitter = a, a.prototype._events = void 0, a.prototype._eventsCount = 0, a.prototype._maxListeners = void 0;
|
|
9874
9874
|
var o = 10;
|
|
9875
9875
|
function s(e) {
|
|
9876
9876
|
if (typeof e != "function") throw TypeError("The \"listener\" argument must be of type Function. Received type " + typeof e);
|
|
@@ -9974,7 +9974,7 @@ function Rs() {
|
|
|
9974
9974
|
var r = e._events;
|
|
9975
9975
|
if (r === void 0) return [];
|
|
9976
9976
|
var i = r[t];
|
|
9977
|
-
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ?
|
|
9977
|
+
return i === void 0 ? [] : typeof i == "function" ? n ? [i.listener || i] : [i] : n ? ee(i) : m(i, i.length);
|
|
9978
9978
|
}
|
|
9979
9979
|
a.prototype.listeners = function(e) {
|
|
9980
9980
|
return f(this, e, !0);
|
|
@@ -10003,11 +10003,11 @@ function Rs() {
|
|
|
10003
10003
|
for (; t + 1 < e.length; t++) e[t] = e[t + 1];
|
|
10004
10004
|
e.pop();
|
|
10005
10005
|
}
|
|
10006
|
-
function
|
|
10006
|
+
function ee(e) {
|
|
10007
10007
|
for (var t = Array(e.length), n = 0; n < t.length; ++n) t[n] = e[n].listener || e[n];
|
|
10008
10008
|
return t;
|
|
10009
10009
|
}
|
|
10010
|
-
function
|
|
10010
|
+
function g(e, t) {
|
|
10011
10011
|
return new Promise(function(n, r) {
|
|
10012
10012
|
function i(n) {
|
|
10013
10013
|
e.removeListener(t, a), r(n);
|
|
@@ -19280,7 +19280,7 @@ var eh = class extends Qm {
|
|
|
19280
19280
|
i(/* @__PURE__ */ Error("agent not active within 10 seconds"));
|
|
19281
19281
|
}, 1e4), h = yield this.waitUntilActiveAgentPresent();
|
|
19282
19282
|
clearTimeout(m), this.log.debug("sending preconnect buffer", Object.assign(Object.assign({}, this.logContext), H(e)));
|
|
19283
|
-
let
|
|
19283
|
+
let ee = yield this.streamBytes({
|
|
19284
19284
|
name: "preconnect-buffer",
|
|
19285
19285
|
mimeType: n,
|
|
19286
19286
|
topic: "lk.agent.pre-connect-audio-buffer",
|
|
@@ -19295,7 +19295,7 @@ var eh = class extends Qm {
|
|
|
19295
19295
|
for (var u = !0, d = Fs(t), p; p = yield d.next(), a = p.done, !a; u = !0) {
|
|
19296
19296
|
l = p.value, u = !1;
|
|
19297
19297
|
let e = l;
|
|
19298
|
-
yield
|
|
19298
|
+
yield ee.write(e);
|
|
19299
19299
|
}
|
|
19300
19300
|
} catch (e) {
|
|
19301
19301
|
s = { error: e };
|
|
@@ -19306,7 +19306,7 @@ var eh = class extends Qm {
|
|
|
19306
19306
|
if (s) throw s.error;
|
|
19307
19307
|
}
|
|
19308
19308
|
}
|
|
19309
|
-
yield
|
|
19309
|
+
yield ee.close(), r();
|
|
19310
19310
|
} catch (e) {
|
|
19311
19311
|
i(e);
|
|
19312
19312
|
}
|
|
@@ -23406,56 +23406,57 @@ function S_(e, t) {
|
|
|
23406
23406
|
let n = (t || "").trim();
|
|
23407
23407
|
return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || /\b(that'?s all|we'?re done)\b/i.test(n) || e === "bot" && (/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n)) || /^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)) : !1;
|
|
23408
23408
|
}
|
|
23409
|
-
function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m, voicePageHighlightMode: h = "speech" }) {
|
|
23410
|
-
let [g,
|
|
23411
|
-
|
|
23409
|
+
function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, historyRef: d, hasSyncedRef: f, onMessageSync: p, onStartSync: m, voicePageHighlightMode: h = "speech", priorChatContext: ee = "" }) {
|
|
23410
|
+
let [g, te] = s("idle"), [_, ne] = s(null), [re, ie] = s(!1), ae = o(null), oe = o(null), se = o(""), v = o(async () => {}), ce = o(!1), le = o(""), ue = o(null), y = o(null), b = o(null), de = o(!1), fe = o(!1), pe = o(0), me = o(null), he = n(() => {
|
|
23411
|
+
y.current &&= (clearTimeout(y.current), null), le.current = "", ue.current = null, de.current = !1, fe.current = !1, pe.current = 0, me.current = null, b.current != null && (cancelAnimationFrame(b.current), b.current = null);
|
|
23412
23412
|
try {
|
|
23413
23413
|
vn();
|
|
23414
23414
|
} catch {}
|
|
23415
|
-
}, []),
|
|
23416
|
-
|
|
23415
|
+
}, []), ge = n(async () => {
|
|
23416
|
+
he();
|
|
23417
23417
|
try {
|
|
23418
|
-
await
|
|
23418
|
+
await ae.current?.endSession?.();
|
|
23419
23419
|
} catch {}
|
|
23420
|
-
|
|
23420
|
+
ae.current = null, ie(!1), te("idle"), ce.current = !1, typeof p == "function" && await p(d.current), typeof c == "function" && c();
|
|
23421
23421
|
}, [
|
|
23422
|
-
|
|
23422
|
+
he,
|
|
23423
23423
|
d,
|
|
23424
23424
|
p,
|
|
23425
23425
|
c
|
|
23426
23426
|
]);
|
|
23427
|
-
|
|
23427
|
+
v.current = ge, i(() => {
|
|
23428
23428
|
let t = !1, n = null;
|
|
23429
23429
|
return (async () => {
|
|
23430
|
+
let i = typeof ee == "string" ? ee.trim() : "";
|
|
23430
23431
|
try {
|
|
23431
23432
|
if (await navigator.mediaDevices.getUserMedia({ audio: !0 }), t) return;
|
|
23432
|
-
d.current = [],
|
|
23433
|
-
let
|
|
23433
|
+
d.current = [], se.current = "", ce.current = !1, de.current = !1, fe.current = !1;
|
|
23434
|
+
let o = h === "transcript" || h === "speech", s = __(g_({
|
|
23434
23435
|
siteId: r || null,
|
|
23435
23436
|
apiBaseUrl: a || null,
|
|
23436
|
-
getLastUserVoiceText: () =>
|
|
23437
|
+
getLastUserVoiceText: () => se.current,
|
|
23437
23438
|
voicePageHighlightMode: h,
|
|
23438
23439
|
markHostPageReading: () => {
|
|
23439
|
-
|
|
23440
|
+
fe.current = !0;
|
|
23440
23441
|
},
|
|
23441
23442
|
markExplicitToolHighlight: () => {
|
|
23442
|
-
|
|
23443
|
+
pe.current = Date.now() + 4500;
|
|
23443
23444
|
},
|
|
23444
23445
|
requestEndSession: () => {
|
|
23445
23446
|
queueMicrotask(() => {
|
|
23446
|
-
|
|
23447
|
+
ce.current || (ce.current = !0, v.current?.());
|
|
23447
23448
|
});
|
|
23448
23449
|
}
|
|
23449
|
-
})),
|
|
23450
|
+
})), c = () => {
|
|
23450
23451
|
try {
|
|
23451
|
-
if (!
|
|
23452
|
-
let e =
|
|
23453
|
-
if (!e?.trim() ||
|
|
23452
|
+
if (!o) return;
|
|
23453
|
+
let e = le.current;
|
|
23454
|
+
if (!e?.trim() || ue.current == null || e.trim().length < 12 || !(de.current || fe.current || e.trim().length >= 40) || Date.now() < pe.current) return;
|
|
23454
23455
|
rn();
|
|
23455
23456
|
let t = mn(e, { strict: !1 }), n = t ? hn(t) : null;
|
|
23456
23457
|
if (n) {
|
|
23457
23458
|
let e = !1;
|
|
23458
|
-
|
|
23459
|
+
me.current !== n && (e = gn(n), me.current = n), _n(n, {
|
|
23459
23460
|
speaking: !0,
|
|
23460
23461
|
scroll: e
|
|
23461
23462
|
});
|
|
@@ -23463,79 +23464,79 @@ function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23463
23464
|
} catch (e) {
|
|
23464
23465
|
console.warn("[VoiceInterface] block highlight failed", e?.message);
|
|
23465
23466
|
}
|
|
23466
|
-
},
|
|
23467
|
-
if (!
|
|
23468
|
-
|
|
23469
|
-
let t = (
|
|
23467
|
+
}, l = (e = !1) => {
|
|
23468
|
+
if (!o) return;
|
|
23469
|
+
y.current && clearTimeout(y.current);
|
|
23470
|
+
let t = (le.current || "").trim();
|
|
23470
23471
|
if (t.length < 10) return;
|
|
23471
23472
|
let n = /[.!?]["']?\s*$/.test(t), r = e ? 0 : n && t.length >= 24 ? x_ : b_;
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
|
|
23473
|
+
y.current = setTimeout(() => {
|
|
23474
|
+
y.current = null, b.current != null && cancelAnimationFrame(b.current), b.current = requestAnimationFrame(() => {
|
|
23475
|
+
b.current = null, c();
|
|
23475
23476
|
});
|
|
23476
23477
|
}, r);
|
|
23477
|
-
},
|
|
23478
|
+
}, u = await Uh.startSession({
|
|
23478
23479
|
agentId: e,
|
|
23479
|
-
clientTools:
|
|
23480
|
+
clientTools: s,
|
|
23480
23481
|
onUnhandledClientToolCall: (e) => {
|
|
23481
23482
|
console.error("[VoiceInterface] ElevenLabs requested a client tool that is not registered in the widget:", e?.tool_name, e?.parameters, "Add a matching handler in voiceClientTools (snake_case and camelCase are both supported).");
|
|
23482
23483
|
},
|
|
23483
23484
|
onModeChange: ({ mode: e }) => {
|
|
23484
|
-
t ||
|
|
23485
|
+
t || te(e === "speaking" ? "speaking" : "listening");
|
|
23485
23486
|
},
|
|
23486
23487
|
onAgentChatResponsePart: (e) => {
|
|
23487
23488
|
if (t) return;
|
|
23488
|
-
let n = e?.text_response_part ?? e, r = n?.type,
|
|
23489
|
-
r === "start" ? (
|
|
23489
|
+
let n = e?.text_response_part ?? e, r = n?.type, i = n?.text ?? "";
|
|
23490
|
+
r === "start" ? (y.current &&= (clearTimeout(y.current), null), b.current != null && (cancelAnimationFrame(b.current), b.current = null), me.current = null, le.current = i, ue.current = Date.now()) : r === "delta" ? (le.current += i, ue.current ??= Date.now()) : r === "stop" ? le.current += i : (le.current += i, ue.current == null && i && (ue.current = Date.now())), o && le.current.trim().length >= 10 && l(r === "stop");
|
|
23490
23491
|
},
|
|
23491
23492
|
onInterruption: () => {
|
|
23492
|
-
|
|
23493
|
+
he();
|
|
23493
23494
|
},
|
|
23494
23495
|
onMessage: (e) => {
|
|
23495
23496
|
if (t) return;
|
|
23496
23497
|
let n = e.role === "user" ? "user" : "bot", r = e.message || e.text || e.content || "";
|
|
23497
23498
|
if (!r) return;
|
|
23498
|
-
let
|
|
23499
|
+
let i = {
|
|
23499
23500
|
sender: n,
|
|
23500
23501
|
message: r,
|
|
23501
23502
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
23502
23503
|
};
|
|
23503
|
-
if (n === "user")
|
|
23504
|
-
else if (n === "bot" && r.trim() &&
|
|
23504
|
+
if (n === "user") se.current = r, r.trim().length >= 1 && (de.current = !0);
|
|
23505
|
+
else if (n === "bot" && r.trim() && o && (de.current || fe.current)) {
|
|
23505
23506
|
let e = r.trim();
|
|
23506
|
-
e.length > (
|
|
23507
|
+
e.length > (le.current?.length || 0) && (le.current = e, ue.current ??= Date.now(), e.length >= 10 && l(!1));
|
|
23507
23508
|
}
|
|
23508
|
-
d.current = [...d.current,
|
|
23509
|
-
|
|
23509
|
+
d.current = [...d.current, i], S_(n, r) && queueMicrotask(() => {
|
|
23510
|
+
ce.current || (ce.current = !0, v.current?.());
|
|
23510
23511
|
});
|
|
23511
23512
|
},
|
|
23512
23513
|
onError: (e) => {
|
|
23513
|
-
t || (console.error("[VoiceInterface] ElevenLabs error", e),
|
|
23514
|
+
t || (console.error("[VoiceInterface] ElevenLabs error", e), he(), te("error"), ne("Voice session encountered an error."));
|
|
23514
23515
|
},
|
|
23515
23516
|
onDisconnect: () => {
|
|
23516
|
-
t || (console.log("[VoiceInterface] session disconnected"),
|
|
23517
|
+
t || (console.log("[VoiceInterface] session disconnected"), he(), ie(!1), te("idle"));
|
|
23517
23518
|
}
|
|
23518
23519
|
});
|
|
23519
23520
|
if (t) {
|
|
23520
|
-
|
|
23521
|
+
u.endSession().catch(() => {});
|
|
23521
23522
|
return;
|
|
23522
23523
|
}
|
|
23523
|
-
n =
|
|
23524
|
+
n = u, ae.current = u, ie(!0), te("listening");
|
|
23524
23525
|
try {
|
|
23525
23526
|
let e = typeof window < "u" ? window.location.href : "", t = "";
|
|
23526
23527
|
try {
|
|
23527
|
-
t = await
|
|
23528
|
+
t = await s.list_page_forms();
|
|
23528
23529
|
} catch {
|
|
23529
23530
|
t = "[]";
|
|
23530
23531
|
}
|
|
23531
|
-
|
|
23532
|
+
u.sendContextualUpdate(`Current page URL: ${e}. Site ID: ${r || "unknown"}. Page fields/buttons JSON: ${t}. Navigation: when the user wants to go to any page (contact, pricing, about, services, etc.), call search_site_content then navigate_to_page immediately — never ask permission. After navigating to a page with a form, call list_page_forms and proactively start helping the user fill it. Contact / lead forms: use only the main contact form (Full Name, Email, Message). Ignore footer or secondary marketing URL fields unless the user explicitly asks to use them. Fill in order: name → email → message. Message must be a short visitor note (what they want from the team), not a transcript of the conversation. Forms: use fill_form_fields then click_page_button (e.g. Send Message) when appropriate. Fill each field right after the user gives that value — do not click submit until required fields are filled. ` + (o ? "On-page reading: the widget highlights host regions from your speech (debounced). For a precise block, call highlight_on_page({ section_text: \"...\" }) using visible headings or labels on the page, or read_page_content({ section_text: \"...\" }). " : "On-page reading: highlight the correct section by calling highlight_on_page({ section_text: \"...\" }) with visible heading/plan text, or read_page_content({ section_text: \"...\" }) when reading a specific section — the UI follows tool targets, not loose speech. ") + "Voice: if the user wants to end the voice session, call end_voice_session or confirm and end."), i && u.sendContextualUpdate(`Prior messages in this chat (same conversation thread). Continue naturally; do not repeat verbatim unless the user asks.\n${i}`);
|
|
23532
23533
|
} catch {}
|
|
23533
23534
|
typeof m == "function" && m();
|
|
23534
23535
|
} catch (e) {
|
|
23535
|
-
t || (console.error("[VoiceInterface] startSession failed", e),
|
|
23536
|
+
t || (console.error("[VoiceInterface] startSession failed", e), te("error"), ne("Could not start voice session. Please try again."));
|
|
23536
23537
|
}
|
|
23537
23538
|
})(), () => {
|
|
23538
|
-
t = !0,
|
|
23539
|
+
t = !0, he(), n ? n.endSession().catch(() => {}) : ae.current && ae.current.endSession().catch(() => {});
|
|
23539
23540
|
};
|
|
23540
23541
|
}, [
|
|
23541
23542
|
e,
|
|
@@ -23543,12 +23544,12 @@ function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23543
23544
|
a,
|
|
23544
23545
|
d,
|
|
23545
23546
|
m,
|
|
23546
|
-
|
|
23547
|
+
he,
|
|
23547
23548
|
h
|
|
23548
23549
|
]);
|
|
23549
|
-
let
|
|
23550
|
+
let _e = g === "listening" || g === "speaking", ve = y_[g] || y_.idle, ye = v_[g] || v_.idle;
|
|
23550
23551
|
return /* @__PURE__ */ u("div", {
|
|
23551
|
-
ref:
|
|
23552
|
+
ref: oe,
|
|
23552
23553
|
style: {
|
|
23553
23554
|
display: "flex",
|
|
23554
23555
|
flexDirection: "column",
|
|
@@ -23570,19 +23571,19 @@ function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23570
23571
|
justifyContent: "center"
|
|
23571
23572
|
},
|
|
23572
23573
|
children: [
|
|
23573
|
-
|
|
23574
|
+
_e && /* @__PURE__ */ l("div", { style: {
|
|
23574
23575
|
position: "absolute",
|
|
23575
23576
|
inset: "-16px",
|
|
23576
23577
|
borderRadius: "50%",
|
|
23577
|
-
border: `2px solid ${
|
|
23578
|
+
border: `2px solid ${ve}`,
|
|
23578
23579
|
animation: "fe-orb-pulse 1.4s ease-in-out infinite",
|
|
23579
23580
|
opacity: .6
|
|
23580
23581
|
} }),
|
|
23581
|
-
|
|
23582
|
+
_e && /* @__PURE__ */ l("div", { style: {
|
|
23582
23583
|
position: "absolute",
|
|
23583
23584
|
inset: "-8px",
|
|
23584
23585
|
borderRadius: "50%",
|
|
23585
|
-
border: `2px solid ${
|
|
23586
|
+
border: `2px solid ${ve}`,
|
|
23586
23587
|
animation: "fe-orb-pulse 1.4s ease-in-out 0.35s infinite",
|
|
23587
23588
|
opacity: .4
|
|
23588
23589
|
} }),
|
|
@@ -23591,18 +23592,18 @@ function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23591
23592
|
width: "140px",
|
|
23592
23593
|
height: "140px",
|
|
23593
23594
|
borderRadius: "50%",
|
|
23594
|
-
background:
|
|
23595
|
-
border: `3px solid ${
|
|
23595
|
+
background: ye,
|
|
23596
|
+
border: `3px solid ${ve}`,
|
|
23596
23597
|
display: "flex",
|
|
23597
23598
|
alignItems: "center",
|
|
23598
23599
|
justifyContent: "center",
|
|
23599
23600
|
transition: "all 0.35s ease",
|
|
23600
23601
|
transform: g === "speaking" ? "scale(1.08)" : "scale(1)",
|
|
23601
|
-
boxShadow: `0 0 40px ${
|
|
23602
|
+
boxShadow: `0 0 40px ${ye}, 0 8px 32px rgba(0,0,0,0.08)`
|
|
23602
23603
|
},
|
|
23603
23604
|
children: /* @__PURE__ */ l(Nn, {
|
|
23604
23605
|
size: 44,
|
|
23605
|
-
color:
|
|
23606
|
+
color: ve
|
|
23606
23607
|
})
|
|
23607
23608
|
})
|
|
23608
23609
|
]
|
|
@@ -23619,11 +23620,11 @@ function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23619
23620
|
g === "idle" && "Starting voice session…",
|
|
23620
23621
|
g === "listening" && "Listening…",
|
|
23621
23622
|
g === "speaking" && "AI is speaking…",
|
|
23622
|
-
g === "error" && (
|
|
23623
|
+
g === "error" && (_ || "Error")
|
|
23623
23624
|
]
|
|
23624
23625
|
}),
|
|
23625
23626
|
/* @__PURE__ */ u("button", {
|
|
23626
|
-
onClick:
|
|
23627
|
+
onClick: ge,
|
|
23627
23628
|
style: {
|
|
23628
23629
|
display: "flex",
|
|
23629
23630
|
alignItems: "center",
|
|
@@ -23651,8 +23652,25 @@ function C_({ agentId: e, chatId: t, siteId: r, apiBaseUrl: a, onEnd: c, history
|
|
|
23651
23652
|
});
|
|
23652
23653
|
}
|
|
23653
23654
|
//#endregion
|
|
23655
|
+
//#region src/utils/voicePriorContext.js
|
|
23656
|
+
function w_(e, t = {}) {
|
|
23657
|
+
let n = t.maxChars ?? 4500;
|
|
23658
|
+
if (!Array.isArray(e) || e.length === 0) return "";
|
|
23659
|
+
let r = [];
|
|
23660
|
+
for (let t of e) {
|
|
23661
|
+
if (!t || t.isPending) continue;
|
|
23662
|
+
let e = String(t.sender || "").toLowerCase(), n = null;
|
|
23663
|
+
if (e === "user" ? n = "Visitor" : (e === "bot" || e === "ai" || e === "agent") && (n = "Assistant"), !n) continue;
|
|
23664
|
+
let i = String(t.message || "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim().slice(0, 1200);
|
|
23665
|
+
i && r.push(`${n}: ${i}`);
|
|
23666
|
+
}
|
|
23667
|
+
if (r.length === 0) return "";
|
|
23668
|
+
let i = r.join("\n");
|
|
23669
|
+
return i.length > n && (i = "…(earlier messages omitted)\n" + i.slice(-n)), i;
|
|
23670
|
+
}
|
|
23671
|
+
//#endregion
|
|
23654
23672
|
//#region src/components/FlowEngageWidget.jsx
|
|
23655
|
-
var
|
|
23673
|
+
var T_ = [
|
|
23656
23674
|
{
|
|
23657
23675
|
key: "become_client",
|
|
23658
23676
|
label: "Become a Client"
|
|
@@ -23673,7 +23691,7 @@ var w_ = [
|
|
|
23673
23691
|
key: "looking_for_job",
|
|
23674
23692
|
label: "Looking for a Job"
|
|
23675
23693
|
}
|
|
23676
|
-
],
|
|
23694
|
+
], E_ = () => /* @__PURE__ */ l("div", {
|
|
23677
23695
|
style: {
|
|
23678
23696
|
display: "flex",
|
|
23679
23697
|
marginBottom: "12px",
|
|
@@ -23704,8 +23722,8 @@ var w_ = [
|
|
|
23704
23722
|
} }, e)), /* @__PURE__ */ l("style", { children: "\n @keyframes fe-dot-bounce {\n 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }\n 40% { transform: translateY(-5px); opacity: 1; }\n }\n " })]
|
|
23705
23723
|
})
|
|
23706
23724
|
});
|
|
23707
|
-
function
|
|
23708
|
-
let { status: e, runtimeConfig: t, resolvedConfig: n, chatId: r, chatHistory: o, isOpen: c, activeScreen: d, isHumanHandled: f, agentName: p, agentHeadshot: m, visitorEmail: h, isAgentTyping:
|
|
23725
|
+
function D_() {
|
|
23726
|
+
let { status: e, runtimeConfig: t, resolvedConfig: n, chatId: r, chatHistory: o, isOpen: c, activeScreen: d, isHumanHandled: f, agentName: p, agentHeadshot: m, visitorEmail: h, isAgentTyping: ee, isAiTyping: g, isLoading: te, isVoiceMode: _, isRateLimited: ne, rateLimitMessage: re, isConversationEnded: ie, incomingCall: ae, activeCallId: oe, callConnectionState: se, callConnectedAt: v, isCallMuted: ce, webRTCError: le, language: ue, historyRef: y, onMessageSync: b, endConversation: de, acceptCall: fe, rejectCall: pe, endWebRTCCall: me, toggleCallMute: he, dismissCallError: ge, captureVisitorEmail: _e, openWidget: ve, closeWidget: ye, sendMessage: be, setVoiceMode: xe, startTyping: Se, stopTyping: Ce, updateTypingDraft: we } = Xt(), [Te, Ee] = s(""), [De, Oe] = s(null), [ke, Ae] = s(null), [je, Me] = s(null), [Ne, Pe] = s(0), [x, Fe] = s(h || ""), [Ie, Le] = s("");
|
|
23709
23727
|
i(() => {
|
|
23710
23728
|
try {
|
|
23711
23729
|
nn();
|
|
@@ -23732,10 +23750,10 @@ function E_() {
|
|
|
23732
23750
|
outline: "none",
|
|
23733
23751
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
23734
23752
|
...c ? {} : Ue
|
|
23735
|
-
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] ||
|
|
23753
|
+
}, Ge = S.recommendations?.[ue] || Re.recommendations?.[ue] || T_, Ke = S.greetings?.[ue] || Re.greetings?.[ue], qe = ze.chatButtonText || "Chat with us", Je = ze.headerName || t?.websiteName || "OpenSense Labs", C = ze.logoUrl || null, w = ze.hideWatermark || !1, T = Re.elevenLabsAgentId || t?.elevenLabsAgentId || null, Ye = t?.siteId || n?.siteId || null, Xe = t?.apiBaseUrl || "", Ze = ze.fallbackAgentName || "Agent", Qe = ze.botLabel || "AI", $e = m && String(m).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, et = ae?.agentName || p || Ze, tt = o.some((e) => e.sender === "user"), nt = a(() => {
|
|
23736
23754
|
let e = o.findIndex((e) => e.sender === "user");
|
|
23737
23755
|
return e === -1 ? !1 : o.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
23738
|
-
}, [o]), rt = !h && tt && nt;
|
|
23756
|
+
}, [o]), rt = a(() => w_(o), [o]), it = !h && tt && nt;
|
|
23739
23757
|
i(() => {
|
|
23740
23758
|
Fe(h || ""), h && Le("");
|
|
23741
23759
|
}, [h]), i(() => {
|
|
@@ -23777,13 +23795,13 @@ function E_() {
|
|
|
23777
23795
|
Ce,
|
|
23778
23796
|
we
|
|
23779
23797
|
]);
|
|
23780
|
-
let
|
|
23798
|
+
let at = (e) => e ? {
|
|
23781
23799
|
replyTo: e.messageId || e.id || null,
|
|
23782
23800
|
replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
|
|
23783
23801
|
replyToSender: e.sender || null
|
|
23784
|
-
} : null,
|
|
23802
|
+
} : null, ot = async (e) => {
|
|
23785
23803
|
if (e.preventDefault(), ie) return;
|
|
23786
|
-
if (
|
|
23804
|
+
if (it) {
|
|
23787
23805
|
let e = x.trim().toLowerCase();
|
|
23788
23806
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
23789
23807
|
Le("Please enter a valid email so we can continue helping you.");
|
|
@@ -23793,10 +23811,10 @@ function E_() {
|
|
|
23793
23811
|
return;
|
|
23794
23812
|
}
|
|
23795
23813
|
if (!Te.trim()) return;
|
|
23796
|
-
let t = Te.trim(), n =
|
|
23814
|
+
let t = Te.trim(), n = at(je);
|
|
23797
23815
|
Ee(""), Me(null), await be(t, "", n);
|
|
23798
|
-
},
|
|
23799
|
-
if (
|
|
23816
|
+
}, st = async () => {
|
|
23817
|
+
if (it) {
|
|
23800
23818
|
Le("Please share your email before starting a call.");
|
|
23801
23819
|
return;
|
|
23802
23820
|
}
|
|
@@ -23810,9 +23828,9 @@ function E_() {
|
|
|
23810
23828
|
} catch (e) {
|
|
23811
23829
|
Ae(e.message || "Could not access microphone.");
|
|
23812
23830
|
}
|
|
23813
|
-
},
|
|
23831
|
+
}, ct = () => {
|
|
23814
23832
|
De && (De.getTracks().forEach((e) => e.stop()), Oe(null)), xe(!1);
|
|
23815
|
-
},
|
|
23833
|
+
}, lt = (e) => {
|
|
23816
23834
|
let t = Math.floor(e / 60), n = e % 60;
|
|
23817
23835
|
return `${t.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
|
|
23818
23836
|
};
|
|
@@ -23867,7 +23885,8 @@ function E_() {
|
|
|
23867
23885
|
apiBaseUrl: Xe,
|
|
23868
23886
|
historyRef: y,
|
|
23869
23887
|
onMessageSync: b,
|
|
23870
|
-
onEnd:
|
|
23888
|
+
onEnd: ct,
|
|
23889
|
+
priorChatContext: rt
|
|
23871
23890
|
})
|
|
23872
23891
|
}, "voice") : o.length === 0 ? /* @__PURE__ */ l("div", {
|
|
23873
23892
|
style: {
|
|
@@ -23890,10 +23909,10 @@ function E_() {
|
|
|
23890
23909
|
className: "fe-screen-fade-in",
|
|
23891
23910
|
children: /* @__PURE__ */ l(Zn, {
|
|
23892
23911
|
chatHistory: o,
|
|
23893
|
-
isAiTyping:
|
|
23894
|
-
isAgentTyping:
|
|
23912
|
+
isAiTyping: g,
|
|
23913
|
+
isAgentTyping: ee,
|
|
23895
23914
|
setReplyContext: Me,
|
|
23896
|
-
TypingDots:
|
|
23915
|
+
TypingDots: E_,
|
|
23897
23916
|
primaryColor: Ve,
|
|
23898
23917
|
agentHeadshot: $e,
|
|
23899
23918
|
agentDisplayName: p || Ze
|
|
@@ -23910,7 +23929,7 @@ function E_() {
|
|
|
23910
23929
|
acceptCall: fe,
|
|
23911
23930
|
activeCallId: oe,
|
|
23912
23931
|
callConnectionState: se,
|
|
23913
|
-
formatCallDuration:
|
|
23932
|
+
formatCallDuration: lt,
|
|
23914
23933
|
callDurationSeconds: Ne,
|
|
23915
23934
|
endWebRTCCall: me,
|
|
23916
23935
|
isCallMuted: ce,
|
|
@@ -23928,15 +23947,15 @@ function E_() {
|
|
|
23928
23947
|
children: /* @__PURE__ */ l(tr, {
|
|
23929
23948
|
input: Te,
|
|
23930
23949
|
setInput: Ee,
|
|
23931
|
-
onSubmit:
|
|
23950
|
+
onSubmit: ot,
|
|
23932
23951
|
isConversationEnded: ie,
|
|
23933
23952
|
callUiActive: !!(ae || oe),
|
|
23934
|
-
handleToggleVoice:
|
|
23953
|
+
handleToggleVoice: st,
|
|
23935
23954
|
activeScreen: d,
|
|
23936
23955
|
inputDisabled: te || ne || ie,
|
|
23937
23956
|
replyContext: je,
|
|
23938
23957
|
clearReplyContext: () => Me(null),
|
|
23939
|
-
requiresEmail:
|
|
23958
|
+
requiresEmail: it,
|
|
23940
23959
|
emailInput: x,
|
|
23941
23960
|
setEmailInput: Fe,
|
|
23942
23961
|
emailError: Ie
|
|
@@ -23972,4 +23991,4 @@ function E_() {
|
|
|
23972
23991
|
}) : null;
|
|
23973
23992
|
}
|
|
23974
23993
|
//#endregion
|
|
23975
|
-
export { An as FlowEngageProvider,
|
|
23994
|
+
export { An as FlowEngageProvider, D_ as FlowEngageWidget, Xt as useFlowEngage };
|