@flowengage/react-chatbot 8.0.28 → 8.0.30
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.
- package/dist/flowengage-embed.js +20 -20
- package/dist/flowengage-react-chatbot.cjs +16 -16
- package/dist/flowengage-react-chatbot.mjs +529 -516
- package/package.json +2 -2
|
@@ -18,7 +18,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
18
18
|
}, T = (e) => x.call(e, "module.exports") ? e["module.exports"] : w(v({}, "__esModule", { value: !0 }), e), ee = (e) => {
|
|
19
19
|
if (!e || typeof e != "object") throw Error("FlowEngage config is required");
|
|
20
20
|
if (!e.siteId || typeof e.siteId != "string") throw Error("[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId=\"your-site-id\" /> or config={{ siteId: 'your-site-id' }}.");
|
|
21
|
-
let t = (e.apiBaseUrl || "https://be-flowengage-
|
|
21
|
+
let t = (e.apiBaseUrl || "https://be-flowengage-dev.oslabs.app").replace(/\/+$/, "");
|
|
22
22
|
return {
|
|
23
23
|
siteId: e.siteId.trim(),
|
|
24
24
|
apiBaseUrl: t
|
|
@@ -26,7 +26,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
26
26
|
}, te = (e, t) => {
|
|
27
27
|
let n = Number.parseInt(String(e ?? ""), 10);
|
|
28
28
|
return Number.isFinite(n) && n > 0 ? n : t;
|
|
29
|
-
}, ne = te(void 0, 1e4), re = te(void 0, 15e3),
|
|
29
|
+
}, ne = te(void 0, 1e4), re = te(void 0, 15e3), E = {
|
|
30
30
|
chatId: "flowengage.chatId",
|
|
31
31
|
isOpen: "flowengage.isOpen",
|
|
32
32
|
activeScreen: "flowengage.activeScreen",
|
|
@@ -34,16 +34,16 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
34
34
|
agentName: "flowengage.agentName",
|
|
35
35
|
agentHeadshot: "flowengage.agentHeadshot",
|
|
36
36
|
visitorEmail: "flowengage.visitorEmail"
|
|
37
|
-
},
|
|
38
|
-
if (!
|
|
39
|
-
let e = window.localStorage.getItem(
|
|
37
|
+
}, ie = 6e4, ae = 480 * 60, oe = 3e4, D = typeof window < "u", se = (e) => e ? `flowengage.visitorEmail.${e}` : null, ce = () => {
|
|
38
|
+
if (!D) return null;
|
|
39
|
+
let e = window.localStorage.getItem(E.chatId);
|
|
40
40
|
return e && String(e).trim() ? String(e).trim() : null;
|
|
41
|
-
},
|
|
42
|
-
if (
|
|
43
|
-
window.localStorage.removeItem(
|
|
41
|
+
}, le = () => {
|
|
42
|
+
if (D) try {
|
|
43
|
+
window.localStorage.removeItem(E.chatId);
|
|
44
44
|
} catch {}
|
|
45
|
-
},
|
|
46
|
-
if (!
|
|
45
|
+
}, ue = () => D ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", de = (e) => e ? `flowengage.entrySeen.${e}` : null, fe = (e) => {
|
|
46
|
+
if (!D || !e) return !1;
|
|
47
47
|
try {
|
|
48
48
|
let t = de(e);
|
|
49
49
|
return t ? window.localStorage.getItem(t) === "1" : !1;
|
|
@@ -51,12 +51,12 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
51
51
|
return !1;
|
|
52
52
|
}
|
|
53
53
|
}, pe = (e) => {
|
|
54
|
-
if (!(!
|
|
54
|
+
if (!(!D || !e)) try {
|
|
55
55
|
let t = de(e);
|
|
56
56
|
t && window.localStorage.setItem(t, "1");
|
|
57
57
|
} catch {}
|
|
58
58
|
}, me = (e) => e ? `flowengage.persistedChatId.${e}` : null, he = (e) => {
|
|
59
|
-
if (!
|
|
59
|
+
if (!D || !e) return null;
|
|
60
60
|
try {
|
|
61
61
|
let t = me(e), n = t ? window.localStorage.getItem(t) : null;
|
|
62
62
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
@@ -64,21 +64,21 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
}, ge = (e) => {
|
|
67
|
-
if (!(!
|
|
67
|
+
if (!(!D || !e)) try {
|
|
68
68
|
let t = me(e);
|
|
69
69
|
t && window.localStorage.removeItem(t);
|
|
70
70
|
} catch {}
|
|
71
71
|
}, _e = (e, t) => {
|
|
72
|
-
if (!(!
|
|
72
|
+
if (!(!D || !e || !t)) try {
|
|
73
73
|
let n = me(e);
|
|
74
74
|
n && window.localStorage.setItem(n, String(t).trim());
|
|
75
75
|
} catch {}
|
|
76
|
-
}, ve = () =>
|
|
76
|
+
}, ve = () => D ? {
|
|
77
77
|
isOpen: !1,
|
|
78
|
-
activeScreen: window.sessionStorage.getItem(
|
|
79
|
-
isHumanHandled: window.sessionStorage.getItem(
|
|
80
|
-
agentName: window.sessionStorage.getItem(
|
|
81
|
-
agentHeadshot: window.sessionStorage.getItem(
|
|
78
|
+
activeScreen: window.sessionStorage.getItem(E.activeScreen) || "ai",
|
|
79
|
+
isHumanHandled: window.sessionStorage.getItem(E.isHumanHandled) === "true",
|
|
80
|
+
agentName: window.sessionStorage.getItem(E.agentName),
|
|
81
|
+
agentHeadshot: window.sessionStorage.getItem(E.agentHeadshot),
|
|
82
82
|
visitorEmail: ""
|
|
83
83
|
} : {
|
|
84
84
|
isOpen: !1,
|
|
@@ -88,8 +88,8 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
88
88
|
agentHeadshot: null,
|
|
89
89
|
visitorEmail: ""
|
|
90
90
|
}, ye = (e) => {
|
|
91
|
-
|
|
92
|
-
let n =
|
|
91
|
+
D && Object.entries(e).forEach(([e, t]) => {
|
|
92
|
+
let n = E[e];
|
|
93
93
|
if (n) {
|
|
94
94
|
if (t == null || t === !1) {
|
|
95
95
|
window.sessionStorage.removeItem(n);
|
|
@@ -99,25 +99,25 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
}, be = (e) => {
|
|
102
|
-
if (!
|
|
103
|
-
let t =
|
|
102
|
+
if (!D || !e) return "";
|
|
103
|
+
let t = se(e), n = window.localStorage.getItem(t);
|
|
104
104
|
if (!n) {
|
|
105
|
-
let e = window.sessionStorage.getItem(
|
|
106
|
-
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(
|
|
105
|
+
let e = window.sessionStorage.getItem(E.visitorEmail);
|
|
106
|
+
e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(E.visitorEmail), n = e);
|
|
107
107
|
}
|
|
108
108
|
return n || "";
|
|
109
109
|
}, xe = (e, t) => {
|
|
110
|
-
if (!
|
|
111
|
-
let n =
|
|
110
|
+
if (!D) return;
|
|
111
|
+
let n = se(t);
|
|
112
112
|
if (!n) return;
|
|
113
113
|
let r = typeof e == "string" ? e.trim() : "";
|
|
114
114
|
if (!r) {
|
|
115
|
-
window.localStorage.removeItem(n), window.sessionStorage.removeItem(
|
|
115
|
+
window.localStorage.removeItem(n), window.sessionStorage.removeItem(E.visitorEmail);
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(
|
|
118
|
+
window.localStorage.setItem(n, r), window.sessionStorage.removeItem(E.visitorEmail);
|
|
119
119
|
}, Se = (e) => e ? `flowengage.visitorId.${e}` : null, Ce = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, we = (e) => {
|
|
120
|
-
if (!
|
|
120
|
+
if (!D || !e) return null;
|
|
121
121
|
try {
|
|
122
122
|
let t = Se(e), n = t ? window.localStorage.getItem(t) : null;
|
|
123
123
|
return n && String(n).trim() ? String(n).trim() : null;
|
|
@@ -125,7 +125,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
127
|
}, Te = (e) => {
|
|
128
|
-
if (!
|
|
128
|
+
if (!D || !e) return null;
|
|
129
129
|
try {
|
|
130
130
|
let t = we(e);
|
|
131
131
|
if (t) return t;
|
|
@@ -135,7 +135,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
135
135
|
return Ce();
|
|
136
136
|
}
|
|
137
137
|
}, Ee = "flowengage.tabId", De = () => {
|
|
138
|
-
if (!
|
|
138
|
+
if (!D) return "default";
|
|
139
139
|
try {
|
|
140
140
|
let e = window.sessionStorage.getItem(Ee);
|
|
141
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(Ee, e)), e;
|
|
@@ -143,7 +143,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
143
143
|
return "default";
|
|
144
144
|
}
|
|
145
145
|
}, Oe = (e) => e ? `flowengage.voice.transcript.${e}.${De()}` : null, ke = 600 * 1e3, O = (e, t, n = {}) => {
|
|
146
|
-
if (!
|
|
146
|
+
if (!D || !e) return;
|
|
147
147
|
let r = typeof t == "string" ? t.trim() : "";
|
|
148
148
|
if (!r) return;
|
|
149
149
|
let i = Number.isFinite(n.ttlMs) ? n.ttlMs : ke, a = {
|
|
@@ -155,7 +155,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
155
155
|
t && window.localStorage.setItem(t, JSON.stringify(a));
|
|
156
156
|
} catch {}
|
|
157
157
|
}, Ae = (e) => {
|
|
158
|
-
if (!
|
|
158
|
+
if (!D || !e) return null;
|
|
159
159
|
try {
|
|
160
160
|
let t = Oe(e), n = t ? window.localStorage.getItem(t) : null;
|
|
161
161
|
if (!n) return null;
|
|
@@ -165,41 +165,41 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
165
165
|
return null;
|
|
166
166
|
}
|
|
167
167
|
}, je = (e) => {
|
|
168
|
-
if (!(!
|
|
168
|
+
if (!(!D || !e)) try {
|
|
169
169
|
let t = Oe(e);
|
|
170
170
|
t && window.localStorage.removeItem(t);
|
|
171
171
|
} catch {}
|
|
172
172
|
}, Me = "flowengage.voice.pendingResume", Ne = () => {
|
|
173
|
-
if (
|
|
173
|
+
if (D) try {
|
|
174
174
|
window.sessionStorage.setItem(Me, "1");
|
|
175
175
|
} catch {}
|
|
176
176
|
}, Pe = () => {
|
|
177
|
-
if (!
|
|
177
|
+
if (!D) return !1;
|
|
178
178
|
try {
|
|
179
179
|
return window.sessionStorage.getItem(Me) === "1" ? (window.sessionStorage.removeItem(Me), !0) : !1;
|
|
180
180
|
} catch {
|
|
181
181
|
return !1;
|
|
182
182
|
}
|
|
183
183
|
}, Fe = "flowengage.chat.pendingReopen", Ie = () => {
|
|
184
|
-
if (
|
|
184
|
+
if (D) try {
|
|
185
185
|
window.sessionStorage.setItem(Fe, "1");
|
|
186
186
|
} catch {}
|
|
187
187
|
}, Le = () => {
|
|
188
|
-
if (!
|
|
188
|
+
if (!D) return !1;
|
|
189
189
|
try {
|
|
190
190
|
return window.sessionStorage.getItem(Fe) === "1" ? (window.sessionStorage.removeItem(Fe), !0) : !1;
|
|
191
191
|
} catch {
|
|
192
192
|
return !1;
|
|
193
193
|
}
|
|
194
194
|
}, Re = () => {
|
|
195
|
-
if (!
|
|
195
|
+
if (!D) return !1;
|
|
196
196
|
try {
|
|
197
197
|
return window.sessionStorage.getItem(Me) === "1";
|
|
198
198
|
} catch {
|
|
199
199
|
return !1;
|
|
200
200
|
}
|
|
201
201
|
}, ze = (e) => e ? `flowengage.voice.navState.${e}.${De()}` : null, Be = (e, t, n, r) => {
|
|
202
|
-
if (!(!
|
|
202
|
+
if (!(!D || !e || !t)) try {
|
|
203
203
|
let i = ze(e);
|
|
204
204
|
i && window.sessionStorage.setItem(i, JSON.stringify({
|
|
205
205
|
previousPage: String(t),
|
|
@@ -209,7 +209,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
|
|
|
209
209
|
}));
|
|
210
210
|
} catch {}
|
|
211
211
|
}, Ve = (e) => {
|
|
212
|
-
if (!
|
|
212
|
+
if (!D || !e) return null;
|
|
213
213
|
try {
|
|
214
214
|
let t = ze(e);
|
|
215
215
|
if (!t) return null;
|
|
@@ -609,21 +609,21 @@ function mt(e, t) {
|
|
|
609
609
|
}
|
|
610
610
|
//#endregion
|
|
611
611
|
//#region node_modules/@socket.io/component-emitter/lib/esm/index.js
|
|
612
|
-
function
|
|
613
|
-
if (e) return
|
|
612
|
+
function N(e) {
|
|
613
|
+
if (e) return ht(e);
|
|
614
614
|
}
|
|
615
|
-
function
|
|
616
|
-
for (var t in
|
|
615
|
+
function ht(e) {
|
|
616
|
+
for (var t in N.prototype) e[t] = N.prototype[t];
|
|
617
617
|
return e;
|
|
618
618
|
}
|
|
619
|
-
|
|
619
|
+
N.prototype.on = N.prototype.addEventListener = function(e, t) {
|
|
620
620
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
|
|
621
|
-
},
|
|
621
|
+
}, N.prototype.once = function(e, t) {
|
|
622
622
|
function n() {
|
|
623
623
|
this.off(e, n), t.apply(this, arguments);
|
|
624
624
|
}
|
|
625
625
|
return n.fn = t, this.on(e, n), this;
|
|
626
|
-
},
|
|
626
|
+
}, N.prototype.off = N.prototype.removeListener = N.prototype.removeAllListeners = N.prototype.removeEventListener = function(e, t) {
|
|
627
627
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
|
|
628
628
|
var n = this._callbacks["$" + e];
|
|
629
629
|
if (!n) return this;
|
|
@@ -633,7 +633,7 @@ ht.prototype.on = ht.prototype.addEventListener = function(e, t) {
|
|
|
633
633
|
break;
|
|
634
634
|
}
|
|
635
635
|
return n.length === 0 && delete this._callbacks["$" + e], this;
|
|
636
|
-
},
|
|
636
|
+
}, N.prototype.emit = function(e) {
|
|
637
637
|
this._callbacks = this._callbacks || {};
|
|
638
638
|
for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
|
|
639
639
|
if (n) {
|
|
@@ -641,22 +641,22 @@ ht.prototype.on = ht.prototype.addEventListener = function(e, t) {
|
|
|
641
641
|
for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
|
|
642
642
|
}
|
|
643
643
|
return this;
|
|
644
|
-
},
|
|
644
|
+
}, N.prototype.emitReserved = N.prototype.emit, N.prototype.listeners = function(e) {
|
|
645
645
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
|
|
646
|
-
},
|
|
646
|
+
}, N.prototype.hasListeners = function(e) {
|
|
647
647
|
return !!this.listeners(e).length;
|
|
648
648
|
};
|
|
649
649
|
//#endregion
|
|
650
650
|
//#region node_modules/engine.io-client/build/esm/globals.js
|
|
651
|
-
var
|
|
651
|
+
var gt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), _t = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), vt = "arraybuffer";
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region node_modules/engine.io-client/build/esm/util.js
|
|
654
654
|
function yt(e, ...t) {
|
|
655
655
|
return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
|
|
656
656
|
}
|
|
657
|
-
var bt =
|
|
657
|
+
var bt = _t.setTimeout, xt = _t.clearTimeout;
|
|
658
658
|
function St(e, t) {
|
|
659
|
-
t.useNativeTimers ? (e.setTimeoutFn = bt.bind(
|
|
659
|
+
t.useNativeTimers ? (e.setTimeoutFn = bt.bind(_t), e.clearTimeoutFn = xt.bind(_t)) : (e.setTimeoutFn = _t.setTimeout.bind(_t), e.clearTimeoutFn = _t.clearTimeout.bind(_t));
|
|
660
660
|
}
|
|
661
661
|
var Ct = 1.33;
|
|
662
662
|
function wt(e) {
|
|
@@ -691,7 +691,7 @@ var kt = class extends Error {
|
|
|
691
691
|
constructor(e, t, n) {
|
|
692
692
|
super(e), this.description = t, this.context = n, this.type = "TransportError";
|
|
693
693
|
}
|
|
694
|
-
}, At = class extends
|
|
694
|
+
}, At = class extends N {
|
|
695
695
|
constructor(e) {
|
|
696
696
|
super(), this.writable = !1, St(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
697
697
|
}
|
|
@@ -815,7 +815,7 @@ var Ft = class extends jt {
|
|
|
815
815
|
this.onError("xhr poll error", e, t);
|
|
816
816
|
}), this.pollXhr = e;
|
|
817
817
|
}
|
|
818
|
-
}, It = class e extends
|
|
818
|
+
}, It = class e extends N {
|
|
819
819
|
constructor(e, t, n) {
|
|
820
820
|
super(), this.createRequest = e, St(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
|
|
821
821
|
}
|
|
@@ -874,7 +874,7 @@ var Ft = class extends jt {
|
|
|
874
874
|
if (It.requestsCount = 0, It.requests = {}, typeof document < "u") {
|
|
875
875
|
if (typeof attachEvent == "function") attachEvent("onunload", Lt);
|
|
876
876
|
else if (typeof addEventListener == "function") {
|
|
877
|
-
let e = "onpagehide" in
|
|
877
|
+
let e = "onpagehide" in _t ? "pagehide" : "unload";
|
|
878
878
|
addEventListener(e, Lt, !1);
|
|
879
879
|
}
|
|
880
880
|
}
|
|
@@ -900,7 +900,7 @@ function Bt(e) {
|
|
|
900
900
|
if (typeof XMLHttpRequest < "u" && (!t || Nt)) return new XMLHttpRequest();
|
|
901
901
|
} catch {}
|
|
902
902
|
if (!t) try {
|
|
903
|
-
return new
|
|
903
|
+
return new _t[["Active", "Object"].join("X")]("Microsoft.XMLHTTP");
|
|
904
904
|
} catch {}
|
|
905
905
|
}
|
|
906
906
|
//#endregion
|
|
@@ -935,7 +935,7 @@ var Vt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
935
935
|
try {
|
|
936
936
|
this.doWrite(n, e);
|
|
937
937
|
} catch {}
|
|
938
|
-
r &&
|
|
938
|
+
r && gt(() => {
|
|
939
939
|
this.writable = !0, this.emitReserved("drain");
|
|
940
940
|
}, this.setTimeoutFn);
|
|
941
941
|
});
|
|
@@ -948,7 +948,7 @@ var Vt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
948
948
|
let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
949
949
|
return this.opts.timestampRequests && (t[this.opts.timestampParam] = Et()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
950
950
|
}
|
|
951
|
-
}, Ut =
|
|
951
|
+
}, Ut = _t.WebSocket || _t.MozWebSocket, Wt = {
|
|
952
952
|
websocket: class extends Ht {
|
|
953
953
|
createSocket(e, t, n) {
|
|
954
954
|
return Vt ? new Ut(e, t, n) : t ? new Ut(e, t) : new Ut(e);
|
|
@@ -991,7 +991,7 @@ var Vt = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
991
991
|
for (let t = 0; t < e.length; t++) {
|
|
992
992
|
let n = e[t], r = t === e.length - 1;
|
|
993
993
|
this._writer.write(n).then(() => {
|
|
994
|
-
r &&
|
|
994
|
+
r && gt(() => {
|
|
995
995
|
this.writable = !0, this.emitReserved("drain");
|
|
996
996
|
}, this.setTimeoutFn);
|
|
997
997
|
});
|
|
@@ -1043,7 +1043,7 @@ var Xt = typeof addEventListener == "function" && typeof removeEventListener ==
|
|
|
1043
1043
|
Xt && addEventListener("offline", () => {
|
|
1044
1044
|
Zt.forEach((e) => e());
|
|
1045
1045
|
}, !1);
|
|
1046
|
-
var Qt = class e extends
|
|
1046
|
+
var Qt = class e extends N {
|
|
1047
1047
|
constructor(e, t) {
|
|
1048
1048
|
if (super(), this.binaryType = vt, 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) {
|
|
1049
1049
|
let n = qt(e);
|
|
@@ -1149,7 +1149,7 @@ var Qt = class e extends ht {
|
|
|
1149
1149
|
_hasPingExpired() {
|
|
1150
1150
|
if (!this._pingTimeoutTime) return !0;
|
|
1151
1151
|
let e = Date.now() > this._pingTimeoutTime;
|
|
1152
|
-
return e && (this._pingTimeoutTime = 0,
|
|
1152
|
+
return e && (this._pingTimeoutTime = 0, gt(() => {
|
|
1153
1153
|
this._onClose("ping timeout");
|
|
1154
1154
|
}, this.setTimeoutFn)), e;
|
|
1155
1155
|
}
|
|
@@ -1368,7 +1368,7 @@ var gn = class {
|
|
|
1368
1368
|
let t = un(e), n = this.encodeAsString(t.packet), r = t.buffers;
|
|
1369
1369
|
return r.unshift(n), r;
|
|
1370
1370
|
}
|
|
1371
|
-
}, _n = class e extends
|
|
1371
|
+
}, _n = class e extends N {
|
|
1372
1372
|
constructor(e) {
|
|
1373
1373
|
super(), this.opts = Object.assign({
|
|
1374
1374
|
reviver: void 0,
|
|
@@ -1501,7 +1501,7 @@ var En = Object.freeze({
|
|
|
1501
1501
|
disconnecting: 1,
|
|
1502
1502
|
newListener: 1,
|
|
1503
1503
|
removeListener: 1
|
|
1504
|
-
}), Dn = class extends
|
|
1504
|
+
}), Dn = class extends N {
|
|
1505
1505
|
constructor(e, t, n) {
|
|
1506
1506
|
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();
|
|
1507
1507
|
}
|
|
@@ -1754,7 +1754,7 @@ On.prototype.duration = function() {
|
|
|
1754
1754
|
};
|
|
1755
1755
|
//#endregion
|
|
1756
1756
|
//#region node_modules/socket.io-client/build/esm/manager.js
|
|
1757
|
-
var kn = class extends
|
|
1757
|
+
var kn = class extends N {
|
|
1758
1758
|
constructor(e, t) {
|
|
1759
1759
|
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, St(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 On({
|
|
1760
1760
|
min: this.reconnectionDelay(),
|
|
@@ -1827,7 +1827,7 @@ var kn = class extends ht {
|
|
|
1827
1827
|
}
|
|
1828
1828
|
}
|
|
1829
1829
|
ondecoded(e) {
|
|
1830
|
-
|
|
1830
|
+
gt(() => {
|
|
1831
1831
|
this.emitReserved("packet", e);
|
|
1832
1832
|
}, this.setTimeoutFn);
|
|
1833
1833
|
}
|
|
@@ -2811,7 +2811,10 @@ async function Nr(e, t = {}) {
|
|
|
2811
2811
|
try {
|
|
2812
2812
|
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
2813
2813
|
} catch {}
|
|
2814
|
-
return
|
|
2814
|
+
return {
|
|
2815
|
+
navigated: !1,
|
|
2816
|
+
reason: "not-found"
|
|
2817
|
+
};
|
|
2815
2818
|
}
|
|
2816
2819
|
return { navigated: !0 };
|
|
2817
2820
|
}
|
|
@@ -2913,46 +2916,30 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2913
2916
|
message: "Looks like you're already on this page!",
|
|
2914
2917
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2915
2918
|
}]);
|
|
2916
|
-
}, []), [T, te] = m(ve().isOpen), [ne, re] = m(ve().activeScreen), [
|
|
2917
|
-
url: null,
|
|
2918
|
-
at: 0
|
|
2919
|
-
}), gt = o((e, t) => {
|
|
2920
|
-
let n = e;
|
|
2921
|
-
try {
|
|
2922
|
-
n = new URL(e, window.location.origin).href;
|
|
2923
|
-
} catch {}
|
|
2924
|
-
let r = ht.current;
|
|
2925
|
-
return r.url === n && Date.now() - r.at < 4e3 ? Promise.resolve({
|
|
2926
|
-
navigated: !0,
|
|
2927
|
-
deduped: !0
|
|
2928
|
-
}) : (ht.current = {
|
|
2929
|
-
url: n,
|
|
2930
|
-
at: Date.now()
|
|
2931
|
-
}, Nr(e, t));
|
|
2932
|
-
}, []), _t = p([]), N = p(null), vt = p(null), yt = p(null), bt = p(!1), xt = p(!1), St = p(""), Ct = p(null), wt = p(null), Tt = p([]), Et = p(0), Dt = p(ce), Ot = p([]), kt = p(!1), At = p(!1), jt = p(i), Mt = p({
|
|
2919
|
+
}, []), [T, te] = m(ve().isOpen), [ne, re] = m(ve().activeScreen), [E, D] = m(ve().isHumanHandled), [se, de] = m(ve().agentName), [fe, pe] = m(ve().agentHeadshot), [me, Se] = m(() => be(i?.siteId)), [Ce, we] = m(!1), [Ee, De] = m(!1), [Oe, ke] = m("idle"), [O, Ae] = m(!1), [je, Me] = m(!1), [Pe, Fe] = m(""), [Ie, Le] = m(!1), [Re, ze] = m(0), [Be, Ve] = m(0), [He, Ue] = m(!1), [k, qe] = m(null), [Je, Ye] = m(null), [Xe, Ze] = m("idle"), [Qe, $e] = m(null), [et, tt] = m(!1), [nt, rt] = m(""), [it, at] = m(!1), A = p(null), j = p(null), ot = p(""), st = p(!1), ct = p(null), lt = p(null), ut = p(null), M = p(null), dt = p(null), ft = p(null), pt = p(null), mt = p(!1), N = p([]), ht = p(null), gt = p(null), _t = p(null), vt = p(!1), yt = p(!1), bt = p(""), xt = p(null), St = p(null), Ct = p([]), wt = p(0), Tt = p(se), Et = p([]), Dt = p(!1), Ot = p(!1), kt = p(i), At = p({
|
|
2933
2920
|
notifyRouteChange: () => {},
|
|
2934
2921
|
cleanup: () => {}
|
|
2935
|
-
}),
|
|
2922
|
+
}), jt = o((e = {}) => {
|
|
2936
2923
|
let t = !!e.is_human_handled;
|
|
2937
|
-
return
|
|
2938
|
-
}, []),
|
|
2924
|
+
return D(t), t ? (re("agent"), e.agent_info?.name && de(e.agent_info.name), e.agent_info?.headshot && pe(e.agent_info.headshot), t) : (re("ai"), t);
|
|
2925
|
+
}, []), Mt = f(() => {
|
|
2939
2926
|
let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
|
|
2940
|
-
return Number.isFinite(t) && t > 0 ? t :
|
|
2927
|
+
return Number.isFinite(t) && t > 0 ? t : ae;
|
|
2941
2928
|
}, [i, _]);
|
|
2942
2929
|
c(() => {
|
|
2943
2930
|
lt.current = k;
|
|
2944
2931
|
}, [k]), c(() => {
|
|
2945
|
-
|
|
2946
|
-
}, [
|
|
2947
|
-
|
|
2932
|
+
Tt.current = se;
|
|
2933
|
+
}, [se]), c(() => {
|
|
2934
|
+
Ot.current = Ie;
|
|
2948
2935
|
}, [Ie]), c(() => {
|
|
2949
|
-
|
|
2936
|
+
kt.current = i;
|
|
2950
2937
|
}, [i]);
|
|
2951
|
-
let
|
|
2938
|
+
let Nt = () => {
|
|
2952
2939
|
rt("");
|
|
2953
|
-
},
|
|
2954
|
-
|
|
2955
|
-
}, []),
|
|
2940
|
+
}, Pt = o(() => {
|
|
2941
|
+
_t.current &&= (window.clearTimeout(_t.current), null);
|
|
2942
|
+
}, []), Ft = (e) => {
|
|
2956
2943
|
let t = typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
2957
2944
|
return Se(t), xe(t, i?.siteId), t;
|
|
2958
2945
|
};
|
|
@@ -2960,12 +2947,12 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2960
2947
|
let e = i?.siteId;
|
|
2961
2948
|
e && Se(be(e));
|
|
2962
2949
|
}, [i?.siteId]);
|
|
2963
|
-
let
|
|
2964
|
-
let t =
|
|
2965
|
-
if (
|
|
2950
|
+
let It = (e = "unspecified") => {
|
|
2951
|
+
let t = ht.current || ft.current?.callId, n = wt.current, r = xt.current;
|
|
2952
|
+
if (xt.current = null, wt.current = 0, r && r.state !== "inactive") {
|
|
2966
2953
|
r.onstop = () => {
|
|
2967
|
-
let e =
|
|
2968
|
-
if (
|
|
2954
|
+
let e = Ct.current;
|
|
2955
|
+
if (Ct.current = [], e.length > 0 && t && j.current) {
|
|
2969
2956
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2970
2957
|
j.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2971
2958
|
}
|
|
@@ -2973,42 +2960,42 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
2973
2960
|
try {
|
|
2974
2961
|
r.stop();
|
|
2975
2962
|
} catch {
|
|
2976
|
-
r.onstop = null,
|
|
2963
|
+
r.onstop = null, Ct.current = [];
|
|
2977
2964
|
}
|
|
2978
2965
|
} else if (r && r.state === "inactive") {
|
|
2979
|
-
let e =
|
|
2980
|
-
if (
|
|
2966
|
+
let e = Ct.current;
|
|
2967
|
+
if (Ct.current = [], e.length > 0 && t && j.current) {
|
|
2981
2968
|
let r = new Blob(e, { type: e[0].type }), i = n > 0 ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
2982
2969
|
j.current.uploadRecording(t, r, i).then((e) => console.log("[FlowEngageCall] recording upload success", e)).catch((e) => console.warn("[FlowEngageCall] recording upload failed", e));
|
|
2983
2970
|
}
|
|
2984
|
-
} else
|
|
2985
|
-
if (
|
|
2971
|
+
} else Ct.current = [];
|
|
2972
|
+
if (St.current) {
|
|
2986
2973
|
try {
|
|
2987
|
-
|
|
2974
|
+
St.current.close();
|
|
2988
2975
|
} catch {}
|
|
2989
|
-
|
|
2976
|
+
St.current = null;
|
|
2990
2977
|
}
|
|
2991
|
-
ut.current &&= (ut.current.close(), null), M.current &&= (M.current.getTracks().forEach((e) => e.stop()), null), dt.current &&= (dt.current.srcObject = null, dt.current.remove(), null),
|
|
2992
|
-
},
|
|
2993
|
-
let t = A.current, n =
|
|
2994
|
-
if (!(!t?.connected || !n ||
|
|
2995
|
-
|
|
2978
|
+
ut.current &&= (ut.current.close(), null), M.current &&= (M.current.getTracks().forEach((e) => e.stop()), null), dt.current &&= (dt.current.srcObject = null, dt.current.remove(), null), Pt(), ft.current = null, N.current = [], ht.current = null, gt.current = null, vt.current = !1, tt(!1), qe(null), Ye(null), Ze("idle"), $e(null);
|
|
2979
|
+
}, Lt = (e = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
2980
|
+
let t = A.current, n = ht.current || ft.current?.callId;
|
|
2981
|
+
if (!(!t?.connected || !n || vt.current)) {
|
|
2982
|
+
vt.current = !0, t.emit("call:connected", {
|
|
2996
2983
|
callId: n,
|
|
2997
2984
|
chatId: ot.current,
|
|
2998
2985
|
connectedAt: e
|
|
2999
2986
|
});
|
|
3000
2987
|
try {
|
|
3001
2988
|
let e = M.current, t = dt.current?.srcObject;
|
|
3002
|
-
if (e && t && !
|
|
3003
|
-
|
|
2989
|
+
if (e && t && !xt.current) {
|
|
2990
|
+
Ct.current = [];
|
|
3004
2991
|
let n = new (window.AudioContext || window.webkitAudioContext)();
|
|
3005
|
-
|
|
2992
|
+
St.current = n;
|
|
3006
2993
|
let r = n.createMediaStreamDestination();
|
|
3007
2994
|
n.createMediaStreamSource(e).connect(r), n.createMediaStreamSource(t).connect(r);
|
|
3008
2995
|
let i = window.MediaRecorder.isTypeSupported("audio/webm") ? "audio/webm" : "audio/mp4", a = new window.MediaRecorder(r.stream, { mimeType: i });
|
|
3009
2996
|
a.ondataavailable = (e) => {
|
|
3010
|
-
e.data && e.data.size > 0 &&
|
|
3011
|
-
},
|
|
2997
|
+
e.data && e.data.size > 0 && Ct.current.push(e.data);
|
|
2998
|
+
}, xt.current = a, wt.current = Date.now(), a.start(1e3), setTimeout(() => {
|
|
3012
2999
|
try {
|
|
3013
3000
|
if (!window.speechSynthesis) return;
|
|
3014
3001
|
let e = new SpeechSynthesisUtterance("This call is being recorded for quality and training purposes.");
|
|
@@ -3036,27 +3023,27 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3036
3023
|
}
|
|
3037
3024
|
} catch {}
|
|
3038
3025
|
}
|
|
3039
|
-
},
|
|
3026
|
+
}, Rt = (e = {}) => {
|
|
3040
3027
|
if (!e.callId) return;
|
|
3041
|
-
let t =
|
|
3028
|
+
let t = gt.current === e.callId, n = ht.current === e.callId, r = lt.current?.callId === e.callId;
|
|
3042
3029
|
if (!(!t && !n && !r)) {
|
|
3043
|
-
if (
|
|
3044
|
-
|
|
3030
|
+
if (Pt(), qe(null), t || n) {
|
|
3031
|
+
ht.current = e.callId, Ye(e.callId), Ze((e) => e === "connected" ? e : "connecting"), te(!0);
|
|
3045
3032
|
return;
|
|
3046
3033
|
}
|
|
3047
3034
|
Ze("idle");
|
|
3048
3035
|
}
|
|
3049
|
-
},
|
|
3036
|
+
}, zt = (e = {}) => {
|
|
3050
3037
|
if (!e.callId) return;
|
|
3051
|
-
let t =
|
|
3038
|
+
let t = gt.current === e.callId, n = ht.current === e.callId, r = lt.current?.callId === e.callId;
|
|
3052
3039
|
if (!(!t && !n && !r)) {
|
|
3053
|
-
if (
|
|
3054
|
-
|
|
3040
|
+
if (Pt(), n) {
|
|
3041
|
+
It();
|
|
3055
3042
|
return;
|
|
3056
3043
|
}
|
|
3057
|
-
|
|
3044
|
+
gt.current = null, ft.current = null, N.current = [], qe(null), Ze("idle");
|
|
3058
3045
|
}
|
|
3059
|
-
},
|
|
3046
|
+
}, Bt = async (e = {}) => {
|
|
3060
3047
|
let t = ut.current, n = A.current, r = e.sdpOffer || e.offer?.sdp;
|
|
3061
3048
|
if (!t || !n?.connected || !r || !e.callId) {
|
|
3062
3049
|
console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
|
|
@@ -3071,14 +3058,14 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3071
3058
|
if (await t.setRemoteDescription(new RTCSessionDescription({
|
|
3072
3059
|
type: "offer",
|
|
3073
3060
|
sdp: r
|
|
3074
|
-
})),
|
|
3061
|
+
})), N.current.length > 0) {
|
|
3075
3062
|
console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
|
|
3076
3063
|
callId: e.callId,
|
|
3077
3064
|
chatId: ot.current,
|
|
3078
|
-
queuedCount:
|
|
3065
|
+
queuedCount: N.current.length
|
|
3079
3066
|
});
|
|
3080
|
-
for (let e of
|
|
3081
|
-
|
|
3067
|
+
for (let e of N.current) await t.addIceCandidate(new RTCIceCandidate(e));
|
|
3068
|
+
N.current = [];
|
|
3082
3069
|
}
|
|
3083
3070
|
let i = await t.createAnswer();
|
|
3084
3071
|
await t.setLocalDescription(i), n.emit("call:answer", {
|
|
@@ -3091,15 +3078,15 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3091
3078
|
ye({
|
|
3092
3079
|
isOpen: T,
|
|
3093
3080
|
activeScreen: ne,
|
|
3094
|
-
isHumanHandled:
|
|
3095
|
-
agentName:
|
|
3081
|
+
isHumanHandled: E,
|
|
3082
|
+
agentName: se,
|
|
3096
3083
|
agentHeadshot: fe
|
|
3097
3084
|
});
|
|
3098
3085
|
}, [
|
|
3099
3086
|
T,
|
|
3100
3087
|
ne,
|
|
3101
|
-
|
|
3102
|
-
|
|
3088
|
+
E,
|
|
3089
|
+
se,
|
|
3103
3090
|
fe
|
|
3104
3091
|
]), c(() => {
|
|
3105
3092
|
let e = !0;
|
|
@@ -3115,14 +3102,14 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3115
3102
|
apiBaseUrl: t.apiBaseUrl,
|
|
3116
3103
|
userId: n.userId,
|
|
3117
3104
|
siteId: a,
|
|
3118
|
-
priorChatId: e || r ? null : o ||
|
|
3105
|
+
priorChatId: e || r ? null : o || ce(),
|
|
3119
3106
|
forceNew: e,
|
|
3120
3107
|
resumeChatId: r,
|
|
3121
3108
|
visitorId: s
|
|
3122
3109
|
}))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
|
|
3123
|
-
|
|
3110
|
+
le(), _e(a, c);
|
|
3124
3111
|
} catch (e) {
|
|
3125
|
-
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o ||
|
|
3112
|
+
console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ue(), _e(a, c);
|
|
3126
3113
|
}
|
|
3127
3114
|
ot.current = c;
|
|
3128
3115
|
let l = Ke({
|
|
@@ -3141,12 +3128,8 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3141
3128
|
chatId: c,
|
|
3142
3129
|
siteId: t.siteId
|
|
3143
3130
|
});
|
|
3144
|
-
A.current = f, f.on("connect",
|
|
3131
|
+
A.current = f, f.on("connect", () => {
|
|
3145
3132
|
ke("connected");
|
|
3146
|
-
let e = ot.current;
|
|
3147
|
-
if (e && j.current) try {
|
|
3148
|
-
Nt(await j.current.checkHumanHandled(e));
|
|
3149
|
-
} catch {}
|
|
3150
3133
|
}), f.on("disconnect", () => {
|
|
3151
3134
|
ke("disconnected");
|
|
3152
3135
|
}), f.on("aiTyping", () => {
|
|
@@ -3188,7 +3171,7 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3188
3171
|
...n,
|
|
3189
3172
|
isPending: !1,
|
|
3190
3173
|
id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
|
|
3191
|
-
}]), (n.sender === "agent" || n.agent_name) && (
|
|
3174
|
+
}]), (n.sender === "agent" || n.agent_name) && (D(!0), re("agent"), de(Ur([
|
|
3192
3175
|
n.agent_name,
|
|
3193
3176
|
n.agentName,
|
|
3194
3177
|
n.metadata?.agentName
|
|
@@ -3199,9 +3182,9 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3199
3182
|
e.agent?.name,
|
|
3200
3183
|
e.agentName,
|
|
3201
3184
|
e.agent_name,
|
|
3202
|
-
|
|
3185
|
+
Tt.current
|
|
3203
3186
|
], d);
|
|
3204
|
-
|
|
3187
|
+
D(!0), re("agent"), de(t), pe(e.agent?.headshot || null), te(!0), ze((e) => e + 1), S((e) => Wr(e, {
|
|
3205
3188
|
id: `agent-joined-${Date.now()}`,
|
|
3206
3189
|
sender: "system",
|
|
3207
3190
|
message: `${t} has joined the chat.`,
|
|
@@ -3213,9 +3196,9 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3213
3196
|
e.agent?.name,
|
|
3214
3197
|
e.agentName,
|
|
3215
3198
|
e.agent_name,
|
|
3216
|
-
|
|
3199
|
+
Tt.current
|
|
3217
3200
|
], d);
|
|
3218
|
-
|
|
3201
|
+
D(!1), re("ai"), S((e) => Wr(e, {
|
|
3219
3202
|
id: `agent-left-${Date.now()}`,
|
|
3220
3203
|
sender: "system",
|
|
3221
3204
|
message: `${t} has left the chat.`,
|
|
@@ -3235,9 +3218,9 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3235
3218
|
}]);
|
|
3236
3219
|
}), f.on("chat:history_update", (e) => {
|
|
3237
3220
|
let t = zr(e.chat_history || []);
|
|
3238
|
-
S(t), t.length === 0 && (Ue(!1),
|
|
3221
|
+
S(t), t.length === 0 && (Ue(!1), D(!1), re("ai"), De(!1), we(!1));
|
|
3239
3222
|
}), f.on("conversation:reset", () => {
|
|
3240
|
-
S([]), Ue(!1),
|
|
3223
|
+
S([]), Ue(!1), D(!1), re("ai"), De(!1), we(!1);
|
|
3241
3224
|
}), f.on("voice:end_session", (e = {}) => {
|
|
3242
3225
|
console.log("[FlowEngageProvider] voice:end_session received — ending ElevenLabs session"), Ve((e) => e + 1), te(!0), ze((e) => e + 1);
|
|
3243
3226
|
}), f.on("typing:start", (e) => {
|
|
@@ -3249,9 +3232,9 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3249
3232
|
e.agentName,
|
|
3250
3233
|
e.ownerName,
|
|
3251
3234
|
e.agent?.name,
|
|
3252
|
-
|
|
3235
|
+
Tt.current
|
|
3253
3236
|
], "Agent");
|
|
3254
|
-
|
|
3237
|
+
Nt(), Pt(), vt.current = !1, qe({
|
|
3255
3238
|
callId: e.callId,
|
|
3256
3239
|
from: e.from || "owner",
|
|
3257
3240
|
agentId: e.agentId || null,
|
|
@@ -3260,7 +3243,7 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3260
3243
|
}), f.on("call:offer", async (e = {}) => {
|
|
3261
3244
|
ft.current = e;
|
|
3262
3245
|
try {
|
|
3263
|
-
await
|
|
3246
|
+
await Bt(e);
|
|
3264
3247
|
} catch (e) {
|
|
3265
3248
|
console.error("[FlowEngageProvider] failed to apply remote offer", e);
|
|
3266
3249
|
}
|
|
@@ -3275,8 +3258,8 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3275
3258
|
console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
|
|
3276
3259
|
callId: e.callId,
|
|
3277
3260
|
chatId: e.chatId || ot.current,
|
|
3278
|
-
queueSize:
|
|
3279
|
-
}),
|
|
3261
|
+
queueSize: N.current.length + 1
|
|
3262
|
+
}), N.current.push(t);
|
|
3280
3263
|
return;
|
|
3281
3264
|
}
|
|
3282
3265
|
await ut.current.addIceCandidate(new RTCIceCandidate(t));
|
|
@@ -3284,56 +3267,65 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3284
3267
|
console.error("[FlowEngageProvider] failed to add ICE candidate", e);
|
|
3285
3268
|
}
|
|
3286
3269
|
}), f.on("call:ended", () => {
|
|
3287
|
-
|
|
3270
|
+
Nt(), It("socket:call_ended");
|
|
3288
3271
|
}), f.on("call:accepted", (e = {}) => {
|
|
3289
|
-
|
|
3272
|
+
Rt(e);
|
|
3290
3273
|
}), f.on("call:accepted_by_other", (e = {}) => {
|
|
3291
|
-
|
|
3274
|
+
Rt(e);
|
|
3292
3275
|
}), f.on("call:rejected", (e = {}) => {
|
|
3293
|
-
|
|
3276
|
+
zt(e);
|
|
3294
3277
|
}), f.on("call:missed", (e = {}) => {
|
|
3295
|
-
|
|
3278
|
+
zt(e);
|
|
3296
3279
|
}), f.on("call:failed", (e = {}) => {
|
|
3297
|
-
|
|
3280
|
+
zt(e);
|
|
3298
3281
|
}), f.on("call:connected", (e = {}) => {
|
|
3299
3282
|
if (!e.callId) return;
|
|
3300
|
-
let t =
|
|
3283
|
+
let t = gt.current === e.callId, n = ht.current === e.callId, r = ft.current?.callId === e.callId, i = lt.current?.callId === e.callId;
|
|
3301
3284
|
if (!t && !n && !r) {
|
|
3302
3285
|
i && (qe(null), Ze("idle"));
|
|
3303
3286
|
return;
|
|
3304
3287
|
}
|
|
3305
|
-
|
|
3288
|
+
vt.current = !0, gt.current = null, ht.current = e.callId, Ye(e.callId), qe(null), Ze("connected"), $e(e.connectedAt || (/* @__PURE__ */ new Date()).toISOString()), te(!0);
|
|
3306
3289
|
}), f.on("call:unavailable", (e = {}) => {
|
|
3307
|
-
|
|
3290
|
+
It("socket:call_unavailable"), rt(Vr(e, "This visitor is not available for a call right now.")), te(!0);
|
|
3308
3291
|
}), f.on("call:error", (e = {}) => {
|
|
3309
|
-
|
|
3310
|
-
}), f.on("visitor:navigate", async ({ url: e, section:
|
|
3311
|
-
|
|
3312
|
-
if (!e
|
|
3313
|
-
|
|
3292
|
+
It("socket:call_error"), rt(Vr(e, "We couldn't connect the call right now.")), te(!0);
|
|
3293
|
+
}), f.on("visitor:navigate", async ({ url: e, section: n, highlight: r } = {}) => {
|
|
3294
|
+
if (e) {
|
|
3295
|
+
if (!await Er(e, {
|
|
3296
|
+
siteId: t.siteId,
|
|
3297
|
+
apiBaseUrl: t.apiBaseUrl
|
|
3298
|
+
})) {
|
|
3299
|
+
C();
|
|
3314
3300
|
return;
|
|
3315
3301
|
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3302
|
+
Nr(e, { voiceActive: Ot.current }).then(({ navigated: e, reason: t }) => {
|
|
3303
|
+
if (!e) {
|
|
3304
|
+
t === "not-found" ? C() : t === "already-on-page" && w();
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
let i = n || r;
|
|
3308
|
+
i && setTimeout(() => {
|
|
3309
|
+
let e = xr(null, i);
|
|
3310
|
+
e && Sr(e);
|
|
3311
|
+
}, 300);
|
|
3312
|
+
});
|
|
3313
|
+
}
|
|
3322
3314
|
}), f.on("visitor:highlight", ({ sectionId: e, sectionText: t } = {}) => {
|
|
3323
3315
|
if (!e && !t) return;
|
|
3324
3316
|
let n = xr(e || null, t || null);
|
|
3325
3317
|
n && Sr(n);
|
|
3326
3318
|
}), f.on("visitor:clear_highlight", () => {
|
|
3327
3319
|
Cr();
|
|
3328
|
-
}),
|
|
3320
|
+
}), At.current = Nn({
|
|
3329
3321
|
socket: f,
|
|
3330
3322
|
chatId: c
|
|
3331
3323
|
});
|
|
3332
3324
|
let h = await l.loadHistory(c, r);
|
|
3333
3325
|
if (!e) return;
|
|
3334
|
-
S(zr(h.chat_history || [])),
|
|
3326
|
+
S(zr(h.chat_history || [])), D(!!h.is_human_handled), re(h.is_human_handled ? "agent" : ne);
|
|
3335
3327
|
let g = h?.visitor_email || h?.visitorEmail;
|
|
3336
|
-
if (g && String(g).trim() &&
|
|
3328
|
+
if (g && String(g).trim() && Ft(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
|
|
3337
3329
|
u("ready");
|
|
3338
3330
|
} catch (t) {
|
|
3339
3331
|
if (!e) return;
|
|
@@ -3342,32 +3334,45 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3342
3334
|
e && at(!1);
|
|
3343
3335
|
}
|
|
3344
3336
|
})(), () => {
|
|
3345
|
-
e = !1,
|
|
3337
|
+
e = !1, At.current?.cleanup?.(), It(), A.current?.disconnect();
|
|
3346
3338
|
};
|
|
3347
3339
|
}, [
|
|
3348
3340
|
i,
|
|
3349
3341
|
r,
|
|
3350
3342
|
a
|
|
3351
3343
|
]), c(() => () => {
|
|
3352
|
-
if (Ie && !
|
|
3353
|
-
let e = ot.current, t =
|
|
3354
|
-
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}),
|
|
3344
|
+
if (Ie && !Dt.current && Et.current.length > 0) {
|
|
3345
|
+
let e = ot.current, t = Et.current, n = j.current;
|
|
3346
|
+
n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Dt.current = !0);
|
|
3355
3347
|
}
|
|
3356
3348
|
}, [Ie, _]);
|
|
3357
|
-
let
|
|
3349
|
+
let Vt = p(null), Ht = p(!1);
|
|
3358
3350
|
c(() => {
|
|
3359
3351
|
let e = j.current;
|
|
3360
|
-
!e || !y ||
|
|
3352
|
+
!e || !y || Vt.current !== T && (T && Vt.current !== null ? (e.updateChatStatus(y, "open").catch(() => {}), Ht.current = !0) : Vt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), Vt.current = T);
|
|
3361
3353
|
}, [T, y]), c(() => {
|
|
3362
3354
|
let e = () => {
|
|
3363
3355
|
let e = ot.current, t = j.current;
|
|
3364
3356
|
!e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
|
|
3365
3357
|
};
|
|
3366
3358
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
3367
|
-
}, [])
|
|
3368
|
-
|
|
3359
|
+
}, []), c(() => {
|
|
3360
|
+
if (!j.current || !y || l !== "ready") return;
|
|
3361
|
+
let e = window.setInterval(async () => {
|
|
3362
|
+
try {
|
|
3363
|
+
let e = await j.current.checkHumanHandled(y);
|
|
3364
|
+
D(!!e.is_human_handled), e.is_human_handled && (re("agent"), e.agent_info?.name && de(Ur([e.agent_info.name], "Agent")), e.agent_info?.headshot && pe(e.agent_info.headshot)), jt(e);
|
|
3365
|
+
} catch {}
|
|
3366
|
+
}, 1e4);
|
|
3367
|
+
return () => window.clearInterval(e);
|
|
3368
|
+
}, [
|
|
3369
|
+
y,
|
|
3370
|
+
l,
|
|
3371
|
+
jt
|
|
3372
|
+
]);
|
|
3373
|
+
let Ut = async () => {
|
|
3369
3374
|
if (!(!k?.callId || !j.current || !A.current || !y)) {
|
|
3370
|
-
|
|
3375
|
+
Nt(), gt.current = k.callId, Pt();
|
|
3371
3376
|
try {
|
|
3372
3377
|
let e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
3373
3378
|
M.current = e;
|
|
@@ -3383,26 +3388,26 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3383
3388
|
let e = n.connectionState;
|
|
3384
3389
|
if (e === "connected") {
|
|
3385
3390
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3386
|
-
Ze("connected"), $e((t) => t || e),
|
|
3391
|
+
Ze("connected"), $e((t) => t || e), Lt(e);
|
|
3387
3392
|
return;
|
|
3388
3393
|
}
|
|
3389
3394
|
if (e === "connecting") {
|
|
3390
3395
|
Ze((e) => e === "connected" ? e : "connecting");
|
|
3391
3396
|
return;
|
|
3392
3397
|
}
|
|
3393
|
-
(e === "failed" || e === "closed") &&
|
|
3398
|
+
(e === "failed" || e === "closed") && It(`peer:connection_${e}`);
|
|
3394
3399
|
}, n.oniceconnectionstatechange = () => {
|
|
3395
3400
|
let e = n.iceConnectionState;
|
|
3396
3401
|
if (e === "connected" || e === "completed") {
|
|
3397
3402
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3398
|
-
Ze("connected"), $e((t) => t || e),
|
|
3403
|
+
Ze("connected"), $e((t) => t || e), Lt(e);
|
|
3399
3404
|
return;
|
|
3400
3405
|
}
|
|
3401
3406
|
if (e === "checking" || e === "new") {
|
|
3402
3407
|
Ze((e) => e === "connected" ? e : "connecting");
|
|
3403
3408
|
return;
|
|
3404
3409
|
}
|
|
3405
|
-
(e === "failed" || e === "closed") &&
|
|
3410
|
+
(e === "failed" || e === "closed") && It(`peer:ice_${e}`);
|
|
3406
3411
|
}, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
|
|
3407
3412
|
n.addTrack(t, e);
|
|
3408
3413
|
}), n.onicecandidate = (e) => {
|
|
@@ -3423,10 +3428,10 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3423
3428
|
e.id = "flowengage-remote-audio", e.autoplay = !0, e.playsInline = !0, e.onplay = () => {}, e.onpause = () => {}, e.onended = () => {}, e.onerror = (e) => {}, dt.current = e, document.body.appendChild(e);
|
|
3424
3429
|
}
|
|
3425
3430
|
dt.current.srcObject = e.streams[0];
|
|
3426
|
-
let r = k?.callId, i = r && (
|
|
3427
|
-
if (!
|
|
3431
|
+
let r = k?.callId, i = r && (gt.current === r || ht.current === r);
|
|
3432
|
+
if (!vt.current && i) {
|
|
3428
3433
|
let e = (/* @__PURE__ */ new Date()).toISOString();
|
|
3429
|
-
Ze("connected"), $e((t) => t || e),
|
|
3434
|
+
Ze("connected"), $e((t) => t || e), ht.current = r, Ye(r), Lt(e);
|
|
3430
3435
|
}
|
|
3431
3436
|
dt.current.srcObject = t || null;
|
|
3432
3437
|
let a = dt.current.play?.();
|
|
@@ -3436,15 +3441,15 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3436
3441
|
r && (console.log("[FlowEngageProvider] found pending remote offer during accept", {
|
|
3437
3442
|
callId: r.callId || k.callId,
|
|
3438
3443
|
chatId: y
|
|
3439
|
-
}), await
|
|
3444
|
+
}), await Bt({
|
|
3440
3445
|
...r,
|
|
3441
3446
|
callId: r.callId || k.callId
|
|
3442
3447
|
})), await j.current.acceptCall(k.callId, y), A.current?.emit("call:accepted", {
|
|
3443
3448
|
callId: k.callId,
|
|
3444
3449
|
chatId: y
|
|
3445
|
-
}),
|
|
3450
|
+
}), ht.current = k.callId, Ye(k.callId), Ze((e) => e === "connected" || vt.current ? "connected" : "connecting"), qe(null), te(!0);
|
|
3446
3451
|
} catch (e) {
|
|
3447
|
-
if (
|
|
3452
|
+
if (gt.current = null, It("accept_call_failed"), e?.status === 404 || e?.status === 409 || e?.status === 422) {
|
|
3448
3453
|
rt(Vr(e, "This visitor call is no longer available."));
|
|
3449
3454
|
return;
|
|
3450
3455
|
}
|
|
@@ -3460,13 +3465,13 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3460
3465
|
rt("We couldn't connect the call right now. Please try again.");
|
|
3461
3466
|
}
|
|
3462
3467
|
}
|
|
3463
|
-
},
|
|
3468
|
+
}, Wt = async () => {
|
|
3464
3469
|
if (!k?.callId || !j.current || !y) {
|
|
3465
|
-
|
|
3470
|
+
It("reject_call_without_server_context");
|
|
3466
3471
|
return;
|
|
3467
3472
|
}
|
|
3468
3473
|
let e = k.callId;
|
|
3469
|
-
|
|
3474
|
+
Pt(), Nt(), A.current?.emit("call:rejected", {
|
|
3470
3475
|
callId: e,
|
|
3471
3476
|
chatId: y,
|
|
3472
3477
|
reason: "visitor_declined"
|
|
@@ -3476,48 +3481,48 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3476
3481
|
} catch (e) {
|
|
3477
3482
|
rt(Vr(e, "We couldn't decline the call cleanly."));
|
|
3478
3483
|
} finally {
|
|
3479
|
-
|
|
3484
|
+
It("reject_call_finally");
|
|
3480
3485
|
}
|
|
3481
|
-
},
|
|
3482
|
-
|
|
3486
|
+
}, Gt = p(Wt);
|
|
3487
|
+
Gt.current = Wt, c(() => {
|
|
3483
3488
|
if (!k?.callId || Je) {
|
|
3484
|
-
|
|
3489
|
+
Pt();
|
|
3485
3490
|
return;
|
|
3486
3491
|
}
|
|
3487
3492
|
let e = k.callId;
|
|
3488
|
-
return
|
|
3489
|
-
lt.current?.callId === e &&
|
|
3490
|
-
},
|
|
3491
|
-
|
|
3493
|
+
return Pt(), _t.current = window.setTimeout(() => {
|
|
3494
|
+
lt.current?.callId === e && gt.current !== e && ht.current !== e && Gt.current();
|
|
3495
|
+
}, oe), () => {
|
|
3496
|
+
_t.current &&= (window.clearTimeout(_t.current), null);
|
|
3492
3497
|
};
|
|
3493
3498
|
}, [
|
|
3494
3499
|
Je,
|
|
3495
|
-
|
|
3500
|
+
Pt,
|
|
3496
3501
|
k?.callId
|
|
3497
3502
|
]);
|
|
3498
|
-
let
|
|
3503
|
+
let Kt = async () => {
|
|
3499
3504
|
if (!Je || !j.current || !y) {
|
|
3500
|
-
|
|
3505
|
+
It("end_call_without_server_context");
|
|
3501
3506
|
return;
|
|
3502
3507
|
}
|
|
3503
|
-
|
|
3508
|
+
Nt();
|
|
3504
3509
|
try {
|
|
3505
3510
|
await j.current.endWebRTCCall(Je, y);
|
|
3506
3511
|
} catch (e) {
|
|
3507
3512
|
rt(Vr(e, "The call ended locally, but the server could not be updated."));
|
|
3508
3513
|
} finally {
|
|
3509
|
-
|
|
3514
|
+
It("end_call_finally");
|
|
3510
3515
|
}
|
|
3511
|
-
},
|
|
3516
|
+
}, qt = () => {
|
|
3512
3517
|
let e = M.current?.getAudioTracks?.() || [], t = ut.current?.getSenders?.().map((e) => e.track).filter((e) => e?.kind === "audio") || [], n = [...e, ...t].filter(Boolean);
|
|
3513
3518
|
if (n.length === 0) return;
|
|
3514
3519
|
let r = !et;
|
|
3515
3520
|
n.forEach((e) => {
|
|
3516
3521
|
e.enabled = !r;
|
|
3517
3522
|
}), tt(r);
|
|
3518
|
-
},
|
|
3523
|
+
}, Jt = async (e = {}) => {
|
|
3519
3524
|
let t = e.notifyChatInitiated === !0;
|
|
3520
|
-
if (te(!0), !(!t || !j.current || !y || typeof window > "u")) {
|
|
3525
|
+
if (Ht.current = !0, te(!0), !(!t || !j.current || !y || typeof window > "u")) {
|
|
3521
3526
|
try {
|
|
3522
3527
|
await j.current.trackVisitor({
|
|
3523
3528
|
chatId: y,
|
|
@@ -3528,8 +3533,8 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3528
3533
|
await j.current.updateChatStatus(y, "open");
|
|
3529
3534
|
} catch {}
|
|
3530
3535
|
}
|
|
3531
|
-
},
|
|
3532
|
-
let t =
|
|
3536
|
+
}, Yt = async (e) => {
|
|
3537
|
+
let t = Ft(e);
|
|
3533
3538
|
if (!t || !j.current || !ot.current) return t;
|
|
3534
3539
|
try {
|
|
3535
3540
|
await j.current.trackVisitor({
|
|
@@ -3541,25 +3546,25 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3541
3546
|
console.error("[FlowEngageProvider] failed to persist visitor email", e);
|
|
3542
3547
|
}
|
|
3543
3548
|
return t;
|
|
3544
|
-
},
|
|
3545
|
-
!y || !A.current?.connected ||
|
|
3549
|
+
}, Xt = () => {
|
|
3550
|
+
!y || !A.current?.connected || yt.current || (yt.current = !0, A.current.emit("typing:start", {
|
|
3546
3551
|
chatId: y,
|
|
3547
3552
|
sender: "user"
|
|
3548
3553
|
}));
|
|
3549
|
-
},
|
|
3550
|
-
!y || !A.current?.connected || !
|
|
3554
|
+
}, Zt = () => {
|
|
3555
|
+
!y || !A.current?.connected || !yt.current || (yt.current = !1, A.current.emit("typing:stop", {
|
|
3551
3556
|
chatId: y,
|
|
3552
3557
|
sender: "user"
|
|
3553
3558
|
}));
|
|
3554
|
-
},
|
|
3559
|
+
}, Qt = (e = "") => {
|
|
3555
3560
|
let t = typeof e == "string" ? e : "";
|
|
3556
|
-
!y || !A.current?.connected || t !== "" &&
|
|
3561
|
+
!y || !A.current?.connected || t !== "" && bt.current === t || (bt.current = t, A.current.emit("typing:update", {
|
|
3557
3562
|
chatId: y,
|
|
3558
3563
|
sender: "user",
|
|
3559
3564
|
text: t
|
|
3560
3565
|
}));
|
|
3561
3566
|
};
|
|
3562
|
-
function
|
|
3567
|
+
function $t() {
|
|
3563
3568
|
if (typeof document > "u") return null;
|
|
3564
3569
|
try {
|
|
3565
3570
|
let e = (document.querySelector("main") || document.querySelector("[role='main']") || document.querySelector("article") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
|
|
@@ -3570,117 +3575,126 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3570
3575
|
return null;
|
|
3571
3576
|
}
|
|
3572
3577
|
}
|
|
3573
|
-
let
|
|
3574
|
-
let
|
|
3575
|
-
if (!
|
|
3576
|
-
|
|
3577
|
-
let
|
|
3578
|
-
if (pt.current &&
|
|
3578
|
+
let en = async (e, t = "", n = null, a = {}) => {
|
|
3579
|
+
let o = typeof e == "string" ? e.trim() : "";
|
|
3580
|
+
if (!o || !j.current || !y || l !== "ready" || He) return;
|
|
3581
|
+
Zt(), mt.current = !1;
|
|
3582
|
+
let s = /^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i, c = /^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i, u = /\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;
|
|
3583
|
+
if (pt.current && s.test(o) && !c.test(o)) {
|
|
3579
3584
|
let { url: e, section: t } = pt.current;
|
|
3580
|
-
pt.current = null, mt.current = !0, console.log("[FWH Nav] Client-side nav firing →", e),
|
|
3585
|
+
pt.current = null, mt.current = !0, console.log("[FWH Nav] Client-side nav firing →", e), Nr(e, { voiceActive: Ot.current }).then(({ navigated: e, reason: n }) => {
|
|
3581
3586
|
if (!e) {
|
|
3582
3587
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3583
3588
|
return;
|
|
3584
3589
|
}
|
|
3585
|
-
!t || !
|
|
3590
|
+
!t || !Ot.current || setTimeout(() => {
|
|
3586
3591
|
let e = xr(null, t);
|
|
3587
3592
|
e && Sr(e);
|
|
3588
3593
|
}, 300);
|
|
3589
3594
|
});
|
|
3590
|
-
} else
|
|
3591
|
-
let
|
|
3592
|
-
id:
|
|
3595
|
+
} else s.test(o) || (pt.current = null);
|
|
3596
|
+
let d = `pending-user-${Date.now()}`, f = {
|
|
3597
|
+
id: d,
|
|
3593
3598
|
sender: "user",
|
|
3594
3599
|
message: e,
|
|
3595
3600
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3596
3601
|
isPending: !0,
|
|
3597
|
-
type:
|
|
3598
|
-
metadata:
|
|
3602
|
+
type: a?.type || "text",
|
|
3603
|
+
metadata: a?.metadata || void 0,
|
|
3599
3604
|
...n || {}
|
|
3600
3605
|
};
|
|
3601
|
-
S((e) => [...e,
|
|
3602
|
-
let
|
|
3603
|
-
if (
|
|
3604
|
-
|
|
3606
|
+
S((e) => [...e, f]);
|
|
3607
|
+
let p = E;
|
|
3608
|
+
if (p) try {
|
|
3609
|
+
p = jt(await j.current.checkHumanHandled(y));
|
|
3605
3610
|
} catch {}
|
|
3606
|
-
if (
|
|
3611
|
+
if (p && A.current?.connected) {
|
|
3607
3612
|
A.current.emit("customer:message", {
|
|
3608
3613
|
chatId: y,
|
|
3609
3614
|
content: e,
|
|
3610
3615
|
sender: "user",
|
|
3611
3616
|
email: me || void 0,
|
|
3612
|
-
type:
|
|
3613
|
-
metadata:
|
|
3617
|
+
type: a?.type || "text",
|
|
3618
|
+
metadata: a?.metadata || {},
|
|
3614
3619
|
...n || {}
|
|
3615
3620
|
});
|
|
3616
3621
|
return;
|
|
3617
3622
|
}
|
|
3618
3623
|
Ae(!0);
|
|
3619
3624
|
try {
|
|
3620
|
-
let
|
|
3625
|
+
let s = await j.current.sendAiMessage(y, e, r, t, {
|
|
3621
3626
|
...n || {},
|
|
3622
3627
|
...me ? { email: me } : {}
|
|
3623
3628
|
}, {
|
|
3624
|
-
...
|
|
3629
|
+
...a,
|
|
3625
3630
|
currentPageUrl: typeof window < "u" ? window.location.href : void 0,
|
|
3626
3631
|
currentPageTitle: typeof window < "u" ? document.title : void 0,
|
|
3627
3632
|
currentPagePath: typeof window < "u" ? window.location.pathname : void 0,
|
|
3628
|
-
currentPageContent:
|
|
3629
|
-
}),
|
|
3633
|
+
currentPageContent: $t() || void 0
|
|
3634
|
+
}), c = s.chat_history || [];
|
|
3630
3635
|
if (console.log("[FWH Nav Debug] API response fields:", {
|
|
3631
|
-
has_navigate: !!
|
|
3632
|
-
navigate:
|
|
3633
|
-
has_pending_navigate: !!
|
|
3634
|
-
pending_navigate:
|
|
3635
|
-
last_bot_msg: [...
|
|
3636
|
-
}),
|
|
3636
|
+
has_navigate: !!s.navigate,
|
|
3637
|
+
navigate: s.navigate,
|
|
3638
|
+
has_pending_navigate: !!s.pending_navigate,
|
|
3639
|
+
pending_navigate: s.pending_navigate,
|
|
3640
|
+
last_bot_msg: [...c].reverse().find((e) => e.sender === "bot")?.message?.substring(0, 80)
|
|
3641
|
+
}), s.pending_navigate?.url) {
|
|
3637
3642
|
let e = {
|
|
3638
|
-
url:
|
|
3639
|
-
section:
|
|
3643
|
+
url: s.pending_navigate.url,
|
|
3644
|
+
section: s.pending_navigate.section || null
|
|
3640
3645
|
};
|
|
3641
|
-
|
|
3646
|
+
u.test(o) ? (console.log("[FWH Nav] Auto-navigating (intent detected) →", e.url), Er(e.url, {
|
|
3647
|
+
siteId: i?.siteId,
|
|
3648
|
+
apiBaseUrl: i?.apiBaseUrl
|
|
3649
|
+
}).then((t) => {
|
|
3642
3650
|
if (!t) {
|
|
3643
|
-
|
|
3651
|
+
C();
|
|
3644
3652
|
return;
|
|
3645
3653
|
}
|
|
3646
|
-
e.
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3654
|
+
Nr(e.url, { voiceActive: Ot.current }).then(({ navigated: t, reason: n }) => {
|
|
3655
|
+
if (!t) {
|
|
3656
|
+
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3657
|
+
return;
|
|
3658
|
+
}
|
|
3659
|
+
e.section && setTimeout(() => {
|
|
3660
|
+
let t = xr(null, e.section);
|
|
3661
|
+
t && Sr(t);
|
|
3662
|
+
}, 300);
|
|
3663
|
+
});
|
|
3650
3664
|
})) : (pt.current = e, console.log("[FWH Nav] Stored pending nav →", pt.current));
|
|
3651
3665
|
}
|
|
3652
|
-
if (
|
|
3666
|
+
if (s.navigate?.url) if (mt.current) mt.current = !1;
|
|
3653
3667
|
else {
|
|
3654
|
-
let { url: e, section: t } =
|
|
3655
|
-
|
|
3668
|
+
let { url: e, section: t } = s.navigate;
|
|
3669
|
+
Nr(e, { voiceActive: Ot.current }).then(({ navigated: e, reason: n }) => {
|
|
3656
3670
|
if (!e) {
|
|
3657
3671
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3658
3672
|
return;
|
|
3659
3673
|
}
|
|
3660
|
-
!t || !
|
|
3674
|
+
!t || !Ot.current || setTimeout(() => {
|
|
3661
3675
|
let e = xr(null, t);
|
|
3662
3676
|
e && Sr(e);
|
|
3663
3677
|
}, 300);
|
|
3664
3678
|
});
|
|
3665
3679
|
}
|
|
3666
3680
|
else {
|
|
3667
|
-
let e = [...
|
|
3681
|
+
let e = [...c].reverse().find((e) => e.sender === "bot" || e.sender === "assistant");
|
|
3668
3682
|
if (e?.message) {
|
|
3669
3683
|
let t = Br(e.message);
|
|
3670
3684
|
t && Er(t.url, {
|
|
3671
|
-
siteId:
|
|
3672
|
-
apiBaseUrl:
|
|
3685
|
+
siteId: kt.current?.siteId,
|
|
3686
|
+
apiBaseUrl: kt.current?.apiBaseUrl
|
|
3673
3687
|
}).then((e) => {
|
|
3674
3688
|
if (!e) {
|
|
3675
3689
|
C();
|
|
3676
3690
|
return;
|
|
3677
3691
|
}
|
|
3678
|
-
|
|
3692
|
+
Nr(t.url, { voiceActive: Ot.current }).then(({ navigated: e, reason: n }) => {
|
|
3679
3693
|
if (!e) {
|
|
3680
3694
|
n === "not-found" ? C() : n === "already-on-page" && w();
|
|
3681
3695
|
return;
|
|
3682
3696
|
}
|
|
3683
|
-
!t.section || !
|
|
3697
|
+
!t.section || !Ot.current || setTimeout(() => {
|
|
3684
3698
|
let e = xr(null, t.section);
|
|
3685
3699
|
e && Sr(e);
|
|
3686
3700
|
}, 300);
|
|
@@ -3688,26 +3702,26 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3688
3702
|
});
|
|
3689
3703
|
}
|
|
3690
3704
|
}
|
|
3691
|
-
S(zr(
|
|
3705
|
+
S(zr(c)), D(!!s.is_human_handled), re(s.is_human_handled ? "agent" : "ai"), De(!1), Ae(!1), await j.current.updateChatStatus(y, "messageSent");
|
|
3692
3706
|
} catch (e) {
|
|
3693
|
-
S((e) => e.filter((e) => e.id !==
|
|
3707
|
+
S((e) => e.filter((e) => e.id !== d)), De(!1), Ae(!1), e.status === 429 ? (Me(!0), Fe(e.message), window.setTimeout(() => {
|
|
3694
3708
|
Me(!1), Fe("");
|
|
3695
|
-
},
|
|
3709
|
+
}, ie)) : h(e);
|
|
3696
3710
|
}
|
|
3697
|
-
},
|
|
3711
|
+
}, tn = async (e) => {
|
|
3698
3712
|
if (!j.current || !e) throw Error("Upload is unavailable right now.");
|
|
3699
3713
|
return j.current.uploadChatFile(e);
|
|
3700
|
-
},
|
|
3714
|
+
}, nn = async (e) => {
|
|
3701
3715
|
if (!(!j.current || !y)) {
|
|
3702
3716
|
try {
|
|
3703
3717
|
let t = e ? "voice" : "text";
|
|
3704
3718
|
await j.current.setChatMode(y, t);
|
|
3705
3719
|
} catch {}
|
|
3706
|
-
Le(e), e && (
|
|
3720
|
+
Le(e), e && (Dt.current = !1);
|
|
3707
3721
|
}
|
|
3708
|
-
},
|
|
3709
|
-
if (
|
|
3710
|
-
if (
|
|
3722
|
+
}, rn = async (e) => {
|
|
3723
|
+
if (Dt.current) return;
|
|
3724
|
+
if (Dt.current = !0, !j.current || !y || !e?.length) {
|
|
3711
3725
|
Le(!1);
|
|
3712
3726
|
return;
|
|
3713
3727
|
}
|
|
@@ -3734,9 +3748,9 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3734
3748
|
} finally {
|
|
3735
3749
|
Le(!1);
|
|
3736
3750
|
}
|
|
3737
|
-
},
|
|
3751
|
+
}, an = async () => {
|
|
3738
3752
|
if (!(!j.current || !y)) {
|
|
3739
|
-
Ie && !
|
|
3753
|
+
Ie && !Dt.current && Et.current.length > 0 && await rn(Et.current);
|
|
3740
3754
|
try {
|
|
3741
3755
|
await j.current.endConversation(y);
|
|
3742
3756
|
} catch {
|
|
@@ -3754,9 +3768,9 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3754
3768
|
}
|
|
3755
3769
|
};
|
|
3756
3770
|
c(() => {
|
|
3757
|
-
if (Xe !== "connected" || !Je || !y || !Qe || !
|
|
3758
|
-
let e = new Date(Qe).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0,
|
|
3759
|
-
rt("The call ended because it reached the time limit."),
|
|
3771
|
+
if (Xe !== "connected" || !Je || !y || !Qe || !Mt) return;
|
|
3772
|
+
let e = new Date(Qe).getTime(), t = Number.isFinite(e) ? Date.now() - e : 0, n = Math.max(0, Mt * 1e3 - t), r = window.setTimeout(() => {
|
|
3773
|
+
rt("The call ended because it reached the time limit."), Kt();
|
|
3760
3774
|
}, n);
|
|
3761
3775
|
return () => window.clearTimeout(r);
|
|
3762
3776
|
}, [
|
|
@@ -3764,29 +3778,29 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3764
3778
|
Qe,
|
|
3765
3779
|
Xe,
|
|
3766
3780
|
y,
|
|
3767
|
-
|
|
3768
|
-
|
|
3781
|
+
Kt,
|
|
3782
|
+
Mt
|
|
3769
3783
|
]), c(() => {
|
|
3770
3784
|
let e = () => {
|
|
3771
3785
|
let e = ot.current, t = j.current;
|
|
3772
3786
|
if (!t || !e) return;
|
|
3773
|
-
if (
|
|
3774
|
-
t.beaconEndWebRTCCall(
|
|
3787
|
+
if (Ot.current && Et.current.length > 0 && Ne(), !Dt.current && Et.current.length > 0 && (t.beaconSyncVoice(e, Et.current) || t.syncVoice(e, Et.current).catch(() => {}), Dt.current = !0), ht.current) {
|
|
3788
|
+
t.beaconEndWebRTCCall(ht.current, e);
|
|
3775
3789
|
return;
|
|
3776
3790
|
}
|
|
3777
|
-
let n =
|
|
3791
|
+
let n = gt.current || lt.current?.callId;
|
|
3778
3792
|
n && t.beaconCustomerUnavailable(n, e);
|
|
3779
3793
|
};
|
|
3780
3794
|
return window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), () => {
|
|
3781
3795
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
3782
3796
|
};
|
|
3783
3797
|
}, []);
|
|
3784
|
-
let
|
|
3798
|
+
let on = o(() => {
|
|
3785
3799
|
let e = i?.siteId;
|
|
3786
|
-
ge(e), st.current = !0, ct.current = null, A.current?.disconnect(), S([]), b(""), ot.current = "", Ue(!1),
|
|
3787
|
-
}, [i?.siteId]),
|
|
3788
|
-
i?.siteId, st.current = !1, ct.current = e, A.current?.disconnect(), S([]), b(""), ot.current = "", Ue(!1),
|
|
3789
|
-
}, [i?.siteId]),
|
|
3800
|
+
ge(e), st.current = !0, ct.current = null, A.current?.disconnect(), S([]), b(""), ot.current = "", Ue(!1), D(!1), de(null), pe(null), at(!0), s((e) => e + 1);
|
|
3801
|
+
}, [i?.siteId]), sn = o((e) => {
|
|
3802
|
+
i?.siteId, st.current = !1, ct.current = e, A.current?.disconnect(), S([]), b(""), ot.current = "", Ue(!1), D(!1), de(null), pe(null), at(!0), s((e) => e + 1);
|
|
3803
|
+
}, [i?.siteId]), cn = f(() => ({
|
|
3790
3804
|
status: l,
|
|
3791
3805
|
error: d,
|
|
3792
3806
|
runtimeConfig: _,
|
|
@@ -3795,8 +3809,8 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3795
3809
|
chatHistory: x,
|
|
3796
3810
|
isOpen: T,
|
|
3797
3811
|
activeScreen: ne,
|
|
3798
|
-
isHumanHandled:
|
|
3799
|
-
agentName:
|
|
3812
|
+
isHumanHandled: E,
|
|
3813
|
+
agentName: se,
|
|
3800
3814
|
agentHeadshot: fe,
|
|
3801
3815
|
visitorEmail: me,
|
|
3802
3816
|
isAgentTyping: Ce,
|
|
@@ -3817,36 +3831,36 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3817
3831
|
isCallMuted: et,
|
|
3818
3832
|
webRTCError: nt,
|
|
3819
3833
|
language: r,
|
|
3820
|
-
historyRef:
|
|
3821
|
-
hasSyncedRef:
|
|
3822
|
-
dismissCallError:
|
|
3823
|
-
captureVisitorEmail:
|
|
3824
|
-
startTyping:
|
|
3825
|
-
stopTyping:
|
|
3826
|
-
updateTypingDraft:
|
|
3827
|
-
notifyRouteChange: () =>
|
|
3828
|
-
openWidget:
|
|
3834
|
+
historyRef: Et,
|
|
3835
|
+
hasSyncedRef: Dt,
|
|
3836
|
+
dismissCallError: Nt,
|
|
3837
|
+
captureVisitorEmail: Yt,
|
|
3838
|
+
startTyping: Xt,
|
|
3839
|
+
stopTyping: Zt,
|
|
3840
|
+
updateTypingDraft: Qt,
|
|
3841
|
+
notifyRouteChange: () => At.current?.notifyRouteChange?.(),
|
|
3842
|
+
openWidget: Jt,
|
|
3829
3843
|
closeWidget: () => te(!1),
|
|
3830
3844
|
toggleWidget: () => {
|
|
3831
3845
|
if (T) {
|
|
3832
3846
|
te(!1);
|
|
3833
3847
|
return;
|
|
3834
3848
|
}
|
|
3835
|
-
|
|
3849
|
+
Jt({ notifyChatInitiated: !0 });
|
|
3836
3850
|
},
|
|
3837
|
-
sendMessage:
|
|
3838
|
-
uploadChatFile:
|
|
3839
|
-
setVoiceMode:
|
|
3840
|
-
onMessageSync:
|
|
3841
|
-
endConversation:
|
|
3842
|
-
startNewChat:
|
|
3843
|
-
resumeChat:
|
|
3851
|
+
sendMessage: en,
|
|
3852
|
+
uploadChatFile: tn,
|
|
3853
|
+
setVoiceMode: nn,
|
|
3854
|
+
onMessageSync: rn,
|
|
3855
|
+
endConversation: an,
|
|
3856
|
+
startNewChat: on,
|
|
3857
|
+
resumeChat: sn,
|
|
3844
3858
|
getVisitorChatHistory: () => j.current?.getVisitorChatHistory?.(),
|
|
3845
3859
|
getVisitorChatThread: (e) => j.current?.getVisitorChatThread?.(e),
|
|
3846
|
-
acceptCall:
|
|
3847
|
-
rejectCall:
|
|
3848
|
-
endWebRTCCall:
|
|
3849
|
-
toggleCallMute:
|
|
3860
|
+
acceptCall: Ut,
|
|
3861
|
+
rejectCall: Wt,
|
|
3862
|
+
endWebRTCCall: Kt,
|
|
3863
|
+
toggleCallMute: qt
|
|
3850
3864
|
}), [
|
|
3851
3865
|
l,
|
|
3852
3866
|
d,
|
|
@@ -3856,8 +3870,8 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3856
3870
|
x,
|
|
3857
3871
|
T,
|
|
3858
3872
|
ne,
|
|
3859
|
-
|
|
3860
|
-
|
|
3873
|
+
E,
|
|
3874
|
+
se,
|
|
3861
3875
|
fe,
|
|
3862
3876
|
me,
|
|
3863
3877
|
Ce,
|
|
@@ -3878,25 +3892,25 @@ function Gr({ siteId: e, config: t, children: n, language: r = "en" }) {
|
|
|
3878
3892
|
et,
|
|
3879
3893
|
nt,
|
|
3880
3894
|
r,
|
|
3895
|
+
Yt,
|
|
3881
3896
|
Xt,
|
|
3882
3897
|
Zt,
|
|
3883
3898
|
Qt,
|
|
3884
|
-
|
|
3899
|
+
Ut,
|
|
3885
3900
|
Wt,
|
|
3886
|
-
|
|
3901
|
+
Kt,
|
|
3887
3902
|
qt,
|
|
3888
3903
|
Jt,
|
|
3889
|
-
|
|
3904
|
+
en,
|
|
3890
3905
|
tn,
|
|
3891
3906
|
nn,
|
|
3892
3907
|
rn,
|
|
3893
3908
|
an,
|
|
3894
3909
|
on,
|
|
3895
|
-
|
|
3896
|
-
Ft
|
|
3910
|
+
Nt
|
|
3897
3911
|
]);
|
|
3898
3912
|
return /* @__PURE__ */ g(Pn.Provider, {
|
|
3899
|
-
value:
|
|
3913
|
+
value: cn,
|
|
3900
3914
|
children: n
|
|
3901
3915
|
});
|
|
3902
3916
|
}
|
|
@@ -27351,7 +27365,7 @@ function rO({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
|
|
|
27351
27365
|
//#endregion
|
|
27352
27366
|
//#region src/components/ChatInput.jsx
|
|
27353
27367
|
function iO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: c, clearReplyContext: l, requiresEmail: u, emailInput: d, setEmailInput: f, emailError: m, showVoiceToggle: v = !1, voiceEnabled: y = !0, onFileSelect: b, selectedFile: x = null, onRemoveSelectedFile: S, attachmentError: C = "", isUploadingAttachment: w = !1, inputPlaceholder: T = "Type your message" }) {
|
|
27354
|
-
let ee = p(null), te = c?.sender === "user" ? "You" : c?.sender === "agent" ? "Agent" : "AI Assistant", ne = u ? !!d?.trim() : !!e?.trim() || !!x, re = s || w || !ne,
|
|
27368
|
+
let ee = p(null), te = c?.sender === "user" ? "You" : c?.sender === "agent" ? "Agent" : "AI Assistant", ne = u ? !!d?.trim() : !!e?.trim() || !!x, re = s || w || !ne, E = !u && y && v;
|
|
27355
27369
|
return /* @__PURE__ */ _("div", {
|
|
27356
27370
|
style: {
|
|
27357
27371
|
padding: "0 16px",
|
|
@@ -27535,7 +27549,7 @@ function iO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
27535
27549
|
},
|
|
27536
27550
|
onSubmit: n,
|
|
27537
27551
|
children: [
|
|
27538
|
-
|
|
27552
|
+
E ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
|
|
27539
27553
|
ref: ee,
|
|
27540
27554
|
type: "file",
|
|
27541
27555
|
accept: XD,
|
|
@@ -27585,7 +27599,7 @@ function iO({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
|
|
|
27585
27599
|
fontSize: "14px",
|
|
27586
27600
|
outline: "none",
|
|
27587
27601
|
padding: 0,
|
|
27588
|
-
paddingLeft:
|
|
27602
|
+
paddingLeft: E ? "0" : "8px",
|
|
27589
27603
|
color: "#111827",
|
|
27590
27604
|
background: "transparent",
|
|
27591
27605
|
cursor: "text"
|
|
@@ -30051,34 +30065,34 @@ function gk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
|
|
|
30051
30065
|
]
|
|
30052
30066
|
});
|
|
30053
30067
|
}
|
|
30054
|
-
function _k({ 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
|
|
30068
|
+
function _k({ 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 }) {
|
|
30055
30069
|
c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
|
|
30056
|
-
let [
|
|
30070
|
+
let [b, x] = m("idle"), [S, C] = m(!1), [w, T] = m(!1), [ee, te] = m(!1), [ne, re] = m(""), [E, ie] = m(""), ae = p(!1), oe = p(!1), D = p(null), se = p(0), ce = p(""), le = p(null), ue = p(""), de = p(async () => {}), fe = p(!1), pe = p(!1), me = p(!1), he = p(!1), ge = p("minimized"), _e = p(null), ve = p(null), ye = p(null), be = p(0), xe = p(!1), Se = p("idle"), Ce = p(!1), we = p(!1), Te = p(null), Ee = p(null), De = p(!1), Oe = o((e = "minimized") => {
|
|
30057
30071
|
console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
|
|
30058
30072
|
destination: e,
|
|
30059
30073
|
stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
|
|
30060
|
-
}),
|
|
30061
|
-
|
|
30062
|
-
});
|
|
30063
|
-
}, [l]),
|
|
30064
|
-
|
|
30065
|
-
}, []),
|
|
30066
|
-
|
|
30067
|
-
if (!(!
|
|
30068
|
-
|
|
30074
|
+
}), ge.current = e, he.current = !0, queueMicrotask(() => {
|
|
30075
|
+
fe.current || (fe.current = !0, de.current?.());
|
|
30076
|
+
});
|
|
30077
|
+
}, [l]), ke = o(() => {
|
|
30078
|
+
D.current &&= (clearTimeout(D.current), null);
|
|
30079
|
+
}, []), Me = o(() => {
|
|
30080
|
+
ke(), D.current = setTimeout(() => {
|
|
30081
|
+
if (!(!oe.current || ae.current)) if (se.current < 3) {
|
|
30082
|
+
se.current += 1;
|
|
30069
30083
|
try {
|
|
30070
|
-
|
|
30084
|
+
le.current?.sendUserMessage?.("[SYSTEM: The visitor still has NOT entered their email in the text box. Remind them once, briefly and warmly: 'I still need your email in the box below to continue — could you enter it, please?' Then stay completely silent again. Do NOT answer any other question until the email is provided.]");
|
|
30071
30085
|
} catch {}
|
|
30072
|
-
|
|
30086
|
+
Me();
|
|
30073
30087
|
} else {
|
|
30074
30088
|
try {
|
|
30075
|
-
|
|
30089
|
+
le.current?.sendUserMessage?.("[SYSTEM: The visitor did not provide their email after multiple reminders. Say a brief, warm goodbye EXACTLY like: 'Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!' Then stop talking. Do NOT ask for the email again.]");
|
|
30076
30090
|
} catch {}
|
|
30077
|
-
|
|
30091
|
+
oe.current = !1, te(!1), ke(), xe.current = !0;
|
|
30078
30092
|
}
|
|
30079
30093
|
}, 1e4);
|
|
30080
|
-
}, [
|
|
30081
|
-
|
|
30094
|
+
}, [ke]), Pe = o(async (e) => {
|
|
30095
|
+
he.current = !0;
|
|
30082
30096
|
try {
|
|
30083
30097
|
Bn();
|
|
30084
30098
|
} catch {}
|
|
@@ -30086,9 +30100,9 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30086
30100
|
Ve(i);
|
|
30087
30101
|
} catch {}
|
|
30088
30102
|
try {
|
|
30089
|
-
await
|
|
30103
|
+
await le.current?.endSession?.();
|
|
30090
30104
|
} catch {}
|
|
30091
|
-
let t =
|
|
30105
|
+
let t = _e.current, n = ve.current;
|
|
30092
30106
|
if (t && s && a) {
|
|
30093
30107
|
let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
|
|
30094
30108
|
fetch(`${a}/api/voice/save-chat-recording`, {
|
|
@@ -30102,7 +30116,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30102
30116
|
})
|
|
30103
30117
|
}).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
|
|
30104
30118
|
}
|
|
30105
|
-
if (
|
|
30119
|
+
if (_e.current = null, ve.current = null, le.current = null, x("idle"), C(!1), fe.current = !1, Lr(), i) try {
|
|
30106
30120
|
je(i);
|
|
30107
30121
|
} catch {}
|
|
30108
30122
|
typeof u == "function" && await u(l.current), e?.();
|
|
@@ -30113,26 +30127,26 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30113
30127
|
s,
|
|
30114
30128
|
a
|
|
30115
30129
|
]);
|
|
30116
|
-
|
|
30117
|
-
|
|
30118
|
-
}, [
|
|
30119
|
-
d &&
|
|
30130
|
+
de.current = () => Pe(ge.current === "chat" ? t : n), c(() => {
|
|
30131
|
+
pe.current = S;
|
|
30132
|
+
}, [S]), c(() => {
|
|
30133
|
+
d && Oe("chat");
|
|
30120
30134
|
}, [d]), c(() => {
|
|
30121
30135
|
let e = !1, o = null, c = null, d = null;
|
|
30122
30136
|
return (async () => {
|
|
30123
30137
|
if (!r) {
|
|
30124
|
-
|
|
30138
|
+
x("error");
|
|
30125
30139
|
return;
|
|
30126
30140
|
}
|
|
30127
30141
|
try {
|
|
30128
30142
|
if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
|
|
30129
|
-
l.current = [],
|
|
30143
|
+
l.current = [], ue.current = "", fe.current = !1, me.current = !1, he.current = !1, ge.current = "minimized", Ir({ onBeforeNavigate: () => {
|
|
30130
30144
|
if (i && l.current.length > 0) try {
|
|
30131
30145
|
let e = CO(l.current);
|
|
30132
30146
|
e && O(i, e);
|
|
30133
30147
|
} catch {}
|
|
30134
30148
|
if (!or()) {
|
|
30135
|
-
let e =
|
|
30149
|
+
let e = _e.current, t = ve.current;
|
|
30136
30150
|
if (e && s && a) try {
|
|
30137
30151
|
let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
|
|
30138
30152
|
chatId: s,
|
|
@@ -30145,7 +30159,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30145
30159
|
headers: { "Content-Type": "application/json" },
|
|
30146
30160
|
body: r,
|
|
30147
30161
|
keepalive: !0
|
|
30148
|
-
}).catch(() => {}),
|
|
30162
|
+
}).catch(() => {}), _e.current = null, ve.current = null;
|
|
30149
30163
|
} catch {}
|
|
30150
30164
|
}
|
|
30151
30165
|
Ne();
|
|
@@ -30154,20 +30168,20 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30154
30168
|
siteId: i || null,
|
|
30155
30169
|
apiBaseUrl: a || null,
|
|
30156
30170
|
chatId: s || null,
|
|
30157
|
-
getLastUserVoiceText: () =>
|
|
30171
|
+
getLastUserVoiceText: () => ue.current,
|
|
30158
30172
|
requestEndSession: () => {
|
|
30159
|
-
|
|
30173
|
+
xe.current = !0;
|
|
30160
30174
|
},
|
|
30161
30175
|
requestEmailCollection: () => {
|
|
30162
|
-
|
|
30176
|
+
ae.current || oe.current || (oe.current = !0, se.current = 0, te(!0), Me());
|
|
30163
30177
|
}
|
|
30164
|
-
})), n = i ? Ae(i) : null, u = !!n?.transcript, p = i ? Ve(i) : null, m = !!p, g = typeof window < "u" ? window.location.pathname : "/", _ = typeof document < "u" ? document.title : "", v = g.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/",
|
|
30178
|
+
})), n = i ? Ae(i) : null, u = !!n?.transcript, p = i ? Ve(i) : null, m = !!p, g = typeof window < "u" ? window.location.pathname : "/", _ = typeof document < "u" ? document.title : "", v = g.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", b = v === "/" || v === "", S = null;
|
|
30165
30179
|
try {
|
|
30166
30180
|
let e = await fetch(`${a}/api/voice/signed-url?siteId=${encodeURIComponent(i || "")}`, {
|
|
30167
30181
|
method: "GET",
|
|
30168
30182
|
headers: { "Content-Type": "application/json" }
|
|
30169
30183
|
});
|
|
30170
|
-
if (e.ok)
|
|
30184
|
+
if (e.ok) S = (await e.json()).signedUrl || null, S && console.log("[FlowEngage] ✅ Using signed ElevenLabs URL");
|
|
30171
30185
|
else if (e.status === 429) {
|
|
30172
30186
|
let t = await e.json().catch(() => ({}));
|
|
30173
30187
|
throw Error(t.message || "Too many voice sessions started. Please wait a minute before trying again.");
|
|
@@ -30176,67 +30190,67 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30176
30190
|
if (e.message && e.message.includes("Too many voice sessions")) throw e;
|
|
30177
30191
|
console.warn("[FlowEngage] ⚠️ Signed URL fetch error:", e.message);
|
|
30178
30192
|
}
|
|
30179
|
-
let
|
|
30193
|
+
let w = {
|
|
30180
30194
|
clientTools: t,
|
|
30181
30195
|
connectionType: "websocket",
|
|
30182
30196
|
minSpeechDurationMs: 50,
|
|
30183
|
-
...
|
|
30184
|
-
},
|
|
30185
|
-
_ && _.includes("|") && (
|
|
30186
|
-
let
|
|
30187
|
-
if (
|
|
30188
|
-
let e = p?.pageName ||
|
|
30189
|
-
|
|
30190
|
-
} else if (u)
|
|
30197
|
+
...S ? { signedUrl: S } : { agentId: r }
|
|
30198
|
+
}, T = (g.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), ee = "";
|
|
30199
|
+
_ && _.includes("|") && (ee = _.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
|
|
30200
|
+
let ne = ee || T || "this page";
|
|
30201
|
+
if (S) if (m) {
|
|
30202
|
+
let e = p?.pageName || ne;
|
|
30203
|
+
w.overrides = { agent: { firstMessage: `I have navigated you on ${e} page. Do you want to know about any specific section or want a complete overview?` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${e}" (${g})`);
|
|
30204
|
+
} else if (u) w.overrides = { agent: { firstMessage: `Welcome back! I see you're now on the ${ne} page. Would you like me to continue what I was explaining before, or would you like to know about this page instead?` } };
|
|
30191
30205
|
else {
|
|
30192
30206
|
let e = f || "";
|
|
30193
|
-
|
|
30207
|
+
w.overrides = { agent: { firstMessage: h || (b ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${ne} page!`) } }, b || console.log(`[FlowEngage] 🏠 Page-context override: "${ne}" for ${g}`);
|
|
30194
30208
|
}
|
|
30195
|
-
else u && (
|
|
30196
|
-
let
|
|
30197
|
-
...
|
|
30209
|
+
else u && (w.overrides = { agent: { firstMessage: "" } });
|
|
30210
|
+
let re = !1, E = m ? `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, ie = !1, D = !m && !u ? "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, de = u && !m, ye = !1, ke = de ? `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, je = !1, Pe = !1, Fe = !!y, Ie = await DD.startSession({
|
|
30211
|
+
...w,
|
|
30198
30212
|
onConnect: ({ conversationId: e }) => {
|
|
30199
|
-
|
|
30213
|
+
_e.current = e, ve.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
|
|
30200
30214
|
},
|
|
30201
30215
|
onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
|
|
30202
30216
|
onModeChange: ({ mode: t }) => {
|
|
30203
30217
|
if (!e) {
|
|
30204
30218
|
if (t === "speaking") {
|
|
30205
|
-
|
|
30219
|
+
Ee.current &&= (clearTimeout(Ee.current), null), x("speaking"), Se.current = "speaking", Ce.current = !0, De.current = !1, Te.current &&= (clearTimeout(Te.current), null);
|
|
30206
30220
|
return;
|
|
30207
30221
|
}
|
|
30208
|
-
if (
|
|
30209
|
-
|
|
30222
|
+
if (Se.current = "listening", xe.current) {
|
|
30223
|
+
xe.current = !1, Oe();
|
|
30210
30224
|
return;
|
|
30211
30225
|
}
|
|
30212
|
-
if (
|
|
30213
|
-
|
|
30226
|
+
if (Fe && !Pe) {
|
|
30227
|
+
Pe = !0, re = !0, ie = !0;
|
|
30214
30228
|
try {
|
|
30215
|
-
|
|
30229
|
+
le.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.");
|
|
30216
30230
|
} catch {}
|
|
30217
30231
|
}
|
|
30218
|
-
if (
|
|
30219
|
-
|
|
30232
|
+
if (E && !re) {
|
|
30233
|
+
re = !0;
|
|
30220
30234
|
try {
|
|
30221
|
-
|
|
30235
|
+
le.current?.sendContextualUpdate?.(E);
|
|
30222
30236
|
} catch {}
|
|
30223
30237
|
}
|
|
30224
|
-
if (
|
|
30225
|
-
|
|
30238
|
+
if (ke && !ye) {
|
|
30239
|
+
ye = !0;
|
|
30226
30240
|
try {
|
|
30227
|
-
|
|
30241
|
+
le.current?.sendContextualUpdate?.(ke);
|
|
30228
30242
|
} catch {}
|
|
30229
30243
|
}
|
|
30230
|
-
if (
|
|
30231
|
-
|
|
30244
|
+
if (D && !ie) {
|
|
30245
|
+
ie = !0;
|
|
30232
30246
|
try {
|
|
30233
|
-
|
|
30247
|
+
le.current?.sendContextualUpdate?.(D);
|
|
30234
30248
|
} catch {}
|
|
30235
30249
|
}
|
|
30236
|
-
|
|
30237
|
-
e ||
|
|
30238
|
-
if (!e &&
|
|
30239
|
-
|
|
30250
|
+
Ee.current && clearTimeout(Ee.current), Ee.current = setTimeout(() => {
|
|
30251
|
+
e || Se.current !== "speaking" && (De.current || (Ee.current = null, Se.current = "listening", x("listening"), Ce.current && we.current && !pe.current && !oe.current && (Te.current && clearTimeout(Te.current), Te.current = setTimeout(() => {
|
|
30252
|
+
if (!e && Se.current === "listening" && !pe.current && !oe.current) try {
|
|
30253
|
+
le.current?.sendContextualUpdate?.("The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.");
|
|
30240
30254
|
} catch {}
|
|
30241
30255
|
}, 15e3))));
|
|
30242
30256
|
}, 1200);
|
|
@@ -30247,11 +30261,11 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30247
30261
|
let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
|
|
30248
30262
|
if (r) {
|
|
30249
30263
|
if (n === "user") {
|
|
30250
|
-
|
|
30264
|
+
ue.current = r, De.current = !0, we.current = !0, Ee.current &&= (clearTimeout(Ee.current), null), Te.current &&= (clearTimeout(Te.current), null);
|
|
30251
30265
|
try {
|
|
30252
30266
|
Bn();
|
|
30253
30267
|
} catch {}
|
|
30254
|
-
|
|
30268
|
+
Fe && !je && !ae.current && (je = !0, ce.current = r, oe.current || (oe.current = !0, se.current = 0, te(!0), Me()));
|
|
30255
30269
|
}
|
|
30256
30270
|
if (l.current = [...l.current, {
|
|
30257
30271
|
sender: n,
|
|
@@ -30262,50 +30276,50 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30262
30276
|
e && O(i, e);
|
|
30263
30277
|
} catch {}
|
|
30264
30278
|
if (pk(n, r)) {
|
|
30265
|
-
|
|
30279
|
+
xe.current = !0;
|
|
30266
30280
|
return;
|
|
30267
30281
|
}
|
|
30268
|
-
if (
|
|
30269
|
-
|
|
30282
|
+
if (pe.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 (be.current += 1, be.current === 2) try {
|
|
30283
|
+
le.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.");
|
|
30270
30284
|
} catch {}
|
|
30271
|
-
else
|
|
30285
|
+
else be.current >= 5 && Oe("minimized");
|
|
30272
30286
|
}
|
|
30273
30287
|
},
|
|
30274
30288
|
onError: (t) => {
|
|
30275
|
-
if (!e && !
|
|
30276
|
-
|
|
30289
|
+
if (!e && !he.current && !me.current && !Re()) {
|
|
30290
|
+
me.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
|
|
30277
30291
|
message: t?.message,
|
|
30278
30292
|
name: t?.name,
|
|
30279
30293
|
raw: t
|
|
30280
30294
|
});
|
|
30281
30295
|
try {
|
|
30282
|
-
|
|
30296
|
+
le.current?.setMicMuted?.(!0);
|
|
30283
30297
|
} catch {}
|
|
30284
|
-
|
|
30298
|
+
C(!0), x("error"), Oe("chat");
|
|
30285
30299
|
}
|
|
30286
30300
|
},
|
|
30287
30301
|
onDisconnect: (t) => {
|
|
30288
|
-
if (e ||
|
|
30302
|
+
if (e || he.current || me.current || Re()) return;
|
|
30289
30303
|
let n = l.current?.length || 0;
|
|
30290
30304
|
console.warn("[FlowEngageVoiceCall] session:disconnected", {
|
|
30291
30305
|
historyCount: n,
|
|
30292
30306
|
reason: t?.reason,
|
|
30293
30307
|
closeCode: t?.context?.code,
|
|
30294
30308
|
closeReason: t?.context?.reason || t?.message,
|
|
30295
|
-
lastUserText:
|
|
30296
|
-
wasMuted:
|
|
30297
|
-
}),
|
|
30309
|
+
lastUserText: ue.current || "",
|
|
30310
|
+
wasMuted: pe.current
|
|
30311
|
+
}), me.current = !0;
|
|
30298
30312
|
try {
|
|
30299
|
-
|
|
30313
|
+
le.current?.setMicMuted?.(!0);
|
|
30300
30314
|
} catch {}
|
|
30301
|
-
|
|
30315
|
+
C(!0), Oe("chat");
|
|
30302
30316
|
}
|
|
30303
30317
|
});
|
|
30304
30318
|
if (e) {
|
|
30305
|
-
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"),
|
|
30319
|
+
console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), Ie.endSession().catch(() => {});
|
|
30306
30320
|
return;
|
|
30307
30321
|
}
|
|
30308
|
-
o =
|
|
30322
|
+
o = Ie, le.current = Ie, x("listening");
|
|
30309
30323
|
try {
|
|
30310
30324
|
let e = typeof window < "u" ? window.location.href : "", r = "[]";
|
|
30311
30325
|
try {
|
|
@@ -30317,7 +30331,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30317
30331
|
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 && (a = [...new Set(n)].slice(0, 15).join(" | "));
|
|
30318
30332
|
} catch {}
|
|
30319
30333
|
let o = u && !m ? `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` : "";
|
|
30320
|
-
|
|
30334
|
+
Ie.sendContextualUpdate(`${o}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${a}. SiteId: ${i || "unknown"}. Forms: ${r}. 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.`);
|
|
30321
30335
|
} catch {}
|
|
30322
30336
|
if (typeof window < "u") {
|
|
30323
30337
|
let t = window.location.pathname, n = () => {
|
|
@@ -30346,7 +30360,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30346
30360
|
ts: Date.now()
|
|
30347
30361
|
});
|
|
30348
30362
|
try {
|
|
30349
|
-
|
|
30363
|
+
le.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${l}" page (${i}). Page title: "${a}". Sections: ${JSON.stringify(o)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${l} 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 flowengage_navigate, do NOT call flowengage_highlight, the visitor will navigate themselves if needed. IF I want to hear about this page: call flowengage_highlight for sections of "${l}" only.]`);
|
|
30350
30364
|
} catch {}
|
|
30351
30365
|
};
|
|
30352
30366
|
c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
|
|
@@ -30354,7 +30368,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30354
30368
|
}, d = () => setTimeout(n, 50), window.addEventListener("popstate", d);
|
|
30355
30369
|
}
|
|
30356
30370
|
} catch (r) {
|
|
30357
|
-
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (
|
|
30371
|
+
e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (x("error"), ge.current = "chat", window.setTimeout(() => {
|
|
30358
30372
|
e || t?.();
|
|
30359
30373
|
}, 0)));
|
|
30360
30374
|
}
|
|
@@ -30363,15 +30377,15 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30363
30377
|
agentId: r,
|
|
30364
30378
|
siteId: i,
|
|
30365
30379
|
apiBaseUrl: a
|
|
30366
|
-
}), e = !0,
|
|
30380
|
+
}), e = !0, he.current = !0;
|
|
30367
30381
|
try {
|
|
30368
30382
|
Bn();
|
|
30369
30383
|
} catch {}
|
|
30370
30384
|
if (i) try {
|
|
30371
30385
|
Ve(i);
|
|
30372
30386
|
} catch {}
|
|
30373
|
-
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Lr(),
|
|
30374
|
-
let t = o ||
|
|
30387
|
+
typeof window < "u" && (window.__fe_user_nav_during_speech = null), Lr(), Te.current &&= (clearTimeout(Te.current), null), Ee.current &&= (clearTimeout(Ee.current), null), D.current &&= (clearTimeout(D.current), null), Ce.current = !1, De.current = !1, Se.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
|
|
30388
|
+
let t = o || le.current, n = _e.current, f = ve.current;
|
|
30375
30389
|
if (t?.endSession?.().catch(() => {}), n && s && a) {
|
|
30376
30390
|
let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
|
|
30377
30391
|
chatId: s,
|
|
@@ -30384,7 +30398,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30384
30398
|
headers: { "Content-Type": "application/json" },
|
|
30385
30399
|
body: t,
|
|
30386
30400
|
keepalive: !0
|
|
30387
|
-
}).catch(() => {}),
|
|
30401
|
+
}).catch(() => {}), _e.current = null, ve.current = null;
|
|
30388
30402
|
}
|
|
30389
30403
|
typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
|
|
30390
30404
|
};
|
|
@@ -30392,53 +30406,53 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30392
30406
|
r,
|
|
30393
30407
|
i,
|
|
30394
30408
|
a,
|
|
30395
|
-
|
|
30409
|
+
Oe
|
|
30396
30410
|
]), c(() => {
|
|
30397
|
-
if (!
|
|
30411
|
+
if (!w) return;
|
|
30398
30412
|
let e = (e) => {
|
|
30399
30413
|
let t = e.composedPath?.()?.[0] || e.target;
|
|
30400
|
-
|
|
30414
|
+
ye.current && !ye.current.contains(t) && T(!1);
|
|
30401
30415
|
};
|
|
30402
30416
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
30403
|
-
}, [
|
|
30404
|
-
let
|
|
30405
|
-
if (
|
|
30406
|
-
if (
|
|
30407
|
-
|
|
30417
|
+
}, [w]);
|
|
30418
|
+
let Fe = async () => {
|
|
30419
|
+
if (le.current) try {
|
|
30420
|
+
if (S) {
|
|
30421
|
+
be.current = 0, await le.current.setMicMuted?.(!1), C(!1);
|
|
30408
30422
|
try {
|
|
30409
|
-
|
|
30423
|
+
le.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
|
|
30410
30424
|
} catch {}
|
|
30411
30425
|
} else {
|
|
30412
|
-
|
|
30426
|
+
be.current = 0, await le.current.setMicMuted?.(!0), C(!0);
|
|
30413
30427
|
try {
|
|
30414
|
-
|
|
30428
|
+
le.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.");
|
|
30415
30429
|
} catch {}
|
|
30416
30430
|
}
|
|
30417
30431
|
} catch {}
|
|
30418
|
-
},
|
|
30432
|
+
}, Ie = o(async (e) => {
|
|
30419
30433
|
e?.preventDefault?.();
|
|
30420
|
-
let t =
|
|
30434
|
+
let t = ne.trim().toLowerCase();
|
|
30421
30435
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
|
|
30422
|
-
|
|
30436
|
+
ie("Please enter a valid email address.");
|
|
30423
30437
|
return;
|
|
30424
30438
|
}
|
|
30425
|
-
|
|
30439
|
+
ie("");
|
|
30426
30440
|
try {
|
|
30427
30441
|
typeof v == "function" && await v(t);
|
|
30428
30442
|
} catch {}
|
|
30429
|
-
|
|
30430
|
-
let n =
|
|
30431
|
-
|
|
30443
|
+
ae.current = !0, oe.current = !1, ke(), te(!1), re("");
|
|
30444
|
+
let n = ce.current;
|
|
30445
|
+
ce.current = "";
|
|
30432
30446
|
try {
|
|
30433
|
-
|
|
30447
|
+
le.current?.sendUserMessage?.("[SYSTEM: EMAIL_SAVED — the visitor typed and submitted their email address. Say a brief 'Thank you!' and then " + (n ? `immediately answer their original question fully: "${n}".` : "continue helping them.") + " Do NOT ask for their email again.]");
|
|
30434
30448
|
} catch {}
|
|
30435
30449
|
}, [
|
|
30436
|
-
|
|
30450
|
+
ne,
|
|
30437
30451
|
v,
|
|
30438
|
-
|
|
30439
|
-
]),
|
|
30452
|
+
ke
|
|
30453
|
+
]), Le = Array.isArray(e) && e[0] || "#3B82F6";
|
|
30440
30454
|
return /* @__PURE__ */ _("div", {
|
|
30441
|
-
ref:
|
|
30455
|
+
ref: ye,
|
|
30442
30456
|
style: {
|
|
30443
30457
|
position: "relative",
|
|
30444
30458
|
display: "flex",
|
|
@@ -30448,8 +30462,8 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30448
30462
|
animation: "fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)"
|
|
30449
30463
|
},
|
|
30450
30464
|
children: [
|
|
30451
|
-
|
|
30452
|
-
onSubmit:
|
|
30465
|
+
ee && /* @__PURE__ */ _("form", {
|
|
30466
|
+
onSubmit: Ie,
|
|
30453
30467
|
style: {
|
|
30454
30468
|
width: "270px",
|
|
30455
30469
|
maxWidth: "calc(100vw - 40px)",
|
|
@@ -30480,9 +30494,9 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30480
30494
|
inputMode: "email",
|
|
30481
30495
|
autoComplete: "email",
|
|
30482
30496
|
autoFocus: !0,
|
|
30483
|
-
value:
|
|
30497
|
+
value: ne,
|
|
30484
30498
|
onChange: (e) => {
|
|
30485
|
-
|
|
30499
|
+
re(e.target.value), E && ie("");
|
|
30486
30500
|
},
|
|
30487
30501
|
placeholder: "you@example.com",
|
|
30488
30502
|
style: {
|
|
@@ -30490,33 +30504,33 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30490
30504
|
boxSizing: "border-box",
|
|
30491
30505
|
padding: "10px 12px",
|
|
30492
30506
|
borderRadius: "10px",
|
|
30493
|
-
border:
|
|
30507
|
+
border: E ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
30494
30508
|
background: "#1f2937",
|
|
30495
30509
|
color: "white",
|
|
30496
30510
|
fontSize: "14px",
|
|
30497
30511
|
outline: "none"
|
|
30498
30512
|
}
|
|
30499
30513
|
}),
|
|
30500
|
-
|
|
30514
|
+
E && /* @__PURE__ */ g("span", {
|
|
30501
30515
|
style: {
|
|
30502
30516
|
color: "#f87171",
|
|
30503
30517
|
fontSize: "12px"
|
|
30504
30518
|
},
|
|
30505
|
-
children:
|
|
30519
|
+
children: E
|
|
30506
30520
|
}),
|
|
30507
30521
|
/* @__PURE__ */ g("button", {
|
|
30508
30522
|
type: "submit",
|
|
30509
|
-
disabled: !
|
|
30523
|
+
disabled: !ne.trim(),
|
|
30510
30524
|
style: {
|
|
30511
30525
|
width: "100%",
|
|
30512
30526
|
padding: "10px 12px",
|
|
30513
30527
|
borderRadius: "10px",
|
|
30514
30528
|
border: "none",
|
|
30515
|
-
background:
|
|
30529
|
+
background: ne.trim() ? Le : "#374151",
|
|
30516
30530
|
color: "white",
|
|
30517
30531
|
fontSize: "14px",
|
|
30518
30532
|
fontWeight: 600,
|
|
30519
|
-
cursor:
|
|
30533
|
+
cursor: ne.trim() ? "pointer" : "default",
|
|
30520
30534
|
transition: "background 0.2s ease"
|
|
30521
30535
|
},
|
|
30522
30536
|
children: "Submit"
|
|
@@ -30526,7 +30540,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30526
30540
|
/* @__PURE__ */ _("div", {
|
|
30527
30541
|
style: { position: "relative" },
|
|
30528
30542
|
children: [
|
|
30529
|
-
|
|
30543
|
+
b === "listening" && !S && /* @__PURE__ */ g("span", {
|
|
30530
30544
|
style: {
|
|
30531
30545
|
position: "absolute",
|
|
30532
30546
|
right: "100%",
|
|
@@ -30542,7 +30556,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30542
30556
|
},
|
|
30543
30557
|
children: "Listening..."
|
|
30544
30558
|
}),
|
|
30545
|
-
|
|
30559
|
+
S && /* @__PURE__ */ g("span", {
|
|
30546
30560
|
style: {
|
|
30547
30561
|
position: "absolute",
|
|
30548
30562
|
right: "100%",
|
|
@@ -30560,13 +30574,13 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30560
30574
|
}),
|
|
30561
30575
|
/* @__PURE__ */ g(mk, {
|
|
30562
30576
|
size: 72,
|
|
30563
|
-
voiceState:
|
|
30564
|
-
isMuted:
|
|
30577
|
+
voiceState: b,
|
|
30578
|
+
isMuted: S,
|
|
30565
30579
|
orbColors: e
|
|
30566
30580
|
})
|
|
30567
30581
|
]
|
|
30568
30582
|
}),
|
|
30569
|
-
|
|
30583
|
+
b === "error" && /* @__PURE__ */ g("span", {
|
|
30570
30584
|
style: {
|
|
30571
30585
|
color: "#f87171",
|
|
30572
30586
|
fontSize: "13px",
|
|
@@ -30581,25 +30595,25 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30581
30595
|
alignItems: "center"
|
|
30582
30596
|
},
|
|
30583
30597
|
children: [/* @__PURE__ */ g("button", {
|
|
30584
|
-
onClick:
|
|
30585
|
-
title:
|
|
30598
|
+
onClick: Fe,
|
|
30599
|
+
title: S ? "Unmute" : "Mute",
|
|
30586
30600
|
style: {
|
|
30587
30601
|
width: "24px",
|
|
30588
30602
|
height: "24px",
|
|
30589
30603
|
borderRadius: "50%",
|
|
30590
|
-
background:
|
|
30591
|
-
border:
|
|
30604
|
+
background: S ? "#7f1d1d" : "#1f2937",
|
|
30605
|
+
border: S ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
|
|
30592
30606
|
display: "flex",
|
|
30593
30607
|
alignItems: "center",
|
|
30594
30608
|
justifyContent: "center",
|
|
30595
30609
|
cursor: "pointer",
|
|
30596
|
-
color:
|
|
30610
|
+
color: S ? "#f87171" : "white",
|
|
30597
30611
|
transition: "all 0.2s ease",
|
|
30598
30612
|
boxShadow: "0 2px 8px rgba(0,0,0,0.4)",
|
|
30599
30613
|
padding: 0,
|
|
30600
30614
|
flexShrink: 0
|
|
30601
30615
|
},
|
|
30602
|
-
children:
|
|
30616
|
+
children: S ? /* @__PURE__ */ _("svg", {
|
|
30603
30617
|
width: "16",
|
|
30604
30618
|
height: "16",
|
|
30605
30619
|
viewBox: "0 0 24 24",
|
|
@@ -30635,7 +30649,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30635
30649
|
color: "currentColor"
|
|
30636
30650
|
})
|
|
30637
30651
|
}), /* @__PURE__ */ g("button", {
|
|
30638
|
-
onClick: () =>
|
|
30652
|
+
onClick: () => T((e) => !e),
|
|
30639
30653
|
style: {
|
|
30640
30654
|
width: "24px",
|
|
30641
30655
|
height: "24px",
|
|
@@ -30658,7 +30672,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30658
30672
|
})
|
|
30659
30673
|
})]
|
|
30660
30674
|
}),
|
|
30661
|
-
|
|
30675
|
+
w && /* @__PURE__ */ _("div", {
|
|
30662
30676
|
style: {
|
|
30663
30677
|
position: "absolute",
|
|
30664
30678
|
bottom: 0,
|
|
@@ -30676,7 +30690,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30676
30690
|
children: [
|
|
30677
30691
|
/* @__PURE__ */ _("button", {
|
|
30678
30692
|
onClick: () => {
|
|
30679
|
-
|
|
30693
|
+
T(!1), ge.current = "chat", Pe(t);
|
|
30680
30694
|
},
|
|
30681
30695
|
style: {
|
|
30682
30696
|
display: "flex",
|
|
@@ -30705,7 +30719,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30705
30719
|
}),
|
|
30706
30720
|
/* @__PURE__ */ _("button", {
|
|
30707
30721
|
onClick: () => {
|
|
30708
|
-
|
|
30722
|
+
T(!1), ge.current = "minimized", Pe(n);
|
|
30709
30723
|
},
|
|
30710
30724
|
style: {
|
|
30711
30725
|
display: "flex",
|
|
@@ -30733,7 +30747,7 @@ function _k({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
|
|
|
30733
30747
|
children: [/* @__PURE__ */ g(RD, {}), "End Conversation"]
|
|
30734
30748
|
}),
|
|
30735
30749
|
/* @__PURE__ */ g("button", {
|
|
30736
|
-
onClick: () =>
|
|
30750
|
+
onClick: () => T(!1),
|
|
30737
30751
|
style: {
|
|
30738
30752
|
position: "absolute",
|
|
30739
30753
|
bottom: "8px",
|
|
@@ -30831,7 +30845,7 @@ var yk = () => /* @__PURE__ */ g("div", {
|
|
|
30831
30845
|
} }, e))
|
|
30832
30846
|
})
|
|
30833
30847
|
});
|
|
30834
|
-
function bk({ 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: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile:
|
|
30848
|
+
function bk({ 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: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: E, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, activeCallId: ge, isCallMuted: _e, toggleCallMute: ve, endWebRTCCall: ye, formatCallDuration: be, callDurationSeconds: xe, isCallMinimized: Se, onExpand: Ce, onCollapse: we, onStartVoice: Te, voiceEnabled: Ee, headerBgColor: De, onNewChat: Oe, showPoweredBy: ke, privacyPolicyUrl: O, getVisitorChatHistory: Ae, resumeChat: je, isSessionRestoring: Me, isClosing: Ne }) {
|
|
30835
30849
|
let Pe = l.length > 0, Fe = T || ee || w, Ie = !!ge, [Le, Re] = m(!1), [ze, Be] = m(!1), [Ve, He] = m([]), [Ue, We] = m(!1), Ge = p(null), [Ke, k] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [qe, Je] = m(0);
|
|
30836
30850
|
c(() => {
|
|
30837
30851
|
if (!s) return;
|
|
@@ -31510,7 +31524,7 @@ function bk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31510
31524
|
]
|
|
31511
31525
|
})]
|
|
31512
31526
|
}),
|
|
31513
|
-
|
|
31527
|
+
le && /* @__PURE__ */ _("div", {
|
|
31514
31528
|
style: {
|
|
31515
31529
|
margin: "0 16px 8px",
|
|
31516
31530
|
padding: "9px 14px",
|
|
@@ -31549,7 +31563,7 @@ function bk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31549
31563
|
flexShrink: 0,
|
|
31550
31564
|
position: "relative",
|
|
31551
31565
|
zIndex: 1,
|
|
31552
|
-
padding:
|
|
31566
|
+
padding: oe ? "6px 0 0" : "12px 0 0"
|
|
31553
31567
|
},
|
|
31554
31568
|
children: /* @__PURE__ */ g(iO, {
|
|
31555
31569
|
input: x,
|
|
@@ -31561,17 +31575,17 @@ function bk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31561
31575
|
showVoiceToggle: f === "agent",
|
|
31562
31576
|
activeScreen: f,
|
|
31563
31577
|
inputDisabled: Fe,
|
|
31564
|
-
replyContext:
|
|
31578
|
+
replyContext: ue,
|
|
31565
31579
|
clearReplyContext: () => de(null),
|
|
31566
31580
|
onFileSelect: re,
|
|
31567
31581
|
selectedFile: ne,
|
|
31568
|
-
onRemoveSelectedFile:
|
|
31569
|
-
attachmentError:
|
|
31570
|
-
isUploadingAttachment:
|
|
31571
|
-
requiresEmail:
|
|
31572
|
-
emailInput:
|
|
31573
|
-
setEmailInput:
|
|
31574
|
-
emailError:
|
|
31582
|
+
onRemoveSelectedFile: E,
|
|
31583
|
+
attachmentError: ie,
|
|
31584
|
+
isUploadingAttachment: ae,
|
|
31585
|
+
requiresEmail: oe,
|
|
31586
|
+
emailInput: D,
|
|
31587
|
+
setEmailInput: se,
|
|
31588
|
+
emailError: ce,
|
|
31575
31589
|
inputPlaceholder: e.inputPlaceholder
|
|
31576
31590
|
})
|
|
31577
31591
|
}),
|
|
@@ -31626,13 +31640,13 @@ function bk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
|
|
|
31626
31640
|
});
|
|
31627
31641
|
}
|
|
31628
31642
|
function xk() {
|
|
31629
|
-
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: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language:
|
|
31643
|
+
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: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, chatId: ie, historyRef: ae, onMessageSync: oe, sendMessage: D, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: me, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se, getVisitorChatHistory: Ce, resumeChat: we, isSessionRestoring: Te, openToChatCounter: Ee, voiceEndCounter: De } = Fn();
|
|
31630
31644
|
c(() => {
|
|
31631
31645
|
try {
|
|
31632
31646
|
yr();
|
|
31633
31647
|
} catch {}
|
|
31634
31648
|
}, []), c(() => {
|
|
31635
|
-
Ee && M !== "voice_mode" && M !== "text_chat" && M !== "call_screen" && (
|
|
31649
|
+
Ee && M !== "voice_mode" && M !== "text_chat" && M !== "call_screen" && (ue?.(!1), dt("text_chat"));
|
|
31636
31650
|
}, [Ee]);
|
|
31637
31651
|
let Oe = t?.widgetSettings || {}, ke = n?.widgetSettings || {}, O = {
|
|
31638
31652
|
...Oe.branding || {},
|
|
@@ -31647,7 +31661,7 @@ function xk() {
|
|
|
31647
31661
|
small: 50,
|
|
31648
31662
|
medium: 64,
|
|
31649
31663
|
large: 80
|
|
31650
|
-
}, Be = ze[Me.orbSize] || ze.small, Ve = Me.position || "bottom-right", He = O.fallbackAgentName || "Agent", Ue = ck(Ie ?? Me.chatBgColors), We = O.logo || O.logoUrl || null, Ge =
|
|
31664
|
+
}, Be = ze[Me.orbSize] || ze.small, Ve = Me.position || "bottom-right", He = O.fallbackAgentName || "Agent", Ue = ck(Ie ?? Me.chatBgColors), We = O.logo || O.logoUrl || null, Ge = E || "en", Ke = Oe.recommendations?.[Ge] || [], k = (ke.recommendations?.[Ge] ?? Ke).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
|
|
31651
31665
|
id: e.key || `qr-${t}`,
|
|
31652
31666
|
label: e.label,
|
|
31653
31667
|
message: e.label,
|
|
@@ -31668,7 +31682,7 @@ function xk() {
|
|
|
31668
31682
|
...ke.pageVisibility || {}
|
|
31669
31683
|
};
|
|
31670
31684
|
return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
|
|
31671
|
-
})(), nt = tt.length === 0 || tt.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? $e.startsWith(e.slice(0, -1)) : $e.replace(/\/$/, "") === e.replace(/\/$/, "")), rt = Oe.greetings?.[
|
|
31685
|
+
})(), nt = tt.length === 0 || tt.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? $e.startsWith(e.slice(0, -1)) : $e.replace(/\/$/, "") === e.replace(/\/$/, "")), rt = Oe.greetings?.[E] || ke.greetings?.[E] || O.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", it = {
|
|
31672
31686
|
entryPrompt: O.entryPrompt || "Do you want to explore in a new way?",
|
|
31673
31687
|
yesLabel: O.yesLabel || "Yes",
|
|
31674
31688
|
laterLabel: O.laterLabel || "Later",
|
|
@@ -31691,7 +31705,7 @@ function xk() {
|
|
|
31691
31705
|
]), st = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, ct = r.some((e) => e.sender === "user"), lt = f(() => {
|
|
31692
31706
|
let e = r.findIndex((e) => e.sender === "user");
|
|
31693
31707
|
return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
|
|
31694
|
-
}, [r]), ut = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [M, dt] = m(() => ut ? "text_chat" : "entry_prompt"), [ft, pt] = m(""), [mt,
|
|
31708
|
+
}, [r]), ut = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [M, dt] = m(() => ut ? "text_chat" : "entry_prompt"), [ft, pt] = m(""), [mt, N] = m(null), [ht, gt] = m(h || ""), [_t, vt] = m(""), [yt, bt] = m(!1), [xt, St] = m(0), [Ct, wt] = m(null), [Tt, Et] = m(null), [Dt, Ot] = m(""), [kt, At] = m(!1), [jt, Mt] = m(!1), [Nt, Pt] = m(!1), Ft = p(null), It = p(!1), Lt = !h && ct && lt && M !== "voice_mode";
|
|
31695
31709
|
d(() => {
|
|
31696
31710
|
if (e !== "ready" || It.current) return;
|
|
31697
31711
|
if (It.current = !0, !Fe) {
|
|
@@ -31704,11 +31718,11 @@ function xk() {
|
|
|
31704
31718
|
} catch {}
|
|
31705
31719
|
let n = Pe(), r = A ? Ae(A) : null, i = n || !!r?.transcript;
|
|
31706
31720
|
if (t) {
|
|
31707
|
-
|
|
31721
|
+
ce?.({ notifyChatInitiated: !0 }), ue?.(!0), dt("voice_mode");
|
|
31708
31722
|
return;
|
|
31709
31723
|
}
|
|
31710
31724
|
if (Le()) {
|
|
31711
|
-
|
|
31725
|
+
ce?.({ notifyChatInitiated: !1 }), dt("text_chat");
|
|
31712
31726
|
return;
|
|
31713
31727
|
}
|
|
31714
31728
|
if (i) {
|
|
@@ -31716,7 +31730,7 @@ function xk() {
|
|
|
31716
31730
|
dt("minimized_orb");
|
|
31717
31731
|
return;
|
|
31718
31732
|
}
|
|
31719
|
-
|
|
31733
|
+
ce?.({ notifyChatInitiated: !0 }), ue?.(!0), dt("voice_mode");
|
|
31720
31734
|
return;
|
|
31721
31735
|
}
|
|
31722
31736
|
if (A) try {
|
|
@@ -31732,7 +31746,7 @@ function xk() {
|
|
|
31732
31746
|
let e = window.matchMedia("(max-width: 640px)"), t = (e) => zt(e.matches);
|
|
31733
31747
|
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
31734
31748
|
}, []), c(() => {
|
|
31735
|
-
|
|
31749
|
+
gt(h || ""), h && vt("");
|
|
31736
31750
|
}, [h]);
|
|
31737
31751
|
let Bt = o(() => {
|
|
31738
31752
|
Et(null), Ot("");
|
|
@@ -31780,7 +31794,7 @@ function xk() {
|
|
|
31780
31794
|
hasIncomingCall: !!w?.callId,
|
|
31781
31795
|
activeCallId: T,
|
|
31782
31796
|
callConnectionState: ee
|
|
31783
|
-
}), Ft.current = e, M === "voice_mode" &&
|
|
31797
|
+
}), Ft.current = e, M === "voice_mode" && ue?.(!1), ce?.(), Ht());
|
|
31784
31798
|
}
|
|
31785
31799
|
}, [
|
|
31786
31800
|
T,
|
|
@@ -31788,8 +31802,8 @@ function xk() {
|
|
|
31788
31802
|
Ht,
|
|
31789
31803
|
w?.callId,
|
|
31790
31804
|
i,
|
|
31791
|
-
|
|
31792
|
-
|
|
31805
|
+
ce,
|
|
31806
|
+
ue,
|
|
31793
31807
|
M
|
|
31794
31808
|
]), c(() => {
|
|
31795
31809
|
!w && !T && M === "call_screen" && dt("text_chat");
|
|
@@ -31830,12 +31844,12 @@ function xk() {
|
|
|
31830
31844
|
} : null, Gt = async (e) => {
|
|
31831
31845
|
if (e.preventDefault(), C) return;
|
|
31832
31846
|
if (Lt) {
|
|
31833
|
-
let e =
|
|
31847
|
+
let e = ht.trim().toLowerCase();
|
|
31834
31848
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
|
|
31835
31849
|
vt("Please enter a valid email so we can continue helping you.");
|
|
31836
31850
|
return;
|
|
31837
31851
|
}
|
|
31838
|
-
await
|
|
31852
|
+
await le(e), vt(""), bt(!0), setTimeout(() => bt(!1), 3e3);
|
|
31839
31853
|
return;
|
|
31840
31854
|
}
|
|
31841
31855
|
let t = Wt(mt);
|
|
@@ -31843,8 +31857,8 @@ function xk() {
|
|
|
31843
31857
|
if (Tt) {
|
|
31844
31858
|
try {
|
|
31845
31859
|
At(!0), Ot("");
|
|
31846
|
-
let e = await
|
|
31847
|
-
pt(""),
|
|
31860
|
+
let e = await se(Tt), n = e?.data || e, r = ft.trim() || `Shared file: ${eO(Tt)}`;
|
|
31861
|
+
pt(""), N(null), Bt(), await D(r, "", t, {
|
|
31848
31862
|
type: "file",
|
|
31849
31863
|
metadata: {
|
|
31850
31864
|
fileUrl: n?.fileUrl,
|
|
@@ -31861,7 +31875,7 @@ function xk() {
|
|
|
31861
31875
|
return;
|
|
31862
31876
|
}
|
|
31863
31877
|
let n = ft.trim();
|
|
31864
|
-
pt(""),
|
|
31878
|
+
pt(""), N(null), await D(n, "", t);
|
|
31865
31879
|
}, Kt = o(() => {
|
|
31866
31880
|
r.length !== 0 && me?.();
|
|
31867
31881
|
}, [r.length, me]), qt = (e) => {
|
|
@@ -31870,11 +31884,11 @@ function xk() {
|
|
|
31870
31884
|
}, Jt = o(async (e) => {
|
|
31871
31885
|
if (C || b) return;
|
|
31872
31886
|
let t = e.message || e.label || e.text || "";
|
|
31873
|
-
t.trim() && await
|
|
31887
|
+
t.trim() && await D(t.trim(), "");
|
|
31874
31888
|
}, [
|
|
31875
31889
|
C,
|
|
31876
31890
|
b,
|
|
31877
|
-
|
|
31891
|
+
D
|
|
31878
31892
|
]), Yt = Rt && M === "entry_prompt" ? { inset: 0 } : Rt && M === "text_chat" ? {
|
|
31879
31893
|
left: 0,
|
|
31880
31894
|
right: 0,
|
|
@@ -31920,11 +31934,11 @@ function xk() {
|
|
|
31920
31934
|
t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
|
|
31921
31935
|
}
|
|
31922
31936
|
} catch {}
|
|
31923
|
-
|
|
31937
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!0), dt("voice_mode");
|
|
31924
31938
|
}, $t = () => {
|
|
31925
|
-
|
|
31939
|
+
ce({ notifyChatInitiated: !0 }), ue?.(!1), dt("text_chat");
|
|
31926
31940
|
}, en = () => {
|
|
31927
|
-
|
|
31941
|
+
ue?.(!1), Xt();
|
|
31928
31942
|
};
|
|
31929
31943
|
return e !== "ready" || !Qe || Ne.chat === !1 || !nt ? null : /* @__PURE__ */ _("div", {
|
|
31930
31944
|
className: "flowengage-widget-root",
|
|
@@ -32042,15 +32056,14 @@ function xk() {
|
|
|
32042
32056
|
agentId: at,
|
|
32043
32057
|
siteId: A,
|
|
32044
32058
|
apiBaseUrl: j,
|
|
32045
|
-
chatId:
|
|
32046
|
-
historyRef:
|
|
32047
|
-
onMessageSync:
|
|
32059
|
+
chatId: ie,
|
|
32060
|
+
historyRef: ae,
|
|
32061
|
+
onMessageSync: oe,
|
|
32048
32062
|
voiceEndCounter: De,
|
|
32049
32063
|
websiteName: t?.websiteName,
|
|
32050
32064
|
voiceFirstMessage: Oe.voiceFirstMessage || null,
|
|
32051
|
-
captureVisitorEmail:
|
|
32052
|
-
emailRequired: !h
|
|
32053
|
-
emailCaptureEnabled: O.disableEmailCapture !== !0
|
|
32065
|
+
captureVisitorEmail: le,
|
|
32066
|
+
emailRequired: !h
|
|
32054
32067
|
}, "voice"),
|
|
32055
32068
|
M === "call_screen" && /* @__PURE__ */ g(xO, {
|
|
32056
32069
|
incomingCall: w,
|
|
@@ -32101,12 +32114,12 @@ function xk() {
|
|
|
32101
32114
|
attachmentError: Dt,
|
|
32102
32115
|
isUploadingAttachment: kt,
|
|
32103
32116
|
requiresEmail: Lt,
|
|
32104
|
-
emailInput:
|
|
32105
|
-
setEmailInput:
|
|
32106
|
-
emailError:
|
|
32117
|
+
emailInput: ht,
|
|
32118
|
+
setEmailInput: gt,
|
|
32119
|
+
emailError: _t,
|
|
32107
32120
|
emailCaptureSuccess: yt,
|
|
32108
32121
|
replyContext: mt,
|
|
32109
|
-
setReplyContext:
|
|
32122
|
+
setReplyContext: N,
|
|
32110
32123
|
webRTCError: re,
|
|
32111
32124
|
micError: Ct,
|
|
32112
32125
|
setMicError: wt,
|