@flowengage/react-chatbot 8.0.107 → 8.0.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,38 +42,38 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
42
42
  if (j) try {
43
43
  window.localStorage.removeItem(A.chatId);
44
44
  } catch {}
45
- }, ae = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", N = (e) => e ? `flowengage.entrySeen.${e}` : null, oe = (e) => {
45
+ }, N = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", P = (e) => e ? `flowengage.entrySeen.${e}` : null, ae = (e) => {
46
46
  if (!j || !e) return !1;
47
47
  try {
48
- let t = N(e);
48
+ let t = P(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
- }, se = (e) => {
53
+ }, oe = (e) => {
54
54
  if (!(!j || !e)) try {
55
- let t = N(e);
55
+ let t = P(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
- }, ce = (e) => e ? `flowengage.persistedChatId.${e}` : null, le = (e) => {
58
+ }, se = (e) => e ? `flowengage.persistedChatId.${e}` : null, ce = (e) => {
59
59
  if (!j || !e) return null;
60
60
  try {
61
- let t = ce(e), n = t ? window.localStorage.getItem(t) : null;
61
+ let t = se(e), n = t ? window.localStorage.getItem(t) : null;
62
62
  return n && String(n).trim() ? String(n).trim() : null;
63
63
  } catch {
64
64
  return null;
65
65
  }
66
- }, ue = (e) => {
66
+ }, le = (e) => {
67
67
  if (!(!j || !e)) try {
68
- let t = ce(e);
68
+ let t = se(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
- }, de = (e, t) => {
71
+ }, ue = (e, t) => {
72
72
  if (!(!j || !e || !t)) try {
73
- let n = ce(e);
73
+ let n = se(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
- }, fe = () => j ? {
76
+ }, de = () => j ? {
77
77
  isOpen: !1,
78
78
  activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
79
79
  isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
@@ -87,7 +87,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
87
87
  agentName: null,
88
88
  agentHeadshot: null,
89
89
  visitorEmail: ""
90
- }, pe = (e) => {
90
+ }, fe = (e) => {
91
91
  j && Object.entries(e).forEach(([e, t]) => {
92
92
  let n = A[e];
93
93
  if (n) {
@@ -98,7 +98,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
98
98
  window.sessionStorage.setItem(n, String(t));
99
99
  }
100
100
  });
101
- }, me = (e) => {
101
+ }, pe = (e) => {
102
102
  if (!j || !e) return "";
103
103
  let t = M(e), n = window.localStorage.getItem(t);
104
104
  if (!n) {
@@ -106,7 +106,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
106
106
  e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
107
107
  }
108
108
  return n || "";
109
- }, he = (e, t) => {
109
+ }, me = (e, t) => {
110
110
  if (!j) return;
111
111
  let n = M(t);
112
112
  if (!n) return;
@@ -116,91 +116,91 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
116
116
  return;
117
117
  }
118
118
  window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
119
- }, ge = (e) => e ? `flowengage.visitorId.${e}` : null, P = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, _e = (e) => {
119
+ }, he = (e) => e ? `flowengage.visitorId.${e}` : null, ge = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, F = (e) => {
120
120
  if (!j || !e) return null;
121
121
  try {
122
- let t = ge(e), n = t ? window.localStorage.getItem(t) : null;
122
+ let t = he(e), n = t ? window.localStorage.getItem(t) : null;
123
123
  return n && String(n).trim() ? String(n).trim() : null;
124
124
  } catch {
125
125
  return null;
126
126
  }
127
- }, ve = (e) => {
127
+ }, _e = (e) => {
128
128
  if (!j || !e) return null;
129
129
  try {
130
- let t = _e(e);
130
+ let t = F(e);
131
131
  if (t) return t;
132
- let n = P(), r = ge(e);
132
+ let n = ge(), r = he(e);
133
133
  return r && window.localStorage.setItem(r, n), n;
134
134
  } catch {
135
- return P();
135
+ return ge();
136
136
  }
137
- }, ye = "flowengage.tabId", be = () => {
137
+ }, ve = "flowengage.tabId", ye = () => {
138
138
  if (!j) return "default";
139
139
  try {
140
- let e = window.sessionStorage.getItem(ye);
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(ye, e)), e;
140
+ let e = window.sessionStorage.getItem(ve);
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(ve, e)), e;
142
142
  } catch {
143
143
  return "default";
144
144
  }
145
- }, F = (e) => e ? `flowengage.voice.transcript.${e}.${be()}` : null, xe = 600 * 1e3, I = (e, t, n = {}) => {
145
+ }, I = (e) => e ? `flowengage.voice.transcript.${e}.${ye()}` : null, be = 600 * 1e3, L = (e, t, n = {}) => {
146
146
  if (!j || !e) return;
147
147
  let r = typeof t == "string" ? t.trim() : "";
148
148
  if (!r) return;
149
- let i = Number.isFinite(n.ttlMs) ? n.ttlMs : xe, a = {
149
+ let i = Number.isFinite(n.ttlMs) ? n.ttlMs : be, a = {
150
150
  transcript: r,
151
151
  expiresAt: Date.now() + i
152
152
  };
153
153
  try {
154
- let t = F(e);
154
+ let t = I(e);
155
155
  t && window.localStorage.setItem(t, JSON.stringify(a));
156
156
  } catch {}
157
- }, Se = (e) => {
157
+ }, xe = (e) => {
158
158
  if (!j || !e) return null;
159
159
  try {
160
- let t = F(e), n = t ? window.localStorage.getItem(t) : null;
160
+ let t = I(e), n = t ? window.localStorage.getItem(t) : null;
161
161
  if (!n) return null;
162
162
  let r = JSON.parse(n);
163
163
  return !r || typeof r.transcript != "string" ? null : Number.isFinite(r.expiresAt) && Date.now() > r.expiresAt ? (window.localStorage.removeItem(t), null) : r;
164
164
  } catch {
165
165
  return null;
166
166
  }
167
- }, Ce = (e) => {
167
+ }, Se = (e) => {
168
168
  if (!(!j || !e)) try {
169
- let t = F(e);
169
+ let t = I(e);
170
170
  t && window.localStorage.removeItem(t);
171
171
  } catch {}
172
- }, L = "flowengage.voice.pendingResume", we = () => {
172
+ }, R = "flowengage.voice.pendingResume", Ce = () => {
173
173
  if (j) try {
174
- window.sessionStorage.setItem(L, "1");
174
+ window.sessionStorage.setItem(R, "1");
175
175
  } catch {}
176
- }, Te = () => {
176
+ }, we = () => {
177
177
  if (!j) return !1;
178
178
  try {
179
- return window.sessionStorage.getItem(L) === "1" ? (window.sessionStorage.removeItem(L), !0) : !1;
179
+ return window.sessionStorage.getItem(R) === "1" ? (window.sessionStorage.removeItem(R), !0) : !1;
180
180
  } catch {
181
181
  return !1;
182
182
  }
183
- }, Ee = "flowengage.chat.pendingReopen", De = () => {
183
+ }, Te = "flowengage.chat.pendingReopen", Ee = () => {
184
184
  if (j) try {
185
- window.sessionStorage.setItem(Ee, "1");
185
+ window.sessionStorage.setItem(Te, "1");
186
186
  } catch {}
187
- }, Oe = () => {
187
+ }, De = () => {
188
188
  if (!j) return !1;
189
189
  try {
190
- return window.sessionStorage.getItem(Ee) === "1" ? (window.sessionStorage.removeItem(Ee), !0) : !1;
190
+ return window.sessionStorage.getItem(Te) === "1" ? (window.sessionStorage.removeItem(Te), !0) : !1;
191
191
  } catch {
192
192
  return !1;
193
193
  }
194
- }, ke = () => {
194
+ }, Oe = () => {
195
195
  if (!j) return !1;
196
196
  try {
197
- return window.sessionStorage.getItem(L) === "1";
197
+ return window.sessionStorage.getItem(R) === "1";
198
198
  } catch {
199
199
  return !1;
200
200
  }
201
- }, Ae = (e) => e ? `flowengage.voice.navState.${e}.${be()}` : null, je = (e, t, n, r) => {
201
+ }, ke = (e) => e ? `flowengage.voice.navState.${e}.${ye()}` : null, Ae = (e, t, n, r) => {
202
202
  if (!(!j || !e || !t)) try {
203
- let i = Ae(e);
203
+ let i = ke(e);
204
204
  i && window.sessionStorage.setItem(i, JSON.stringify({
205
205
  previousPage: String(t),
206
206
  targetPath: n ? new URL(String(n), window.location.href).pathname : null,
@@ -208,10 +208,10 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
208
208
  ts: Date.now()
209
209
  }));
210
210
  } catch {}
211
- }, Me = (e) => {
211
+ }, je = (e) => {
212
212
  if (!j || !e) return null;
213
213
  try {
214
- let t = Ae(e);
214
+ let t = ke(e);
215
215
  if (!t) return null;
216
216
  let n = window.sessionStorage.getItem(t);
217
217
  if (!n) return null;
@@ -224,7 +224,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
224
224
  } catch {
225
225
  return null;
226
226
  }
227
- }, R = async (e) => {
227
+ }, Me = async (e) => {
228
228
  let t = await e.json().catch(() => ({}));
229
229
  if (!e.ok) {
230
230
  let n = Error(t.message || t.error || `Request failed with status ${e.status}`);
@@ -243,7 +243,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
243
243
  }
244
244
  }, Ne = async ({ apiBaseUrl: e, userId: t, siteId: n, priorChatId: r = null, forceNew: i = !1, resumeChatId: a = null, visitorId: o = null }) => {
245
245
  let s = `${e}/api/visitors/resolve-session`, c = { siteId: n };
246
- return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), R(await z(s, {
246
+ return r && String(r).trim() && (c.priorChatId = String(r).trim()), i && (c.forceNew = !0), a && (c.resumeChatId = a), o && (c.visitorId = o), Me(await z(s, {
247
247
  method: "POST",
248
248
  mode: "cors",
249
249
  headers: {
@@ -256,7 +256,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
256
256
  }));
257
257
  }, Pe = async ({ apiBaseUrl: e, siteId: t }) => {
258
258
  let n = typeof window < "u" ? window.location.origin : "http://localhost";
259
- return (await R(await z(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
259
+ return (await Me(await z(`${e}/api/widget/chatbot-loader?${new URLSearchParams({
260
260
  siteId: t,
261
261
  origin: n
262
262
  }).toString()}`, { method: "GET" }))).data;
@@ -274,7 +274,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
274
274
  headers: { "Content-Type": "application/json" },
275
275
  body: i
276
276
  }).catch(() => {}), !0) : !1;
277
- }, a = async (i, a = {}) => R(await z(`${e}${i}`, {
277
+ }, a = async (i, a = {}) => Me(await z(`${e}${i}`, {
278
278
  ...a,
279
279
  headers: {
280
280
  "Content-Type": "application/json",
@@ -289,7 +289,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
289
289
  ...n ? { "x-site-id": n } : {},
290
290
  ...a.headers || {}
291
291
  };
292
- return R(await z(`${e}${r}`, {
292
+ return Me(await z(`${e}${r}`, {
293
293
  ...a,
294
294
  body: i,
295
295
  headers: o
@@ -333,7 +333,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
333
333
  stream: !0
334
334
  })
335
335
  });
336
- if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return R(p);
336
+ if (!(p.headers.get("content-type") || "").includes("text/event-stream")) return Me(p);
337
337
  let m = p.body.getReader(), h = new TextDecoder(), g = "", _ = null, v = (e) => {
338
338
  let t = e.split("\n").find((e) => e.startsWith("data: "));
339
339
  if (t) try {
@@ -449,7 +449,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
449
449
  });
450
450
  },
451
451
  async getIceServersConfig() {
452
- return R(await z(`${e}/api/calls/ice-config`, {
452
+ return Me(await z(`${e}/api/calls/ice-config`, {
453
453
  method: "GET",
454
454
  headers: {
455
455
  "x-user-id": t,
@@ -2855,7 +2855,7 @@ async function wr(e, t = {}) {
2855
2855
  reason: "already-on-page"
2856
2856
  };
2857
2857
  let a = i.pathname + i.search + i.hash;
2858
- if (window.Shopify) return n && mr(n), r || De(), r ? Cr().then(() => window.location.assign(i.href)) : window.location.assign(i.href), { navigated: !0 };
2858
+ if (window.Shopify) return n && mr(n), r || Ee(), r ? Cr().then(() => window.location.assign(i.href)) : window.location.assign(i.href), { navigated: !0 };
2859
2859
  let o = window.next?.router;
2860
2860
  if (o?.push) return new Promise((e) => {
2861
2861
  let t = () => {
@@ -2874,11 +2874,11 @@ async function wr(e, t = {}) {
2874
2874
  try {
2875
2875
  window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
2876
2876
  } catch {}
2877
- return n && mr(n), r || De(), window.location.assign(i.href), { navigated: !0 };
2877
+ return n && mr(n), r || Ee(), window.location.assign(i.href), { navigated: !0 };
2878
2878
  }
2879
2879
  return { navigated: !0 };
2880
2880
  }
2881
- return n && mr(n), r || De(), window.location.assign(i.href), { navigated: !0 };
2881
+ return n && mr(n), r || Ee(), window.location.assign(i.href), { navigated: !0 };
2882
2882
  } catch (t) {
2883
2883
  console.warn("[FlowEngage] shadowNavigate error:", t), n && mr(n);
2884
2884
  try {
@@ -3296,7 +3296,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3296
3296
  message: "Looks like you're already on this page!",
3297
3297
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3298
3298
  }]);
3299
- }, []), [D, O] = m(fe().isOpen), [k, A] = m(fe().activeScreen), [j, M] = m(fe().isHumanHandled), [N, oe] = m(fe().agentName), [se, ce] = m(fe().agentHeadshot), [ge, P] = m(() => me(i?.siteId)), [_e, ye] = m(!1), [be, F] = m(!1), [xe, I] = m("idle"), [Se, Ce] = m(!1), [L, Te] = m(!1), [Ee, De] = m(""), [Oe, ke] = m(!1), [Ae, je] = m(0), [Me, R] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3299
+ }, []), [D, O] = m(de().isOpen), [k, A] = m(de().activeScreen), [j, M] = m(de().isHumanHandled), [P, ae] = m(de().agentName), [oe, se] = m(de().agentHeadshot), [he, ge] = m(() => pe(i?.siteId)), [F, ve] = m(!1), [ye, I] = m(!1), [be, L] = m("idle"), [xe, Se] = m(!1), [R, we] = m(!1), [Te, Ee] = m(""), [De, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3300
3300
  url: null,
3301
3301
  at: 0
3302
3302
  }), it = o((e, t) => {
@@ -3313,12 +3313,12 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3313
3313
  url: n,
3314
3314
  at: Date.now()
3315
3315
  }, wr(e, t));
3316
- }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(N), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3316
+ }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(P), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3317
3317
  notifyRouteChange: () => {},
3318
3318
  cleanup: () => {}
3319
3319
  }), St = o((e = {}) => {
3320
3320
  let t = !!e.is_human_handled;
3321
- return M(t), t ? (A("agent"), e.agent_info?.name && oe(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (A("ai"), t);
3321
+ return M(t), t ? (A("agent"), e.agent_info?.name && ae(e.agent_info.name), e.agent_info?.headshot && se(e.agent_info.headshot), t) : (A("ai"), t);
3322
3322
  }, []), Ct = f(() => {
3323
3323
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
3324
3324
  return Number.isFinite(t) && t > 0 ? t : te;
@@ -3326,10 +3326,10 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3326
3326
  c(() => {
3327
3327
  Qe.current = V;
3328
3328
  }, [V]), c(() => {
3329
- gt.current = N;
3330
- }, [N]), c(() => {
3331
- yt.current = Oe;
3332
- }, [Oe]), c(() => {
3329
+ gt.current = P;
3330
+ }, [P]), c(() => {
3331
+ yt.current = De;
3332
+ }, [De]), c(() => {
3333
3333
  bt.current = i;
3334
3334
  }, [i]);
3335
3335
  let wt = () => {
@@ -3338,17 +3338,17 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3338
3338
  ct.current &&= (window.clearTimeout(ct.current), null);
3339
3339
  }, []), Et = (e) => {
3340
3340
  let t = typeof e == "string" ? e.trim().toLowerCase() : "";
3341
- return P(t), he(t, i?.siteId), t;
3341
+ return ge(t), me(t, i?.siteId), t;
3342
3342
  };
3343
3343
  c(() => {
3344
3344
  let e = i?.siteId;
3345
3345
  if (!e) return;
3346
- let t = me(e);
3346
+ let t = pe(e);
3347
3347
  if (t) {
3348
- P(t);
3348
+ ge(t);
3349
3349
  return;
3350
3350
  }
3351
- P((t) => (t && he(t, e), t));
3351
+ ge((t) => (t && me(t, e), t));
3352
3352
  }, [i?.siteId]);
3353
3353
  let Dt = (e = "unspecified") => {
3354
3354
  let t = ot.current || tt.current?.callId, n = ht.current, r = ft.current;
@@ -3478,19 +3478,19 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3478
3478
  });
3479
3479
  };
3480
3480
  c(() => {
3481
- pe({
3481
+ fe({
3482
3482
  isOpen: D,
3483
3483
  activeScreen: k,
3484
3484
  isHumanHandled: j,
3485
- agentName: N,
3486
- agentHeadshot: se
3485
+ agentName: P,
3486
+ agentHeadshot: oe
3487
3487
  });
3488
3488
  }, [
3489
3489
  D,
3490
3490
  k,
3491
3491
  j,
3492
- N,
3493
- se
3492
+ P,
3493
+ oe
3494
3494
  ]), c(() => {
3495
3495
  let e = !0;
3496
3496
  return (async () => {
@@ -3498,7 +3498,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3498
3498
  try {
3499
3499
  let t = E(i), n = await Pe(t);
3500
3500
  if (!e) return;
3501
- let a = t.siteId, o = le(a), s = ve(a), c = "";
3501
+ let a = t.siteId, o = ce(a), s = _e(a), c = "";
3502
3502
  try {
3503
3503
  let e = Xe.current, r = Ze.current;
3504
3504
  if (Xe.current = !1, Ze.current = null, c = (await Ne({
@@ -3510,9 +3510,9 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3510
3510
  resumeChatId: r,
3511
3511
  visitorId: s
3512
3512
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3513
- ie(), de(a, c);
3513
+ ie(), ue(a, c);
3514
3514
  } catch (e) {
3515
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ae(), de(a, c);
3515
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || N(), ue(a, c);
3516
3516
  }
3517
3517
  Ye.current = c;
3518
3518
  let l = Fe({
@@ -3532,23 +3532,23 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3532
3532
  siteId: t.siteId
3533
3533
  });
3534
3534
  H.current = f, f.on("connect", async () => {
3535
- I("connected");
3535
+ L("connected");
3536
3536
  let e = Ye.current;
3537
3537
  if (e && U.current) try {
3538
3538
  St(await U.current.checkHumanHandled(e));
3539
3539
  } catch {}
3540
3540
  }), f.on("disconnect", () => {
3541
- I("disconnected");
3541
+ L("disconnected");
3542
3542
  }), f.on("aiTyping", () => {
3543
- F(!0);
3543
+ I(!0);
3544
3544
  }), f.on("ai:typing", () => {
3545
- F(!0);
3545
+ I(!0);
3546
3546
  }), f.on("messageReceived", (e) => {
3547
3547
  let t = e.message || e, n = {
3548
3548
  ...t,
3549
3549
  message: oi(t.message)
3550
3550
  };
3551
- F(!1), ye(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3551
+ I(!1), ve(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3552
3552
  ...n,
3553
3553
  isPending: !1,
3554
3554
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3566,7 +3566,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3566
3566
  ...t,
3567
3567
  message: oi(t.message)
3568
3568
  };
3569
- F(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ye(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3569
+ I(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && ((n.sender === "agent" || n.agent_name || n.sender === "ai" || n.sender === "bot") && ve(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3570
3570
  ...n,
3571
3571
  isPending: !1,
3572
3572
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3578,11 +3578,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3578
3578
  ...n,
3579
3579
  isPending: !1,
3580
3580
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
3581
- }]), (n.sender === "agent" || n.agent_name) && (M(!0), A("agent"), oe(di([
3581
+ }]), (n.sender === "agent" || n.agent_name) && (M(!0), A("agent"), ae(di([
3582
3582
  n.agent_name,
3583
3583
  n.agentName,
3584
3584
  n.metadata?.agentName
3585
- ], d)), n.sender_headshot && ce(n.sender_headshot), O(!0), je((e) => e + 1)));
3585
+ ], d)), n.sender_headshot && se(n.sender_headshot), O(!0), Ae((e) => e + 1)));
3586
3586
  });
3587
3587
  let p = (e = {}) => {
3588
3588
  let t = di([
@@ -3591,7 +3591,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3591
3591
  e.agent_name,
3592
3592
  gt.current
3593
3593
  ], d);
3594
- M(!0), A("agent"), oe(t), ce(e.agent?.headshot || null), O(!0), je((e) => e + 1), S((e) => fi(e, {
3594
+ M(!0), A("agent"), ae(t), se(e.agent?.headshot || null), O(!0), Ae((e) => e + 1), S((e) => fi(e, {
3595
3595
  id: `agent-joined-${Date.now()}`,
3596
3596
  sender: "system",
3597
3597
  message: `${t} has joined the chat.`,
@@ -3625,15 +3625,15 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3625
3625
  }]);
3626
3626
  }), f.on("chat:history_update", (e) => {
3627
3627
  let t = si(e.chat_history || []);
3628
- S(t), t.length === 0 && (B(!1), M(!1), A("ai"), F(!1), ye(!1));
3628
+ S(t), t.length === 0 && (B(!1), M(!1), A("ai"), I(!1), ve(!1));
3629
3629
  }), f.on("conversation:reset", () => {
3630
- S([]), B(!1), M(!1), A("ai"), F(!1), ye(!1);
3630
+ S([]), B(!1), M(!1), A("ai"), I(!1), ve(!1);
3631
3631
  }), f.on("voice:end_session", (e = {}) => {
3632
- console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), R((e) => e + 1), O(!0), je((e) => e + 1);
3632
+ console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Me((e) => e + 1), O(!0), Ae((e) => e + 1);
3633
3633
  }), f.on("typing:start", (e) => {
3634
- e.sender === "agent" && ye(!0);
3634
+ e.sender === "agent" && ve(!0);
3635
3635
  }), f.on("typing:stop", (e) => {
3636
- e.sender === "agent" && ye(!1);
3636
+ e.sender === "agent" && ve(!1);
3637
3637
  }), f.on("call:incoming", (e = {}) => {
3638
3638
  let t = di([
3639
3639
  e.agentName,
@@ -3646,7 +3646,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3646
3646
  from: e.from || "owner",
3647
3647
  agentId: e.agentId || null,
3648
3648
  agentName: t
3649
- }), oe((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
3649
+ }), ae((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
3650
3650
  }), f.on("call:offer", async (e = {}) => {
3651
3651
  tt.current = e;
3652
3652
  try {
@@ -3739,11 +3739,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3739
3739
  r,
3740
3740
  a
3741
3741
  ]), c(() => () => {
3742
- if (Oe && !vt.current && _t.current.length > 0) {
3742
+ if (De && !vt.current && _t.current.length > 0) {
3743
3743
  let e = Ye.current, t = _t.current, n = U.current;
3744
3744
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), vt.current = !0);
3745
3745
  }
3746
- }, [Oe, _]);
3746
+ }, [De, _]);
3747
3747
  let Mt = p(null);
3748
3748
  c(() => {
3749
3749
  let e = U.current;
@@ -3998,17 +3998,17 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3998
3998
  chatId: y,
3999
3999
  content: e,
4000
4000
  sender: "user",
4001
- email: ge || void 0,
4001
+ email: he || void 0,
4002
4002
  type: i?.type || "text",
4003
4003
  metadata: i?.metadata || {},
4004
4004
  ...n || {}
4005
4005
  });
4006
4006
  return;
4007
4007
  }
4008
- Ce(!0);
4008
+ Se(!0);
4009
4009
  try {
4010
4010
  let o = await Lr(), s = Fr(), l = `stream-preview-${Date.now().toString(36)}`, u = (e) => {
4011
- F(!1), S((t) => {
4011
+ I(!1), S((t) => {
4012
4012
  let n = t.findIndex((e) => e.id === l);
4013
4013
  if (n === -1) return [...t, {
4014
4014
  id: l,
@@ -4025,7 +4025,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4025
4025
  });
4026
4026
  }, d = await U.current.sendAiMessage(y, e, r, t, {
4027
4027
  ...n || {},
4028
- ...ge ? { email: ge } : {}
4028
+ ...he ? { email: he } : {}
4029
4029
  }, {
4030
4030
  ...i,
4031
4031
  currentPageUrl: typeof window < "u" ? window.location.href : void 0,
@@ -4102,10 +4102,10 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4102
4102
  });
4103
4103
  }
4104
4104
  }
4105
- S(si(f)), Array.isArray(d.cart_actions) && d.cart_actions.length && w(d.cart_actions), M(!!d.is_human_handled), A(d.is_human_handled ? "agent" : "ai"), F(!1), Ce(!1), await U.current.updateChatStatus(y, "messageSent");
4105
+ S(si(f)), Array.isArray(d.cart_actions) && d.cart_actions.length && w(d.cart_actions), M(!!d.is_human_handled), A(d.is_human_handled ? "agent" : "ai"), I(!1), Se(!1), await U.current.updateChatStatus(y, "messageSent");
4106
4106
  } catch (e) {
4107
- S((e) => e.filter((e) => e.id !== u && !e.isStreaming)), F(!1), Ce(!1), e.status === 429 ? (Te(!0), De(e.message), window.setTimeout(() => {
4108
- Te(!1), De("");
4107
+ S((e) => e.filter((e) => e.id !== u && !e.isStreaming)), I(!1), Se(!1), e.status === 429 ? (we(!0), Ee(e.message), window.setTimeout(() => {
4108
+ we(!1), Ee("");
4109
4109
  }, ee)) : h(e);
4110
4110
  }
4111
4111
  }, Gt = async (e) => {
@@ -4117,12 +4117,12 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4117
4117
  let t = e ? "voice" : "text";
4118
4118
  await U.current.setChatMode(y, t);
4119
4119
  } catch {}
4120
- ke(e), e && (vt.current = !1);
4120
+ Oe(e), e && (vt.current = !1);
4121
4121
  }
4122
4122
  }, qt = async (e) => {
4123
4123
  if (vt.current) return;
4124
4124
  if (vt.current = !0, !U.current || !y || !e?.length) {
4125
- ke(!1);
4125
+ Oe(!1);
4126
4126
  return;
4127
4127
  }
4128
4128
  let t = () => {
@@ -4146,11 +4146,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4146
4146
  } catch {
4147
4147
  t();
4148
4148
  } finally {
4149
- ke(!1);
4149
+ Oe(!1);
4150
4150
  }
4151
4151
  }, Jt = async () => {
4152
4152
  if (!(!U.current || !y)) {
4153
- Oe && !vt.current && _t.current.length > 0 && await qt(_t.current);
4153
+ De && !vt.current && _t.current.length > 0 && await qt(_t.current);
4154
4154
  try {
4155
4155
  await U.current.endConversation(y);
4156
4156
  } catch {
@@ -4184,7 +4184,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4184
4184
  let e = () => {
4185
4185
  let e = Ye.current, t = U.current;
4186
4186
  if (!t || !e) return;
4187
- if (yt.current && _t.current.length > 0 && we(), !vt.current && _t.current.length > 0 && (t.beaconSyncVoice(e, _t.current) || t.syncVoice(e, _t.current).catch(() => {}), vt.current = !0), ot.current) {
4187
+ if (yt.current && _t.current.length > 0 && Ce(), !vt.current && _t.current.length > 0 && (t.beaconSyncVoice(e, _t.current) || t.syncVoice(e, _t.current).catch(() => {}), vt.current = !0), ot.current) {
4188
4188
  t.beaconEndWebRTCCall(ot.current, e);
4189
4189
  return;
4190
4190
  }
@@ -4197,9 +4197,9 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4197
4197
  }, []);
4198
4198
  let Yt = o(() => {
4199
4199
  let e = i?.siteId;
4200
- ue(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), oe(null), ce(null), Je(!0), s((e) => e + 1);
4200
+ le(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), ae(null), se(null), Je(!0), s((e) => e + 1);
4201
4201
  }, [i?.siteId]), Xt = o((e) => {
4202
- i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), oe(null), ce(null), Je(!0), s((e) => e + 1);
4202
+ i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), ae(null), se(null), Je(!0), s((e) => e + 1);
4203
4203
  }, [i?.siteId]), Zt = f(() => ({
4204
4204
  status: l,
4205
4205
  error: d,
@@ -4210,20 +4210,20 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4210
4210
  isOpen: D,
4211
4211
  activeScreen: k,
4212
4212
  isHumanHandled: j,
4213
- agentName: N,
4214
- agentHeadshot: se,
4215
- visitorEmail: ge,
4216
- isAgentTyping: _e,
4217
- isAiTyping: be,
4218
- connectionStatus: xe,
4219
- isLoading: Se,
4220
- isVoiceMode: Oe,
4221
- isRateLimited: L,
4222
- rateLimitMessage: Ee,
4213
+ agentName: P,
4214
+ agentHeadshot: oe,
4215
+ visitorEmail: he,
4216
+ isAgentTyping: F,
4217
+ isAiTyping: ye,
4218
+ connectionStatus: be,
4219
+ isLoading: xe,
4220
+ isVoiceMode: De,
4221
+ isRateLimited: R,
4222
+ rateLimitMessage: Te,
4223
4223
  isConversationEnded: z,
4224
4224
  isSessionRestoring: qe,
4225
- openToChatCounter: Ae,
4226
- voiceEndCounter: Me,
4225
+ openToChatCounter: ke,
4226
+ voiceEndCounter: je,
4227
4227
  incomingCall: V,
4228
4228
  activeCallId: Le,
4229
4229
  callConnectionState: ze,
@@ -4271,20 +4271,20 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4271
4271
  D,
4272
4272
  k,
4273
4273
  j,
4274
- N,
4275
- se,
4276
- ge,
4277
- _e,
4274
+ P,
4275
+ oe,
4276
+ he,
4277
+ F,
4278
+ ye,
4278
4279
  be,
4279
4280
  xe,
4280
- Se,
4281
- Oe,
4282
- L,
4283
- Ee,
4281
+ De,
4282
+ R,
4283
+ Te,
4284
4284
  z,
4285
4285
  qe,
4286
- Ae,
4287
- Me,
4286
+ ke,
4287
+ je,
4288
4288
  V,
4289
4289
  Le,
4290
4290
  ze,
@@ -9269,7 +9269,7 @@ function _h(e, t, n) {
9269
9269
  try {
9270
9270
  n.gain.cancelScheduledValues(t), n.gain.setValueAtTime(n.gain.value, t), n.gain.linearRampToValueAtTime(0, t + gh), e.stop(t + gh);
9271
9271
  } catch {}
9272
- }), a = [], r = 0;
9272
+ }), a = [], r = 0, i = 0;
9273
9273
  }, s = () => r > e.currentTime;
9274
9274
  return {
9275
9275
  enqueue: (o) => {
@@ -9279,14 +9279,14 @@ function _h(e, t, n) {
9279
9279
  u.buffer = l;
9280
9280
  let d = e.createGain();
9281
9281
  u.connect(d), d.connect(e.destination), n && d.connect(n);
9282
- let f = !s(), p = f ? e.currentTime + fh : r;
9283
- f && (i = p), u.start(p), r = p + l.duration;
9284
- let m = {
9282
+ let f = s() ? r : e.currentTime + fh;
9283
+ i ||= f, u.start(f), r = f + l.duration;
9284
+ let p = {
9285
9285
  source: u,
9286
9286
  gain: d
9287
9287
  };
9288
- a.push(m), u.onended = () => {
9289
- a = a.filter((e) => e !== m), !a.length && !s() && t?.();
9288
+ a.push(p), u.onended = () => {
9289
+ a = a.filter((e) => e !== p), !a.length && !s() && t?.();
9290
9290
  };
9291
9291
  },
9292
9292
  stop: o,
@@ -9354,58 +9354,58 @@ async function yh(e) {
9354
9354
  }
9355
9355
  }, O = (e, t, n) => {
9356
9356
  t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, rh));
9357
- }, k = !1, A = !1, ee = !1, te = !1, ne = !0, j = 0, M = !1, re = !1, ie = ih, ae = ah, N = null, oe = !1, se = !1, ce = () => {
9358
- N && clearTimeout(N);
9357
+ }, k = !1, A = !1, ee = !1, te = !1, ne = !0, j = 0, M = !1, re = !1, ie = ih, N = ah, P = null, ae = !1, oe = !1, se = () => {
9358
+ P && clearTimeout(P);
9359
9359
  let e = () => {
9360
9360
  if (!k) {
9361
- if (le.isPlaying()) {
9362
- N = setTimeout(e, 150);
9361
+ if (ce.isPlaying()) {
9362
+ P = setTimeout(e, 150);
9363
9363
  return;
9364
9364
  }
9365
- if (N = null, oe) {
9365
+ if (P = null, ae) {
9366
9366
  p?.();
9367
9367
  return;
9368
9368
  }
9369
- !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), se && (se = !1, d?.());
9369
+ !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), oe && (oe = !1, d?.());
9370
9370
  }
9371
9371
  };
9372
- N = setTimeout(e, 150);
9373
- }, le = _h(_, () => {
9372
+ P = setTimeout(e, 150);
9373
+ }, ce = _h(_, () => {
9374
9374
  te && (te = !1, c?.({ mode: "listening" }));
9375
9375
  }, v);
9376
- typeof window < "u" && (window.__fe_agentAudioPlaying = () => le.isPlaying());
9377
- let ue = _.createMediaStreamSource(g);
9378
- ue.connect(v);
9379
- let de = _.createScriptProcessor(nh, 1, 1), fe = !1, pe = 0, me = 0;
9380
- de.onaudioprocess = (e) => {
9376
+ typeof window < "u" && (window.__fe_agentAudioPlaying = () => ce.isPlaying());
9377
+ let le = _.createMediaStreamSource(g);
9378
+ le.connect(v);
9379
+ let ue = _.createScriptProcessor(nh, 1, 1), de = !1, fe = 0, pe = 0;
9380
+ ue.onaudioprocess = (e) => {
9381
9381
  if (k || C.readyState !== WebSocket.OPEN) return;
9382
9382
  let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
9383
9383
  if (A) {
9384
- ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), fe = !1, pe = 0, me = 0, n();
9384
+ ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), de = !1, fe = 0, pe = 0, n();
9385
9385
  return;
9386
9386
  }
9387
9387
  let r = lh(t);
9388
- if (le.isPlaying() || re ? (fe = !1, pe = 0, me = 0) : r >= oh ? (me = 0, pe += 1, !fe && pe >= sh && (fe = !0, c?.({ mode: "user-speaking" }))) : (pe = 0, fe && ++me >= ch && (fe = !1, me = 0, c?.({
9388
+ if (ce.isPlaying() || re ? (de = !1, fe = 0, pe = 0) : r >= oh ? (pe = 0, fe += 1, !de && fe >= sh && (de = !0, c?.({ mode: "user-speaking" }))) : (fe = 0, de && ++pe >= ch && (de = !1, pe = 0, c?.({
9389
9389
  mode: "thinking",
9390
9390
  tentative: !0
9391
- }))), (le.isPlaying() || re) && !M) {
9391
+ }))), (ce.isPlaying() || re) && !M) {
9392
9392
  if (r < ie) j = 0;
9393
- else if (++j >= ae) {
9393
+ else if (++j >= N) {
9394
9394
  M = !0, j = 0;
9395
- let e = le.playedMs();
9396
- le.stop(), ne = !1, re = !1, N && !oe && (clearTimeout(N), N = null), se = !1, C.send(JSON.stringify({
9395
+ let e = ce.playedMs();
9396
+ ce.stop(), ne = !1, re = !1, P && !ae && (clearTimeout(P), P = null), oe = !1, C.send(JSON.stringify({
9397
9397
  type: "VisitorInterrupted",
9398
9398
  played_ms: Math.round(e)
9399
9399
  })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
9400
9400
  }
9401
9401
  }
9402
9402
  C.send(uh(t).buffer);
9403
- }, ue.connect(de), de.connect(_.destination);
9404
- let he = () => {
9403
+ }, le.connect(ue), ue.connect(_.destination);
9404
+ let me = () => {
9405
9405
  if (!k) {
9406
- k = !0, N &&= (clearTimeout(N), null), D(), le.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9406
+ k = !0, P &&= (clearTimeout(P), null), D(), ce.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9407
9407
  try {
9408
- de.disconnect(), ue.disconnect();
9408
+ ue.disconnect(), le.disconnect();
9409
9409
  } catch {}
9410
9410
  if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
9411
9411
  x.onstop = () => hh(t, n, S, b, y);
@@ -9417,7 +9417,7 @@ async function yh(e) {
9417
9417
  } else b.length && hh(t, n, S, b, y);
9418
9418
  _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
9419
9419
  }
9420
- }, ge = async (e) => {
9420
+ }, he = async (e) => {
9421
9421
  let t = i[e.name];
9422
9422
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
9423
9423
  let n = {};
@@ -9429,10 +9429,10 @@ async function yh(e) {
9429
9429
  } catch (e) {
9430
9430
  return { error: e?.message || "Tool execution failed" };
9431
9431
  }
9432
- }, P = async (e) => {
9432
+ }, ge = async (e) => {
9433
9433
  for (let t of e.functions || []) {
9434
9434
  if (!t.client_side) continue;
9435
- let e = await ge(t);
9435
+ let e = await he(t);
9436
9436
  if (k || C.readyState !== WebSocket.OPEN) return;
9437
9437
  C.send(JSON.stringify({
9438
9438
  type: "FunctionCallResponse",
@@ -9441,10 +9441,10 @@ async function yh(e) {
9441
9441
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
9442
9442
  }));
9443
9443
  }
9444
- }, _e = (e) => {
9444
+ }, F = (e) => {
9445
9445
  switch (e.type) {
9446
9446
  case "Welcome":
9447
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ie = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (ae = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9447
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ie = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (N = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9448
9448
  break;
9449
9449
  case "ConversationText": {
9450
9450
  let t = String(e.content || "");
@@ -9463,25 +9463,25 @@ async function yh(e) {
9463
9463
  break;
9464
9464
  }
9465
9465
  case "UserStartedSpeaking":
9466
- D(), le.stop(), re = !1, ne = !1, te = !1, N && !oe && (clearTimeout(N), N = null), se = !1, c?.({ mode: "listening" });
9466
+ D(), ce.stop(), re = !1, ne = !1, te = !1, P && !ae && (clearTimeout(P), P = null), oe = !1, c?.({ mode: "listening" });
9467
9467
  break;
9468
9468
  case "AgentStartedSpeaking":
9469
9469
  ne = !0, te = !0, M = !1, j = 0, c?.({ mode: "speaking" });
9470
9470
  break;
9471
9471
  case "AgentAudioDone":
9472
- re = !1, D(), ce(), le.isPlaying() || (te = !1, c?.({ mode: "listening" }));
9472
+ re = !1, D(), se(), ce.isPlaying() || (te = !1, c?.({ mode: "listening" }));
9473
9473
  break;
9474
9474
  case "FunctionCallRequest":
9475
- P(e);
9475
+ ge(e);
9476
9476
  break;
9477
9477
  case "AgentPreparing":
9478
9478
  re = !0;
9479
9479
  break;
9480
9480
  case "AgentTurnComplete":
9481
- se = !0, ce();
9481
+ oe = !0, se();
9482
9482
  break;
9483
9483
  case "SessionEnding":
9484
- console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), oe = !0;
9484
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ae = !0;
9485
9485
  break;
9486
9486
  case "AgentThinking":
9487
9487
  c?.({ mode: "thinking" });
@@ -9498,16 +9498,16 @@ async function yh(e) {
9498
9498
  };
9499
9499
  return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9500
9500
  if (e.data instanceof ArrayBuffer) {
9501
- ne && le.enqueue(new Int16Array(e.data));
9501
+ ne && ce.enqueue(new Int16Array(e.data));
9502
9502
  return;
9503
9503
  }
9504
9504
  try {
9505
- _e(JSON.parse(e.data));
9505
+ F(JSON.parse(e.data));
9506
9506
  } catch {}
9507
9507
  }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9508
- he(), o?.();
9508
+ me(), o?.();
9509
9509
  }, {
9510
- endSession: async () => he(),
9510
+ endSession: async () => me(),
9511
9511
  sendContextualUpdate: (e) => {
9512
9512
  k || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9513
9513
  type: "UpdatePrompt",
@@ -12351,17 +12351,28 @@ function t_() {
12351
12351
  let n = t[r + 1], o = jn(n);
12352
12352
  o && n.tagName === e.tagName && o.length < 60 && (e.nextElementSibling === n || e.parentElement === n.parentElement) && (a = `${i} ${o}`, r++);
12353
12353
  }
12354
- a.length > 2 && a.length < 200 && n.push(a), r++;
12354
+ a.length > 2 && a.length < 200 && n.push({
12355
+ text: a,
12356
+ level: Number(e.tagName.slice(1)) || 6
12357
+ }), r++;
12355
12358
  }
12356
12359
  return n;
12357
12360
  }, t = document.querySelector("main, [role='main']") || document.body, n = e(t.querySelectorAll("h1, h2, h3, h4, h5"));
12358
12361
  n.length || (n = e(document.body.querySelectorAll("h1, h2, h3, h4, h5")));
12359
- let r = [...new Set(n)].slice(0, 30), i = Array.from(t.querySelectorAll("h1")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, .flowengage-widget-root") && !e.closest("nav, footer, header, aside, .nav, .footer, .header, .sidebar")), a = null;
12360
- if (i.length === 1) {
12361
- let e = jn(i[0]);
12362
- e && r[0] && r[0].toLowerCase().trim() === e.toLowerCase().trim() && (a = r[0]);
12363
- }
12364
- let o = "";
12362
+ let r = /* @__PURE__ */ new Set(), i = [];
12363
+ for (let e of n) if (!(!e || r.has(e.text)) && (r.add(e.text), i.push(e), i.length >= 30)) break;
12364
+ let a = i.map((e) => e.text), o = [];
12365
+ for (let e = 0; e < i.length; e++) {
12366
+ let t = 0;
12367
+ for (let n = e + 1; n < i.length && !(i[n].level <= i[e].level); n++) t += 1;
12368
+ t >= 3 && o.push(i[e].text);
12369
+ }
12370
+ let s = Array.from(t.querySelectorAll("h1")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, .flowengage-widget-root") && !e.closest("nav, footer, header, aside, .nav, .footer, .header, .sidebar")), c = null;
12371
+ if (s.length === 1) {
12372
+ let e = jn(s[0]);
12373
+ e && a[0] && a[0].toLowerCase().trim() === e.toLowerCase().trim() && (c = a[0]);
12374
+ }
12375
+ let l = "";
12365
12376
  try {
12366
12377
  let e = t.querySelector("h1, h2, h3, h4, h5");
12367
12378
  if (e) {
@@ -12371,13 +12382,14 @@ function t_() {
12371
12382
  r.querySelectorAll("p, li").forEach((e) => {
12372
12383
  let t = e.textContent.replace(/\s+/g, " ").trim();
12373
12384
  t.length > 20 && i.push(t);
12374
- }), o = i.join(" ").slice(0, 600);
12385
+ }), l = i.join(" ").slice(0, 600);
12375
12386
  }
12376
12387
  } catch {}
12377
12388
  return {
12378
- headings: r,
12379
- pageTitleHeading: a,
12380
- introText: o
12389
+ headings: a,
12390
+ pageTitleHeading: c,
12391
+ introText: l,
12392
+ containerHeadings: o
12381
12393
  };
12382
12394
  }
12383
12395
  function n_(e) {
@@ -12518,10 +12530,10 @@ function r_(e) {
12518
12530
  sender: "user",
12519
12531
  message: e
12520
12532
  }]);
12521
- n && I(t, n);
12533
+ n && L(t, n);
12522
12534
  }
12523
12535
  } catch {}
12524
- we();
12536
+ Ce();
12525
12537
  let e = a;
12526
12538
  try {
12527
12539
  e = new URL(a, typeof window < "u" ? window.location.href : "").href;
@@ -12531,7 +12543,7 @@ function r_(e) {
12531
12543
  let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
12532
12544
  n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
12533
12545
  } catch {}
12534
- t && typeof window < "u" && je(t, window.location.href, e, n), gr(e);
12546
+ t && typeof window < "u" && Ae(t, window.location.href, e, n), gr(e);
12535
12547
  try {
12536
12548
  window.__fe_agent_nav = {
12537
12549
  path: new URL(e, window.location.href).pathname,
@@ -12896,7 +12908,7 @@ function r_(e) {
12896
12908
  try {
12897
12909
  r = new URL(e, window.location.href).href;
12898
12910
  } catch {}
12899
- return t && je(t, window.location.href, r, n), gr(r), Cr().then(() => {
12911
+ return t && Ae(t, window.location.href, r, n), gr(r), Cr().then(() => {
12900
12912
  window.location.assign(r);
12901
12913
  }), `OK_NAVIGATING to ${n}. The page is loading — say one short phrase like "Here you go." and nothing more.`;
12902
12914
  }
@@ -12913,8 +12925,8 @@ function r_(e) {
12913
12925
  var i_ = /^(get in touch|contact us|let'?s (talk|connect)|subscribe|newsletter|follow us|quick links|company|solutions|what we do|resources|legal|sitemap|share this)/i;
12914
12926
  function a_() {
12915
12927
  try {
12916
- let { headings: e, pageTitleHeading: t } = t_();
12917
- return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !i_.test(e.trim()));
12928
+ let { headings: e, pageTitleHeading: t, containerHeadings: n } = t_(), r = new Set((n || []).map((e) => e.trim())), i = (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !i_.test(e.trim())), a = i.filter((e) => !r.has(e.trim()));
12929
+ return a.length ? a : i;
12918
12930
  } catch {
12919
12931
  return [];
12920
12932
  }
@@ -13354,87 +13366,92 @@ function v_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13354
13366
  }
13355
13367
  function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
13356
13368
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
13357
- let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, re] = m(""), ie = p(!1), ae = p(!1), N = p(null), oe = p(0), se = p(""), ce = p(!1), le = p(0), ue = p(!1), de = p(!1), fe = p(!1), pe = p([]), me = p(null), he = (e) => {
13358
- ue.current = e, e || (de.current = !1), P.current?.setWalkthroughActive?.(e);
13369
+ let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, re] = m(""), ie = p(!1), N = p(!1), P = p(null), ae = p(0), oe = p(""), se = p(!1), ce = p(0), le = p(!1), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = p(null), he = (e) => {
13370
+ le.current = e, e || (ue.current = !1), F.current?.setWalkthroughActive?.(e);
13359
13371
  };
13360
13372
  me.current = async () => {
13361
- if (de.current) return;
13362
- let e = pe.current;
13373
+ if (ue.current) return;
13374
+ let e = typeof window < "u" ? window.location.pathname : null;
13375
+ if (e && pe.current && e !== pe.current) {
13376
+ console.log("[FlowEngage] walkthrough ended — visitor left " + pe.current), pe.current = null, fe.current = [], he(!1);
13377
+ return;
13378
+ }
13379
+ let t = fe.current;
13363
13380
  ge.current += 1;
13364
- let t = ge.current, n = e[t];
13365
- if (!n) {
13366
- if (he(!1), e.length) P.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
13367
- else if (t === 0) {
13381
+ let n = ge.current, r = t[n];
13382
+ if (!r) {
13383
+ if (he(!1), t.length) F.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
13384
+ else if (n === 0) {
13368
13385
  let e = "";
13369
13386
  try {
13370
13387
  let t = await _e.current?.["fwh-read-content-mvp"]?.({});
13371
13388
  typeof t == "string" && t && !/^Could not/i.test(t) && (e = t.slice(0, 2800));
13372
13389
  } catch {}
13373
- P.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
13390
+ F.current?.sendUserMessage?.(e ? `Give the visitor a complete spoken overview of this page in 4-6 sentences, based ONLY on this page content:\n"""${e}"""\nThen ask which part they'd like to hear more about. Do not call any tool.` : "Give the visitor a complete spoken overview of this page in 4-6 sentences based on what you know about it, then ask which part they'd like to hear more about. Do not call any tool.", { suppressQuestion: !0 });
13374
13391
  }
13375
13392
  return;
13376
13393
  }
13377
13394
  try {
13378
- await _e.current?.highlightOnPage?.({ section_text: n });
13395
+ await _e.current?.highlightOnPage?.({ section_text: r });
13379
13396
  } catch (e) {
13380
13397
  console.warn("[FlowEngage] walkthrough highlight failed:", e?.message || e);
13381
13398
  }
13382
- console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`);
13383
- let r = "";
13399
+ console.debug(`[FlowEngage] walkthrough step ${n + 1}/${t.length}: ${r}`);
13400
+ let i = "";
13384
13401
  try {
13385
- let e = await _e.current?.["fwh-read-content-mvp"]?.({ section_text: n });
13386
- typeof e == "string" && e && !/^Could not/i.test(e) && (r = e.slice(0, 2500));
13402
+ let e = await _e.current?.["fwh-read-content-mvp"]?.({ section_text: r });
13403
+ typeof e == "string" && e && !/^Could not/i.test(e) && (i = e.slice(0, 2500));
13387
13404
  } catch {}
13388
- let i = r ? `Here is this section's full content — describe it from THIS text only, and do not call any tool:\n"""${r}"""\n` : "read the section's content silently first (fwh-read-content-mvp) if you don't already have it. ";
13389
- P.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t === 0 ? "Starting with" : "Next —"} ${n}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; ` + i + "This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.", { suppressQuestion: !0 });
13405
+ let a = i ? `Here is this section's full content — describe it from THIS text only, and do not call any tool:\n"""${i}"""\n` : "read the section's content silently first (fwh-read-content-mvp) if you don't already have it. ";
13406
+ F.current?.sendUserMessage?.(`Describe the section titled "${r}" in 3-4 sentences, starting with ${n === 0 ? "Starting with" : "Next —"} ${r}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; ` + a + "This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.", { suppressQuestion: !0 });
13390
13407
  };
13391
- let ge = p(0), P = p(null), _e = p(null), ve = p(""), ye = p(async () => {}), be = p(!1), F = p(!1), xe = p(!1), L = p(!1), Te = p("minimized"), Ee = p(null), De = p(null), Oe = p(null), Ae = p(0), je = p(!1), R = p("idle"), z = p(null), Ne = p(!1), Pe = p(null), Fe = o((e = "minimized") => {
13408
+ let ge = p(0), F = p(null), _e = p(null), ve = p(""), ye = p(async () => {}), I = p(!1), be = p(!1), R = p(!1), we = p(!1), Te = p("minimized"), Ee = p(null), De = p(null), ke = p(null), Ae = p(0), Me = p(!1), z = p("idle"), Ne = p(null), Pe = p(!1), Fe = p(null), B = o((e = "minimized") => {
13392
13409
  console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
13393
13410
  destination: e,
13394
13411
  stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
13395
- }), Te.current = e, L.current = !0, queueMicrotask(() => {
13396
- be.current || (be.current = !0, ye.current?.());
13412
+ }), Te.current = e, we.current = !0, queueMicrotask(() => {
13413
+ I.current || (I.current = !0, ye.current?.());
13397
13414
  });
13398
- }, [l]), B = o(() => {
13399
- N.current &&= (clearTimeout(N.current), null);
13415
+ }, [l]), V = o(() => {
13416
+ P.current &&= (clearTimeout(P.current), null);
13400
13417
  }, []);
13401
13418
  c(() => {
13402
13419
  if (y) {
13403
13420
  ie.current = !1;
13404
13421
  return;
13405
13422
  }
13406
- if (ie.current = !0, ae.current = !1, te(!1), B(), ce.current) {
13407
- ce.current = !1, P.current?.setMicMuted?.(!1);
13408
- let e = se.current;
13409
- se.current = "", P.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && P.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13410
- }
13411
- P.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
13412
- }, [y, B]);
13413
- let V = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Ie = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Le = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, Re = o(() => {
13414
- B(), N.current = setTimeout(() => {
13415
- if (!(!ae.current || ie.current)) if (oe.current < 3) {
13416
- oe.current += 1;
13423
+ if (ie.current = !0, N.current = !1, te(!1), V(), se.current) {
13424
+ se.current = !1, F.current?.setMicMuted?.(!1);
13425
+ let e = oe.current;
13426
+ oe.current = "", F.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && F.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13427
+ }
13428
+ F.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
13429
+ }, [y, V]);
13430
+ let Ie = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Le = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Re = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, ze = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, Be = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ve = o(() => {
13431
+ V(), P.current = setTimeout(() => {
13432
+ if (!(!N.current || ie.current)) if (ae.current < 3) {
13433
+ ae.current += 1;
13417
13434
  try {
13418
- P.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
13435
+ F.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
13419
13436
  } catch {}
13420
- Re();
13437
+ Ve();
13421
13438
  } else {
13422
13439
  try {
13423
- P.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
13440
+ F.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
13424
13441
  } catch {}
13425
- ae.current = !1, te(!1), B(), je.current = !0;
13442
+ N.current = !1, te(!1), V(), Me.current = !0;
13426
13443
  }
13427
13444
  }, 1e4);
13428
- }, [B]), ze = o(async (e) => {
13429
- L.current = !0;
13445
+ }, [V]), He = o(async (e) => {
13446
+ we.current = !0;
13430
13447
  try {
13431
13448
  On();
13432
13449
  } catch {}
13433
13450
  if (i) try {
13434
- Me(i);
13451
+ je(i);
13435
13452
  } catch {}
13436
13453
  try {
13437
- await P.current?.endSession?.();
13454
+ await F.current?.endSession?.();
13438
13455
  } catch {}
13439
13456
  let t = Ee.current, n = De.current;
13440
13457
  if (t && s && a) {
@@ -13450,8 +13467,8 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13450
13467
  })
13451
13468
  }).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
13452
13469
  }
13453
- if (Ee.current = null, De.current = null, P.current = null, E("idle"), O(!1), be.current = !1, Or(), i) try {
13454
- Ce(i);
13470
+ if (Ee.current = null, De.current = null, F.current = null, E("idle"), O(!1), I.current = !1, Or(), i) try {
13471
+ Se(i);
13455
13472
  } catch {}
13456
13473
  typeof u == "function" && await u(l.current), e?.();
13457
13474
  }, [
@@ -13461,10 +13478,10 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13461
13478
  s,
13462
13479
  a
13463
13480
  ]);
13464
- ye.current = () => ze(Te.current === "chat" ? t : n), c(() => {
13465
- F.current = D;
13481
+ ye.current = () => He(Te.current === "chat" ? t : n), c(() => {
13482
+ be.current = D;
13466
13483
  }, [D]), c(() => {
13467
- d && Fe("chat");
13484
+ d && B("chat");
13468
13485
  }, [d]), c(() => {
13469
13486
  let e = !1, o = null, c = null, d = null;
13470
13487
  return (async () => {
@@ -13474,10 +13491,10 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13474
13491
  }
13475
13492
  try {
13476
13493
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
13477
- l.current = [], ve.current = "", be.current = !1, xe.current = !1, L.current = !1, Te.current = "minimized", Dr({ onBeforeNavigate: () => {
13494
+ l.current = [], ve.current = "", I.current = !1, R.current = !1, we.current = !1, Te.current = "minimized", Dr({ onBeforeNavigate: () => {
13478
13495
  if (i && l.current.length > 0) try {
13479
13496
  let e = _g(l.current);
13480
- e && I(i, e);
13497
+ e && L(i, e);
13481
13498
  } catch {}
13482
13499
  if (!qn()) {
13483
13500
  let e = Ee.current, t = De.current;
@@ -13496,21 +13513,21 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13496
13513
  }).catch(() => {}), Ee.current = null, De.current = null;
13497
13514
  } catch {}
13498
13515
  }
13499
- we();
13516
+ Ce();
13500
13517
  } });
13501
13518
  let t = o_(r_({
13502
13519
  siteId: i || null,
13503
13520
  apiBaseUrl: a || null,
13504
13521
  chatId: s || null,
13505
13522
  getLastUserVoiceText: () => ve.current,
13506
- isWalkthroughActive: () => ue.current && !de.current,
13523
+ isWalkthroughActive: () => le.current && !ue.current,
13507
13524
  requestEndSession: () => {
13508
- je.current = !0;
13525
+ Me.current = !0;
13509
13526
  },
13510
13527
  requestEmailCollection: () => {
13511
- b && (ie.current || ae.current || (ae.current = !0, oe.current = 0, te(!0), Re()));
13528
+ b && (ie.current || N.current || (N.current = !0, ae.current = 0, te(!0), Ve()));
13512
13529
  }
13513
- })), n = i ? Se(i) : null, r = !!n?.transcript, u = i ? Me(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
13530
+ })), n = i ? xe(i) : null, r = !!n?.transcript, u = i ? je(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
13514
13531
  apiBaseUrl: a,
13515
13532
  siteId: i,
13516
13533
  chatId: s,
@@ -13543,123 +13560,123 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13543
13560
  let e = f || "";
13544
13561
  x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${T}! How may I help you?`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
13545
13562
  }
13546
- let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [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, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, re = !1, N = M ? `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, ye = !1, Ce = !1, Oe = b && !!y && !fe.current, ze = await bh.startSession({
13563
+ let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [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, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, re = !1, P = M ? `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, ye = !1, Se = !1, ke = b && !!y && !de.current, He = await bh.startSession({
13547
13564
  ...x,
13548
13565
  onConnect: ({ conversationId: e }) => {
13549
13566
  Ee.current = e, De.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13550
13567
  },
13551
13568
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
13552
13569
  onSessionInfo: ({ emailOnFile: e }) => {
13553
- fe.current = !!e, e && (ie.current = !0, ae.current = !1, te(!1), B(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13570
+ de.current = !!e, e && (ie.current = !0, N.current = !1, te(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13554
13571
  },
13555
13572
  onAgentTurnEnd: () => {
13556
- e || ue.current && (de.current || ce.current || setTimeout(() => me.current?.(), 250));
13573
+ e || le.current && (ue.current || se.current || setTimeout(() => me.current?.(), 250));
13557
13574
  },
13558
13575
  onSessionEnding: () => {
13559
- e || Fe("minimized");
13576
+ e || B("minimized");
13560
13577
  },
13561
13578
  onModeChange: ({ mode: t, tentative: n }) => {
13562
13579
  if (!e) {
13563
13580
  if (t === "speaking") {
13564
- z.current &&= (clearTimeout(z.current), null), Pe.current &&= (clearTimeout(Pe.current), null), E("speaking"), R.current = "speaking", Ne.current = !1;
13581
+ Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), E("speaking"), z.current = "speaking", Pe.current = !1;
13565
13582
  return;
13566
13583
  }
13567
13584
  if (t === "user-speaking") {
13568
- if (ae.current && !ie.current && Re(), Pe.current &&= (clearTimeout(Pe.current), null), R.current === "speaking") return;
13585
+ if (N.current && !ie.current && Ve(), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13569
13586
  try {
13570
13587
  On();
13571
13588
  } catch {}
13572
- z.current &&= (clearTimeout(z.current), null), R.current !== "listening" && (E("listening"), R.current = "listening");
13589
+ Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "listening" && (E("listening"), z.current = "listening");
13573
13590
  return;
13574
13591
  }
13575
13592
  if (t === "thinking") {
13576
- if (z.current &&= (clearTimeout(z.current), null), Pe.current &&= (clearTimeout(Pe.current), null), R.current === "speaking") return;
13577
- E("thinking"), R.current = "thinking", n && (Pe.current = setTimeout(() => {
13578
- Pe.current = null, !(e || R.current !== "thinking") && (R.current = "listening", E("listening"));
13593
+ if (Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13594
+ E("thinking"), z.current = "thinking", n && (Fe.current = setTimeout(() => {
13595
+ Fe.current = null, !(e || z.current !== "thinking") && (z.current = "listening", E("listening"));
13579
13596
  }, 4e3));
13580
13597
  return;
13581
13598
  }
13582
- if (R.current = "listening", je.current) {
13583
- je.current = !1, Fe();
13599
+ if (z.current = "listening", Me.current) {
13600
+ Me.current = !1, B();
13584
13601
  return;
13585
13602
  }
13586
- if (Oe && !Ce && !ie.current && !fe.current) {
13587
- Ce = !0, A = !0, ne = !0;
13603
+ if (ke && !Se && !ie.current && !de.current) {
13604
+ Se = !0, A = !0, ne = !0;
13588
13605
  try {
13589
- P.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
13606
+ F.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
13590
13607
  } catch {}
13591
13608
  }
13592
13609
  if (ee && !A) {
13593
13610
  A = !0;
13594
13611
  try {
13595
- P.current?.sendContextualUpdate?.(ee);
13612
+ F.current?.sendContextualUpdate?.(ee);
13596
13613
  } catch {}
13597
13614
  }
13598
- if (N && !re) {
13615
+ if (P && !re) {
13599
13616
  re = !0;
13600
13617
  try {
13601
- P.current?.sendContextualUpdate?.(N);
13618
+ F.current?.sendContextualUpdate?.(P);
13602
13619
  } catch {}
13603
13620
  }
13604
13621
  if (j && !ne) {
13605
13622
  ne = !0;
13606
13623
  try {
13607
- P.current?.sendContextualUpdate?.(j);
13624
+ F.current?.sendContextualUpdate?.(j);
13608
13625
  } catch {}
13609
13626
  }
13610
- z.current && clearTimeout(z.current), z.current = setTimeout(() => {
13611
- e || R.current !== "speaking" && (Ne.current || (z.current = null, R.current = "listening", E("listening")));
13627
+ Ne.current && clearTimeout(Ne.current), Ne.current = setTimeout(() => {
13628
+ e || z.current !== "speaking" && (Pe.current || (Ne.current = null, z.current = "listening", E("listening")));
13612
13629
  }, 1200);
13613
13630
  }
13614
13631
  },
13615
13632
  onMessage: (t) => {
13616
- if (e || ce.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13633
+ if (e || se.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13617
13634
  let n = t.role === "user" && /^(Describe the section titled "|\[SYSTEM:|Give the visitor a complete spoken overview|That was the last section)/.test(String(t.message || "").trim()), r = /\b(?:this|that|the)\s+(?:case\s*stud(?:y|ies)|product|article|blog|post|item|service)\b/i.test(String(t.message || ""));
13618
- if (!n && !r && t.role === "user" && V.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), he(!0), de.current = !1, le.current = 0, ge.current = -1, pe.current = a_(), setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${pe.current.length} sections on this page`);
13619
- else if (!n && t.role === "user" && ue.current) {
13620
- let e = String(t.message || "").trim();
13621
- Le.test(e) ? de.current && (de.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => me.current?.(), 300)) : (de.current = !0, console.debug("[FlowEngage] walkthrough paused — visitor interjected"));
13635
+ if (!n && !r && t.role === "user" && Ie.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), he(!0), ue.current = !1, ce.current = 0, ge.current = -1, fe.current = a_(), pe.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`);
13636
+ else if (!n && t.role === "user" && le.current) {
13637
+ let e = String(t.message || "").trim(), n = Be(e), r = (e) => !!e && (Re.test(e) || ze.test(e));
13638
+ !n || r(e) || r(n) ? ue.current && (ue.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => me.current?.(), 300)) : (console.log("[FlowEngage] walkthrough ended — visitor moved to a new topic"), pe.current = null, fe.current = [], he(!1));
13622
13639
  }
13623
- if (t.role !== "user" && Ie.test(String(t.message || ""))) {
13624
- let e = pe.current.length;
13640
+ if (t.role !== "user" && Le.test(String(t.message || ""))) {
13641
+ let e = fe.current.length;
13625
13642
  !e || ge.current >= e - 1 ? he(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${ge.current + 1}/${e} — ignoring, tour continues`);
13626
13643
  }
13627
13644
  let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
13628
13645
  if (o) {
13629
- if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ne.current = !0, z.current &&= (clearTimeout(z.current), null), R.current !== "speaking" && (E("thinking"), R.current = "thinking"), Oe && !ye && !ie.current && !fe.current && (ye = !0, se.current = o, ce.current = !0, P.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), P.current?.setMicMuted?.(!0), ae.current || (ae.current = !0, oe.current = 0, te(!0), Re()))), l.current = [...l.current, {
13646
+ if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), ke && !ye && !ie.current && !de.current && (ye = !0, oe.current = o, se.current = !0, F.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), F.current?.setMicMuted?.(!0), N.current || (N.current = !0, ae.current = 0, te(!0), Ve()))), l.current = [...l.current, {
13630
13647
  sender: a,
13631
13648
  message: o,
13632
13649
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
13633
13650
  debug: t.debug
13634
13651
  }], i) try {
13635
13652
  let e = _g(l.current);
13636
- e && I(i, e);
13653
+ e && L(i, e);
13637
13654
  } catch {}
13638
13655
  if (h_(a, o)) {
13639
- je.current = !0;
13656
+ Me.current = !0;
13640
13657
  return;
13641
13658
  }
13642
- if (F.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o)) if (Ae.current += 1, Ae.current === 2) try {
13643
- P.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.");
13659
+ if (be.current && a === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(o)) if (Ae.current += 1, Ae.current === 2) try {
13660
+ F.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.");
13644
13661
  } catch {}
13645
- else Ae.current >= 5 && Fe("minimized");
13662
+ else Ae.current >= 5 && B("minimized");
13646
13663
  }
13647
13664
  },
13648
13665
  onError: (t) => {
13649
- if (!e && !L.current && !xe.current && !ke()) {
13650
- xe.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13666
+ if (!e && !we.current && !R.current && !Oe()) {
13667
+ R.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13651
13668
  message: t?.message,
13652
13669
  name: t?.name,
13653
13670
  raw: t
13654
13671
  });
13655
13672
  try {
13656
- P.current?.setMicMuted?.(!0);
13673
+ F.current?.setMicMuted?.(!0);
13657
13674
  } catch {}
13658
- O(!0), E("error"), Fe("chat");
13675
+ O(!0), E("error"), B("chat");
13659
13676
  }
13660
13677
  },
13661
13678
  onDisconnect: (t) => {
13662
- if (e || L.current || xe.current || ke()) return;
13679
+ if (e || we.current || R.current || Oe()) return;
13663
13680
  let n = l.current?.length || 0;
13664
13681
  console.warn("[FlowEngageVoiceCall] session:disconnected", {
13665
13682
  historyCount: n,
@@ -13667,21 +13684,21 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13667
13684
  closeCode: t?.context?.code,
13668
13685
  closeReason: t?.context?.reason || t?.message,
13669
13686
  lastUserText: ve.current || "",
13670
- wasMuted: F.current
13671
- }), xe.current = !0;
13687
+ wasMuted: be.current
13688
+ }), R.current = !0;
13672
13689
  try {
13673
- P.current?.setMicMuted?.(!0);
13690
+ F.current?.setMicMuted?.(!0);
13674
13691
  } catch {}
13675
- O(!0), Fe("chat");
13692
+ O(!0), B("chat");
13676
13693
  }
13677
13694
  });
13678
13695
  if (e) {
13679
- console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), ze.endSession().catch(() => {});
13696
+ console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), He.endSession().catch(() => {});
13680
13697
  return;
13681
13698
  }
13682
- o = ze, P.current = ze, E("listening");
13699
+ o = He, F.current = He, E("listening");
13683
13700
  try {
13684
- sessionStorage.setItem(`el_conv_${i}`, ze.getId());
13701
+ sessionStorage.setItem(`el_conv_${i}`, He.getId());
13685
13702
  } catch {}
13686
13703
  parent.postMessage({ type: "AGENT_EXPAND" }, "*");
13687
13704
  try {
@@ -13695,7 +13712,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13695
13712
  n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (o = [...new Set(n)].slice(0, 15).join(" | "));
13696
13713
  } catch {}
13697
13714
  let s = r && !p ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
13698
- ze.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), ze.sendContextualUpdate(c_(e, o, a));
13715
+ He.sendContextualUpdate(`${s}SiteId: ${i || "unknown"}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`), He.sendContextualUpdate(c_(e, o, a));
13699
13716
  } catch {}
13700
13717
  if (typeof window < "u") {
13701
13718
  let t = window.location.pathname, n = Date.now(), r = (e) => {
@@ -13728,10 +13745,10 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13728
13745
  if (o) {
13729
13746
  typeof window < "u" && (window.__fe_agent_nav = null), console.log(`[FlowEngage] agent-driven navigation settled: "${s}" → "${i}"`);
13730
13747
  try {
13731
- P.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
13748
+ F.current?.sendUserMessage?.(`[SYSTEM: YOU just navigated the visitor to the "${m}" page (${c}) at their request — this was YOUR action, not theirs. Page title: "${l}". Sections: ${JSON.stringify(u)}. Say: "Here we are on the ${m} page." Then introduce this page in 2-3 sentences, and finish by asking: "Would you like me to walk you through it section by section?" NEVER say "I see you've navigated" — the visitor did not navigate, you did. Do NOT call fwh-navigate-mvp again. Wait for their answer before describing sections.]`, { suppressQuestion: !0 });
13732
13749
  } catch {}
13733
13750
  try {
13734
- P.current?.sendContextualUpdate?.(c_(c, d));
13751
+ F.current?.sendContextualUpdate?.(c_(c, d));
13735
13752
  } catch {}
13736
13753
  return;
13737
13754
  }
@@ -13743,10 +13760,10 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13743
13760
  ts: Date.now()
13744
13761
  }), console.log(`[FlowEngage] visitor navigation detected: "${s}" → "${i}" (agent target: ${k || "none"})`);
13745
13762
  try {
13746
- P.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${m}" page (${c}). Page title: "${l}". Sections: ${JSON.stringify(u)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${m} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${m}" only.]`);
13763
+ F.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${m}" page (${c}). Page title: "${l}". Sections: ${JSON.stringify(u)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${m} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${m}" only.]`);
13747
13764
  } catch {}
13748
13765
  try {
13749
- P.current?.sendContextualUpdate?.(c_(c, d));
13766
+ F.current?.sendContextualUpdate?.(c_(c, d));
13750
13767
  } catch {}
13751
13768
  };
13752
13769
  c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
@@ -13763,15 +13780,15 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13763
13780
  agentId: r,
13764
13781
  siteId: i,
13765
13782
  apiBaseUrl: a
13766
- }), e = !0, L.current = !0;
13783
+ }), e = !0, we.current = !0;
13767
13784
  try {
13768
13785
  On();
13769
13786
  } catch {}
13770
13787
  if (i) try {
13771
- Me(i);
13788
+ je(i);
13772
13789
  } catch {}
13773
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), z.current &&= (clearTimeout(z.current), null), Pe.current &&= (clearTimeout(Pe.current), null), N.current &&= (clearTimeout(N.current), null), Ne.current = !1, R.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13774
- let t = o || P.current, n = Ee.current, f = De.current;
13790
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), P.current &&= (clearTimeout(P.current), null), Pe.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13791
+ let t = o || F.current, n = Ee.current, f = De.current;
13775
13792
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13776
13793
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
13777
13794
  chatId: s,
@@ -13792,53 +13809,53 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13792
13809
  r,
13793
13810
  i,
13794
13811
  a,
13795
- Fe
13812
+ B
13796
13813
  ]), c(() => {
13797
13814
  if (!k) return;
13798
13815
  let e = (e) => {
13799
13816
  let t = e.composedPath?.()?.[0] || e.target;
13800
- Oe.current && !Oe.current.contains(t) && A(!1);
13817
+ ke.current && !ke.current.contains(t) && A(!1);
13801
13818
  };
13802
13819
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13803
13820
  }, [k]);
13804
- let Be = async () => {
13805
- if (P.current) try {
13821
+ let Ue = async () => {
13822
+ if (F.current) try {
13806
13823
  if (D) {
13807
- Ae.current = 0, await P.current.setMicMuted?.(!1), O(!1);
13824
+ Ae.current = 0, await F.current.setMicMuted?.(!1), O(!1);
13808
13825
  try {
13809
- P.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13826
+ F.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13810
13827
  } catch {}
13811
13828
  } else {
13812
- Ae.current = 0, await P.current.setMicMuted?.(!0), O(!0);
13829
+ Ae.current = 0, await F.current.setMicMuted?.(!0), O(!0);
13813
13830
  try {
13814
- P.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.");
13831
+ F.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.");
13815
13832
  } catch {}
13816
13833
  }
13817
13834
  } catch {}
13818
- }, Ve = o(async (e) => {
13835
+ }, We = o(async (e) => {
13819
13836
  e?.preventDefault?.();
13820
13837
  let t = ne.trim().toLowerCase();
13821
13838
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13822
13839
  re("Please enter a valid email address.");
13823
13840
  return;
13824
13841
  }
13825
- re(""), ie.current = !0, ae.current = !1, B(), te(!1), j(""), ce.current = !1;
13842
+ re(""), ie.current = !0, N.current = !1, V(), te(!1), j(""), se.current = !1;
13826
13843
  try {
13827
13844
  typeof v == "function" && await v(t);
13828
13845
  } catch {}
13829
- P.current?.setMicMuted?.(!1);
13830
- let n = se.current;
13831
- se.current = "";
13846
+ F.current?.setMicMuted?.(!1);
13847
+ let n = oe.current;
13848
+ oe.current = "";
13832
13849
  try {
13833
- P.current?.injectAgentSpeech?.("Thank you for submitting your email."), P.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13850
+ F.current?.injectAgentSpeech?.("Thank you for submitting your email."), F.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13834
13851
  } catch {}
13835
13852
  }, [
13836
13853
  ne,
13837
13854
  v,
13838
- B
13839
- ]), He = Array.isArray(e) && e[0] || "#3B82F6";
13855
+ V
13856
+ ]), Ge = Array.isArray(e) && e[0] || "#3B82F6";
13840
13857
  return /* @__PURE__ */ _("div", {
13841
- ref: Oe,
13858
+ ref: ke,
13842
13859
  style: {
13843
13860
  position: "relative",
13844
13861
  display: "flex",
@@ -13849,7 +13866,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13849
13866
  },
13850
13867
  children: [
13851
13868
  ee && /* @__PURE__ */ _("form", {
13852
- onSubmit: Ve,
13869
+ onSubmit: We,
13853
13870
  style: {
13854
13871
  width: "270px",
13855
13872
  maxWidth: "calc(100vw - 40px)",
@@ -13912,7 +13929,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13912
13929
  padding: "10px 12px",
13913
13930
  borderRadius: "10px",
13914
13931
  border: "none",
13915
- background: ne.trim() ? He : "#374151",
13932
+ background: ne.trim() ? Ge : "#374151",
13916
13933
  color: "white",
13917
13934
  fontSize: "14px",
13918
13935
  fontWeight: 600,
@@ -13981,7 +13998,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13981
13998
  alignItems: "center"
13982
13999
  },
13983
14000
  children: [/* @__PURE__ */ g("button", {
13984
- onClick: Be,
14001
+ onClick: Ue,
13985
14002
  title: D ? "Unmute" : "Mute",
13986
14003
  style: {
13987
14004
  width: "24px",
@@ -14076,7 +14093,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14076
14093
  children: [
14077
14094
  /* @__PURE__ */ _("button", {
14078
14095
  onClick: () => {
14079
- A(!1), Te.current = "chat", ze(t);
14096
+ A(!1), Te.current = "chat", He(t);
14080
14097
  },
14081
14098
  style: {
14082
14099
  display: "flex",
@@ -14105,7 +14122,7 @@ function y_({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
14105
14122
  }),
14106
14123
  /* @__PURE__ */ _("button", {
14107
14124
  onClick: () => {
14108
- A(!1), Te.current = "minimized", ze(n);
14125
+ A(!1), Te.current = "minimized", He(n);
14109
14126
  },
14110
14127
  style: {
14111
14128
  display: "flex",
@@ -14231,8 +14248,8 @@ var x_ = () => /* @__PURE__ */ g("div", {
14231
14248
  } }, e))
14232
14249
  })
14233
14250
  });
14234
- function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: ae, setReplyContext: N, webRTCError: oe, micError: se, setMicError: ce, dismissCallError: le, activeCallId: ue, isCallMuted: de, toggleCallMute: fe, endWebRTCCall: pe, formatCallDuration: me, callDurationSeconds: he, isCallMinimized: ge, onExpand: P, onCollapse: _e, onStartVoice: ve, voiceEnabled: ye, headerBgColor: be, onNewChat: F, showPoweredBy: xe, privacyPolicyUrl: I, getVisitorChatHistory: Se, resumeChat: Ce, isSessionRestoring: L, isClosing: we }) {
14235
- let Te = l.length > 0, Ee = T || E || w, De = !!ue, [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, R] = m([]), [z, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
14251
+ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: N, setReplyContext: P, webRTCError: ae, micError: oe, setMicError: se, dismissCallError: ce, activeCallId: le, isCallMuted: ue, toggleCallMute: de, endWebRTCCall: fe, formatCallDuration: pe, callDurationSeconds: me, isCallMinimized: he, onExpand: ge, onCollapse: F, onStartVoice: _e, voiceEnabled: ve, headerBgColor: ye, onNewChat: I, showPoweredBy: be, privacyPolicyUrl: L, getVisitorChatHistory: xe, resumeChat: Se, isSessionRestoring: R, isClosing: Ce }) {
14252
+ let we = l.length > 0, Te = T || E || w, Ee = !!le, [De, Oe] = m(!1), [ke, Ae] = m(!1), [je, Me] = m([]), [z, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
14236
14253
  c(() => {
14237
14254
  if (!s) return;
14238
14255
  let e = window.visualViewport;
@@ -14245,26 +14262,26 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14245
14262
  };
14246
14263
  }, [s]);
14247
14264
  let Le = s && window.innerHeight - Fe > 150, Re = async () => {
14248
- ke(!1), je(!0), Ne(!0);
14265
+ Oe(!1), Ae(!0), Ne(!0);
14249
14266
  try {
14250
- let e = await Se();
14251
- e?.data && R(e.data);
14267
+ let e = await xe();
14268
+ e?.data && Me(e.data);
14252
14269
  } catch (e) {
14253
14270
  console.error(e);
14254
14271
  } finally {
14255
14272
  Ne(!1);
14256
14273
  }
14257
14274
  }, ze = async (e) => {
14258
- je(!1), Ce?.(e.chatId);
14275
+ Ae(!1), Se?.(e.chatId);
14259
14276
  };
14260
14277
  return c(() => {
14261
- if (!Oe) return;
14278
+ if (!De) return;
14262
14279
  let e = (e) => {
14263
14280
  let t = e.composedPath?.()?.[0] || e.target;
14264
- Pe.current && !Pe.current.contains(t) && ke(!1);
14281
+ Pe.current && !Pe.current.contains(t) && Oe(!1);
14265
14282
  };
14266
14283
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
14267
- }, [Oe]), /* @__PURE__ */ _("div", {
14284
+ }, [De]), /* @__PURE__ */ _("div", {
14268
14285
  style: s ? {
14269
14286
  "--flowengage-primary": n,
14270
14287
  "--flowengage-accent": n,
@@ -14278,7 +14295,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14278
14295
  display: "flex",
14279
14296
  flexDirection: "column",
14280
14297
  overflow: "hidden",
14281
- animation: we ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
14298
+ animation: Ce ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
14282
14299
  } : {
14283
14300
  "--flowengage-primary": n,
14284
14301
  "--flowengage-accent": n,
@@ -14291,7 +14308,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14291
14308
  flexDirection: "column",
14292
14309
  overflow: "hidden",
14293
14310
  position: "relative",
14294
- animation: we ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
14311
+ animation: Ce ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
14295
14312
  },
14296
14313
  children: [
14297
14314
  /* @__PURE__ */ _("div", {
@@ -14301,7 +14318,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14301
14318
  alignItems: "center",
14302
14319
  columnGap: "14px",
14303
14320
  padding: "16px 10px 14px",
14304
- background: be || "transparent",
14321
+ background: ye || "transparent",
14305
14322
  flexShrink: 0,
14306
14323
  position: "relative",
14307
14324
  zIndex: 30
@@ -14314,7 +14331,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14314
14331
  alignItems: "center"
14315
14332
  },
14316
14333
  children: /* @__PURE__ */ g("button", {
14317
- onClick: _e,
14334
+ onClick: F,
14318
14335
  style: {
14319
14336
  width: "40px",
14320
14337
  height: "40px",
@@ -14419,7 +14436,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14419
14436
  ref: Pe,
14420
14437
  children: [/* @__PURE__ */ g("button", {
14421
14438
  type: "button",
14422
- onClick: () => ke((e) => !e),
14439
+ onClick: () => Oe((e) => !e),
14423
14440
  style: {
14424
14441
  width: "40px",
14425
14442
  height: "40px",
@@ -14465,7 +14482,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14465
14482
  })
14466
14483
  ]
14467
14484
  })
14468
- }), Oe && /* @__PURE__ */ _("div", {
14485
+ }), De && /* @__PURE__ */ _("div", {
14469
14486
  style: {
14470
14487
  position: "absolute",
14471
14488
  top: "34px",
@@ -14481,10 +14498,10 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14481
14498
  animation: "fe-orb-fade-in 0.18s ease"
14482
14499
  },
14483
14500
  children: [
14484
- ye && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
14501
+ ve && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
14485
14502
  type: "button",
14486
14503
  onClick: () => {
14487
- ke(!1), ve?.();
14504
+ Oe(!1), _e?.();
14488
14505
  },
14489
14506
  style: {
14490
14507
  display: "flex",
@@ -14526,7 +14543,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14526
14543
  /* @__PURE__ */ _("button", {
14527
14544
  type: "button",
14528
14545
  onClick: () => {
14529
- ke(!1), F?.();
14546
+ Oe(!1), I?.();
14530
14547
  },
14531
14548
  style: {
14532
14549
  display: "flex",
@@ -14561,7 +14578,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14561
14578
  children: [/* @__PURE__ */ g("path", { d: "M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7" }), /* @__PURE__ */ g("path", { d: "M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" })]
14562
14579
  }), "Start new chat"]
14563
14580
  }),
14564
- Se && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
14581
+ xe && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
14565
14582
  height: "1px",
14566
14583
  background: "rgba(255,255,255,0.07)",
14567
14584
  margin: "0 14px"
@@ -14609,7 +14626,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14609
14626
  /* @__PURE__ */ _("button", {
14610
14627
  type: "button",
14611
14628
  onClick: () => {
14612
- ke(!1), _e?.();
14629
+ Oe(!1), F?.();
14613
14630
  },
14614
14631
  style: {
14615
14632
  display: "flex",
@@ -14668,23 +14685,23 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14668
14685
  ]
14669
14686
  }),
14670
14687
  /* @__PURE__ */ g($h, {
14671
- webRTCError: oe,
14672
- micError: se,
14673
- setMicError: ce,
14674
- dismissCallError: le,
14688
+ webRTCError: ae,
14689
+ micError: oe,
14690
+ setMicError: se,
14691
+ dismissCallError: ce,
14675
14692
  isRateLimited: E,
14676
14693
  rateLimitMessage: D
14677
14694
  }),
14678
- ge && /* @__PURE__ */ g(gg, {
14695
+ he && /* @__PURE__ */ g(gg, {
14679
14696
  agentName: v,
14680
14697
  agentHeadshot: y,
14681
14698
  fallbackAgentName: b,
14682
- callDurationSeconds: he,
14683
- isCallMuted: de,
14684
- formatCallDuration: me,
14685
- toggleCallMute: fe,
14686
- endWebRTCCall: pe,
14687
- onExpand: P,
14699
+ callDurationSeconds: me,
14700
+ isCallMuted: ue,
14701
+ formatCallDuration: pe,
14702
+ toggleCallMute: de,
14703
+ endWebRTCCall: fe,
14704
+ onExpand: ge,
14688
14705
  primaryColor: n
14689
14706
  }),
14690
14707
  /* @__PURE__ */ _("div", {
@@ -14696,7 +14713,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14696
14713
  background: "transparent",
14697
14714
  position: "relative"
14698
14715
  },
14699
- children: [Ae ? /* @__PURE__ */ _("div", {
14716
+ children: [ke ? /* @__PURE__ */ _("div", {
14700
14717
  style: {
14701
14718
  position: "absolute",
14702
14719
  inset: 0,
@@ -14715,7 +14732,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14715
14732
  flexShrink: 0
14716
14733
  },
14717
14734
  children: /* @__PURE__ */ _("button", {
14718
- onClick: () => je(!1),
14735
+ onClick: () => Ae(!1),
14719
14736
  style: {
14720
14737
  background: "none",
14721
14738
  border: "none",
@@ -14757,7 +14774,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14757
14774
  fontSize: "14px"
14758
14775
  },
14759
14776
  children: "Loading past conversations..."
14760
- }) : Me.length > 0 ? /* @__PURE__ */ g("div", { children: Me.map((e) => /* @__PURE__ */ _("div", {
14777
+ }) : je.length > 0 ? /* @__PURE__ */ g("div", { children: je.map((e) => /* @__PURE__ */ _("div", {
14761
14778
  onClick: () => ze(e),
14762
14779
  style: {
14763
14780
  padding: "16px 20px",
@@ -14809,18 +14826,18 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14809
14826
  children: "No previous chats found."
14810
14827
  })
14811
14828
  })]
14812
- }) : null, Te ? /* @__PURE__ */ g(Xh, {
14829
+ }) : null, we ? /* @__PURE__ */ g(Xh, {
14813
14830
  chatHistory: l,
14814
14831
  isAiTyping: u,
14815
14832
  isLoading: T,
14816
14833
  isAgentTyping: d,
14817
- setReplyContext: N,
14834
+ setReplyContext: P,
14818
14835
  TypingDots: x_,
14819
14836
  primaryColor: n,
14820
14837
  agentHeadshot: y,
14821
14838
  agentDisplayName: v || b,
14822
14839
  botAvatarNode: /* @__PURE__ */ g(b_, { orbColors: t })
14823
- }) : L ? /* @__PURE__ */ _("div", {
14840
+ }) : R ? /* @__PURE__ */ _("div", {
14824
14841
  style: {
14825
14842
  flex: 1,
14826
14843
  display: "flex",
@@ -14956,13 +14973,13 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14956
14973
  setInput: S,
14957
14974
  onSubmit: C,
14958
14975
  isConversationEnded: w,
14959
- callUiActive: De,
14960
- handleToggleVoice: ve,
14976
+ callUiActive: Ee,
14977
+ handleToggleVoice: _e,
14961
14978
  showVoiceToggle: f === "agent",
14962
14979
  activeScreen: f,
14963
- inputDisabled: Ee,
14964
- replyContext: ae,
14965
- clearReplyContext: () => N(null),
14980
+ inputDisabled: Te,
14981
+ replyContext: N,
14982
+ clearReplyContext: () => P(null),
14966
14983
  onFileSelect: k,
14967
14984
  selectedFile: O,
14968
14985
  onRemoveSelectedFile: A,
@@ -14983,7 +15000,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14983
15000
  paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
14984
15001
  pointerEvents: "none"
14985
15002
  },
14986
- children: [I && /* @__PURE__ */ _("p", {
15003
+ children: [L && /* @__PURE__ */ _("p", {
14987
15004
  style: {
14988
15005
  margin: "0 0 4px",
14989
15006
  fontSize: "10px",
@@ -14996,7 +15013,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14996
15013
  "This conversation is recorded for quality assurance purposes.",
14997
15014
  " ",
14998
15015
  /* @__PURE__ */ g("a", {
14999
- href: I,
15016
+ href: L,
15000
15017
  target: "_blank",
15001
15018
  rel: "noopener noreferrer",
15002
15019
  style: {
@@ -15006,7 +15023,7 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15006
15023
  children: "See our privacy policy"
15007
15024
  })
15008
15025
  ]
15009
- }), xe && /* @__PURE__ */ _("span", {
15026
+ }), be && /* @__PURE__ */ _("span", {
15010
15027
  style: {
15011
15028
  fontSize: "11px",
15012
15029
  color: "#9ca3af",
@@ -15026,33 +15043,33 @@ function S_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15026
15043
  });
15027
15044
  }
15028
15045
  function C_() {
15029
- let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: M, openWidget: re, captureVisitorEmail: ie, setVoiceMode: ae, endConversation: N, startNewChat: ce, acceptCall: le, rejectCall: ue, endWebRTCCall: de, toggleCallMute: fe, dismissCallError: pe, startTyping: me, stopTyping: he, updateTypingDraft: ge, getVisitorChatHistory: P, resumeChat: _e, isSessionRestoring: ve, openToChatCounter: ye, voiceEndCounter: be } = Cn();
15046
+ let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: M, openWidget: re, captureVisitorEmail: ie, setVoiceMode: N, endConversation: P, startNewChat: se, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: F, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = Cn();
15030
15047
  c(() => {
15031
15048
  try {
15032
15049
  or();
15033
15050
  } catch {}
15034
15051
  }, []), c(() => {
15035
- ye && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (ae?.(!1), $e("text_chat"));
15036
- }, [ye]);
15037
- let F = t?.widgetSettings || {}, xe = n?.widgetSettings || {}, I = {
15038
- ...F.branding || {},
15039
- ...xe.branding || {}
15040
- }, L = {
15041
- ...F.theme || {},
15042
- ...xe.theme || {}
15043
- }, we = {
15044
- ...F.features || {},
15045
- ...xe.features || {}
15046
- }, Ee = we.voice !== !1, De = Array.isArray(L.orbColors) && L.orbColors.length > 0 ? L.orbColors : null, ke = L.buttonColor || L.primaryColor || De?.[0] || "#3B82F6", Ae = {
15052
+ ve && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (N?.(!1), $e("text_chat"));
15053
+ }, [ve]);
15054
+ let I = t?.widgetSettings || {}, be = n?.widgetSettings || {}, L = {
15055
+ ...I.branding || {},
15056
+ ...be.branding || {}
15057
+ }, R = {
15058
+ ...I.theme || {},
15059
+ ...be.theme || {}
15060
+ }, Ce = {
15061
+ ...I.features || {},
15062
+ ...be.features || {}
15063
+ }, Te = Ce.voice !== !1, Ee = Array.isArray(R.orbColors) && R.orbColors.length > 0 ? R.orbColors : null, Oe = R.buttonColor || R.primaryColor || Ee?.[0] || "#3B82F6", ke = {
15047
15064
  small: 50,
15048
15065
  medium: 64,
15049
15066
  large: 80
15050
- }, je = Ae[L.orbSize] || Ae.small, Me = L.position || "bottom-right", R = I.fallbackAgentName || "Agent", z = u_(De ?? L.chatBgColors), Ne = I.logo || I.logoUrl || null, Pe = A || "en", Fe = F.recommendations?.[Pe] || [], B = (xe.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15067
+ }, Ae = ke[R.orbSize] || ke.small, je = R.position || "bottom-right", Me = L.fallbackAgentName || "Agent", z = u_(Ee ?? R.chatBgColors), Ne = L.logo || L.logoUrl || null, Pe = A || "en", Fe = I.recommendations?.[Pe] || [], B = (be.recommendations?.[Pe] ?? Fe).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
15051
15068
  id: e.key || `qr-${t}`,
15052
15069
  label: e.label,
15053
15070
  message: e.label,
15054
15071
  text: e.label
15055
- })), V = Array.isArray(I.quickChatOptions) && I.quickChatOptions.length > 0 ? I.quickChatOptions : B, Ie = I.hideWatermark === !0 ? !1 : I.showPoweredBy !== !1, Le = I.headerBgColor || null, Re = L.bottomPosition == null ? "1.5rem" : `${L.bottomPosition}px`, ze = I.privacyPolicyUrl || null, Be = I.chatbotEnabled !== !1 && L.chatbotEnabled !== !1, [Ve, He] = m(() => typeof window < "u" ? window.location.pathname : "/");
15072
+ })), V = Array.isArray(L.quickChatOptions) && L.quickChatOptions.length > 0 ? L.quickChatOptions : B, Ie = L.hideWatermark === !0 ? !1 : L.showPoweredBy !== !1, Le = L.headerBgColor || null, Re = R.bottomPosition == null ? "1.5rem" : `${R.bottomPosition}px`, ze = L.privacyPolicyUrl || null, Be = L.chatbotEnabled !== !1 && R.chatbotEnabled !== !1, [Ve, He] = m(() => typeof window < "u" ? window.location.pathname : "/");
15056
15073
  c(() => {
15057
15074
  if (typeof window > "u") return;
15058
15075
  let e = () => He(window.location.pathname), t = window.history.pushState.bind(window.history);
@@ -15064,24 +15081,24 @@ function C_() {
15064
15081
  }, []);
15065
15082
  let Ue = (() => {
15066
15083
  let e = {
15067
- ...F.pageVisibility || {},
15068
- ...xe.pageVisibility || {}
15084
+ ...I.pageVisibility || {},
15085
+ ...be.pageVisibility || {}
15069
15086
  };
15070
15087
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
15071
- })(), We = Ue.length === 0 || Ue.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ve.startsWith(e.slice(0, -1)) : Ve.replace(/\/$/, "") === e.replace(/\/$/, "")), Ge = F.greetings?.[A] || xe.greetings?.[A] || I.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ke = {
15072
- entryPrompt: I.entryPrompt || "Do you want to explore in a new way?",
15073
- yesLabel: I.yesLabel || "Yes",
15074
- laterLabel: I.laterLabel || "Later",
15075
- connectionTitle: I.connectionTitle || "How would you like to connect?",
15076
- connectionSubtitle: I.connectionSubtitle || "",
15077
- voiceLabel: I.voiceLabel || "Voice",
15078
- textLabel: I.textLabel || "Text",
15079
- chatTitle: I.headerName || "Chat with FlowEngage",
15080
- hasCustomTitle: !!(I.headerName && String(I.headerName).trim()),
15088
+ })(), We = Ue.length === 0 || Ue.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ve.startsWith(e.slice(0, -1)) : Ve.replace(/\/$/, "") === e.replace(/\/$/, "")), Ge = I.greetings?.[A] || be.greetings?.[A] || L.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ke = {
15089
+ entryPrompt: L.entryPrompt || "Do you want to explore in a new way?",
15090
+ yesLabel: L.yesLabel || "Yes",
15091
+ laterLabel: L.laterLabel || "Later",
15092
+ connectionTitle: L.connectionTitle || "How would you like to connect?",
15093
+ connectionSubtitle: L.connectionSubtitle || "",
15094
+ voiceLabel: L.voiceLabel || "Voice",
15095
+ textLabel: L.textLabel || "Text",
15096
+ chatTitle: L.headerName || "Chat with FlowEngage",
15097
+ hasCustomTitle: !!(L.headerName && String(L.headerName).trim()),
15081
15098
  introGreeting: Ge,
15082
- inputPlaceholder: I.inputPlaceholder || "Type your message",
15083
- analysingLabel: I.analysingLabel || "analysing..."
15084
- }, qe = xe.elevenLabsAgentId || t?.elevenLabsAgentId || null, Je = t?.siteId || n?.siteId || null, H = t?.apiBaseUrl || "";
15099
+ inputPlaceholder: L.inputPlaceholder || "Type your message",
15100
+ analysingLabel: L.analysingLabel || "analysing..."
15101
+ }, qe = be.elevenLabsAgentId || t?.elevenLabsAgentId || null, Je = t?.siteId || n?.siteId || null, H = t?.apiBaseUrl || "";
15085
15102
  c(() => {
15086
15103
  Kn(t?.siteType || null);
15087
15104
  }, [t?.siteType]);
@@ -15092,10 +15109,10 @@ function C_() {
15092
15109
  ]), Ye = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Xe = r.some((e) => e.sender === "user"), Ze = f(() => {
15093
15110
  let e = r.findIndex((e) => e.sender === "user");
15094
15111
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
15095
- }, [r]), Qe = !!(xe._dashboardLivePreview || F._dashboardLivePreview), [W, $e] = m(() => Qe ? "text_chat" : "entry_prompt"), [et, tt] = m(""), [nt, G] = m(null), [rt, it] = m(h || ""), [at, ot] = m(""), [st, ct] = m(!1), [lt, ut] = m(0), [dt, ft] = m(null), [pt, mt] = m(null), [ht, gt] = m(""), [_t, vt] = m(!1), [yt, bt] = m(!1), [xt, St] = m(!1), Ct = p(null), wt = p(!1), Tt = !h && Xe && Ze && W !== "voice_mode";
15112
+ }, [r]), Qe = !!(be._dashboardLivePreview || I._dashboardLivePreview), [W, $e] = m(() => Qe ? "text_chat" : "entry_prompt"), [et, tt] = m(""), [nt, G] = m(null), [rt, it] = m(h || ""), [at, ot] = m(""), [st, ct] = m(!1), [lt, ut] = m(0), [dt, ft] = m(null), [pt, mt] = m(null), [ht, gt] = m(""), [_t, vt] = m(!1), [yt, bt] = m(!1), [xt, St] = m(!1), Ct = p(null), wt = p(!1), Tt = !h && Xe && Ze && W !== "voice_mode";
15096
15113
  d(() => {
15097
15114
  if (e !== "ready" || wt.current) return;
15098
- if (wt.current = !0, !Ee) {
15115
+ if (wt.current = !0, !Te) {
15099
15116
  $e("minimized_orb");
15100
15117
  return;
15101
15118
  }
@@ -15103,12 +15120,12 @@ function C_() {
15103
15120
  try {
15104
15121
  t = vr().shouldResumeVoice;
15105
15122
  } catch {}
15106
- let n = Te(), r = Je ? Se(Je) : null, i = n || !!r?.transcript;
15123
+ let n = we(), r = Je ? xe(Je) : null, i = n || !!r?.transcript;
15107
15124
  if (t) {
15108
- re?.({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15125
+ re?.({ notifyChatInitiated: !0 }), N?.(!0), $e("voice_mode");
15109
15126
  return;
15110
15127
  }
15111
- if (Oe()) {
15128
+ if (De()) {
15112
15129
  re?.({ notifyChatInitiated: !1 }), $e("text_chat");
15113
15130
  return;
15114
15131
  }
@@ -15117,13 +15134,13 @@ function C_() {
15117
15134
  $e("minimized_orb");
15118
15135
  return;
15119
15136
  }
15120
- re?.({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15137
+ re?.({ notifyChatInitiated: !0 }), N?.(!0), $e("voice_mode");
15121
15138
  return;
15122
15139
  }
15123
15140
  if (Je) try {
15124
- Ce(Je);
15141
+ Se(Je);
15125
15142
  } catch {}
15126
- if (oe(Je)) {
15143
+ if (ae(Je)) {
15127
15144
  $e("minimized_orb");
15128
15145
  return;
15129
15146
  }
@@ -15181,7 +15198,7 @@ function C_() {
15181
15198
  hasIncomingCall: !!w?.callId,
15182
15199
  activeCallId: T,
15183
15200
  callConnectionState: E
15184
- }), Ct.current = e, W === "voice_mode" && ae?.(!1), re?.(), At());
15201
+ }), Ct.current = e, W === "voice_mode" && N?.(!1), re?.(), At());
15185
15202
  }
15186
15203
  }, [
15187
15204
  T,
@@ -15190,7 +15207,7 @@ function C_() {
15190
15207
  w?.callId,
15191
15208
  i,
15192
15209
  re,
15193
- ae,
15210
+ N,
15194
15211
  W
15195
15212
  ]), c(() => {
15196
15213
  !w && !T && W === "call_screen" && $e("text_chat");
@@ -15202,16 +15219,16 @@ function C_() {
15202
15219
  !T && yt && bt(!1);
15203
15220
  }, [T, yt]), c(() => {
15204
15221
  if (!s || C) {
15205
- ge?.(""), he?.();
15222
+ he?.(""), me?.();
15206
15223
  return;
15207
15224
  }
15208
15225
  if (!et.trim() || pt) {
15209
- ge?.("");
15210
- let e = window.setTimeout(() => he?.(), 100);
15226
+ he?.("");
15227
+ let e = window.setTimeout(() => me?.(), 100);
15211
15228
  return () => window.clearTimeout(e);
15212
15229
  }
15213
- me?.();
15214
- let e = window.setTimeout(() => ge?.(et), 120), t = window.setTimeout(() => he?.(), 1200);
15230
+ pe?.();
15231
+ let e = window.setTimeout(() => he?.(et), 120), t = window.setTimeout(() => me?.(), 1200);
15215
15232
  return () => {
15216
15233
  window.clearTimeout(e), window.clearTimeout(t);
15217
15234
  };
@@ -15220,9 +15237,9 @@ function C_() {
15220
15237
  pt,
15221
15238
  s,
15222
15239
  C,
15240
+ pe,
15223
15241
  me,
15224
- he,
15225
- ge
15242
+ he
15226
15243
  ]);
15227
15244
  let Mt = (e) => e ? {
15228
15245
  replyTo: e.messageId || e.id || null,
@@ -15264,8 +15281,8 @@ function C_() {
15264
15281
  let n = et.trim();
15265
15282
  tt(""), G(null), await j(n, "", t);
15266
15283
  }, Pt = o(() => {
15267
- r.length !== 0 && ce?.();
15268
- }, [r.length, ce]), Ft = (e) => {
15284
+ r.length !== 0 && se?.();
15285
+ }, [r.length, se]), Ft = (e) => {
15269
15286
  let t = Math.floor(e / 60);
15270
15287
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
15271
15288
  }, It = o(async (e) => {
@@ -15296,14 +15313,14 @@ function C_() {
15296
15313
  height: "min(640px, calc(100vh - 120px))",
15297
15314
  borderRadius: "22px",
15298
15315
  overflow: "hidden",
15299
- ...Me === "bottom-left" ? {
15316
+ ...je === "bottom-left" ? {
15300
15317
  left: "1.5rem",
15301
15318
  bottom: Re
15302
15319
  } : {
15303
15320
  right: "1.5rem",
15304
15321
  bottom: Re
15305
15322
  }
15306
- } : Me === "bottom-left" ? {
15323
+ } : je === "bottom-left" ? {
15307
15324
  left: "1.5rem",
15308
15325
  bottom: Re
15309
15326
  } : {
@@ -15321,13 +15338,13 @@ function C_() {
15321
15338
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
15322
15339
  }
15323
15340
  } catch {}
15324
- re({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15341
+ re({ notifyChatInitiated: !0 }), N?.(!0), $e("voice_mode");
15325
15342
  }, Vt = () => {
15326
- re({ notifyChatInitiated: !0 }), ae?.(!1), $e("text_chat");
15343
+ re({ notifyChatInitiated: !0 }), N?.(!1), $e("text_chat");
15327
15344
  }, Ht = () => {
15328
- ae?.(!1), Rt();
15345
+ N?.(!1), Rt();
15329
15346
  };
15330
- return e !== "ready" || !Be || we.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
15347
+ return e !== "ready" || !Be || Ce.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
15331
15348
  className: "flowengage-widget-root",
15332
15349
  style: {
15333
15350
  position: "fixed",
@@ -15339,13 +15356,13 @@ function C_() {
15339
15356
  children: [
15340
15357
  W === "entry_prompt" && /* @__PURE__ */ g(__, {
15341
15358
  copy: Ke,
15342
- orbColors: De,
15343
- primaryColor: ke,
15359
+ orbColors: Ee,
15360
+ primaryColor: Oe,
15344
15361
  onYes: () => {
15345
- se(Je), Bt();
15362
+ oe(Je), Bt();
15346
15363
  },
15347
15364
  onLater: () => {
15348
- se(Je), Rt();
15365
+ oe(Je), Rt();
15349
15366
  },
15350
15367
  isMobile: Et,
15351
15368
  isClosing: xt
@@ -15369,7 +15386,7 @@ function C_() {
15369
15386
  transformOrigin: "bottom right",
15370
15387
  display: "inline-flex",
15371
15388
  flexDirection: "column",
15372
- alignItems: Me === "bottom-left" ? "flex-start" : "flex-end",
15389
+ alignItems: je === "bottom-left" ? "flex-start" : "flex-end",
15373
15390
  gap: "10px"
15374
15391
  },
15375
15392
  children: [T && /* @__PURE__ */ _("button", {
@@ -15421,15 +15438,15 @@ function C_() {
15421
15438
  })]
15422
15439
  })]
15423
15440
  }), /* @__PURE__ */ g(g_, {
15424
- size: je,
15425
- orbColors: De,
15426
- onClick: T ? At : Ee ? zt : Vt
15441
+ size: Ae,
15442
+ orbColors: Ee,
15443
+ onClick: T ? At : Te ? zt : Vt
15427
15444
  })]
15428
15445
  }),
15429
15446
  W === "connection_modal" && /* @__PURE__ */ g(v_, {
15430
15447
  copy: Ke,
15431
- orbColors: De,
15432
- primaryColor: ke,
15448
+ orbColors: Ee,
15449
+ primaryColor: Oe,
15433
15450
  onVoice: Bt,
15434
15451
  onText: Vt,
15435
15452
  onClose: Rt,
@@ -15437,7 +15454,7 @@ function C_() {
15437
15454
  isClosing: xt
15438
15455
  }),
15439
15456
  W === "voice_mode" && /* @__PURE__ */ g(y_, {
15440
- orbColors: De,
15457
+ orbColors: Ee,
15441
15458
  onEnterChat: Vt,
15442
15459
  onEndChat: Ht,
15443
15460
  agentId: qe,
@@ -15446,16 +15463,16 @@ function C_() {
15446
15463
  chatId: ee,
15447
15464
  historyRef: te,
15448
15465
  onMessageSync: ne,
15449
- voiceEndCounter: be,
15466
+ voiceEndCounter: ye,
15450
15467
  websiteName: t?.websiteName,
15451
- voiceFirstMessage: F.voiceFirstMessage || null,
15468
+ voiceFirstMessage: I.voiceFirstMessage || null,
15452
15469
  captureVisitorEmail: ie,
15453
15470
  emailRequired: !h,
15454
- emailCaptureEnabled: we.emailCapture !== !1 && I.disableEmailCapture !== !0,
15455
- listeningLabel: I.voiceListeningLabel || "Listening...",
15456
- thinkingLabel: I.voiceThinkingLabel || "Thinking...",
15457
- enterChatModeLabel: I.voiceEnterChatLabel || "Enter Chat Mode",
15458
- endConversationLabel: I.voiceEndConversationLabel || "End Conversation"
15471
+ emailCaptureEnabled: Ce.emailCapture !== !1 && L.disableEmailCapture !== !0,
15472
+ listeningLabel: L.voiceListeningLabel || "Listening...",
15473
+ thinkingLabel: L.voiceThinkingLabel || "Thinking...",
15474
+ enterChatModeLabel: L.voiceEnterChatLabel || "Enter Chat Mode",
15475
+ endConversationLabel: L.voiceEndConversationLabel || "End Conversation"
15459
15476
  }, "voice"),
15460
15477
  W === "call_screen" && /* @__PURE__ */ g(hg, {
15461
15478
  incomingCall: w,
@@ -15465,22 +15482,22 @@ function C_() {
15465
15482
  isCallMuted: O,
15466
15483
  agentName: U,
15467
15484
  agentHeadshot: Ye,
15468
- fallbackAgentName: R,
15469
- acceptCall: le,
15470
- rejectCall: ue,
15471
- endWebRTCCall: de,
15472
- toggleCallMute: fe,
15485
+ fallbackAgentName: Me,
15486
+ acceptCall: ce,
15487
+ rejectCall: le,
15488
+ endWebRTCCall: ue,
15489
+ toggleCallMute: de,
15473
15490
  formatCallDuration: Ft,
15474
15491
  onMinimize: jt,
15475
- primaryColor: ke,
15476
- orbColors: De,
15492
+ primaryColor: Oe,
15493
+ orbColors: Ee,
15477
15494
  chatHistory: r
15478
15495
  }),
15479
15496
  W === "text_chat" && /* @__PURE__ */ g(S_, {
15480
15497
  isClosing: xt,
15481
15498
  copy: Ke,
15482
- orbColors: De,
15483
- primaryColor: ke,
15499
+ orbColors: Ee,
15500
+ primaryColor: Oe,
15484
15501
  chatBgGradient: z,
15485
15502
  logo: Ne,
15486
15503
  quickChatOptions: V,
@@ -15492,7 +15509,7 @@ function C_() {
15492
15509
  activeScreen: a,
15493
15510
  agentName: U,
15494
15511
  agentHeadshot: Ye,
15495
- fallbackAgentName: R,
15512
+ fallbackAgentName: Me,
15496
15513
  input: et,
15497
15514
  setInput: tt,
15498
15515
  onSubmit: Nt,
@@ -15515,16 +15532,16 @@ function C_() {
15515
15532
  webRTCError: k,
15516
15533
  micError: dt,
15517
15534
  setMicError: ft,
15518
- dismissCallError: pe,
15535
+ dismissCallError: fe,
15519
15536
  activeCallId: T,
15520
15537
  isCallMuted: O,
15521
- toggleCallMute: fe,
15522
- endWebRTCCall: de,
15538
+ toggleCallMute: de,
15539
+ endWebRTCCall: ue,
15523
15540
  formatCallDuration: Ft,
15524
15541
  callDurationSeconds: lt,
15525
15542
  onCollapse: Rt,
15526
15543
  onStartVoice: Bt,
15527
- voiceEnabled: Ee,
15544
+ voiceEnabled: Te,
15528
15545
  onNewChat: Pt,
15529
15546
  onMinimize: jt,
15530
15547
  onExpand: At,
@@ -15532,9 +15549,9 @@ function C_() {
15532
15549
  showPoweredBy: Ie,
15533
15550
  privacyPolicyUrl: ze,
15534
15551
  headerBgColor: Le,
15535
- getVisitorChatHistory: P,
15536
- resumeChat: _e,
15537
- isSessionRestoring: ve
15552
+ getVisitorChatHistory: ge,
15553
+ resumeChat: F,
15554
+ isSessionRestoring: _e
15538
15555
  }),
15539
15556
  /* @__PURE__ */ g("style", { children: "\n /* Force any SVG (or img) inside LogoSlot to fill the container height\n regardless of whether the component forwards its style prop. */\n .fe-logo-slot svg,\n .fe-logo-slot img { height: 100%; width: auto; display: block; }\n\n @keyframes fe-orb-breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.04)} }\n @keyframes fe-orb-breathe-subtle { 0%,100%{transform:scale(1)} 50%{transform:scale(1.025)} }\n @keyframes fe-orb-pulse { 0%{transform:scale(1);opacity:.65} 50%{transform:scale(1.28);opacity:.1} 100%{transform:scale(1);opacity:.65} }\n @keyframes fe-orb-glow { from{opacity:.35} to{opacity:.75} }\n @keyframes fe-orb-fade-in { from{opacity:0} to{opacity:1} }\n @keyframes fe-orb-slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }\n @keyframes fe-orb-slide-down { from{opacity:1;transform:translateY(0)} to{opacity:0;transform:translateY(24px)} }\n @keyframes fe-orb-bar-0 { from{height:6px} to{height:18px} }\n @keyframes fe-orb-bar-1 { from{height:10px} to{height:22px} }\n @keyframes fe-orb-bar-2 { from{height:14px} to{height:26px} }\n @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }\n @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }\n @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }\n " })
15540
15557
  ]