@flowengage/react-chatbot 8.0.128 → 8.0.130
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.
|
@@ -34,72 +34,72 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
34
34
|
agentName: "flowengage.agentName",
|
|
35
35
|
agentHeadshot: "flowengage.agentHeadshot",
|
|
36
36
|
visitorEmail: "flowengage.visitorEmail"
|
|
37
|
-
}, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u",
|
|
37
|
+
}, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", re = (e) => e ? `flowengage.visitorEmail.${e}` : null, ie = () => {
|
|
38
38
|
if (!j) return null;
|
|
39
39
|
let e = window.localStorage.getItem(A.chatId);
|
|
40
40
|
return e && String(e).trim() ? String(e).trim() : null;
|
|
41
|
-
},
|
|
41
|
+
}, ae = () => {
|
|
42
42
|
if (j) try {
|
|
43
43
|
window.localStorage.removeItem(A.chatId);
|
|
44
44
|
} catch {}
|
|
45
|
-
},
|
|
45
|
+
}, oe = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", M = (e) => e ? `flowengage.entrySeen.${e}` : null, se = (e) => {
|
|
46
46
|
if (!j || !e) return !1;
|
|
47
47
|
try {
|
|
48
|
-
let t =
|
|
48
|
+
let t = M(e);
|
|
49
49
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
50
50
|
} catch {
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
|
-
},
|
|
53
|
+
}, N = (e) => {
|
|
54
54
|
if (!(!j || !e)) try {
|
|
55
|
-
let t =
|
|
55
|
+
let t = M(e);
|
|
56
56
|
t && window.localStorage.setItem(t, "1");
|
|
57
57
|
} catch {}
|
|
58
|
-
},
|
|
58
|
+
}, ce = (e) => e ? `flowengage.navPreference.${e}` : null, P = (e) => e ? `flowengage.navPreferencePromptShown.${e}` : null, le = (e) => {
|
|
59
59
|
if (!j || !e) return null;
|
|
60
60
|
try {
|
|
61
|
-
let t =
|
|
61
|
+
let t = ce(e), n = t ? window.localStorage.getItem(t) : null;
|
|
62
62
|
return n === "auto" || n === "ask" ? n : null;
|
|
63
63
|
} catch {
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, ue = (e, t) => {
|
|
67
67
|
if (!(!j || !e || t !== "auto" && t !== "ask")) try {
|
|
68
|
-
let n =
|
|
69
|
-
n && window.localStorage.setItem(n, t),
|
|
68
|
+
let n = ce(e);
|
|
69
|
+
n && window.localStorage.setItem(n, t), fe(e);
|
|
70
70
|
} catch {}
|
|
71
|
-
},
|
|
71
|
+
}, de = (e) => {
|
|
72
72
|
if (!j || !e) return !1;
|
|
73
73
|
try {
|
|
74
|
-
let t =
|
|
74
|
+
let t = P(e);
|
|
75
75
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
76
76
|
} catch {
|
|
77
77
|
return !1;
|
|
78
78
|
}
|
|
79
|
-
},
|
|
79
|
+
}, fe = (e) => {
|
|
80
80
|
if (!(!j || !e)) try {
|
|
81
|
-
let t =
|
|
81
|
+
let t = P(e);
|
|
82
82
|
t && window.localStorage.setItem(t, "1");
|
|
83
83
|
} catch {}
|
|
84
|
-
},
|
|
84
|
+
}, pe = (e) => e ? `flowengage.persistedChatId.${e}` : null, me = (e) => {
|
|
85
85
|
if (!j || !e) return null;
|
|
86
86
|
try {
|
|
87
|
-
let t =
|
|
87
|
+
let t = pe(e), n = t ? window.localStorage.getItem(t) : null;
|
|
88
88
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
89
89
|
} catch {
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, he = (e) => {
|
|
93
93
|
if (!(!j || !e)) try {
|
|
94
|
-
let t =
|
|
94
|
+
let t = pe(e);
|
|
95
95
|
t && window.localStorage.removeItem(t);
|
|
96
96
|
} catch {}
|
|
97
|
-
},
|
|
97
|
+
}, ge = (e, t) => {
|
|
98
98
|
if (!(!j || !e || !t)) try {
|
|
99
|
-
let n =
|
|
99
|
+
let n = pe(e);
|
|
100
100
|
n && window.localStorage.setItem(n, String(t).trim());
|
|
101
101
|
} catch {}
|
|
102
|
-
},
|
|
102
|
+
}, _e = () => j ? {
|
|
103
103
|
isOpen: !1,
|
|
104
104
|
activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
|
|
105
105
|
isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
|
|
@@ -113,7 +113,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
113
113
|
agentName: null,
|
|
114
114
|
agentHeadshot: null,
|
|
115
115
|
visitorEmail: ""
|
|
116
|
-
},
|
|
116
|
+
}, ve = (e) => {
|
|
117
117
|
j && Object.entries(e).forEach(([e, t]) => {
|
|
118
118
|
let n = A[e];
|
|
119
119
|
if (n) {
|
|
@@ -124,17 +124,17 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
124
124
|
window.sessionStorage.setItem(n, String(t));
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
|
-
},
|
|
127
|
+
}, ye = (e) => {
|
|
128
128
|
if (!j || !e) return "";
|
|
129
|
-
let t =
|
|
129
|
+
let t = re(e), n = window.localStorage.getItem(t);
|
|
130
130
|
if (!n) {
|
|
131
131
|
let e = window.sessionStorage.getItem(A.visitorEmail);
|
|
132
132
|
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
|
|
133
133
|
}
|
|
134
134
|
return n || "";
|
|
135
|
-
},
|
|
135
|
+
}, be = (e, t) => {
|
|
136
136
|
if (!j) return;
|
|
137
|
-
let n =
|
|
137
|
+
let n = re(t);
|
|
138
138
|
if (!n) return;
|
|
139
139
|
let r = typeof e == "string" ? e.trim() : "";
|
|
140
140
|
if (!r) {
|
|
@@ -142,91 +142,91 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
|
|
145
|
-
},
|
|
145
|
+
}, xe = (e) => e ? `flowengage.visitorId.${e}` : null, Se = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, F = (e) => {
|
|
146
146
|
if (!j || !e) return null;
|
|
147
147
|
try {
|
|
148
|
-
let t =
|
|
148
|
+
let t = xe(e), n = t ? window.localStorage.getItem(t) : null;
|
|
149
149
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
150
150
|
} catch {
|
|
151
151
|
return null;
|
|
152
152
|
}
|
|
153
|
-
},
|
|
153
|
+
}, I = (e) => {
|
|
154
154
|
if (!j || !e) return null;
|
|
155
155
|
try {
|
|
156
|
-
let t =
|
|
156
|
+
let t = F(e);
|
|
157
157
|
if (t) return t;
|
|
158
|
-
let n =
|
|
158
|
+
let n = Se(), r = xe(e);
|
|
159
159
|
return r && window.localStorage.setItem(r, n), n;
|
|
160
160
|
} catch {
|
|
161
|
-
return
|
|
161
|
+
return Se();
|
|
162
162
|
}
|
|
163
|
-
},
|
|
163
|
+
}, L = "flowengage.tabId", Ce = () => {
|
|
164
164
|
if (!j) return "default";
|
|
165
165
|
try {
|
|
166
|
-
let e = window.sessionStorage.getItem(
|
|
167
|
-
return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(
|
|
166
|
+
let e = window.sessionStorage.getItem(L);
|
|
167
|
+
return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(L, e)), e;
|
|
168
168
|
} catch {
|
|
169
169
|
return "default";
|
|
170
170
|
}
|
|
171
|
-
},
|
|
171
|
+
}, we = (e) => e ? `flowengage.voice.transcript.${e}.${Ce()}` : null, Te = 600 * 1e3, Ee = (e, t, n = {}) => {
|
|
172
172
|
if (!j || !e) return;
|
|
173
173
|
let r = typeof t == "string" ? t.trim() : "";
|
|
174
174
|
if (!r) return;
|
|
175
|
-
let i = Number.isFinite(n.ttlMs) ? n.ttlMs :
|
|
175
|
+
let i = Number.isFinite(n.ttlMs) ? n.ttlMs : Te, a = {
|
|
176
176
|
transcript: r,
|
|
177
177
|
expiresAt: Date.now() + i
|
|
178
178
|
};
|
|
179
179
|
try {
|
|
180
|
-
let t =
|
|
180
|
+
let t = we(e);
|
|
181
181
|
t && window.localStorage.setItem(t, JSON.stringify(a));
|
|
182
182
|
} catch {}
|
|
183
|
-
},
|
|
183
|
+
}, De = (e) => {
|
|
184
184
|
if (!j || !e) return null;
|
|
185
185
|
try {
|
|
186
|
-
let t =
|
|
186
|
+
let t = we(e), n = t ? window.localStorage.getItem(t) : null;
|
|
187
187
|
if (!n) return null;
|
|
188
188
|
let r = JSON.parse(n);
|
|
189
189
|
return !r || typeof r.transcript != "string" ? null : Number.isFinite(r.expiresAt) && Date.now() > r.expiresAt ? (window.localStorage.removeItem(t), null) : r;
|
|
190
190
|
} catch {
|
|
191
191
|
return null;
|
|
192
192
|
}
|
|
193
|
-
},
|
|
193
|
+
}, Oe = (e) => {
|
|
194
194
|
if (!(!j || !e)) try {
|
|
195
|
-
let t =
|
|
195
|
+
let t = we(e);
|
|
196
196
|
t && window.localStorage.removeItem(t);
|
|
197
197
|
} catch {}
|
|
198
|
-
},
|
|
198
|
+
}, ke = "flowengage.voice.pendingResume", Ae = () => {
|
|
199
199
|
if (j) try {
|
|
200
|
-
window.sessionStorage.setItem(
|
|
200
|
+
window.sessionStorage.setItem(ke, "1");
|
|
201
201
|
} catch {}
|
|
202
|
-
},
|
|
202
|
+
}, je = () => {
|
|
203
203
|
if (!j) return !1;
|
|
204
204
|
try {
|
|
205
|
-
return window.sessionStorage.getItem(
|
|
205
|
+
return window.sessionStorage.getItem(ke) === "1" ? (window.sessionStorage.removeItem(ke), !0) : !1;
|
|
206
206
|
} catch {
|
|
207
207
|
return !1;
|
|
208
208
|
}
|
|
209
|
-
},
|
|
209
|
+
}, Me = "flowengage.chat.pendingReopen", Ne = () => {
|
|
210
210
|
if (j) try {
|
|
211
|
-
window.sessionStorage.setItem(
|
|
211
|
+
window.sessionStorage.setItem(Me, "1");
|
|
212
212
|
} catch {}
|
|
213
|
-
},
|
|
213
|
+
}, Pe = () => {
|
|
214
214
|
if (!j) return !1;
|
|
215
215
|
try {
|
|
216
|
-
return window.sessionStorage.getItem(
|
|
216
|
+
return window.sessionStorage.getItem(Me) === "1" ? (window.sessionStorage.removeItem(Me), !0) : !1;
|
|
217
217
|
} catch {
|
|
218
218
|
return !1;
|
|
219
219
|
}
|
|
220
|
-
},
|
|
220
|
+
}, Fe = () => {
|
|
221
221
|
if (!j) return !1;
|
|
222
222
|
try {
|
|
223
|
-
return window.sessionStorage.getItem(
|
|
223
|
+
return window.sessionStorage.getItem(ke) === "1";
|
|
224
224
|
} catch {
|
|
225
225
|
return !1;
|
|
226
226
|
}
|
|
227
|
-
},
|
|
227
|
+
}, Ie = (e) => e ? `flowengage.voice.navState.${e}.${Ce()}` : null, Le = (e, t, n, r) => {
|
|
228
228
|
if (!(!j || !e || !t)) try {
|
|
229
|
-
let i =
|
|
229
|
+
let i = Ie(e);
|
|
230
230
|
i && window.sessionStorage.setItem(i, JSON.stringify({
|
|
231
231
|
previousPage: String(t),
|
|
232
232
|
targetPath: n ? new URL(String(n), window.location.href).pathname : null,
|
|
@@ -234,10 +234,10 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
234
234
|
ts: Date.now()
|
|
235
235
|
}));
|
|
236
236
|
} catch {}
|
|
237
|
-
},
|
|
237
|
+
}, Re = (e) => {
|
|
238
238
|
if (!j || !e) return null;
|
|
239
239
|
try {
|
|
240
|
-
let t =
|
|
240
|
+
let t = Ie(e);
|
|
241
241
|
if (!t) return null;
|
|
242
242
|
let n = window.sessionStorage.getItem(t);
|
|
243
243
|
if (!n) return null;
|
|
@@ -250,14 +250,14 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
250
250
|
} catch {
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
|
-
},
|
|
253
|
+
}, R = async (e) => {
|
|
254
254
|
let t = await e.json().catch(() => ({}));
|
|
255
255
|
if (!e.ok) {
|
|
256
256
|
let n = Error(t.message || t.error || `Request failed with status ${e.status}`);
|
|
257
257
|
throw n.status = e.status, n;
|
|
258
258
|
}
|
|
259
259
|
return t;
|
|
260
|
-
},
|
|
260
|
+
}, ze = async (e, t = {}) => {
|
|
261
261
|
try {
|
|
262
262
|
return await fetch(e, {
|
|
263
263
|
mode: "cors",
|
|
@@ -267,9 +267,9 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
267
267
|
let n = /* @__PURE__ */ Error(`Network error reaching ${e}. Check: (1) backend is running, (2) CORS allows this origin, (3) siteId is correct. Original: ${t.message}`);
|
|
268
268
|
throw n.status = 0, n.cause = t, n;
|
|
269
269
|
}
|
|
270
|
-
},
|
|
270
|
+
}, Be = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
|
|
271
271
|
let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
|
|
272
|
-
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o),
|
|
272
|
+
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), R(await ze(s, {
|
|
273
273
|
method: "POST",
|
|
274
274
|
mode: "cors",
|
|
275
275
|
headers: {
|
|
@@ -280,13 +280,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
280
280
|
},
|
|
281
281
|
body: JSON.stringify(c)
|
|
282
282
|
}));
|
|
283
|
-
},
|
|
283
|
+
}, Ve = async ({ apiBaseUrl: e, siteId: t }) => {
|
|
284
284
|
let n = typeof window < "u" ? window.location.origin : "http://localhost";
|
|
285
|
-
return (await
|
|
285
|
+
return (await R(await ze(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
|
|
286
286
|
siteId: t,
|
|
287
287
|
origin: n
|
|
288
288
|
}).toString()}`, { method: "GET" }))).data;
|
|
289
|
-
},
|
|
289
|
+
}, z = ({ apiBaseUrl: e, userId: t, siteId: n, visitorId: r = null }) => {
|
|
290
290
|
let i = (t, n) => {
|
|
291
291
|
let r = `${e}${t}`, i = JSON.stringify(n);
|
|
292
292
|
if (typeof navigator < "u" && navigator.sendBeacon) try {
|
|
@@ -300,7 +300,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
300
300
|
headers: { "Content-Type": "application/json" },
|
|
301
301
|
body: i
|
|
302
302
|
}).catch(() => {}), !0) : !1;
|
|
303
|
-
}, a = async (i, a = {}) =>
|
|
303
|
+
}, a = async (i, a = {}) => R(await ze(`${e}${i}`, {
|
|
304
304
|
...a,
|
|
305
305
|
headers: {
|
|
306
306
|
"Content-Type": "application/json",
|
|
@@ -315,7 +315,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
315
315
|
...n ? { "x-site-id": n } : {},
|
|
316
316
|
...a.headers || {}
|
|
317
317
|
};
|
|
318
|
-
return
|
|
318
|
+
return R(await ze(`${e}${r}`, {
|
|
319
319
|
...a,
|
|
320
320
|
body: i,
|
|
321
321
|
headers: o
|
|
@@ -346,7 +346,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
346
346
|
method: "POST",
|
|
347
347
|
body: JSON.stringify(f)
|
|
348
348
|
});
|
|
349
|
-
let p = await
|
|
349
|
+
let p = await ze(`${e}/api/ai/chat`, {
|
|
350
350
|
method: "POST",
|
|
351
351
|
headers: {
|
|
352
352
|
"Content-Type": "application/json",
|
|
@@ -359,7 +359,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
359
359
|
stream: !0
|
|
360
360
|
})
|
|
361
361
|
});
|
|
362
|
-
if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return
|
|
362
|
+
if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return R(p);
|
|
363
363
|
let m = p.body.getReader(), h = new TextDecoder(), g = "", _ = null, v = (e) => {
|
|
364
364
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
365
365
|
if (t) try {
|
|
@@ -475,7 +475,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
475
475
|
});
|
|
476
476
|
},
|
|
477
477
|
async getIceServersConfig() {
|
|
478
|
-
return
|
|
478
|
+
return R(await ze(`${e}/api/calls/ice-config`, {
|
|
479
479
|
method: "GET",
|
|
480
480
|
headers: {
|
|
481
481
|
"x-user-id": t,
|
|
@@ -2881,7 +2881,7 @@ async function Ar(e, t = {}) {
|
|
|
2881
2881
|
reason: "already-on-page"
|
|
2882
2882
|
};
|
|
2883
2883
|
let a = i.pathname + i.search + i.hash;
|
|
2884
|
-
if (window.Shopify) return n && br(n), r ||
|
|
2884
|
+
if (window.Shopify) return n && br(n), r || Ne(), r ? kr().then(() => window.location.assign(i.href)) : window.location.assign(i.href), { navigated: !0 };
|
|
2885
2885
|
let o = window.next?.router;
|
|
2886
2886
|
if (o?.push) return new Promise((e) => {
|
|
2887
2887
|
let t = () => {
|
|
@@ -2900,11 +2900,11 @@ async function Ar(e, t = {}) {
|
|
|
2900
2900
|
try {
|
|
2901
2901
|
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
2902
2902
|
} catch {}
|
|
2903
|
-
return n && br(n), r ||
|
|
2903
|
+
return n && br(n), r || Ne(), window.location.assign(i.href), { navigated: !0 };
|
|
2904
2904
|
}
|
|
2905
2905
|
return { navigated: !0 };
|
|
2906
2906
|
}
|
|
2907
|
-
return n && br(n), r ||
|
|
2907
|
+
return n && br(n), r || Ne(), window.location.assign(i.href), { navigated: !0 };
|
|
2908
2908
|
} catch (t) {
|
|
2909
2909
|
console.warn("[FlowEngage] shadowNavigate error:", t), n && br(n);
|
|
2910
2910
|
try {
|
|
@@ -3325,7 +3325,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3325
3325
|
message: "Looks like you're already on this page!",
|
|
3326
3326
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3327
3327
|
}]);
|
|
3328
|
-
}, []), [D, O] = m(
|
|
3328
|
+
}, []), [D, O] = m(_e().isOpen), [k, A] = m(_e().activeScreen), [j, re] = m(_e().isHumanHandled), [M, se] = m(_e().agentName), [N, ce] = m(_e().agentHeadshot), [P, ue] = m(() => ye(i?.siteId)), [pe, xe] = m(!1), [Se, F] = m(!1), [L, Ce] = m("idle"), [we, Te] = m(!1), [Ee, De] = m(!1), [Oe, ke] = m(""), [je, Me] = m(!1), [Ne, Pe] = m(0), [Fe, Ie] = m(0), [Le, Re] = m(!1), [R, ze] = m(null), [B, He] = m(null), [Ue, V] = m("idle"), [We, Ge] = m(null), [Ke, qe] = m(!1), [Je, Ye] = m(""), [Xe, Ze] = m(!1), H = p(null), U = p(null), Qe = p(""), $e = p(!1), W = p(null), et = p(null), tt = p(null), nt = p(null), rt = p(null), it = p(null), at = p(null), ot = p(!1), st = p({
|
|
3329
3329
|
url: null,
|
|
3330
3330
|
at: 0
|
|
3331
3331
|
}), ct = o((e, t) => {
|
|
@@ -3342,23 +3342,23 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3342
3342
|
url: n,
|
|
3343
3343
|
at: Date.now()
|
|
3344
3344
|
}, Ar(e, t));
|
|
3345
|
-
}, []), G = p([]), lt = p(null), ut = p(null), dt = p(null), ft = p(!1), pt = p(!1), mt = p(""), ht = p(null), gt = p(null), _t = p([]), vt = p(0), yt = p(
|
|
3345
|
+
}, []), G = p([]), lt = p(null), ut = p(null), dt = p(null), ft = p(!1), pt = p(!1), mt = p(""), ht = p(null), gt = p(null), _t = p([]), vt = p(0), yt = p(M), bt = p([]), xt = p(!1), St = p(!1), Ct = p(i), wt = p({
|
|
3346
3346
|
notifyRouteChange: () => {},
|
|
3347
3347
|
cleanup: () => {}
|
|
3348
3348
|
}), Tt = o((e = {}) => {
|
|
3349
3349
|
let t = !!e.is_human_handled;
|
|
3350
|
-
return
|
|
3350
|
+
return re(t), t ? (A("agent"), e.agent_info?.name && se(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (A("ai"), t);
|
|
3351
3351
|
}, []), Et = f(() => {
|
|
3352
3352
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
3353
3353
|
return Number.isFinite(t) && t > 0 ? t : te;
|
|
3354
3354
|
}, [i, _]);
|
|
3355
3355
|
c(() => {
|
|
3356
|
-
et.current =
|
|
3357
|
-
}, [
|
|
3358
|
-
yt.current =
|
|
3359
|
-
}, [
|
|
3360
|
-
St.current =
|
|
3361
|
-
}, [
|
|
3356
|
+
et.current = R;
|
|
3357
|
+
}, [R]), c(() => {
|
|
3358
|
+
yt.current = M;
|
|
3359
|
+
}, [M]), c(() => {
|
|
3360
|
+
St.current = je;
|
|
3361
|
+
}, [je]), c(() => {
|
|
3362
3362
|
Ct.current = i;
|
|
3363
3363
|
}, [i]);
|
|
3364
3364
|
let Dt = () => {
|
|
@@ -3367,17 +3367,17 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3367
3367
|
dt.current &&= (window.clearTimeout(dt.current), null);
|
|
3368
3368
|
}, []), kt = (e) => {
|
|
3369
3369
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
3370
|
-
return
|
|
3370
|
+
return ue(t), be(t, i?.siteId), t;
|
|
3371
3371
|
};
|
|
3372
3372
|
c(() => {
|
|
3373
3373
|
let e = i?.siteId;
|
|
3374
3374
|
if (!e) return;
|
|
3375
|
-
let t =
|
|
3375
|
+
let t = ye(e);
|
|
3376
3376
|
if (t) {
|
|
3377
|
-
|
|
3377
|
+
ue(t);
|
|
3378
3378
|
return;
|
|
3379
3379
|
}
|
|
3380
|
-
|
|
3380
|
+
ue((t) => (t && be(t, e), t));
|
|
3381
3381
|
}, [i?.siteId]);
|
|
3382
3382
|
let At = (e = "unspecified") => {
|
|
3383
3383
|
let t = lt.current || it.current?.callId, n = vt.current, r = ht.current;
|
|
@@ -3407,7 +3407,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3407
3407
|
} catch {}
|
|
3408
3408
|
gt.current = null;
|
|
3409
3409
|
}
|
|
3410
|
-
tt.current &&= (tt.current.close(), null), nt.current &&= (nt.current.getTracks().forEach((e) => e.stop()), null), rt.current &&= (rt.current.srcObject = null, rt.current.remove(), null), Ot(), it.current = null, G.current = [], lt.current = null, ut.current = null, ft.current = !1, qe(!1),
|
|
3410
|
+
tt.current &&= (tt.current.close(), null), nt.current &&= (nt.current.getTracks().forEach((e) => e.stop()), null), rt.current &&= (rt.current.srcObject = null, rt.current.remove(), null), Ot(), it.current = null, G.current = [], lt.current = null, ut.current = null, ft.current = !1, qe(!1), ze(null), He(null), V("idle"), Ge(null);
|
|
3411
3411
|
}, jt = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
3412
3412
|
let t = H.current, n = lt.current || it.current?.callId;
|
|
3413
3413
|
if (!(!t?.connected || !n || ft.current)) {
|
|
@@ -3459,7 +3459,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3459
3459
|
if (!e.callId) return;
|
|
3460
3460
|
let t = ut.current === e.callId, n = lt.current === e.callId, r = et.current?.callId === e.callId;
|
|
3461
3461
|
if (!(!t && !n && !r)) {
|
|
3462
|
-
if (Ot(),
|
|
3462
|
+
if (Ot(), ze(null), t || n) {
|
|
3463
3463
|
lt.current = e.callId, He(e.callId), V((e) => e === "connected" ? e : "connecting"), O(!0);
|
|
3464
3464
|
return;
|
|
3465
3465
|
}
|
|
@@ -3473,7 +3473,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3473
3473
|
At();
|
|
3474
3474
|
return;
|
|
3475
3475
|
}
|
|
3476
|
-
ut.current = null, it.current = null, G.current = [],
|
|
3476
|
+
ut.current = null, it.current = null, G.current = [], ze(null), V("idle");
|
|
3477
3477
|
}
|
|
3478
3478
|
}, Pt = async (e = {}) => {
|
|
3479
3479
|
let t = tt.current, n = H.current, r = e.sdpOffer || e.offer?.sdp;
|
|
@@ -3507,44 +3507,44 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3507
3507
|
});
|
|
3508
3508
|
};
|
|
3509
3509
|
c(() => {
|
|
3510
|
-
|
|
3510
|
+
ve({
|
|
3511
3511
|
isOpen: D,
|
|
3512
3512
|
activeScreen: k,
|
|
3513
3513
|
isHumanHandled: j,
|
|
3514
|
-
agentName:
|
|
3515
|
-
agentHeadshot:
|
|
3514
|
+
agentName: M,
|
|
3515
|
+
agentHeadshot: N
|
|
3516
3516
|
});
|
|
3517
3517
|
}, [
|
|
3518
3518
|
D,
|
|
3519
3519
|
k,
|
|
3520
3520
|
j,
|
|
3521
|
-
|
|
3522
|
-
|
|
3521
|
+
M,
|
|
3522
|
+
N
|
|
3523
3523
|
]), c(() => {
|
|
3524
3524
|
let e = !0;
|
|
3525
3525
|
return (async () => {
|
|
3526
3526
|
Ze(!0);
|
|
3527
3527
|
try {
|
|
3528
|
-
let t = E(i), n = await
|
|
3528
|
+
let t = E(i), n = await Ve(t);
|
|
3529
3529
|
if (!e) return;
|
|
3530
|
-
let a = t.siteId, o =
|
|
3530
|
+
let a = t.siteId, o = me(a), s = I(a), c = "";
|
|
3531
3531
|
try {
|
|
3532
3532
|
let e = $e.current, r = W.current;
|
|
3533
|
-
if ($e.current = !1, W.current = null, c = (await
|
|
3533
|
+
if ($e.current = !1, W.current = null, c = (await Be({
|
|
3534
3534
|
apiBaseUrl: t.apiBaseUrl,
|
|
3535
3535
|
userId: n.userId,
|
|
3536
3536
|
siteId: a,
|
|
3537
|
-
priorChatId: e || r ? null : o ||
|
|
3537
|
+
priorChatId: e || r ? null : o || ie(),
|
|
3538
3538
|
forceNew: e,
|
|
3539
3539
|
resumeChatId: r,
|
|
3540
3540
|
visitorId: s
|
|
3541
3541
|
}))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
|
|
3542
|
-
|
|
3542
|
+
ae(), ge(a, c);
|
|
3543
3543
|
} catch (e) {
|
|
3544
|
-
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o ||
|
|
3544
|
+
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || oe(), ge(a, c);
|
|
3545
3545
|
}
|
|
3546
3546
|
Qe.current = c;
|
|
3547
|
-
let l =
|
|
3547
|
+
let l = z({
|
|
3548
3548
|
apiBaseUrl: t.apiBaseUrl,
|
|
3549
3549
|
userId: n.userId,
|
|
3550
3550
|
siteId: t.siteId,
|
|
@@ -3561,23 +3561,23 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3561
3561
|
siteId: t.siteId
|
|
3562
3562
|
});
|
|
3563
3563
|
H.current = f, f.on("connect", async () => {
|
|
3564
|
-
|
|
3564
|
+
Ce("connected");
|
|
3565
3565
|
let e = Qe.current;
|
|
3566
3566
|
if (e && U.current) try {
|
|
3567
3567
|
Tt(await U.current.checkHumanHandled(e));
|
|
3568
3568
|
} catch {}
|
|
3569
3569
|
}), f.on("disconnect", () => {
|
|
3570
|
-
|
|
3570
|
+
Ce("disconnected");
|
|
3571
3571
|
}), f.on("aiTyping", () => {
|
|
3572
|
-
|
|
3572
|
+
F(!0);
|
|
3573
3573
|
}), f.on("ai:typing", () => {
|
|
3574
|
-
|
|
3574
|
+
F(!0);
|
|
3575
3575
|
}), f.on("messageReceived", (e) => {
|
|
3576
3576
|
let t = e.message || e, n = {
|
|
3577
3577
|
...t,
|
|
3578
3578
|
message: fi(t.message)
|
|
3579
3579
|
};
|
|
3580
|
-
|
|
3580
|
+
F(!1), xe(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
|
|
3581
3581
|
...n,
|
|
3582
3582
|
isPending: !1,
|
|
3583
3583
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3595,7 +3595,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3595
3595
|
...t,
|
|
3596
3596
|
message: fi(t.message)
|
|
3597
3597
|
};
|
|
3598
|
-
|
|
3598
|
+
F(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && xe(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
|
|
3599
3599
|
...n,
|
|
3600
3600
|
isPending: !1,
|
|
3601
3601
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3607,11 +3607,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3607
3607
|
...n,
|
|
3608
3608
|
isPending: !1,
|
|
3609
3609
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
3610
|
-
}]), (n.sender === "agent" || n.agent_name) && (
|
|
3610
|
+
}]), (n.sender === "agent" || n.agent_name) && (re(!0), A("agent"), se(_i([
|
|
3611
3611
|
n.agent_name,
|
|
3612
3612
|
n.agentName,
|
|
3613
3613
|
n.metadata?.agentName
|
|
3614
|
-
], d)), n.sender_headshot &&
|
|
3614
|
+
], d)), n.sender_headshot && ce(n.sender_headshot), O(!0), Pe((e) => e + 1)));
|
|
3615
3615
|
});
|
|
3616
3616
|
let p = (e = {}) => {
|
|
3617
3617
|
let t = _i([
|
|
@@ -3620,7 +3620,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3620
3620
|
e.agent_name,
|
|
3621
3621
|
yt.current
|
|
3622
3622
|
], d);
|
|
3623
|
-
|
|
3623
|
+
re(!0), A("agent"), se(t), ce(e.agent?.headshot || null), O(!0), Pe((e) => e + 1), S((e) => vi(e, {
|
|
3624
3624
|
id: `agent-joined-${Date.now()}`,
|
|
3625
3625
|
sender: "system",
|
|
3626
3626
|
message: `${t} has joined the chat.`,
|
|
@@ -3634,7 +3634,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3634
3634
|
e.agent_name,
|
|
3635
3635
|
yt.current
|
|
3636
3636
|
], d);
|
|
3637
|
-
|
|
3637
|
+
re(!1), A("ai"), S((e) => vi(e, {
|
|
3638
3638
|
id: `agent-left-${Date.now()}`,
|
|
3639
3639
|
sender: "system",
|
|
3640
3640
|
message: `${t} has left the chat.`,
|
|
@@ -3643,7 +3643,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3643
3643
|
}));
|
|
3644
3644
|
};
|
|
3645
3645
|
f.on("agent:joined", p), f.on("agentJoined", p), f.on("agent:left", m), f.on("agentLeft", m), f.on("conversationEnded", (e) => {
|
|
3646
|
-
|
|
3646
|
+
Re(!0);
|
|
3647
3647
|
let t = e?.message || "This conversation has ended. Thank you for reaching out!";
|
|
3648
3648
|
S((e) => [...e, {
|
|
3649
3649
|
id: `conversation-ended-${Date.now()}`,
|
|
@@ -3654,15 +3654,15 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3654
3654
|
}]);
|
|
3655
3655
|
}), f.on("chat:history_update", (e) => {
|
|
3656
3656
|
let t = pi(e.chat_history || []);
|
|
3657
|
-
S(t), t.length === 0 && (
|
|
3657
|
+
S(t), t.length === 0 && (Re(!1), re(!1), A("ai"), F(!1), xe(!1));
|
|
3658
3658
|
}), f.on("conversation:reset", () => {
|
|
3659
|
-
S([]),
|
|
3659
|
+
S([]), Re(!1), re(!1), A("ai"), F(!1), xe(!1);
|
|
3660
3660
|
}), f.on("voice:end_session", (e = {}) => {
|
|
3661
|
-
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"),
|
|
3661
|
+
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ie((e) => e + 1), O(!0), Pe((e) => e + 1);
|
|
3662
3662
|
}), f.on("typing:start", (e) => {
|
|
3663
|
-
e.sender === "agent" &&
|
|
3663
|
+
e.sender === "agent" && xe(!0);
|
|
3664
3664
|
}), f.on("typing:stop", (e) => {
|
|
3665
|
-
e.sender === "agent" &&
|
|
3665
|
+
e.sender === "agent" && xe(!1);
|
|
3666
3666
|
}), f.on("call:incoming", (e = {}) => {
|
|
3667
3667
|
let t = _i([
|
|
3668
3668
|
e.agentName,
|
|
@@ -3670,12 +3670,12 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3670
3670
|
e.agent?.name,
|
|
3671
3671
|
yt.current
|
|
3672
3672
|
], "Agent");
|
|
3673
|
-
Dt(), Ot(), ft.current = !1,
|
|
3673
|
+
Dt(), Ot(), ft.current = !1, ze({
|
|
3674
3674
|
callId: e.callId,
|
|
3675
3675
|
from: e.from || "owner",
|
|
3676
3676
|
agentId: e.agentId || null,
|
|
3677
3677
|
agentName: t
|
|
3678
|
-
}),
|
|
3678
|
+
}), se((e) => _i([t, e], "Agent")), V("incoming"), Ge(null), O(!0);
|
|
3679
3679
|
}), f.on("call:offer", async (e = {}) => {
|
|
3680
3680
|
it.current = e;
|
|
3681
3681
|
try {
|
|
@@ -3718,10 +3718,10 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3718
3718
|
if (!e.callId) return;
|
|
3719
3719
|
let t = ut.current === e.callId, n = lt.current === e.callId, r = it.current?.callId === e.callId, i = et.current?.callId === e.callId;
|
|
3720
3720
|
if (!t && !n && !r) {
|
|
3721
|
-
i && (
|
|
3721
|
+
i && (ze(null), V("idle"));
|
|
3722
3722
|
return;
|
|
3723
3723
|
}
|
|
3724
|
-
ft.current = !0, ut.current = null, lt.current = e.callId, He(e.callId),
|
|
3724
|
+
ft.current = !0, ut.current = null, lt.current = e.callId, He(e.callId), ze(null), V("connected"), Ge(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), O(!0);
|
|
3725
3725
|
}), f.on("call:unavailable", (e = {}) => {
|
|
3726
3726
|
At("socket:call_unavailable"), Ye(hi(e, "This visitor is not available for a call right now.")), O(!0);
|
|
3727
3727
|
}), f.on("call:error", (e = {}) => {
|
|
@@ -3750,7 +3750,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3750
3750
|
});
|
|
3751
3751
|
let h = await l.loadHistory(c, r);
|
|
3752
3752
|
if (!e) return;
|
|
3753
|
-
S(pi(h.chat_history || [])),
|
|
3753
|
+
S(pi(h.chat_history || [])), re(!!h.is_human_handled), A(h.is_human_handled ? "agent" : k);
|
|
3754
3754
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3755
3755
|
if (g && String(g).trim() && kt(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3756
3756
|
u("ready");
|
|
@@ -3768,11 +3768,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3768
3768
|
r,
|
|
3769
3769
|
a
|
|
3770
3770
|
]), c(() => () => {
|
|
3771
|
-
if (
|
|
3771
|
+
if (je && !xt.current && bt.current.length > 0) {
|
|
3772
3772
|
let e = Qe.current, t = bt.current, n = U.current;
|
|
3773
3773
|
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), xt.current = !0);
|
|
3774
3774
|
}
|
|
3775
|
-
}, [
|
|
3775
|
+
}, [je, _]);
|
|
3776
3776
|
let Ft = p(null);
|
|
3777
3777
|
c(() => {
|
|
3778
3778
|
let e = U.current;
|
|
@@ -3785,8 +3785,8 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3785
3785
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
3786
3786
|
}, []);
|
|
3787
3787
|
let It = async () => {
|
|
3788
|
-
if (!(!
|
|
3789
|
-
Dt(), ut.current =
|
|
3788
|
+
if (!(!R?.callId || !U.current || !H.current || !y)) {
|
|
3789
|
+
Dt(), ut.current = R.callId, Ot();
|
|
3790
3790
|
try {
|
|
3791
3791
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3792
3792
|
nt.current = e;
|
|
@@ -3828,7 +3828,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3828
3828
|
if (!e.candidate || !H.current?.connected) return;
|
|
3829
3829
|
let t = e.candidate;
|
|
3830
3830
|
H.current.emit("call:ice-candidate", {
|
|
3831
|
-
callId:
|
|
3831
|
+
callId: R.callId,
|
|
3832
3832
|
candidate: t.candidate,
|
|
3833
3833
|
sdpMid: t.sdpMid,
|
|
3834
3834
|
sdpMLineIndex: t.sdpMLineIndex,
|
|
@@ -3842,7 +3842,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3842
3842
|
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, rt.current = e, document.body.appendChild(e);
|
|
3843
3843
|
}
|
|
3844
3844
|
rt.current.srcObject = e.streams[0];
|
|
3845
|
-
let r =
|
|
3845
|
+
let r = R?.callId, i = r && (ut.current === r || lt.current === r);
|
|
3846
3846
|
if (!ft.current && i) {
|
|
3847
3847
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3848
3848
|
V("connected"), Ge((t) => t || e), lt.current = r, He(r), jt(e);
|
|
@@ -3853,15 +3853,15 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3853
3853
|
};
|
|
3854
3854
|
let r = it.current;
|
|
3855
3855
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3856
|
-
callId: r.callId ||
|
|
3856
|
+
callId: r.callId || R.callId,
|
|
3857
3857
|
chatId: y
|
|
3858
3858
|
}), await Pt({
|
|
3859
3859
|
...r,
|
|
3860
|
-
callId: r.callId ||
|
|
3861
|
-
})), await U.current.acceptCall(
|
|
3862
|
-
callId:
|
|
3860
|
+
callId: r.callId || R.callId
|
|
3861
|
+
})), await U.current.acceptCall(R.callId, y), H.current?.emit("call:accepted", {
|
|
3862
|
+
callId: R.callId,
|
|
3863
3863
|
chatId: y
|
|
3864
|
-
}), lt.current =
|
|
3864
|
+
}), lt.current = R.callId, He(R.callId), V((e) => e === "connected" || ft.current ? "connected" : "connecting"), ze(null), O(!0);
|
|
3865
3865
|
} catch (e) {
|
|
3866
3866
|
if (ut.current = null, At("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3867
3867
|
Ye(hi(e, "This visitor call is no longer available."));
|
|
@@ -3869,7 +3869,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3869
3869
|
}
|
|
3870
3870
|
if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
|
|
3871
3871
|
try {
|
|
3872
|
-
await U.current.rejectCall(
|
|
3872
|
+
await U.current.rejectCall(R.callId, y);
|
|
3873
3873
|
} catch (e) {
|
|
3874
3874
|
console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
|
|
3875
3875
|
}
|
|
@@ -3880,11 +3880,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3880
3880
|
}
|
|
3881
3881
|
}
|
|
3882
3882
|
}, Lt = async () => {
|
|
3883
|
-
if (!
|
|
3883
|
+
if (!R?.callId || !U.current || !y) {
|
|
3884
3884
|
At("reject_call_without_server_context");
|
|
3885
3885
|
return;
|
|
3886
3886
|
}
|
|
3887
|
-
let e =
|
|
3887
|
+
let e = R.callId;
|
|
3888
3888
|
Ot(), Dt(), H.current?.emit("call:rejected", {
|
|
3889
3889
|
callId: e,
|
|
3890
3890
|
chatId: y,
|
|
@@ -3899,11 +3899,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3899
3899
|
}
|
|
3900
3900
|
}, Rt = p(Lt);
|
|
3901
3901
|
Rt.current = Lt, c(() => {
|
|
3902
|
-
if (!
|
|
3902
|
+
if (!R?.callId || B) {
|
|
3903
3903
|
Ot();
|
|
3904
3904
|
return;
|
|
3905
3905
|
}
|
|
3906
|
-
let e =
|
|
3906
|
+
let e = R.callId;
|
|
3907
3907
|
return Ot(), dt.current = window.setTimeout(() => {
|
|
3908
3908
|
et.current?.callId === e && ut.current !== e && lt.current !== e && Rt.current();
|
|
3909
3909
|
}, ne), () => {
|
|
@@ -3912,7 +3912,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3912
3912
|
}, [
|
|
3913
3913
|
B,
|
|
3914
3914
|
Ot,
|
|
3915
|
-
|
|
3915
|
+
R?.callId
|
|
3916
3916
|
]);
|
|
3917
3917
|
let zt = async () => {
|
|
3918
3918
|
if (!B || !U.current || !y) {
|
|
@@ -3991,7 +3991,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3991
3991
|
}
|
|
3992
3992
|
let qt = async (e, t = "", n = null, a = {}) => {
|
|
3993
3993
|
let o = typeof e == "string" ? e.trim() : "";
|
|
3994
|
-
if (!o || !U.current || !y || l !== "ready" ||
|
|
3994
|
+
if (!o || !U.current || !y || l !== "ready" || Le) return;
|
|
3995
3995
|
Wt(), ot.current = !1;
|
|
3996
3996
|
let s = /^\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, c = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, u = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
|
|
3997
3997
|
if (at.current && s.test(o) && !c.test(o)) {
|
|
@@ -4027,17 +4027,17 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4027
4027
|
chatId: y,
|
|
4028
4028
|
content: e,
|
|
4029
4029
|
sender: "user",
|
|
4030
|
-
email:
|
|
4030
|
+
email: P || void 0,
|
|
4031
4031
|
type: a?.type || "text",
|
|
4032
4032
|
metadata: a?.metadata || {},
|
|
4033
4033
|
...n || {}
|
|
4034
4034
|
});
|
|
4035
4035
|
return;
|
|
4036
4036
|
}
|
|
4037
|
-
|
|
4037
|
+
Te(!0);
|
|
4038
4038
|
try {
|
|
4039
4039
|
let s = await Ur(), c = Vr(), l = `stream-preview-${Date.now().toString(36)}`, d = (e) => {
|
|
4040
|
-
|
|
4040
|
+
F(!1), S((t) => {
|
|
4041
4041
|
let n = t.findIndex((e) => e.id === l);
|
|
4042
4042
|
if (n === -1) return [...t, {
|
|
4043
4043
|
id: l,
|
|
@@ -4054,14 +4054,14 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4054
4054
|
});
|
|
4055
4055
|
}, f = await U.current.sendAiMessage(y, e, r, t, {
|
|
4056
4056
|
...n || {},
|
|
4057
|
-
...
|
|
4057
|
+
...P ? { email: P } : {}
|
|
4058
4058
|
}, {
|
|
4059
4059
|
...a,
|
|
4060
4060
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
4061
4061
|
currentPageTitle: typeof window < "u" ? document.title : void 0,
|
|
4062
4062
|
currentPagePath: typeof window < "u" ? window.location.pathname : void 0,
|
|
4063
4063
|
currentPageContent: Kt() || void 0,
|
|
4064
|
-
navPreference:
|
|
4064
|
+
navPreference: le(i?.siteId) || void 0,
|
|
4065
4065
|
...s ? { shopifyCart: s } : {},
|
|
4066
4066
|
...c ? { shopifyCustomerId: c } : {}
|
|
4067
4067
|
}, d), p = f.chat_history || [];
|
|
@@ -4087,7 +4087,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4087
4087
|
}, 300);
|
|
4088
4088
|
})) : (at.current = e, console.log("[FWH Nav] Stored pending nav →", at.current));
|
|
4089
4089
|
let t = i?.siteId;
|
|
4090
|
-
t && !
|
|
4090
|
+
t && !de(t) && (fe(t), S((e) => [...e, {
|
|
4091
4091
|
id: `nav-pref-${Date.now()}`,
|
|
4092
4092
|
type: "nav_pref_choice",
|
|
4093
4093
|
sender: "system",
|
|
@@ -4140,10 +4140,14 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4140
4140
|
});
|
|
4141
4141
|
}
|
|
4142
4142
|
}
|
|
4143
|
-
S(pi(p)), Array.isArray(f.cart_actions) && f.cart_actions.length && w(f.cart_actions),
|
|
4143
|
+
S(pi(p)), Array.isArray(f.cart_actions) && f.cart_actions.length && w(f.cart_actions), re(!!f.is_human_handled), A(f.is_human_handled ? "agent" : "ai"), F(!1), Te(!1), await U.current.updateChatStatus(y, "messageSent");
|
|
4144
4144
|
} catch (e) {
|
|
4145
|
-
S((e) => e.filter((e) =>
|
|
4146
|
-
|
|
4145
|
+
S((e) => e.filter((e) => !e.isStreaming).map((e) => e.id === d ? {
|
|
4146
|
+
...e,
|
|
4147
|
+
isPending: !1,
|
|
4148
|
+
failed: !0
|
|
4149
|
+
} : e)), F(!1), Te(!1), e.status === 429 ? (De(!0), ke(e.message), window.setTimeout(() => {
|
|
4150
|
+
De(!1), ke("");
|
|
4147
4151
|
}, ee)) : h(e);
|
|
4148
4152
|
}
|
|
4149
4153
|
}, Jt = async (e) => {
|
|
@@ -4155,12 +4159,12 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4155
4159
|
let t = e ? "voice" : "text";
|
|
4156
4160
|
await U.current.setChatMode(y, t);
|
|
4157
4161
|
} catch {}
|
|
4158
|
-
|
|
4162
|
+
Me(e), e && (xt.current = !1);
|
|
4159
4163
|
}
|
|
4160
4164
|
}, Xt = async (e) => {
|
|
4161
4165
|
if (xt.current) return;
|
|
4162
4166
|
if (xt.current = !0, !U.current || !y || !e?.length) {
|
|
4163
|
-
|
|
4167
|
+
Me(!1);
|
|
4164
4168
|
return;
|
|
4165
4169
|
}
|
|
4166
4170
|
let t = () => {
|
|
@@ -4184,11 +4188,11 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4184
4188
|
} catch {
|
|
4185
4189
|
t();
|
|
4186
4190
|
} finally {
|
|
4187
|
-
|
|
4191
|
+
Me(!1);
|
|
4188
4192
|
}
|
|
4189
4193
|
}, Zt = async () => {
|
|
4190
4194
|
if (!(!U.current || !y)) {
|
|
4191
|
-
|
|
4195
|
+
je && !xt.current && bt.current.length > 0 && await Xt(bt.current);
|
|
4192
4196
|
try {
|
|
4193
4197
|
await U.current.endConversation(y);
|
|
4194
4198
|
} catch {
|
|
@@ -4196,7 +4200,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4196
4200
|
await U.current.updateChatStatus(y, "ended");
|
|
4197
4201
|
} catch {}
|
|
4198
4202
|
}
|
|
4199
|
-
|
|
4203
|
+
Re(!0), S((e) => [...e, {
|
|
4200
4204
|
id: `conversation-ended-${Date.now()}`,
|
|
4201
4205
|
sender: "system",
|
|
4202
4206
|
message: "This conversation has ended. Thank you for reaching out!",
|
|
@@ -4222,7 +4226,7 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4222
4226
|
let e = () => {
|
|
4223
4227
|
let e = Qe.current, t = U.current;
|
|
4224
4228
|
if (!t || !e) return;
|
|
4225
|
-
if (St.current && bt.current.length > 0 &&
|
|
4229
|
+
if (St.current && bt.current.length > 0 && Ae(), !xt.current && bt.current.length > 0 && (t.beaconSyncVoice(e, bt.current) || t.syncVoice(e, bt.current).catch(() => {}), xt.current = !0), lt.current) {
|
|
4226
4230
|
t.beaconEndWebRTCCall(lt.current, e);
|
|
4227
4231
|
return;
|
|
4228
4232
|
}
|
|
@@ -4235,9 +4239,9 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4235
4239
|
}, []);
|
|
4236
4240
|
let Qt = o(() => {
|
|
4237
4241
|
let e = i?.siteId;
|
|
4238
|
-
|
|
4242
|
+
he(e), $e.current = !0, W.current = null, H.current?.disconnect(), S([]), b(""), Qe.current = "", Re(!1), re(!1), se(null), ce(null), Ze(!0), s((e) => e + 1);
|
|
4239
4243
|
}, [i?.siteId]), $t = o((e) => {
|
|
4240
|
-
i?.siteId, $e.current = !1, W.current = e, H.current?.disconnect(), S([]), b(""), Qe.current = "",
|
|
4244
|
+
i?.siteId, $e.current = !1, W.current = e, H.current?.disconnect(), S([]), b(""), Qe.current = "", Re(!1), re(!1), se(null), ce(null), Ze(!0), s((e) => e + 1);
|
|
4241
4245
|
}, [i?.siteId]), en = f(() => ({
|
|
4242
4246
|
status: l,
|
|
4243
4247
|
error: d,
|
|
@@ -4248,21 +4252,21 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4248
4252
|
isOpen: D,
|
|
4249
4253
|
activeScreen: k,
|
|
4250
4254
|
isHumanHandled: j,
|
|
4251
|
-
agentName:
|
|
4252
|
-
agentHeadshot:
|
|
4253
|
-
visitorEmail:
|
|
4254
|
-
isAgentTyping:
|
|
4255
|
-
isAiTyping:
|
|
4256
|
-
connectionStatus:
|
|
4257
|
-
isLoading:
|
|
4258
|
-
isVoiceMode:
|
|
4259
|
-
isRateLimited:
|
|
4260
|
-
rateLimitMessage:
|
|
4261
|
-
isConversationEnded:
|
|
4255
|
+
agentName: M,
|
|
4256
|
+
agentHeadshot: N,
|
|
4257
|
+
visitorEmail: P,
|
|
4258
|
+
isAgentTyping: pe,
|
|
4259
|
+
isAiTyping: Se,
|
|
4260
|
+
connectionStatus: L,
|
|
4261
|
+
isLoading: we,
|
|
4262
|
+
isVoiceMode: je,
|
|
4263
|
+
isRateLimited: Ee,
|
|
4264
|
+
rateLimitMessage: Oe,
|
|
4265
|
+
isConversationEnded: Le,
|
|
4262
4266
|
isSessionRestoring: Xe,
|
|
4263
|
-
openToChatCounter:
|
|
4264
|
-
voiceEndCounter:
|
|
4265
|
-
incomingCall:
|
|
4267
|
+
openToChatCounter: Ne,
|
|
4268
|
+
voiceEndCounter: Fe,
|
|
4269
|
+
incomingCall: R,
|
|
4266
4270
|
activeCallId: B,
|
|
4267
4271
|
callConnectionState: Ue,
|
|
4268
4272
|
callConnectedAt: We,
|
|
@@ -4313,21 +4317,21 @@ function yi({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
4313
4317
|
D,
|
|
4314
4318
|
k,
|
|
4315
4319
|
j,
|
|
4320
|
+
M,
|
|
4316
4321
|
N,
|
|
4317
4322
|
P,
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
Ie,
|
|
4323
|
+
pe,
|
|
4324
|
+
Se,
|
|
4325
|
+
L,
|
|
4326
|
+
we,
|
|
4327
|
+
je,
|
|
4328
|
+
Ee,
|
|
4329
|
+
Oe,
|
|
4330
|
+
Le,
|
|
4327
4331
|
Xe,
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4332
|
+
Ne,
|
|
4333
|
+
Fe,
|
|
4334
|
+
R,
|
|
4331
4335
|
B,
|
|
4332
4336
|
Ue,
|
|
4333
4337
|
We,
|
|
@@ -9345,7 +9349,7 @@ async function Dh(e, t, n) {
|
|
|
9345
9349
|
let r = new URLSearchParams({ siteId: t || "" });
|
|
9346
9350
|
n && r.set("chatId", n);
|
|
9347
9351
|
let i = Vr();
|
|
9348
|
-
i && r.set("shopifyCustomerId", String(i)),
|
|
9352
|
+
i && r.set("shopifyCustomerId", String(i)), le(t) === "auto" && r.set("navPreference", "auto");
|
|
9349
9353
|
let a = await fetch(`${e}/api/voice/session?${r.toString()}`, {
|
|
9350
9354
|
method: "GET",
|
|
9351
9355
|
headers: { "Content-Type": "application/json" }
|
|
@@ -9401,52 +9405,52 @@ async function Oh(e) {
|
|
|
9401
9405
|
}
|
|
9402
9406
|
}, k = (e, t, n) => {
|
|
9403
9407
|
t && (E.role && E.role !== e && O(), E.role = e, E.text = E.text ? `${E.text} ${t}`.replace(/\s+/g, " ") : t, n && (E.debug = n), E.timer && clearTimeout(E.timer), E.timer = setTimeout(O, lh));
|
|
9404
|
-
}, A = !1, ee = !1, te = !1, ne = !1, j = !1,
|
|
9405
|
-
|
|
9408
|
+
}, A = !1, ee = !1, te = !1, ne = !1, j = !1, re = !0, ie = 0, ae = 0, oe = !1, M = !1, se = uh, N = null, ce = !1, P = !1, le = () => {
|
|
9409
|
+
N && clearTimeout(N);
|
|
9406
9410
|
let e = () => {
|
|
9407
9411
|
if (!A) {
|
|
9408
|
-
if (
|
|
9409
|
-
|
|
9412
|
+
if (ue.isPlaying()) {
|
|
9413
|
+
N = setTimeout(e, 150);
|
|
9410
9414
|
return;
|
|
9411
9415
|
}
|
|
9412
|
-
if (
|
|
9416
|
+
if (N = null, ce) {
|
|
9413
9417
|
p?.();
|
|
9414
9418
|
return;
|
|
9415
9419
|
}
|
|
9416
|
-
!A && w.readyState === WebSocket.OPEN && w.send(JSON.stringify({ type: "PlaybackDrained" })),
|
|
9420
|
+
!A && w.readyState === WebSocket.OPEN && w.send(JSON.stringify({ type: "PlaybackDrained" })), P && (P = !1, d?.());
|
|
9417
9421
|
}
|
|
9418
9422
|
};
|
|
9419
|
-
|
|
9420
|
-
},
|
|
9423
|
+
N = setTimeout(e, 150);
|
|
9424
|
+
}, ue = Eh(v, () => {
|
|
9421
9425
|
ne && (ne = !1, c?.({ mode: j ? "thinking" : "listening" }));
|
|
9422
9426
|
}, y);
|
|
9423
|
-
typeof window < "u" && (window.__fe_agentAudioPlaying = () =>
|
|
9424
|
-
let
|
|
9425
|
-
|
|
9426
|
-
let
|
|
9427
|
-
|
|
9427
|
+
typeof window < "u" && (window.__fe_agentAudioPlaying = () => ue.isPlaying());
|
|
9428
|
+
let de = v.createMediaStreamSource(_);
|
|
9429
|
+
de.connect(y);
|
|
9430
|
+
let fe = v.createScriptProcessor(ch, 1, 1), pe = !1;
|
|
9431
|
+
fe.onaudioprocess = (e) => {
|
|
9428
9432
|
if (A || w.readyState !== WebSocket.OPEN) return;
|
|
9429
9433
|
let t = e.inputBuffer.getChannelData(0), n = () => w.send(new Int16Array(t.length).buffer);
|
|
9430
9434
|
if (ee) {
|
|
9431
|
-
te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")),
|
|
9435
|
+
te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), pe = !1, ie = 0, ae = 0, n();
|
|
9432
9436
|
return;
|
|
9433
9437
|
}
|
|
9434
|
-
let r = vh(t), i = _h(t), a =
|
|
9435
|
-
if (r >= o && i >= dh && i <= fh ? (
|
|
9436
|
-
|
|
9437
|
-
let e =
|
|
9438
|
-
|
|
9438
|
+
let r = vh(t), i = _h(t), a = ue.isPlaying() || M, o = a ? se * gh : se, s = a ? hh : ph;
|
|
9439
|
+
if (r >= o && i >= dh && i <= fh ? (ae = 0, ie += 1) : ++ae >= mh && (ie = 0), a ? pe = !1 : !pe && ie >= ph ? (pe = !0, c?.({ mode: "user-speaking" })) : pe && ie === 0 && (pe = !1), a && !oe && ie >= s) {
|
|
9440
|
+
oe = !0, j = !1, ie = 0;
|
|
9441
|
+
let e = ue.playedMs();
|
|
9442
|
+
ue.stop(), re = !1, M = !1, N && !ce && (clearTimeout(N), N = null), P = !1, w.send(JSON.stringify({
|
|
9439
9443
|
type: "VisitorInterrupted",
|
|
9440
9444
|
played_ms: Math.round(e)
|
|
9441
9445
|
})), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
|
|
9442
9446
|
}
|
|
9443
9447
|
w.send(yh(t).buffer);
|
|
9444
|
-
},
|
|
9445
|
-
let
|
|
9448
|
+
}, de.connect(fe), fe.connect(v.destination);
|
|
9449
|
+
let me = () => {
|
|
9446
9450
|
if (!A) {
|
|
9447
|
-
A = !0,
|
|
9451
|
+
A = !0, N &&= (clearTimeout(N), null), O(), ue.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
|
|
9448
9452
|
try {
|
|
9449
|
-
|
|
9453
|
+
fe.disconnect(), de.disconnect();
|
|
9450
9454
|
} catch {}
|
|
9451
9455
|
if (_.getTracks().forEach((e) => e.stop()), S && S.state !== "inactive") {
|
|
9452
9456
|
S.onstop = () => wh(t, n, C, x, b);
|
|
@@ -9458,7 +9462,7 @@ async function Oh(e) {
|
|
|
9458
9462
|
} else x.length && wh(t, n, C, x, b);
|
|
9459
9463
|
v.close().catch(() => {}), (w.readyState === WebSocket.OPEN || w.readyState === WebSocket.CONNECTING) && w.close();
|
|
9460
9464
|
}
|
|
9461
|
-
},
|
|
9465
|
+
}, he = async (e) => {
|
|
9462
9466
|
let t = i[e.name];
|
|
9463
9467
|
if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
|
|
9464
9468
|
let n = {};
|
|
@@ -9470,10 +9474,10 @@ async function Oh(e) {
|
|
|
9470
9474
|
} catch (e) {
|
|
9471
9475
|
return { error: e?.message || "Tool execution failed" };
|
|
9472
9476
|
}
|
|
9473
|
-
},
|
|
9477
|
+
}, ge = async (e) => {
|
|
9474
9478
|
for (let t of e.functions || []) {
|
|
9475
9479
|
if (!t.client_side) continue;
|
|
9476
|
-
let e = await
|
|
9480
|
+
let e = await he(t);
|
|
9477
9481
|
if (A || w.readyState !== WebSocket.OPEN) return;
|
|
9478
9482
|
w.send(JSON.stringify({
|
|
9479
9483
|
type: "FunctionCallResponse",
|
|
@@ -9482,10 +9486,10 @@ async function Oh(e) {
|
|
|
9482
9486
|
content: typeof e == "string" ? e : JSON.stringify(e ?? {})
|
|
9483
9487
|
}));
|
|
9484
9488
|
}
|
|
9485
|
-
},
|
|
9489
|
+
}, _e = (e) => {
|
|
9486
9490
|
switch (e.type) {
|
|
9487
9491
|
case "Welcome":
|
|
9488
|
-
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (
|
|
9492
|
+
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (se = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, C = e.session_id || r || n || null, a?.({ conversationId: C });
|
|
9489
9493
|
break;
|
|
9490
9494
|
case "ConversationText": {
|
|
9491
9495
|
let t = String(e.content || "");
|
|
@@ -9504,25 +9508,25 @@ async function Oh(e) {
|
|
|
9504
9508
|
break;
|
|
9505
9509
|
}
|
|
9506
9510
|
case "UserStartedSpeaking":
|
|
9507
|
-
O(),
|
|
9511
|
+
O(), ue.stop(), M = !1, re = !1, ne = !1, j = !1, N && !ce && (clearTimeout(N), N = null), P = !1, c?.({ mode: "listening" });
|
|
9508
9512
|
break;
|
|
9509
9513
|
case "AgentStartedSpeaking":
|
|
9510
|
-
|
|
9514
|
+
re = !0, ne = !0, oe = !1, ie = 0, c?.({ mode: "speaking" });
|
|
9511
9515
|
break;
|
|
9512
9516
|
case "AgentAudioDone":
|
|
9513
|
-
|
|
9517
|
+
M = !1, O(), le(), ue.isPlaying() || (ne = !1, c?.({ mode: j ? "thinking" : "listening" }));
|
|
9514
9518
|
break;
|
|
9515
9519
|
case "FunctionCallRequest":
|
|
9516
|
-
|
|
9520
|
+
ge(e);
|
|
9517
9521
|
break;
|
|
9518
9522
|
case "AgentPreparing":
|
|
9519
|
-
|
|
9523
|
+
M = !0;
|
|
9520
9524
|
break;
|
|
9521
9525
|
case "AgentTurnComplete":
|
|
9522
|
-
j = !1,
|
|
9526
|
+
j = !1, P = !0, le();
|
|
9523
9527
|
break;
|
|
9524
9528
|
case "SessionEnding":
|
|
9525
|
-
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"),
|
|
9529
|
+
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ce = !0;
|
|
9526
9530
|
break;
|
|
9527
9531
|
case "AgentThinking":
|
|
9528
9532
|
j = !0, c?.({ mode: "thinking" });
|
|
@@ -9546,7 +9550,7 @@ async function Oh(e) {
|
|
|
9546
9550
|
};
|
|
9547
9551
|
return w.onopen = () => w.send(JSON.stringify(g)), w.onmessage = (e) => {
|
|
9548
9552
|
if (e.data instanceof ArrayBuffer) {
|
|
9549
|
-
|
|
9553
|
+
re && ue.enqueue(new Int16Array(e.data));
|
|
9550
9554
|
return;
|
|
9551
9555
|
}
|
|
9552
9556
|
let t;
|
|
@@ -9556,14 +9560,14 @@ async function Oh(e) {
|
|
|
9556
9560
|
return;
|
|
9557
9561
|
}
|
|
9558
9562
|
try {
|
|
9559
|
-
|
|
9563
|
+
_e(t);
|
|
9560
9564
|
} catch (e) {
|
|
9561
9565
|
console.error("[FlowEngage] voice event handler failed:", t?.type, e);
|
|
9562
9566
|
}
|
|
9563
9567
|
}, w.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), w.onclose = () => {
|
|
9564
|
-
|
|
9568
|
+
me(), o?.();
|
|
9565
9569
|
}, {
|
|
9566
|
-
endSession: async () =>
|
|
9570
|
+
endSession: async () => me(),
|
|
9567
9571
|
sendContextualUpdate: (e) => {
|
|
9568
9572
|
A || w.readyState !== WebSocket.OPEN || !e || w.send(JSON.stringify({
|
|
9569
9573
|
type: "UpdatePrompt",
|
|
@@ -10396,7 +10400,7 @@ function Lg({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
|
|
|
10396
10400
|
//#region src/components/MessageList.jsx
|
|
10397
10401
|
function Rg({ siteId: e, onChoose: t }) {
|
|
10398
10402
|
let [n, r] = m(null), i = (n) => {
|
|
10399
|
-
|
|
10403
|
+
ue(e, n), r(n), t?.(n);
|
|
10400
10404
|
};
|
|
10401
10405
|
return /* @__PURE__ */ g("div", {
|
|
10402
10406
|
style: {
|
|
@@ -10523,7 +10527,7 @@ function zg({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10523
10527
|
e.map((e) => {
|
|
10524
10528
|
if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
|
|
10525
10529
|
if (e.type === "nav_pref_choice") return /* @__PURE__ */ g(Rg, { siteId: d?.siteId }, e.id || e.messageId);
|
|
10526
|
-
let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, f = e.type === "file" && e.metadata?.fileUrl,
|
|
10530
|
+
let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, f = e.failed, p = e.type === "file" && e.metadata?.fileUrl, m = e.agent_name || e.agentName || e.metadata?.agentName || l, v = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, S = xg(e.replyToContent || e.replyContext?.message || ""), C = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
|
|
10527
10531
|
return t ? /* @__PURE__ */ g("div", {
|
|
10528
10532
|
style: {
|
|
10529
10533
|
display: "flex",
|
|
@@ -10569,8 +10573,8 @@ function zg({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10569
10573
|
marginTop: !c && (r || o) ? "22px" : "0px"
|
|
10570
10574
|
},
|
|
10571
10575
|
children: r ? u || /* @__PURE__ */ g(hg, { size: 16 }) : /* @__PURE__ */ g(Lg, {
|
|
10572
|
-
src:
|
|
10573
|
-
name:
|
|
10576
|
+
src: v || "",
|
|
10577
|
+
name: m,
|
|
10574
10578
|
imgStyle: {
|
|
10575
10579
|
width: "100%",
|
|
10576
10580
|
height: "100%",
|
|
@@ -10623,12 +10627,12 @@ function zg({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10623
10627
|
color: n ? "#fff" : "#111827",
|
|
10624
10628
|
fontSize: "14px",
|
|
10625
10629
|
fontWeight: 400,
|
|
10626
|
-
opacity: c ? .55 : 1,
|
|
10630
|
+
opacity: c || e.failed ? .55 : 1,
|
|
10627
10631
|
transition: "opacity 0.3s ease",
|
|
10628
10632
|
wordBreak: "break-word",
|
|
10629
10633
|
width: "fit-content"
|
|
10630
10634
|
},
|
|
10631
|
-
children: [
|
|
10635
|
+
children: [S && /* @__PURE__ */ _("div", {
|
|
10632
10636
|
style: {
|
|
10633
10637
|
marginBottom: "8px",
|
|
10634
10638
|
borderRadius: "14px",
|
|
@@ -10643,7 +10647,7 @@ function zg({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10643
10647
|
marginBottom: "2px",
|
|
10644
10648
|
fontWeight: 600
|
|
10645
10649
|
},
|
|
10646
|
-
children:
|
|
10650
|
+
children: C
|
|
10647
10651
|
}), /* @__PURE__ */ g("div", {
|
|
10648
10652
|
style: {
|
|
10649
10653
|
display: "-webkit-box",
|
|
@@ -10651,9 +10655,9 @@ function zg({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10651
10655
|
WebkitBoxOrient: "vertical",
|
|
10652
10656
|
overflow: "hidden"
|
|
10653
10657
|
},
|
|
10654
|
-
children:
|
|
10658
|
+
children: S
|
|
10655
10659
|
})]
|
|
10656
|
-
}),
|
|
10660
|
+
}), p ? (() => {
|
|
10657
10661
|
let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = Pg(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
|
|
10658
10662
|
color: "#ef4444",
|
|
10659
10663
|
label: "PDF"
|
|
@@ -10859,6 +10863,13 @@ function zg({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
10859
10863
|
fontStyle: "italic"
|
|
10860
10864
|
},
|
|
10861
10865
|
children: "sending…"
|
|
10866
|
+
}) : f ? /* @__PURE__ */ g("span", {
|
|
10867
|
+
style: {
|
|
10868
|
+
fontSize: "10px",
|
|
10869
|
+
color: "#dc2626",
|
|
10870
|
+
fontWeight: 500
|
|
10871
|
+
},
|
|
10872
|
+
children: "Not sent — tap send to try again"
|
|
10862
10873
|
}) : /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("span", {
|
|
10863
10874
|
style: {
|
|
10864
10875
|
fontSize: "10px",
|
|
@@ -12809,7 +12820,7 @@ function T_(e) {
|
|
|
12809
12820
|
function E_(e) {
|
|
12810
12821
|
let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = typeof e.beaconSyncFullVoiceHistory == "function" ? e.beaconSyncFullVoiceHistory : null, a = [], o = {
|
|
12811
12822
|
"fwh-navigate-mvp": async (n) => {
|
|
12812
|
-
if ($("fwh-navigate-mvp ▶ raw parameters:", n), e?.isWalkthroughActive?.()) return $("fwh-navigate-mvp ✖ blocked — walkthrough in progress"), "NAVIGATION_BLOCKED_DURING_WALKTHROUGH. A walkthrough of the current page is
|
|
12823
|
+
if ($("fwh-navigate-mvp ▶ raw parameters:", n), e?.isWalkthroughActive?.()) return $("fwh-navigate-mvp ✖ blocked — walkthrough in progress"), "NAVIGATION_BLOCKED_DURING_WALKTHROUGH. A walkthrough of the current page is running, so the visitor was not moved.";
|
|
12813
12824
|
let a = x_(n), o = S_(a), s = a.section_text ?? a.sectionText ?? a.section, c = Array.isArray(a.expected_landmarks) ? a.expected_landmarks : Array.isArray(a.expectedLandmarks) ? a.expectedLandmarks : [];
|
|
12814
12825
|
if ($("fwh-navigate-mvp · coerced:", {
|
|
12815
12826
|
url: o,
|
|
@@ -12824,17 +12835,17 @@ function E_(e) {
|
|
|
12824
12835
|
if (e.hostname === window.location.hostname && e.origin !== window.location.origin) o = e.pathname + e.search + e.hash, $("fwh-navigate-mvp · cross-protocol same-host URL normalized →", o);
|
|
12825
12836
|
else if (e.origin !== window.location.origin && /^https?:$/i.test(e.protocol)) {
|
|
12826
12837
|
let t = e.hostname;
|
|
12827
|
-
return $("fwh-navigate-mvp ✖ external URL blocked:", e.href), `EXTERNAL_LINK_BLOCKED:
|
|
12838
|
+
return $("fwh-navigate-mvp ✖ external URL blocked:", e.href), `EXTERNAL_LINK_BLOCKED: "${o}" is on another site (${t}) and opens in a new tab, which you can't open. The visitor can click that link themselves.`;
|
|
12828
12839
|
}
|
|
12829
12840
|
} catch {}
|
|
12830
12841
|
if (typeof window < "u") {
|
|
12831
12842
|
try {
|
|
12832
12843
|
let e = new URL(o, window.location.href);
|
|
12833
|
-
if (e.pathname === window.location.pathname && e.search === window.location.search) return $("fwh-navigate-mvp ✖ already on page, skipping"), "OK_ALREADY_ON_PAGE. The visitor is already on this page
|
|
12844
|
+
if (e.pathname === window.location.pathname && e.search === window.location.search) return $("fwh-navigate-mvp ✖ already on page, skipping"), "OK_ALREADY_ON_PAGE. The visitor is already on this page, so nothing changed.";
|
|
12834
12845
|
} catch {}
|
|
12835
12846
|
let e = window.__fe_user_nav_during_speech;
|
|
12836
12847
|
if (e && Date.now() - e.ts < 3e4) try {
|
|
12837
|
-
if (new URL(o, window.location.href).pathname === e.fromPath) return $("flowengage_navigate ✖ blocked — would navigate back to page visitor just left", e), `NAV_BLOCKED:
|
|
12848
|
+
if (new URL(o, window.location.href).pathname === e.fromPath) return $("flowengage_navigate ✖ blocked — would navigate back to page visitor just left", e), `NAV_BLOCKED: the visitor just left "${e.fromPageName}" themselves and is now on "${e.toPageName}", so they were not moved back.`;
|
|
12838
12849
|
} catch {}
|
|
12839
12850
|
}
|
|
12840
12851
|
let { allowed: l, correctedUrl: u } = await yr(o, {
|
|
@@ -12842,7 +12853,7 @@ function E_(e) {
|
|
|
12842
12853
|
apiBaseUrl: e.apiBaseUrl
|
|
12843
12854
|
});
|
|
12844
12855
|
if (!l) {
|
|
12845
|
-
let e = `PAGE_NOT_IN_SITE: "${o}" is
|
|
12856
|
+
let e = `PAGE_NOT_IN_SITE: "${o}" is not a page on this site, so the visitor was not moved. The real pages are in your Site Pages list, fwh-list-nav-links-mvp and fwh-search-mvp.`;
|
|
12846
12857
|
return $("fwh-navigate-mvp ✖ blocked", e), e;
|
|
12847
12858
|
}
|
|
12848
12859
|
u && u !== o && ($("fwh-navigate-mvp · corrected url:", {
|
|
@@ -12861,10 +12872,10 @@ function E_(e) {
|
|
|
12861
12872
|
sender: "user",
|
|
12862
12873
|
message: e
|
|
12863
12874
|
}]);
|
|
12864
|
-
n &&
|
|
12875
|
+
n && Ee(t, n);
|
|
12865
12876
|
}
|
|
12866
12877
|
} catch {}
|
|
12867
|
-
|
|
12878
|
+
Ae();
|
|
12868
12879
|
let e = o;
|
|
12869
12880
|
try {
|
|
12870
12881
|
e = new URL(o, typeof window < "u" ? window.location.href : "").href;
|
|
@@ -12874,7 +12885,7 @@ function E_(e) {
|
|
|
12874
12885
|
let e = new URL(o, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
|
|
12875
12886
|
n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
|
|
12876
12887
|
} catch {}
|
|
12877
|
-
t && typeof window < "u" &&
|
|
12888
|
+
t && typeof window < "u" && Le(t, window.location.href, e, n), Sr(e);
|
|
12878
12889
|
try {
|
|
12879
12890
|
window.__fe_agent_nav = {
|
|
12880
12891
|
path: new URL(e, window.location.href).pathname,
|
|
@@ -12894,7 +12905,7 @@ function E_(e) {
|
|
|
12894
12905
|
let a = [], s = null, c = "", l = Date.now() + 12e3;
|
|
12895
12906
|
for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: a, pageTitleHeading: s, introText: c} = w_(), !(a.length >= 1)););
|
|
12896
12907
|
C_(), $("fwh-navigate-mvp → page headings collected:", a, "titleHeading:", s);
|
|
12897
|
-
let u = a.length ? a.join(" | ") : "none", d = a.length ? "
|
|
12908
|
+
let u = a.length ? a.join(" | ") : "none", d = a.length ? "" : "Headings were not ready yet; fwh-get-current-page-mvp returns them.", f = s ? ` "${s}" is the page title, not a section. Intro text: "${c || "none"}".` : c ? ` Intro text before the first section: "${c}".` : "", p = "";
|
|
12898
12909
|
try {
|
|
12899
12910
|
if (a.length > 0) {
|
|
12900
12911
|
let e = a.slice(0, 3), t = [];
|
|
@@ -12905,10 +12916,10 @@ function E_(e) {
|
|
|
12905
12916
|
r && t.push(`[Section: ${n}] ${r}`);
|
|
12906
12917
|
}
|
|
12907
12918
|
}
|
|
12908
|
-
t.length > 0 && (p = `
|
|
12919
|
+
t.length > 0 && (p = ` Content of the first sections: ${t.join(" | ")}.`);
|
|
12909
12920
|
}
|
|
12910
12921
|
} catch {}
|
|
12911
|
-
if (Tr()) return Cr(), $("fwh-navigate-mvp ✖ landed on a not-found/404 page:", i), `NAVIGATION_PAGE_NOT_FOUND.
|
|
12922
|
+
if (Tr()) return Cr(), $("fwh-navigate-mvp ✖ landed on a not-found/404 page:", i), `NAVIGATION_PAGE_NOT_FOUND. ${i} shows a "not found" error — that page doesn't exist on this site.`;
|
|
12912
12923
|
let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
|
|
12913
12924
|
for (; Date.now() < m && !l_(h, e) && l_(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
|
|
12914
12925
|
$("fwh-navigate-mvp route settle:", {
|
|
@@ -12917,9 +12928,9 @@ function E_(e) {
|
|
|
12917
12928
|
settledPath: h
|
|
12918
12929
|
});
|
|
12919
12930
|
let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = l_(h, e), y = !l_(h, t), b = v || y;
|
|
12920
|
-
return $("fwh-navigate-mvp settled:", h, "target:", e, "match:", b), b ? (Cr(), `OK_NAVIGATE_SPA.
|
|
12931
|
+
return $("fwh-navigate-mvp settled:", h, "target:", e, "match:", b), b ? (Cr(), `OK_NAVIGATE_SPA. The visitor is now on ${g} (page: "${_}"). Section headings: ${u}.${f} ${d}${p}`) : (Cr(), `NAVIGATION_DID_NOT_HAPPEN. The page did not change; the visitor is still on ${g} (page: "${_}").`);
|
|
12921
12932
|
} catch {}
|
|
12922
|
-
return "OK_NAVIGATE_RELOADING. The page is reloading
|
|
12933
|
+
return "OK_NAVIGATE_RELOADING. The page is reloading; this call ends now and continues on the new page.";
|
|
12923
12934
|
} catch (e) {
|
|
12924
12935
|
let t = `Navigation error: ${e?.message || String(e)}`;
|
|
12925
12936
|
return $("fwh-navigate-mvp ✖", t), Ph("Navigation failed", {
|
|
@@ -12937,7 +12948,7 @@ function E_(e) {
|
|
|
12937
12948
|
if (Wn(3e3), typeof window < "u" && window.__fe_user_nav_during_speech) {
|
|
12938
12949
|
let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
|
|
12939
12950
|
if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
|
|
12940
|
-
else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED:
|
|
12951
|
+
else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED: the visitor moved themselves from "${e.fromPageName}" to "${e.toPageName}" (${t}) while you were speaking, so nothing was highlighted.`;
|
|
12941
12952
|
}
|
|
12942
12953
|
C_();
|
|
12943
12954
|
let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = mr(n || null, i || null);
|
|
@@ -12947,10 +12958,10 @@ function E_(e) {
|
|
|
12947
12958
|
}
|
|
12948
12959
|
if (!a) {
|
|
12949
12960
|
$("fwh-highlight-mvp ✖ no element for:", i || n);
|
|
12950
|
-
let { headings: e } = w_(), t = e.length ? `
|
|
12961
|
+
let { headings: e } = w_(), t = e.length ? `Headings on this page: ${e.map((e) => `"${e}"`).join(" | ")}.` : "This page has no headings to highlight.";
|
|
12951
12962
|
return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
|
|
12952
12963
|
}
|
|
12953
|
-
return Nn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}"
|
|
12964
|
+
return Nn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}" is highlighted on screen.`;
|
|
12954
12965
|
},
|
|
12955
12966
|
"fwh-read-content-mvp": async (e) => {
|
|
12956
12967
|
$("fwh-read-content-mvp ▶", e);
|
|
@@ -13077,24 +13088,24 @@ function E_(e) {
|
|
|
13077
13088
|
});
|
|
13078
13089
|
}), e.forEach((e) => t.push(e)), !t.length) return "NAV_LINKS: No navigation links found on this page. Use fwh-read-content-mvp to read page content or fwh-search-mvp to search the site.";
|
|
13079
13090
|
let r = t.slice(0, 50).map((e, t) => `${t + 1}. "${e.text}"${e.isSelectOption ? ` (dropdown option in "${e.selectLabel}")` : ""} → ${e.href}`).join("\n");
|
|
13080
|
-
return $("fwh-list-nav-links-mvp ✓", `${t.length} links`), `NAV_LINKS (${t.length} total, showing up to 50):\n${r}
|
|
13091
|
+
return $("fwh-list-nav-links-mvp ✓", `${t.length} links`), `NAV_LINKS (${t.length} total, showing up to 50):\n${r}`;
|
|
13081
13092
|
},
|
|
13082
13093
|
"fwh-end-session-mvp": async () => ($("fwh-end-session-mvp ▶"), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
|
|
13083
|
-
"fwh-request-email-mvp": async () => ($("fwh-request-email-mvp ▶"), typeof e.requestEmailCollection == "function" && e.requestEmailCollection(), "EMAIL_BOX_SHOWN.
|
|
13094
|
+
"fwh-request-email-mvp": async () => ($("fwh-request-email-mvp ▶"), typeof e.requestEmailCollection == "function" && e.requestEmailCollection(), "EMAIL_BOX_SHOWN. A text box for their email is on screen now. EMAIL_SAVED arrives once they submit it."),
|
|
13084
13095
|
"fwh-get-current-page-mvp": async () => {
|
|
13085
13096
|
if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
|
|
13086
13097
|
let e = window.location.href, t = window.location.pathname, n = document.title || "";
|
|
13087
|
-
if (Tr()) return $("fwh-get-current-page-mvp ✓ 404 detected", { url: e }), `CURRENT_PAGE_NOT_FOUND. The visitor is
|
|
13098
|
+
if (Tr()) return $("fwh-get-current-page-mvp ✓ 404 detected", { url: e }), `CURRENT_PAGE_NOT_FOUND. The visitor is on a "not found" error page (${e}); there is no content here.`;
|
|
13088
13099
|
let { headings: r, pageTitleHeading: i, introText: a } = w_();
|
|
13089
13100
|
$("fwh-get-current-page-mvp ✓", {
|
|
13090
13101
|
url: e,
|
|
13091
13102
|
path: t,
|
|
13092
13103
|
title: n
|
|
13093
13104
|
}), $("fwh-get-current-page-mvp → page headings collected:", r, "titleHeading:", i);
|
|
13094
|
-
let o = i ? `
|
|
13095
|
-
if (!r.length) return `CURRENT_PAGE. URL: ${e} | Title: ${n} |${o}
|
|
13105
|
+
let o = i ? ` "${i}" is the page title, not a section. Intro text: "${a || "none"}".` : a ? ` Intro text before the first section: "${a}".` : "";
|
|
13106
|
+
if (!r.length) return `CURRENT_PAGE. URL: ${e} | Title: ${n} |${o} This page has no section headings.`;
|
|
13096
13107
|
let s = r.map((e) => `"${e}"`).join(" | ");
|
|
13097
|
-
return `CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o}
|
|
13108
|
+
return `CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o}`;
|
|
13098
13109
|
},
|
|
13099
13110
|
"fwh-list-forms-mvp": async () => {
|
|
13100
13111
|
let e = h_(), t = g_();
|
|
@@ -13109,7 +13120,7 @@ function E_(e) {
|
|
|
13109
13120
|
hint: "field_key: use the label/placeholder/name shown above. CRITICAL: fields with inputCategory='dropdown_select' are SELECT elements — their field_key must match the SELECT's own label (e.g. 'Company Size'), NOT the option text (e.g. 'Small Business') and NOT a nearby text input label. Never fill a SELECT option value into a text input."
|
|
13110
13121
|
});
|
|
13111
13122
|
},
|
|
13112
|
-
"fwh-fill-form-mvp": async () => "FORM_FILLING_DISABLED:
|
|
13123
|
+
"fwh-fill-form-mvp": async () => "FORM_FILLING_DISABLED: forms can't be filled in for the visitor; fwh-list-forms-mvp lists the fields.",
|
|
13113
13124
|
"fwh-click-button-mvp": async (e) => {
|
|
13114
13125
|
let t = x_(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
|
|
13115
13126
|
if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
|
|
@@ -13239,9 +13250,9 @@ function E_(e) {
|
|
|
13239
13250
|
try {
|
|
13240
13251
|
r = new URL(e, window.location.href).href;
|
|
13241
13252
|
} catch {}
|
|
13242
|
-
return t &&
|
|
13253
|
+
return t && Le(t, window.location.href, r, n), Sr(r), kr().then(() => {
|
|
13243
13254
|
window.location.assign(r);
|
|
13244
|
-
}), `OK_NAVIGATING to ${n}. The page is loading
|
|
13255
|
+
}), `OK_NAVIGATING to ${n}. The page is loading.`;
|
|
13245
13256
|
}
|
|
13246
13257
|
return {
|
|
13247
13258
|
...o,
|
|
@@ -13282,8 +13293,8 @@ function k_(e) {
|
|
|
13282
13293
|
//#endregion
|
|
13283
13294
|
//#region src/components/FlowEngageWidget.jsx
|
|
13284
13295
|
var A_ = "[PAGE_CONTEXT]";
|
|
13285
|
-
function j_(e, t, n) {
|
|
13286
|
-
return `${A_}
|
|
13296
|
+
function j_(e, t, n, r) {
|
|
13297
|
+
return `${A_} The visitor is on ${e}${r ? `, having moved here themselves from the ${r} page` : ""}. Approximate headings: ${t || "none"}. ${n ? `Forms: ${n}. ` : ""}`.trim();
|
|
13287
13298
|
}
|
|
13288
13299
|
var M_ = {
|
|
13289
13300
|
blue: "#135bd8",
|
|
@@ -13697,87 +13708,87 @@ function V_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
13697
13708
|
}
|
|
13698
13709
|
function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, beaconSyncVoiceTranscript: d, widgetPosition: f = "bottom-right", voiceEndCounter: h, websiteName: v, voiceFirstMessage: y, captureVisitorEmail: b, emailRequired: x, emailCaptureEnabled: S = !0, listeningLabel: C = "Listening...", thinkingLabel: w = "Thinking...", enterChatModeLabel: T = "Enter Chat Mode", endConversationLabel: E = "End Conversation" }) {
|
|
13699
13710
|
c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
|
|
13700
|
-
let [D, O] = m("idle"), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(() =>
|
|
13711
|
+
let [D, O] = m("idle"), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(() => le(i) === "auto"), re = () => {
|
|
13701
13712
|
let e = ne ? "ask" : "auto";
|
|
13702
|
-
|
|
13703
|
-
}, [
|
|
13704
|
-
|
|
13713
|
+
ue(i, e), j(e === "auto");
|
|
13714
|
+
}, [ie, ae] = m(!1), [oe, M] = m(""), [se, N] = m(""), ce = p(!1), P = p(!1), de = p(null), fe = p(0), pe = p(""), me = p(!1), he = p(0), ge = p(!1), _e = p(!1), ve = p(!1), ye = p([]), be = p(null), xe = p(""), Se = p(null), F = (e) => {
|
|
13715
|
+
ge.current = e, e || (_e.current = !1), L.current?.setWalkthroughActive?.(e);
|
|
13705
13716
|
};
|
|
13706
|
-
|
|
13707
|
-
if (
|
|
13717
|
+
Se.current = async () => {
|
|
13718
|
+
if (_e.current) return;
|
|
13708
13719
|
let e = typeof window < "u" ? window.location.pathname : null;
|
|
13709
|
-
if (e &&
|
|
13710
|
-
console.log("[FlowEngage] walkthrough ended — visitor left " +
|
|
13720
|
+
if (e && be.current && e !== be.current) {
|
|
13721
|
+
console.log("[FlowEngage] walkthrough ended — visitor left " + be.current), be.current = null, ye.current = [], F(!1);
|
|
13711
13722
|
return;
|
|
13712
13723
|
}
|
|
13713
|
-
let t =
|
|
13714
|
-
|
|
13715
|
-
let n =
|
|
13724
|
+
let t = ye.current;
|
|
13725
|
+
I.current += 1;
|
|
13726
|
+
let n = I.current, r = t[n];
|
|
13716
13727
|
if (!r) {
|
|
13717
|
-
if (
|
|
13728
|
+
if (F(!1), t.length) L.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
|
|
13718
13729
|
else if (n === 0) {
|
|
13719
13730
|
let e = "";
|
|
13720
13731
|
try {
|
|
13721
|
-
let t = await
|
|
13732
|
+
let t = await Ce.current?.["fwh-read-content-mvp"]?.({});
|
|
13722
13733
|
typeof t == "string" && t && !/^Could not/i.test(t) && (e = t.slice(0, 2800));
|
|
13723
13734
|
} catch {}
|
|
13724
|
-
|
|
13735
|
+
L.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
|
|
13725
13736
|
}
|
|
13726
13737
|
return;
|
|
13727
13738
|
}
|
|
13728
13739
|
try {
|
|
13729
|
-
await
|
|
13740
|
+
await Ce.current?.highlightOnPage?.({ section_text: r });
|
|
13730
13741
|
} catch (e) {
|
|
13731
13742
|
console.warn("[FlowEngage] walkthrough highlight failed:", e?.message || e);
|
|
13732
13743
|
}
|
|
13733
13744
|
console.debug(`[FlowEngage] walkthrough step ${n + 1}/${t.length}: ${r}`);
|
|
13734
13745
|
let i = "";
|
|
13735
13746
|
try {
|
|
13736
|
-
let e = await
|
|
13747
|
+
let e = await Ce.current?.["fwh-read-content-mvp"]?.({ section_text: r });
|
|
13737
13748
|
typeof e == "string" && e && !/^Could not/i.test(e) && (i = e.slice(0, 2500));
|
|
13738
13749
|
} catch {}
|
|
13739
13750
|
let a = i ? `Here is this section's full content — describe it from THIS text only, and do not call any tool:\n"""${i}"""\n` : "read the section's content silently first (fwh-read-content-mvp) if you don't already have it. ";
|
|
13740
|
-
|
|
13751
|
+
L.current?.sendUserMessage?.(`Describe the section titled "${r}" in 3-4 sentences, starting with ${n === 0 ? "Starting with" : "Next —"} ${r}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; ` + a + "This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.", { suppressQuestion: !0 });
|
|
13741
13752
|
};
|
|
13742
|
-
let
|
|
13753
|
+
let I = p(0), L = p(null), Ce = p(null), we = p(""), Te = p(async () => {}), ke = p(!1), je = p(!1), Me = p(!1), Ne = p(!1), Pe = p("minimized"), Ie = p(null), Le = p(null), R = p(null), ze = p(0), Be = p(!1), Ve = p("idle"), z = p(null), B = p(!1), He = p(null), Ue = o((e = "minimized") => {
|
|
13743
13754
|
console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
|
|
13744
13755
|
destination: e,
|
|
13745
13756
|
stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
|
|
13746
|
-
}),
|
|
13747
|
-
|
|
13757
|
+
}), Pe.current = e, Ne.current = !0, queueMicrotask(() => {
|
|
13758
|
+
ke.current || (ke.current = !0, Te.current?.());
|
|
13748
13759
|
});
|
|
13749
13760
|
}, [l]), V = o(() => {
|
|
13750
|
-
|
|
13761
|
+
de.current &&= (clearTimeout(de.current), null);
|
|
13751
13762
|
}, []);
|
|
13752
13763
|
c(() => {
|
|
13753
13764
|
if (x) {
|
|
13754
|
-
|
|
13765
|
+
ce.current = !1;
|
|
13755
13766
|
return;
|
|
13756
13767
|
}
|
|
13757
|
-
if (
|
|
13758
|
-
|
|
13759
|
-
let e =
|
|
13760
|
-
|
|
13768
|
+
if (ce.current = !0, P.current = !1, ae(!1), V(), me.current) {
|
|
13769
|
+
me.current = !1, L.current?.setMicMuted?.(!1);
|
|
13770
|
+
let e = pe.current;
|
|
13771
|
+
pe.current = "", L.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && L.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
|
|
13761
13772
|
}
|
|
13762
|
-
|
|
13773
|
+
L.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
|
|
13763
13774
|
}, [x, V]);
|
|
13764
13775
|
let We = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Ge = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Ke = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, qe = /(would you like (me )?to take you|shall i take you|want me to take you|would you like to (go|explore|visit|see)|take you there)/i, Je = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, Ye = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Xe = o(() => {
|
|
13765
|
-
V(),
|
|
13766
|
-
if (!(!
|
|
13767
|
-
|
|
13776
|
+
V(), de.current = setTimeout(() => {
|
|
13777
|
+
if (!(!P.current || ce.current)) if (fe.current < 3) {
|
|
13778
|
+
fe.current += 1;
|
|
13768
13779
|
try {
|
|
13769
|
-
|
|
13780
|
+
L.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
|
|
13770
13781
|
} catch {}
|
|
13771
13782
|
Xe();
|
|
13772
13783
|
} else {
|
|
13773
13784
|
try {
|
|
13774
|
-
|
|
13785
|
+
L.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
|
|
13775
13786
|
} catch {}
|
|
13776
|
-
|
|
13787
|
+
P.current = !1, ae(!1), V(), Be.current = !0;
|
|
13777
13788
|
}
|
|
13778
13789
|
}, 1e4);
|
|
13779
13790
|
}, [V]), Ze = o(async (e) => {
|
|
13780
|
-
|
|
13791
|
+
Ne.current = !0;
|
|
13781
13792
|
try {
|
|
13782
13793
|
Pn();
|
|
13783
13794
|
} catch {}
|
|
@@ -13785,12 +13796,12 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13785
13796
|
Jh();
|
|
13786
13797
|
} catch {}
|
|
13787
13798
|
if (i) try {
|
|
13788
|
-
|
|
13799
|
+
Re(i);
|
|
13789
13800
|
} catch {}
|
|
13790
13801
|
try {
|
|
13791
|
-
await
|
|
13802
|
+
await L.current?.endSession?.();
|
|
13792
13803
|
} catch {}
|
|
13793
|
-
let t =
|
|
13804
|
+
let t = Ie.current, n = Le.current;
|
|
13794
13805
|
if (t && s && a) {
|
|
13795
13806
|
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
13796
13807
|
fetch(`${a}/api/voice/save-chat-recording`, {
|
|
@@ -13804,8 +13815,8 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13804
13815
|
})
|
|
13805
13816
|
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
13806
13817
|
}
|
|
13807
|
-
if (
|
|
13808
|
-
|
|
13818
|
+
if (Ie.current = null, Le.current = null, L.current = null, O("idle"), A(!1), ke.current = !1, Pr(), i) try {
|
|
13819
|
+
Oe(i);
|
|
13809
13820
|
} catch {}
|
|
13810
13821
|
typeof u == "function" && await u(l.current), e?.();
|
|
13811
13822
|
}, [
|
|
@@ -13815,8 +13826,8 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13815
13826
|
s,
|
|
13816
13827
|
a
|
|
13817
13828
|
]);
|
|
13818
|
-
|
|
13819
|
-
|
|
13829
|
+
Te.current = () => Ze(Pe.current === "chat" ? t : n), c(() => {
|
|
13830
|
+
je.current = k;
|
|
13820
13831
|
}, [k]), c(() => {
|
|
13821
13832
|
h && Ue("chat");
|
|
13822
13833
|
}, [h]), c(() => {
|
|
@@ -13828,13 +13839,13 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13828
13839
|
}
|
|
13829
13840
|
try {
|
|
13830
13841
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
13831
|
-
l.current = [],
|
|
13842
|
+
l.current = [], we.current = "", ke.current = !1, Me.current = !1, Ne.current = !1, Pe.current = "minimized", Nr({ onBeforeNavigate: () => {
|
|
13832
13843
|
if (i && l.current.length > 0) try {
|
|
13833
13844
|
let e = o_(l.current);
|
|
13834
|
-
e &&
|
|
13845
|
+
e && Ee(i, e);
|
|
13835
13846
|
} catch {}
|
|
13836
13847
|
if (!$n()) {
|
|
13837
|
-
let e =
|
|
13848
|
+
let e = Ie.current, t = Le.current;
|
|
13838
13849
|
if (e && s && a) try {
|
|
13839
13850
|
let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
|
|
13840
13851
|
chatId: s,
|
|
@@ -13847,68 +13858,57 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13847
13858
|
headers: { "Content-Type": "application/json" },
|
|
13848
13859
|
body: r,
|
|
13849
13860
|
keepalive: !0
|
|
13850
|
-
}).catch(() => {}),
|
|
13861
|
+
}).catch(() => {}), Ie.current = null, Le.current = null;
|
|
13851
13862
|
} catch {}
|
|
13852
13863
|
}
|
|
13853
|
-
|
|
13864
|
+
Ae();
|
|
13854
13865
|
} });
|
|
13855
13866
|
let t = k_(E_({
|
|
13856
13867
|
siteId: i || null,
|
|
13857
13868
|
apiBaseUrl: a || null,
|
|
13858
13869
|
chatId: s || null,
|
|
13859
|
-
getLastUserVoiceText: () =>
|
|
13870
|
+
getLastUserVoiceText: () => we.current,
|
|
13860
13871
|
beaconSyncFullVoiceHistory: () => d?.(l.current),
|
|
13861
|
-
isWalkthroughActive: () =>
|
|
13872
|
+
isWalkthroughActive: () => ge.current && !_e.current,
|
|
13862
13873
|
requestEndSession: () => {
|
|
13863
|
-
|
|
13874
|
+
Be.current = !0;
|
|
13864
13875
|
},
|
|
13865
13876
|
requestEmailCollection: () => {
|
|
13866
|
-
S && (
|
|
13877
|
+
S && (ce.current || P.current || (P.current = !0, fe.current = 0, ae(!0), Xe()));
|
|
13867
13878
|
}
|
|
13868
|
-
})), n = i ?
|
|
13879
|
+
})), n = !!(i ? De(i) : null)?.transcript, r = i ? Re(i) : null, u = !!r, m = typeof window < "u" ? window.location.pathname : "/", h = typeof document < "u" ? document.title : "", g = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", _ = g === "/" || g === "", b = {
|
|
13869
13880
|
apiBaseUrl: a,
|
|
13870
13881
|
siteId: i,
|
|
13871
13882
|
chatId: s,
|
|
13872
13883
|
clientTools: t
|
|
13873
13884
|
};
|
|
13874
|
-
|
|
13875
|
-
let
|
|
13876
|
-
|
|
13877
|
-
let
|
|
13878
|
-
if (!
|
|
13885
|
+
Ce.current = t;
|
|
13886
|
+
let C = (m.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), w = "";
|
|
13887
|
+
h && h.includes("|") && (w = h.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
13888
|
+
let T = w || C || "", E = T ? `the ${T} page` : "this page", D = (() => {
|
|
13889
|
+
if (!r?.targetUrl) return null;
|
|
13879
13890
|
try {
|
|
13880
|
-
return new URL(
|
|
13881
|
-
} catch {
|
|
13882
|
-
return !0;
|
|
13883
|
-
}
|
|
13884
|
-
})(), ee = (() => {
|
|
13885
|
-
if (!u?.targetUrl) return null;
|
|
13886
|
-
try {
|
|
13887
|
-
return new URL(u.targetUrl, window.location.href).pathname;
|
|
13891
|
+
return new URL(r.targetUrl, window.location.href).pathname;
|
|
13888
13892
|
} catch {
|
|
13889
13893
|
return null;
|
|
13890
13894
|
}
|
|
13891
13895
|
})();
|
|
13892
|
-
if (
|
|
13893
|
-
else if (m) {
|
|
13894
|
-
let e = u?.pageName ? `the ${u.pageName} page` : D;
|
|
13895
|
-
C.greeting = `I have navigated you to ${e}. Do you want to know about any specific section or want a complete overview?`, console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${h})`);
|
|
13896
|
-
} else if (r) C.greeting = `Welcome back! I see you're now on ${D}. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;
|
|
13896
|
+
if (u || n) b.greeting = null;
|
|
13897
13897
|
else {
|
|
13898
13898
|
let e = v || "";
|
|
13899
|
-
|
|
13899
|
+
b.greeting = y || (_ ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${E}! How may I help you?`), _ || console.log(`[FlowEngage] 🏠 Page-context greeting: "${T}" for ${m}`);
|
|
13900
13900
|
}
|
|
13901
|
-
let
|
|
13902
|
-
...
|
|
13901
|
+
let k = !1, ee = !1, te = S && !!x && !ve.current, ne = await kh.startSession({
|
|
13902
|
+
...b,
|
|
13903
13903
|
onConnect: ({ conversationId: e }) => {
|
|
13904
|
-
|
|
13904
|
+
Ie.current = e, Le.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
13905
13905
|
},
|
|
13906
13906
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
13907
13907
|
onSessionInfo: ({ emailOnFile: e }) => {
|
|
13908
|
-
|
|
13908
|
+
ve.current = !!e, e && (ce.current = !0, P.current = !1, ae(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
|
|
13909
13909
|
},
|
|
13910
13910
|
onAgentTurnEnd: () => {
|
|
13911
|
-
e ||
|
|
13911
|
+
e || ge.current && (_e.current || me.current || setTimeout(() => Se.current?.(), 250));
|
|
13912
13912
|
},
|
|
13913
13913
|
onSessionEnding: () => {
|
|
13914
13914
|
e || Ue("minimized");
|
|
@@ -13923,145 +13923,123 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13923
13923
|
onModeChange: ({ mode: t, tentative: n }) => {
|
|
13924
13924
|
if (!e) {
|
|
13925
13925
|
if (t === "speaking") {
|
|
13926
|
-
|
|
13926
|
+
z.current &&= (clearTimeout(z.current), null), He.current &&= (clearTimeout(He.current), null), O("speaking"), Ve.current = "speaking", B.current = !1;
|
|
13927
13927
|
return;
|
|
13928
13928
|
}
|
|
13929
13929
|
if (t === "user-speaking") {
|
|
13930
|
-
if (
|
|
13930
|
+
if (P.current && !ce.current && Xe(), He.current &&= (clearTimeout(He.current), null), Ve.current === "speaking") return;
|
|
13931
13931
|
try {
|
|
13932
13932
|
Pn();
|
|
13933
13933
|
} catch {}
|
|
13934
|
-
|
|
13934
|
+
z.current &&= (clearTimeout(z.current), null), Ve.current !== "listening" && (O("listening"), Ve.current = "listening");
|
|
13935
13935
|
return;
|
|
13936
13936
|
}
|
|
13937
13937
|
if (t === "thinking") {
|
|
13938
|
-
if (
|
|
13939
|
-
O("thinking"),
|
|
13940
|
-
He.current = null, !(e ||
|
|
13938
|
+
if (z.current &&= (clearTimeout(z.current), null), He.current &&= (clearTimeout(He.current), null), Ve.current === "speaking") return;
|
|
13939
|
+
O("thinking"), Ve.current = "thinking", n && (He.current = setTimeout(() => {
|
|
13940
|
+
He.current = null, !(e || Ve.current !== "thinking") && (Ve.current = "listening", O("listening"));
|
|
13941
13941
|
}, 4e3));
|
|
13942
13942
|
return;
|
|
13943
13943
|
}
|
|
13944
|
-
if (
|
|
13945
|
-
|
|
13944
|
+
if (Ve.current = "listening", Be.current) {
|
|
13945
|
+
Be.current = !1, Ue();
|
|
13946
13946
|
return;
|
|
13947
13947
|
}
|
|
13948
|
-
if (
|
|
13949
|
-
|
|
13950
|
-
try {
|
|
13951
|
-
R.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
|
|
13952
|
-
} catch {}
|
|
13953
|
-
}
|
|
13954
|
-
if (ne && !te) {
|
|
13955
|
-
te = !0;
|
|
13956
|
-
try {
|
|
13957
|
-
R.current?.sendContextualUpdate?.(ne);
|
|
13958
|
-
} catch {}
|
|
13959
|
-
}
|
|
13960
|
-
if (N && !ae) {
|
|
13961
|
-
ae = !0;
|
|
13962
|
-
try {
|
|
13963
|
-
R.current?.sendContextualUpdate?.(N);
|
|
13964
|
-
} catch {}
|
|
13965
|
-
}
|
|
13966
|
-
if (M && !j) {
|
|
13967
|
-
j = !0;
|
|
13948
|
+
if (te && !ee && !ce.current && !ve.current) {
|
|
13949
|
+
ee = !0;
|
|
13968
13950
|
try {
|
|
13969
|
-
|
|
13951
|
+
L.current?.sendContextualUpdate?.("The visitor hasn't given their email yet; the app will ask for it when they first speak.");
|
|
13970
13952
|
} catch {}
|
|
13971
13953
|
}
|
|
13972
|
-
|
|
13973
|
-
e ||
|
|
13954
|
+
z.current && clearTimeout(z.current), z.current = setTimeout(() => {
|
|
13955
|
+
e || Ve.current !== "speaking" && (B.current || (z.current = null, Ve.current = "listening", O("listening")));
|
|
13974
13956
|
}, 1200);
|
|
13975
13957
|
}
|
|
13976
13958
|
},
|
|
13977
13959
|
onMessage: (t) => {
|
|
13978
|
-
if (e ||
|
|
13960
|
+
if (e || me.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
|
|
13979
13961
|
let n = t.role === "user" && /^(Describe the section titled "|\[SYSTEM:|Give the visitor a complete spoken overview|That was the last section)/.test(String(t.message || "").trim());
|
|
13980
13962
|
if (t.role === "user" && !n) try {
|
|
13981
13963
|
Jh();
|
|
13982
13964
|
} catch {}
|
|
13983
13965
|
let r = /\b(?:this|that|the)\s+(?:case\s*stud(?:y|ies)|product|article|blog|post|item|service)\b/i.test(String(t.message || ""));
|
|
13984
|
-
if (!n && !r && t.role === "user" && We.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null),
|
|
13985
|
-
else if (!n && t.role === "user" &&
|
|
13966
|
+
if (!n && !r && t.role === "user" && We.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), F(!0), _e.current = !1, he.current = 0, I.current = -1, ye.current = O_(), be.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => Se.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${ye.current.length} sections on this page`);
|
|
13967
|
+
else if (!n && t.role === "user" && ge.current) {
|
|
13986
13968
|
let e = String(t.message || "").trim(), n = Ye(e), r = (e) => !!e && (Ke.test(e) || Je.test(e));
|
|
13987
|
-
qe.test(
|
|
13969
|
+
qe.test(xe.current || "") ? (console.log("[FlowEngage] walkthrough ended — visitor accepted a navigation offer"), be.current = null, ye.current = [], F(!1)) : !n || r(e) || r(n) ? _e.current && (_e.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => Se.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), be.current = null, ye.current = [], F(!1));
|
|
13988
13970
|
}
|
|
13989
|
-
if (t.role !== "user" && !n && (
|
|
13990
|
-
let e =
|
|
13991
|
-
!e ||
|
|
13971
|
+
if (t.role !== "user" && !n && (xe.current = String(t.message || "")), t.role !== "user" && Ge.test(String(t.message || ""))) {
|
|
13972
|
+
let e = ye.current.length;
|
|
13973
|
+
!e || I.current >= e - 1 ? F(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${I.current + 1}/${e} — ignoring, tour continues`);
|
|
13992
13974
|
}
|
|
13993
13975
|
let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
|
|
13994
13976
|
if (o) {
|
|
13995
|
-
if (a === "user" && (
|
|
13977
|
+
if (a === "user" && (we.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), B.current = !0, z.current &&= (clearTimeout(z.current), null), Ve.current !== "speaking" && (O("thinking"), Ve.current = "thinking"), te && !k && !ce.current && !ve.current && (k = !0, pe.current = o, me.current = !0, L.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), L.current?.setMicMuted?.(!0), P.current || (P.current = !0, fe.current = 0, ae(!0), Xe()))), l.current = [...l.current, {
|
|
13996
13978
|
sender: a,
|
|
13997
13979
|
message: o,
|
|
13998
13980
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13999
13981
|
debug: t.debug
|
|
14000
13982
|
}], i) try {
|
|
14001
13983
|
let e = o_(l.current);
|
|
14002
|
-
e &&
|
|
13984
|
+
e && Ee(i, e);
|
|
14003
13985
|
} catch {}
|
|
14004
13986
|
if (R_(a, o)) {
|
|
14005
|
-
|
|
13987
|
+
Be.current = !0;
|
|
14006
13988
|
return;
|
|
14007
13989
|
}
|
|
14008
|
-
|
|
14009
|
-
R.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.");
|
|
14010
|
-
} catch {}
|
|
14011
|
-
else Re.current >= 5 && Ue("minimized");
|
|
13990
|
+
je.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o) && (ze.current += 1, ze.current >= 5 && Ue("minimized"));
|
|
14012
13991
|
}
|
|
14013
13992
|
},
|
|
14014
13993
|
onError: (t) => {
|
|
14015
|
-
if (!e && !
|
|
14016
|
-
|
|
13994
|
+
if (!e && !Ne.current && !Me.current && !Fe()) {
|
|
13995
|
+
Me.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
14017
13996
|
message: t?.message,
|
|
14018
13997
|
name: t?.name,
|
|
14019
13998
|
raw: t
|
|
14020
13999
|
});
|
|
14021
14000
|
try {
|
|
14022
|
-
|
|
14001
|
+
L.current?.setMicMuted?.(!0);
|
|
14023
14002
|
} catch {}
|
|
14024
14003
|
A(!0), O("error"), Ue("chat");
|
|
14025
14004
|
}
|
|
14026
14005
|
},
|
|
14027
14006
|
onDisconnect: (t) => {
|
|
14028
|
-
if (e ||
|
|
14007
|
+
if (e || Ne.current || Me.current || Fe()) return;
|
|
14029
14008
|
let n = l.current?.length || 0;
|
|
14030
14009
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
14031
14010
|
historyCount: n,
|
|
14032
14011
|
reason: t?.reason,
|
|
14033
14012
|
closeCode: t?.context?.code,
|
|
14034
14013
|
closeReason: t?.context?.reason || t?.message,
|
|
14035
|
-
lastUserText:
|
|
14036
|
-
wasMuted:
|
|
14037
|
-
}),
|
|
14014
|
+
lastUserText: we.current || "",
|
|
14015
|
+
wasMuted: je.current
|
|
14016
|
+
}), Me.current = !0;
|
|
14038
14017
|
try {
|
|
14039
|
-
|
|
14018
|
+
L.current?.setMicMuted?.(!0);
|
|
14040
14019
|
} catch {}
|
|
14041
14020
|
A(!0), Ue("chat");
|
|
14042
14021
|
}
|
|
14043
14022
|
});
|
|
14044
14023
|
if (e) {
|
|
14045
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
14024
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ne.endSession().catch(() => {});
|
|
14046
14025
|
return;
|
|
14047
14026
|
}
|
|
14048
|
-
o =
|
|
14027
|
+
o = ne, L.current = ne, O("listening");
|
|
14049
14028
|
try {
|
|
14050
|
-
sessionStorage.setItem(`el_conv_${i}`,
|
|
14029
|
+
sessionStorage.setItem(`el_conv_${i}`, ne.getId());
|
|
14051
14030
|
} catch {}
|
|
14052
14031
|
parent.postMessage({ type: "AGENT_EXPAND" }, "*");
|
|
14053
14032
|
try {
|
|
14054
|
-
let e = typeof window < "u" ? window.location.href : "",
|
|
14033
|
+
let e = typeof window < "u" ? window.location.href : "", n = "[]";
|
|
14055
14034
|
try {
|
|
14056
|
-
|
|
14035
|
+
n = await t["fwh-list-forms-mvp"]();
|
|
14057
14036
|
} catch {}
|
|
14058
|
-
let
|
|
14037
|
+
let r = "none";
|
|
14059
14038
|
if (typeof window < "u" && typeof document < "u") try {
|
|
14060
14039
|
let e = "#flowengage-root, .flowengage-shell, .flowengage-widget-root", t = document.querySelector("main, [role='main']") || document.body, n = Array.from(t.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200);
|
|
14061
|
-
n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (
|
|
14040
|
+
n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (r = [...new Set(n)].slice(0, 15).join(" | "));
|
|
14062
14041
|
} catch {}
|
|
14063
|
-
|
|
14064
|
-
ue.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${x ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), ue.sendContextualUpdate(j_(e, o, a));
|
|
14042
|
+
x || ne.sendContextualUpdate("The visitor's email is already on file from an earlier session."), ne.sendContextualUpdate(j_(e, r, n));
|
|
14065
14043
|
} catch {}
|
|
14066
14044
|
if (typeof window < "u") {
|
|
14067
14045
|
let t = window.location.pathname, n = Date.now(), r = (e) => {
|
|
@@ -14070,57 +14048,51 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14070
14048
|
} catch {
|
|
14071
14049
|
return ((e || "/").replace(/\/+$/, "") || "/").toLowerCase();
|
|
14072
14050
|
}
|
|
14073
|
-
},
|
|
14051
|
+
}, i = () => {
|
|
14074
14052
|
if (e) return;
|
|
14075
|
-
let
|
|
14076
|
-
if (r(
|
|
14077
|
-
t =
|
|
14053
|
+
let i = window.location.pathname;
|
|
14054
|
+
if (r(i) === r(t)) {
|
|
14055
|
+
t = i;
|
|
14078
14056
|
return;
|
|
14079
14057
|
}
|
|
14080
14058
|
if (Date.now() - n < 8e3) {
|
|
14081
|
-
t =
|
|
14059
|
+
t = i;
|
|
14082
14060
|
return;
|
|
14083
14061
|
}
|
|
14084
|
-
let
|
|
14085
|
-
t =
|
|
14086
|
-
let
|
|
14062
|
+
let a = typeof window < "u" && window.__fe_agent_nav || null, o = D && r(i) === r(D) || Gn() || a && Date.now() - a.ts < 15e3 && r(a.path) === r(i), s = t;
|
|
14063
|
+
t = i;
|
|
14064
|
+
let c = window.location.href, l = typeof document < "u" ? Array.from(document.querySelectorAll("h1, h2, h3, h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell")).map((e) => ({
|
|
14087
14065
|
tag: e.tagName,
|
|
14088
14066
|
text: e.textContent.trim()
|
|
14089
14067
|
})).filter((e) => e.text.length > 0 && e.text.length < 200).slice(0, 20) : [];
|
|
14090
14068
|
try {
|
|
14091
14069
|
Pn();
|
|
14092
14070
|
} catch {}
|
|
14093
|
-
let
|
|
14094
|
-
if (
|
|
14095
|
-
|
|
14096
|
-
R.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${h}" page (${l}) at their request — this was YOUR action, not theirs. Page title: "${u}". Sections: ${JSON.stringify(d)}. Say: "Here we are on the ${h} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
|
|
14097
|
-
} catch {}
|
|
14098
|
-
else console.log("[FlowEngage] auto-nav — skipping the arrival acknowledgment turn");
|
|
14071
|
+
let u = l.map((e) => e.text).join(" | "), d = (e) => (e.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", f = d(s), p = d(i);
|
|
14072
|
+
if (o) {
|
|
14073
|
+
typeof window < "u" && (window.__fe_agent_nav = null), console.log(`[FlowEngage] agent-driven navigation settled: "${s}" → "${i}"`);
|
|
14099
14074
|
try {
|
|
14100
|
-
|
|
14075
|
+
L.current?.sendContextualUpdate?.(j_(c, u));
|
|
14101
14076
|
} catch {}
|
|
14102
14077
|
return;
|
|
14103
14078
|
}
|
|
14104
14079
|
typeof window < "u" && (window.__fe_user_nav_during_speech = {
|
|
14105
|
-
fromPath:
|
|
14106
|
-
toPath:
|
|
14107
|
-
fromPageName:
|
|
14108
|
-
toPageName:
|
|
14080
|
+
fromPath: s,
|
|
14081
|
+
toPath: i,
|
|
14082
|
+
fromPageName: f,
|
|
14083
|
+
toPageName: p,
|
|
14109
14084
|
ts: Date.now()
|
|
14110
|
-
}), console.log(`[FlowEngage] visitor navigation detected: "${
|
|
14085
|
+
}), console.log(`[FlowEngage] visitor navigation detected: "${s}" → "${i}" (agent target: ${D || "none"})`);
|
|
14111
14086
|
try {
|
|
14112
|
-
|
|
14113
|
-
} catch {}
|
|
14114
|
-
try {
|
|
14115
|
-
R.current?.sendContextualUpdate?.(j_(l, f));
|
|
14087
|
+
L.current?.sendContextualUpdate?.(j_(c, u, null, f));
|
|
14116
14088
|
} catch {}
|
|
14117
14089
|
};
|
|
14118
14090
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
14119
|
-
c(...e), setTimeout(
|
|
14120
|
-
}, p = () => setTimeout(
|
|
14091
|
+
c(...e), setTimeout(i, 50);
|
|
14092
|
+
}, p = () => setTimeout(i, 50), window.addEventListener("popstate", p);
|
|
14121
14093
|
}
|
|
14122
14094
|
} catch (r) {
|
|
14123
|
-
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (O("error"),
|
|
14095
|
+
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (O("error"), Pe.current = "chat", window.setTimeout(() => {
|
|
14124
14096
|
e || t?.();
|
|
14125
14097
|
}, 0)));
|
|
14126
14098
|
}
|
|
@@ -14129,15 +14101,15 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14129
14101
|
agentId: r,
|
|
14130
14102
|
siteId: i,
|
|
14131
14103
|
apiBaseUrl: a
|
|
14132
|
-
}), e = !0,
|
|
14104
|
+
}), e = !0, Ne.current = !0;
|
|
14133
14105
|
try {
|
|
14134
14106
|
Pn();
|
|
14135
14107
|
} catch {}
|
|
14136
14108
|
if (i) try {
|
|
14137
|
-
|
|
14109
|
+
Re(i);
|
|
14138
14110
|
} catch {}
|
|
14139
|
-
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pr(),
|
|
14140
|
-
let t = o ||
|
|
14111
|
+
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pr(), z.current &&= (clearTimeout(z.current), null), He.current &&= (clearTimeout(He.current), null), de.current &&= (clearTimeout(de.current), null), B.current = !1, Ve.current = "idle", c && typeof window < "u" && (window.history.pushState = c), p && typeof window < "u" && window.removeEventListener("popstate", p);
|
|
14112
|
+
let t = o || L.current, n = Ie.current, d = Le.current;
|
|
14141
14113
|
if (t?.endSession?.().catch(() => {}), n && s && a) {
|
|
14142
14114
|
let e = d ? Math.round((Date.now() - d) / 1e3) : 0, t = JSON.stringify({
|
|
14143
14115
|
chatId: s,
|
|
@@ -14150,7 +14122,7 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14150
14122
|
headers: { "Content-Type": "application/json" },
|
|
14151
14123
|
body: t,
|
|
14152
14124
|
keepalive: !0
|
|
14153
|
-
}).catch(() => {}),
|
|
14125
|
+
}).catch(() => {}), Ie.current = null, Le.current = null;
|
|
14154
14126
|
}
|
|
14155
14127
|
typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
|
|
14156
14128
|
};
|
|
@@ -14163,48 +14135,48 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14163
14135
|
if (!ee) return;
|
|
14164
14136
|
let e = (e) => {
|
|
14165
14137
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
14166
|
-
|
|
14138
|
+
R.current && !R.current.contains(t) && te(!1);
|
|
14167
14139
|
};
|
|
14168
14140
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
14169
14141
|
}, [ee]);
|
|
14170
14142
|
let H = async () => {
|
|
14171
|
-
if (
|
|
14143
|
+
if (L.current) try {
|
|
14172
14144
|
if (k) {
|
|
14173
|
-
|
|
14145
|
+
ze.current = 0, await L.current.setMicMuted?.(!1), A(!1);
|
|
14174
14146
|
try {
|
|
14175
|
-
|
|
14147
|
+
L.current.sendContextualUpdate?.("[MIC] The visitor unmuted their microphone.");
|
|
14176
14148
|
} catch {}
|
|
14177
14149
|
} else {
|
|
14178
|
-
|
|
14150
|
+
ze.current = 0, await L.current.setMicMuted?.(!0), A(!0);
|
|
14179
14151
|
try {
|
|
14180
|
-
|
|
14152
|
+
L.current.sendContextualUpdate?.("[MIC] The visitor muted their microphone.");
|
|
14181
14153
|
} catch {}
|
|
14182
14154
|
}
|
|
14183
14155
|
} catch {}
|
|
14184
14156
|
}, U = o(async (e) => {
|
|
14185
14157
|
e?.preventDefault?.();
|
|
14186
|
-
let t =
|
|
14158
|
+
let t = oe.trim().toLowerCase();
|
|
14187
14159
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
|
|
14188
|
-
|
|
14160
|
+
N("Please enter a valid email address.");
|
|
14189
14161
|
return;
|
|
14190
14162
|
}
|
|
14191
|
-
|
|
14163
|
+
N(""), ce.current = !0, P.current = !1, V(), ae(!1), M(""), me.current = !1;
|
|
14192
14164
|
try {
|
|
14193
14165
|
typeof b == "function" && await b(t);
|
|
14194
14166
|
} catch {}
|
|
14195
|
-
|
|
14196
|
-
let n =
|
|
14197
|
-
|
|
14167
|
+
L.current?.setMicMuted?.(!1);
|
|
14168
|
+
let n = pe.current;
|
|
14169
|
+
pe.current = "";
|
|
14198
14170
|
try {
|
|
14199
|
-
|
|
14171
|
+
L.current?.injectAgentSpeech?.("Thank you for submitting your email."), L.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
|
|
14200
14172
|
} catch {}
|
|
14201
14173
|
}, [
|
|
14202
|
-
|
|
14174
|
+
oe,
|
|
14203
14175
|
b,
|
|
14204
14176
|
V
|
|
14205
14177
|
]), Qe = Array.isArray(e) && e[0] || "#3B82F6";
|
|
14206
14178
|
return /* @__PURE__ */ _("div", {
|
|
14207
|
-
ref:
|
|
14179
|
+
ref: R,
|
|
14208
14180
|
style: {
|
|
14209
14181
|
position: "relative",
|
|
14210
14182
|
display: "flex",
|
|
@@ -14214,7 +14186,7 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14214
14186
|
animation: "fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)"
|
|
14215
14187
|
},
|
|
14216
14188
|
children: [
|
|
14217
|
-
|
|
14189
|
+
ie && /* @__PURE__ */ _("form", {
|
|
14218
14190
|
onSubmit: U,
|
|
14219
14191
|
style: {
|
|
14220
14192
|
width: "270px",
|
|
@@ -14246,9 +14218,9 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14246
14218
|
inputMode: "email",
|
|
14247
14219
|
autoComplete: "email",
|
|
14248
14220
|
autoFocus: !0,
|
|
14249
|
-
value:
|
|
14221
|
+
value: oe,
|
|
14250
14222
|
onChange: (e) => {
|
|
14251
|
-
|
|
14223
|
+
M(e.target.value), se && N("");
|
|
14252
14224
|
},
|
|
14253
14225
|
placeholder: "you@example.com",
|
|
14254
14226
|
style: {
|
|
@@ -14256,33 +14228,33 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14256
14228
|
boxSizing: "border-box",
|
|
14257
14229
|
padding: "10px 12px",
|
|
14258
14230
|
borderRadius: "10px",
|
|
14259
|
-
border:
|
|
14231
|
+
border: se ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
14260
14232
|
background: "#1f2937",
|
|
14261
14233
|
color: "white",
|
|
14262
14234
|
fontSize: "14px",
|
|
14263
14235
|
outline: "none"
|
|
14264
14236
|
}
|
|
14265
14237
|
}),
|
|
14266
|
-
|
|
14238
|
+
se && /* @__PURE__ */ g("span", {
|
|
14267
14239
|
style: {
|
|
14268
14240
|
color: "#f87171",
|
|
14269
14241
|
fontSize: "12px"
|
|
14270
14242
|
},
|
|
14271
|
-
children:
|
|
14243
|
+
children: se
|
|
14272
14244
|
}),
|
|
14273
14245
|
/* @__PURE__ */ g("button", {
|
|
14274
14246
|
type: "submit",
|
|
14275
|
-
disabled: !
|
|
14247
|
+
disabled: !oe.trim(),
|
|
14276
14248
|
style: {
|
|
14277
14249
|
width: "100%",
|
|
14278
14250
|
padding: "10px 12px",
|
|
14279
14251
|
borderRadius: "10px",
|
|
14280
14252
|
border: "none",
|
|
14281
|
-
background:
|
|
14253
|
+
background: oe.trim() ? Qe : "#374151",
|
|
14282
14254
|
color: "white",
|
|
14283
14255
|
fontSize: "14px",
|
|
14284
14256
|
fontWeight: 600,
|
|
14285
|
-
cursor:
|
|
14257
|
+
cursor: oe.trim() ? "pointer" : "default",
|
|
14286
14258
|
transition: "background 0.2s ease"
|
|
14287
14259
|
},
|
|
14288
14260
|
children: "Submit"
|
|
@@ -14442,7 +14414,7 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14442
14414
|
children: [
|
|
14443
14415
|
/* @__PURE__ */ _("button", {
|
|
14444
14416
|
onClick: () => {
|
|
14445
|
-
te(!1),
|
|
14417
|
+
te(!1), Pe.current = "chat", Ze(t);
|
|
14446
14418
|
},
|
|
14447
14419
|
style: {
|
|
14448
14420
|
display: "flex",
|
|
@@ -14470,7 +14442,7 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14470
14442
|
children: [/* @__PURE__ */ g(vg, {}), T]
|
|
14471
14443
|
}),
|
|
14472
14444
|
i && /* @__PURE__ */ _("button", {
|
|
14473
|
-
onClick: () =>
|
|
14445
|
+
onClick: () => re(),
|
|
14474
14446
|
style: {
|
|
14475
14447
|
display: "flex",
|
|
14476
14448
|
alignItems: "center",
|
|
@@ -14546,7 +14518,7 @@ function H_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
14546
14518
|
}),
|
|
14547
14519
|
/* @__PURE__ */ _("button", {
|
|
14548
14520
|
onClick: () => {
|
|
14549
|
-
te(!1),
|
|
14521
|
+
te(!1), Pe.current = "minimized", Ze(n);
|
|
14550
14522
|
},
|
|
14551
14523
|
style: {
|
|
14552
14524
|
display: "flex",
|
|
@@ -14672,11 +14644,11 @@ var W_ = () => /* @__PURE__ */ g("div", {
|
|
|
14672
14644
|
} }, e))
|
|
14673
14645
|
})
|
|
14674
14646
|
});
|
|
14675
|
-
function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput:
|
|
14676
|
-
let
|
|
14677
|
-
let e =
|
|
14678
|
-
|
|
14679
|
-
}, [
|
|
14647
|
+
function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: re, emailError: ie, emailCaptureSuccess: ae, replyContext: oe, setReplyContext: M, webRTCError: se, micError: N, setMicError: ce, dismissCallError: P, activeCallId: de, isCallMuted: fe, toggleCallMute: pe, endWebRTCCall: me, formatCallDuration: he, callDurationSeconds: ge, isCallMinimized: _e, onExpand: ve, onCollapse: ye, onStartVoice: be, voiceEnabled: xe, headerBgColor: Se, onNewChat: F, showPoweredBy: I, privacyPolicyUrl: L, getVisitorChatHistory: Ce, resumeChat: we, isSessionRestoring: Te, isClosing: Ee }) {
|
|
14648
|
+
let De = l.length > 0, Oe = T || E || w, ke = !!de, [Ae, je] = m(!1), { resolvedConfig: Me } = kn(), Ne = Me?.siteId || null, [Pe, Fe] = m(() => le(Ne) === "auto"), Ie = () => {
|
|
14649
|
+
let e = Pe ? "ask" : "auto";
|
|
14650
|
+
ue(Ne, e), Fe(e === "auto");
|
|
14651
|
+
}, [Le, Re] = m(!1), [R, ze] = m([]), [Be, Ve] = m(!1), z = p(null), [B, He] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Ue, V] = m(0);
|
|
14680
14652
|
c(() => {
|
|
14681
14653
|
if (!s) return;
|
|
14682
14654
|
let e = window.visualViewport;
|
|
@@ -14689,26 +14661,26 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14689
14661
|
};
|
|
14690
14662
|
}, [s]);
|
|
14691
14663
|
let We = s && window.innerHeight - B > 150, Ge = async () => {
|
|
14692
|
-
|
|
14664
|
+
je(!1), Re(!0), Ve(!0);
|
|
14693
14665
|
try {
|
|
14694
|
-
let e = await
|
|
14695
|
-
e?.data &&
|
|
14666
|
+
let e = await Ce();
|
|
14667
|
+
e?.data && ze(e.data);
|
|
14696
14668
|
} catch (e) {
|
|
14697
14669
|
console.error(e);
|
|
14698
14670
|
} finally {
|
|
14699
|
-
|
|
14671
|
+
Ve(!1);
|
|
14700
14672
|
}
|
|
14701
14673
|
}, Ke = async (e) => {
|
|
14702
|
-
|
|
14674
|
+
Re(!1), we?.(e.chatId);
|
|
14703
14675
|
};
|
|
14704
14676
|
return c(() => {
|
|
14705
|
-
if (!
|
|
14677
|
+
if (!Ae) return;
|
|
14706
14678
|
let e = (e) => {
|
|
14707
14679
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
14708
|
-
|
|
14680
|
+
z.current && !z.current.contains(t) && je(!1);
|
|
14709
14681
|
};
|
|
14710
14682
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
14711
|
-
}, [
|
|
14683
|
+
}, [Ae]), /* @__PURE__ */ _("div", {
|
|
14712
14684
|
style: s ? {
|
|
14713
14685
|
"--flowengage-primary": n,
|
|
14714
14686
|
"--flowengage-accent": n,
|
|
@@ -14722,7 +14694,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14722
14694
|
display: "flex",
|
|
14723
14695
|
flexDirection: "column",
|
|
14724
14696
|
overflow: "hidden",
|
|
14725
|
-
animation:
|
|
14697
|
+
animation: Ee ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
|
|
14726
14698
|
} : {
|
|
14727
14699
|
"--flowengage-primary": n,
|
|
14728
14700
|
"--flowengage-accent": n,
|
|
@@ -14735,7 +14707,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14735
14707
|
flexDirection: "column",
|
|
14736
14708
|
overflow: "hidden",
|
|
14737
14709
|
position: "relative",
|
|
14738
|
-
animation:
|
|
14710
|
+
animation: Ee ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
|
|
14739
14711
|
},
|
|
14740
14712
|
children: [
|
|
14741
14713
|
/* @__PURE__ */ _("div", {
|
|
@@ -14745,7 +14717,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14745
14717
|
alignItems: "center",
|
|
14746
14718
|
columnGap: "14px",
|
|
14747
14719
|
padding: "16px 10px 14px",
|
|
14748
|
-
background:
|
|
14720
|
+
background: Se || "transparent",
|
|
14749
14721
|
flexShrink: 0,
|
|
14750
14722
|
position: "relative",
|
|
14751
14723
|
zIndex: 30
|
|
@@ -14758,7 +14730,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14758
14730
|
alignItems: "center"
|
|
14759
14731
|
},
|
|
14760
14732
|
children: /* @__PURE__ */ g("button", {
|
|
14761
|
-
onClick:
|
|
14733
|
+
onClick: ye,
|
|
14762
14734
|
style: {
|
|
14763
14735
|
width: "40px",
|
|
14764
14736
|
height: "40px",
|
|
@@ -14860,10 +14832,10 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14860
14832
|
isolation: "isolate",
|
|
14861
14833
|
zIndex: 10
|
|
14862
14834
|
},
|
|
14863
|
-
ref:
|
|
14835
|
+
ref: z,
|
|
14864
14836
|
children: [/* @__PURE__ */ g("button", {
|
|
14865
14837
|
type: "button",
|
|
14866
|
-
onClick: () =>
|
|
14838
|
+
onClick: () => je((e) => !e),
|
|
14867
14839
|
style: {
|
|
14868
14840
|
width: "40px",
|
|
14869
14841
|
height: "40px",
|
|
@@ -14909,7 +14881,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14909
14881
|
})
|
|
14910
14882
|
]
|
|
14911
14883
|
})
|
|
14912
|
-
}),
|
|
14884
|
+
}), Ae && /* @__PURE__ */ _("div", {
|
|
14913
14885
|
style: {
|
|
14914
14886
|
position: "absolute",
|
|
14915
14887
|
top: "34px",
|
|
@@ -14925,10 +14897,10 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14925
14897
|
animation: "fe-orb-fade-in 0.18s ease"
|
|
14926
14898
|
},
|
|
14927
14899
|
children: [
|
|
14928
|
-
|
|
14900
|
+
xe && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
|
|
14929
14901
|
type: "button",
|
|
14930
14902
|
onClick: () => {
|
|
14931
|
-
|
|
14903
|
+
je(!1), be?.();
|
|
14932
14904
|
},
|
|
14933
14905
|
style: {
|
|
14934
14906
|
display: "flex",
|
|
@@ -14970,7 +14942,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14970
14942
|
/* @__PURE__ */ _("button", {
|
|
14971
14943
|
type: "button",
|
|
14972
14944
|
onClick: () => {
|
|
14973
|
-
|
|
14945
|
+
je(!1), F?.();
|
|
14974
14946
|
},
|
|
14975
14947
|
style: {
|
|
14976
14948
|
display: "flex",
|
|
@@ -15005,7 +14977,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15005
14977
|
children: [/* @__PURE__ */ g("path", { d: "M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7" }), /* @__PURE__ */ g("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })]
|
|
15006
14978
|
}), "Start new chat"]
|
|
15007
14979
|
}),
|
|
15008
|
-
|
|
14980
|
+
Ce && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
|
|
15009
14981
|
height: "1px",
|
|
15010
14982
|
background: "rgba(255,255,255,0.07)",
|
|
15011
14983
|
margin: "0 14px"
|
|
@@ -15045,14 +15017,14 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15045
15017
|
children: /* @__PURE__ */ g("path", { d: "M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z" })
|
|
15046
15018
|
}), "Chat history"]
|
|
15047
15019
|
})] }),
|
|
15048
|
-
|
|
15020
|
+
Ne && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
|
|
15049
15021
|
height: "1px",
|
|
15050
15022
|
background: "rgba(255,255,255,0.07)",
|
|
15051
15023
|
margin: "0 14px"
|
|
15052
15024
|
} }), /* @__PURE__ */ _("button", {
|
|
15053
15025
|
type: "button",
|
|
15054
15026
|
onClick: () => {
|
|
15055
|
-
|
|
15027
|
+
Ie(), je(!1);
|
|
15056
15028
|
},
|
|
15057
15029
|
style: {
|
|
15058
15030
|
display: "flex",
|
|
@@ -15109,7 +15081,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15109
15081
|
width: "34px",
|
|
15110
15082
|
height: "19px",
|
|
15111
15083
|
borderRadius: "999px",
|
|
15112
|
-
background:
|
|
15084
|
+
background: Pe ? "#22c55e" : "rgba(255,255,255,0.2)",
|
|
15113
15085
|
position: "relative",
|
|
15114
15086
|
flexShrink: 0,
|
|
15115
15087
|
transition: "background 0.15s ease"
|
|
@@ -15117,7 +15089,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15117
15089
|
children: /* @__PURE__ */ g("span", { style: {
|
|
15118
15090
|
position: "absolute",
|
|
15119
15091
|
top: "2px",
|
|
15120
|
-
left:
|
|
15092
|
+
left: Pe ? "17px" : "2px",
|
|
15121
15093
|
width: "15px",
|
|
15122
15094
|
height: "15px",
|
|
15123
15095
|
borderRadius: "50%",
|
|
@@ -15134,7 +15106,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15134
15106
|
/* @__PURE__ */ _("button", {
|
|
15135
15107
|
type: "button",
|
|
15136
15108
|
onClick: () => {
|
|
15137
|
-
|
|
15109
|
+
je(!1), ye?.();
|
|
15138
15110
|
},
|
|
15139
15111
|
style: {
|
|
15140
15112
|
display: "flex",
|
|
@@ -15193,23 +15165,23 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15193
15165
|
]
|
|
15194
15166
|
}),
|
|
15195
15167
|
/* @__PURE__ */ g(Hg, {
|
|
15196
|
-
webRTCError:
|
|
15197
|
-
micError:
|
|
15198
|
-
setMicError:
|
|
15199
|
-
dismissCallError:
|
|
15168
|
+
webRTCError: se,
|
|
15169
|
+
micError: N,
|
|
15170
|
+
setMicError: ce,
|
|
15171
|
+
dismissCallError: P,
|
|
15200
15172
|
isRateLimited: E,
|
|
15201
15173
|
rateLimitMessage: D
|
|
15202
15174
|
}),
|
|
15203
|
-
|
|
15175
|
+
_e && /* @__PURE__ */ g(a_, {
|
|
15204
15176
|
agentName: v,
|
|
15205
15177
|
agentHeadshot: y,
|
|
15206
15178
|
fallbackAgentName: b,
|
|
15207
|
-
callDurationSeconds:
|
|
15208
|
-
isCallMuted:
|
|
15209
|
-
formatCallDuration:
|
|
15210
|
-
toggleCallMute:
|
|
15211
|
-
endWebRTCCall:
|
|
15212
|
-
onExpand:
|
|
15179
|
+
callDurationSeconds: ge,
|
|
15180
|
+
isCallMuted: fe,
|
|
15181
|
+
formatCallDuration: he,
|
|
15182
|
+
toggleCallMute: pe,
|
|
15183
|
+
endWebRTCCall: me,
|
|
15184
|
+
onExpand: ve,
|
|
15213
15185
|
primaryColor: n
|
|
15214
15186
|
}),
|
|
15215
15187
|
/* @__PURE__ */ _("div", {
|
|
@@ -15221,7 +15193,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15221
15193
|
background: "transparent",
|
|
15222
15194
|
position: "relative"
|
|
15223
15195
|
},
|
|
15224
|
-
children: [
|
|
15196
|
+
children: [Le ? /* @__PURE__ */ _("div", {
|
|
15225
15197
|
style: {
|
|
15226
15198
|
position: "absolute",
|
|
15227
15199
|
inset: 0,
|
|
@@ -15240,7 +15212,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15240
15212
|
flexShrink: 0
|
|
15241
15213
|
},
|
|
15242
15214
|
children: /* @__PURE__ */ _("button", {
|
|
15243
|
-
onClick: () =>
|
|
15215
|
+
onClick: () => Re(!1),
|
|
15244
15216
|
style: {
|
|
15245
15217
|
background: "none",
|
|
15246
15218
|
border: "none",
|
|
@@ -15274,7 +15246,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15274
15246
|
overflowY: "auto",
|
|
15275
15247
|
position: "relative"
|
|
15276
15248
|
},
|
|
15277
|
-
children:
|
|
15249
|
+
children: Be ? /* @__PURE__ */ g("div", {
|
|
15278
15250
|
style: {
|
|
15279
15251
|
padding: "40px 20px",
|
|
15280
15252
|
textAlign: "center",
|
|
@@ -15282,7 +15254,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15282
15254
|
fontSize: "14px"
|
|
15283
15255
|
},
|
|
15284
15256
|
children: "Loading past conversations..."
|
|
15285
|
-
}) :
|
|
15257
|
+
}) : R.length > 0 ? /* @__PURE__ */ g("div", { children: R.map((e) => /* @__PURE__ */ _("div", {
|
|
15286
15258
|
onClick: () => Ke(e),
|
|
15287
15259
|
style: {
|
|
15288
15260
|
padding: "16px 20px",
|
|
@@ -15334,18 +15306,18 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15334
15306
|
children: "No previous chats found."
|
|
15335
15307
|
})
|
|
15336
15308
|
})]
|
|
15337
|
-
}) : null,
|
|
15309
|
+
}) : null, De ? /* @__PURE__ */ g(zg, {
|
|
15338
15310
|
chatHistory: l,
|
|
15339
15311
|
isAiTyping: u,
|
|
15340
15312
|
isLoading: T,
|
|
15341
15313
|
isAgentTyping: d,
|
|
15342
|
-
setReplyContext:
|
|
15314
|
+
setReplyContext: M,
|
|
15343
15315
|
TypingDots: W_,
|
|
15344
15316
|
primaryColor: n,
|
|
15345
15317
|
agentHeadshot: y,
|
|
15346
15318
|
agentDisplayName: v || b,
|
|
15347
15319
|
botAvatarNode: /* @__PURE__ */ g(U_, { orbColors: t })
|
|
15348
|
-
}) :
|
|
15320
|
+
}) : Te ? /* @__PURE__ */ _("div", {
|
|
15349
15321
|
style: {
|
|
15350
15322
|
flex: 1,
|
|
15351
15323
|
display: "flex",
|
|
@@ -15435,7 +15407,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15435
15407
|
]
|
|
15436
15408
|
})]
|
|
15437
15409
|
}),
|
|
15438
|
-
|
|
15410
|
+
ae && /* @__PURE__ */ _("div", {
|
|
15439
15411
|
style: {
|
|
15440
15412
|
margin: "0 16px 8px",
|
|
15441
15413
|
padding: "9px 14px",
|
|
@@ -15481,13 +15453,13 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15481
15453
|
setInput: S,
|
|
15482
15454
|
onSubmit: C,
|
|
15483
15455
|
isConversationEnded: w,
|
|
15484
|
-
callUiActive:
|
|
15485
|
-
handleToggleVoice:
|
|
15456
|
+
callUiActive: ke,
|
|
15457
|
+
handleToggleVoice: be,
|
|
15486
15458
|
showVoiceToggle: f === "agent",
|
|
15487
15459
|
activeScreen: f,
|
|
15488
|
-
inputDisabled:
|
|
15489
|
-
replyContext:
|
|
15490
|
-
clearReplyContext: () =>
|
|
15460
|
+
inputDisabled: Oe,
|
|
15461
|
+
replyContext: oe,
|
|
15462
|
+
clearReplyContext: () => M(null),
|
|
15491
15463
|
onFileSelect: k,
|
|
15492
15464
|
selectedFile: O,
|
|
15493
15465
|
onRemoveSelectedFile: A,
|
|
@@ -15495,8 +15467,8 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15495
15467
|
isUploadingAttachment: te,
|
|
15496
15468
|
requiresEmail: ne,
|
|
15497
15469
|
emailInput: j,
|
|
15498
|
-
setEmailInput:
|
|
15499
|
-
emailError:
|
|
15470
|
+
setEmailInput: re,
|
|
15471
|
+
emailError: ie,
|
|
15500
15472
|
inputPlaceholder: e.inputPlaceholder
|
|
15501
15473
|
})
|
|
15502
15474
|
}),
|
|
@@ -15508,7 +15480,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15508
15480
|
paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
|
|
15509
15481
|
pointerEvents: "none"
|
|
15510
15482
|
},
|
|
15511
|
-
children: [
|
|
15483
|
+
children: [L && /* @__PURE__ */ _("p", {
|
|
15512
15484
|
style: {
|
|
15513
15485
|
margin: "0 0 4px",
|
|
15514
15486
|
fontSize: "10px",
|
|
@@ -15521,7 +15493,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15521
15493
|
"This conversation is recorded for quality assurance purposes.",
|
|
15522
15494
|
" ",
|
|
15523
15495
|
/* @__PURE__ */ g("a", {
|
|
15524
|
-
href:
|
|
15496
|
+
href: L,
|
|
15525
15497
|
target: "_blank",
|
|
15526
15498
|
rel: "noopener noreferrer",
|
|
15527
15499
|
style: {
|
|
@@ -15531,7 +15503,7 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15531
15503
|
children: "See our privacy policy"
|
|
15532
15504
|
})
|
|
15533
15505
|
]
|
|
15534
|
-
}),
|
|
15506
|
+
}), I && /* @__PURE__ */ _("span", {
|
|
15535
15507
|
style: {
|
|
15536
15508
|
fontSize: "11px",
|
|
15537
15509
|
color: "#9ca3af",
|
|
@@ -15551,33 +15523,33 @@ function G_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
15551
15523
|
});
|
|
15552
15524
|
}
|
|
15553
15525
|
function K_() {
|
|
15554
|
-
let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, beaconSyncVoiceTranscript: j, sendMessage:
|
|
15526
|
+
let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, beaconSyncVoiceTranscript: j, sendMessage: re, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode: M, endConversation: ce, startNewChat: P, acceptCall: le, rejectCall: ue, endWebRTCCall: de, toggleCallMute: fe, dismissCallError: pe, startTyping: me, stopTyping: he, updateTypingDraft: ge, getVisitorChatHistory: _e, resumeChat: ve, isSessionRestoring: ye, openToChatCounter: be, voiceEndCounter: xe } = kn();
|
|
15555
15527
|
c(() => {
|
|
15556
15528
|
try {
|
|
15557
15529
|
fr();
|
|
15558
15530
|
} catch {}
|
|
15559
15531
|
}, []), c(() => {
|
|
15560
|
-
|
|
15561
|
-
}, [
|
|
15562
|
-
let
|
|
15563
|
-
...
|
|
15564
|
-
...
|
|
15565
|
-
},
|
|
15566
|
-
...
|
|
15567
|
-
...
|
|
15568
|
-
},
|
|
15569
|
-
...
|
|
15570
|
-
...
|
|
15571
|
-
},
|
|
15532
|
+
be && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (M?.(!1), et("text_chat"));
|
|
15533
|
+
}, [be]);
|
|
15534
|
+
let Se = t?.widgetSettings || {}, F = n?.widgetSettings || {}, I = {
|
|
15535
|
+
...Se.branding || {},
|
|
15536
|
+
...F.branding || {}
|
|
15537
|
+
}, L = {
|
|
15538
|
+
...Se.theme || {},
|
|
15539
|
+
...F.theme || {}
|
|
15540
|
+
}, Ce = {
|
|
15541
|
+
...Se.features || {},
|
|
15542
|
+
...F.features || {}
|
|
15543
|
+
}, we = Ce.voice !== !1, Te = Array.isArray(L.orbColors) && L.orbColors.length > 0 ? L.orbColors : null, Ee = L.buttonColor || L.primaryColor || Te?.[0] || "#3B82F6", ke = {
|
|
15572
15544
|
small: 50,
|
|
15573
15545
|
medium: 64,
|
|
15574
15546
|
large: 80
|
|
15575
|
-
},
|
|
15547
|
+
}, Ae = ke[L.orbSize] || ke.small, Me = L.position || "bottom-right", Ne = I.fallbackAgentName || "Agent", Fe = N_(Te ?? L.chatBgColors), Ie = I.logo || I.logoUrl || null, Le = A || "en", Re = Se.recommendations?.[Le] || [], R = (F.recommendations?.[Le] ?? Re).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
15576
15548
|
id: e.key || `qr-${t}`,
|
|
15577
15549
|
label: e.label,
|
|
15578
15550
|
message: e.label,
|
|
15579
15551
|
text: e.label
|
|
15580
|
-
})),
|
|
15552
|
+
})), ze = Array.isArray(I.quickChatOptions) && I.quickChatOptions.length > 0 ? I.quickChatOptions : R, Be = I.hideWatermark === !0 ? !1 : I.showPoweredBy !== !1, Ve = I.headerBgColor || null, z = L.bottomPosition == null ? "1.5rem" : `${L.bottomPosition}px`, B = I.privacyPolicyUrl || null, He = I.chatbotEnabled !== !1 && L.chatbotEnabled !== !1, [Ue, V] = m(() => typeof window < "u" ? window.location.pathname : "/");
|
|
15581
15553
|
c(() => {
|
|
15582
15554
|
if (typeof window > "u") return;
|
|
15583
15555
|
let e = () => V(window.location.pathname), t = window.history.pushState.bind(window.history);
|
|
@@ -15589,24 +15561,24 @@ function K_() {
|
|
|
15589
15561
|
}, []);
|
|
15590
15562
|
let We = (() => {
|
|
15591
15563
|
let e = {
|
|
15592
|
-
...
|
|
15593
|
-
...
|
|
15564
|
+
...Se.pageVisibility || {},
|
|
15565
|
+
...F.pageVisibility || {}
|
|
15594
15566
|
};
|
|
15595
15567
|
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
15596
|
-
})(), Ge = We.length === 0 || We.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ue.startsWith(e.slice(0, -1)) : Ue.replace(/\/$/, "") === e.replace(/\/$/, "")), Ke =
|
|
15597
|
-
entryPrompt:
|
|
15598
|
-
yesLabel:
|
|
15599
|
-
laterLabel:
|
|
15600
|
-
connectionTitle:
|
|
15601
|
-
connectionSubtitle:
|
|
15602
|
-
voiceLabel:
|
|
15603
|
-
textLabel:
|
|
15604
|
-
chatTitle:
|
|
15605
|
-
hasCustomTitle: !!(
|
|
15568
|
+
})(), Ge = We.length === 0 || We.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ue.startsWith(e.slice(0, -1)) : Ue.replace(/\/$/, "") === e.replace(/\/$/, "")), Ke = Se.greetings?.[A] || F.greetings?.[A] || I.introGreeting || (t?.websiteName && String(t.websiteName).trim() ? `Hello, I'm here to help you know more about ${String(t.websiteName).trim()}.` : "Hello, I'm here to help — what would you like to know?"), qe = {
|
|
15569
|
+
entryPrompt: I.entryPrompt || "Do you want to explore in a new way?",
|
|
15570
|
+
yesLabel: I.yesLabel || "Yes",
|
|
15571
|
+
laterLabel: I.laterLabel || "Later",
|
|
15572
|
+
connectionTitle: I.connectionTitle || "How would you like to connect?",
|
|
15573
|
+
connectionSubtitle: I.connectionSubtitle || "",
|
|
15574
|
+
voiceLabel: I.voiceLabel || "Voice",
|
|
15575
|
+
textLabel: I.textLabel || "Text",
|
|
15576
|
+
chatTitle: I.headerName || "Chat with FlowEngage",
|
|
15577
|
+
hasCustomTitle: !!(I.headerName && String(I.headerName).trim()),
|
|
15606
15578
|
introGreeting: Ke,
|
|
15607
|
-
inputPlaceholder:
|
|
15608
|
-
analysingLabel:
|
|
15609
|
-
}, Je =
|
|
15579
|
+
inputPlaceholder: I.inputPlaceholder || "Type your message",
|
|
15580
|
+
analysingLabel: I.analysingLabel || "analysing..."
|
|
15581
|
+
}, Je = F.elevenLabsAgentId || t?.elevenLabsAgentId || null, Ye = t?.siteId || n?.siteId || null, Xe = t?.apiBaseUrl || "";
|
|
15610
15582
|
c(() => {
|
|
15611
15583
|
Qn(t?.siteType || null);
|
|
15612
15584
|
}, [t?.siteType]);
|
|
@@ -15617,10 +15589,10 @@ function K_() {
|
|
|
15617
15589
|
]), H = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, U = r.some((e) => e.sender === "user"), Qe = f(() => {
|
|
15618
15590
|
let e = r.findIndex((e) => e.sender === "user");
|
|
15619
15591
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
15620
|
-
}, [r]), $e = !!(
|
|
15592
|
+
}, [r]), $e = !!(F._dashboardLivePreview || Se._dashboardLivePreview), [W, et] = m(() => $e ? "text_chat" : "entry_prompt"), [tt, nt] = m(""), [rt, it] = m(null), [at, ot] = m(h || ""), [st, ct] = m(""), [G, lt] = m(!1), [ut, dt] = m(0), [ft, pt] = m(null), [mt, ht] = m(null), [gt, _t] = m(""), [vt, yt] = m(!1), [bt, xt] = m(!1), [St, Ct] = m(!1), wt = p(null), Tt = p(!1), Et = !h && U && Qe && W !== "voice_mode";
|
|
15621
15593
|
d(() => {
|
|
15622
15594
|
if (e !== "ready" || Tt.current) return;
|
|
15623
|
-
if (Tt.current = !0, !
|
|
15595
|
+
if (Tt.current = !0, !we) {
|
|
15624
15596
|
et("minimized_orb");
|
|
15625
15597
|
return;
|
|
15626
15598
|
}
|
|
@@ -15628,13 +15600,13 @@ function K_() {
|
|
|
15628
15600
|
try {
|
|
15629
15601
|
t = wr().shouldResumeVoice;
|
|
15630
15602
|
} catch {}
|
|
15631
|
-
let n =
|
|
15603
|
+
let n = je(), r = Ye ? De(Ye) : null, i = n || !!r?.transcript;
|
|
15632
15604
|
if (t) {
|
|
15633
|
-
|
|
15605
|
+
ae?.({ notifyChatInitiated: !0 }), M?.(!0), et("voice_mode");
|
|
15634
15606
|
return;
|
|
15635
15607
|
}
|
|
15636
|
-
if (
|
|
15637
|
-
|
|
15608
|
+
if (Pe()) {
|
|
15609
|
+
ae?.({ notifyChatInitiated: !1 }), et("text_chat");
|
|
15638
15610
|
return;
|
|
15639
15611
|
}
|
|
15640
15612
|
if (i) {
|
|
@@ -15642,13 +15614,13 @@ function K_() {
|
|
|
15642
15614
|
et("minimized_orb");
|
|
15643
15615
|
return;
|
|
15644
15616
|
}
|
|
15645
|
-
|
|
15617
|
+
ae?.({ notifyChatInitiated: !0 }), M?.(!0), et("voice_mode");
|
|
15646
15618
|
return;
|
|
15647
15619
|
}
|
|
15648
15620
|
if (Ye) try {
|
|
15649
|
-
|
|
15621
|
+
Oe(Ye);
|
|
15650
15622
|
} catch {}
|
|
15651
|
-
if (
|
|
15623
|
+
if (se(Ye)) {
|
|
15652
15624
|
et("minimized_orb");
|
|
15653
15625
|
return;
|
|
15654
15626
|
}
|
|
@@ -15706,7 +15678,7 @@ function K_() {
|
|
|
15706
15678
|
hasIncomingCall: !!w?.callId,
|
|
15707
15679
|
activeCallId: T,
|
|
15708
15680
|
callConnectionState: E
|
|
15709
|
-
}), wt.current = e, W === "voice_mode" &&
|
|
15681
|
+
}), wt.current = e, W === "voice_mode" && M?.(!1), ae?.(), jt());
|
|
15710
15682
|
}
|
|
15711
15683
|
}, [
|
|
15712
15684
|
T,
|
|
@@ -15714,8 +15686,8 @@ function K_() {
|
|
|
15714
15686
|
jt,
|
|
15715
15687
|
w?.callId,
|
|
15716
15688
|
i,
|
|
15717
|
-
|
|
15718
|
-
|
|
15689
|
+
ae,
|
|
15690
|
+
M,
|
|
15719
15691
|
W
|
|
15720
15692
|
]), c(() => {
|
|
15721
15693
|
!w && !T && W === "call_screen" && et("text_chat");
|
|
@@ -15727,16 +15699,16 @@ function K_() {
|
|
|
15727
15699
|
!T && bt && xt(!1);
|
|
15728
15700
|
}, [T, bt]), c(() => {
|
|
15729
15701
|
if (!s || C) {
|
|
15730
|
-
|
|
15702
|
+
ge?.(""), he?.();
|
|
15731
15703
|
return;
|
|
15732
15704
|
}
|
|
15733
15705
|
if (!tt.trim() || mt) {
|
|
15734
|
-
|
|
15735
|
-
let e = window.setTimeout(() =>
|
|
15706
|
+
ge?.("");
|
|
15707
|
+
let e = window.setTimeout(() => he?.(), 100);
|
|
15736
15708
|
return () => window.clearTimeout(e);
|
|
15737
15709
|
}
|
|
15738
|
-
|
|
15739
|
-
let e = window.setTimeout(() =>
|
|
15710
|
+
me?.();
|
|
15711
|
+
let e = window.setTimeout(() => ge?.(tt), 120), t = window.setTimeout(() => he?.(), 1200);
|
|
15740
15712
|
return () => {
|
|
15741
15713
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
15742
15714
|
};
|
|
@@ -15745,9 +15717,9 @@ function K_() {
|
|
|
15745
15717
|
mt,
|
|
15746
15718
|
s,
|
|
15747
15719
|
C,
|
|
15748
|
-
pe,
|
|
15749
15720
|
me,
|
|
15750
|
-
he
|
|
15721
|
+
he,
|
|
15722
|
+
ge
|
|
15751
15723
|
]);
|
|
15752
15724
|
let Nt = (e) => e ? {
|
|
15753
15725
|
replyTo: e.messageId || e.id || null,
|
|
@@ -15761,7 +15733,7 @@ function K_() {
|
|
|
15761
15733
|
ct("Please enter a valid email so we can continue helping you.");
|
|
15762
15734
|
return;
|
|
15763
15735
|
}
|
|
15764
|
-
await
|
|
15736
|
+
await oe(e), ct(""), lt(!0), setTimeout(() => lt(!1), 3e3);
|
|
15765
15737
|
return;
|
|
15766
15738
|
}
|
|
15767
15739
|
let t = Nt(rt);
|
|
@@ -15769,8 +15741,8 @@ function K_() {
|
|
|
15769
15741
|
if (mt) {
|
|
15770
15742
|
try {
|
|
15771
15743
|
yt(!0), _t("");
|
|
15772
|
-
let e = await
|
|
15773
|
-
nt(""), it(null), kt(), await
|
|
15744
|
+
let e = await ie(mt), n = e?.data || e, r = tt.trim() || `Shared file: ${Fg(mt)}`;
|
|
15745
|
+
nt(""), it(null), kt(), await re(r, "", t, {
|
|
15774
15746
|
type: "file",
|
|
15775
15747
|
metadata: {
|
|
15776
15748
|
fileUrl: n?.fileUrl,
|
|
@@ -15787,20 +15759,20 @@ function K_() {
|
|
|
15787
15759
|
return;
|
|
15788
15760
|
}
|
|
15789
15761
|
let n = tt.trim();
|
|
15790
|
-
nt(""), it(null), await
|
|
15762
|
+
nt(""), it(null), await re(n, "", t);
|
|
15791
15763
|
}, Ft = o(() => {
|
|
15792
|
-
r.length !== 0 &&
|
|
15793
|
-
}, [r.length,
|
|
15764
|
+
r.length !== 0 && P?.();
|
|
15765
|
+
}, [r.length, P]), It = (e) => {
|
|
15794
15766
|
let t = Math.floor(e / 60);
|
|
15795
15767
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
15796
15768
|
}, Lt = o(async (e) => {
|
|
15797
15769
|
if (C || b) return;
|
|
15798
15770
|
let t = e.message || e.label || e.text || "";
|
|
15799
|
-
t.trim() && await
|
|
15771
|
+
t.trim() && await re(t.trim(), "");
|
|
15800
15772
|
}, [
|
|
15801
15773
|
C,
|
|
15802
15774
|
b,
|
|
15803
|
-
|
|
15775
|
+
re
|
|
15804
15776
|
]), Rt = Dt && W === "entry_prompt" ? { inset: 0 } : Dt && W === "text_chat" ? {
|
|
15805
15777
|
left: 0,
|
|
15806
15778
|
right: 0,
|
|
@@ -15821,19 +15793,19 @@ function K_() {
|
|
|
15821
15793
|
height: "min(640px, calc(100vh - 120px))",
|
|
15822
15794
|
borderRadius: "22px",
|
|
15823
15795
|
overflow: "hidden",
|
|
15824
|
-
...
|
|
15796
|
+
...Me === "bottom-left" ? {
|
|
15825
15797
|
left: "1.5rem",
|
|
15826
|
-
bottom:
|
|
15798
|
+
bottom: z
|
|
15827
15799
|
} : {
|
|
15828
15800
|
right: "1.5rem",
|
|
15829
|
-
bottom:
|
|
15801
|
+
bottom: z
|
|
15830
15802
|
}
|
|
15831
|
-
} :
|
|
15803
|
+
} : Me === "bottom-left" ? {
|
|
15832
15804
|
left: "1.5rem",
|
|
15833
|
-
bottom:
|
|
15805
|
+
bottom: z
|
|
15834
15806
|
} : {
|
|
15835
15807
|
right: "1.5rem",
|
|
15836
|
-
bottom:
|
|
15808
|
+
bottom: z
|
|
15837
15809
|
}, zt = o(() => {
|
|
15838
15810
|
W !== "minimized_orb" && (Ct(!0), setTimeout(() => {
|
|
15839
15811
|
et("minimized_orb"), Ct(!1), T && xt(!0);
|
|
@@ -15846,13 +15818,13 @@ function K_() {
|
|
|
15846
15818
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
15847
15819
|
}
|
|
15848
15820
|
} catch {}
|
|
15849
|
-
|
|
15821
|
+
ae({ notifyChatInitiated: !0 }), M?.(!0), et("voice_mode");
|
|
15850
15822
|
}, Ht = () => {
|
|
15851
|
-
|
|
15823
|
+
ae({ notifyChatInitiated: !0 }), M?.(!1), et("text_chat");
|
|
15852
15824
|
}, Ut = () => {
|
|
15853
|
-
|
|
15825
|
+
M?.(!1), zt();
|
|
15854
15826
|
};
|
|
15855
|
-
return e !== "ready" || !He ||
|
|
15827
|
+
return e !== "ready" || !He || Ce.chat === !1 || !Ge ? null : /* @__PURE__ */ _("div", {
|
|
15856
15828
|
className: "flowengage-widget-root",
|
|
15857
15829
|
style: {
|
|
15858
15830
|
position: "fixed",
|
|
@@ -15864,13 +15836,13 @@ function K_() {
|
|
|
15864
15836
|
children: [
|
|
15865
15837
|
W === "entry_prompt" && /* @__PURE__ */ g(B_, {
|
|
15866
15838
|
copy: qe,
|
|
15867
|
-
orbColors:
|
|
15868
|
-
primaryColor:
|
|
15839
|
+
orbColors: Te,
|
|
15840
|
+
primaryColor: Ee,
|
|
15869
15841
|
onYes: () => {
|
|
15870
|
-
|
|
15842
|
+
N(Ye), Vt();
|
|
15871
15843
|
},
|
|
15872
15844
|
onLater: () => {
|
|
15873
|
-
|
|
15845
|
+
N(Ye), zt();
|
|
15874
15846
|
},
|
|
15875
15847
|
isMobile: Dt,
|
|
15876
15848
|
isClosing: St
|
|
@@ -15894,7 +15866,7 @@ function K_() {
|
|
|
15894
15866
|
transformOrigin: "bottom right",
|
|
15895
15867
|
display: "inline-flex",
|
|
15896
15868
|
flexDirection: "column",
|
|
15897
|
-
alignItems:
|
|
15869
|
+
alignItems: Me === "bottom-left" ? "flex-start" : "flex-end",
|
|
15898
15870
|
gap: "10px"
|
|
15899
15871
|
},
|
|
15900
15872
|
children: [T && /* @__PURE__ */ _("button", {
|
|
@@ -15946,15 +15918,15 @@ function K_() {
|
|
|
15946
15918
|
})]
|
|
15947
15919
|
})]
|
|
15948
15920
|
}), /* @__PURE__ */ g(z_, {
|
|
15949
|
-
size:
|
|
15950
|
-
orbColors:
|
|
15951
|
-
onClick: T ? jt :
|
|
15921
|
+
size: Ae,
|
|
15922
|
+
orbColors: Te,
|
|
15923
|
+
onClick: T ? jt : we ? Bt : Ht
|
|
15952
15924
|
})]
|
|
15953
15925
|
}),
|
|
15954
15926
|
W === "connection_modal" && /* @__PURE__ */ g(V_, {
|
|
15955
15927
|
copy: qe,
|
|
15956
|
-
orbColors:
|
|
15957
|
-
primaryColor:
|
|
15928
|
+
orbColors: Te,
|
|
15929
|
+
primaryColor: Ee,
|
|
15958
15930
|
onVoice: Vt,
|
|
15959
15931
|
onText: Ht,
|
|
15960
15932
|
onClose: zt,
|
|
@@ -15962,7 +15934,7 @@ function K_() {
|
|
|
15962
15934
|
isClosing: St
|
|
15963
15935
|
}),
|
|
15964
15936
|
W === "voice_mode" && /* @__PURE__ */ g(H_, {
|
|
15965
|
-
orbColors:
|
|
15937
|
+
orbColors: Te,
|
|
15966
15938
|
onEnterChat: Ht,
|
|
15967
15939
|
onEndChat: Ut,
|
|
15968
15940
|
agentId: Je,
|
|
@@ -15972,17 +15944,17 @@ function K_() {
|
|
|
15972
15944
|
historyRef: te,
|
|
15973
15945
|
onMessageSync: ne,
|
|
15974
15946
|
beaconSyncVoiceTranscript: j,
|
|
15975
|
-
widgetPosition:
|
|
15976
|
-
voiceEndCounter:
|
|
15947
|
+
widgetPosition: Me,
|
|
15948
|
+
voiceEndCounter: xe,
|
|
15977
15949
|
websiteName: t?.websiteName,
|
|
15978
|
-
voiceFirstMessage:
|
|
15979
|
-
captureVisitorEmail:
|
|
15950
|
+
voiceFirstMessage: Se.voiceFirstMessage || null,
|
|
15951
|
+
captureVisitorEmail: oe,
|
|
15980
15952
|
emailRequired: !h,
|
|
15981
|
-
emailCaptureEnabled:
|
|
15982
|
-
listeningLabel:
|
|
15983
|
-
thinkingLabel:
|
|
15984
|
-
enterChatModeLabel:
|
|
15985
|
-
endConversationLabel:
|
|
15953
|
+
emailCaptureEnabled: Ce.emailCapture !== !1 && I.disableEmailCapture !== !0,
|
|
15954
|
+
listeningLabel: I.voiceListeningLabel || "Listening...",
|
|
15955
|
+
thinkingLabel: I.voiceThinkingLabel || "Thinking...",
|
|
15956
|
+
enterChatModeLabel: I.voiceEnterChatLabel || "Enter Chat Mode",
|
|
15957
|
+
endConversationLabel: I.voiceEndConversationLabel || "End Conversation"
|
|
15986
15958
|
}, "voice"),
|
|
15987
15959
|
W === "call_screen" && /* @__PURE__ */ g(i_, {
|
|
15988
15960
|
incomingCall: w,
|
|
@@ -15992,25 +15964,25 @@ function K_() {
|
|
|
15992
15964
|
isCallMuted: O,
|
|
15993
15965
|
agentName: Ze,
|
|
15994
15966
|
agentHeadshot: H,
|
|
15995
|
-
fallbackAgentName:
|
|
15996
|
-
acceptCall:
|
|
15997
|
-
rejectCall:
|
|
15998
|
-
endWebRTCCall:
|
|
15999
|
-
toggleCallMute:
|
|
15967
|
+
fallbackAgentName: Ne,
|
|
15968
|
+
acceptCall: le,
|
|
15969
|
+
rejectCall: ue,
|
|
15970
|
+
endWebRTCCall: de,
|
|
15971
|
+
toggleCallMute: fe,
|
|
16000
15972
|
formatCallDuration: It,
|
|
16001
15973
|
onMinimize: Mt,
|
|
16002
|
-
primaryColor:
|
|
16003
|
-
orbColors:
|
|
15974
|
+
primaryColor: Ee,
|
|
15975
|
+
orbColors: Te,
|
|
16004
15976
|
chatHistory: r
|
|
16005
15977
|
}),
|
|
16006
15978
|
W === "text_chat" && /* @__PURE__ */ g(G_, {
|
|
16007
15979
|
isClosing: St,
|
|
16008
15980
|
copy: qe,
|
|
16009
|
-
orbColors:
|
|
16010
|
-
primaryColor:
|
|
16011
|
-
chatBgGradient:
|
|
16012
|
-
logo:
|
|
16013
|
-
quickChatOptions:
|
|
15981
|
+
orbColors: Te,
|
|
15982
|
+
primaryColor: Ee,
|
|
15983
|
+
chatBgGradient: Fe,
|
|
15984
|
+
logo: Ie,
|
|
15985
|
+
quickChatOptions: ze,
|
|
16014
15986
|
onQuickChatSelect: Lt,
|
|
16015
15987
|
isMobile: Dt,
|
|
16016
15988
|
chatHistory: r,
|
|
@@ -16019,7 +15991,7 @@ function K_() {
|
|
|
16019
15991
|
activeScreen: a,
|
|
16020
15992
|
agentName: Ze,
|
|
16021
15993
|
agentHeadshot: H,
|
|
16022
|
-
fallbackAgentName:
|
|
15994
|
+
fallbackAgentName: Ne,
|
|
16023
15995
|
input: tt,
|
|
16024
15996
|
setInput: nt,
|
|
16025
15997
|
onSubmit: Pt,
|
|
@@ -16042,26 +16014,26 @@ function K_() {
|
|
|
16042
16014
|
webRTCError: k,
|
|
16043
16015
|
micError: ft,
|
|
16044
16016
|
setMicError: pt,
|
|
16045
|
-
dismissCallError:
|
|
16017
|
+
dismissCallError: pe,
|
|
16046
16018
|
activeCallId: T,
|
|
16047
16019
|
isCallMuted: O,
|
|
16048
|
-
toggleCallMute:
|
|
16049
|
-
endWebRTCCall:
|
|
16020
|
+
toggleCallMute: fe,
|
|
16021
|
+
endWebRTCCall: de,
|
|
16050
16022
|
formatCallDuration: It,
|
|
16051
16023
|
callDurationSeconds: ut,
|
|
16052
16024
|
onCollapse: zt,
|
|
16053
16025
|
onStartVoice: Vt,
|
|
16054
|
-
voiceEnabled:
|
|
16026
|
+
voiceEnabled: we,
|
|
16055
16027
|
onNewChat: Ft,
|
|
16056
16028
|
onMinimize: Mt,
|
|
16057
16029
|
onExpand: jt,
|
|
16058
16030
|
isCallMinimized: !!T,
|
|
16059
|
-
showPoweredBy:
|
|
16031
|
+
showPoweredBy: Be,
|
|
16060
16032
|
privacyPolicyUrl: B,
|
|
16061
|
-
headerBgColor:
|
|
16062
|
-
getVisitorChatHistory:
|
|
16063
|
-
resumeChat:
|
|
16064
|
-
isSessionRestoring:
|
|
16033
|
+
headerBgColor: Ve,
|
|
16034
|
+
getVisitorChatHistory: _e,
|
|
16035
|
+
resumeChat: ve,
|
|
16036
|
+
isSessionRestoring: ye
|
|
16065
16037
|
}),
|
|
16066
16038
|
/* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-slide-down { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(24px)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
|
|
16067
16039
|
]
|