@flowengage/react-chatbot 8.0.82 → 8.0.84
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.
|
@@ -42,38 +42,38 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
42
42
|
if (A) try {
|
|
43
43
|
window.localStorage.removeItem(k.chatId);
|
|
44
44
|
} catch {}
|
|
45
|
-
},
|
|
45
|
+
}, se = () => A ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", j = (e) => e ? `flowengage.entrySeen.${e}` : null, ce = (e) => {
|
|
46
46
|
if (!A || !e) return !1;
|
|
47
47
|
try {
|
|
48
|
-
let t =
|
|
48
|
+
let t = j(e);
|
|
49
49
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
50
50
|
} catch {
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
|
-
},
|
|
53
|
+
}, le = (e) => {
|
|
54
54
|
if (!(!A || !e)) try {
|
|
55
|
-
let t =
|
|
55
|
+
let t = j(e);
|
|
56
56
|
t && window.localStorage.setItem(t, "1");
|
|
57
57
|
} catch {}
|
|
58
|
-
},
|
|
58
|
+
}, ue = (e) => e ? `flowengage.persistedChatId.${e}` : null, de = (e) => {
|
|
59
59
|
if (!A || !e) return null;
|
|
60
60
|
try {
|
|
61
|
-
let t =
|
|
61
|
+
let t = ue(e), n = t ? window.localStorage.getItem(t) : null;
|
|
62
62
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
63
63
|
} catch {
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, fe = (e) => {
|
|
67
67
|
if (!(!A || !e)) try {
|
|
68
|
-
let t =
|
|
68
|
+
let t = ue(e);
|
|
69
69
|
t && window.localStorage.removeItem(t);
|
|
70
70
|
} catch {}
|
|
71
|
-
},
|
|
71
|
+
}, pe = (e, t) => {
|
|
72
72
|
if (!(!A || !e || !t)) try {
|
|
73
|
-
let n =
|
|
73
|
+
let n = ue(e);
|
|
74
74
|
n && window.localStorage.setItem(n, String(t).trim());
|
|
75
75
|
} catch {}
|
|
76
|
-
},
|
|
76
|
+
}, me = () => A ? {
|
|
77
77
|
isOpen: !1,
|
|
78
78
|
activeScreen: window.sessionStorage.getItem(k.activeScreen) || "ai",
|
|
79
79
|
isHumanHandled: window.sessionStorage.getItem(k.isHumanHandled) === "true",
|
|
@@ -87,7 +87,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
87
87
|
agentName: null,
|
|
88
88
|
agentHeadshot: null,
|
|
89
89
|
visitorEmail: ""
|
|
90
|
-
},
|
|
90
|
+
}, he = (e) => {
|
|
91
91
|
A && Object.entries(e).forEach(([e, t]) => {
|
|
92
92
|
let n = k[e];
|
|
93
93
|
if (n) {
|
|
@@ -98,7 +98,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
98
98
|
window.sessionStorage.setItem(n, String(t));
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
},
|
|
101
|
+
}, ge = (e) => {
|
|
102
102
|
if (!A || !e) return "";
|
|
103
103
|
let t = ie(e), n = window.localStorage.getItem(t);
|
|
104
104
|
if (!n) {
|
|
@@ -106,7 +106,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
106
106
|
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(k.visitorEmail), n = e);
|
|
107
107
|
}
|
|
108
108
|
return n || "";
|
|
109
|
-
},
|
|
109
|
+
}, _e = (e, t) => {
|
|
110
110
|
if (!A) return;
|
|
111
111
|
let n = ie(t);
|
|
112
112
|
if (!n) return;
|
|
@@ -116,91 +116,91 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(k.visitorEmail);
|
|
119
|
-
},
|
|
119
|
+
}, ve = (e) => e ? `flowengage.visitorId.${e}` : null, M = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, ye = (e) => {
|
|
120
120
|
if (!A || !e) return null;
|
|
121
121
|
try {
|
|
122
|
-
let t =
|
|
122
|
+
let t = ve(e), n = t ? window.localStorage.getItem(t) : null;
|
|
123
123
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
124
124
|
} catch {
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
-
},
|
|
127
|
+
}, be = (e) => {
|
|
128
128
|
if (!A || !e) return null;
|
|
129
129
|
try {
|
|
130
|
-
let t =
|
|
130
|
+
let t = ye(e);
|
|
131
131
|
if (t) return t;
|
|
132
|
-
let n =
|
|
132
|
+
let n = M(), r = ve(e);
|
|
133
133
|
return r && window.localStorage.setItem(r, n), n;
|
|
134
134
|
} catch {
|
|
135
|
-
return
|
|
135
|
+
return M();
|
|
136
136
|
}
|
|
137
|
-
},
|
|
137
|
+
}, xe = "flowengage.tabId", Se = () => {
|
|
138
138
|
if (!A) return "default";
|
|
139
139
|
try {
|
|
140
|
-
let e = window.sessionStorage.getItem(
|
|
141
|
-
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(
|
|
140
|
+
let e = window.sessionStorage.getItem(xe);
|
|
141
|
+
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(xe, e)), e;
|
|
142
142
|
} catch {
|
|
143
143
|
return "default";
|
|
144
144
|
}
|
|
145
|
-
},
|
|
145
|
+
}, Ce = (e) => e ? `flowengage.voice.transcript.${e}.${Se()}` : null, we = 600 * 1e3, N = (e, t, n = {}) => {
|
|
146
146
|
if (!A || !e) return;
|
|
147
147
|
let r = typeof t == "string" ? t.trim() : "";
|
|
148
148
|
if (!r) return;
|
|
149
|
-
let i = Number.isFinite(n.ttlMs) ? n.ttlMs :
|
|
149
|
+
let i = Number.isFinite(n.ttlMs) ? n.ttlMs : we, a = {
|
|
150
150
|
transcript: r,
|
|
151
151
|
expiresAt: Date.now() + i
|
|
152
152
|
};
|
|
153
153
|
try {
|
|
154
|
-
let t =
|
|
154
|
+
let t = Ce(e);
|
|
155
155
|
t && window.localStorage.setItem(t, JSON.stringify(a));
|
|
156
156
|
} catch {}
|
|
157
|
-
},
|
|
157
|
+
}, Te = (e) => {
|
|
158
158
|
if (!A || !e) return null;
|
|
159
159
|
try {
|
|
160
|
-
let t =
|
|
160
|
+
let t = Ce(e), n = t ? window.localStorage.getItem(t) : null;
|
|
161
161
|
if (!n) return null;
|
|
162
162
|
let r = JSON.parse(n);
|
|
163
163
|
return !r || typeof r.transcript != "string" ? null : Number.isFinite(r.expiresAt) && Date.now() > r.expiresAt ? (window.localStorage.removeItem(t), null) : r;
|
|
164
164
|
} catch {
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
167
|
-
},
|
|
167
|
+
}, Ee = (e) => {
|
|
168
168
|
if (!(!A || !e)) try {
|
|
169
|
-
let t =
|
|
169
|
+
let t = Ce(e);
|
|
170
170
|
t && window.localStorage.removeItem(t);
|
|
171
171
|
} catch {}
|
|
172
|
-
},
|
|
172
|
+
}, P = "flowengage.voice.pendingResume", De = () => {
|
|
173
173
|
if (A) try {
|
|
174
|
-
window.sessionStorage.setItem(
|
|
174
|
+
window.sessionStorage.setItem(P, "1");
|
|
175
175
|
} catch {}
|
|
176
|
-
},
|
|
176
|
+
}, Oe = () => {
|
|
177
177
|
if (!A) return !1;
|
|
178
178
|
try {
|
|
179
|
-
return window.sessionStorage.getItem(
|
|
179
|
+
return window.sessionStorage.getItem(P) === "1" ? (window.sessionStorage.removeItem(P), !0) : !1;
|
|
180
180
|
} catch {
|
|
181
181
|
return !1;
|
|
182
182
|
}
|
|
183
|
-
},
|
|
183
|
+
}, ke = "flowengage.chat.pendingReopen", F = () => {
|
|
184
184
|
if (A) try {
|
|
185
|
-
window.sessionStorage.setItem(
|
|
185
|
+
window.sessionStorage.setItem(ke, "1");
|
|
186
186
|
} catch {}
|
|
187
|
-
},
|
|
187
|
+
}, Ae = () => {
|
|
188
188
|
if (!A) return !1;
|
|
189
189
|
try {
|
|
190
|
-
return window.sessionStorage.getItem(
|
|
190
|
+
return window.sessionStorage.getItem(ke) === "1" ? (window.sessionStorage.removeItem(ke), !0) : !1;
|
|
191
191
|
} catch {
|
|
192
192
|
return !1;
|
|
193
193
|
}
|
|
194
|
-
},
|
|
194
|
+
}, je = () => {
|
|
195
195
|
if (!A) return !1;
|
|
196
196
|
try {
|
|
197
|
-
return window.sessionStorage.getItem(
|
|
197
|
+
return window.sessionStorage.getItem(P) === "1";
|
|
198
198
|
} catch {
|
|
199
199
|
return !1;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
201
|
+
}, Me = (e) => e ? `flowengage.voice.navState.${e}.${Se()}` : null, I = (e, t, n, r) => {
|
|
202
202
|
if (!(!A || !e || !t)) try {
|
|
203
|
-
let i =
|
|
203
|
+
let i = Me(e);
|
|
204
204
|
i && window.sessionStorage.setItem(i, JSON.stringify({
|
|
205
205
|
previousPage: String(t),
|
|
206
206
|
targetPath: n ? new URL(String(n), window.location.href).pathname : null,
|
|
@@ -208,10 +208,10 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
208
208
|
ts: Date.now()
|
|
209
209
|
}));
|
|
210
210
|
} catch {}
|
|
211
|
-
},
|
|
211
|
+
}, Ne = (e) => {
|
|
212
212
|
if (!A || !e) return null;
|
|
213
213
|
try {
|
|
214
|
-
let t =
|
|
214
|
+
let t = Me(e);
|
|
215
215
|
if (!t) return null;
|
|
216
216
|
let n = window.sessionStorage.getItem(t);
|
|
217
217
|
if (!n) return null;
|
|
@@ -224,14 +224,14 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
224
224
|
} catch {
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
|
-
},
|
|
227
|
+
}, L = async (e) => {
|
|
228
228
|
let t = await e.json().catch(() => ({}));
|
|
229
229
|
if (!e.ok) {
|
|
230
230
|
let n = Error(t.message || t.error || `Request failed with status ${e.status}`);
|
|
231
231
|
throw n.status = e.status, n;
|
|
232
232
|
}
|
|
233
233
|
return t;
|
|
234
|
-
},
|
|
234
|
+
}, Pe = async (e, t = {}) => {
|
|
235
235
|
try {
|
|
236
236
|
return await fetch(e, {
|
|
237
237
|
mode: "cors",
|
|
@@ -241,9 +241,9 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
241
241
|
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}`);
|
|
242
242
|
throw n.status = 0, n.cause = t, n;
|
|
243
243
|
}
|
|
244
|
-
},
|
|
244
|
+
}, Fe = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
|
|
245
245
|
let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
|
|
246
|
-
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o),
|
|
246
|
+
return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), L(await Pe(s, {
|
|
247
247
|
method: "POST",
|
|
248
248
|
mode: "cors",
|
|
249
249
|
headers: {
|
|
@@ -254,13 +254,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
254
254
|
},
|
|
255
255
|
body: JSON.stringify(c)
|
|
256
256
|
}));
|
|
257
|
-
},
|
|
257
|
+
}, Ie = async ({ apiBaseUrl: e, siteId: t }) => {
|
|
258
258
|
let n = typeof window < "u" ? window.location.origin : "http://localhost";
|
|
259
|
-
return (await
|
|
259
|
+
return (await L(await Pe(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
|
|
260
260
|
siteId: t,
|
|
261
261
|
origin: n
|
|
262
262
|
}).toString()}`, { method: "GET" }))).data;
|
|
263
|
-
},
|
|
263
|
+
}, Le = ({ apiBaseUrl: e, userId: t, siteId: n, visitorId: r = null }) => {
|
|
264
264
|
let i = (t, n) => {
|
|
265
265
|
let r = `${e}${t}`, i = JSON.stringify(n);
|
|
266
266
|
if (typeof navigator < "u" && navigator.sendBeacon) try {
|
|
@@ -274,7 +274,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
274
274
|
headers: { "Content-Type": "application/json" },
|
|
275
275
|
body: i
|
|
276
276
|
}).catch(() => {}), !0) : !1;
|
|
277
|
-
}, a = async (i, a = {}) =>
|
|
277
|
+
}, a = async (i, a = {}) => L(await Pe(`${e}${i}`, {
|
|
278
278
|
...a,
|
|
279
279
|
headers: {
|
|
280
280
|
"Content-Type": "application/json",
|
|
@@ -289,7 +289,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
289
289
|
...n ? { "x-site-id": n } : {},
|
|
290
290
|
...a.headers || {}
|
|
291
291
|
};
|
|
292
|
-
return
|
|
292
|
+
return L(await Pe(`${e}${r}`, {
|
|
293
293
|
...a,
|
|
294
294
|
body: i,
|
|
295
295
|
headers: o
|
|
@@ -415,7 +415,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
415
415
|
});
|
|
416
416
|
},
|
|
417
417
|
async getIceServersConfig() {
|
|
418
|
-
return
|
|
418
|
+
return L(await Pe(`${e}/api/calls/ice-config`, {
|
|
419
419
|
method: "GET",
|
|
420
420
|
headers: {
|
|
421
421
|
"x-user-id": t,
|
|
@@ -470,82 +470,82 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
470
470
|
return i.append("chatId", r), i.append("type", "widget_closed"), t && i.append("userId", String(t)), n && i.append("siteId", String(n)), navigator.sendBeacon(`${e}/api/chat/status`, i);
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
|
-
},
|
|
474
|
-
|
|
475
|
-
var
|
|
476
|
-
Object.keys(
|
|
477
|
-
|
|
473
|
+
}, R = Object.create(null);
|
|
474
|
+
R.open = "0", R.close = "1", R.ping = "2", R.pong = "3", R.message = "4", R.upgrade = "5", R.noop = "6";
|
|
475
|
+
var Re = Object.create(null);
|
|
476
|
+
Object.keys(R).forEach((e) => {
|
|
477
|
+
Re[R[e]] = e;
|
|
478
478
|
});
|
|
479
|
-
var
|
|
479
|
+
var ze = {
|
|
480
480
|
type: "error",
|
|
481
481
|
data: "parser error"
|
|
482
|
-
},
|
|
482
|
+
}, Be = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Ve = typeof ArrayBuffer == "function", He = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, Ue = ({ type: e, data: t }, n, r) => Be && t instanceof Blob ? n ? r(t) : We(t, r) : Ve && (t instanceof ArrayBuffer || He(t)) ? n ? r(t) : We(new Blob([t]), r) : r(R[e] + (t || "")), We = (e, t) => {
|
|
483
483
|
let n = new FileReader();
|
|
484
484
|
return n.onload = function() {
|
|
485
485
|
let e = n.result.split(",")[1];
|
|
486
486
|
t("b" + (e || ""));
|
|
487
487
|
}, n.readAsDataURL(e);
|
|
488
488
|
};
|
|
489
|
-
function
|
|
489
|
+
function Ge(e) {
|
|
490
490
|
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
491
491
|
}
|
|
492
|
-
var
|
|
493
|
-
function
|
|
494
|
-
if (
|
|
495
|
-
if (
|
|
496
|
-
|
|
497
|
-
|
|
492
|
+
var Ke;
|
|
493
|
+
function qe(e, t) {
|
|
494
|
+
if (Be && e.data instanceof Blob) return e.data.arrayBuffer().then(Ge).then(t);
|
|
495
|
+
if (Ve && (e.data instanceof ArrayBuffer || He(e.data))) return t(Ge(e.data));
|
|
496
|
+
Ue(e, !1, (e) => {
|
|
497
|
+
Ke ||= new TextEncoder(), t(Ke.encode(e));
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
//#endregion
|
|
501
501
|
//#region node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
|
|
502
|
-
var
|
|
503
|
-
for (let e = 0; e < 64; e++) Je
|
|
504
|
-
var
|
|
502
|
+
var Je = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ye = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
503
|
+
for (let e = 0; e < 64; e++) Ye[Je.charCodeAt(e)] = e;
|
|
504
|
+
var Xe = (e) => {
|
|
505
505
|
let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
|
|
506
506
|
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
507
507
|
let l = new ArrayBuffer(t), u = new Uint8Array(l);
|
|
508
|
-
for (r = 0; r < n; r += 4) a =
|
|
508
|
+
for (r = 0; r < n; r += 4) a = Ye[e.charCodeAt(r)], o = Ye[e.charCodeAt(r + 1)], s = Ye[e.charCodeAt(r + 2)], c = Ye[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
|
|
509
509
|
return l;
|
|
510
|
-
},
|
|
510
|
+
}, z = typeof ArrayBuffer == "function", B = (e, t) => {
|
|
511
511
|
if (typeof e != "string") return {
|
|
512
512
|
type: "message",
|
|
513
|
-
data:
|
|
513
|
+
data: Qe(e, t)
|
|
514
514
|
};
|
|
515
515
|
let n = e.charAt(0);
|
|
516
516
|
return n === "b" ? {
|
|
517
517
|
type: "message",
|
|
518
|
-
data:
|
|
519
|
-
} :
|
|
520
|
-
type:
|
|
518
|
+
data: Ze(e.substring(1), t)
|
|
519
|
+
} : Re[n] ? e.length > 1 ? {
|
|
520
|
+
type: Re[n],
|
|
521
521
|
data: e.substring(1)
|
|
522
|
-
} : { type:
|
|
523
|
-
},
|
|
522
|
+
} : { type: Re[n] } : ze;
|
|
523
|
+
}, Ze = (e, t) => z ? Qe(Xe(e), t) : {
|
|
524
524
|
base64: !0,
|
|
525
525
|
data: e
|
|
526
|
-
},
|
|
526
|
+
}, Qe = (e, t) => {
|
|
527
527
|
switch (t) {
|
|
528
528
|
case "blob": return e instanceof Blob ? e : new Blob([e]);
|
|
529
529
|
default: return e instanceof ArrayBuffer ? e : e.buffer;
|
|
530
530
|
}
|
|
531
|
-
},
|
|
531
|
+
}, $e = "", et = (e, t) => {
|
|
532
532
|
let n = e.length, r = Array(n), i = 0;
|
|
533
533
|
e.forEach((e, a) => {
|
|
534
|
-
|
|
535
|
-
r[a] = e, ++i === n && t(r.join(
|
|
534
|
+
Ue(e, !1, (e) => {
|
|
535
|
+
r[a] = e, ++i === n && t(r.join($e));
|
|
536
536
|
});
|
|
537
537
|
});
|
|
538
|
-
},
|
|
539
|
-
let n = e.split(
|
|
538
|
+
}, tt = (e, t) => {
|
|
539
|
+
let n = e.split($e), r = [];
|
|
540
540
|
for (let e = 0; e < n.length; e++) {
|
|
541
|
-
let i =
|
|
541
|
+
let i = B(n[e], t);
|
|
542
542
|
if (r.push(i), i.type === "error") break;
|
|
543
543
|
}
|
|
544
544
|
return r;
|
|
545
545
|
};
|
|
546
|
-
function
|
|
546
|
+
function V() {
|
|
547
547
|
return new TransformStream({ transform(e, t) {
|
|
548
|
-
|
|
548
|
+
qe(e, (n) => {
|
|
549
549
|
let r = n.length, i;
|
|
550
550
|
if (r < 126) i = new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
|
|
551
551
|
else if (r < 65536) {
|
|
@@ -561,44 +561,44 @@ function H() {
|
|
|
561
561
|
});
|
|
562
562
|
} });
|
|
563
563
|
}
|
|
564
|
-
var
|
|
565
|
-
function
|
|
564
|
+
var H;
|
|
565
|
+
function nt(e) {
|
|
566
566
|
return e.reduce((e, t) => e + t.length, 0);
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function rt(e, t) {
|
|
569
569
|
if (e[0].length === t) return e.shift();
|
|
570
570
|
let n = new Uint8Array(t), r = 0;
|
|
571
571
|
for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
|
|
572
572
|
return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
|
|
573
573
|
}
|
|
574
|
-
function
|
|
575
|
-
|
|
574
|
+
function it(e, t) {
|
|
575
|
+
H ||= new TextDecoder();
|
|
576
576
|
let n = [], r = 0, i = -1, a = !1;
|
|
577
577
|
return new TransformStream({ transform(o, s) {
|
|
578
578
|
for (n.push(o);;) {
|
|
579
579
|
if (r === 0) {
|
|
580
|
-
if (
|
|
581
|
-
let e =
|
|
580
|
+
if (nt(n) < 1) break;
|
|
581
|
+
let e = rt(n, 1);
|
|
582
582
|
a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
|
|
583
583
|
} else if (r === 1) {
|
|
584
|
-
if (
|
|
585
|
-
let e =
|
|
584
|
+
if (nt(n) < 2) break;
|
|
585
|
+
let e = rt(n, 2);
|
|
586
586
|
i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
|
|
587
587
|
} else if (r === 2) {
|
|
588
|
-
if (
|
|
589
|
-
let e =
|
|
588
|
+
if (nt(n) < 8) break;
|
|
589
|
+
let e = rt(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
|
|
590
590
|
if (a > 2 ** 21 - 1) {
|
|
591
|
-
s.enqueue(
|
|
591
|
+
s.enqueue(ze);
|
|
592
592
|
break;
|
|
593
593
|
}
|
|
594
594
|
i = a * 2 ** 32 + t.getUint32(4), r = 3;
|
|
595
595
|
} else {
|
|
596
|
-
if (
|
|
597
|
-
let e =
|
|
598
|
-
s.enqueue(
|
|
596
|
+
if (nt(n) < i) break;
|
|
597
|
+
let e = rt(n, i);
|
|
598
|
+
s.enqueue(B(a ? e : H.decode(e), t)), r = 0;
|
|
599
599
|
}
|
|
600
600
|
if (i === 0 || i > e) {
|
|
601
|
-
s.enqueue(
|
|
601
|
+
s.enqueue(ze);
|
|
602
602
|
break;
|
|
603
603
|
}
|
|
604
604
|
}
|
|
@@ -606,21 +606,21 @@ function rt(e, t) {
|
|
|
606
606
|
}
|
|
607
607
|
//#endregion
|
|
608
608
|
//#region node_modules/@socket.io/component-emitter/lib/esm/index.js
|
|
609
|
-
function
|
|
610
|
-
if (e) return
|
|
609
|
+
function U(e) {
|
|
610
|
+
if (e) return at(e);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
for (var t in
|
|
612
|
+
function at(e) {
|
|
613
|
+
for (var t in U.prototype) e[t] = U.prototype[t];
|
|
614
614
|
return e;
|
|
615
615
|
}
|
|
616
|
-
|
|
616
|
+
U.prototype.on = U.prototype.addEventListener = function(e, t) {
|
|
617
617
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
|
|
618
|
-
},
|
|
618
|
+
}, U.prototype.once = function(e, t) {
|
|
619
619
|
function n() {
|
|
620
620
|
this.off(e, n), t.apply(this, arguments);
|
|
621
621
|
}
|
|
622
622
|
return n.fn = t, this.on(e, n), this;
|
|
623
|
-
},
|
|
623
|
+
}, U.prototype.off = U.prototype.removeListener = U.prototype.removeAllListeners = U.prototype.removeEventListener = function(e, t) {
|
|
624
624
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
|
|
625
625
|
var n = this._callbacks["$" + e];
|
|
626
626
|
if (!n) return this;
|
|
@@ -630,7 +630,7 @@ W.prototype.on = W.prototype.addEventListener = function(e, t) {
|
|
|
630
630
|
break;
|
|
631
631
|
}
|
|
632
632
|
return n.length === 0 && delete this._callbacks["$" + e], this;
|
|
633
|
-
},
|
|
633
|
+
}, U.prototype.emit = function(e) {
|
|
634
634
|
this._callbacks = this._callbacks || {};
|
|
635
635
|
for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
|
|
636
636
|
if (n) {
|
|
@@ -638,43 +638,43 @@ W.prototype.on = W.prototype.addEventListener = function(e, t) {
|
|
|
638
638
|
for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
|
|
639
639
|
}
|
|
640
640
|
return this;
|
|
641
|
-
},
|
|
641
|
+
}, U.prototype.emitReserved = U.prototype.emit, U.prototype.listeners = function(e) {
|
|
642
642
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
|
|
643
|
-
},
|
|
643
|
+
}, U.prototype.hasListeners = function(e) {
|
|
644
644
|
return !!this.listeners(e).length;
|
|
645
645
|
};
|
|
646
646
|
//#endregion
|
|
647
647
|
//#region node_modules/engine.io-client/build/esm/globals.js
|
|
648
|
-
var
|
|
648
|
+
var ot = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), W = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), st = "arraybuffer";
|
|
649
649
|
//#endregion
|
|
650
650
|
//#region node_modules/engine.io-client/build/esm/util.js
|
|
651
|
-
function
|
|
651
|
+
function ct(e, ...t) {
|
|
652
652
|
return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
|
|
653
653
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
656
|
-
t.useNativeTimers ? (e.setTimeoutFn =
|
|
657
|
-
}
|
|
658
|
-
var dt = 1.33;
|
|
659
|
-
function ft(e) {
|
|
660
|
-
return typeof e == "string" ? pt(e) : Math.ceil((e.byteLength || e.size) * dt);
|
|
654
|
+
var lt = W.setTimeout, ut = W.clearTimeout;
|
|
655
|
+
function dt(e, t) {
|
|
656
|
+
t.useNativeTimers ? (e.setTimeoutFn = lt.bind(W), e.clearTimeoutFn = ut.bind(W)) : (e.setTimeoutFn = W.setTimeout.bind(W), e.clearTimeoutFn = W.clearTimeout.bind(W));
|
|
661
657
|
}
|
|
658
|
+
var ft = 1.33;
|
|
662
659
|
function pt(e) {
|
|
660
|
+
return typeof e == "string" ? mt(e) : Math.ceil((e.byteLength || e.size) * ft);
|
|
661
|
+
}
|
|
662
|
+
function mt(e) {
|
|
663
663
|
let t = 0, n = 0;
|
|
664
664
|
for (let r = 0, i = e.length; r < i; r++) t = e.charCodeAt(r), t < 128 ? n += 1 : t < 2048 ? n += 2 : t < 55296 || t >= 57344 ? n += 3 : (r++, n += 4);
|
|
665
665
|
return n;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function ht() {
|
|
668
668
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
669
669
|
}
|
|
670
670
|
//#endregion
|
|
671
671
|
//#region node_modules/engine.io-client/build/esm/contrib/parseqs.js
|
|
672
|
-
function
|
|
672
|
+
function gt(e) {
|
|
673
673
|
let t = "";
|
|
674
674
|
for (let n in e) e.hasOwnProperty(n) && (t.length && (t += "&"), t += encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
|
|
675
675
|
return t;
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function _t(e) {
|
|
678
678
|
let t = {}, n = e.split("&");
|
|
679
679
|
for (let e = 0, r = n.length; e < r; e++) {
|
|
680
680
|
let r = n[e].split("=");
|
|
@@ -684,16 +684,16 @@ function gt(e) {
|
|
|
684
684
|
}
|
|
685
685
|
//#endregion
|
|
686
686
|
//#region node_modules/engine.io-client/build/esm/transport.js
|
|
687
|
-
var
|
|
687
|
+
var vt = class extends Error {
|
|
688
688
|
constructor(e, t, n) {
|
|
689
689
|
super(e), this.description = t, this.context = n, this.type = "TransportError";
|
|
690
690
|
}
|
|
691
|
-
},
|
|
691
|
+
}, yt = class extends U {
|
|
692
692
|
constructor(e) {
|
|
693
|
-
super(), this.writable = !1,
|
|
693
|
+
super(), this.writable = !1, dt(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
694
694
|
}
|
|
695
695
|
onError(e, t, n) {
|
|
696
|
-
return super.emitReserved("error", new
|
|
696
|
+
return super.emitReserved("error", new vt(e, t, n)), this;
|
|
697
697
|
}
|
|
698
698
|
open() {
|
|
699
699
|
return this.readyState = "opening", this.doOpen(), this;
|
|
@@ -708,7 +708,7 @@ var _t = class extends Error {
|
|
|
708
708
|
this.readyState = "open", this.writable = !0, super.emitReserved("open");
|
|
709
709
|
}
|
|
710
710
|
onData(e) {
|
|
711
|
-
let t =
|
|
711
|
+
let t = B(e, this.socket.binaryType);
|
|
712
712
|
this.onPacket(t);
|
|
713
713
|
}
|
|
714
714
|
onPacket(e) {
|
|
@@ -729,10 +729,10 @@ var _t = class extends Error {
|
|
|
729
729
|
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
730
730
|
}
|
|
731
731
|
_query(e) {
|
|
732
|
-
let t =
|
|
732
|
+
let t = gt(e);
|
|
733
733
|
return t.length ? "?" + t : "";
|
|
734
734
|
}
|
|
735
|
-
},
|
|
735
|
+
}, bt = class extends yt {
|
|
736
736
|
constructor() {
|
|
737
737
|
super(...arguments), this._polling = !1;
|
|
738
738
|
}
|
|
@@ -760,7 +760,7 @@ var _t = class extends Error {
|
|
|
760
760
|
this._polling = !0, this.doPoll(), this.emitReserved("poll");
|
|
761
761
|
}
|
|
762
762
|
onData(e) {
|
|
763
|
-
|
|
763
|
+
tt(e, this.socket.binaryType).forEach((e) => {
|
|
764
764
|
if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
|
|
765
765
|
this.onPacket(e);
|
|
766
766
|
}), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
@@ -772,7 +772,7 @@ var _t = class extends Error {
|
|
|
772
772
|
this.readyState === "open" ? e() : this.once("open", e);
|
|
773
773
|
}
|
|
774
774
|
write(e) {
|
|
775
|
-
this.writable = !1,
|
|
775
|
+
this.writable = !1, et(e, (e) => {
|
|
776
776
|
this.doWrite(e, () => {
|
|
777
777
|
this.writable = !0, this.emitReserved("drain");
|
|
778
778
|
});
|
|
@@ -780,17 +780,17 @@ var _t = class extends Error {
|
|
|
780
780
|
}
|
|
781
781
|
uri() {
|
|
782
782
|
let e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
783
|
-
return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
783
|
+
return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = ht()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
784
784
|
}
|
|
785
|
-
},
|
|
785
|
+
}, xt = !1;
|
|
786
786
|
try {
|
|
787
|
-
|
|
787
|
+
xt = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
788
788
|
} catch {}
|
|
789
|
-
var
|
|
789
|
+
var St = xt;
|
|
790
790
|
//#endregion
|
|
791
791
|
//#region node_modules/engine.io-client/build/esm/transports/polling-xhr.js
|
|
792
|
-
function
|
|
793
|
-
var
|
|
792
|
+
function Ct() {}
|
|
793
|
+
var wt = class extends bt {
|
|
794
794
|
constructor(e) {
|
|
795
795
|
if (super(e), typeof location < "u") {
|
|
796
796
|
let t = location.protocol === "https:", n = location.port;
|
|
@@ -812,13 +812,13 @@ var Ct = class extends yt {
|
|
|
812
812
|
this.onError("xhr poll error", e, t);
|
|
813
813
|
}), this.pollXhr = e;
|
|
814
814
|
}
|
|
815
|
-
},
|
|
815
|
+
}, Tt = class e extends U {
|
|
816
816
|
constructor(e, t, n) {
|
|
817
|
-
super(), this.createRequest = e,
|
|
817
|
+
super(), this.createRequest = e, dt(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
|
|
818
818
|
}
|
|
819
819
|
_create() {
|
|
820
820
|
var t;
|
|
821
|
-
let n =
|
|
821
|
+
let n = ct(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
822
822
|
n.xdomain = !!this._opts.xd;
|
|
823
823
|
let r = this._xhr = this.createRequest(n);
|
|
824
824
|
try {
|
|
@@ -854,7 +854,7 @@ var Ct = class extends yt {
|
|
|
854
854
|
}
|
|
855
855
|
_cleanup(t) {
|
|
856
856
|
if (!(this._xhr === void 0 || this._xhr === null)) {
|
|
857
|
-
if (this._xhr.onreadystatechange =
|
|
857
|
+
if (this._xhr.onreadystatechange = Ct, t) try {
|
|
858
858
|
this._xhr.abort();
|
|
859
859
|
} catch {}
|
|
860
860
|
typeof document < "u" && delete e.requests[this._index], this._xhr = null;
|
|
@@ -868,46 +868,46 @@ var Ct = class extends yt {
|
|
|
868
868
|
this._cleanup();
|
|
869
869
|
}
|
|
870
870
|
};
|
|
871
|
-
if (
|
|
872
|
-
if (typeof attachEvent == "function") attachEvent("onunload",
|
|
871
|
+
if (Tt.requestsCount = 0, Tt.requests = {}, typeof document < "u") {
|
|
872
|
+
if (typeof attachEvent == "function") attachEvent("onunload", Et);
|
|
873
873
|
else if (typeof addEventListener == "function") {
|
|
874
|
-
let e = "onpagehide" in
|
|
875
|
-
addEventListener(e,
|
|
874
|
+
let e = "onpagehide" in W ? "pagehide" : "unload";
|
|
875
|
+
addEventListener(e, Et, !1);
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
function
|
|
879
|
-
for (let e in
|
|
878
|
+
function Et() {
|
|
879
|
+
for (let e in Tt.requests) Tt.requests.hasOwnProperty(e) && Tt.requests[e].abort();
|
|
880
880
|
}
|
|
881
|
-
var
|
|
881
|
+
var G = (function() {
|
|
882
882
|
let e = Ot({ xdomain: !1 });
|
|
883
883
|
return e && e.responseType !== null;
|
|
884
|
-
})(), Dt = class extends
|
|
884
|
+
})(), Dt = class extends wt {
|
|
885
885
|
constructor(e) {
|
|
886
886
|
super(e);
|
|
887
887
|
let t = e && e.forceBase64;
|
|
888
|
-
this.supportsBinary =
|
|
888
|
+
this.supportsBinary = G && !t;
|
|
889
889
|
}
|
|
890
890
|
request(e = {}) {
|
|
891
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new
|
|
891
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new Tt(Ot, this.uri(), e);
|
|
892
892
|
}
|
|
893
893
|
};
|
|
894
894
|
function Ot(e) {
|
|
895
895
|
let t = e.xdomain;
|
|
896
896
|
try {
|
|
897
|
-
if (typeof XMLHttpRequest < "u" && (!t ||
|
|
897
|
+
if (typeof XMLHttpRequest < "u" && (!t || St)) return new XMLHttpRequest();
|
|
898
898
|
} catch {}
|
|
899
899
|
if (!t) try {
|
|
900
|
-
return new
|
|
900
|
+
return new W[["Active", "Object"].join("X")]("Microsoft.XMLHTTP");
|
|
901
901
|
} catch {}
|
|
902
902
|
}
|
|
903
903
|
//#endregion
|
|
904
904
|
//#region node_modules/engine.io-client/build/esm/transports/websocket.js
|
|
905
|
-
var kt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", At = class extends
|
|
905
|
+
var kt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", At = class extends yt {
|
|
906
906
|
get name() {
|
|
907
907
|
return "websocket";
|
|
908
908
|
}
|
|
909
909
|
doOpen() {
|
|
910
|
-
let e = this.uri(), t = this.opts.protocols, n = kt ? {} :
|
|
910
|
+
let e = this.uri(), t = this.opts.protocols, n = kt ? {} : ct(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
911
911
|
this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
|
|
912
912
|
try {
|
|
913
913
|
this.ws = this.createSocket(e, t, n);
|
|
@@ -928,11 +928,11 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
928
928
|
this.writable = !1;
|
|
929
929
|
for (let t = 0; t < e.length; t++) {
|
|
930
930
|
let n = e[t], r = t === e.length - 1;
|
|
931
|
-
|
|
931
|
+
Ue(n, this.supportsBinary, (e) => {
|
|
932
932
|
try {
|
|
933
933
|
this.doWrite(n, e);
|
|
934
934
|
} catch {}
|
|
935
|
-
r &&
|
|
935
|
+
r && ot(() => {
|
|
936
936
|
this.writable = !0, this.emitReserved("drain");
|
|
937
937
|
}, this.setTimeoutFn);
|
|
938
938
|
});
|
|
@@ -943,9 +943,9 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
943
943
|
}
|
|
944
944
|
uri() {
|
|
945
945
|
let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
946
|
-
return this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
946
|
+
return this.opts.timestampRequests && (t[this.opts.timestampParam] = ht()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
947
947
|
}
|
|
948
|
-
}, jt =
|
|
948
|
+
}, jt = W.WebSocket || W.MozWebSocket, Mt = {
|
|
949
949
|
websocket: class extends At {
|
|
950
950
|
createSocket(e, t, n) {
|
|
951
951
|
return kt ? new jt(e, t, n) : t ? new jt(e, t) : new jt(e);
|
|
@@ -954,7 +954,7 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
954
954
|
this.ws.send(t);
|
|
955
955
|
}
|
|
956
956
|
},
|
|
957
|
-
webtransport: class extends
|
|
957
|
+
webtransport: class extends yt {
|
|
958
958
|
get name() {
|
|
959
959
|
return "webtransport";
|
|
960
960
|
}
|
|
@@ -970,7 +970,7 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
970
970
|
this.onError("webtransport error", e);
|
|
971
971
|
}), this._transport.ready.then(() => {
|
|
972
972
|
this._transport.createBidirectionalStream().then((e) => {
|
|
973
|
-
let t =
|
|
973
|
+
let t = it(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = V();
|
|
974
974
|
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
975
975
|
let i = () => {
|
|
976
976
|
n.read().then(({ done: e, value: t }) => {
|
|
@@ -988,7 +988,7 @@ var kt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
988
988
|
for (let t = 0; t < e.length; t++) {
|
|
989
989
|
let n = e[t], r = t === e.length - 1;
|
|
990
990
|
this._writer.write(n).then(() => {
|
|
991
|
-
r &&
|
|
991
|
+
r && ot(() => {
|
|
992
992
|
this.writable = !0, this.emitReserved("drain");
|
|
993
993
|
}, this.setTimeoutFn);
|
|
994
994
|
});
|
|
@@ -1040,13 +1040,13 @@ var Rt = typeof addEventListener == "function" && typeof removeEventListener ==
|
|
|
1040
1040
|
Rt && addEventListener("offline", () => {
|
|
1041
1041
|
zt.forEach((e) => e());
|
|
1042
1042
|
}, !1);
|
|
1043
|
-
var Bt = class e extends
|
|
1043
|
+
var Bt = class e extends U {
|
|
1044
1044
|
constructor(e, t) {
|
|
1045
|
-
if (super(), this.binaryType =
|
|
1045
|
+
if (super(), this.binaryType = st, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
|
|
1046
1046
|
let n = Ft(e);
|
|
1047
1047
|
t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
|
|
1048
1048
|
} else t.host && (t.hostname = Ft(t.host).host);
|
|
1049
|
-
|
|
1049
|
+
dt(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
|
|
1050
1050
|
let t = e.prototype.name;
|
|
1051
1051
|
this.transports.push(t), this._transportsByName[t] = e;
|
|
1052
1052
|
}), this.opts = Object.assign({
|
|
@@ -1061,7 +1061,7 @@ var Bt = class e extends W {
|
|
|
1061
1061
|
perMessageDeflate: { threshold: 1024 },
|
|
1062
1062
|
transportOptions: {},
|
|
1063
1063
|
closeOnBeforeunload: !1
|
|
1064
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query =
|
|
1064
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = _t(this.opts.query)), Rt && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
1065
1065
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
1066
1066
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
1067
1067
|
this._onClose("transport close", { description: "network connection lost" });
|
|
@@ -1138,7 +1138,7 @@ var Bt = class e extends W {
|
|
|
1138
1138
|
let e = 1;
|
|
1139
1139
|
for (let t = 0; t < this.writeBuffer.length; t++) {
|
|
1140
1140
|
let n = this.writeBuffer[t].data;
|
|
1141
|
-
if (n && (e +=
|
|
1141
|
+
if (n && (e += pt(n)), t > 0 && e > this._maxPayload) return this.writeBuffer.slice(0, t);
|
|
1142
1142
|
e += 2;
|
|
1143
1143
|
}
|
|
1144
1144
|
return this.writeBuffer;
|
|
@@ -1146,7 +1146,7 @@ var Bt = class e extends W {
|
|
|
1146
1146
|
_hasPingExpired() {
|
|
1147
1147
|
if (!this._pingTimeoutTime) return !0;
|
|
1148
1148
|
let e = Date.now() > this._pingTimeoutTime;
|
|
1149
|
-
return e && (this._pingTimeoutTime = 0,
|
|
1149
|
+
return e && (this._pingTimeoutTime = 0, ot(() => {
|
|
1150
1150
|
this._onClose("ping timeout");
|
|
1151
1151
|
}, this.setTimeoutFn)), e;
|
|
1152
1152
|
}
|
|
@@ -1365,7 +1365,7 @@ var rn = class {
|
|
|
1365
1365
|
let t = Zt(e), n = this.encodeAsString(t.packet), r = t.buffers;
|
|
1366
1366
|
return r.unshift(n), r;
|
|
1367
1367
|
}
|
|
1368
|
-
}, an = class e extends
|
|
1368
|
+
}, an = class e extends U {
|
|
1369
1369
|
constructor(e) {
|
|
1370
1370
|
super(), this.opts = Object.assign({
|
|
1371
1371
|
reviver: void 0,
|
|
@@ -1498,7 +1498,7 @@ var mn = Object.freeze({
|
|
|
1498
1498
|
disconnecting: 1,
|
|
1499
1499
|
newListener: 1,
|
|
1500
1500
|
removeListener: 1
|
|
1501
|
-
}), hn = class extends
|
|
1501
|
+
}), hn = class extends U {
|
|
1502
1502
|
constructor(e, t, n) {
|
|
1503
1503
|
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
|
|
1504
1504
|
}
|
|
@@ -1751,9 +1751,9 @@ gn.prototype.duration = function() {
|
|
|
1751
1751
|
};
|
|
1752
1752
|
//#endregion
|
|
1753
1753
|
//#region node_modules/socket.io-client/build/esm/manager.js
|
|
1754
|
-
var _n = class extends
|
|
1754
|
+
var _n = class extends U {
|
|
1755
1755
|
constructor(e, t) {
|
|
1756
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t,
|
|
1756
|
+
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, dt(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new gn({
|
|
1757
1757
|
min: this.reconnectionDelay(),
|
|
1758
1758
|
max: this.reconnectionDelayMax(),
|
|
1759
1759
|
jitter: this.randomizationFactor()
|
|
@@ -1824,7 +1824,7 @@ var _n = class extends W {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
}
|
|
1826
1826
|
ondecoded(e) {
|
|
1827
|
-
|
|
1827
|
+
ot(() => {
|
|
1828
1828
|
this.emitReserved("packet", e);
|
|
1829
1829
|
}, this.setTimeoutFn);
|
|
1830
1830
|
}
|
|
@@ -2817,11 +2817,11 @@ async function br(e, t = {}) {
|
|
|
2817
2817
|
try {
|
|
2818
2818
|
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
2819
2819
|
} catch {}
|
|
2820
|
-
return n && mr(n), r ||
|
|
2820
|
+
return n && mr(n), r || F(), window.location.assign(i.href), { navigated: !0 };
|
|
2821
2821
|
}
|
|
2822
2822
|
return { navigated: !0 };
|
|
2823
2823
|
}
|
|
2824
|
-
return n && mr(n), r ||
|
|
2824
|
+
return n && mr(n), r || F(), window.location.assign(i.href), { navigated: !0 };
|
|
2825
2825
|
} catch (t) {
|
|
2826
2826
|
console.warn("[FlowEngage] shadowNavigate error:", t), n && mr(n);
|
|
2827
2827
|
try {
|
|
@@ -2919,108 +2919,108 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2919
2919
|
message: "Looks like you're already on this page!",
|
|
2920
2920
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2921
2921
|
}]);
|
|
2922
|
-
}, []), [T, D] = m(
|
|
2922
|
+
}, []), [T, D] = m(me().isOpen), [ee, O] = m(me().activeScreen), [k, A] = m(me().isHumanHandled), [ie, j] = m(me().agentName), [ce, le] = m(me().agentHeadshot), [ue, ve] = m(() => ge(i?.siteId)), [M, ye] = m(!1), [xe, Se] = m(!1), [Ce, we] = m("idle"), [N, Te] = m(!1), [Ee, P] = m(!1), [Oe, ke] = m(""), [F, Ae] = m(!1), [je, Me] = m(0), [I, Ne] = m(0), [L, Pe] = m(!1), [R, Re] = m(null), [ze, Be] = m(null), [Ve, He] = m("idle"), [Ue, We] = m(null), [Ge, Ke] = m(!1), [qe, Je] = m(""), [Ye, Xe] = m(!1), z = p(null), B = p(null), Ze = p(""), Qe = p(!1), $e = p(null), et = p(null), tt = p(null), V = p(null), H = p(null), nt = p(null), rt = p(null), it = p(!1), U = p({
|
|
2923
2923
|
url: null,
|
|
2924
2924
|
at: 0
|
|
2925
|
-
}),
|
|
2925
|
+
}), at = o((e, t) => {
|
|
2926
2926
|
let n = e;
|
|
2927
2927
|
try {
|
|
2928
2928
|
n = new URL(e, window.location.origin).href;
|
|
2929
2929
|
} catch {}
|
|
2930
|
-
let r =
|
|
2930
|
+
let r = U.current;
|
|
2931
2931
|
return r.url === n && Date.now() - r.at < 4e3 ? Promise.resolve({
|
|
2932
2932
|
navigated: !0,
|
|
2933
2933
|
deduped: !0
|
|
2934
|
-
}) : (
|
|
2934
|
+
}) : (U.current = {
|
|
2935
2935
|
url: n,
|
|
2936
2936
|
at: Date.now()
|
|
2937
2937
|
}, br(e, t));
|
|
2938
|
-
}, []),
|
|
2938
|
+
}, []), ot = p([]), W = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(ie), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
|
|
2939
2939
|
notifyRouteChange: () => {},
|
|
2940
2940
|
cleanup: () => {}
|
|
2941
|
-
}),
|
|
2941
|
+
}), St = o((e = {}) => {
|
|
2942
2942
|
let t = !!e.is_human_handled;
|
|
2943
|
-
return A(t), t ? (O("agent"), e.agent_info?.name &&
|
|
2944
|
-
}, []),
|
|
2943
|
+
return A(t), t ? (O("agent"), e.agent_info?.name && j(e.agent_info.name), e.agent_info?.headshot && le(e.agent_info.headshot), t) : (O("ai"), t);
|
|
2944
|
+
}, []), Ct = f(() => {
|
|
2945
2945
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
2946
2946
|
return Number.isFinite(t) && t > 0 ? t : ne;
|
|
2947
2947
|
}, [i, _]);
|
|
2948
2948
|
c(() => {
|
|
2949
|
-
|
|
2950
|
-
}, [
|
|
2951
|
-
|
|
2949
|
+
et.current = R;
|
|
2950
|
+
}, [R]), c(() => {
|
|
2951
|
+
gt.current = ie;
|
|
2952
2952
|
}, [ie]), c(() => {
|
|
2953
|
-
|
|
2954
|
-
}, [
|
|
2955
|
-
|
|
2953
|
+
yt.current = F;
|
|
2954
|
+
}, [F]), c(() => {
|
|
2955
|
+
bt.current = i;
|
|
2956
2956
|
}, [i]);
|
|
2957
|
-
let
|
|
2958
|
-
|
|
2959
|
-
},
|
|
2960
|
-
|
|
2961
|
-
}, []),
|
|
2957
|
+
let wt = () => {
|
|
2958
|
+
Je("");
|
|
2959
|
+
}, Tt = o(() => {
|
|
2960
|
+
ct.current &&= (window.clearTimeout(ct.current), null);
|
|
2961
|
+
}, []), Et = (e) => {
|
|
2962
2962
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
2963
|
-
return
|
|
2963
|
+
return ve(t), _e(t, i?.siteId), t;
|
|
2964
2964
|
};
|
|
2965
2965
|
c(() => {
|
|
2966
2966
|
let e = i?.siteId;
|
|
2967
2967
|
if (!e) return;
|
|
2968
|
-
let t =
|
|
2968
|
+
let t = ge(e);
|
|
2969
2969
|
if (t) {
|
|
2970
|
-
|
|
2970
|
+
ve(t);
|
|
2971
2971
|
return;
|
|
2972
2972
|
}
|
|
2973
|
-
|
|
2973
|
+
ve((t) => (t && _e(t, e), t));
|
|
2974
2974
|
}, [i?.siteId]);
|
|
2975
|
-
let
|
|
2976
|
-
let t =
|
|
2977
|
-
if (
|
|
2975
|
+
let G = (e = "unspecified") => {
|
|
2976
|
+
let t = W.current || nt.current?.callId, n = ht.current, r = ft.current;
|
|
2977
|
+
if (ft.current = null, ht.current = 0, r && r.state !== "inactive") {
|
|
2978
2978
|
r.onstop = () => {
|
|
2979
|
-
let e =
|
|
2980
|
-
if (
|
|
2979
|
+
let e = mt.current;
|
|
2980
|
+
if (mt.current = [], e.length > 0 && t && B.current) {
|
|
2981
2981
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2982
|
-
|
|
2982
|
+
B.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2983
2983
|
}
|
|
2984
2984
|
};
|
|
2985
2985
|
try {
|
|
2986
2986
|
r.stop();
|
|
2987
2987
|
} catch {
|
|
2988
|
-
r.onstop = null,
|
|
2988
|
+
r.onstop = null, mt.current = [];
|
|
2989
2989
|
}
|
|
2990
2990
|
} else if (r && r.state === "inactive") {
|
|
2991
|
-
let e =
|
|
2992
|
-
if (
|
|
2991
|
+
let e = mt.current;
|
|
2992
|
+
if (mt.current = [], e.length > 0 && t && B.current) {
|
|
2993
2993
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2994
|
-
|
|
2994
|
+
B.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2995
2995
|
}
|
|
2996
|
-
} else
|
|
2997
|
-
if (
|
|
2996
|
+
} else mt.current = [];
|
|
2997
|
+
if (pt.current) {
|
|
2998
2998
|
try {
|
|
2999
|
-
|
|
2999
|
+
pt.current.close();
|
|
3000
3000
|
} catch {}
|
|
3001
|
-
|
|
3001
|
+
pt.current = null;
|
|
3002
3002
|
}
|
|
3003
|
-
|
|
3003
|
+
tt.current &&= (tt.current.close(), null), V.current &&= (V.current.getTracks().forEach((e) => e.stop()), null), H.current &&= (H.current.srcObject = null, H.current.remove(), null), Tt(), nt.current = null, ot.current = [], W.current = null, st.current = null, lt.current = !1, Ke(!1), Re(null), Be(null), He("idle"), We(null);
|
|
3004
3004
|
}, Dt = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
3005
|
-
let t =
|
|
3006
|
-
if (!(!t?.connected || !n ||
|
|
3007
|
-
|
|
3005
|
+
let t = z.current, n = W.current || nt.current?.callId;
|
|
3006
|
+
if (!(!t?.connected || !n || lt.current)) {
|
|
3007
|
+
lt.current = !0, t.emit("call:connected", {
|
|
3008
3008
|
callId: n,
|
|
3009
|
-
chatId:
|
|
3009
|
+
chatId: Ze.current,
|
|
3010
3010
|
connectedAt: e
|
|
3011
3011
|
});
|
|
3012
3012
|
try {
|
|
3013
|
-
let e =
|
|
3014
|
-
if (e && t && !
|
|
3015
|
-
|
|
3013
|
+
let e = V.current, t = H.current?.srcObject;
|
|
3014
|
+
if (e && t && !ft.current) {
|
|
3015
|
+
mt.current = [];
|
|
3016
3016
|
let n = new (window.AudioContext || window.webkitAudioContext)();
|
|
3017
|
-
|
|
3017
|
+
pt.current = n;
|
|
3018
3018
|
let r = n.createMediaStreamDestination();
|
|
3019
3019
|
n.createMediaStreamSource(e).connect(r), n.createMediaStreamSource(t).connect(r);
|
|
3020
3020
|
let i = window.MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4", a = new window.MediaRecorder(r.stream, { mimeType: i });
|
|
3021
3021
|
a.ondataavailable = (e) => {
|
|
3022
|
-
e.data && e.data.size > 0 &&
|
|
3023
|
-
},
|
|
3022
|
+
e.data && e.data.size > 0 && mt.current.push(e.data);
|
|
3023
|
+
}, ft.current = a, ht.current = Date.now(), a.start(1e3), setTimeout(() => {
|
|
3024
3024
|
try {
|
|
3025
3025
|
if (!window.speechSynthesis) return;
|
|
3026
3026
|
let e = new SpeechSynthesisUtterance("This call is being recorded for quality and training purposes.");
|
|
@@ -3050,80 +3050,80 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3050
3050
|
}
|
|
3051
3051
|
}, Ot = (e = {}) => {
|
|
3052
3052
|
if (!e.callId) return;
|
|
3053
|
-
let t =
|
|
3053
|
+
let t = st.current === e.callId, n = W.current === e.callId, r = et.current?.callId === e.callId;
|
|
3054
3054
|
if (!(!t && !n && !r)) {
|
|
3055
|
-
if (
|
|
3056
|
-
|
|
3055
|
+
if (Tt(), Re(null), t || n) {
|
|
3056
|
+
W.current = e.callId, Be(e.callId), He((e) => e === "connected" ? e : "connecting"), D(!0);
|
|
3057
3057
|
return;
|
|
3058
3058
|
}
|
|
3059
|
-
|
|
3059
|
+
He("idle");
|
|
3060
3060
|
}
|
|
3061
3061
|
}, kt = (e = {}) => {
|
|
3062
3062
|
if (!e.callId) return;
|
|
3063
|
-
let t =
|
|
3063
|
+
let t = st.current === e.callId, n = W.current === e.callId, r = et.current?.callId === e.callId;
|
|
3064
3064
|
if (!(!t && !n && !r)) {
|
|
3065
|
-
if (
|
|
3066
|
-
|
|
3065
|
+
if (Tt(), n) {
|
|
3066
|
+
G();
|
|
3067
3067
|
return;
|
|
3068
3068
|
}
|
|
3069
|
-
|
|
3069
|
+
st.current = null, nt.current = null, ot.current = [], Re(null), He("idle");
|
|
3070
3070
|
}
|
|
3071
3071
|
}, At = async (e = {}) => {
|
|
3072
|
-
let t =
|
|
3072
|
+
let t = tt.current, n = z.current, r = e.sdpOffer || e.offer?.sdp;
|
|
3073
3073
|
if (!t || !n?.connected || !r || !e.callId) {
|
|
3074
3074
|
console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
|
|
3075
3075
|
callId: e.callId,
|
|
3076
|
-
chatId:
|
|
3076
|
+
chatId: Ze.current,
|
|
3077
3077
|
hasPeerConnection: !!t,
|
|
3078
3078
|
socketConnected: !!n?.connected,
|
|
3079
3079
|
hasOffer: !!r
|
|
3080
|
-
}),
|
|
3080
|
+
}), nt.current = e;
|
|
3081
3081
|
return;
|
|
3082
3082
|
}
|
|
3083
3083
|
if (await t.setRemoteDescription(new RTCSessionDescription({
|
|
3084
3084
|
type: "offer",
|
|
3085
3085
|
sdp: r
|
|
3086
|
-
})),
|
|
3086
|
+
})), ot.current.length > 0) {
|
|
3087
3087
|
console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
|
|
3088
3088
|
callId: e.callId,
|
|
3089
|
-
chatId:
|
|
3090
|
-
queuedCount:
|
|
3089
|
+
chatId: Ze.current,
|
|
3090
|
+
queuedCount: ot.current.length
|
|
3091
3091
|
});
|
|
3092
|
-
for (let e of
|
|
3093
|
-
|
|
3092
|
+
for (let e of ot.current) await t.addIceCandidate(new RTCIceCandidate(e));
|
|
3093
|
+
ot.current = [];
|
|
3094
3094
|
}
|
|
3095
3095
|
let i = await t.createAnswer();
|
|
3096
3096
|
await t.setLocalDescription(i), n.emit("call:answer", {
|
|
3097
3097
|
callId: e.callId,
|
|
3098
3098
|
sdpAnswer: i.sdp,
|
|
3099
|
-
chatId:
|
|
3099
|
+
chatId: Ze.current
|
|
3100
3100
|
});
|
|
3101
3101
|
};
|
|
3102
3102
|
c(() => {
|
|
3103
|
-
|
|
3103
|
+
he({
|
|
3104
3104
|
isOpen: T,
|
|
3105
3105
|
activeScreen: ee,
|
|
3106
3106
|
isHumanHandled: k,
|
|
3107
3107
|
agentName: ie,
|
|
3108
|
-
agentHeadshot:
|
|
3108
|
+
agentHeadshot: ce
|
|
3109
3109
|
});
|
|
3110
3110
|
}, [
|
|
3111
3111
|
T,
|
|
3112
3112
|
ee,
|
|
3113
3113
|
k,
|
|
3114
3114
|
ie,
|
|
3115
|
-
|
|
3115
|
+
ce
|
|
3116
3116
|
]), c(() => {
|
|
3117
3117
|
let e = !0;
|
|
3118
3118
|
return (async () => {
|
|
3119
|
-
|
|
3119
|
+
Xe(!0);
|
|
3120
3120
|
try {
|
|
3121
|
-
let t = E(i), n = await
|
|
3121
|
+
let t = E(i), n = await Ie(t);
|
|
3122
3122
|
if (!e) return;
|
|
3123
|
-
let a = t.siteId, o =
|
|
3123
|
+
let a = t.siteId, o = de(a), s = be(a), c = "";
|
|
3124
3124
|
try {
|
|
3125
|
-
let e =
|
|
3126
|
-
if (
|
|
3125
|
+
let e = Qe.current, r = $e.current;
|
|
3126
|
+
if (Qe.current = !1, $e.current = null, c = (await Fe({
|
|
3127
3127
|
apiBaseUrl: t.apiBaseUrl,
|
|
3128
3128
|
userId: n.userId,
|
|
3129
3129
|
siteId: a,
|
|
@@ -3132,18 +3132,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3132
3132
|
resumeChatId: r,
|
|
3133
3133
|
visitorId: s
|
|
3134
3134
|
}))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
|
|
3135
|
-
oe(),
|
|
3135
|
+
oe(), pe(a, c);
|
|
3136
3136
|
} catch (e) {
|
|
3137
|
-
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o ||
|
|
3137
|
+
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || se(), pe(a, c);
|
|
3138
3138
|
}
|
|
3139
|
-
|
|
3140
|
-
let l =
|
|
3139
|
+
Ze.current = c;
|
|
3140
|
+
let l = Le({
|
|
3141
3141
|
apiBaseUrl: t.apiBaseUrl,
|
|
3142
3142
|
userId: n.userId,
|
|
3143
3143
|
siteId: t.siteId,
|
|
3144
3144
|
visitorId: s
|
|
3145
3145
|
});
|
|
3146
|
-
|
|
3146
|
+
B.current = l, v({
|
|
3147
3147
|
...n,
|
|
3148
3148
|
apiBaseUrl: t.apiBaseUrl
|
|
3149
3149
|
}), b(c);
|
|
@@ -3153,24 +3153,24 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3153
3153
|
chatId: c,
|
|
3154
3154
|
siteId: t.siteId
|
|
3155
3155
|
});
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
let e =
|
|
3159
|
-
if (e &&
|
|
3160
|
-
|
|
3156
|
+
z.current = f, f.on("connect", async () => {
|
|
3157
|
+
we("connected");
|
|
3158
|
+
let e = Ze.current;
|
|
3159
|
+
if (e && B.current) try {
|
|
3160
|
+
St(await B.current.checkHumanHandled(e));
|
|
3161
3161
|
} catch {}
|
|
3162
3162
|
}), f.on("disconnect", () => {
|
|
3163
|
-
|
|
3163
|
+
we("disconnected");
|
|
3164
3164
|
}), f.on("aiTyping", () => {
|
|
3165
|
-
|
|
3165
|
+
Se(!0);
|
|
3166
3166
|
}), f.on("ai:typing", () => {
|
|
3167
|
-
|
|
3167
|
+
Se(!0);
|
|
3168
3168
|
}), f.on("messageReceived", (e) => {
|
|
3169
3169
|
let t = e.message || e, n = {
|
|
3170
3170
|
...t,
|
|
3171
3171
|
message: Tr(t.message)
|
|
3172
3172
|
};
|
|
3173
|
-
|
|
3173
|
+
Se(!1), ye(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
|
|
3174
3174
|
...n,
|
|
3175
3175
|
isPending: !1,
|
|
3176
3176
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3188,7 +3188,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3188
3188
|
...t,
|
|
3189
3189
|
message: Tr(t.message)
|
|
3190
3190
|
};
|
|
3191
|
-
|
|
3191
|
+
Se(!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") && ye(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
|
|
3192
3192
|
...n,
|
|
3193
3193
|
isPending: !1,
|
|
3194
3194
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
@@ -3200,20 +3200,20 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3200
3200
|
...n,
|
|
3201
3201
|
isPending: !1,
|
|
3202
3202
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
3203
|
-
}]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"),
|
|
3203
|
+
}]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"), j(Ar([
|
|
3204
3204
|
n.agent_name,
|
|
3205
3205
|
n.agentName,
|
|
3206
3206
|
n.metadata?.agentName
|
|
3207
|
-
], d)), n.sender_headshot &&
|
|
3207
|
+
], d)), n.sender_headshot && le(n.sender_headshot), D(!0), Me((e) => e + 1)));
|
|
3208
3208
|
});
|
|
3209
3209
|
let p = (e = {}) => {
|
|
3210
3210
|
let t = Ar([
|
|
3211
3211
|
e.agent?.name,
|
|
3212
3212
|
e.agentName,
|
|
3213
3213
|
e.agent_name,
|
|
3214
|
-
|
|
3214
|
+
gt.current
|
|
3215
3215
|
], d);
|
|
3216
|
-
A(!0), O("agent"),
|
|
3216
|
+
A(!0), O("agent"), j(t), le(e.agent?.headshot || null), D(!0), Me((e) => e + 1), S((e) => jr(e, {
|
|
3217
3217
|
id: `agent-joined-${Date.now()}`,
|
|
3218
3218
|
sender: "system",
|
|
3219
3219
|
message: `${t} has joined the chat.`,
|
|
@@ -3225,7 +3225,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3225
3225
|
e.agent?.name,
|
|
3226
3226
|
e.agentName,
|
|
3227
3227
|
e.agent_name,
|
|
3228
|
-
|
|
3228
|
+
gt.current
|
|
3229
3229
|
], d);
|
|
3230
3230
|
A(!1), O("ai"), S((e) => jr(e, {
|
|
3231
3231
|
id: `agent-left-${Date.now()}`,
|
|
@@ -3236,7 +3236,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3236
3236
|
}));
|
|
3237
3237
|
};
|
|
3238
3238
|
f.on("agent:joined", p), f.on("agentJoined", p), f.on("agent:left", m), f.on("agentLeft", m), f.on("conversationEnded", (e) => {
|
|
3239
|
-
|
|
3239
|
+
Pe(!0);
|
|
3240
3240
|
let t = e?.message || "This conversation has ended. Thank you for reaching out!";
|
|
3241
3241
|
S((e) => [...e, {
|
|
3242
3242
|
id: `conversation-ended-${Date.now()}`,
|
|
@@ -3247,30 +3247,30 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3247
3247
|
}]);
|
|
3248
3248
|
}), f.on("chat:history_update", (e) => {
|
|
3249
3249
|
let t = Er(e.chat_history || []);
|
|
3250
|
-
S(t), t.length === 0 && (
|
|
3250
|
+
S(t), t.length === 0 && (Pe(!1), A(!1), O("ai"), Se(!1), ye(!1));
|
|
3251
3251
|
}), f.on("conversation:reset", () => {
|
|
3252
|
-
S([]),
|
|
3252
|
+
S([]), Pe(!1), A(!1), O("ai"), Se(!1), ye(!1);
|
|
3253
3253
|
}), f.on("voice:end_session", (e = {}) => {
|
|
3254
|
-
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"),
|
|
3254
|
+
console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ne((e) => e + 1), D(!0), Me((e) => e + 1);
|
|
3255
3255
|
}), f.on("typing:start", (e) => {
|
|
3256
|
-
e.sender === "agent" &&
|
|
3256
|
+
e.sender === "agent" && ye(!0);
|
|
3257
3257
|
}), f.on("typing:stop", (e) => {
|
|
3258
|
-
e.sender === "agent" &&
|
|
3258
|
+
e.sender === "agent" && ye(!1);
|
|
3259
3259
|
}), f.on("call:incoming", (e = {}) => {
|
|
3260
3260
|
let t = Ar([
|
|
3261
3261
|
e.agentName,
|
|
3262
3262
|
e.ownerName,
|
|
3263
3263
|
e.agent?.name,
|
|
3264
|
-
|
|
3264
|
+
gt.current
|
|
3265
3265
|
], "Agent");
|
|
3266
|
-
|
|
3266
|
+
wt(), Tt(), lt.current = !1, Re({
|
|
3267
3267
|
callId: e.callId,
|
|
3268
3268
|
from: e.from || "owner",
|
|
3269
3269
|
agentId: e.agentId || null,
|
|
3270
3270
|
agentName: t
|
|
3271
|
-
}),
|
|
3271
|
+
}), j((e) => Ar([t, e], "Agent")), He("incoming"), We(null), D(!0);
|
|
3272
3272
|
}), f.on("call:offer", async (e = {}) => {
|
|
3273
|
-
|
|
3273
|
+
nt.current = e;
|
|
3274
3274
|
try {
|
|
3275
3275
|
await At(e);
|
|
3276
3276
|
} catch (e) {
|
|
@@ -3283,20 +3283,20 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3283
3283
|
console.warn("[FlowEngageProvider] ignoring invalid ICE candidate payload", e);
|
|
3284
3284
|
return;
|
|
3285
3285
|
}
|
|
3286
|
-
if (!
|
|
3286
|
+
if (!tt.current || !tt.current.remoteDescription) {
|
|
3287
3287
|
console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
|
|
3288
3288
|
callId: e.callId,
|
|
3289
|
-
chatId: e.chatId ||
|
|
3290
|
-
queueSize:
|
|
3291
|
-
}),
|
|
3289
|
+
chatId: e.chatId || Ze.current,
|
|
3290
|
+
queueSize: ot.current.length + 1
|
|
3291
|
+
}), ot.current.push(t);
|
|
3292
3292
|
return;
|
|
3293
3293
|
}
|
|
3294
|
-
await
|
|
3294
|
+
await tt.current.addIceCandidate(new RTCIceCandidate(t));
|
|
3295
3295
|
} catch (e) {
|
|
3296
3296
|
console.error("[FlowEngageProvider] failed to add ICE candidate", e);
|
|
3297
3297
|
}
|
|
3298
3298
|
}), f.on("call:ended", () => {
|
|
3299
|
-
|
|
3299
|
+
wt(), G("socket:call_ended");
|
|
3300
3300
|
}), f.on("call:accepted", (e = {}) => {
|
|
3301
3301
|
Ot(e);
|
|
3302
3302
|
}), f.on("call:accepted_by_other", (e = {}) => {
|
|
@@ -3309,18 +3309,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3309
3309
|
kt(e);
|
|
3310
3310
|
}), f.on("call:connected", (e = {}) => {
|
|
3311
3311
|
if (!e.callId) return;
|
|
3312
|
-
let t =
|
|
3312
|
+
let t = st.current === e.callId, n = W.current === e.callId, r = nt.current?.callId === e.callId, i = et.current?.callId === e.callId;
|
|
3313
3313
|
if (!t && !n && !r) {
|
|
3314
|
-
i && (
|
|
3314
|
+
i && (Re(null), He("idle"));
|
|
3315
3315
|
return;
|
|
3316
3316
|
}
|
|
3317
|
-
|
|
3317
|
+
lt.current = !0, st.current = null, W.current = e.callId, Be(e.callId), Re(null), He("connected"), We(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), D(!0);
|
|
3318
3318
|
}), f.on("call:unavailable", (e = {}) => {
|
|
3319
|
-
|
|
3319
|
+
G("socket:call_unavailable"), Je(Or(e, "This visitor is not available for a call right now.")), D(!0);
|
|
3320
3320
|
}), f.on("call:error", (e = {}) => {
|
|
3321
|
-
|
|
3321
|
+
G("socket:call_error"), Je(Or(e, "We couldn't connect the call right now.")), D(!0);
|
|
3322
3322
|
}), f.on("visitor:navigate", async ({ url: e, section: t, highlight: n } = {}) => {
|
|
3323
|
-
e &&
|
|
3323
|
+
e && at(e, { voiceActive: yt.current }).then(({ navigated: e, reason: r }) => {
|
|
3324
3324
|
if (!e) {
|
|
3325
3325
|
r === "not-found" ? C() : r === "already-on-page" && w();
|
|
3326
3326
|
return;
|
|
@@ -3337,7 +3337,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3337
3337
|
n && lr(n);
|
|
3338
3338
|
}), f.on("visitor:clear_highlight", () => {
|
|
3339
3339
|
ur();
|
|
3340
|
-
}),
|
|
3340
|
+
}), xt.current = xn({
|
|
3341
3341
|
socket: f,
|
|
3342
3342
|
chatId: c
|
|
3343
3343
|
});
|
|
@@ -3345,83 +3345,83 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3345
3345
|
if (!e) return;
|
|
3346
3346
|
S(Er(h.chat_history || [])), A(!!h.is_human_handled), O(h.is_human_handled ? "agent" : ee);
|
|
3347
3347
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3348
|
-
if (g && String(g).trim() &&
|
|
3348
|
+
if (g && String(g).trim() && Et(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3349
3349
|
u("ready");
|
|
3350
3350
|
} catch (t) {
|
|
3351
3351
|
if (!e) return;
|
|
3352
3352
|
h(t), u("error");
|
|
3353
3353
|
} finally {
|
|
3354
|
-
e &&
|
|
3354
|
+
e && Xe(!1);
|
|
3355
3355
|
}
|
|
3356
3356
|
})(), () => {
|
|
3357
|
-
e = !1,
|
|
3357
|
+
e = !1, xt.current?.cleanup?.(), G(), z.current?.disconnect();
|
|
3358
3358
|
};
|
|
3359
3359
|
}, [
|
|
3360
3360
|
i,
|
|
3361
3361
|
r,
|
|
3362
3362
|
a
|
|
3363
3363
|
]), c(() => () => {
|
|
3364
|
-
if (
|
|
3365
|
-
let e =
|
|
3366
|
-
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}),
|
|
3364
|
+
if (F && !vt.current && _t.current.length > 0) {
|
|
3365
|
+
let e = Ze.current, t = _t.current, n = B.current;
|
|
3366
|
+
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), vt.current = !0);
|
|
3367
3367
|
}
|
|
3368
|
-
}, [
|
|
3368
|
+
}, [F, _]);
|
|
3369
3369
|
let jt = p(null);
|
|
3370
3370
|
c(() => {
|
|
3371
|
-
let e =
|
|
3371
|
+
let e = B.current;
|
|
3372
3372
|
!e || !y || jt.current !== T && (T && jt.current !== null ? e.updateChatStatus(y, "open").catch(() => {}) : jt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), jt.current = T);
|
|
3373
3373
|
}, [T, y]), c(() => {
|
|
3374
3374
|
let e = () => {
|
|
3375
|
-
let e =
|
|
3375
|
+
let e = Ze.current, t = B.current;
|
|
3376
3376
|
!e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
|
|
3377
3377
|
};
|
|
3378
3378
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
3379
3379
|
}, []);
|
|
3380
3380
|
let Mt = async () => {
|
|
3381
|
-
if (!(!
|
|
3382
|
-
|
|
3381
|
+
if (!(!R?.callId || !B.current || !z.current || !y)) {
|
|
3382
|
+
wt(), st.current = R.callId, Tt();
|
|
3383
3383
|
try {
|
|
3384
3384
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3385
|
-
|
|
3385
|
+
V.current = e;
|
|
3386
3386
|
let t = [{ urls: "stun:stun.l.google.com:19302" }];
|
|
3387
3387
|
try {
|
|
3388
|
-
let e = await
|
|
3388
|
+
let e = await B.current.getIceServersConfig();
|
|
3389
3389
|
e?.data?.iceServers?.length && (t = e.data.iceServers);
|
|
3390
3390
|
} catch (e) {
|
|
3391
3391
|
console.warn("[FlowEngageProvider] ice-config fetch failed, using STUN default", e);
|
|
3392
3392
|
}
|
|
3393
3393
|
let n = new RTCPeerConnection({ iceServers: t });
|
|
3394
|
-
|
|
3394
|
+
tt.current = n, n.onconnectionstatechange = () => {
|
|
3395
3395
|
let e = n.connectionState;
|
|
3396
3396
|
if (e === "connected") {
|
|
3397
3397
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3398
|
-
|
|
3398
|
+
He("connected"), We((t) => t || e), Dt(e);
|
|
3399
3399
|
return;
|
|
3400
3400
|
}
|
|
3401
3401
|
if (e === "connecting") {
|
|
3402
|
-
|
|
3402
|
+
He((e) => e === "connected" ? e : "connecting");
|
|
3403
3403
|
return;
|
|
3404
3404
|
}
|
|
3405
|
-
(e === "failed" || e === "closed") &&
|
|
3405
|
+
(e === "failed" || e === "closed") && G(`peer:connection_${e}`);
|
|
3406
3406
|
}, n.oniceconnectionstatechange = () => {
|
|
3407
3407
|
let e = n.iceConnectionState;
|
|
3408
3408
|
if (e === "connected" || e === "completed") {
|
|
3409
3409
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3410
|
-
|
|
3410
|
+
He("connected"), We((t) => t || e), Dt(e);
|
|
3411
3411
|
return;
|
|
3412
3412
|
}
|
|
3413
3413
|
if (e === "checking" || e === "new") {
|
|
3414
|
-
|
|
3414
|
+
He((e) => e === "connected" ? e : "connecting");
|
|
3415
3415
|
return;
|
|
3416
3416
|
}
|
|
3417
|
-
(e === "failed" || e === "closed") &&
|
|
3417
|
+
(e === "failed" || e === "closed") && G(`peer:ice_${e}`);
|
|
3418
3418
|
}, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
|
|
3419
3419
|
n.addTrack(t, e);
|
|
3420
3420
|
}), n.onicecandidate = (e) => {
|
|
3421
|
-
if (!e.candidate || !
|
|
3421
|
+
if (!e.candidate || !z.current?.connected) return;
|
|
3422
3422
|
let t = e.candidate;
|
|
3423
|
-
|
|
3424
|
-
callId:
|
|
3423
|
+
z.current.emit("call:ice-candidate", {
|
|
3424
|
+
callId: R.callId,
|
|
3425
3425
|
candidate: t.candidate,
|
|
3426
3426
|
sdpMid: t.sdpMid,
|
|
3427
3427
|
sdpMLineIndex: t.sdpMLineIndex,
|
|
@@ -3430,122 +3430,122 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3430
3430
|
});
|
|
3431
3431
|
}, n.ontrack = (e) => {
|
|
3432
3432
|
let [t] = e.streams || [], [n] = t?.getAudioTracks?.() || [];
|
|
3433
|
-
if (!
|
|
3433
|
+
if (!H.current) {
|
|
3434
3434
|
let e = document.createElement("audio");
|
|
3435
|
-
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {},
|
|
3435
|
+
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, H.current = e, document.body.appendChild(e);
|
|
3436
3436
|
}
|
|
3437
|
-
|
|
3438
|
-
let r =
|
|
3439
|
-
if (!
|
|
3437
|
+
H.current.srcObject = e.streams[0];
|
|
3438
|
+
let r = R?.callId, i = r && (st.current === r || W.current === r);
|
|
3439
|
+
if (!lt.current && i) {
|
|
3440
3440
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3441
|
-
|
|
3441
|
+
He("connected"), We((t) => t || e), W.current = r, Be(r), Dt(e);
|
|
3442
3442
|
}
|
|
3443
|
-
|
|
3444
|
-
let a =
|
|
3443
|
+
H.current.srcObject = t || null;
|
|
3444
|
+
let a = H.current.play?.();
|
|
3445
3445
|
a?.catch && a.catch((e) => {});
|
|
3446
3446
|
};
|
|
3447
|
-
let r =
|
|
3447
|
+
let r = nt.current;
|
|
3448
3448
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3449
|
-
callId: r.callId ||
|
|
3449
|
+
callId: r.callId || R.callId,
|
|
3450
3450
|
chatId: y
|
|
3451
3451
|
}), await At({
|
|
3452
3452
|
...r,
|
|
3453
|
-
callId: r.callId ||
|
|
3454
|
-
})), await
|
|
3455
|
-
callId:
|
|
3453
|
+
callId: r.callId || R.callId
|
|
3454
|
+
})), await B.current.acceptCall(R.callId, y), z.current?.emit("call:accepted", {
|
|
3455
|
+
callId: R.callId,
|
|
3456
3456
|
chatId: y
|
|
3457
|
-
}),
|
|
3457
|
+
}), W.current = R.callId, Be(R.callId), He((e) => e === "connected" || lt.current ? "connected" : "connecting"), Re(null), D(!0);
|
|
3458
3458
|
} catch (e) {
|
|
3459
|
-
if (
|
|
3460
|
-
|
|
3459
|
+
if (st.current = null, G("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3460
|
+
Je(Or(e, "This visitor call is no longer available."));
|
|
3461
3461
|
return;
|
|
3462
3462
|
}
|
|
3463
3463
|
if (e?.name === "NotAllowedError" || e?.name === "PermissionDeniedError") {
|
|
3464
3464
|
try {
|
|
3465
|
-
await
|
|
3465
|
+
await B.current.rejectCall(R.callId, y);
|
|
3466
3466
|
} catch (e) {
|
|
3467
3467
|
console.error("[FlowEngageProvider] failed to reject call after microphone denial", e);
|
|
3468
3468
|
}
|
|
3469
|
-
|
|
3469
|
+
Je("Microphone access was denied. Please allow microphone access to accept the call.");
|
|
3470
3470
|
return;
|
|
3471
3471
|
}
|
|
3472
|
-
|
|
3472
|
+
Je("We couldn't connect the call right now. Please try again.");
|
|
3473
3473
|
}
|
|
3474
3474
|
}
|
|
3475
3475
|
}, Nt = async () => {
|
|
3476
|
-
if (!
|
|
3477
|
-
|
|
3476
|
+
if (!R?.callId || !B.current || !y) {
|
|
3477
|
+
G("reject_call_without_server_context");
|
|
3478
3478
|
return;
|
|
3479
3479
|
}
|
|
3480
|
-
let e =
|
|
3481
|
-
|
|
3480
|
+
let e = R.callId;
|
|
3481
|
+
Tt(), wt(), z.current?.emit("call:rejected", {
|
|
3482
3482
|
callId: e,
|
|
3483
3483
|
chatId: y,
|
|
3484
3484
|
reason: "visitor_declined"
|
|
3485
3485
|
});
|
|
3486
3486
|
try {
|
|
3487
|
-
await
|
|
3487
|
+
await B.current.rejectCall(e, y);
|
|
3488
3488
|
} catch (e) {
|
|
3489
|
-
|
|
3489
|
+
Je(Or(e, "We couldn't decline the call cleanly."));
|
|
3490
3490
|
} finally {
|
|
3491
|
-
|
|
3491
|
+
G("reject_call_finally");
|
|
3492
3492
|
}
|
|
3493
3493
|
}, Pt = p(Nt);
|
|
3494
3494
|
Pt.current = Nt, c(() => {
|
|
3495
|
-
if (!
|
|
3496
|
-
|
|
3495
|
+
if (!R?.callId || ze) {
|
|
3496
|
+
Tt();
|
|
3497
3497
|
return;
|
|
3498
3498
|
}
|
|
3499
|
-
let e =
|
|
3500
|
-
return
|
|
3501
|
-
|
|
3499
|
+
let e = R.callId;
|
|
3500
|
+
return Tt(), ct.current = window.setTimeout(() => {
|
|
3501
|
+
et.current?.callId === e && st.current !== e && W.current !== e && Pt.current();
|
|
3502
3502
|
}, re), () => {
|
|
3503
|
-
|
|
3503
|
+
ct.current &&= (window.clearTimeout(ct.current), null);
|
|
3504
3504
|
};
|
|
3505
3505
|
}, [
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3506
|
+
ze,
|
|
3507
|
+
Tt,
|
|
3508
|
+
R?.callId
|
|
3509
3509
|
]);
|
|
3510
3510
|
let Ft = async () => {
|
|
3511
|
-
if (!
|
|
3512
|
-
|
|
3511
|
+
if (!ze || !B.current || !y) {
|
|
3512
|
+
G("end_call_without_server_context");
|
|
3513
3513
|
return;
|
|
3514
3514
|
}
|
|
3515
|
-
|
|
3515
|
+
wt();
|
|
3516
3516
|
try {
|
|
3517
|
-
await
|
|
3517
|
+
await B.current.endWebRTCCall(ze, y);
|
|
3518
3518
|
} catch (e) {
|
|
3519
|
-
|
|
3519
|
+
Je(Or(e, "The call ended locally, but the server could not be updated."));
|
|
3520
3520
|
} finally {
|
|
3521
|
-
|
|
3521
|
+
G("end_call_finally");
|
|
3522
3522
|
}
|
|
3523
3523
|
}, It = () => {
|
|
3524
|
-
let e =
|
|
3524
|
+
let e = V.current?.getAudioTracks?.() || [], t = tt.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3525
3525
|
if (n.length === 0) return;
|
|
3526
|
-
let r = !
|
|
3526
|
+
let r = !Ge;
|
|
3527
3527
|
n.forEach((e) => {
|
|
3528
3528
|
e.enabled = !r;
|
|
3529
|
-
}),
|
|
3529
|
+
}), Ke(r);
|
|
3530
3530
|
}, Lt = async (e = {}) => {
|
|
3531
3531
|
let t = e.notifyChatInitiated === !0;
|
|
3532
|
-
if (D(!0), !(!t || !
|
|
3532
|
+
if (D(!0), !(!t || !B.current || !y || typeof window > "u")) {
|
|
3533
3533
|
try {
|
|
3534
|
-
await
|
|
3534
|
+
await B.current.trackVisitor({
|
|
3535
3535
|
chatId: y,
|
|
3536
3536
|
currentPagePath: window.location.pathname || "/"
|
|
3537
3537
|
});
|
|
3538
3538
|
} catch {}
|
|
3539
3539
|
try {
|
|
3540
|
-
await
|
|
3540
|
+
await B.current.updateChatStatus(y, "open");
|
|
3541
3541
|
} catch {}
|
|
3542
3542
|
}
|
|
3543
3543
|
}, Rt = async (e) => {
|
|
3544
|
-
let t =
|
|
3545
|
-
if (!t || !
|
|
3544
|
+
let t = Et(e);
|
|
3545
|
+
if (!t || !B.current || !Ze.current) return t;
|
|
3546
3546
|
try {
|
|
3547
|
-
await
|
|
3548
|
-
chatId:
|
|
3547
|
+
await B.current.trackVisitor({
|
|
3548
|
+
chatId: Ze.current,
|
|
3549
3549
|
currentPagePath: typeof window < "u" && window.location.pathname || "/",
|
|
3550
3550
|
email: t
|
|
3551
3551
|
});
|
|
@@ -3554,18 +3554,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3554
3554
|
}
|
|
3555
3555
|
return t;
|
|
3556
3556
|
}, zt = () => {
|
|
3557
|
-
!y || !
|
|
3557
|
+
!y || !z.current?.connected || ut.current || (ut.current = !0, z.current.emit("typing:start", {
|
|
3558
3558
|
chatId: y,
|
|
3559
3559
|
sender: "user"
|
|
3560
3560
|
}));
|
|
3561
3561
|
}, Bt = () => {
|
|
3562
|
-
!y || !
|
|
3562
|
+
!y || !z.current?.connected || !ut.current || (ut.current = !1, z.current.emit("typing:stop", {
|
|
3563
3563
|
chatId: y,
|
|
3564
3564
|
sender: "user"
|
|
3565
3565
|
}));
|
|
3566
3566
|
}, Vt = (e = "") => {
|
|
3567
3567
|
let t = typeof e == "string" ? e : "";
|
|
3568
|
-
!y || !
|
|
3568
|
+
!y || !z.current?.connected || t !== "" && dt.current === t || (dt.current = t, z.current.emit("typing:update", {
|
|
3569
3569
|
chatId: y,
|
|
3570
3570
|
sender: "user",
|
|
3571
3571
|
text: t
|
|
@@ -3584,22 +3584,22 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3584
3584
|
}
|
|
3585
3585
|
let Ut = async (e, t = "", n = null, i = {}) => {
|
|
3586
3586
|
let a = typeof e == "string" ? e.trim() : "";
|
|
3587
|
-
if (!a || !
|
|
3588
|
-
Bt(),
|
|
3587
|
+
if (!a || !B.current || !y || l !== "ready" || L) return;
|
|
3588
|
+
Bt(), it.current = !1;
|
|
3589
3589
|
let o = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, s = /^\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, c = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
|
|
3590
|
-
if (
|
|
3591
|
-
let { url: e, section: t } =
|
|
3592
|
-
|
|
3590
|
+
if (rt.current && o.test(a) && !s.test(a)) {
|
|
3591
|
+
let { url: e, section: t } = rt.current;
|
|
3592
|
+
rt.current = null, it.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), at(e, { voiceActive: yt.current }).then(({ navigated: e, reason: n }) => {
|
|
3593
3593
|
if (!e) {
|
|
3594
3594
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3595
3595
|
return;
|
|
3596
3596
|
}
|
|
3597
|
-
!t || !
|
|
3597
|
+
!t || !yt.current || setTimeout(() => {
|
|
3598
3598
|
let e = cr(null, t);
|
|
3599
3599
|
e && lr(e);
|
|
3600
3600
|
}, 300);
|
|
3601
3601
|
});
|
|
3602
|
-
} else o.test(a) || (
|
|
3602
|
+
} else o.test(a) || (rt.current = null);
|
|
3603
3603
|
let u = `pending-user-${Date.now()}`, d = {
|
|
3604
3604
|
id: u,
|
|
3605
3605
|
sender: "user",
|
|
@@ -3613,25 +3613,25 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3613
3613
|
S((e) => [...e, d]);
|
|
3614
3614
|
let f = k;
|
|
3615
3615
|
if (f) try {
|
|
3616
|
-
f =
|
|
3616
|
+
f = St(await B.current.checkHumanHandled(y));
|
|
3617
3617
|
} catch {}
|
|
3618
|
-
if (f &&
|
|
3619
|
-
|
|
3618
|
+
if (f && z.current?.connected) {
|
|
3619
|
+
z.current.emit("customer:message", {
|
|
3620
3620
|
chatId: y,
|
|
3621
3621
|
content: e,
|
|
3622
3622
|
sender: "user",
|
|
3623
|
-
email:
|
|
3623
|
+
email: ue || void 0,
|
|
3624
3624
|
type: i?.type || "text",
|
|
3625
3625
|
metadata: i?.metadata || {},
|
|
3626
3626
|
...n || {}
|
|
3627
3627
|
});
|
|
3628
3628
|
return;
|
|
3629
3629
|
}
|
|
3630
|
-
|
|
3630
|
+
Te(!0);
|
|
3631
3631
|
try {
|
|
3632
|
-
let o = await
|
|
3632
|
+
let o = await B.current.sendAiMessage(y, e, r, t, {
|
|
3633
3633
|
...n || {},
|
|
3634
|
-
...
|
|
3634
|
+
...ue ? { email: ue } : {}
|
|
3635
3635
|
}, {
|
|
3636
3636
|
...i,
|
|
3637
3637
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
@@ -3650,7 +3650,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3650
3650
|
url: o.pending_navigate.url,
|
|
3651
3651
|
section: o.pending_navigate.section || null
|
|
3652
3652
|
};
|
|
3653
|
-
c.test(a) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url),
|
|
3653
|
+
c.test(a) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url), at(e.url, { voiceActive: yt.current }).then(({ navigated: t, reason: n }) => {
|
|
3654
3654
|
if (!t) {
|
|
3655
3655
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3656
3656
|
return;
|
|
@@ -3659,12 +3659,12 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3659
3659
|
let t = cr(null, e.section);
|
|
3660
3660
|
t && lr(t);
|
|
3661
3661
|
}, 300);
|
|
3662
|
-
})) : (
|
|
3662
|
+
})) : (rt.current = e, console.log("[FWH Nav] Stored pending nav →", rt.current));
|
|
3663
3663
|
}
|
|
3664
|
-
if (o.navigate?.url) if (
|
|
3664
|
+
if (o.navigate?.url) if (it.current) it.current = !1;
|
|
3665
3665
|
else {
|
|
3666
3666
|
let { url: e, section: t } = o.navigate;
|
|
3667
|
-
|
|
3667
|
+
at(e, { voiceActive: yt.current }).then(({ navigated: e, reason: n }) => {
|
|
3668
3668
|
if (!e) {
|
|
3669
3669
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3670
3670
|
return;
|
|
@@ -3686,19 +3686,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3686
3686
|
if (e?.message) {
|
|
3687
3687
|
let t = Dr(e.message);
|
|
3688
3688
|
t && pr(t.url, {
|
|
3689
|
-
siteId:
|
|
3690
|
-
apiBaseUrl:
|
|
3689
|
+
siteId: bt.current?.siteId,
|
|
3690
|
+
apiBaseUrl: bt.current?.apiBaseUrl
|
|
3691
3691
|
}).then(({ allowed: e, correctedUrl: n }) => {
|
|
3692
3692
|
if (!e) {
|
|
3693
3693
|
C();
|
|
3694
3694
|
return;
|
|
3695
3695
|
}
|
|
3696
|
-
|
|
3696
|
+
at(n || t.url, { voiceActive: yt.current }).then(({ navigated: e, reason: n }) => {
|
|
3697
3697
|
if (!e) {
|
|
3698
3698
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3699
3699
|
return;
|
|
3700
3700
|
}
|
|
3701
|
-
!t.section || !
|
|
3701
|
+
!t.section || !yt.current || setTimeout(() => {
|
|
3702
3702
|
let e = cr(null, t.section);
|
|
3703
3703
|
e && lr(e);
|
|
3704
3704
|
}, 300);
|
|
@@ -3706,27 +3706,27 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3706
3706
|
});
|
|
3707
3707
|
}
|
|
3708
3708
|
}
|
|
3709
|
-
S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"),
|
|
3709
|
+
S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"), Se(!1), Te(!1), await B.current.updateChatStatus(y, "messageSent");
|
|
3710
3710
|
} catch (e) {
|
|
3711
|
-
S((e) => e.filter((e) => e.id !== u)),
|
|
3712
|
-
|
|
3711
|
+
S((e) => e.filter((e) => e.id !== u)), Se(!1), Te(!1), e.status === 429 ? (P(!0), ke(e.message), window.setTimeout(() => {
|
|
3712
|
+
P(!1), ke("");
|
|
3713
3713
|
}, te)) : h(e);
|
|
3714
3714
|
}
|
|
3715
3715
|
}, Wt = async (e) => {
|
|
3716
|
-
if (!
|
|
3717
|
-
return
|
|
3716
|
+
if (!B.current || !e) throw Error("Upload is unavailable right now.");
|
|
3717
|
+
return B.current.uploadChatFile(e);
|
|
3718
3718
|
}, Gt = async (e) => {
|
|
3719
|
-
if (!(!
|
|
3719
|
+
if (!(!B.current || !y)) {
|
|
3720
3720
|
try {
|
|
3721
3721
|
let t = e ? "voice" : "text";
|
|
3722
|
-
await
|
|
3722
|
+
await B.current.setChatMode(y, t);
|
|
3723
3723
|
} catch {}
|
|
3724
|
-
|
|
3724
|
+
Ae(e), e && (vt.current = !1);
|
|
3725
3725
|
}
|
|
3726
3726
|
}, Kt = async (e) => {
|
|
3727
|
-
if (
|
|
3728
|
-
if (
|
|
3729
|
-
|
|
3727
|
+
if (vt.current) return;
|
|
3728
|
+
if (vt.current = !0, !B.current || !y || !e?.length) {
|
|
3729
|
+
Ae(!1);
|
|
3730
3730
|
return;
|
|
3731
3731
|
}
|
|
3732
3732
|
let t = () => {
|
|
@@ -3738,10 +3738,10 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3738
3738
|
});
|
|
3739
3739
|
};
|
|
3740
3740
|
try {
|
|
3741
|
-
let n = await
|
|
3741
|
+
let n = await B.current.syncVoice(y, e);
|
|
3742
3742
|
if (n?.chat_history?.length) S(Er(n.chat_history));
|
|
3743
3743
|
else if (n?.success) try {
|
|
3744
|
-
let e = await
|
|
3744
|
+
let e = await B.current.loadHistory(y, r);
|
|
3745
3745
|
e?.chat_history?.length ? S(Er(e.chat_history)) : t();
|
|
3746
3746
|
} catch {
|
|
3747
3747
|
t();
|
|
@@ -3750,19 +3750,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3750
3750
|
} catch {
|
|
3751
3751
|
t();
|
|
3752
3752
|
} finally {
|
|
3753
|
-
|
|
3753
|
+
Ae(!1);
|
|
3754
3754
|
}
|
|
3755
3755
|
}, qt = async () => {
|
|
3756
|
-
if (!(!
|
|
3757
|
-
|
|
3756
|
+
if (!(!B.current || !y)) {
|
|
3757
|
+
F && !vt.current && _t.current.length > 0 && await Kt(_t.current);
|
|
3758
3758
|
try {
|
|
3759
|
-
await
|
|
3759
|
+
await B.current.endConversation(y);
|
|
3760
3760
|
} catch {
|
|
3761
3761
|
try {
|
|
3762
|
-
await
|
|
3762
|
+
await B.current.updateChatStatus(y, "ended");
|
|
3763
3763
|
} catch {}
|
|
3764
3764
|
}
|
|
3765
|
-
|
|
3765
|
+
Pe(!0), S((e) => [...e, {
|
|
3766
3766
|
id: `conversation-ended-${Date.now()}`,
|
|
3767
3767
|
sender: "system",
|
|
3768
3768
|
message: "This conversation has ended. Thank you for reaching out!",
|
|
@@ -3772,27 +3772,27 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3772
3772
|
}
|
|
3773
3773
|
};
|
|
3774
3774
|
c(() => {
|
|
3775
|
-
if (
|
|
3776
|
-
let e = new Date(
|
|
3777
|
-
|
|
3775
|
+
if (Ve !== "connected" || !ze || !y || !Ue || !Ct) return;
|
|
3776
|
+
let e = new Date(Ue).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, Ct * 1e3 - t), r = window.setTimeout(() => {
|
|
3777
|
+
Je("The call ended because it reached the time limit."), Ft();
|
|
3778
3778
|
}, n);
|
|
3779
3779
|
return () => window.clearTimeout(r);
|
|
3780
3780
|
}, [
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3781
|
+
ze,
|
|
3782
|
+
Ue,
|
|
3783
|
+
Ve,
|
|
3784
3784
|
y,
|
|
3785
3785
|
Ft,
|
|
3786
|
-
|
|
3786
|
+
Ct
|
|
3787
3787
|
]), c(() => {
|
|
3788
3788
|
let e = () => {
|
|
3789
|
-
let e =
|
|
3789
|
+
let e = Ze.current, t = B.current;
|
|
3790
3790
|
if (!t || !e) return;
|
|
3791
|
-
if (
|
|
3792
|
-
t.beaconEndWebRTCCall(
|
|
3791
|
+
if (yt.current && _t.current.length > 0 && De(), !vt.current && _t.current.length > 0 && (t.beaconSyncVoice(e, _t.current) || t.syncVoice(e, _t.current).catch(() => {}), vt.current = !0), W.current) {
|
|
3792
|
+
t.beaconEndWebRTCCall(W.current, e);
|
|
3793
3793
|
return;
|
|
3794
3794
|
}
|
|
3795
|
-
let n =
|
|
3795
|
+
let n = st.current || et.current?.callId;
|
|
3796
3796
|
n && t.beaconCustomerUnavailable(n, e);
|
|
3797
3797
|
};
|
|
3798
3798
|
return window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), () => {
|
|
@@ -3801,9 +3801,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3801
3801
|
}, []);
|
|
3802
3802
|
let Jt = o(() => {
|
|
3803
3803
|
let e = i?.siteId;
|
|
3804
|
-
|
|
3804
|
+
fe(e), Qe.current = !0, $e.current = null, z.current?.disconnect(), S([]), b(""), Ze.current = "", Pe(!1), A(!1), j(null), le(null), Xe(!0), s((e) => e + 1);
|
|
3805
3805
|
}, [i?.siteId]), Yt = o((e) => {
|
|
3806
|
-
i?.siteId,
|
|
3806
|
+
i?.siteId, Qe.current = !1, $e.current = e, z.current?.disconnect(), S([]), b(""), Ze.current = "", Pe(!1), A(!1), j(null), le(null), Xe(!0), s((e) => e + 1);
|
|
3807
3807
|
}, [i?.siteId]), Xt = f(() => ({
|
|
3808
3808
|
status: l,
|
|
3809
3809
|
error: d,
|
|
@@ -3815,34 +3815,34 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3815
3815
|
activeScreen: ee,
|
|
3816
3816
|
isHumanHandled: k,
|
|
3817
3817
|
agentName: ie,
|
|
3818
|
-
agentHeadshot:
|
|
3819
|
-
visitorEmail:
|
|
3820
|
-
isAgentTyping:
|
|
3821
|
-
isAiTyping:
|
|
3822
|
-
connectionStatus:
|
|
3823
|
-
isLoading:
|
|
3824
|
-
isVoiceMode:
|
|
3825
|
-
isRateLimited:
|
|
3826
|
-
rateLimitMessage:
|
|
3827
|
-
isConversationEnded:
|
|
3828
|
-
isSessionRestoring:
|
|
3829
|
-
openToChatCounter:
|
|
3830
|
-
voiceEndCounter:
|
|
3831
|
-
incomingCall:
|
|
3832
|
-
activeCallId:
|
|
3833
|
-
callConnectionState:
|
|
3834
|
-
callConnectedAt:
|
|
3835
|
-
isCallMuted:
|
|
3836
|
-
webRTCError:
|
|
3818
|
+
agentHeadshot: ce,
|
|
3819
|
+
visitorEmail: ue,
|
|
3820
|
+
isAgentTyping: M,
|
|
3821
|
+
isAiTyping: xe,
|
|
3822
|
+
connectionStatus: Ce,
|
|
3823
|
+
isLoading: N,
|
|
3824
|
+
isVoiceMode: F,
|
|
3825
|
+
isRateLimited: Ee,
|
|
3826
|
+
rateLimitMessage: Oe,
|
|
3827
|
+
isConversationEnded: L,
|
|
3828
|
+
isSessionRestoring: Ye,
|
|
3829
|
+
openToChatCounter: je,
|
|
3830
|
+
voiceEndCounter: I,
|
|
3831
|
+
incomingCall: R,
|
|
3832
|
+
activeCallId: ze,
|
|
3833
|
+
callConnectionState: Ve,
|
|
3834
|
+
callConnectedAt: Ue,
|
|
3835
|
+
isCallMuted: Ge,
|
|
3836
|
+
webRTCError: qe,
|
|
3837
3837
|
language: r,
|
|
3838
|
-
historyRef:
|
|
3839
|
-
hasSyncedRef:
|
|
3840
|
-
dismissCallError:
|
|
3838
|
+
historyRef: _t,
|
|
3839
|
+
hasSyncedRef: vt,
|
|
3840
|
+
dismissCallError: wt,
|
|
3841
3841
|
captureVisitorEmail: Rt,
|
|
3842
3842
|
startTyping: zt,
|
|
3843
3843
|
stopTyping: Bt,
|
|
3844
3844
|
updateTypingDraft: Vt,
|
|
3845
|
-
notifyRouteChange: () =>
|
|
3845
|
+
notifyRouteChange: () => xt.current?.notifyRouteChange?.(),
|
|
3846
3846
|
openWidget: Lt,
|
|
3847
3847
|
closeWidget: () => D(!1),
|
|
3848
3848
|
toggleWidget: () => {
|
|
@@ -3859,8 +3859,8 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3859
3859
|
endConversation: qt,
|
|
3860
3860
|
startNewChat: Jt,
|
|
3861
3861
|
resumeChat: Yt,
|
|
3862
|
-
getVisitorChatHistory: () =>
|
|
3863
|
-
getVisitorChatThread: (e) =>
|
|
3862
|
+
getVisitorChatHistory: () => B.current?.getVisitorChatHistory?.(),
|
|
3863
|
+
getVisitorChatThread: (e) => B.current?.getVisitorChatThread?.(e),
|
|
3864
3864
|
acceptCall: Mt,
|
|
3865
3865
|
rejectCall: Nt,
|
|
3866
3866
|
endWebRTCCall: Ft,
|
|
@@ -3876,25 +3876,25 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3876
3876
|
ee,
|
|
3877
3877
|
k,
|
|
3878
3878
|
ie,
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
ye,
|
|
3879
|
+
ce,
|
|
3880
|
+
ue,
|
|
3881
|
+
M,
|
|
3883
3882
|
xe,
|
|
3883
|
+
Ce,
|
|
3884
|
+
N,
|
|
3884
3885
|
F,
|
|
3885
|
-
L,
|
|
3886
|
-
we,
|
|
3887
3886
|
Ee,
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3887
|
+
Oe,
|
|
3888
|
+
L,
|
|
3889
|
+
Ye,
|
|
3891
3890
|
je,
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3891
|
+
I,
|
|
3892
|
+
R,
|
|
3893
|
+
ze,
|
|
3894
|
+
Ve,
|
|
3895
|
+
Ue,
|
|
3896
|
+
Ge,
|
|
3897
|
+
qe,
|
|
3898
3898
|
r,
|
|
3899
3899
|
Rt,
|
|
3900
3900
|
zt,
|
|
@@ -3911,7 +3911,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3911
3911
|
Kt,
|
|
3912
3912
|
qt,
|
|
3913
3913
|
Jt,
|
|
3914
|
-
|
|
3914
|
+
wt
|
|
3915
3915
|
]);
|
|
3916
3916
|
return /* @__PURE__ */ g(Sn.Provider, {
|
|
3917
3917
|
value: Xt,
|
|
@@ -8947,61 +8947,61 @@ async function Lm(e) {
|
|
|
8947
8947
|
}
|
|
8948
8948
|
}, ee = (e, t, n) => {
|
|
8949
8949
|
t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, Sm));
|
|
8950
|
-
}, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, ae = !1, oe = Cm,
|
|
8951
|
-
|
|
8952
|
-
let
|
|
8950
|
+
}, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, ae = !1, oe = Cm, se = wm, j = null, ce = !1, le = !1, ue = () => {
|
|
8951
|
+
j && clearTimeout(j);
|
|
8952
|
+
let e = () => {
|
|
8953
8953
|
if (!O) {
|
|
8954
|
-
if (
|
|
8955
|
-
|
|
8954
|
+
if (de.isPlaying()) {
|
|
8955
|
+
j = setTimeout(e, 150);
|
|
8956
8956
|
return;
|
|
8957
8957
|
}
|
|
8958
|
-
if (
|
|
8958
|
+
if (j = null, ce) {
|
|
8959
8959
|
p?.();
|
|
8960
8960
|
return;
|
|
8961
8961
|
}
|
|
8962
|
-
!O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })),
|
|
8962
|
+
!O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), le && (le = !1, d?.());
|
|
8963
8963
|
}
|
|
8964
8964
|
};
|
|
8965
|
-
|
|
8966
|
-
},
|
|
8965
|
+
j = setTimeout(e, 150);
|
|
8966
|
+
}, de = Fm(_, () => {
|
|
8967
8967
|
ne && (ne = !1, c?.({ mode: "listening" }));
|
|
8968
|
-
}, v),
|
|
8969
|
-
|
|
8970
|
-
let
|
|
8971
|
-
|
|
8968
|
+
}, v), fe = _.createMediaStreamSource(g);
|
|
8969
|
+
fe.connect(v);
|
|
8970
|
+
let pe = _.createScriptProcessor(xm, 1, 1), me = !1, he = 0, ge = 0;
|
|
8971
|
+
pe.onaudioprocess = (e) => {
|
|
8972
8972
|
if (O || C.readyState !== WebSocket.OPEN) return;
|
|
8973
8973
|
let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
|
|
8974
8974
|
if (k) {
|
|
8975
|
-
te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")),
|
|
8975
|
+
te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), me = !1, he = 0, ge = 0, n();
|
|
8976
8976
|
return;
|
|
8977
8977
|
}
|
|
8978
8978
|
let r = Om(t);
|
|
8979
|
-
if (
|
|
8979
|
+
if (de.isPlaying() || ae ? (me = !1, he = 0, ge = 0) : r >= Tm ? (ge = 0, he += 1, !me && he >= Em && (me = !0, c?.({ mode: "user-speaking" }))) : (he = 0, me && ++ge >= Dm && (me = !1, ge = 0, c?.({
|
|
8980
8980
|
mode: "thinking",
|
|
8981
8981
|
tentative: !0
|
|
8982
|
-
}))), (
|
|
8982
|
+
}))), (de.isPlaying() || ae) && !ie) {
|
|
8983
8983
|
if (r < oe) {
|
|
8984
8984
|
A = 0, n();
|
|
8985
8985
|
return;
|
|
8986
8986
|
}
|
|
8987
|
-
if (A += 1, A <
|
|
8987
|
+
if (A += 1, A < se) {
|
|
8988
8988
|
n();
|
|
8989
8989
|
return;
|
|
8990
8990
|
}
|
|
8991
8991
|
ie = !0, A = 0;
|
|
8992
|
-
let e =
|
|
8993
|
-
|
|
8992
|
+
let e = de.playedMs();
|
|
8993
|
+
de.stop(), re = !1, ae = !1, j && !ce && (clearTimeout(j), j = null), le = !1, C.send(JSON.stringify({
|
|
8994
8994
|
type: "VisitorInterrupted",
|
|
8995
8995
|
played_ms: Math.round(e)
|
|
8996
8996
|
})), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
|
|
8997
8997
|
}
|
|
8998
8998
|
C.send(km(t).buffer);
|
|
8999
|
-
},
|
|
9000
|
-
let
|
|
8999
|
+
}, fe.connect(pe), pe.connect(_.destination);
|
|
9000
|
+
let _e = () => {
|
|
9001
9001
|
if (!O) {
|
|
9002
|
-
O = !0,
|
|
9002
|
+
O = !0, j &&= (clearTimeout(j), null), D(), de.stop();
|
|
9003
9003
|
try {
|
|
9004
|
-
|
|
9004
|
+
pe.disconnect(), fe.disconnect();
|
|
9005
9005
|
} catch {}
|
|
9006
9006
|
if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
|
|
9007
9007
|
x.onstop = () => Pm(t, n, S, b, y);
|
|
@@ -9013,7 +9013,7 @@ async function Lm(e) {
|
|
|
9013
9013
|
} else b.length && Pm(t, n, S, b, y);
|
|
9014
9014
|
_.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
|
|
9015
9015
|
}
|
|
9016
|
-
},
|
|
9016
|
+
}, ve = async (e) => {
|
|
9017
9017
|
let t = i[e.name];
|
|
9018
9018
|
if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
|
|
9019
9019
|
let n = {};
|
|
@@ -9025,10 +9025,10 @@ async function Lm(e) {
|
|
|
9025
9025
|
} catch (e) {
|
|
9026
9026
|
return { error: e?.message || "Tool execution failed" };
|
|
9027
9027
|
}
|
|
9028
|
-
},
|
|
9028
|
+
}, M = async (e) => {
|
|
9029
9029
|
for (let t of e.functions || []) {
|
|
9030
9030
|
if (!t.client_side) continue;
|
|
9031
|
-
let e = await
|
|
9031
|
+
let e = await ve(t);
|
|
9032
9032
|
if (O || C.readyState !== WebSocket.OPEN) return;
|
|
9033
9033
|
C.send(JSON.stringify({
|
|
9034
9034
|
type: "FunctionCallResponse",
|
|
@@ -9037,10 +9037,10 @@ async function Lm(e) {
|
|
|
9037
9037
|
content: typeof e == "string" ? e : JSON.stringify(e ?? {})
|
|
9038
9038
|
}));
|
|
9039
9039
|
}
|
|
9040
|
-
},
|
|
9040
|
+
}, ye = (e) => {
|
|
9041
9041
|
switch (e.type) {
|
|
9042
9042
|
case "Welcome":
|
|
9043
|
-
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (oe = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (
|
|
9043
|
+
Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (oe = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (se = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
|
|
9044
9044
|
break;
|
|
9045
9045
|
case "ConversationText": {
|
|
9046
9046
|
let t = String(e.content || "");
|
|
@@ -9059,22 +9059,25 @@ async function Lm(e) {
|
|
|
9059
9059
|
break;
|
|
9060
9060
|
}
|
|
9061
9061
|
case "UserStartedSpeaking":
|
|
9062
|
-
D(),
|
|
9062
|
+
D(), de.stop(), ae = !1, re = !1, ne = !1, j && !ce && (clearTimeout(j), j = null), le = !1, c?.({ mode: "listening" });
|
|
9063
9063
|
break;
|
|
9064
9064
|
case "AgentStartedSpeaking":
|
|
9065
9065
|
re = !0, ne = !0, ie = !1, A = 0, c?.({ mode: "speaking" });
|
|
9066
9066
|
break;
|
|
9067
9067
|
case "AgentAudioDone":
|
|
9068
|
-
ae = !1, D(),
|
|
9068
|
+
ae = !1, D(), e.turnComplete === !0 && (le = !0), ue(), de.isPlaying() || (ne = !1, c?.({ mode: "listening" }));
|
|
9069
9069
|
break;
|
|
9070
9070
|
case "FunctionCallRequest":
|
|
9071
|
-
|
|
9071
|
+
M(e);
|
|
9072
9072
|
break;
|
|
9073
9073
|
case "AgentPreparing":
|
|
9074
9074
|
ae = !0;
|
|
9075
9075
|
break;
|
|
9076
|
+
case "AgentTurnComplete":
|
|
9077
|
+
le = !0, ue();
|
|
9078
|
+
break;
|
|
9076
9079
|
case "SessionEnding":
|
|
9077
|
-
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"),
|
|
9080
|
+
console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ce = !0;
|
|
9078
9081
|
break;
|
|
9079
9082
|
case "AgentThinking":
|
|
9080
9083
|
c?.({ mode: "thinking" });
|
|
@@ -9091,16 +9094,16 @@ async function Lm(e) {
|
|
|
9091
9094
|
};
|
|
9092
9095
|
return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
|
|
9093
9096
|
if (e.data instanceof ArrayBuffer) {
|
|
9094
|
-
re &&
|
|
9097
|
+
re && de.enqueue(new Int16Array(e.data));
|
|
9095
9098
|
return;
|
|
9096
9099
|
}
|
|
9097
9100
|
try {
|
|
9098
|
-
|
|
9101
|
+
ye(JSON.parse(e.data));
|
|
9099
9102
|
} catch {}
|
|
9100
9103
|
}, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
|
|
9101
|
-
|
|
9104
|
+
_e(), o?.();
|
|
9102
9105
|
}, {
|
|
9103
|
-
endSession: async () =>
|
|
9106
|
+
endSession: async () => _e(),
|
|
9104
9107
|
sendContextualUpdate: (e) => {
|
|
9105
9108
|
O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
|
|
9106
9109
|
type: "UpdatePrompt",
|
|
@@ -12104,10 +12107,10 @@ function xg(e) {
|
|
|
12104
12107
|
sender: "user",
|
|
12105
12108
|
message: e
|
|
12106
12109
|
}]);
|
|
12107
|
-
n &&
|
|
12110
|
+
n && N(t, n);
|
|
12108
12111
|
}
|
|
12109
12112
|
} catch {}
|
|
12110
|
-
|
|
12113
|
+
De();
|
|
12111
12114
|
let e = a;
|
|
12112
12115
|
try {
|
|
12113
12116
|
e = new URL(a, typeof window < "u" ? window.location.href : "").href;
|
|
@@ -12117,7 +12120,7 @@ function xg(e) {
|
|
|
12117
12120
|
let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
|
|
12118
12121
|
n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
|
|
12119
12122
|
} catch {}
|
|
12120
|
-
t && typeof window < "u" &&
|
|
12123
|
+
t && typeof window < "u" && I(t, window.location.href, e, n), gr(e), $("fwh-navigate-mvp → real navigation", a);
|
|
12121
12124
|
let i = typeof window < "u" && !!qn();
|
|
12122
12125
|
if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), i && Rn(12e3), br(a, { voiceActive: !0 }).catch(() => {}), i) try {
|
|
12123
12126
|
let e = new URL(a, window.location.origin).pathname, t = window.location.pathname, n = Date.now() + 2e3;
|
|
@@ -12835,72 +12838,72 @@ function Pg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
12835
12838
|
}
|
|
12836
12839
|
function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
|
|
12837
12840
|
c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
|
|
12838
|
-
let [T, E] = m("idle"), [D, ee] = m(!1), [O, k] = m(!1), [te, ne] = m(!1), [re, A] = m(""), [ie, ae] = m(""), oe = p(!1),
|
|
12839
|
-
|
|
12841
|
+
let [T, E] = m("idle"), [D, ee] = m(!1), [O, k] = m(!1), [te, ne] = m(!1), [re, A] = m(""), [ie, ae] = m(""), oe = p(!1), se = p(!1), j = p(null), ce = p(0), le = p(""), ue = p(!1), de = p(0), fe = p(!1), pe = p(!1), me = p(!1), he = p([]), ge = p(null), _e = (e) => {
|
|
12842
|
+
fe.current = e, e || (pe.current = !1), M.current?.setWalkthroughActive?.(e);
|
|
12840
12843
|
};
|
|
12841
|
-
|
|
12842
|
-
if (
|
|
12843
|
-
let e =
|
|
12844
|
-
|
|
12845
|
-
let t =
|
|
12844
|
+
ge.current = async () => {
|
|
12845
|
+
if (pe.current) return;
|
|
12846
|
+
let e = he.current;
|
|
12847
|
+
ve.current += 1;
|
|
12848
|
+
let t = ve.current, n = e[t];
|
|
12846
12849
|
if (!n) {
|
|
12847
|
-
|
|
12850
|
+
_e(!1), e.length && M.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
|
|
12848
12851
|
return;
|
|
12849
12852
|
}
|
|
12850
12853
|
try {
|
|
12851
12854
|
await toolsRef.current?.highlightOnPage?.({ section_text: n });
|
|
12852
12855
|
} catch {}
|
|
12853
|
-
console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`),
|
|
12856
|
+
console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`), M.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t === 0 ? "Starting with" : "Next —"} ${n}. 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; read the section's content silently first (fwh-read-content-mvp) if you don't already have it. 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 });
|
|
12854
12857
|
};
|
|
12855
|
-
let
|
|
12858
|
+
let ve = p(0), M = p(null), ye = p(""), be = p(async () => {}), xe = p(!1), Se = p(!1), Ce = p(!1), we = p(!1), P = p("minimized"), Oe = p(null), ke = p(null), F = p(null), Ae = p(0), Me = p(!1), I = p("idle"), L = p(null), Pe = p(!1), Fe = p(null), Ie = o((e = "minimized") => {
|
|
12856
12859
|
console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
|
|
12857
12860
|
destination: e,
|
|
12858
12861
|
stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
|
|
12859
|
-
}),
|
|
12860
|
-
|
|
12862
|
+
}), P.current = e, we.current = !0, queueMicrotask(() => {
|
|
12863
|
+
xe.current || (xe.current = !0, be.current?.());
|
|
12861
12864
|
});
|
|
12862
|
-
}, [l]),
|
|
12863
|
-
|
|
12865
|
+
}, [l]), Le = o(() => {
|
|
12866
|
+
j.current &&= (clearTimeout(j.current), null);
|
|
12864
12867
|
}, []);
|
|
12865
12868
|
c(() => {
|
|
12866
12869
|
if (y) {
|
|
12867
12870
|
oe.current = !1;
|
|
12868
12871
|
return;
|
|
12869
12872
|
}
|
|
12870
|
-
if (oe.current = !0,
|
|
12871
|
-
|
|
12872
|
-
let e =
|
|
12873
|
-
|
|
12874
|
-
}
|
|
12875
|
-
|
|
12876
|
-
}, [y,
|
|
12877
|
-
let
|
|
12878
|
-
|
|
12879
|
-
if (!(!
|
|
12880
|
-
|
|
12873
|
+
if (oe.current = !0, se.current = !1, ne(!1), Le(), ue.current) {
|
|
12874
|
+
ue.current = !1, M.current?.setMicMuted?.(!1);
|
|
12875
|
+
let e = le.current;
|
|
12876
|
+
le.current = "", M.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && M.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
|
|
12877
|
+
}
|
|
12878
|
+
M.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.");
|
|
12879
|
+
}, [y, Le]);
|
|
12880
|
+
let R = /(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, Re = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, ze = /^((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, Be = o(() => {
|
|
12881
|
+
Le(), j.current = setTimeout(() => {
|
|
12882
|
+
if (!(!se.current || oe.current)) if (ce.current < 3) {
|
|
12883
|
+
ce.current += 1;
|
|
12881
12884
|
try {
|
|
12882
|
-
|
|
12885
|
+
M.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
|
|
12883
12886
|
} catch {}
|
|
12884
|
-
|
|
12887
|
+
Be();
|
|
12885
12888
|
} else {
|
|
12886
12889
|
try {
|
|
12887
|
-
|
|
12890
|
+
M.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");
|
|
12888
12891
|
} catch {}
|
|
12889
|
-
|
|
12892
|
+
se.current = !1, ne(!1), Le(), Me.current = !0;
|
|
12890
12893
|
}
|
|
12891
12894
|
}, 1e4);
|
|
12892
|
-
}, [
|
|
12893
|
-
|
|
12895
|
+
}, [Le]), Ve = o(async (e) => {
|
|
12896
|
+
we.current = !0;
|
|
12894
12897
|
try {
|
|
12895
12898
|
On();
|
|
12896
12899
|
} catch {}
|
|
12897
12900
|
if (i) try {
|
|
12898
|
-
|
|
12901
|
+
Ne(i);
|
|
12899
12902
|
} catch {}
|
|
12900
12903
|
try {
|
|
12901
|
-
await
|
|
12904
|
+
await M.current?.endSession?.();
|
|
12902
12905
|
} catch {}
|
|
12903
|
-
let t =
|
|
12906
|
+
let t = Oe.current, n = ke.current;
|
|
12904
12907
|
if (t && s && a) {
|
|
12905
12908
|
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
12906
12909
|
fetch(`${a}/api/voice/save-chat-recording`, {
|
|
@@ -12914,8 +12917,8 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12914
12917
|
})
|
|
12915
12918
|
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
12916
12919
|
}
|
|
12917
|
-
if (
|
|
12918
|
-
|
|
12920
|
+
if (Oe.current = null, ke.current = null, M.current = null, E("idle"), ee(!1), xe.current = !1, wr(), i) try {
|
|
12921
|
+
Ee(i);
|
|
12919
12922
|
} catch {}
|
|
12920
12923
|
typeof u == "function" && await u(l.current), e?.();
|
|
12921
12924
|
}, [
|
|
@@ -12925,10 +12928,10 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12925
12928
|
s,
|
|
12926
12929
|
a
|
|
12927
12930
|
]);
|
|
12928
|
-
|
|
12929
|
-
|
|
12931
|
+
be.current = () => Ve(P.current === "chat" ? t : n), c(() => {
|
|
12932
|
+
Se.current = D;
|
|
12930
12933
|
}, [D]), c(() => {
|
|
12931
|
-
d &&
|
|
12934
|
+
d && Ie("chat");
|
|
12932
12935
|
}, [d]), c(() => {
|
|
12933
12936
|
let e = !1, o = null, c = null, d = null;
|
|
12934
12937
|
return (async () => {
|
|
@@ -12938,13 +12941,13 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12938
12941
|
}
|
|
12939
12942
|
try {
|
|
12940
12943
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
12941
|
-
l.current = [],
|
|
12944
|
+
l.current = [], ye.current = "", xe.current = !1, Ce.current = !1, we.current = !1, P.current = "minimized", Cr({ onBeforeNavigate: () => {
|
|
12942
12945
|
if (i && l.current.length > 0) try {
|
|
12943
12946
|
let e = Fh(l.current);
|
|
12944
|
-
e &&
|
|
12947
|
+
e && N(i, e);
|
|
12945
12948
|
} catch {}
|
|
12946
12949
|
if (!qn()) {
|
|
12947
|
-
let e =
|
|
12950
|
+
let e = Oe.current, t = ke.current;
|
|
12948
12951
|
if (e && s && a) try {
|
|
12949
12952
|
let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
|
|
12950
12953
|
chatId: s,
|
|
@@ -12957,24 +12960,24 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
12957
12960
|
headers: { "Content-Type": "application/json" },
|
|
12958
12961
|
body: r,
|
|
12959
12962
|
keepalive: !0
|
|
12960
|
-
}).catch(() => {}),
|
|
12963
|
+
}).catch(() => {}), Oe.current = null, ke.current = null;
|
|
12961
12964
|
} catch {}
|
|
12962
12965
|
}
|
|
12963
|
-
|
|
12966
|
+
De();
|
|
12964
12967
|
} });
|
|
12965
12968
|
let t = wg(xg({
|
|
12966
12969
|
siteId: i || null,
|
|
12967
12970
|
apiBaseUrl: a || null,
|
|
12968
12971
|
chatId: s || null,
|
|
12969
|
-
getLastUserVoiceText: () =>
|
|
12970
|
-
isWalkthroughActive: () =>
|
|
12972
|
+
getLastUserVoiceText: () => ye.current,
|
|
12973
|
+
isWalkthroughActive: () => fe.current && !pe.current,
|
|
12971
12974
|
requestEndSession: () => {
|
|
12972
|
-
|
|
12975
|
+
Me.current = !0;
|
|
12973
12976
|
},
|
|
12974
12977
|
requestEmailCollection: () => {
|
|
12975
|
-
b && (oe.current ||
|
|
12978
|
+
b && (oe.current || se.current || (se.current = !0, ce.current = 0, ne(!0), Be()));
|
|
12976
12979
|
}
|
|
12977
|
-
})), n = i ?
|
|
12980
|
+
})), n = i ? Te(i) : null, r = !!n?.transcript, u = i ? Ne(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
|
|
12978
12981
|
apiBaseUrl: a,
|
|
12979
12982
|
siteId: i,
|
|
12980
12983
|
chatId: s,
|
|
@@ -13005,142 +13008,142 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13005
13008
|
let e = f || "";
|
|
13006
13009
|
x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${w} page!`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
|
|
13007
13010
|
}
|
|
13008
|
-
let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, re = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, A = r && !p, ie = !1, ae = A ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null,
|
|
13011
|
+
let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, re = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, A = r && !p, ie = !1, ae = A ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, j = !1, be = !1, Ee = b && !!y && !me.current, F = await Rm.startSession({
|
|
13009
13012
|
...x,
|
|
13010
13013
|
onConnect: ({ conversationId: e }) => {
|
|
13011
|
-
|
|
13014
|
+
Oe.current = e, ke.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
13012
13015
|
},
|
|
13013
13016
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
13014
13017
|
onSessionInfo: ({ emailOnFile: e }) => {
|
|
13015
|
-
|
|
13018
|
+
me.current = !!e, e && (oe.current = !0, se.current = !1, ne(!1), Le(), console.log("[FlowEngage] email already on file per server — gate disabled"));
|
|
13016
13019
|
},
|
|
13017
13020
|
onAgentTurnEnd: () => {
|
|
13018
|
-
e ||
|
|
13021
|
+
e || fe.current && (pe.current || ue.current || setTimeout(() => ge.current?.(), 250));
|
|
13019
13022
|
},
|
|
13020
13023
|
onSessionEnding: () => {
|
|
13021
|
-
e ||
|
|
13024
|
+
e || Ie("minimized");
|
|
13022
13025
|
},
|
|
13023
13026
|
onModeChange: ({ mode: t, tentative: n }) => {
|
|
13024
13027
|
if (!e) {
|
|
13025
13028
|
if (t === "speaking") {
|
|
13026
|
-
|
|
13029
|
+
L.current &&= (clearTimeout(L.current), null), Fe.current &&= (clearTimeout(Fe.current), null), E("speaking"), I.current = "speaking", Pe.current = !1;
|
|
13027
13030
|
return;
|
|
13028
13031
|
}
|
|
13029
13032
|
if (t === "user-speaking") {
|
|
13033
|
+
if (Fe.current &&= (clearTimeout(Fe.current), null), I.current === "speaking") return;
|
|
13030
13034
|
try {
|
|
13031
13035
|
On();
|
|
13032
13036
|
} catch {}
|
|
13033
|
-
|
|
13034
|
-
R.current &&= (clearTimeout(R.current), null), je.current !== "listening" && (E("listening"), je.current = "listening");
|
|
13037
|
+
L.current &&= (clearTimeout(L.current), null), I.current !== "listening" && (E("listening"), I.current = "listening");
|
|
13035
13038
|
return;
|
|
13036
13039
|
}
|
|
13037
13040
|
if (t === "thinking") {
|
|
13038
|
-
if (
|
|
13039
|
-
E("thinking"),
|
|
13040
|
-
|
|
13041
|
+
if (L.current &&= (clearTimeout(L.current), null), Fe.current &&= (clearTimeout(Fe.current), null), I.current === "speaking") return;
|
|
13042
|
+
E("thinking"), I.current = "thinking", n && (Fe.current = setTimeout(() => {
|
|
13043
|
+
Fe.current = null, !(e || I.current !== "thinking") && (I.current = "listening", E("listening"));
|
|
13041
13044
|
}, 4e3));
|
|
13042
13045
|
return;
|
|
13043
13046
|
}
|
|
13044
|
-
if (
|
|
13045
|
-
|
|
13047
|
+
if (I.current = "listening", Me.current) {
|
|
13048
|
+
Me.current = !1, Ie();
|
|
13046
13049
|
return;
|
|
13047
13050
|
}
|
|
13048
|
-
if (
|
|
13049
|
-
|
|
13051
|
+
if (Ee && !be && !oe.current && !me.current) {
|
|
13052
|
+
be = !0, O = !0, te = !0;
|
|
13050
13053
|
try {
|
|
13051
|
-
|
|
13054
|
+
M.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
|
|
13052
13055
|
} catch {}
|
|
13053
13056
|
}
|
|
13054
13057
|
if (k && !O) {
|
|
13055
13058
|
O = !0;
|
|
13056
13059
|
try {
|
|
13057
|
-
|
|
13060
|
+
M.current?.sendContextualUpdate?.(k);
|
|
13058
13061
|
} catch {}
|
|
13059
13062
|
}
|
|
13060
13063
|
if (ae && !ie) {
|
|
13061
13064
|
ie = !0;
|
|
13062
13065
|
try {
|
|
13063
|
-
|
|
13066
|
+
M.current?.sendContextualUpdate?.(ae);
|
|
13064
13067
|
} catch {}
|
|
13065
13068
|
}
|
|
13066
13069
|
if (re && !te) {
|
|
13067
13070
|
te = !0;
|
|
13068
13071
|
try {
|
|
13069
|
-
|
|
13072
|
+
M.current?.sendContextualUpdate?.(re);
|
|
13070
13073
|
} catch {}
|
|
13071
13074
|
}
|
|
13072
|
-
|
|
13073
|
-
e ||
|
|
13075
|
+
L.current && clearTimeout(L.current), L.current = setTimeout(() => {
|
|
13076
|
+
e || I.current !== "speaking" && (Pe.current || (L.current = null, I.current = "listening", E("listening")));
|
|
13074
13077
|
}, 1200);
|
|
13075
13078
|
}
|
|
13076
13079
|
},
|
|
13077
13080
|
onMessage: (t) => {
|
|
13078
|
-
if (e ||
|
|
13079
|
-
if (t.role === "user" &&
|
|
13080
|
-
else if (t.role === "user" &&
|
|
13081
|
+
if (e || ue.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
|
|
13082
|
+
if (t.role === "user" && R.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), _e(!0), pe.current = !1, de.current = 0, ve.current = -1, he.current = Cg(), setTimeout(() => ge.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${he.current.length} sections on this page`);
|
|
13083
|
+
else if (t.role === "user" && fe.current) {
|
|
13081
13084
|
let e = String(t.message || "").trim();
|
|
13082
|
-
|
|
13085
|
+
ze.test(e) ? pe.current && (pe.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => ge.current?.(), 300)) : (pe.current = !0, console.debug("[FlowEngage] walkthrough paused — visitor interjected"));
|
|
13083
13086
|
}
|
|
13084
|
-
if (t.role !== "user" &&
|
|
13085
|
-
let e =
|
|
13086
|
-
!e ||
|
|
13087
|
+
if (t.role !== "user" && Re.test(String(t.message || ""))) {
|
|
13088
|
+
let e = he.current.length;
|
|
13089
|
+
!e || ve.current >= e - 1 ? _e(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${ve.current + 1}/${e} — ignoring, tour continues`);
|
|
13087
13090
|
}
|
|
13088
13091
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
13089
13092
|
if (r) {
|
|
13090
|
-
if (n === "user" && (
|
|
13093
|
+
if (n === "user" && (ye.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, L.current &&= (clearTimeout(L.current), null), I.current !== "speaking" && (E("thinking"), I.current = "thinking"), Ee && !j && !oe.current && !me.current && (j = !0, le.current = r, ue.current = !0, M.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), M.current?.setMicMuted?.(!0), se.current || (se.current = !0, ce.current = 0, ne(!0), Be()))), l.current = [...l.current, {
|
|
13091
13094
|
sender: n,
|
|
13092
13095
|
message: r,
|
|
13093
13096
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13094
13097
|
debug: t.debug
|
|
13095
13098
|
}], i) try {
|
|
13096
13099
|
let e = Fh(l.current);
|
|
13097
|
-
e &&
|
|
13100
|
+
e && N(i, e);
|
|
13098
13101
|
} catch {}
|
|
13099
13102
|
if (jg(n, r)) {
|
|
13100
|
-
|
|
13103
|
+
Me.current = !0;
|
|
13101
13104
|
return;
|
|
13102
13105
|
}
|
|
13103
|
-
if (
|
|
13104
|
-
|
|
13106
|
+
if (Se.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (Ae.current += 1, Ae.current === 2) try {
|
|
13107
|
+
M.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.");
|
|
13105
13108
|
} catch {}
|
|
13106
|
-
else
|
|
13109
|
+
else Ae.current >= 5 && Ie("minimized");
|
|
13107
13110
|
}
|
|
13108
13111
|
},
|
|
13109
13112
|
onError: (t) => {
|
|
13110
|
-
if (!e && !
|
|
13111
|
-
|
|
13113
|
+
if (!e && !we.current && !Ce.current && !je()) {
|
|
13114
|
+
Ce.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
13112
13115
|
message: t?.message,
|
|
13113
13116
|
name: t?.name,
|
|
13114
13117
|
raw: t
|
|
13115
13118
|
});
|
|
13116
13119
|
try {
|
|
13117
|
-
|
|
13120
|
+
M.current?.setMicMuted?.(!0);
|
|
13118
13121
|
} catch {}
|
|
13119
|
-
ee(!0), E("error"),
|
|
13122
|
+
ee(!0), E("error"), Ie("chat");
|
|
13120
13123
|
}
|
|
13121
13124
|
},
|
|
13122
13125
|
onDisconnect: (t) => {
|
|
13123
|
-
if (e ||
|
|
13126
|
+
if (e || we.current || Ce.current || je()) return;
|
|
13124
13127
|
let n = l.current?.length || 0;
|
|
13125
13128
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
13126
13129
|
historyCount: n,
|
|
13127
13130
|
reason: t?.reason,
|
|
13128
13131
|
closeCode: t?.context?.code,
|
|
13129
13132
|
closeReason: t?.context?.reason || t?.message,
|
|
13130
|
-
lastUserText:
|
|
13131
|
-
wasMuted:
|
|
13132
|
-
}),
|
|
13133
|
+
lastUserText: ye.current || "",
|
|
13134
|
+
wasMuted: Se.current
|
|
13135
|
+
}), Ce.current = !0;
|
|
13133
13136
|
try {
|
|
13134
|
-
|
|
13137
|
+
M.current?.setMicMuted?.(!0);
|
|
13135
13138
|
} catch {}
|
|
13136
|
-
ee(!0),
|
|
13139
|
+
ee(!0), Ie("chat");
|
|
13137
13140
|
}
|
|
13138
13141
|
});
|
|
13139
13142
|
if (e) {
|
|
13140
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
13143
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), F.endSession().catch(() => {});
|
|
13141
13144
|
return;
|
|
13142
13145
|
}
|
|
13143
|
-
o =
|
|
13146
|
+
o = F, M.current = F, E("listening");
|
|
13144
13147
|
try {
|
|
13145
13148
|
let e = typeof window < "u" ? window.location.href : "", a = "[]";
|
|
13146
13149
|
try {
|
|
@@ -13152,7 +13155,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13152
13155
|
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 && (o = [...new Set(n)].slice(0, 15).join(" | "));
|
|
13153
13156
|
} catch {}
|
|
13154
13157
|
let s = r && !p ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
|
|
13155
|
-
|
|
13158
|
+
F.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. 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. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
|
|
13156
13159
|
} catch {}
|
|
13157
13160
|
if (typeof window < "u") {
|
|
13158
13161
|
let t = window.location.pathname, n = Date.now(), r = (e) => {
|
|
@@ -13198,7 +13201,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13198
13201
|
ts: Date.now()
|
|
13199
13202
|
}), console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${D || "none"})`);
|
|
13200
13203
|
try {
|
|
13201
|
-
|
|
13204
|
+
M.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${d}" only.]`);
|
|
13202
13205
|
} catch {}
|
|
13203
13206
|
};
|
|
13204
13207
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
@@ -13206,7 +13209,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13206
13209
|
}, d = () => setTimeout(i, 50), window.addEventListener("popstate", d);
|
|
13207
13210
|
}
|
|
13208
13211
|
} catch (r) {
|
|
13209
|
-
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"),
|
|
13212
|
+
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"), P.current = "chat", window.setTimeout(() => {
|
|
13210
13213
|
e || t?.();
|
|
13211
13214
|
}, 0)));
|
|
13212
13215
|
}
|
|
@@ -13215,15 +13218,15 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13215
13218
|
agentId: r,
|
|
13216
13219
|
siteId: i,
|
|
13217
13220
|
apiBaseUrl: a
|
|
13218
|
-
}), e = !0,
|
|
13221
|
+
}), e = !0, we.current = !0;
|
|
13219
13222
|
try {
|
|
13220
13223
|
On();
|
|
13221
13224
|
} catch {}
|
|
13222
13225
|
if (i) try {
|
|
13223
|
-
|
|
13226
|
+
Ne(i);
|
|
13224
13227
|
} catch {}
|
|
13225
|
-
typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(),
|
|
13226
|
-
let t = o ||
|
|
13228
|
+
typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), L.current &&= (clearTimeout(L.current), null), Fe.current &&= (clearTimeout(Fe.current), null), j.current &&= (clearTimeout(j.current), null), Pe.current = !1, I.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
|
|
13229
|
+
let t = o || M.current, n = Oe.current, f = ke.current;
|
|
13227
13230
|
if (t?.endSession?.().catch(() => {}), n && s && a) {
|
|
13228
13231
|
let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
|
|
13229
13232
|
chatId: s,
|
|
@@ -13236,7 +13239,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13236
13239
|
headers: { "Content-Type": "application/json" },
|
|
13237
13240
|
body: t,
|
|
13238
13241
|
keepalive: !0
|
|
13239
|
-
}).catch(() => {}),
|
|
13242
|
+
}).catch(() => {}), Oe.current = null, ke.current = null;
|
|
13240
13243
|
}
|
|
13241
13244
|
typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
|
|
13242
13245
|
};
|
|
@@ -13244,53 +13247,53 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13244
13247
|
r,
|
|
13245
13248
|
i,
|
|
13246
13249
|
a,
|
|
13247
|
-
|
|
13250
|
+
Ie
|
|
13248
13251
|
]), c(() => {
|
|
13249
13252
|
if (!O) return;
|
|
13250
13253
|
let e = (e) => {
|
|
13251
13254
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
13252
|
-
|
|
13255
|
+
F.current && !F.current.contains(t) && k(!1);
|
|
13253
13256
|
};
|
|
13254
13257
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
13255
13258
|
}, [O]);
|
|
13256
|
-
let
|
|
13257
|
-
if (
|
|
13259
|
+
let He = async () => {
|
|
13260
|
+
if (M.current) try {
|
|
13258
13261
|
if (D) {
|
|
13259
|
-
|
|
13262
|
+
Ae.current = 0, await M.current.setMicMuted?.(!1), ee(!1);
|
|
13260
13263
|
try {
|
|
13261
|
-
|
|
13264
|
+
M.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
13262
13265
|
} catch {}
|
|
13263
13266
|
} else {
|
|
13264
|
-
|
|
13267
|
+
Ae.current = 0, await M.current.setMicMuted?.(!0), ee(!0);
|
|
13265
13268
|
try {
|
|
13266
|
-
|
|
13269
|
+
M.current.sendContextualUpdate?.("The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.");
|
|
13267
13270
|
} catch {}
|
|
13268
13271
|
}
|
|
13269
13272
|
} catch {}
|
|
13270
|
-
},
|
|
13273
|
+
}, Ue = o(async (e) => {
|
|
13271
13274
|
e?.preventDefault?.();
|
|
13272
13275
|
let t = re.trim().toLowerCase();
|
|
13273
13276
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
|
|
13274
13277
|
ae("Please enter a valid email address.");
|
|
13275
13278
|
return;
|
|
13276
13279
|
}
|
|
13277
|
-
ae(""), oe.current = !0,
|
|
13280
|
+
ae(""), oe.current = !0, se.current = !1, Le(), ne(!1), A(""), ue.current = !1;
|
|
13278
13281
|
try {
|
|
13279
13282
|
typeof v == "function" && await v(t);
|
|
13280
13283
|
} catch {}
|
|
13281
|
-
|
|
13282
|
-
let n =
|
|
13283
|
-
|
|
13284
|
+
M.current?.setMicMuted?.(!1);
|
|
13285
|
+
let n = le.current;
|
|
13286
|
+
le.current = "";
|
|
13284
13287
|
try {
|
|
13285
|
-
|
|
13288
|
+
M.current?.injectAgentSpeech?.("Thank you for submitting your email."), M.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
|
|
13286
13289
|
} catch {}
|
|
13287
13290
|
}, [
|
|
13288
13291
|
re,
|
|
13289
13292
|
v,
|
|
13290
|
-
|
|
13291
|
-
]),
|
|
13293
|
+
Le
|
|
13294
|
+
]), We = Array.isArray(e) && e[0] || "#3B82F6";
|
|
13292
13295
|
return /* @__PURE__ */ _("div", {
|
|
13293
|
-
ref:
|
|
13296
|
+
ref: F,
|
|
13294
13297
|
style: {
|
|
13295
13298
|
position: "relative",
|
|
13296
13299
|
display: "flex",
|
|
@@ -13301,7 +13304,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13301
13304
|
},
|
|
13302
13305
|
children: [
|
|
13303
13306
|
te && /* @__PURE__ */ _("form", {
|
|
13304
|
-
onSubmit:
|
|
13307
|
+
onSubmit: Ue,
|
|
13305
13308
|
style: {
|
|
13306
13309
|
width: "270px",
|
|
13307
13310
|
maxWidth: "calc(100vw - 40px)",
|
|
@@ -13364,7 +13367,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13364
13367
|
padding: "10px 12px",
|
|
13365
13368
|
borderRadius: "10px",
|
|
13366
13369
|
border: "none",
|
|
13367
|
-
background: re.trim() ?
|
|
13370
|
+
background: re.trim() ? We : "#374151",
|
|
13368
13371
|
color: "white",
|
|
13369
13372
|
fontSize: "14px",
|
|
13370
13373
|
fontWeight: 600,
|
|
@@ -13433,7 +13436,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13433
13436
|
alignItems: "center"
|
|
13434
13437
|
},
|
|
13435
13438
|
children: [/* @__PURE__ */ g("button", {
|
|
13436
|
-
onClick:
|
|
13439
|
+
onClick: He,
|
|
13437
13440
|
title: D ? "Unmute" : "Mute",
|
|
13438
13441
|
style: {
|
|
13439
13442
|
width: "24px",
|
|
@@ -13528,7 +13531,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13528
13531
|
children: [
|
|
13529
13532
|
/* @__PURE__ */ _("button", {
|
|
13530
13533
|
onClick: () => {
|
|
13531
|
-
k(!1),
|
|
13534
|
+
k(!1), P.current = "chat", Ve(t);
|
|
13532
13535
|
},
|
|
13533
13536
|
style: {
|
|
13534
13537
|
display: "flex",
|
|
@@ -13557,7 +13560,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
13557
13560
|
}),
|
|
13558
13561
|
/* @__PURE__ */ _("button", {
|
|
13559
13562
|
onClick: () => {
|
|
13560
|
-
k(!1),
|
|
13563
|
+
k(!1), P.current = "minimized", Ve(n);
|
|
13561
13564
|
},
|
|
13562
13565
|
style: {
|
|
13563
13566
|
display: "flex",
|
|
@@ -13683,54 +13686,54 @@ var Lg = () => /* @__PURE__ */ g("div", {
|
|
|
13683
13686
|
} }, e))
|
|
13684
13687
|
})
|
|
13685
13688
|
});
|
|
13686
|
-
function Rg({ 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: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: ae, emailCaptureSuccess: oe, replyContext:
|
|
13687
|
-
let
|
|
13689
|
+
function Rg({ 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: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: ae, emailCaptureSuccess: oe, replyContext: se, setReplyContext: j, webRTCError: ce, micError: le, setMicError: ue, dismissCallError: de, activeCallId: fe, isCallMuted: pe, toggleCallMute: me, endWebRTCCall: he, formatCallDuration: ge, callDurationSeconds: _e, isCallMinimized: ve, onExpand: M, onCollapse: ye, onStartVoice: be, voiceEnabled: xe, headerBgColor: Se, onNewChat: Ce, showPoweredBy: we, privacyPolicyUrl: N, getVisitorChatHistory: Te, resumeChat: Ee, isSessionRestoring: P, isClosing: De }) {
|
|
13690
|
+
let Oe = l.length > 0, ke = T || E || w, F = !!fe, [Ae, je] = m(!1), [Me, I] = m(!1), [Ne, L] = m([]), [Pe, Fe] = m(!1), Ie = p(null), [Le, R] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Re, ze] = m(0);
|
|
13688
13691
|
c(() => {
|
|
13689
13692
|
if (!s) return;
|
|
13690
13693
|
let e = window.visualViewport;
|
|
13691
13694
|
if (!e) return;
|
|
13692
13695
|
let t = () => {
|
|
13693
|
-
|
|
13696
|
+
R(e.height), ze(Math.max(0, window.innerHeight - e.offsetTop - e.height));
|
|
13694
13697
|
};
|
|
13695
13698
|
return e.addEventListener("resize", t), e.addEventListener("scroll", t), t(), () => {
|
|
13696
13699
|
e.removeEventListener("resize", t), e.removeEventListener("scroll", t);
|
|
13697
13700
|
};
|
|
13698
13701
|
}, [s]);
|
|
13699
|
-
let
|
|
13700
|
-
|
|
13702
|
+
let Be = s && window.innerHeight - Le > 150, Ve = async () => {
|
|
13703
|
+
je(!1), I(!0), Fe(!0);
|
|
13701
13704
|
try {
|
|
13702
|
-
let e = await
|
|
13703
|
-
e?.data &&
|
|
13705
|
+
let e = await Te();
|
|
13706
|
+
e?.data && L(e.data);
|
|
13704
13707
|
} catch (e) {
|
|
13705
13708
|
console.error(e);
|
|
13706
13709
|
} finally {
|
|
13707
|
-
|
|
13710
|
+
Fe(!1);
|
|
13708
13711
|
}
|
|
13709
|
-
},
|
|
13710
|
-
|
|
13712
|
+
}, He = async (e) => {
|
|
13713
|
+
I(!1), Ee?.(e.chatId);
|
|
13711
13714
|
};
|
|
13712
13715
|
return c(() => {
|
|
13713
|
-
if (!
|
|
13716
|
+
if (!Ae) return;
|
|
13714
13717
|
let e = (e) => {
|
|
13715
13718
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
13716
|
-
|
|
13719
|
+
Ie.current && !Ie.current.contains(t) && je(!1);
|
|
13717
13720
|
};
|
|
13718
13721
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
13719
|
-
}, [
|
|
13722
|
+
}, [Ae]), /* @__PURE__ */ _("div", {
|
|
13720
13723
|
style: s ? {
|
|
13721
13724
|
"--flowengage-primary": n,
|
|
13722
13725
|
"--flowengage-accent": n,
|
|
13723
13726
|
position: "fixed",
|
|
13724
13727
|
left: "0",
|
|
13725
13728
|
right: "0",
|
|
13726
|
-
bottom: `${
|
|
13727
|
-
height:
|
|
13729
|
+
bottom: `${Re}px`,
|
|
13730
|
+
height: Le > 0 ? `${Math.round(Le * (Be ? 1 : .92))}px` : "90dvh",
|
|
13728
13731
|
background: r,
|
|
13729
13732
|
borderRadius: "16px 16px 0 0",
|
|
13730
13733
|
display: "flex",
|
|
13731
13734
|
flexDirection: "column",
|
|
13732
13735
|
overflow: "hidden",
|
|
13733
|
-
animation:
|
|
13736
|
+
animation: De ? "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)"
|
|
13734
13737
|
} : {
|
|
13735
13738
|
"--flowengage-primary": n,
|
|
13736
13739
|
"--flowengage-accent": n,
|
|
@@ -13743,7 +13746,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13743
13746
|
flexDirection: "column",
|
|
13744
13747
|
overflow: "hidden",
|
|
13745
13748
|
position: "relative",
|
|
13746
|
-
animation:
|
|
13749
|
+
animation: De ? "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)"
|
|
13747
13750
|
},
|
|
13748
13751
|
children: [
|
|
13749
13752
|
/* @__PURE__ */ _("div", {
|
|
@@ -13753,7 +13756,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13753
13756
|
alignItems: "center",
|
|
13754
13757
|
columnGap: "14px",
|
|
13755
13758
|
padding: "16px 10px 14px",
|
|
13756
|
-
background:
|
|
13759
|
+
background: Se || "transparent",
|
|
13757
13760
|
flexShrink: 0,
|
|
13758
13761
|
position: "relative",
|
|
13759
13762
|
zIndex: 30
|
|
@@ -13766,7 +13769,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13766
13769
|
alignItems: "center"
|
|
13767
13770
|
},
|
|
13768
13771
|
children: /* @__PURE__ */ g("button", {
|
|
13769
|
-
onClick:
|
|
13772
|
+
onClick: ye,
|
|
13770
13773
|
style: {
|
|
13771
13774
|
width: "40px",
|
|
13772
13775
|
height: "40px",
|
|
@@ -13868,10 +13871,10 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13868
13871
|
isolation: "isolate",
|
|
13869
13872
|
zIndex: 10
|
|
13870
13873
|
},
|
|
13871
|
-
ref:
|
|
13874
|
+
ref: Ie,
|
|
13872
13875
|
children: [/* @__PURE__ */ g("button", {
|
|
13873
13876
|
type: "button",
|
|
13874
|
-
onClick: () =>
|
|
13877
|
+
onClick: () => je((e) => !e),
|
|
13875
13878
|
style: {
|
|
13876
13879
|
width: "40px",
|
|
13877
13880
|
height: "40px",
|
|
@@ -13917,7 +13920,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13917
13920
|
})
|
|
13918
13921
|
]
|
|
13919
13922
|
})
|
|
13920
|
-
}),
|
|
13923
|
+
}), Ae && /* @__PURE__ */ _("div", {
|
|
13921
13924
|
style: {
|
|
13922
13925
|
position: "absolute",
|
|
13923
13926
|
top: "34px",
|
|
@@ -13933,10 +13936,10 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13933
13936
|
animation: "fe-orb-fade-in 0.18s ease"
|
|
13934
13937
|
},
|
|
13935
13938
|
children: [
|
|
13936
|
-
|
|
13939
|
+
xe && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
|
|
13937
13940
|
type: "button",
|
|
13938
13941
|
onClick: () => {
|
|
13939
|
-
|
|
13942
|
+
je(!1), be?.();
|
|
13940
13943
|
},
|
|
13941
13944
|
style: {
|
|
13942
13945
|
display: "flex",
|
|
@@ -13978,7 +13981,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
13978
13981
|
/* @__PURE__ */ _("button", {
|
|
13979
13982
|
type: "button",
|
|
13980
13983
|
onClick: () => {
|
|
13981
|
-
|
|
13984
|
+
je(!1), Ce?.();
|
|
13982
13985
|
},
|
|
13983
13986
|
style: {
|
|
13984
13987
|
display: "flex",
|
|
@@ -14013,13 +14016,13 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14013
14016
|
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" })]
|
|
14014
14017
|
}), "Start new chat"]
|
|
14015
14018
|
}),
|
|
14016
|
-
|
|
14019
|
+
Te && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
|
|
14017
14020
|
height: "1px",
|
|
14018
14021
|
background: "rgba(255,255,255,0.07)",
|
|
14019
14022
|
margin: "0 14px"
|
|
14020
14023
|
} }), /* @__PURE__ */ _("button", {
|
|
14021
14024
|
type: "button",
|
|
14022
|
-
onClick:
|
|
14025
|
+
onClick: Ve,
|
|
14023
14026
|
style: {
|
|
14024
14027
|
display: "flex",
|
|
14025
14028
|
alignItems: "center",
|
|
@@ -14061,7 +14064,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14061
14064
|
/* @__PURE__ */ _("button", {
|
|
14062
14065
|
type: "button",
|
|
14063
14066
|
onClick: () => {
|
|
14064
|
-
|
|
14067
|
+
je(!1), ye?.();
|
|
14065
14068
|
},
|
|
14066
14069
|
style: {
|
|
14067
14070
|
display: "flex",
|
|
@@ -14120,23 +14123,23 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14120
14123
|
]
|
|
14121
14124
|
}),
|
|
14122
14125
|
/* @__PURE__ */ g(_h, {
|
|
14123
|
-
webRTCError:
|
|
14124
|
-
micError:
|
|
14125
|
-
setMicError:
|
|
14126
|
-
dismissCallError:
|
|
14126
|
+
webRTCError: ce,
|
|
14127
|
+
micError: le,
|
|
14128
|
+
setMicError: ue,
|
|
14129
|
+
dismissCallError: de,
|
|
14127
14130
|
isRateLimited: E,
|
|
14128
14131
|
rateLimitMessage: D
|
|
14129
14132
|
}),
|
|
14130
|
-
|
|
14133
|
+
ve && /* @__PURE__ */ g(Ph, {
|
|
14131
14134
|
agentName: v,
|
|
14132
14135
|
agentHeadshot: y,
|
|
14133
14136
|
fallbackAgentName: b,
|
|
14134
|
-
callDurationSeconds:
|
|
14135
|
-
isCallMuted:
|
|
14136
|
-
formatCallDuration:
|
|
14137
|
-
toggleCallMute:
|
|
14138
|
-
endWebRTCCall:
|
|
14139
|
-
onExpand:
|
|
14137
|
+
callDurationSeconds: _e,
|
|
14138
|
+
isCallMuted: pe,
|
|
14139
|
+
formatCallDuration: ge,
|
|
14140
|
+
toggleCallMute: me,
|
|
14141
|
+
endWebRTCCall: he,
|
|
14142
|
+
onExpand: M,
|
|
14140
14143
|
primaryColor: n
|
|
14141
14144
|
}),
|
|
14142
14145
|
/* @__PURE__ */ _("div", {
|
|
@@ -14148,7 +14151,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14148
14151
|
background: "transparent",
|
|
14149
14152
|
position: "relative"
|
|
14150
14153
|
},
|
|
14151
|
-
children: [
|
|
14154
|
+
children: [Me ? /* @__PURE__ */ _("div", {
|
|
14152
14155
|
style: {
|
|
14153
14156
|
position: "absolute",
|
|
14154
14157
|
inset: 0,
|
|
@@ -14167,7 +14170,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14167
14170
|
flexShrink: 0
|
|
14168
14171
|
},
|
|
14169
14172
|
children: /* @__PURE__ */ _("button", {
|
|
14170
|
-
onClick: () =>
|
|
14173
|
+
onClick: () => I(!1),
|
|
14171
14174
|
style: {
|
|
14172
14175
|
background: "none",
|
|
14173
14176
|
border: "none",
|
|
@@ -14201,7 +14204,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14201
14204
|
overflowY: "auto",
|
|
14202
14205
|
position: "relative"
|
|
14203
14206
|
},
|
|
14204
|
-
children:
|
|
14207
|
+
children: Pe ? /* @__PURE__ */ g("div", {
|
|
14205
14208
|
style: {
|
|
14206
14209
|
padding: "40px 20px",
|
|
14207
14210
|
textAlign: "center",
|
|
@@ -14209,8 +14212,8 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14209
14212
|
fontSize: "14px"
|
|
14210
14213
|
},
|
|
14211
14214
|
children: "Loading past conversations..."
|
|
14212
|
-
}) :
|
|
14213
|
-
onClick: () =>
|
|
14215
|
+
}) : Ne.length > 0 ? /* @__PURE__ */ g("div", { children: Ne.map((e) => /* @__PURE__ */ _("div", {
|
|
14216
|
+
onClick: () => He(e),
|
|
14214
14217
|
style: {
|
|
14215
14218
|
padding: "16px 20px",
|
|
14216
14219
|
borderBottom: "1px solid #f3f4f6",
|
|
@@ -14261,18 +14264,18 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14261
14264
|
children: "No previous chats found."
|
|
14262
14265
|
})
|
|
14263
14266
|
})]
|
|
14264
|
-
}) : null,
|
|
14267
|
+
}) : null, Oe ? /* @__PURE__ */ g(mh, {
|
|
14265
14268
|
chatHistory: l,
|
|
14266
14269
|
isAiTyping: u,
|
|
14267
14270
|
isLoading: T,
|
|
14268
14271
|
isAgentTyping: d,
|
|
14269
|
-
setReplyContext:
|
|
14272
|
+
setReplyContext: j,
|
|
14270
14273
|
TypingDots: Lg,
|
|
14271
14274
|
primaryColor: n,
|
|
14272
14275
|
agentHeadshot: y,
|
|
14273
14276
|
agentDisplayName: v || b,
|
|
14274
14277
|
botAvatarNode: /* @__PURE__ */ g(Ig, { orbColors: t })
|
|
14275
|
-
}) :
|
|
14278
|
+
}) : P ? /* @__PURE__ */ _("div", {
|
|
14276
14279
|
style: {
|
|
14277
14280
|
flex: 1,
|
|
14278
14281
|
display: "flex",
|
|
@@ -14408,13 +14411,13 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14408
14411
|
setInput: S,
|
|
14409
14412
|
onSubmit: C,
|
|
14410
14413
|
isConversationEnded: w,
|
|
14411
|
-
callUiActive:
|
|
14412
|
-
handleToggleVoice:
|
|
14414
|
+
callUiActive: F,
|
|
14415
|
+
handleToggleVoice: be,
|
|
14413
14416
|
showVoiceToggle: f === "agent",
|
|
14414
14417
|
activeScreen: f,
|
|
14415
|
-
inputDisabled:
|
|
14416
|
-
replyContext:
|
|
14417
|
-
clearReplyContext: () =>
|
|
14418
|
+
inputDisabled: ke,
|
|
14419
|
+
replyContext: se,
|
|
14420
|
+
clearReplyContext: () => j(null),
|
|
14418
14421
|
onFileSelect: O,
|
|
14419
14422
|
selectedFile: ee,
|
|
14420
14423
|
onRemoveSelectedFile: k,
|
|
@@ -14427,7 +14430,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14427
14430
|
inputPlaceholder: e.inputPlaceholder
|
|
14428
14431
|
})
|
|
14429
14432
|
}),
|
|
14430
|
-
!
|
|
14433
|
+
!Be && /* @__PURE__ */ _("div", {
|
|
14431
14434
|
style: {
|
|
14432
14435
|
flexShrink: 0,
|
|
14433
14436
|
textAlign: "center",
|
|
@@ -14435,7 +14438,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14435
14438
|
paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
|
|
14436
14439
|
pointerEvents: "none"
|
|
14437
14440
|
},
|
|
14438
|
-
children: [
|
|
14441
|
+
children: [N && /* @__PURE__ */ _("p", {
|
|
14439
14442
|
style: {
|
|
14440
14443
|
margin: "0 0 4px",
|
|
14441
14444
|
fontSize: "10px",
|
|
@@ -14448,7 +14451,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14448
14451
|
"This conversation is recorded for quality assurance purposes.",
|
|
14449
14452
|
" ",
|
|
14450
14453
|
/* @__PURE__ */ g("a", {
|
|
14451
|
-
href:
|
|
14454
|
+
href: N,
|
|
14452
14455
|
target: "_blank",
|
|
14453
14456
|
rel: "noopener noreferrer",
|
|
14454
14457
|
style: {
|
|
@@ -14458,7 +14461,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14458
14461
|
children: "See our privacy policy"
|
|
14459
14462
|
})
|
|
14460
14463
|
]
|
|
14461
|
-
}),
|
|
14464
|
+
}), we && /* @__PURE__ */ _("span", {
|
|
14462
14465
|
style: {
|
|
14463
14466
|
fontSize: "11px",
|
|
14464
14467
|
color: "#9ca3af",
|
|
@@ -14478,162 +14481,162 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
14478
14481
|
});
|
|
14479
14482
|
}
|
|
14480
14483
|
function zg() {
|
|
14481
|
-
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: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode:
|
|
14484
|
+
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: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode: se, endConversation: j, startNewChat: ue, acceptCall: de, rejectCall: fe, endWebRTCCall: pe, toggleCallMute: me, dismissCallError: he, startTyping: ge, stopTyping: _e, updateTypingDraft: ve, getVisitorChatHistory: M, resumeChat: ye, isSessionRestoring: be, openToChatCounter: xe, voiceEndCounter: Se } = Cn();
|
|
14482
14485
|
c(() => {
|
|
14483
14486
|
try {
|
|
14484
14487
|
or();
|
|
14485
14488
|
} catch {}
|
|
14486
14489
|
}, []), c(() => {
|
|
14487
|
-
|
|
14488
|
-
}, [
|
|
14489
|
-
let
|
|
14490
|
-
...
|
|
14491
|
-
...
|
|
14492
|
-
},
|
|
14493
|
-
...
|
|
14494
|
-
...
|
|
14495
|
-
},
|
|
14496
|
-
...
|
|
14497
|
-
...
|
|
14498
|
-
},
|
|
14490
|
+
xe && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (se?.(!1), H("text_chat"));
|
|
14491
|
+
}, [xe]);
|
|
14492
|
+
let Ce = t?.widgetSettings || {}, we = n?.widgetSettings || {}, N = {
|
|
14493
|
+
...Ce.branding || {},
|
|
14494
|
+
...we.branding || {}
|
|
14495
|
+
}, P = {
|
|
14496
|
+
...Ce.theme || {},
|
|
14497
|
+
...we.theme || {}
|
|
14498
|
+
}, De = {
|
|
14499
|
+
...Ce.features || {},
|
|
14500
|
+
...we.features || {}
|
|
14501
|
+
}, ke = De.voice !== !1, F = Array.isArray(P.orbColors) && P.orbColors.length > 0 ? P.orbColors : null, je = P.buttonColor || P.primaryColor || F?.[0] || "#3B82F6", Me = {
|
|
14499
14502
|
small: 50,
|
|
14500
14503
|
medium: 64,
|
|
14501
14504
|
large: 80
|
|
14502
|
-
},
|
|
14505
|
+
}, I = Me[P.orbSize] || Me.small, Ne = P.position || "bottom-right", L = N.fallbackAgentName || "Agent", Pe = Eg(F ?? P.chatBgColors), Fe = N.logo || N.logoUrl || null, Ie = k || "en", Le = Ce.recommendations?.[Ie] || [], R = (we.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
14503
14506
|
id: e.key || `qr-${t}`,
|
|
14504
14507
|
label: e.label,
|
|
14505
14508
|
message: e.label,
|
|
14506
14509
|
text: e.label
|
|
14507
|
-
})),
|
|
14510
|
+
})), Re = Array.isArray(N.quickChatOptions) && N.quickChatOptions.length > 0 ? N.quickChatOptions : R, ze = N.hideWatermark === !0 ? !1 : N.showPoweredBy !== !1, Be = N.headerBgColor || null, Ve = P.bottomPosition == null ? "1.5rem" : `${P.bottomPosition}px`, He = N.privacyPolicyUrl || null, Ue = N.chatbotEnabled !== !1 && P.chatbotEnabled !== !1, [We, Ge] = m(() => typeof window < "u" ? window.location.pathname : "/");
|
|
14508
14511
|
c(() => {
|
|
14509
14512
|
if (typeof window > "u") return;
|
|
14510
|
-
let e = () =>
|
|
14513
|
+
let e = () => Ge(window.location.pathname), t = window.history.pushState.bind(window.history);
|
|
14511
14514
|
return window.history.pushState = (...n) => {
|
|
14512
14515
|
t(...n), setTimeout(e, 50);
|
|
14513
14516
|
}, window.addEventListener("popstate", e), () => {
|
|
14514
14517
|
window.history.pushState = t, window.removeEventListener("popstate", e);
|
|
14515
14518
|
};
|
|
14516
14519
|
}, []);
|
|
14517
|
-
let
|
|
14520
|
+
let Ke = (() => {
|
|
14518
14521
|
let e = {
|
|
14519
|
-
...
|
|
14520
|
-
...
|
|
14522
|
+
...Ce.pageVisibility || {},
|
|
14523
|
+
...we.pageVisibility || {}
|
|
14521
14524
|
};
|
|
14522
14525
|
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
14523
|
-
})(),
|
|
14524
|
-
entryPrompt:
|
|
14525
|
-
yesLabel:
|
|
14526
|
-
laterLabel:
|
|
14527
|
-
connectionTitle:
|
|
14528
|
-
connectionSubtitle:
|
|
14529
|
-
voiceLabel:
|
|
14530
|
-
textLabel:
|
|
14531
|
-
chatTitle:
|
|
14532
|
-
hasCustomTitle: !!(
|
|
14533
|
-
introGreeting:
|
|
14534
|
-
inputPlaceholder:
|
|
14535
|
-
analysingLabel:
|
|
14536
|
-
},
|
|
14526
|
+
})(), qe = Ke.length === 0 || Ke.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? We.startsWith(e.slice(0, -1)) : We.replace(/\/$/, "") === e.replace(/\/$/, "")), Je = Ce.greetings?.[k] || we.greetings?.[k] || N.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
|
|
14527
|
+
entryPrompt: N.entryPrompt || "Do you want to explore in a new way?",
|
|
14528
|
+
yesLabel: N.yesLabel || "Yes",
|
|
14529
|
+
laterLabel: N.laterLabel || "Later",
|
|
14530
|
+
connectionTitle: N.connectionTitle || "How would you like to connect?",
|
|
14531
|
+
connectionSubtitle: N.connectionSubtitle || "",
|
|
14532
|
+
voiceLabel: N.voiceLabel || "Voice",
|
|
14533
|
+
textLabel: N.textLabel || "Text",
|
|
14534
|
+
chatTitle: N.headerName || "Chat with FlowEngage",
|
|
14535
|
+
hasCustomTitle: !!(N.headerName && String(N.headerName).trim()),
|
|
14536
|
+
introGreeting: Je,
|
|
14537
|
+
inputPlaceholder: N.inputPlaceholder || "Type your message",
|
|
14538
|
+
analysingLabel: N.analysingLabel || "analysing..."
|
|
14539
|
+
}, Xe = we.elevenLabsAgentId || t?.elevenLabsAgentId || null, z = t?.siteId || n?.siteId || null, B = t?.apiBaseUrl || "";
|
|
14537
14540
|
c(() => {
|
|
14538
14541
|
Kn(t?.siteType || null);
|
|
14539
14542
|
}, [t?.siteType]);
|
|
14540
|
-
let
|
|
14543
|
+
let Ze = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
|
|
14541
14544
|
l,
|
|
14542
14545
|
t?.ownerName,
|
|
14543
14546
|
t?.websiteName
|
|
14544
|
-
]),
|
|
14547
|
+
]), Qe = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, $e = r.some((e) => e.sender === "user"), et = f(() => {
|
|
14545
14548
|
let e = r.findIndex((e) => e.sender === "user");
|
|
14546
14549
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
14547
|
-
}, [r]),
|
|
14550
|
+
}, [r]), tt = !!(we._dashboardLivePreview || Ce._dashboardLivePreview), [V, H] = m(() => tt ? "text_chat" : "entry_prompt"), [nt, rt] = m(""), [it, U] = m(null), [at, ot] = m(h || ""), [W, st] = m(""), [ct, 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 && $e && et && V !== "voice_mode";
|
|
14548
14551
|
d(() => {
|
|
14549
|
-
if (e !== "ready" ||
|
|
14550
|
-
if (
|
|
14551
|
-
|
|
14552
|
+
if (e !== "ready" || Tt.current) return;
|
|
14553
|
+
if (Tt.current = !0, !ke) {
|
|
14554
|
+
H("minimized_orb");
|
|
14552
14555
|
return;
|
|
14553
14556
|
}
|
|
14554
14557
|
let t = !1;
|
|
14555
14558
|
try {
|
|
14556
14559
|
t = vr().shouldResumeVoice;
|
|
14557
14560
|
} catch {}
|
|
14558
|
-
let n =
|
|
14561
|
+
let n = Oe(), r = z ? Te(z) : null, i = n || !!r?.transcript;
|
|
14559
14562
|
if (t) {
|
|
14560
|
-
ae?.({ notifyChatInitiated: !0 }),
|
|
14563
|
+
ae?.({ notifyChatInitiated: !0 }), se?.(!0), H("voice_mode");
|
|
14561
14564
|
return;
|
|
14562
14565
|
}
|
|
14563
|
-
if (
|
|
14564
|
-
ae?.({ notifyChatInitiated: !1 }),
|
|
14566
|
+
if (Ae()) {
|
|
14567
|
+
ae?.({ notifyChatInitiated: !1 }), H("text_chat");
|
|
14565
14568
|
return;
|
|
14566
14569
|
}
|
|
14567
14570
|
if (i) {
|
|
14568
14571
|
if ((typeof performance < "u" ? performance.getEntriesByType?.("navigation")?.[0]?.type ?? "navigate" : "navigate") === "reload") {
|
|
14569
|
-
|
|
14572
|
+
H("minimized_orb");
|
|
14570
14573
|
return;
|
|
14571
14574
|
}
|
|
14572
|
-
ae?.({ notifyChatInitiated: !0 }),
|
|
14575
|
+
ae?.({ notifyChatInitiated: !0 }), se?.(!0), H("voice_mode");
|
|
14573
14576
|
return;
|
|
14574
14577
|
}
|
|
14575
|
-
if (
|
|
14576
|
-
|
|
14578
|
+
if (z) try {
|
|
14579
|
+
Ee(z);
|
|
14577
14580
|
} catch {}
|
|
14578
|
-
if (
|
|
14579
|
-
|
|
14581
|
+
if (ce(z)) {
|
|
14582
|
+
H("minimized_orb");
|
|
14580
14583
|
return;
|
|
14581
14584
|
}
|
|
14582
14585
|
}, [e, r]);
|
|
14583
|
-
let [
|
|
14586
|
+
let [G, Dt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
|
|
14584
14587
|
c(() => {
|
|
14585
14588
|
let e = window.matchMedia("(max-width: 640px)"), t = (e) => Dt(e.matches);
|
|
14586
14589
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
14587
14590
|
}, []), c(() => {
|
|
14588
|
-
|
|
14591
|
+
ot(h || ""), h && st("");
|
|
14589
14592
|
}, [h]);
|
|
14590
14593
|
let Ot = o(() => {
|
|
14591
|
-
|
|
14594
|
+
ht(null), _t("");
|
|
14592
14595
|
}, []), kt = o((e) => {
|
|
14593
14596
|
let t = lh(e);
|
|
14594
14597
|
if (t) {
|
|
14595
|
-
|
|
14598
|
+
ht(null), _t(t);
|
|
14596
14599
|
return;
|
|
14597
14600
|
}
|
|
14598
|
-
|
|
14601
|
+
ht(e), _t("");
|
|
14599
14602
|
}, []);
|
|
14600
14603
|
c(() => {
|
|
14601
14604
|
if (!D || E !== "connected") {
|
|
14602
|
-
|
|
14605
|
+
dt(0);
|
|
14603
14606
|
return;
|
|
14604
14607
|
}
|
|
14605
14608
|
let e = () => {
|
|
14606
14609
|
let e = new Date(D).getTime();
|
|
14607
|
-
isNaN(e) ||
|
|
14610
|
+
isNaN(e) || dt(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
|
|
14608
14611
|
};
|
|
14609
14612
|
e();
|
|
14610
14613
|
let t = window.setInterval(e, 1e3);
|
|
14611
14614
|
return () => window.clearInterval(t);
|
|
14612
14615
|
}, [D, E]);
|
|
14613
14616
|
let At = o(() => {
|
|
14614
|
-
|
|
14617
|
+
H("call_screen"), xt(!1);
|
|
14615
14618
|
}, []), jt = o(() => {
|
|
14616
|
-
|
|
14619
|
+
H("text_chat"), xt(!0);
|
|
14617
14620
|
}, []);
|
|
14618
14621
|
c(() => {
|
|
14619
14622
|
let e = w?.callId || T || null;
|
|
14620
14623
|
if (!e) {
|
|
14621
|
-
|
|
14624
|
+
wt.current = null;
|
|
14622
14625
|
return;
|
|
14623
14626
|
}
|
|
14624
14627
|
if (w?.callId || E === "connecting" || E === "connected") {
|
|
14625
|
-
if (
|
|
14626
|
-
|
|
14628
|
+
if (V === "minimized_orb" && bt && T && !w?.callId) {
|
|
14629
|
+
wt.current = e;
|
|
14627
14630
|
return;
|
|
14628
14631
|
}
|
|
14629
|
-
!(!i ||
|
|
14632
|
+
!(!i || V === "minimized_orb" || V === "voice_mode") && wt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
|
|
14630
14633
|
forcedKey: e,
|
|
14631
14634
|
isOpen: i,
|
|
14632
|
-
surface:
|
|
14635
|
+
surface: V,
|
|
14633
14636
|
hasIncomingCall: !!w?.callId,
|
|
14634
14637
|
activeCallId: T,
|
|
14635
14638
|
callConnectionState: E
|
|
14636
|
-
}),
|
|
14639
|
+
}), wt.current = e, V === "voice_mode" && se?.(!1), ae?.(), At());
|
|
14637
14640
|
}
|
|
14638
14641
|
}, [
|
|
14639
14642
|
T,
|
|
@@ -14642,39 +14645,39 @@ function zg() {
|
|
|
14642
14645
|
w?.callId,
|
|
14643
14646
|
i,
|
|
14644
14647
|
ae,
|
|
14645
|
-
|
|
14646
|
-
|
|
14648
|
+
se,
|
|
14649
|
+
V
|
|
14647
14650
|
]), c(() => {
|
|
14648
|
-
!w && !T &&
|
|
14651
|
+
!w && !T && V === "call_screen" && H("text_chat");
|
|
14649
14652
|
}, [
|
|
14650
14653
|
w,
|
|
14651
14654
|
T,
|
|
14652
|
-
|
|
14655
|
+
V
|
|
14653
14656
|
]), c(() => {
|
|
14654
|
-
!T &&
|
|
14655
|
-
}, [T,
|
|
14657
|
+
!T && bt && xt(!1);
|
|
14658
|
+
}, [T, bt]), c(() => {
|
|
14656
14659
|
if (!s || C) {
|
|
14657
|
-
|
|
14660
|
+
ve?.(""), _e?.();
|
|
14658
14661
|
return;
|
|
14659
14662
|
}
|
|
14660
|
-
if (!
|
|
14661
|
-
|
|
14662
|
-
let e = window.setTimeout(() =>
|
|
14663
|
+
if (!nt.trim() || mt) {
|
|
14664
|
+
ve?.("");
|
|
14665
|
+
let e = window.setTimeout(() => _e?.(), 100);
|
|
14663
14666
|
return () => window.clearTimeout(e);
|
|
14664
14667
|
}
|
|
14665
|
-
|
|
14666
|
-
let e = window.setTimeout(() =>
|
|
14668
|
+
ge?.();
|
|
14669
|
+
let e = window.setTimeout(() => ve?.(nt), 120), t = window.setTimeout(() => _e?.(), 1200);
|
|
14667
14670
|
return () => {
|
|
14668
14671
|
window.clearTimeout(e), window.clearTimeout(t);
|
|
14669
14672
|
};
|
|
14670
14673
|
}, [
|
|
14671
|
-
|
|
14672
|
-
|
|
14674
|
+
nt,
|
|
14675
|
+
mt,
|
|
14673
14676
|
s,
|
|
14674
14677
|
C,
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
+
ge,
|
|
14679
|
+
_e,
|
|
14680
|
+
ve
|
|
14678
14681
|
]);
|
|
14679
14682
|
let Mt = (e) => e ? {
|
|
14680
14683
|
replyTo: e.messageId || e.id || null,
|
|
@@ -14682,42 +14685,42 @@ function zg() {
|
|
|
14682
14685
|
replyToSender: e.sender || null
|
|
14683
14686
|
} : null, Nt = async (e) => {
|
|
14684
14687
|
if (e.preventDefault(), C) return;
|
|
14685
|
-
if (
|
|
14686
|
-
let e =
|
|
14688
|
+
if (Et) {
|
|
14689
|
+
let e = at.trim().toLowerCase();
|
|
14687
14690
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
14688
|
-
|
|
14691
|
+
st("Please enter a valid email so we can continue helping you.");
|
|
14689
14692
|
return;
|
|
14690
14693
|
}
|
|
14691
|
-
await oe(e),
|
|
14694
|
+
await oe(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
|
|
14692
14695
|
return;
|
|
14693
14696
|
}
|
|
14694
|
-
let t = Mt(
|
|
14695
|
-
if (!
|
|
14696
|
-
if (
|
|
14697
|
+
let t = Mt(it);
|
|
14698
|
+
if (!nt.trim() && !mt) return;
|
|
14699
|
+
if (mt) {
|
|
14697
14700
|
try {
|
|
14698
|
-
|
|
14699
|
-
let e = await ie(
|
|
14700
|
-
|
|
14701
|
+
yt(!0), _t("");
|
|
14702
|
+
let e = await ie(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${dh(mt)}`;
|
|
14703
|
+
rt(""), U(null), Ot(), await A(r, "", t, {
|
|
14701
14704
|
type: "file",
|
|
14702
14705
|
metadata: {
|
|
14703
14706
|
fileUrl: n?.fileUrl,
|
|
14704
|
-
fileName: n?.fileName ||
|
|
14705
|
-
fileType: n?.fileType ||
|
|
14706
|
-
fileSize: n?.fileSize ||
|
|
14707
|
+
fileName: n?.fileName || mt.name,
|
|
14708
|
+
fileType: n?.fileType || mt.type,
|
|
14709
|
+
fileSize: n?.fileSize || mt.size
|
|
14707
14710
|
}
|
|
14708
14711
|
});
|
|
14709
14712
|
} catch (e) {
|
|
14710
|
-
|
|
14713
|
+
_t(e?.message || "Failed to upload the selected file.");
|
|
14711
14714
|
} finally {
|
|
14712
|
-
|
|
14715
|
+
yt(!1);
|
|
14713
14716
|
}
|
|
14714
14717
|
return;
|
|
14715
14718
|
}
|
|
14716
|
-
let n =
|
|
14717
|
-
|
|
14719
|
+
let n = nt.trim();
|
|
14720
|
+
rt(""), U(null), await A(n, "", t);
|
|
14718
14721
|
}, Pt = o(() => {
|
|
14719
|
-
r.length !== 0 &&
|
|
14720
|
-
}, [r.length,
|
|
14722
|
+
r.length !== 0 && ue?.();
|
|
14723
|
+
}, [r.length, ue]), Ft = (e) => {
|
|
14721
14724
|
let t = Math.floor(e / 60);
|
|
14722
14725
|
return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
|
|
14723
14726
|
}, It = o(async (e) => {
|
|
@@ -14728,44 +14731,44 @@ function zg() {
|
|
|
14728
14731
|
C,
|
|
14729
14732
|
b,
|
|
14730
14733
|
A
|
|
14731
|
-
]), Lt =
|
|
14734
|
+
]), Lt = G && V === "entry_prompt" ? { inset: 0 } : G && V === "text_chat" ? {
|
|
14732
14735
|
left: 0,
|
|
14733
14736
|
right: 0,
|
|
14734
14737
|
bottom: 0
|
|
14735
|
-
} :
|
|
14738
|
+
} : G && V === "call_screen" ? {
|
|
14736
14739
|
left: 0,
|
|
14737
14740
|
right: 0,
|
|
14738
14741
|
bottom: 0,
|
|
14739
14742
|
height: "90dvh",
|
|
14740
14743
|
overflow: "hidden",
|
|
14741
14744
|
borderRadius: "16px 16px 0 0"
|
|
14742
|
-
} :
|
|
14745
|
+
} : G && V === "connection_modal" ? {
|
|
14743
14746
|
left: "12px",
|
|
14744
14747
|
right: "12px",
|
|
14745
14748
|
bottom: "12px"
|
|
14746
|
-
} :
|
|
14749
|
+
} : V === "call_screen" ? {
|
|
14747
14750
|
width: "min(350px, calc(100vw - 40px))",
|
|
14748
14751
|
height: "min(640px, calc(100vh - 120px))",
|
|
14749
14752
|
borderRadius: "22px",
|
|
14750
14753
|
overflow: "hidden",
|
|
14751
|
-
...
|
|
14754
|
+
...Ne === "bottom-left" ? {
|
|
14752
14755
|
left: "1.5rem",
|
|
14753
|
-
bottom:
|
|
14756
|
+
bottom: Ve
|
|
14754
14757
|
} : {
|
|
14755
14758
|
right: "1.5rem",
|
|
14756
|
-
bottom:
|
|
14759
|
+
bottom: Ve
|
|
14757
14760
|
}
|
|
14758
|
-
} :
|
|
14761
|
+
} : Ne === "bottom-left" ? {
|
|
14759
14762
|
left: "1.5rem",
|
|
14760
|
-
bottom:
|
|
14763
|
+
bottom: Ve
|
|
14761
14764
|
} : {
|
|
14762
14765
|
right: "1.5rem",
|
|
14763
|
-
bottom:
|
|
14766
|
+
bottom: Ve
|
|
14764
14767
|
}, Rt = o(() => {
|
|
14765
|
-
|
|
14766
|
-
|
|
14768
|
+
V !== "minimized_orb" && (Ct(!0), setTimeout(() => {
|
|
14769
|
+
H("minimized_orb"), Ct(!1), T && xt(!0);
|
|
14767
14770
|
}, 280));
|
|
14768
|
-
}, [T,
|
|
14771
|
+
}, [T, V]), zt = () => H("connection_modal"), Bt = () => {
|
|
14769
14772
|
try {
|
|
14770
14773
|
let e = window.AudioContext || window.webkitAudioContext;
|
|
14771
14774
|
if (e) {
|
|
@@ -14773,13 +14776,13 @@ function zg() {
|
|
|
14773
14776
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
14774
14777
|
}
|
|
14775
14778
|
} catch {}
|
|
14776
|
-
ae({ notifyChatInitiated: !0 }),
|
|
14779
|
+
ae({ notifyChatInitiated: !0 }), se?.(!0), H("voice_mode");
|
|
14777
14780
|
}, Vt = () => {
|
|
14778
|
-
ae({ notifyChatInitiated: !0 }),
|
|
14781
|
+
ae({ notifyChatInitiated: !0 }), se?.(!1), H("text_chat");
|
|
14779
14782
|
}, Ht = () => {
|
|
14780
|
-
|
|
14783
|
+
se?.(!1), Rt();
|
|
14781
14784
|
};
|
|
14782
|
-
return e !== "ready" || !
|
|
14785
|
+
return e !== "ready" || !Ue || De.chat === !1 || !qe ? null : /* @__PURE__ */ _("div", {
|
|
14783
14786
|
className: "flowengage-widget-root",
|
|
14784
14787
|
style: {
|
|
14785
14788
|
position: "fixed",
|
|
@@ -14789,20 +14792,20 @@ function zg() {
|
|
|
14789
14792
|
onWheel: (e) => e.stopPropagation(),
|
|
14790
14793
|
onTouchMove: (e) => e.stopPropagation(),
|
|
14791
14794
|
children: [
|
|
14792
|
-
|
|
14793
|
-
copy:
|
|
14794
|
-
orbColors:
|
|
14795
|
-
primaryColor:
|
|
14795
|
+
V === "entry_prompt" && /* @__PURE__ */ g(Ng, {
|
|
14796
|
+
copy: Ye,
|
|
14797
|
+
orbColors: F,
|
|
14798
|
+
primaryColor: je,
|
|
14796
14799
|
onYes: () => {
|
|
14797
|
-
|
|
14800
|
+
le(z), Bt();
|
|
14798
14801
|
},
|
|
14799
14802
|
onLater: () => {
|
|
14800
|
-
|
|
14803
|
+
le(z), Rt();
|
|
14801
14804
|
},
|
|
14802
|
-
isMobile:
|
|
14803
|
-
isClosing:
|
|
14805
|
+
isMobile: G,
|
|
14806
|
+
isClosing: St
|
|
14804
14807
|
}),
|
|
14805
|
-
|
|
14808
|
+
V === "minimized_orb" && /* @__PURE__ */ _(ym.div, {
|
|
14806
14809
|
layoutId: "fe-main-orb",
|
|
14807
14810
|
initial: {
|
|
14808
14811
|
scale: .4,
|
|
@@ -14821,14 +14824,14 @@ function zg() {
|
|
|
14821
14824
|
transformOrigin: "bottom right",
|
|
14822
14825
|
display: "inline-flex",
|
|
14823
14826
|
flexDirection: "column",
|
|
14824
|
-
alignItems:
|
|
14827
|
+
alignItems: Ne === "bottom-left" ? "flex-start" : "flex-end",
|
|
14825
14828
|
gap: "10px"
|
|
14826
14829
|
},
|
|
14827
14830
|
children: [T && /* @__PURE__ */ _("button", {
|
|
14828
14831
|
type: "button",
|
|
14829
14832
|
onClick: At,
|
|
14830
14833
|
style: {
|
|
14831
|
-
maxWidth:
|
|
14834
|
+
maxWidth: G ? "220px" : "240px",
|
|
14832
14835
|
padding: "10px 14px",
|
|
14833
14836
|
borderRadius: "18px",
|
|
14834
14837
|
border: "1px solid rgba(255,255,255,0.7)",
|
|
@@ -14869,124 +14872,124 @@ function zg() {
|
|
|
14869
14872
|
marginTop: "2px",
|
|
14870
14873
|
whiteSpace: "nowrap"
|
|
14871
14874
|
},
|
|
14872
|
-
children: E === "connected" ? `${Ft(
|
|
14875
|
+
children: E === "connected" ? `${Ft(ut)} with ${Ze}` : `Tap to return to ${Ze}`
|
|
14873
14876
|
})]
|
|
14874
14877
|
})]
|
|
14875
14878
|
}), /* @__PURE__ */ g(Mg, {
|
|
14876
|
-
size:
|
|
14877
|
-
orbColors:
|
|
14878
|
-
onClick: T ? At :
|
|
14879
|
+
size: I,
|
|
14880
|
+
orbColors: F,
|
|
14881
|
+
onClick: T ? At : ke ? zt : Vt
|
|
14879
14882
|
})]
|
|
14880
14883
|
}),
|
|
14881
|
-
|
|
14882
|
-
copy:
|
|
14883
|
-
orbColors:
|
|
14884
|
-
primaryColor:
|
|
14884
|
+
V === "connection_modal" && /* @__PURE__ */ g(Pg, {
|
|
14885
|
+
copy: Ye,
|
|
14886
|
+
orbColors: F,
|
|
14887
|
+
primaryColor: je,
|
|
14885
14888
|
onVoice: Bt,
|
|
14886
14889
|
onText: Vt,
|
|
14887
14890
|
onClose: Rt,
|
|
14888
|
-
isMobile:
|
|
14889
|
-
isClosing:
|
|
14891
|
+
isMobile: G,
|
|
14892
|
+
isClosing: St
|
|
14890
14893
|
}),
|
|
14891
|
-
|
|
14892
|
-
orbColors:
|
|
14894
|
+
V === "voice_mode" && /* @__PURE__ */ g(Fg, {
|
|
14895
|
+
orbColors: F,
|
|
14893
14896
|
onEnterChat: Vt,
|
|
14894
14897
|
onEndChat: Ht,
|
|
14895
|
-
agentId:
|
|
14896
|
-
siteId:
|
|
14897
|
-
apiBaseUrl:
|
|
14898
|
+
agentId: Xe,
|
|
14899
|
+
siteId: z,
|
|
14900
|
+
apiBaseUrl: B,
|
|
14898
14901
|
chatId: te,
|
|
14899
14902
|
historyRef: ne,
|
|
14900
14903
|
onMessageSync: re,
|
|
14901
|
-
voiceEndCounter:
|
|
14904
|
+
voiceEndCounter: Se,
|
|
14902
14905
|
websiteName: t?.websiteName,
|
|
14903
|
-
voiceFirstMessage:
|
|
14906
|
+
voiceFirstMessage: Ce.voiceFirstMessage || null,
|
|
14904
14907
|
captureVisitorEmail: oe,
|
|
14905
14908
|
emailRequired: !h,
|
|
14906
|
-
emailCaptureEnabled:
|
|
14907
|
-
listeningLabel:
|
|
14908
|
-
thinkingLabel:
|
|
14909
|
-
enterChatModeLabel:
|
|
14910
|
-
endConversationLabel:
|
|
14909
|
+
emailCaptureEnabled: N.disableEmailCapture !== !0,
|
|
14910
|
+
listeningLabel: N.voiceListeningLabel || "Listening...",
|
|
14911
|
+
thinkingLabel: N.voiceThinkingLabel || "Thinking...",
|
|
14912
|
+
enterChatModeLabel: N.voiceEnterChatLabel || "Enter Chat Mode",
|
|
14913
|
+
endConversationLabel: N.voiceEndConversationLabel || "End Conversation"
|
|
14911
14914
|
}, "voice"),
|
|
14912
|
-
|
|
14915
|
+
V === "call_screen" && /* @__PURE__ */ g(Nh, {
|
|
14913
14916
|
incomingCall: w,
|
|
14914
14917
|
activeCallId: T,
|
|
14915
14918
|
callConnectionState: E,
|
|
14916
|
-
callDurationSeconds:
|
|
14919
|
+
callDurationSeconds: ut,
|
|
14917
14920
|
isCallMuted: ee,
|
|
14918
|
-
agentName:
|
|
14919
|
-
agentHeadshot:
|
|
14920
|
-
fallbackAgentName:
|
|
14921
|
-
acceptCall:
|
|
14922
|
-
rejectCall:
|
|
14923
|
-
endWebRTCCall:
|
|
14924
|
-
toggleCallMute:
|
|
14921
|
+
agentName: Ze,
|
|
14922
|
+
agentHeadshot: Qe,
|
|
14923
|
+
fallbackAgentName: L,
|
|
14924
|
+
acceptCall: de,
|
|
14925
|
+
rejectCall: fe,
|
|
14926
|
+
endWebRTCCall: pe,
|
|
14927
|
+
toggleCallMute: me,
|
|
14925
14928
|
formatCallDuration: Ft,
|
|
14926
14929
|
onMinimize: jt,
|
|
14927
|
-
primaryColor:
|
|
14928
|
-
orbColors:
|
|
14930
|
+
primaryColor: je,
|
|
14931
|
+
orbColors: F,
|
|
14929
14932
|
chatHistory: r
|
|
14930
14933
|
}),
|
|
14931
|
-
|
|
14932
|
-
isClosing:
|
|
14933
|
-
copy:
|
|
14934
|
-
orbColors:
|
|
14935
|
-
primaryColor:
|
|
14936
|
-
chatBgGradient:
|
|
14937
|
-
logo:
|
|
14938
|
-
quickChatOptions:
|
|
14934
|
+
V === "text_chat" && /* @__PURE__ */ g(Rg, {
|
|
14935
|
+
isClosing: St,
|
|
14936
|
+
copy: Ye,
|
|
14937
|
+
orbColors: F,
|
|
14938
|
+
primaryColor: je,
|
|
14939
|
+
chatBgGradient: Pe,
|
|
14940
|
+
logo: Fe,
|
|
14941
|
+
quickChatOptions: Re,
|
|
14939
14942
|
onQuickChatSelect: It,
|
|
14940
|
-
isMobile:
|
|
14943
|
+
isMobile: G,
|
|
14941
14944
|
chatHistory: r,
|
|
14942
14945
|
isAiTyping: y,
|
|
14943
14946
|
isAgentTyping: v,
|
|
14944
14947
|
activeScreen: a,
|
|
14945
|
-
agentName:
|
|
14946
|
-
agentHeadshot:
|
|
14947
|
-
fallbackAgentName:
|
|
14948
|
-
input:
|
|
14949
|
-
setInput:
|
|
14948
|
+
agentName: Ze,
|
|
14949
|
+
agentHeadshot: Qe,
|
|
14950
|
+
fallbackAgentName: L,
|
|
14951
|
+
input: nt,
|
|
14952
|
+
setInput: rt,
|
|
14950
14953
|
onSubmit: Nt,
|
|
14951
14954
|
isConversationEnded: C,
|
|
14952
14955
|
isLoading: b,
|
|
14953
14956
|
isRateLimited: x,
|
|
14954
14957
|
rateLimitMessage: S,
|
|
14955
|
-
selectedFile:
|
|
14958
|
+
selectedFile: mt,
|
|
14956
14959
|
onFileSelect: kt,
|
|
14957
14960
|
onRemoveSelectedFile: Ot,
|
|
14958
|
-
attachmentError:
|
|
14959
|
-
isUploadingAttachment:
|
|
14960
|
-
requiresEmail:
|
|
14961
|
-
emailInput:
|
|
14962
|
-
setEmailInput:
|
|
14963
|
-
emailError:
|
|
14964
|
-
emailCaptureSuccess:
|
|
14965
|
-
replyContext:
|
|
14966
|
-
setReplyContext:
|
|
14961
|
+
attachmentError: gt,
|
|
14962
|
+
isUploadingAttachment: vt,
|
|
14963
|
+
requiresEmail: Et,
|
|
14964
|
+
emailInput: at,
|
|
14965
|
+
setEmailInput: ot,
|
|
14966
|
+
emailError: W,
|
|
14967
|
+
emailCaptureSuccess: ct,
|
|
14968
|
+
replyContext: it,
|
|
14969
|
+
setReplyContext: U,
|
|
14967
14970
|
webRTCError: O,
|
|
14968
|
-
micError:
|
|
14969
|
-
setMicError:
|
|
14970
|
-
dismissCallError:
|
|
14971
|
+
micError: ft,
|
|
14972
|
+
setMicError: pt,
|
|
14973
|
+
dismissCallError: he,
|
|
14971
14974
|
activeCallId: T,
|
|
14972
14975
|
isCallMuted: ee,
|
|
14973
|
-
toggleCallMute:
|
|
14974
|
-
endWebRTCCall:
|
|
14976
|
+
toggleCallMute: me,
|
|
14977
|
+
endWebRTCCall: pe,
|
|
14975
14978
|
formatCallDuration: Ft,
|
|
14976
|
-
callDurationSeconds:
|
|
14979
|
+
callDurationSeconds: ut,
|
|
14977
14980
|
onCollapse: Rt,
|
|
14978
14981
|
onStartVoice: Bt,
|
|
14979
|
-
voiceEnabled:
|
|
14982
|
+
voiceEnabled: ke,
|
|
14980
14983
|
onNewChat: Pt,
|
|
14981
14984
|
onMinimize: jt,
|
|
14982
14985
|
onExpand: At,
|
|
14983
14986
|
isCallMinimized: !!T,
|
|
14984
|
-
showPoweredBy:
|
|
14985
|
-
privacyPolicyUrl:
|
|
14986
|
-
headerBgColor:
|
|
14987
|
-
getVisitorChatHistory:
|
|
14988
|
-
resumeChat:
|
|
14989
|
-
isSessionRestoring:
|
|
14987
|
+
showPoweredBy: ze,
|
|
14988
|
+
privacyPolicyUrl: He,
|
|
14989
|
+
headerBgColor: Be,
|
|
14990
|
+
getVisitorChatHistory: M,
|
|
14991
|
+
resumeChat: ye,
|
|
14992
|
+
isSessionRestoring: be
|
|
14990
14993
|
}),
|
|
14991
14994
|
/* @__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 " })
|
|
14992
14995
|
]
|