@flowengage/react-chatbot 7.0.29 → 8.0.0
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.
|
@@ -509,7 +509,7 @@ var j = (e) => {
|
|
|
509
509
|
}, it = typeof ArrayBuffer == "function", at = (e, t) => {
|
|
510
510
|
if (typeof e != "string") return {
|
|
511
511
|
type: "message",
|
|
512
|
-
data:
|
|
512
|
+
data: st(e, t)
|
|
513
513
|
};
|
|
514
514
|
let n = e.charAt(0);
|
|
515
515
|
return n === "b" ? {
|
|
@@ -519,23 +519,23 @@ var j = (e) => {
|
|
|
519
519
|
type: qe[n],
|
|
520
520
|
data: e.substring(1)
|
|
521
521
|
} : { type: qe[n] } : Je;
|
|
522
|
-
}, ot = (e, t) => it ?
|
|
522
|
+
}, ot = (e, t) => it ? st(j(e), t) : {
|
|
523
523
|
base64: !0,
|
|
524
524
|
data: e
|
|
525
|
-
},
|
|
525
|
+
}, st = (e, t) => {
|
|
526
526
|
switch (t) {
|
|
527
527
|
case "blob": return e instanceof Blob ? e : new Blob([e]);
|
|
528
528
|
default: return e instanceof ArrayBuffer ? e : e.buffer;
|
|
529
529
|
}
|
|
530
|
-
},
|
|
530
|
+
}, ct = "", M = (e, t) => {
|
|
531
531
|
let n = e.length, r = Array(n), i = 0;
|
|
532
532
|
e.forEach((e, a) => {
|
|
533
533
|
Qe(e, !1, (e) => {
|
|
534
|
-
r[a] = e, ++i === n && t(r.join(
|
|
534
|
+
r[a] = e, ++i === n && t(r.join(ct));
|
|
535
535
|
});
|
|
536
536
|
});
|
|
537
537
|
}, lt = (e, t) => {
|
|
538
|
-
let n = e.split(
|
|
538
|
+
let n = e.split(ct), r = [];
|
|
539
539
|
for (let e = 0; e < n.length; e++) {
|
|
540
540
|
let i = at(n[e], t);
|
|
541
541
|
if (r.push(i), i.type === "error") break;
|
|
@@ -771,7 +771,7 @@ var kt = class extends Error {
|
|
|
771
771
|
this.readyState === "open" ? e() : this.once("open", e);
|
|
772
772
|
}
|
|
773
773
|
write(e) {
|
|
774
|
-
this.writable = !1,
|
|
774
|
+
this.writable = !1, M(e, (e) => {
|
|
775
775
|
this.doWrite(e, () => {
|
|
776
776
|
this.writable = !0, this.emitReserved("drain");
|
|
777
777
|
});
|
|
@@ -2844,7 +2844,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2844
2844
|
let i = f(() => e ? {
|
|
2845
2845
|
...t || {},
|
|
2846
2846
|
siteId: e
|
|
2847
|
-
} : 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(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [O, Ae] = m(!1), [je, Me] = m(""), [Pe, Fe] = m(!1), [Ie, Le] = m(0), [Re, ze] = m(0), [Be, Ve] = m(!1), [k, He] = m(null), [Ke, qe] = m(null), [Je, Ye] = m("idle"), [Xe, Ze] = m(null), [Qe, $e] = m(!1), [et, tt] = m(""), [nt, rt] = m(!1), A = p(null), j = p(null), it = p(""), at = p(!1), ot = p(null),
|
|
2847
|
+
} : 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(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [O, Ae] = m(!1), [je, Me] = m(""), [Pe, Fe] = m(!1), [Ie, Le] = m(0), [Re, ze] = m(0), [Be, Ve] = m(!1), [k, He] = m(null), [Ke, qe] = m(null), [Je, Ye] = m("idle"), [Xe, Ze] = m(null), [Qe, $e] = m(!1), [et, tt] = m(""), [nt, rt] = m(!1), A = p(null), j = p(null), it = p(""), at = p(!1), ot = p(null), st = p(null), ct = p(null), M = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(!1), pt = p([]), mt = p(null), N = p(null), ht = p(null), gt = p(!1), _t = p(!1), vt = p(""), yt = p(null), bt = p(null), xt = p([]), St = p(0), Ct = p(E), wt = p([]), Tt = p(!1), Et = p(!1), Dt = p(i), Ot = p({
|
|
2848
2848
|
notifyRouteChange: () => {},
|
|
2849
2849
|
cleanup: () => {}
|
|
2850
2850
|
}), kt = o((e = {}) => {
|
|
@@ -2855,7 +2855,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2855
2855
|
return Number.isFinite(t) && t > 0 ? t : ae;
|
|
2856
2856
|
}, [i, _]);
|
|
2857
2857
|
c(() => {
|
|
2858
|
-
|
|
2858
|
+
st.current = k;
|
|
2859
2859
|
}, [k]), c(() => {
|
|
2860
2860
|
Ct.current = E;
|
|
2861
2861
|
}, [E]), c(() => {
|
|
@@ -2903,7 +2903,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2903
2903
|
} catch {}
|
|
2904
2904
|
bt.current = null;
|
|
2905
2905
|
}
|
|
2906
|
-
|
|
2906
|
+
ct.current &&= (ct.current.close(), null), M.current &&= (M.current.getTracks().forEach((e) => e.stop()), null), lt.current &&= (lt.current.srcObject = null, lt.current.remove(), null), Mt(), ut.current = null, pt.current = [], mt.current = null, N.current = null, gt.current = !1, $e(!1), He(null), qe(null), Ye("idle"), Ze(null);
|
|
2907
2907
|
}, Ft = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
2908
2908
|
let t = A.current, n = mt.current || ut.current?.callId;
|
|
2909
2909
|
if (!(!t?.connected || !n || gt.current)) {
|
|
@@ -2913,7 +2913,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2913
2913
|
connectedAt: e
|
|
2914
2914
|
});
|
|
2915
2915
|
try {
|
|
2916
|
-
let e =
|
|
2916
|
+
let e = M.current, t = lt.current?.srcObject;
|
|
2917
2917
|
if (e && t && !yt.current) {
|
|
2918
2918
|
xt.current = [];
|
|
2919
2919
|
let n = new (window.AudioContext || window.webkitAudioContext)();
|
|
@@ -2953,7 +2953,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2953
2953
|
}
|
|
2954
2954
|
}, It = (e = {}) => {
|
|
2955
2955
|
if (!e.callId) return;
|
|
2956
|
-
let t = N.current === e.callId, n = mt.current === e.callId, r =
|
|
2956
|
+
let t = N.current === e.callId, n = mt.current === e.callId, r = st.current?.callId === e.callId;
|
|
2957
2957
|
if (!(!t && !n && !r)) {
|
|
2958
2958
|
if (Mt(), He(null), t || n) {
|
|
2959
2959
|
mt.current = e.callId, qe(e.callId), Ye((e) => e === "connected" ? e : "connecting"), w(!0);
|
|
@@ -2963,7 +2963,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2963
2963
|
}
|
|
2964
2964
|
}, Lt = (e = {}) => {
|
|
2965
2965
|
if (!e.callId) return;
|
|
2966
|
-
let t = N.current === e.callId, n = mt.current === e.callId, r =
|
|
2966
|
+
let t = N.current === e.callId, n = mt.current === e.callId, r = st.current?.callId === e.callId;
|
|
2967
2967
|
if (!(!t && !n && !r)) {
|
|
2968
2968
|
if (Mt(), n) {
|
|
2969
2969
|
Pt();
|
|
@@ -2972,7 +2972,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2972
2972
|
N.current = null, ut.current = null, pt.current = [], He(null), Ye("idle");
|
|
2973
2973
|
}
|
|
2974
2974
|
}, Rt = async (e = {}) => {
|
|
2975
|
-
let t =
|
|
2975
|
+
let t = ct.current, n = A.current, r = e.sdpOffer || e.offer?.sdp;
|
|
2976
2976
|
if (!t || !n?.connected || !r || !e.callId) {
|
|
2977
2977
|
console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
|
|
2978
2978
|
callId: e.callId,
|
|
@@ -3182,7 +3182,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3182
3182
|
console.warn("[FlowEngageProvider] ignoring invalid ICE candidate payload", e);
|
|
3183
3183
|
return;
|
|
3184
3184
|
}
|
|
3185
|
-
if (!
|
|
3185
|
+
if (!ct.current || !ct.current.remoteDescription) {
|
|
3186
3186
|
console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
|
|
3187
3187
|
callId: e.callId,
|
|
3188
3188
|
chatId: e.chatId || it.current,
|
|
@@ -3190,7 +3190,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3190
3190
|
}), pt.current.push(t);
|
|
3191
3191
|
return;
|
|
3192
3192
|
}
|
|
3193
|
-
await
|
|
3193
|
+
await ct.current.addIceCandidate(new RTCIceCandidate(t));
|
|
3194
3194
|
} catch (e) {
|
|
3195
3195
|
console.error("[FlowEngageProvider] failed to add ICE candidate", e);
|
|
3196
3196
|
}
|
|
@@ -3208,7 +3208,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3208
3208
|
Lt(e);
|
|
3209
3209
|
}), f.on("call:connected", (e = {}) => {
|
|
3210
3210
|
if (!e.callId) return;
|
|
3211
|
-
let t = N.current === e.callId, n = mt.current === e.callId, r = ut.current?.callId === e.callId, i =
|
|
3211
|
+
let t = N.current === e.callId, n = mt.current === e.callId, r = ut.current?.callId === e.callId, i = st.current?.callId === e.callId;
|
|
3212
3212
|
if (!t && !n && !r) {
|
|
3213
3213
|
i && (He(null), Ye("idle"));
|
|
3214
3214
|
return;
|
|
@@ -3293,7 +3293,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3293
3293
|
jt(), N.current = k.callId, Mt();
|
|
3294
3294
|
try {
|
|
3295
3295
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3296
|
-
|
|
3296
|
+
M.current = e;
|
|
3297
3297
|
let t = [{ urls: "stun:stun.l.google.com:19302" }];
|
|
3298
3298
|
try {
|
|
3299
3299
|
let e = await j.current.getIceServersConfig();
|
|
@@ -3302,7 +3302,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3302
3302
|
console.warn("[FlowEngageProvider] ice-config fetch failed, using STUN default", e);
|
|
3303
3303
|
}
|
|
3304
3304
|
let n = new RTCPeerConnection({ iceServers: t });
|
|
3305
|
-
|
|
3305
|
+
ct.current = n, n.onconnectionstatechange = () => {
|
|
3306
3306
|
let e = n.connectionState;
|
|
3307
3307
|
if (e === "connected") {
|
|
3308
3308
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3409,7 +3409,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3409
3409
|
}
|
|
3410
3410
|
let e = k.callId;
|
|
3411
3411
|
return Mt(), ht.current = window.setTimeout(() => {
|
|
3412
|
-
|
|
3412
|
+
st.current?.callId === e && N.current !== e && mt.current !== e && Ut.current();
|
|
3413
3413
|
}, oe), () => {
|
|
3414
3414
|
ht.current &&= (window.clearTimeout(ht.current), null);
|
|
3415
3415
|
};
|
|
@@ -3432,7 +3432,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3432
3432
|
Pt("end_call_finally");
|
|
3433
3433
|
}
|
|
3434
3434
|
}, Gt = () => {
|
|
3435
|
-
let e =
|
|
3435
|
+
let e = M.current?.getAudioTracks?.() || [], t = ct.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3436
3436
|
if (n.length === 0) return;
|
|
3437
3437
|
let r = !Qe;
|
|
3438
3438
|
n.forEach((e) => {
|
|
@@ -3669,7 +3669,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3669
3669
|
t.beaconEndWebRTCCall(mt.current, e);
|
|
3670
3670
|
return;
|
|
3671
3671
|
}
|
|
3672
|
-
let n = N.current ||
|
|
3672
|
+
let n = N.current || st.current?.callId;
|
|
3673
3673
|
n && t.beaconCustomerUnavailable(n, e);
|
|
3674
3674
|
};
|
|
3675
3675
|
return window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), () => {
|
|
@@ -31665,7 +31665,7 @@ function Bk() {
|
|
|
31665
31665
|
pr();
|
|
31666
31666
|
} catch {}
|
|
31667
31667
|
}, []), c(() => {
|
|
31668
|
-
Ee && M !== "voice_mode" && M !== "text_chat" && M !== "call_screen" && (ue?.(!1),
|
|
31668
|
+
Ee && M !== "voice_mode" && M !== "text_chat" && M !== "call_screen" && (ue?.(!1), lt("text_chat"));
|
|
31669
31669
|
}, [Ee]);
|
|
31670
31670
|
let Oe = t?.widgetSettings || {}, ke = n?.widgetSettings || {}, O = {
|
|
31671
31671
|
...Oe.branding || {},
|
|
@@ -31685,7 +31685,18 @@ function Bk() {
|
|
|
31685
31685
|
label: e.label,
|
|
31686
31686
|
message: e.label,
|
|
31687
31687
|
text: e.label
|
|
31688
|
-
})), qe = Array.isArray(O.quickChatOptions) && O.quickChatOptions.length > 0 ? O.quickChatOptions : Ke, Je = O.hideWatermark === !0 ? !1 : O.showPoweredBy !== !1, Ye = O.headerBgColor || null, Xe = Me.bottomPosition == null ? "1.5rem" : `${Me.bottomPosition}px`, Ze = O.privacyPolicyUrl || null, Qe = O.chatbotEnabled !== !1 && Me.chatbotEnabled !== !1, $e =
|
|
31688
|
+
})), qe = Array.isArray(O.quickChatOptions) && O.quickChatOptions.length > 0 ? O.quickChatOptions : Ke, Je = O.hideWatermark === !0 ? !1 : O.showPoweredBy !== !1, Ye = O.headerBgColor || null, Xe = Me.bottomPosition == null ? "1.5rem" : `${Me.bottomPosition}px`, Ze = O.privacyPolicyUrl || null, Qe = O.chatbotEnabled !== !1 && Me.chatbotEnabled !== !1, $e = (() => {
|
|
31689
|
+
let e = {
|
|
31690
|
+
...Oe.pageVisibility || {},
|
|
31691
|
+
...ke.pageVisibility || {}
|
|
31692
|
+
};
|
|
31693
|
+
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
31694
|
+
})(), et = $e.length === 0 || $e.some((e) => {
|
|
31695
|
+
if (e === "*" || e === "/*") return !0;
|
|
31696
|
+
if (e.endsWith("/*")) return Rt.startsWith(e.slice(0, -1));
|
|
31697
|
+
let t = e.replace(/\/$/, "");
|
|
31698
|
+
return Rt === t || Rt === t + "/";
|
|
31699
|
+
}), tt = Oe.greetings?.[E] || ke.greetings?.[E] || O.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", nt = {
|
|
31689
31700
|
entryPrompt: O.entryPrompt || "Do you want to explore in a new way?",
|
|
31690
31701
|
yesLabel: O.yesLabel || "Yes",
|
|
31691
31702
|
laterLabel: O.laterLabel || "Later",
|
|
@@ -31694,197 +31705,207 @@ function Bk() {
|
|
|
31694
31705
|
textLabel: O.textLabel || "Text",
|
|
31695
31706
|
chatTitle: O.headerName || "Chat with FlowEngage",
|
|
31696
31707
|
hasCustomTitle: !!(O.headerName && String(O.headerName).trim()),
|
|
31697
|
-
introGreeting:
|
|
31708
|
+
introGreeting: tt,
|
|
31698
31709
|
inputPlaceholder: O.inputPlaceholder || "Type your message",
|
|
31699
31710
|
analysingLabel: O.analysingLabel || "analysing..."
|
|
31700
|
-
},
|
|
31711
|
+
}, rt = ke.elevenLabsAgentId || t?.elevenLabsAgentId || null, A = t?.siteId || n?.siteId || null, j = t?.apiBaseUrl || "";
|
|
31701
31712
|
c(() => {
|
|
31702
31713
|
$n(t?.siteType || null);
|
|
31703
31714
|
}, [t?.siteType]);
|
|
31704
|
-
let
|
|
31715
|
+
let it = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
|
|
31705
31716
|
l,
|
|
31706
31717
|
t?.ownerName,
|
|
31707
31718
|
t?.websiteName
|
|
31708
|
-
]),
|
|
31719
|
+
]), at = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, ot = r.some((e) => e.sender === "user"), st = f(() => {
|
|
31709
31720
|
let e = r.findIndex((e) => e.sender === "user");
|
|
31710
31721
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
31711
|
-
}, [r]),
|
|
31722
|
+
}, [r]), ct = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [M, lt] = m(() => ct ? "text_chat" : "entry_prompt"), [ut, dt] = m(""), [ft, pt] = m(null), [mt, N] = m(h || ""), [ht, gt] = m(""), [_t, vt] = m(!1), [yt, bt] = m(0), [xt, St] = m(null), [Ct, wt] = m(null), [Tt, Et] = m(""), [Dt, Ot] = m(!1), [kt, At] = m(!1), [jt, Mt] = m(!1), Nt = p(null), Pt = p(!1), Ft = !h && ot && st && M !== "voice_mode";
|
|
31712
31723
|
d(() => {
|
|
31713
|
-
if (e !== "ready" ||
|
|
31714
|
-
if (
|
|
31715
|
-
|
|
31724
|
+
if (e !== "ready" || Pt.current) return;
|
|
31725
|
+
if (Pt.current = !0, !Fe) {
|
|
31726
|
+
lt("minimized_orb");
|
|
31716
31727
|
return;
|
|
31717
31728
|
}
|
|
31718
31729
|
let t = !1;
|
|
31719
31730
|
try {
|
|
31720
31731
|
t = Tr().shouldResumeVoice;
|
|
31721
31732
|
} catch {}
|
|
31722
|
-
let n = Pe(), r =
|
|
31733
|
+
let n = Pe(), r = A ? Ae(A) : null, i = n || !!r?.transcript;
|
|
31723
31734
|
if (t) {
|
|
31724
|
-
ce?.({ notifyChatInitiated: !0 }), ue?.(!0),
|
|
31735
|
+
ce?.({ notifyChatInitiated: !0 }), ue?.(!0), lt("voice_mode");
|
|
31725
31736
|
return;
|
|
31726
31737
|
}
|
|
31727
31738
|
if (Le()) {
|
|
31728
|
-
ce?.({ notifyChatInitiated: !1 }),
|
|
31739
|
+
ce?.({ notifyChatInitiated: !1 }), lt("text_chat");
|
|
31729
31740
|
return;
|
|
31730
31741
|
}
|
|
31731
31742
|
if (i) {
|
|
31732
31743
|
if ((typeof performance < "u" ? performance.getEntriesByType?.("navigation")?.[0]?.type ?? "navigate" : "navigate") === "reload") {
|
|
31733
|
-
|
|
31744
|
+
lt("minimized_orb");
|
|
31734
31745
|
return;
|
|
31735
31746
|
}
|
|
31736
|
-
ce?.({ notifyChatInitiated: !0 }), ue?.(!0),
|
|
31747
|
+
ce?.({ notifyChatInitiated: !0 }), ue?.(!0), lt("voice_mode");
|
|
31737
31748
|
return;
|
|
31738
31749
|
}
|
|
31739
|
-
if (
|
|
31740
|
-
je(
|
|
31750
|
+
if (A) try {
|
|
31751
|
+
je(A);
|
|
31741
31752
|
} catch {}
|
|
31742
|
-
if (fe(
|
|
31743
|
-
|
|
31753
|
+
if (fe(A)) {
|
|
31754
|
+
lt("minimized_orb");
|
|
31744
31755
|
return;
|
|
31745
31756
|
}
|
|
31746
31757
|
}, [e, r]);
|
|
31747
|
-
let [
|
|
31758
|
+
let [It, Lt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
|
|
31748
31759
|
c(() => {
|
|
31749
|
-
let e = window.matchMedia("(max-width: 640px)"), t = (e) =>
|
|
31760
|
+
let e = window.matchMedia("(max-width: 640px)"), t = (e) => Lt(e.matches);
|
|
31750
31761
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
31762
|
+
}, []);
|
|
31763
|
+
let [Rt, zt] = m(() => typeof window < "u" ? window.location.pathname : "/");
|
|
31764
|
+
c(() => {
|
|
31765
|
+
if (typeof window > "u") return;
|
|
31766
|
+
let e = () => zt(window.location.pathname), t = window.history.pushState.bind(window.history);
|
|
31767
|
+
return window.history.pushState = (...n) => {
|
|
31768
|
+
t(...n), setTimeout(e, 50);
|
|
31769
|
+
}, window.addEventListener("popstate", e), () => {
|
|
31770
|
+
window.history.pushState = t, window.removeEventListener("popstate", e);
|
|
31771
|
+
};
|
|
31751
31772
|
}, []), c(() => {
|
|
31752
|
-
|
|
31773
|
+
N(h || ""), h && gt("");
|
|
31753
31774
|
}, [h]);
|
|
31754
|
-
let
|
|
31755
|
-
|
|
31756
|
-
}, []),
|
|
31775
|
+
let Bt = o(() => {
|
|
31776
|
+
wt(null), Et("");
|
|
31777
|
+
}, []), Vt = o((e) => {
|
|
31757
31778
|
let t = YD(e);
|
|
31758
31779
|
if (t) {
|
|
31759
|
-
|
|
31780
|
+
wt(null), Et(t);
|
|
31760
31781
|
return;
|
|
31761
31782
|
}
|
|
31762
|
-
|
|
31783
|
+
wt(e), Et("");
|
|
31763
31784
|
}, []);
|
|
31764
31785
|
c(() => {
|
|
31765
31786
|
if (!te || ee !== "connected") {
|
|
31766
|
-
|
|
31787
|
+
bt(0);
|
|
31767
31788
|
return;
|
|
31768
31789
|
}
|
|
31769
31790
|
let e = () => {
|
|
31770
31791
|
let e = new Date(te).getTime();
|
|
31771
|
-
isNaN(e) ||
|
|
31792
|
+
isNaN(e) || bt(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
|
|
31772
31793
|
};
|
|
31773
31794
|
e();
|
|
31774
31795
|
let t = window.setInterval(e, 1e3);
|
|
31775
31796
|
return () => window.clearInterval(t);
|
|
31776
31797
|
}, [te, ee]);
|
|
31777
|
-
let
|
|
31778
|
-
|
|
31779
|
-
}, []),
|
|
31780
|
-
|
|
31798
|
+
let Ht = o(() => {
|
|
31799
|
+
lt("call_screen"), At(!1);
|
|
31800
|
+
}, []), Ut = o(() => {
|
|
31801
|
+
lt("text_chat"), At(!0);
|
|
31781
31802
|
}, []);
|
|
31782
31803
|
c(() => {
|
|
31783
31804
|
let e = w?.callId || T || null;
|
|
31784
31805
|
if (!e) {
|
|
31785
|
-
|
|
31806
|
+
Nt.current = null;
|
|
31786
31807
|
return;
|
|
31787
31808
|
}
|
|
31788
31809
|
if (w?.callId || ee === "connecting" || ee === "connected") {
|
|
31789
|
-
if (M === "minimized_orb" &&
|
|
31790
|
-
|
|
31810
|
+
if (M === "minimized_orb" && kt && T && !w?.callId) {
|
|
31811
|
+
Nt.current = e;
|
|
31791
31812
|
return;
|
|
31792
31813
|
}
|
|
31793
|
-
!(!i || M === "minimized_orb" || M === "voice_mode") &&
|
|
31814
|
+
!(!i || M === "minimized_orb" || M === "voice_mode") && Nt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
|
|
31794
31815
|
forcedKey: e,
|
|
31795
31816
|
isOpen: i,
|
|
31796
31817
|
surface: M,
|
|
31797
31818
|
hasIncomingCall: !!w?.callId,
|
|
31798
31819
|
activeCallId: T,
|
|
31799
31820
|
callConnectionState: ee
|
|
31800
|
-
}),
|
|
31821
|
+
}), Nt.current = e, M === "voice_mode" && ue?.(!1), ce?.(), Ht());
|
|
31801
31822
|
}
|
|
31802
31823
|
}, [
|
|
31803
31824
|
T,
|
|
31804
31825
|
ee,
|
|
31805
|
-
|
|
31826
|
+
Ht,
|
|
31806
31827
|
w?.callId,
|
|
31807
31828
|
i,
|
|
31808
31829
|
ce,
|
|
31809
31830
|
ue,
|
|
31810
31831
|
M
|
|
31811
31832
|
]), c(() => {
|
|
31812
|
-
!w && !T && M === "call_screen" &&
|
|
31833
|
+
!w && !T && M === "call_screen" && lt("text_chat");
|
|
31813
31834
|
}, [
|
|
31814
31835
|
w,
|
|
31815
31836
|
T,
|
|
31816
31837
|
M
|
|
31817
31838
|
]), c(() => {
|
|
31818
|
-
!T &&
|
|
31819
|
-
}, [T,
|
|
31839
|
+
!T && kt && At(!1);
|
|
31840
|
+
}, [T, kt]), c(() => {
|
|
31820
31841
|
if (!s || C) {
|
|
31821
31842
|
Se?.(""), xe?.();
|
|
31822
31843
|
return;
|
|
31823
31844
|
}
|
|
31824
|
-
if (!
|
|
31845
|
+
if (!ut.trim() || Ct) {
|
|
31825
31846
|
Se?.("");
|
|
31826
31847
|
let e = window.setTimeout(() => xe?.(), 100);
|
|
31827
31848
|
return () => window.clearTimeout(e);
|
|
31828
31849
|
}
|
|
31829
31850
|
be?.();
|
|
31830
|
-
let e = window.setTimeout(() => Se?.(
|
|
31851
|
+
let e = window.setTimeout(() => Se?.(ut), 120), t = window.setTimeout(() => xe?.(), 1200);
|
|
31831
31852
|
return () => {
|
|
31832
31853
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
31833
31854
|
};
|
|
31834
31855
|
}, [
|
|
31835
|
-
|
|
31836
|
-
|
|
31856
|
+
ut,
|
|
31857
|
+
Ct,
|
|
31837
31858
|
s,
|
|
31838
31859
|
C,
|
|
31839
31860
|
be,
|
|
31840
31861
|
xe,
|
|
31841
31862
|
Se
|
|
31842
31863
|
]);
|
|
31843
|
-
let
|
|
31864
|
+
let Wt = (e) => e ? {
|
|
31844
31865
|
replyTo: e.messageId || e.id || null,
|
|
31845
31866
|
replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
|
|
31846
31867
|
replyToSender: e.sender || null
|
|
31847
|
-
} : null,
|
|
31868
|
+
} : null, Gt = async (e) => {
|
|
31848
31869
|
if (e.preventDefault(), C) return;
|
|
31849
|
-
if (
|
|
31850
|
-
let e =
|
|
31870
|
+
if (Ft) {
|
|
31871
|
+
let e = mt.trim().toLowerCase();
|
|
31851
31872
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
31852
|
-
|
|
31873
|
+
gt("Please enter a valid email so we can continue helping you.");
|
|
31853
31874
|
return;
|
|
31854
31875
|
}
|
|
31855
|
-
await le(e),
|
|
31876
|
+
await le(e), gt(""), vt(!0), setTimeout(() => vt(!1), 3e3);
|
|
31856
31877
|
return;
|
|
31857
31878
|
}
|
|
31858
|
-
let t =
|
|
31859
|
-
if (!
|
|
31860
|
-
if (
|
|
31879
|
+
let t = Wt(ft);
|
|
31880
|
+
if (!ut.trim() && !Ct) return;
|
|
31881
|
+
if (Ct) {
|
|
31861
31882
|
try {
|
|
31862
|
-
|
|
31863
|
-
let e = await se(
|
|
31864
|
-
|
|
31883
|
+
Ot(!0), Et("");
|
|
31884
|
+
let e = await se(Ct), n = e?.data || e, r = ut.trim() || `Shared file: ${ZD(Ct)}`;
|
|
31885
|
+
dt(""), pt(null), Bt(), await D(r, "", t, {
|
|
31865
31886
|
type: "file",
|
|
31866
31887
|
metadata: {
|
|
31867
31888
|
fileUrl: n?.fileUrl,
|
|
31868
|
-
fileName: n?.fileName ||
|
|
31869
|
-
fileType: n?.fileType ||
|
|
31870
|
-
fileSize: n?.fileSize ||
|
|
31889
|
+
fileName: n?.fileName || Ct.name,
|
|
31890
|
+
fileType: n?.fileType || Ct.type,
|
|
31891
|
+
fileSize: n?.fileSize || Ct.size
|
|
31871
31892
|
}
|
|
31872
31893
|
});
|
|
31873
31894
|
} catch (e) {
|
|
31874
|
-
|
|
31895
|
+
Et(e?.message || "Failed to upload the selected file.");
|
|
31875
31896
|
} finally {
|
|
31876
|
-
|
|
31897
|
+
Ot(!1);
|
|
31877
31898
|
}
|
|
31878
31899
|
return;
|
|
31879
31900
|
}
|
|
31880
|
-
let n =
|
|
31881
|
-
|
|
31882
|
-
},
|
|
31901
|
+
let n = ut.trim();
|
|
31902
|
+
dt(""), pt(null), await D(n, "", t);
|
|
31903
|
+
}, Kt = o(() => {
|
|
31883
31904
|
r.length !== 0 && me?.();
|
|
31884
|
-
}, [r.length, me]),
|
|
31905
|
+
}, [r.length, me]), qt = (e) => {
|
|
31885
31906
|
let t = Math.floor(e / 60);
|
|
31886
31907
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
31887
|
-
},
|
|
31908
|
+
}, Jt = o(async (e) => {
|
|
31888
31909
|
if (C || b) return;
|
|
31889
31910
|
let t = e.message || e.label || e.text || "";
|
|
31890
31911
|
t.trim() && await D(t.trim(), "");
|
|
@@ -31892,18 +31913,18 @@ function Bk() {
|
|
|
31892
31913
|
C,
|
|
31893
31914
|
b,
|
|
31894
31915
|
D
|
|
31895
|
-
]),
|
|
31916
|
+
]), Yt = It && M === "entry_prompt" ? { inset: 0 } : It && M === "text_chat" ? {
|
|
31896
31917
|
left: 0,
|
|
31897
31918
|
right: 0,
|
|
31898
31919
|
bottom: 0
|
|
31899
|
-
} :
|
|
31920
|
+
} : It && M === "call_screen" ? {
|
|
31900
31921
|
left: 0,
|
|
31901
31922
|
right: 0,
|
|
31902
31923
|
bottom: 0,
|
|
31903
31924
|
height: "90dvh",
|
|
31904
31925
|
overflow: "hidden",
|
|
31905
31926
|
borderRadius: "16px 16px 0 0"
|
|
31906
|
-
} :
|
|
31927
|
+
} : It && M === "connection_modal" ? {
|
|
31907
31928
|
left: "12px",
|
|
31908
31929
|
right: "12px",
|
|
31909
31930
|
bottom: "12px"
|
|
@@ -31925,11 +31946,11 @@ function Bk() {
|
|
|
31925
31946
|
} : {
|
|
31926
31947
|
right: "1.5rem",
|
|
31927
31948
|
bottom: Xe
|
|
31928
|
-
},
|
|
31929
|
-
M !== "minimized_orb" && (
|
|
31930
|
-
|
|
31949
|
+
}, Xt = o(() => {
|
|
31950
|
+
M !== "minimized_orb" && (Mt(!0), setTimeout(() => {
|
|
31951
|
+
lt("minimized_orb"), Mt(!1), T && At(!0);
|
|
31931
31952
|
}, 280));
|
|
31932
|
-
}, [T, M]),
|
|
31953
|
+
}, [T, M]), Zt = () => lt("connection_modal"), Qt = () => {
|
|
31933
31954
|
try {
|
|
31934
31955
|
let e = window.AudioContext || window.webkitAudioContext;
|
|
31935
31956
|
if (e) {
|
|
@@ -31937,34 +31958,34 @@ function Bk() {
|
|
|
31937
31958
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
31938
31959
|
}
|
|
31939
31960
|
} catch {}
|
|
31940
|
-
ce({ notifyChatInitiated: !0 }), ue?.(!0),
|
|
31941
|
-
},
|
|
31942
|
-
ce({ notifyChatInitiated: !0 }), ue?.(!1),
|
|
31943
|
-
},
|
|
31944
|
-
ue?.(!1),
|
|
31961
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!0), lt("voice_mode");
|
|
31962
|
+
}, $t = () => {
|
|
31963
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!1), lt("text_chat");
|
|
31964
|
+
}, en = () => {
|
|
31965
|
+
ue?.(!1), Xt();
|
|
31945
31966
|
};
|
|
31946
|
-
return e !== "ready" || !Qe || Ne.chat === !1 ? null : /* @__PURE__ */ _("div", {
|
|
31967
|
+
return e !== "ready" || !Qe || Ne.chat === !1 || !et ? null : /* @__PURE__ */ _("div", {
|
|
31947
31968
|
className: "flowengage-widget-root",
|
|
31948
31969
|
style: {
|
|
31949
31970
|
position: "fixed",
|
|
31950
31971
|
zIndex: 999999,
|
|
31951
|
-
...
|
|
31972
|
+
...Yt
|
|
31952
31973
|
},
|
|
31953
31974
|
onWheel: (e) => e.stopPropagation(),
|
|
31954
31975
|
onTouchMove: (e) => e.stopPropagation(),
|
|
31955
31976
|
children: [
|
|
31956
31977
|
M === "entry_prompt" && /* @__PURE__ */ g(Pk, {
|
|
31957
|
-
copy:
|
|
31978
|
+
copy: nt,
|
|
31958
31979
|
orbColors: Ie,
|
|
31959
31980
|
primaryColor: Re,
|
|
31960
31981
|
onYes: () => {
|
|
31961
|
-
pe(
|
|
31982
|
+
pe(A), Qt();
|
|
31962
31983
|
},
|
|
31963
31984
|
onLater: () => {
|
|
31964
|
-
pe(
|
|
31985
|
+
pe(A), Xt();
|
|
31965
31986
|
},
|
|
31966
|
-
isMobile:
|
|
31967
|
-
isClosing:
|
|
31987
|
+
isMobile: It,
|
|
31988
|
+
isClosing: jt
|
|
31968
31989
|
}),
|
|
31969
31990
|
M === "minimized_orb" && /* @__PURE__ */ _(Om.div, {
|
|
31970
31991
|
layoutId: "fe-main-orb",
|
|
@@ -31990,9 +32011,9 @@ function Bk() {
|
|
|
31990
32011
|
},
|
|
31991
32012
|
children: [T && /* @__PURE__ */ _("button", {
|
|
31992
32013
|
type: "button",
|
|
31993
|
-
onClick:
|
|
32014
|
+
onClick: Ht,
|
|
31994
32015
|
style: {
|
|
31995
|
-
maxWidth:
|
|
32016
|
+
maxWidth: It ? "220px" : "240px",
|
|
31996
32017
|
padding: "10px 14px",
|
|
31997
32018
|
borderRadius: "18px",
|
|
31998
32019
|
border: "1px solid rgba(255,255,255,0.7)",
|
|
@@ -32033,32 +32054,32 @@ function Bk() {
|
|
|
32033
32054
|
marginTop: "2px",
|
|
32034
32055
|
whiteSpace: "nowrap"
|
|
32035
32056
|
},
|
|
32036
|
-
children: ee === "connected" ? `${
|
|
32057
|
+
children: ee === "connected" ? `${qt(yt)} with ${it}` : `Tap to return to ${it}`
|
|
32037
32058
|
})]
|
|
32038
32059
|
})]
|
|
32039
32060
|
}), /* @__PURE__ */ g(Nk, {
|
|
32040
32061
|
size: Be,
|
|
32041
32062
|
orbColors: Ie,
|
|
32042
|
-
onClick: T ?
|
|
32063
|
+
onClick: T ? Ht : Fe ? Zt : $t
|
|
32043
32064
|
})]
|
|
32044
32065
|
}),
|
|
32045
32066
|
M === "connection_modal" && /* @__PURE__ */ g(Fk, {
|
|
32046
|
-
copy:
|
|
32067
|
+
copy: nt,
|
|
32047
32068
|
orbColors: Ie,
|
|
32048
32069
|
primaryColor: Re,
|
|
32049
|
-
onVoice:
|
|
32050
|
-
onText:
|
|
32051
|
-
onClose:
|
|
32052
|
-
isMobile:
|
|
32053
|
-
isClosing:
|
|
32070
|
+
onVoice: Qt,
|
|
32071
|
+
onText: $t,
|
|
32072
|
+
onClose: Xt,
|
|
32073
|
+
isMobile: It,
|
|
32074
|
+
isClosing: jt
|
|
32054
32075
|
}),
|
|
32055
32076
|
M === "voice_mode" && /* @__PURE__ */ g(Ik, {
|
|
32056
32077
|
orbColors: Ie,
|
|
32057
|
-
onEnterChat:
|
|
32058
|
-
onEndChat:
|
|
32059
|
-
agentId:
|
|
32060
|
-
siteId:
|
|
32061
|
-
apiBaseUrl:
|
|
32078
|
+
onEnterChat: $t,
|
|
32079
|
+
onEndChat: en,
|
|
32080
|
+
agentId: rt,
|
|
32081
|
+
siteId: A,
|
|
32082
|
+
apiBaseUrl: j,
|
|
32062
32083
|
chatId: ie,
|
|
32063
32084
|
historyRef: ae,
|
|
32064
32085
|
onMessageSync: oe,
|
|
@@ -32069,73 +32090,73 @@ function Bk() {
|
|
|
32069
32090
|
incomingCall: w,
|
|
32070
32091
|
activeCallId: T,
|
|
32071
32092
|
callConnectionState: ee,
|
|
32072
|
-
callDurationSeconds:
|
|
32093
|
+
callDurationSeconds: yt,
|
|
32073
32094
|
isCallMuted: ne,
|
|
32074
|
-
agentName:
|
|
32075
|
-
agentHeadshot:
|
|
32095
|
+
agentName: it,
|
|
32096
|
+
agentHeadshot: at,
|
|
32076
32097
|
fallbackAgentName: k,
|
|
32077
32098
|
acceptCall: he,
|
|
32078
32099
|
rejectCall: ge,
|
|
32079
32100
|
endWebRTCCall: _e,
|
|
32080
32101
|
toggleCallMute: ve,
|
|
32081
|
-
formatCallDuration:
|
|
32082
|
-
onMinimize:
|
|
32102
|
+
formatCallDuration: qt,
|
|
32103
|
+
onMinimize: Ut,
|
|
32083
32104
|
primaryColor: Re,
|
|
32084
32105
|
orbColors: Ie,
|
|
32085
32106
|
chatHistory: r
|
|
32086
32107
|
}),
|
|
32087
32108
|
M === "text_chat" && /* @__PURE__ */ g(zk, {
|
|
32088
|
-
isClosing:
|
|
32089
|
-
copy:
|
|
32109
|
+
isClosing: jt,
|
|
32110
|
+
copy: nt,
|
|
32090
32111
|
orbColors: Ie,
|
|
32091
32112
|
primaryColor: Re,
|
|
32092
32113
|
chatBgGradient: He,
|
|
32093
32114
|
logo: Ue,
|
|
32094
32115
|
quickChatOptions: qe,
|
|
32095
|
-
onQuickChatSelect:
|
|
32096
|
-
isMobile:
|
|
32116
|
+
onQuickChatSelect: Jt,
|
|
32117
|
+
isMobile: It,
|
|
32097
32118
|
chatHistory: r,
|
|
32098
32119
|
isAiTyping: y,
|
|
32099
32120
|
isAgentTyping: v,
|
|
32100
32121
|
activeScreen: a,
|
|
32101
|
-
agentName:
|
|
32102
|
-
agentHeadshot:
|
|
32122
|
+
agentName: it,
|
|
32123
|
+
agentHeadshot: at,
|
|
32103
32124
|
fallbackAgentName: k,
|
|
32104
|
-
input:
|
|
32105
|
-
setInput:
|
|
32106
|
-
onSubmit:
|
|
32125
|
+
input: ut,
|
|
32126
|
+
setInput: dt,
|
|
32127
|
+
onSubmit: Gt,
|
|
32107
32128
|
isConversationEnded: C,
|
|
32108
32129
|
isLoading: b,
|
|
32109
32130
|
isRateLimited: x,
|
|
32110
32131
|
rateLimitMessage: S,
|
|
32111
|
-
selectedFile:
|
|
32112
|
-
onFileSelect:
|
|
32113
|
-
onRemoveSelectedFile:
|
|
32114
|
-
attachmentError:
|
|
32115
|
-
isUploadingAttachment:
|
|
32116
|
-
requiresEmail:
|
|
32117
|
-
emailInput:
|
|
32118
|
-
setEmailInput:
|
|
32119
|
-
emailError:
|
|
32120
|
-
emailCaptureSuccess:
|
|
32121
|
-
replyContext:
|
|
32122
|
-
setReplyContext:
|
|
32132
|
+
selectedFile: Ct,
|
|
32133
|
+
onFileSelect: Vt,
|
|
32134
|
+
onRemoveSelectedFile: Bt,
|
|
32135
|
+
attachmentError: Tt,
|
|
32136
|
+
isUploadingAttachment: Dt,
|
|
32137
|
+
requiresEmail: Ft,
|
|
32138
|
+
emailInput: mt,
|
|
32139
|
+
setEmailInput: N,
|
|
32140
|
+
emailError: ht,
|
|
32141
|
+
emailCaptureSuccess: _t,
|
|
32142
|
+
replyContext: ft,
|
|
32143
|
+
setReplyContext: pt,
|
|
32123
32144
|
webRTCError: re,
|
|
32124
|
-
micError:
|
|
32125
|
-
setMicError:
|
|
32145
|
+
micError: xt,
|
|
32146
|
+
setMicError: St,
|
|
32126
32147
|
dismissCallError: ye,
|
|
32127
32148
|
activeCallId: T,
|
|
32128
32149
|
isCallMuted: ne,
|
|
32129
32150
|
toggleCallMute: ve,
|
|
32130
32151
|
endWebRTCCall: _e,
|
|
32131
|
-
formatCallDuration:
|
|
32132
|
-
callDurationSeconds:
|
|
32133
|
-
onCollapse:
|
|
32134
|
-
onStartVoice:
|
|
32152
|
+
formatCallDuration: qt,
|
|
32153
|
+
callDurationSeconds: yt,
|
|
32154
|
+
onCollapse: Xt,
|
|
32155
|
+
onStartVoice: Qt,
|
|
32135
32156
|
voiceEnabled: Fe,
|
|
32136
|
-
onNewChat:
|
|
32137
|
-
onMinimize:
|
|
32138
|
-
onExpand:
|
|
32157
|
+
onNewChat: Kt,
|
|
32158
|
+
onMinimize: Ut,
|
|
32159
|
+
onExpand: Ht,
|
|
32139
32160
|
isCallMinimized: !!T,
|
|
32140
32161
|
showPoweredBy: Je,
|
|
32141
32162
|
privacyPolicyUrl: Ze,
|