@flowengage/react-chatbot 7.0.15 → 7.0.16
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.
|
@@ -2844,30 +2844,30 @@ function Br({ 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), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, Re] = m(0), [ze, Be] = m(0), [Ve, He] = m(!1), [O, Ue] = m(null), [qe, Je] = m(null), [Ye, Xe] = m("idle"), [Ze, Qe] = m(null), [$e, et] = m(!1), [tt, nt] = m(""), [rt, it] = m(!1), at = p(null), k = p(null), A = p(""), ot = p(!1), st = p(null), ct = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(null), pt = p(null), mt = p(
|
|
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), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, Re] = m(0), [ze, Be] = m(0), [Ve, He] = m(!1), [O, Ue] = m(null), [qe, Je] = m(null), [Ye, Xe] = m("idle"), [Ze, Qe] = m(null), [$e, et] = m(!1), [tt, nt] = m(""), [rt, it] = m(!1), at = p(null), k = p(null), A = p(""), ot = p(!1), st = p(null), ct = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(null), pt = p(null), mt = p(!1), ht = p([]), gt = p(null), j = p(null), _t = p(null), vt = p(!1), yt = p(!1), bt = p(""), xt = p(null), St = p(null), Ct = p([]), wt = p(0), Tt = p(E), Et = p([]), Dt = p(!1), Ot = p(!1), kt = p(i), At = p({
|
|
2848
2848
|
notifyRouteChange: () => {},
|
|
2849
2849
|
cleanup: () => {}
|
|
2850
|
-
}),
|
|
2850
|
+
}), jt = o((e = {}) => {
|
|
2851
2851
|
let t = !!e.is_human_handled;
|
|
2852
2852
|
return re(t), t ? (te("agent"), e.agent_info?.name && D(e.agent_info.name), e.agent_info?.headshot && de(e.agent_info.headshot), t) : (te("ai"), t);
|
|
2853
|
-
}, []),
|
|
2853
|
+
}, []), Mt = f(() => {
|
|
2854
2854
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
2855
2855
|
return Number.isFinite(t) && t > 0 ? t : ae;
|
|
2856
2856
|
}, [i, _]);
|
|
2857
2857
|
c(() => {
|
|
2858
2858
|
ct.current = O;
|
|
2859
2859
|
}, [O]), c(() => {
|
|
2860
|
-
|
|
2860
|
+
Tt.current = E;
|
|
2861
2861
|
}, [E]), c(() => {
|
|
2862
|
-
|
|
2862
|
+
Ot.current = Fe;
|
|
2863
2863
|
}, [Fe]), c(() => {
|
|
2864
|
-
|
|
2864
|
+
kt.current = i;
|
|
2865
2865
|
}, [i]);
|
|
2866
|
-
let
|
|
2866
|
+
let Nt = () => {
|
|
2867
2867
|
nt("");
|
|
2868
|
-
},
|
|
2869
|
-
|
|
2870
|
-
}, []),
|
|
2868
|
+
}, Pt = o(() => {
|
|
2869
|
+
_t.current &&= (window.clearTimeout(_t.current), null);
|
|
2870
|
+
}, []), Ft = (e) => {
|
|
2871
2871
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
2872
2872
|
return pe(t), xe(t, i?.siteId), t;
|
|
2873
2873
|
};
|
|
@@ -2875,12 +2875,12 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2875
2875
|
let e = i?.siteId;
|
|
2876
2876
|
e && pe(be(e));
|
|
2877
2877
|
}, [i?.siteId]);
|
|
2878
|
-
let
|
|
2879
|
-
let t =
|
|
2880
|
-
if (
|
|
2878
|
+
let It = (e = "unspecified") => {
|
|
2879
|
+
let t = gt.current || ft.current?.callId, n = wt.current, r = xt.current;
|
|
2880
|
+
if (xt.current = null, wt.current = 0, r && r.state !== "inactive") {
|
|
2881
2881
|
r.onstop = () => {
|
|
2882
|
-
let e =
|
|
2883
|
-
if (
|
|
2882
|
+
let e = Ct.current;
|
|
2883
|
+
if (Ct.current = [], e.length > 0 && t && k.current) {
|
|
2884
2884
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2885
2885
|
k.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2886
2886
|
}
|
|
@@ -2888,42 +2888,42 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2888
2888
|
try {
|
|
2889
2889
|
r.stop();
|
|
2890
2890
|
} catch {
|
|
2891
|
-
r.onstop = null,
|
|
2891
|
+
r.onstop = null, Ct.current = [];
|
|
2892
2892
|
}
|
|
2893
2893
|
} else if (r && r.state === "inactive") {
|
|
2894
|
-
let e =
|
|
2895
|
-
if (
|
|
2894
|
+
let e = Ct.current;
|
|
2895
|
+
if (Ct.current = [], e.length > 0 && t && k.current) {
|
|
2896
2896
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2897
2897
|
k.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2898
2898
|
}
|
|
2899
|
-
} else
|
|
2900
|
-
if (
|
|
2899
|
+
} else Ct.current = [];
|
|
2900
|
+
if (St.current) {
|
|
2901
2901
|
try {
|
|
2902
|
-
|
|
2902
|
+
St.current.close();
|
|
2903
2903
|
} catch {}
|
|
2904
|
-
|
|
2904
|
+
St.current = null;
|
|
2905
2905
|
}
|
|
2906
|
-
lt.current &&= (lt.current.close(), null), ut.current &&= (ut.current.getTracks().forEach((e) => e.stop()), null), dt.current &&= (dt.current.srcObject = null, dt.current.remove(), null),
|
|
2907
|
-
},
|
|
2908
|
-
let t = at.current, n =
|
|
2909
|
-
if (!(!t?.connected || !n ||
|
|
2910
|
-
|
|
2906
|
+
lt.current &&= (lt.current.close(), null), ut.current &&= (ut.current.getTracks().forEach((e) => e.stop()), null), dt.current &&= (dt.current.srcObject = null, dt.current.remove(), null), Pt(), ft.current = null, ht.current = [], gt.current = null, j.current = null, vt.current = !1, et(!1), Ue(null), Je(null), Xe("idle"), Qe(null);
|
|
2907
|
+
}, Lt = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
2908
|
+
let t = at.current, n = gt.current || ft.current?.callId;
|
|
2909
|
+
if (!(!t?.connected || !n || vt.current)) {
|
|
2910
|
+
vt.current = !0, t.emit("call:connected", {
|
|
2911
2911
|
callId: n,
|
|
2912
2912
|
chatId: A.current,
|
|
2913
2913
|
connectedAt: e
|
|
2914
2914
|
});
|
|
2915
2915
|
try {
|
|
2916
2916
|
let e = ut.current, t = dt.current?.srcObject;
|
|
2917
|
-
if (e && t && !
|
|
2918
|
-
|
|
2917
|
+
if (e && t && !xt.current) {
|
|
2918
|
+
Ct.current = [];
|
|
2919
2919
|
let n = new (window.AudioContext || window.webkitAudioContext)();
|
|
2920
|
-
|
|
2920
|
+
St.current = n;
|
|
2921
2921
|
let r = n.createMediaStreamDestination();
|
|
2922
2922
|
n.createMediaStreamSource(e).connect(r), n.createMediaStreamSource(t).connect(r);
|
|
2923
2923
|
let i = window.MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4", a = new window.MediaRecorder(r.stream, { mimeType: i });
|
|
2924
2924
|
a.ondataavailable = (e) => {
|
|
2925
|
-
e.data && e.data.size > 0 &&
|
|
2926
|
-
},
|
|
2925
|
+
e.data && e.data.size > 0 && Ct.current.push(e.data);
|
|
2926
|
+
}, xt.current = a, wt.current = Date.now(), a.start(1e3), setTimeout(() => {
|
|
2927
2927
|
try {
|
|
2928
2928
|
if (!window.speechSynthesis) return;
|
|
2929
2929
|
let e = new SpeechSynthesisUtterance("This call is being recorded for quality and training purposes.");
|
|
@@ -2951,27 +2951,27 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2951
2951
|
}
|
|
2952
2952
|
} catch {}
|
|
2953
2953
|
}
|
|
2954
|
-
},
|
|
2954
|
+
}, Rt = (e = {}) => {
|
|
2955
2955
|
if (!e.callId) return;
|
|
2956
|
-
let t =
|
|
2956
|
+
let t = j.current === e.callId, n = gt.current === e.callId, r = ct.current?.callId === e.callId;
|
|
2957
2957
|
if (!(!t && !n && !r)) {
|
|
2958
|
-
if (
|
|
2959
|
-
|
|
2958
|
+
if (Pt(), Ue(null), t || n) {
|
|
2959
|
+
gt.current = e.callId, Je(e.callId), Xe((e) => e === "connected" ? e : "connecting"), w(!0);
|
|
2960
2960
|
return;
|
|
2961
2961
|
}
|
|
2962
2962
|
Xe("idle");
|
|
2963
2963
|
}
|
|
2964
|
-
},
|
|
2964
|
+
}, zt = (e = {}) => {
|
|
2965
2965
|
if (!e.callId) return;
|
|
2966
|
-
let t =
|
|
2966
|
+
let t = j.current === e.callId, n = gt.current === e.callId, r = ct.current?.callId === e.callId;
|
|
2967
2967
|
if (!(!t && !n && !r)) {
|
|
2968
|
-
if (
|
|
2969
|
-
|
|
2968
|
+
if (Pt(), n) {
|
|
2969
|
+
It();
|
|
2970
2970
|
return;
|
|
2971
2971
|
}
|
|
2972
|
-
|
|
2972
|
+
j.current = null, ft.current = null, ht.current = [], Ue(null), Xe("idle");
|
|
2973
2973
|
}
|
|
2974
|
-
},
|
|
2974
|
+
}, Bt = async (e = {}) => {
|
|
2975
2975
|
let t = lt.current, n = at.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", {
|
|
@@ -2986,14 +2986,14 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2986
2986
|
if (await t.setRemoteDescription(new RTCSessionDescription({
|
|
2987
2987
|
type: "offer",
|
|
2988
2988
|
sdp: r
|
|
2989
|
-
})),
|
|
2989
|
+
})), ht.current.length > 0) {
|
|
2990
2990
|
console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
|
|
2991
2991
|
callId: e.callId,
|
|
2992
2992
|
chatId: A.current,
|
|
2993
|
-
queuedCount:
|
|
2993
|
+
queuedCount: ht.current.length
|
|
2994
2994
|
});
|
|
2995
|
-
for (let e of
|
|
2996
|
-
|
|
2995
|
+
for (let e of ht.current) await t.addIceCandidate(new RTCIceCandidate(e));
|
|
2996
|
+
ht.current = [];
|
|
2997
2997
|
}
|
|
2998
2998
|
let i = await t.createAnswer();
|
|
2999
2999
|
await t.setLocalDescription(i), n.emit("call:answer", {
|
|
@@ -3110,7 +3110,7 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3110
3110
|
e.agent?.name,
|
|
3111
3111
|
e.agentName,
|
|
3112
3112
|
e.agent_name,
|
|
3113
|
-
|
|
3113
|
+
Tt.current
|
|
3114
3114
|
], d);
|
|
3115
3115
|
re(!0), te("agent"), D(t), de(e.agent?.headshot || null), w(!0), Re((e) => e + 1), S((e) => zr(e, {
|
|
3116
3116
|
id: `agent-joined-${Date.now()}`,
|
|
@@ -3124,7 +3124,7 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3124
3124
|
e.agent?.name,
|
|
3125
3125
|
e.agentName,
|
|
3126
3126
|
e.agent_name,
|
|
3127
|
-
|
|
3127
|
+
Tt.current
|
|
3128
3128
|
], d);
|
|
3129
3129
|
re(!1), te("ai"), S((e) => zr(e, {
|
|
3130
3130
|
id: `agent-left-${Date.now()}`,
|
|
@@ -3160,9 +3160,9 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3160
3160
|
e.agentName,
|
|
3161
3161
|
e.ownerName,
|
|
3162
3162
|
e.agent?.name,
|
|
3163
|
-
|
|
3163
|
+
Tt.current
|
|
3164
3164
|
], "Agent");
|
|
3165
|
-
|
|
3165
|
+
Nt(), Pt(), vt.current = !1, Ue({
|
|
3166
3166
|
callId: e.callId,
|
|
3167
3167
|
from: e.from || "owner",
|
|
3168
3168
|
agentId: e.agentId || null,
|
|
@@ -3171,7 +3171,7 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3171
3171
|
}), f.on("call:offer", async (e = {}) => {
|
|
3172
3172
|
ft.current = e;
|
|
3173
3173
|
try {
|
|
3174
|
-
await
|
|
3174
|
+
await Bt(e);
|
|
3175
3175
|
} catch (e) {
|
|
3176
3176
|
console.error("[FlowEngageProvider] failed to apply remote offer", e);
|
|
3177
3177
|
}
|
|
@@ -3186,8 +3186,8 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
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 || A.current,
|
|
3189
|
-
queueSize:
|
|
3190
|
-
}),
|
|
3189
|
+
queueSize: ht.current.length + 1
|
|
3190
|
+
}), ht.current.push(t);
|
|
3191
3191
|
return;
|
|
3192
3192
|
}
|
|
3193
3193
|
await lt.current.addIceCandidate(new RTCIceCandidate(t));
|
|
@@ -3195,34 +3195,34 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3195
3195
|
console.error("[FlowEngageProvider] failed to add ICE candidate", e);
|
|
3196
3196
|
}
|
|
3197
3197
|
}), f.on("call:ended", () => {
|
|
3198
|
-
|
|
3198
|
+
Nt(), It("socket:call_ended");
|
|
3199
3199
|
}), f.on("call:accepted", (e = {}) => {
|
|
3200
|
-
|
|
3200
|
+
Rt(e);
|
|
3201
3201
|
}), f.on("call:accepted_by_other", (e = {}) => {
|
|
3202
|
-
Lt(e);
|
|
3203
|
-
}), f.on("call:rejected", (e = {}) => {
|
|
3204
3202
|
Rt(e);
|
|
3203
|
+
}), f.on("call:rejected", (e = {}) => {
|
|
3204
|
+
zt(e);
|
|
3205
3205
|
}), f.on("call:missed", (e = {}) => {
|
|
3206
|
-
|
|
3206
|
+
zt(e);
|
|
3207
3207
|
}), f.on("call:failed", (e = {}) => {
|
|
3208
|
-
|
|
3208
|
+
zt(e);
|
|
3209
3209
|
}), f.on("call:connected", (e = {}) => {
|
|
3210
3210
|
if (!e.callId) return;
|
|
3211
|
-
let t =
|
|
3211
|
+
let t = j.current === e.callId, n = gt.current === e.callId, r = ft.current?.callId === e.callId, i = ct.current?.callId === e.callId;
|
|
3212
3212
|
if (!t && !n && !r) {
|
|
3213
3213
|
i && (Ue(null), Xe("idle"));
|
|
3214
3214
|
return;
|
|
3215
3215
|
}
|
|
3216
|
-
|
|
3216
|
+
vt.current = !0, j.current = null, gt.current = e.callId, Je(e.callId), Ue(null), Xe("connected"), Qe(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), w(!0);
|
|
3217
3217
|
}), f.on("call:unavailable", (e = {}) => {
|
|
3218
|
-
|
|
3218
|
+
It("socket:call_unavailable"), nt(Ir(e, "This visitor is not available for a call right now.")), w(!0);
|
|
3219
3219
|
}), f.on("call:error", (e = {}) => {
|
|
3220
|
-
|
|
3220
|
+
It("socket:call_error"), nt(Ir(e, "We couldn't connect the call right now.")), w(!0);
|
|
3221
3221
|
}), f.on("visitor:navigate", async ({ url: e, section: n, highlight: r } = {}) => {
|
|
3222
3222
|
e && await Sr(e, {
|
|
3223
3223
|
siteId: t.siteId,
|
|
3224
3224
|
apiBaseUrl: t.apiBaseUrl
|
|
3225
|
-
}) && Or(e, { voiceActive:
|
|
3225
|
+
}) && Or(e, { voiceActive: Ot.current }).then((e) => {
|
|
3226
3226
|
let t = n || r;
|
|
3227
3227
|
t && setTimeout(() => {
|
|
3228
3228
|
let e = _r(null, t);
|
|
@@ -3235,7 +3235,7 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3235
3235
|
n && vr(n);
|
|
3236
3236
|
}), f.on("visitor:clear_highlight", () => {
|
|
3237
3237
|
yr();
|
|
3238
|
-
}),
|
|
3238
|
+
}), At.current = Fn({
|
|
3239
3239
|
socket: f,
|
|
3240
3240
|
chatId: c
|
|
3241
3241
|
});
|
|
@@ -3243,7 +3243,7 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3243
3243
|
if (!e) return;
|
|
3244
3244
|
S(Pr(h.chat_history || [])), re(!!h.is_human_handled), te(h.is_human_handled ? "agent" : T);
|
|
3245
3245
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3246
|
-
if (g && String(g).trim() &&
|
|
3246
|
+
if (g && String(g).trim() && Ft(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3247
3247
|
u("ready");
|
|
3248
3248
|
} catch (t) {
|
|
3249
3249
|
if (!e) return;
|
|
@@ -3252,22 +3252,22 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3252
3252
|
e && it(!1);
|
|
3253
3253
|
}
|
|
3254
3254
|
})(), () => {
|
|
3255
|
-
e = !1,
|
|
3255
|
+
e = !1, At.current?.cleanup?.(), It(), at.current?.disconnect();
|
|
3256
3256
|
};
|
|
3257
3257
|
}, [
|
|
3258
3258
|
i,
|
|
3259
3259
|
r,
|
|
3260
3260
|
a
|
|
3261
3261
|
]), c(() => () => {
|
|
3262
|
-
if (Fe && !
|
|
3263
|
-
let e = A.current, t =
|
|
3264
|
-
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}),
|
|
3262
|
+
if (Fe && !Dt.current && Et.current.length > 0) {
|
|
3263
|
+
let e = A.current, t = Et.current, n = k.current;
|
|
3264
|
+
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Dt.current = !0);
|
|
3265
3265
|
}
|
|
3266
3266
|
}, [Fe, _]);
|
|
3267
|
-
let
|
|
3267
|
+
let Vt = p(null), Ht = p(!1);
|
|
3268
3268
|
c(() => {
|
|
3269
3269
|
let e = k.current;
|
|
3270
|
-
!e || !y ||
|
|
3270
|
+
!e || !y || Vt.current !== C && (C && Vt.current !== null ? (e.updateChatStatus(y, "open").catch(() => {}), Ht.current = !0) : Vt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), Vt.current = C);
|
|
3271
3271
|
}, [C, y]), c(() => {
|
|
3272
3272
|
let e = () => {
|
|
3273
3273
|
let e = A.current, t = k.current;
|
|
@@ -3279,18 +3279,18 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3279
3279
|
let e = window.setInterval(async () => {
|
|
3280
3280
|
try {
|
|
3281
3281
|
let e = await k.current.checkHumanHandled(y);
|
|
3282
|
-
re(!!e.is_human_handled), e.is_human_handled && (te("agent"), e.agent_info?.name && D(Rr([e.agent_info.name], "Agent")), e.agent_info?.headshot && de(e.agent_info.headshot)),
|
|
3282
|
+
re(!!e.is_human_handled), e.is_human_handled && (te("agent"), e.agent_info?.name && D(Rr([e.agent_info.name], "Agent")), e.agent_info?.headshot && de(e.agent_info.headshot)), jt(e);
|
|
3283
3283
|
} catch {}
|
|
3284
3284
|
}, 1e4);
|
|
3285
3285
|
return () => window.clearInterval(e);
|
|
3286
3286
|
}, [
|
|
3287
3287
|
y,
|
|
3288
3288
|
l,
|
|
3289
|
-
|
|
3289
|
+
jt
|
|
3290
3290
|
]);
|
|
3291
|
-
let
|
|
3291
|
+
let Ut = async () => {
|
|
3292
3292
|
if (!(!O?.callId || !k.current || !at.current || !y)) {
|
|
3293
|
-
|
|
3293
|
+
Nt(), j.current = O.callId, Pt();
|
|
3294
3294
|
try {
|
|
3295
3295
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3296
3296
|
ut.current = e;
|
|
@@ -3306,26 +3306,26 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3306
3306
|
let e = n.connectionState;
|
|
3307
3307
|
if (e === "connected") {
|
|
3308
3308
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3309
|
-
Xe("connected"), Qe((t) => t || e),
|
|
3309
|
+
Xe("connected"), Qe((t) => t || e), Lt(e);
|
|
3310
3310
|
return;
|
|
3311
3311
|
}
|
|
3312
3312
|
if (e === "connecting") {
|
|
3313
3313
|
Xe((e) => e === "connected" ? e : "connecting");
|
|
3314
3314
|
return;
|
|
3315
3315
|
}
|
|
3316
|
-
(e === "failed" || e === "closed") &&
|
|
3316
|
+
(e === "failed" || e === "closed") && It(`peer:connection_${e}`);
|
|
3317
3317
|
}, n.oniceconnectionstatechange = () => {
|
|
3318
3318
|
let e = n.iceConnectionState;
|
|
3319
3319
|
if (e === "connected" || e === "completed") {
|
|
3320
3320
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3321
|
-
Xe("connected"), Qe((t) => t || e),
|
|
3321
|
+
Xe("connected"), Qe((t) => t || e), Lt(e);
|
|
3322
3322
|
return;
|
|
3323
3323
|
}
|
|
3324
3324
|
if (e === "checking" || e === "new") {
|
|
3325
3325
|
Xe((e) => e === "connected" ? e : "connecting");
|
|
3326
3326
|
return;
|
|
3327
3327
|
}
|
|
3328
|
-
(e === "failed" || e === "closed") &&
|
|
3328
|
+
(e === "failed" || e === "closed") && It(`peer:ice_${e}`);
|
|
3329
3329
|
}, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
|
|
3330
3330
|
n.addTrack(t, e);
|
|
3331
3331
|
}), n.onicecandidate = (e) => {
|
|
@@ -3346,10 +3346,10 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3346
3346
|
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, dt.current = e, document.body.appendChild(e);
|
|
3347
3347
|
}
|
|
3348
3348
|
dt.current.srcObject = e.streams[0];
|
|
3349
|
-
let r = O?.callId, i = r && (
|
|
3350
|
-
if (!
|
|
3349
|
+
let r = O?.callId, i = r && (j.current === r || gt.current === r);
|
|
3350
|
+
if (!vt.current && i) {
|
|
3351
3351
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3352
|
-
Xe("connected"), Qe((t) => t || e),
|
|
3352
|
+
Xe("connected"), Qe((t) => t || e), gt.current = r, Je(r), Lt(e);
|
|
3353
3353
|
}
|
|
3354
3354
|
dt.current.srcObject = t || null;
|
|
3355
3355
|
let a = dt.current.play?.();
|
|
@@ -3359,15 +3359,15 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3359
3359
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3360
3360
|
callId: r.callId || O.callId,
|
|
3361
3361
|
chatId: y
|
|
3362
|
-
}), await
|
|
3362
|
+
}), await Bt({
|
|
3363
3363
|
...r,
|
|
3364
3364
|
callId: r.callId || O.callId
|
|
3365
3365
|
})), await k.current.acceptCall(O.callId, y), at.current?.emit("call:accepted", {
|
|
3366
3366
|
callId: O.callId,
|
|
3367
3367
|
chatId: y
|
|
3368
|
-
}),
|
|
3368
|
+
}), gt.current = O.callId, Je(O.callId), Xe((e) => e === "connected" || vt.current ? "connected" : "connecting"), Ue(null), w(!0);
|
|
3369
3369
|
} catch (e) {
|
|
3370
|
-
if (
|
|
3370
|
+
if (j.current = null, It("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3371
3371
|
nt(Ir(e, "This visitor call is no longer available."));
|
|
3372
3372
|
return;
|
|
3373
3373
|
}
|
|
@@ -3383,13 +3383,13 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3383
3383
|
nt("We couldn't connect the call right now. Please try again.");
|
|
3384
3384
|
}
|
|
3385
3385
|
}
|
|
3386
|
-
},
|
|
3386
|
+
}, Wt = async () => {
|
|
3387
3387
|
if (!O?.callId || !k.current || !y) {
|
|
3388
|
-
|
|
3388
|
+
It("reject_call_without_server_context");
|
|
3389
3389
|
return;
|
|
3390
3390
|
}
|
|
3391
3391
|
let e = O.callId;
|
|
3392
|
-
|
|
3392
|
+
Pt(), Nt(), at.current?.emit("call:rejected", {
|
|
3393
3393
|
callId: e,
|
|
3394
3394
|
chatId: y,
|
|
3395
3395
|
reason: "visitor_declined"
|
|
@@ -3399,48 +3399,48 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3399
3399
|
} catch (e) {
|
|
3400
3400
|
nt(Ir(e, "We couldn't decline the call cleanly."));
|
|
3401
3401
|
} finally {
|
|
3402
|
-
|
|
3402
|
+
It("reject_call_finally");
|
|
3403
3403
|
}
|
|
3404
|
-
},
|
|
3405
|
-
|
|
3404
|
+
}, Gt = p(Wt);
|
|
3405
|
+
Gt.current = Wt, c(() => {
|
|
3406
3406
|
if (!O?.callId || qe) {
|
|
3407
|
-
|
|
3407
|
+
Pt();
|
|
3408
3408
|
return;
|
|
3409
3409
|
}
|
|
3410
3410
|
let e = O.callId;
|
|
3411
|
-
return
|
|
3412
|
-
ct.current?.callId === e &&
|
|
3411
|
+
return Pt(), _t.current = window.setTimeout(() => {
|
|
3412
|
+
ct.current?.callId === e && j.current !== e && gt.current !== e && Gt.current();
|
|
3413
3413
|
}, oe), () => {
|
|
3414
|
-
|
|
3414
|
+
_t.current &&= (window.clearTimeout(_t.current), null);
|
|
3415
3415
|
};
|
|
3416
3416
|
}, [
|
|
3417
3417
|
qe,
|
|
3418
|
-
|
|
3418
|
+
Pt,
|
|
3419
3419
|
O?.callId
|
|
3420
3420
|
]);
|
|
3421
|
-
let
|
|
3421
|
+
let Kt = async () => {
|
|
3422
3422
|
if (!qe || !k.current || !y) {
|
|
3423
|
-
|
|
3423
|
+
It("end_call_without_server_context");
|
|
3424
3424
|
return;
|
|
3425
3425
|
}
|
|
3426
|
-
|
|
3426
|
+
Nt();
|
|
3427
3427
|
try {
|
|
3428
3428
|
await k.current.endWebRTCCall(qe, y);
|
|
3429
3429
|
} catch (e) {
|
|
3430
3430
|
nt(Ir(e, "The call ended locally, but the server could not be updated."));
|
|
3431
3431
|
} finally {
|
|
3432
|
-
|
|
3432
|
+
It("end_call_finally");
|
|
3433
3433
|
}
|
|
3434
|
-
},
|
|
3434
|
+
}, qt = () => {
|
|
3435
3435
|
let e = ut.current?.getAudioTracks?.() || [], t = lt.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 = !$e;
|
|
3438
3438
|
n.forEach((e) => {
|
|
3439
3439
|
e.enabled = !r;
|
|
3440
3440
|
}), et(r);
|
|
3441
|
-
},
|
|
3441
|
+
}, Jt = async (e = {}) => {
|
|
3442
3442
|
let t = e.notifyChatInitiated === !0;
|
|
3443
|
-
if (
|
|
3443
|
+
if (Ht.current = !0, w(!0), !(!t || !k.current || !y || typeof window > "u")) {
|
|
3444
3444
|
try {
|
|
3445
3445
|
await k.current.trackVisitor({
|
|
3446
3446
|
chatId: y,
|
|
@@ -3451,8 +3451,8 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3451
3451
|
await k.current.updateChatStatus(y, "open");
|
|
3452
3452
|
} catch {}
|
|
3453
3453
|
}
|
|
3454
|
-
},
|
|
3455
|
-
let t =
|
|
3454
|
+
}, Yt = async (e) => {
|
|
3455
|
+
let t = Ft(e);
|
|
3456
3456
|
if (!t || !k.current || !A.current) return t;
|
|
3457
3457
|
try {
|
|
3458
3458
|
await k.current.trackVisitor({
|
|
@@ -3464,107 +3464,104 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3464
3464
|
console.error("[FlowEngageProvider] failed to persist visitor email", e);
|
|
3465
3465
|
}
|
|
3466
3466
|
return t;
|
|
3467
|
-
},
|
|
3468
|
-
!y || !at.current?.connected ||
|
|
3467
|
+
}, Xt = () => {
|
|
3468
|
+
!y || !at.current?.connected || yt.current || (yt.current = !0, at.current.emit("typing:start", {
|
|
3469
3469
|
chatId: y,
|
|
3470
3470
|
sender: "user"
|
|
3471
3471
|
}));
|
|
3472
|
-
},
|
|
3473
|
-
!y || !at.current?.connected || !
|
|
3472
|
+
}, Zt = () => {
|
|
3473
|
+
!y || !at.current?.connected || !yt.current || (yt.current = !1, at.current.emit("typing:stop", {
|
|
3474
3474
|
chatId: y,
|
|
3475
3475
|
sender: "user"
|
|
3476
3476
|
}));
|
|
3477
|
-
},
|
|
3477
|
+
}, Qt = (e = "") => {
|
|
3478
3478
|
let t = typeof e == "string" ? e : "";
|
|
3479
|
-
!y || !at.current?.connected || t !== "" &&
|
|
3479
|
+
!y || !at.current?.connected || t !== "" && bt.current === t || (bt.current = t, at.current.emit("typing:update", {
|
|
3480
3480
|
chatId: y,
|
|
3481
3481
|
sender: "user",
|
|
3482
3482
|
text: t
|
|
3483
3483
|
}));
|
|
3484
|
-
},
|
|
3485
|
-
let
|
|
3486
|
-
if (!
|
|
3487
|
-
|
|
3488
|
-
let
|
|
3489
|
-
if (pt.current &&
|
|
3484
|
+
}, $t = async (e, t = "", n = null, i = {}) => {
|
|
3485
|
+
let a = typeof e == "string" ? e.trim() : "";
|
|
3486
|
+
if (!a || !k.current || !y || l !== "ready" || Ve) return;
|
|
3487
|
+
Zt();
|
|
3488
|
+
let o = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i;
|
|
3489
|
+
if (pt.current && o.test(a)) {
|
|
3490
3490
|
let { url: e, section: t } = pt.current;
|
|
3491
|
-
pt.current = null, console.log("[FWH Nav] Client-side nav firing →", e), Or(e, { voiceActive:
|
|
3492
|
-
t
|
|
3491
|
+
pt.current = null, mt.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), Or(e, { voiceActive: Ot.current }).then((e) => {
|
|
3492
|
+
!t || !Ot.current || setTimeout(() => {
|
|
3493
3493
|
let e = _r(null, t);
|
|
3494
3494
|
e && vr(e);
|
|
3495
3495
|
}, e ? 300 : 150);
|
|
3496
3496
|
});
|
|
3497
|
-
} else
|
|
3498
|
-
let
|
|
3499
|
-
id:
|
|
3497
|
+
} else o.test(a) || (pt.current = null);
|
|
3498
|
+
let s = `pending-user-${Date.now()}`, c = {
|
|
3499
|
+
id: s,
|
|
3500
3500
|
sender: "user",
|
|
3501
3501
|
message: e,
|
|
3502
3502
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3503
3503
|
isPending: !0,
|
|
3504
|
-
type:
|
|
3505
|
-
metadata:
|
|
3504
|
+
type: i?.type || "text",
|
|
3505
|
+
metadata: i?.metadata || void 0,
|
|
3506
3506
|
...n || {}
|
|
3507
3507
|
};
|
|
3508
|
-
S((e) => [...e,
|
|
3509
|
-
let
|
|
3510
|
-
if (
|
|
3511
|
-
|
|
3508
|
+
S((e) => [...e, c]);
|
|
3509
|
+
let u = ne;
|
|
3510
|
+
if (u) try {
|
|
3511
|
+
u = jt(await k.current.checkHumanHandled(y));
|
|
3512
3512
|
} catch {}
|
|
3513
|
-
if (
|
|
3513
|
+
if (u && at.current?.connected) {
|
|
3514
3514
|
at.current.emit("customer:message", {
|
|
3515
3515
|
chatId: y,
|
|
3516
3516
|
content: e,
|
|
3517
3517
|
sender: "user",
|
|
3518
3518
|
email: fe || void 0,
|
|
3519
|
-
type:
|
|
3520
|
-
metadata:
|
|
3519
|
+
type: i?.type || "text",
|
|
3520
|
+
metadata: i?.metadata || {},
|
|
3521
3521
|
...n || {}
|
|
3522
3522
|
});
|
|
3523
3523
|
return;
|
|
3524
3524
|
}
|
|
3525
3525
|
ke(!0);
|
|
3526
3526
|
try {
|
|
3527
|
-
let
|
|
3527
|
+
let a = await k.current.sendAiMessage(y, e, r, t, {
|
|
3528
3528
|
...n || {},
|
|
3529
3529
|
...fe ? { email: fe } : {}
|
|
3530
3530
|
}, {
|
|
3531
|
-
...
|
|
3531
|
+
...i,
|
|
3532
3532
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
3533
3533
|
currentPageTitle: typeof window < "u" ? document.title : void 0,
|
|
3534
3534
|
currentPagePath: typeof window < "u" ? window.location.pathname : void 0
|
|
3535
|
-
}),
|
|
3535
|
+
}), o = a.chat_history || [];
|
|
3536
3536
|
if (console.log("[FWH Nav Debug] API response fields:", {
|
|
3537
|
-
has_navigate: !!
|
|
3538
|
-
navigate:
|
|
3539
|
-
has_pending_navigate: !!
|
|
3540
|
-
pending_navigate:
|
|
3541
|
-
last_bot_msg: [...
|
|
3542
|
-
}),
|
|
3543
|
-
url:
|
|
3544
|
-
section:
|
|
3545
|
-
}, console.log("[FWH Nav] Stored pending nav →", pt.current)),
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
let e = _r(null, t);
|
|
3554
|
-
e && vr(e);
|
|
3555
|
-
}, e ? 300 : 150);
|
|
3556
|
-
});
|
|
3537
|
+
has_navigate: !!a.navigate,
|
|
3538
|
+
navigate: a.navigate,
|
|
3539
|
+
has_pending_navigate: !!a.pending_navigate,
|
|
3540
|
+
pending_navigate: a.pending_navigate,
|
|
3541
|
+
last_bot_msg: [...o].reverse().find((e) => e.sender === "bot")?.message?.substring(0, 80)
|
|
3542
|
+
}), a.pending_navigate?.url && (pt.current = {
|
|
3543
|
+
url: a.pending_navigate.url,
|
|
3544
|
+
section: a.pending_navigate.section || null
|
|
3545
|
+
}, console.log("[FWH Nav] Stored pending nav →", pt.current)), a.navigate?.url) if (mt.current) mt.current = !1;
|
|
3546
|
+
else {
|
|
3547
|
+
let { url: e, section: t } = a.navigate;
|
|
3548
|
+
Or(e, { voiceActive: Ot.current }).then((e) => {
|
|
3549
|
+
!t || !Ot.current || setTimeout(() => {
|
|
3550
|
+
let e = _r(null, t);
|
|
3551
|
+
e && vr(e);
|
|
3552
|
+
}, e ? 300 : 150);
|
|
3557
3553
|
});
|
|
3558
|
-
}
|
|
3559
|
-
|
|
3554
|
+
}
|
|
3555
|
+
else {
|
|
3556
|
+
let e = [...o].reverse().find((e) => e.sender === "bot" || e.sender === "assistant");
|
|
3560
3557
|
if (e?.message) {
|
|
3561
3558
|
let t = Fr(e.message);
|
|
3562
3559
|
t && Sr(t.url, {
|
|
3563
|
-
siteId:
|
|
3564
|
-
apiBaseUrl:
|
|
3560
|
+
siteId: kt.current?.siteId,
|
|
3561
|
+
apiBaseUrl: kt.current?.apiBaseUrl
|
|
3565
3562
|
}).then((e) => {
|
|
3566
|
-
e && Or(t.url, { voiceActive:
|
|
3567
|
-
t.section
|
|
3563
|
+
e && Or(t.url, { voiceActive: Ot.current }).then((e) => {
|
|
3564
|
+
!t.section || !Ot.current || setTimeout(() => {
|
|
3568
3565
|
let e = _r(null, t.section);
|
|
3569
3566
|
e && vr(e);
|
|
3570
3567
|
}, e ? 300 : 150);
|
|
@@ -3572,26 +3569,26 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3572
3569
|
});
|
|
3573
3570
|
}
|
|
3574
3571
|
}
|
|
3575
|
-
S(Pr(
|
|
3572
|
+
S(Pr(o)), re(!!a.is_human_handled), te(a.is_human_handled ? "agent" : "ai"), we(!1), ke(!1), await k.current.updateChatStatus(y, "messageSent");
|
|
3576
3573
|
} catch (e) {
|
|
3577
|
-
S((e) => e.filter((e) => e.id !==
|
|
3574
|
+
S((e) => e.filter((e) => e.id !== s)), we(!1), ke(!1), e.status === 429 ? (je(!0), Ne(e.message), window.setTimeout(() => {
|
|
3578
3575
|
je(!1), Ne("");
|
|
3579
3576
|
}, ie)) : h(e);
|
|
3580
3577
|
}
|
|
3581
|
-
},
|
|
3578
|
+
}, en = async (e) => {
|
|
3582
3579
|
if (!k.current || !e) throw Error("Upload is unavailable right now.");
|
|
3583
3580
|
return k.current.uploadChatFile(e);
|
|
3584
|
-
},
|
|
3581
|
+
}, tn = async (e) => {
|
|
3585
3582
|
if (!(!k.current || !y)) {
|
|
3586
3583
|
try {
|
|
3587
3584
|
let t = e ? "voice" : "text";
|
|
3588
3585
|
await k.current.setChatMode(y, t);
|
|
3589
3586
|
} catch {}
|
|
3590
|
-
Ie(e), e && (
|
|
3587
|
+
Ie(e), e && (Dt.current = !1);
|
|
3591
3588
|
}
|
|
3592
|
-
},
|
|
3593
|
-
if (
|
|
3594
|
-
if (
|
|
3589
|
+
}, nn = async (e) => {
|
|
3590
|
+
if (Dt.current) return;
|
|
3591
|
+
if (Dt.current = !0, !k.current || !y || !e?.length) {
|
|
3595
3592
|
Ie(!1);
|
|
3596
3593
|
return;
|
|
3597
3594
|
}
|
|
@@ -3618,9 +3615,9 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3618
3615
|
} finally {
|
|
3619
3616
|
Ie(!1);
|
|
3620
3617
|
}
|
|
3621
|
-
},
|
|
3618
|
+
}, rn = async () => {
|
|
3622
3619
|
if (!(!k.current || !y)) {
|
|
3623
|
-
Fe && !
|
|
3620
|
+
Fe && !Dt.current && Et.current.length > 0 && await nn(Et.current);
|
|
3624
3621
|
try {
|
|
3625
3622
|
await k.current.endConversation(y);
|
|
3626
3623
|
} catch {
|
|
@@ -3638,9 +3635,9 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3638
3635
|
}
|
|
3639
3636
|
};
|
|
3640
3637
|
c(() => {
|
|
3641
|
-
if (Ye !== "connected" || !qe || !y || !Ze || !
|
|
3642
|
-
let e = new Date(Ze).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0,
|
|
3643
|
-
nt("The call ended because it reached the time limit."),
|
|
3638
|
+
if (Ye !== "connected" || !qe || !y || !Ze || !Mt) return;
|
|
3639
|
+
let e = new Date(Ze).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, Mt * 1e3 - t), r = window.setTimeout(() => {
|
|
3640
|
+
nt("The call ended because it reached the time limit."), Kt();
|
|
3644
3641
|
}, n);
|
|
3645
3642
|
return () => window.clearTimeout(r);
|
|
3646
3643
|
}, [
|
|
@@ -3648,29 +3645,29 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3648
3645
|
Ze,
|
|
3649
3646
|
Ye,
|
|
3650
3647
|
y,
|
|
3651
|
-
|
|
3652
|
-
|
|
3648
|
+
Kt,
|
|
3649
|
+
Mt
|
|
3653
3650
|
]), c(() => {
|
|
3654
3651
|
let e = () => {
|
|
3655
3652
|
let e = A.current, t = k.current;
|
|
3656
3653
|
if (!t || !e) return;
|
|
3657
|
-
if (
|
|
3658
|
-
t.beaconEndWebRTCCall(
|
|
3654
|
+
if (Ot.current && Et.current.length > 0 && Pe(), !Dt.current && Et.current.length > 0 && (t.beaconSyncVoice(e, Et.current) || t.syncVoice(e, Et.current).catch(() => {}), Dt.current = !0), gt.current) {
|
|
3655
|
+
t.beaconEndWebRTCCall(gt.current, e);
|
|
3659
3656
|
return;
|
|
3660
3657
|
}
|
|
3661
|
-
let n =
|
|
3658
|
+
let n = j.current || ct.current?.callId;
|
|
3662
3659
|
n && t.beaconCustomerUnavailable(n, e);
|
|
3663
3660
|
};
|
|
3664
3661
|
return window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), () => {
|
|
3665
3662
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
3666
3663
|
};
|
|
3667
3664
|
}, []);
|
|
3668
|
-
let
|
|
3665
|
+
let an = o(() => {
|
|
3669
3666
|
let e = i?.siteId;
|
|
3670
3667
|
ge(e), ot.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), A.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
|
|
3671
|
-
}, [i?.siteId]),
|
|
3668
|
+
}, [i?.siteId]), on = o((e) => {
|
|
3672
3669
|
i?.siteId, ot.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), A.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
|
|
3673
|
-
}, [i?.siteId]),
|
|
3670
|
+
}, [i?.siteId]), sn = f(() => ({
|
|
3674
3671
|
status: l,
|
|
3675
3672
|
error: d,
|
|
3676
3673
|
runtimeConfig: _,
|
|
@@ -3701,36 +3698,36 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3701
3698
|
isCallMuted: $e,
|
|
3702
3699
|
webRTCError: tt,
|
|
3703
3700
|
language: r,
|
|
3704
|
-
historyRef:
|
|
3705
|
-
hasSyncedRef:
|
|
3706
|
-
dismissCallError:
|
|
3707
|
-
captureVisitorEmail:
|
|
3708
|
-
startTyping:
|
|
3709
|
-
stopTyping:
|
|
3710
|
-
updateTypingDraft:
|
|
3711
|
-
notifyRouteChange: () =>
|
|
3712
|
-
openWidget:
|
|
3701
|
+
historyRef: Et,
|
|
3702
|
+
hasSyncedRef: Dt,
|
|
3703
|
+
dismissCallError: Nt,
|
|
3704
|
+
captureVisitorEmail: Yt,
|
|
3705
|
+
startTyping: Xt,
|
|
3706
|
+
stopTyping: Zt,
|
|
3707
|
+
updateTypingDraft: Qt,
|
|
3708
|
+
notifyRouteChange: () => At.current?.notifyRouteChange?.(),
|
|
3709
|
+
openWidget: Jt,
|
|
3713
3710
|
closeWidget: () => w(!1),
|
|
3714
3711
|
toggleWidget: () => {
|
|
3715
3712
|
if (C) {
|
|
3716
3713
|
w(!1);
|
|
3717
3714
|
return;
|
|
3718
3715
|
}
|
|
3719
|
-
|
|
3716
|
+
Jt({ notifyChatInitiated: !0 });
|
|
3720
3717
|
},
|
|
3721
|
-
sendMessage:
|
|
3722
|
-
uploadChatFile:
|
|
3723
|
-
setVoiceMode:
|
|
3724
|
-
onMessageSync:
|
|
3725
|
-
endConversation:
|
|
3726
|
-
startNewChat:
|
|
3727
|
-
resumeChat:
|
|
3718
|
+
sendMessage: $t,
|
|
3719
|
+
uploadChatFile: en,
|
|
3720
|
+
setVoiceMode: tn,
|
|
3721
|
+
onMessageSync: nn,
|
|
3722
|
+
endConversation: rn,
|
|
3723
|
+
startNewChat: an,
|
|
3724
|
+
resumeChat: on,
|
|
3728
3725
|
getVisitorChatHistory: () => k.current?.getVisitorChatHistory?.(),
|
|
3729
3726
|
getVisitorChatThread: (e) => k.current?.getVisitorChatThread?.(e),
|
|
3730
|
-
acceptCall:
|
|
3731
|
-
rejectCall:
|
|
3732
|
-
endWebRTCCall:
|
|
3733
|
-
toggleCallMute:
|
|
3727
|
+
acceptCall: Ut,
|
|
3728
|
+
rejectCall: Wt,
|
|
3729
|
+
endWebRTCCall: Kt,
|
|
3730
|
+
toggleCallMute: qt
|
|
3734
3731
|
}), [
|
|
3735
3732
|
l,
|
|
3736
3733
|
d,
|
|
@@ -3762,25 +3759,25 @@ function Br({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3762
3759
|
$e,
|
|
3763
3760
|
tt,
|
|
3764
3761
|
r,
|
|
3765
|
-
Jt,
|
|
3766
3762
|
Yt,
|
|
3767
3763
|
Xt,
|
|
3768
3764
|
Zt,
|
|
3769
|
-
|
|
3765
|
+
Qt,
|
|
3770
3766
|
Ut,
|
|
3771
|
-
|
|
3767
|
+
Wt,
|
|
3772
3768
|
Kt,
|
|
3773
3769
|
qt,
|
|
3774
|
-
|
|
3770
|
+
Jt,
|
|
3775
3771
|
$t,
|
|
3776
3772
|
en,
|
|
3777
3773
|
tn,
|
|
3778
3774
|
nn,
|
|
3779
3775
|
rn,
|
|
3780
|
-
|
|
3776
|
+
an,
|
|
3777
|
+
Nt
|
|
3781
3778
|
]);
|
|
3782
3779
|
return /* @__PURE__ */ g(In.Provider, {
|
|
3783
|
-
value:
|
|
3780
|
+
value: sn,
|
|
3784
3781
|
children: n
|
|
3785
3782
|
});
|
|
3786
3783
|
}
|