@flowengage/react-chatbot 8.0.81 → 8.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,38 +42,38 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
42
42
  if (A) try {
43
43
  window.localStorage.removeItem(k.chatId);
44
44
  } catch {}
45
- }, se = () => A ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", j = (e) => e ? `flowengage.entrySeen.${e}` : null, ce = (e) => {
45
+ }, j = () => A ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", M = (e) => e ? `flowengage.entrySeen.${e}` : null, se = (e) => {
46
46
  if (!A || !e) return !1;
47
47
  try {
48
- let t = j(e);
48
+ let t = M(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
- }, le = (e) => {
53
+ }, ce = (e) => {
54
54
  if (!(!A || !e)) try {
55
- let t = j(e);
55
+ let t = M(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
- }, M = (e) => e ? `flowengage.persistedChatId.${e}` : null, ue = (e) => {
58
+ }, N = (e) => e ? `flowengage.persistedChatId.${e}` : null, le = (e) => {
59
59
  if (!A || !e) return null;
60
60
  try {
61
- let t = M(e), n = t ? window.localStorage.getItem(t) : null;
61
+ let t = N(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
- }, de = (e) => {
66
+ }, ue = (e) => {
67
67
  if (!(!A || !e)) try {
68
- let t = M(e);
68
+ let t = N(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
- }, fe = (e, t) => {
71
+ }, de = (e, t) => {
72
72
  if (!(!A || !e || !t)) try {
73
- let n = M(e);
73
+ let n = N(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
- }, pe = () => A ? {
76
+ }, fe = () => A ? {
77
77
  isOpen: !1,
78
78
  activeScreen: window.sessionStorage.getItem(k.activeScreen) || "ai",
79
79
  isHumanHandled: window.sessionStorage.getItem(k.isHumanHandled) === "true",
@@ -87,7 +87,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
87
87
  agentName: null,
88
88
  agentHeadshot: null,
89
89
  visitorEmail: ""
90
- }, me = (e) => {
90
+ }, pe = (e) => {
91
91
  A && Object.entries(e).forEach(([e, t]) => {
92
92
  let n = k[e];
93
93
  if (n) {
@@ -98,7 +98,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
98
98
  window.sessionStorage.setItem(n, String(t));
99
99
  }
100
100
  });
101
- }, he = (e) => {
101
+ }, me = (e) => {
102
102
  if (!A || !e) return "";
103
103
  let t = ie(e), n = window.localStorage.getItem(t);
104
104
  if (!n) {
@@ -106,7 +106,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
106
106
  e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(k.visitorEmail), n = e);
107
107
  }
108
108
  return n || "";
109
- }, ge = (e, t) => {
109
+ }, he = (e, t) => {
110
110
  if (!A) return;
111
111
  let n = ie(t);
112
112
  if (!n) return;
@@ -116,91 +116,91 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
116
116
  return;
117
117
  }
118
118
  window.localStorage.setItem(n, r), window.sessionStorage.removeItem(k.visitorEmail);
119
- }, _e = (e) => e ? `flowengage.visitorId.${e}` : null, N = () => `v_${Date.now().toString(36)}_${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 16) : Math.random().toString(36).slice(2, 18)}`, ve = (e) => {
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) => {
120
120
  if (!A || !e) return null;
121
121
  try {
122
- let t = _e(e), n = t ? window.localStorage.getItem(t) : null;
122
+ let t = ge(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
- }, ye = (e) => {
127
+ }, ve = (e) => {
128
128
  if (!A || !e) return null;
129
129
  try {
130
- let t = ve(e);
130
+ let t = _e(e);
131
131
  if (t) return t;
132
- let n = N(), r = _e(e);
132
+ let n = P(), r = ge(e);
133
133
  return r && window.localStorage.setItem(r, n), n;
134
134
  } catch {
135
- return N();
135
+ return P();
136
136
  }
137
- }, be = "flowengage.tabId", xe = () => {
137
+ }, ye = "flowengage.tabId", be = () => {
138
138
  if (!A) return "default";
139
139
  try {
140
- let e = window.sessionStorage.getItem(be);
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(be, e)), e;
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;
142
142
  } catch {
143
143
  return "default";
144
144
  }
145
- }, Se = (e) => e ? `flowengage.voice.transcript.${e}.${xe()}` : null, Ce = 600 * 1e3, P = (e, t, n = {}) => {
145
+ }, xe = (e) => e ? `flowengage.voice.transcript.${e}.${be()}` : null, Se = 600 * 1e3, F = (e, t, n = {}) => {
146
146
  if (!A || !e) return;
147
147
  let r = typeof t == "string" ? t.trim() : "";
148
148
  if (!r) return;
149
- let i = Number.isFinite(n.ttlMs) ? n.ttlMs : Ce, a = {
149
+ let i = Number.isFinite(n.ttlMs) ? n.ttlMs : Se, a = {
150
150
  transcript: r,
151
151
  expiresAt: Date.now() + i
152
152
  };
153
153
  try {
154
- let t = Se(e);
154
+ let t = xe(e);
155
155
  t && window.localStorage.setItem(t, JSON.stringify(a));
156
156
  } catch {}
157
- }, we = (e) => {
157
+ }, Ce = (e) => {
158
158
  if (!A || !e) return null;
159
159
  try {
160
- let t = Se(e), n = t ? window.localStorage.getItem(t) : null;
160
+ let t = xe(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
- }, Te = (e) => {
167
+ }, we = (e) => {
168
168
  if (!(!A || !e)) try {
169
- let t = Se(e);
169
+ let t = xe(e);
170
170
  t && window.localStorage.removeItem(t);
171
171
  } catch {}
172
- }, F = "flowengage.voice.pendingResume", Ee = () => {
172
+ }, I = "flowengage.voice.pendingResume", Te = () => {
173
173
  if (A) try {
174
- window.sessionStorage.setItem(F, "1");
174
+ window.sessionStorage.setItem(I, "1");
175
175
  } catch {}
176
- }, De = () => {
176
+ }, Ee = () => {
177
177
  if (!A) return !1;
178
178
  try {
179
- return window.sessionStorage.getItem(F) === "1" ? (window.sessionStorage.removeItem(F), !0) : !1;
179
+ return window.sessionStorage.getItem(I) === "1" ? (window.sessionStorage.removeItem(I), !0) : !1;
180
180
  } catch {
181
181
  return !1;
182
182
  }
183
- }, Oe = "flowengage.chat.pendingReopen", I = () => {
183
+ }, De = "flowengage.chat.pendingReopen", L = () => {
184
184
  if (A) try {
185
- window.sessionStorage.setItem(Oe, "1");
185
+ window.sessionStorage.setItem(De, "1");
186
186
  } catch {}
187
- }, ke = () => {
187
+ }, Oe = () => {
188
188
  if (!A) return !1;
189
189
  try {
190
- return window.sessionStorage.getItem(Oe) === "1" ? (window.sessionStorage.removeItem(Oe), !0) : !1;
190
+ return window.sessionStorage.getItem(De) === "1" ? (window.sessionStorage.removeItem(De), !0) : !1;
191
191
  } catch {
192
192
  return !1;
193
193
  }
194
- }, Ae = () => {
194
+ }, ke = () => {
195
195
  if (!A) return !1;
196
196
  try {
197
- return window.sessionStorage.getItem(F) === "1";
197
+ return window.sessionStorage.getItem(I) === "1";
198
198
  } catch {
199
199
  return !1;
200
200
  }
201
- }, je = (e) => e ? `flowengage.voice.navState.${e}.${xe()}` : null, L = (e, t, n, r) => {
201
+ }, Ae = (e) => e ? `flowengage.voice.navState.${e}.${be()}` : null, je = (e, t, n, r) => {
202
202
  if (!(!A || !e || !t)) try {
203
- let i = je(e);
203
+ let i = Ae(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,
@@ -211,7 +211,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
211
211
  }, Me = (e) => {
212
212
  if (!A || !e) return null;
213
213
  try {
214
- let t = je(e);
214
+ let t = Ae(e);
215
215
  if (!t) return null;
216
216
  let n = window.sessionStorage.getItem(t);
217
217
  if (!n) return null;
@@ -2817,11 +2817,11 @@ async function br(e, t = {}) {
2817
2817
  try {
2818
2818
  window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
2819
2819
  } catch {}
2820
- return n && mr(n), r || I(), window.location.assign(i.href), { navigated: !0 };
2820
+ return n && mr(n), r || L(), window.location.assign(i.href), { navigated: !0 };
2821
2821
  }
2822
2822
  return { navigated: !0 };
2823
2823
  }
2824
- return n && mr(n), r || I(), window.location.assign(i.href), { navigated: !0 };
2824
+ return n && mr(n), r || L(), window.location.assign(i.href), { navigated: !0 };
2825
2825
  } catch (t) {
2826
2826
  console.warn("[FlowEngage] shadowNavigate error:", t), n && mr(n);
2827
2827
  try {
@@ -2919,7 +2919,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2919
2919
  message: "Looks like you're already on this page!",
2920
2920
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2921
2921
  }]);
2922
- }, []), [T, D] = m(pe().isOpen), [ee, O] = m(pe().activeScreen), [k, A] = m(pe().isHumanHandled), [ie, j] = m(pe().agentName), [ce, le] = m(pe().agentHeadshot), [M, _e] = m(() => he(i?.siteId)), [N, ve] = m(!1), [be, xe] = m(!1), [Se, Ce] = m("idle"), [P, we] = m(!1), [Te, F] = m(!1), [De, Oe] = m(""), [I, ke] = m(!1), [Ae, je] = m(0), [L, Me] = m(0), [R, Ne] = m(!1), [z, Le] = m(null), [Re, ze] = m(null), [Be, Ve] = m("idle"), [He, Ue] = m(null), [We, Ge] = m(!1), [Ke, qe] = m(""), [Je, Ye] = m(!1), B = p(null), V = p(null), Xe = p(""), Ze = p(!1), Qe = p(null), $e = p(null), et = p(null), H = p(null), U = p(null), tt = p(null), nt = p(null), rt = p(!1), W = p({
2922
+ }, []), [T, D] = m(fe().isOpen), [ee, O] = m(fe().activeScreen), [k, A] = m(fe().isHumanHandled), [ie, M] = m(fe().agentName), [se, ce] = m(fe().agentHeadshot), [N, ge] = m(() => me(i?.siteId)), [P, _e] = m(!1), [ye, be] = m(!1), [xe, Se] = m("idle"), [F, Ce] = m(!1), [we, I] = m(!1), [Ee, De] = m(""), [L, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [R, Ne] = m(!1), [z, Le] = m(null), [Re, ze] = m(null), [Be, Ve] = m("idle"), [He, Ue] = m(null), [We, Ge] = m(!1), [Ke, qe] = m(""), [Je, Ye] = m(!1), B = p(null), V = p(null), Xe = p(""), Ze = p(!1), Qe = p(null), $e = p(null), et = p(null), H = p(null), U = p(null), tt = p(null), nt = p(null), rt = p(!1), W = p({
2923
2923
  url: null,
2924
2924
  at: 0
2925
2925
  }), it = o((e, t) => {
@@ -2940,7 +2940,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2940
2940
  cleanup: () => {}
2941
2941
  }), xt = o((e = {}) => {
2942
2942
  let t = !!e.is_human_handled;
2943
- return A(t), t ? (O("agent"), e.agent_info?.name && j(e.agent_info.name), e.agent_info?.headshot && le(e.agent_info.headshot), t) : (O("ai"), t);
2943
+ return A(t), t ? (O("agent"), e.agent_info?.name && M(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (O("ai"), t);
2944
2944
  }, []), St = f(() => {
2945
2945
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
2946
2946
  return Number.isFinite(t) && t > 0 ? t : ne;
@@ -2950,8 +2950,8 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2950
2950
  }, [z]), c(() => {
2951
2951
  ht.current = ie;
2952
2952
  }, [ie]), c(() => {
2953
- vt.current = I;
2954
- }, [I]), c(() => {
2953
+ vt.current = L;
2954
+ }, [L]), c(() => {
2955
2955
  yt.current = i;
2956
2956
  }, [i]);
2957
2957
  let Ct = () => {
@@ -2960,17 +2960,17 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2960
2960
  st.current &&= (window.clearTimeout(st.current), null);
2961
2961
  }, []), Tt = (e) => {
2962
2962
  let t = typeof e == "string" ? e.trim().toLowerCase() : "";
2963
- return _e(t), ge(t, i?.siteId), t;
2963
+ return ge(t), he(t, i?.siteId), t;
2964
2964
  };
2965
2965
  c(() => {
2966
2966
  let e = i?.siteId;
2967
2967
  if (!e) return;
2968
- let t = he(e);
2968
+ let t = me(e);
2969
2969
  if (t) {
2970
- _e(t);
2970
+ ge(t);
2971
2971
  return;
2972
2972
  }
2973
- _e((t) => (t && ge(t, e), t));
2973
+ ge((t) => (t && he(t, e), t));
2974
2974
  }, [i?.siteId]);
2975
2975
  let Et = (e = "unspecified") => {
2976
2976
  let t = G.current || tt.current?.callId, n = mt.current, r = dt.current;
@@ -3100,19 +3100,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3100
3100
  });
3101
3101
  };
3102
3102
  c(() => {
3103
- me({
3103
+ pe({
3104
3104
  isOpen: T,
3105
3105
  activeScreen: ee,
3106
3106
  isHumanHandled: k,
3107
3107
  agentName: ie,
3108
- agentHeadshot: ce
3108
+ agentHeadshot: se
3109
3109
  });
3110
3110
  }, [
3111
3111
  T,
3112
3112
  ee,
3113
3113
  k,
3114
3114
  ie,
3115
- ce
3115
+ se
3116
3116
  ]), c(() => {
3117
3117
  let e = !0;
3118
3118
  return (async () => {
@@ -3120,7 +3120,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3120
3120
  try {
3121
3121
  let t = E(i), n = await Fe(t);
3122
3122
  if (!e) return;
3123
- let a = t.siteId, o = ue(a), s = ye(a), c = "";
3123
+ let a = t.siteId, o = le(a), s = ve(a), c = "";
3124
3124
  try {
3125
3125
  let e = Ze.current, r = Qe.current;
3126
3126
  if (Ze.current = !1, Qe.current = null, c = (await Pe({
@@ -3132,9 +3132,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3132
3132
  resumeChatId: r,
3133
3133
  visitorId: s
3134
3134
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3135
- oe(), fe(a, c);
3135
+ oe(), de(a, c);
3136
3136
  } catch (e) {
3137
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || se(), fe(a, c);
3137
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || j(), de(a, c);
3138
3138
  }
3139
3139
  Xe.current = c;
3140
3140
  let l = Ie({
@@ -3154,23 +3154,23 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3154
3154
  siteId: t.siteId
3155
3155
  });
3156
3156
  B.current = f, f.on("connect", async () => {
3157
- Ce("connected");
3157
+ Se("connected");
3158
3158
  let e = Xe.current;
3159
3159
  if (e && V.current) try {
3160
3160
  xt(await V.current.checkHumanHandled(e));
3161
3161
  } catch {}
3162
3162
  }), f.on("disconnect", () => {
3163
- Ce("disconnected");
3163
+ Se("disconnected");
3164
3164
  }), f.on("aiTyping", () => {
3165
- xe(!0);
3165
+ be(!0);
3166
3166
  }), f.on("ai:typing", () => {
3167
- xe(!0);
3167
+ be(!0);
3168
3168
  }), f.on("messageReceived", (e) => {
3169
3169
  let t = e.message || e, n = {
3170
3170
  ...t,
3171
3171
  message: Tr(t.message)
3172
3172
  };
3173
- xe(!1), ve(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3173
+ be(!1), _e(!1), !(n.type === "call_recording" || typeof n.message == "string" && n.message.includes("AI chat recording")) && S((e) => [...e.filter((e) => !e.isPending), {
3174
3174
  ...n,
3175
3175
  isPending: !1,
3176
3176
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3188,7 +3188,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3188
3188
  ...t,
3189
3189
  message: Tr(t.message)
3190
3190
  };
3191
- xe(!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, {
3191
+ be(!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") && _e(!1), S((e) => n.sender === "bot" || n.sender === "ai" ? [...e, {
3192
3192
  ...n,
3193
3193
  isPending: !1,
3194
3194
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
@@ -3200,11 +3200,11 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3200
3200
  ...n,
3201
3201
  isPending: !1,
3202
3202
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
3203
- }]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"), j(Ar([
3203
+ }]), (n.sender === "agent" || n.agent_name) && (A(!0), O("agent"), M(Ar([
3204
3204
  n.agent_name,
3205
3205
  n.agentName,
3206
3206
  n.metadata?.agentName
3207
- ], d)), n.sender_headshot && le(n.sender_headshot), D(!0), je((e) => e + 1)));
3207
+ ], d)), n.sender_headshot && ce(n.sender_headshot), D(!0), Ae((e) => e + 1)));
3208
3208
  });
3209
3209
  let p = (e = {}) => {
3210
3210
  let t = Ar([
@@ -3213,7 +3213,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3213
3213
  e.agent_name,
3214
3214
  ht.current
3215
3215
  ], d);
3216
- A(!0), O("agent"), j(t), le(e.agent?.headshot || null), D(!0), je((e) => e + 1), S((e) => jr(e, {
3216
+ A(!0), O("agent"), M(t), ce(e.agent?.headshot || null), D(!0), Ae((e) => e + 1), S((e) => jr(e, {
3217
3217
  id: `agent-joined-${Date.now()}`,
3218
3218
  sender: "system",
3219
3219
  message: `${t} has joined the chat.`,
@@ -3247,15 +3247,15 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3247
3247
  }]);
3248
3248
  }), f.on("chat:history_update", (e) => {
3249
3249
  let t = Er(e.chat_history || []);
3250
- S(t), t.length === 0 && (Ne(!1), A(!1), O("ai"), xe(!1), ve(!1));
3250
+ S(t), t.length === 0 && (Ne(!1), A(!1), O("ai"), be(!1), _e(!1));
3251
3251
  }), f.on("conversation:reset", () => {
3252
- S([]), Ne(!1), A(!1), O("ai"), xe(!1), ve(!1);
3252
+ S([]), Ne(!1), A(!1), O("ai"), be(!1), _e(!1);
3253
3253
  }), f.on("voice:end_session", (e = {}) => {
3254
- console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Me((e) => e + 1), D(!0), je((e) => e + 1);
3254
+ console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Me((e) => e + 1), D(!0), Ae((e) => e + 1);
3255
3255
  }), f.on("typing:start", (e) => {
3256
- e.sender === "agent" && ve(!0);
3256
+ e.sender === "agent" && _e(!0);
3257
3257
  }), f.on("typing:stop", (e) => {
3258
- e.sender === "agent" && ve(!1);
3258
+ e.sender === "agent" && _e(!1);
3259
3259
  }), f.on("call:incoming", (e = {}) => {
3260
3260
  let t = Ar([
3261
3261
  e.agentName,
@@ -3268,7 +3268,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3268
3268
  from: e.from || "owner",
3269
3269
  agentId: e.agentId || null,
3270
3270
  agentName: t
3271
- }), j((e) => Ar([t, e], "Agent")), Ve("incoming"), Ue(null), D(!0);
3271
+ }), M((e) => Ar([t, e], "Agent")), Ve("incoming"), Ue(null), D(!0);
3272
3272
  }), f.on("call:offer", async (e = {}) => {
3273
3273
  tt.current = e;
3274
3274
  try {
@@ -3361,11 +3361,11 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3361
3361
  r,
3362
3362
  a
3363
3363
  ]), c(() => () => {
3364
- if (I && !_t.current && gt.current.length > 0) {
3364
+ if (L && !_t.current && gt.current.length > 0) {
3365
3365
  let e = Xe.current, t = gt.current, n = V.current;
3366
3366
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), _t.current = !0);
3367
3367
  }
3368
- }, [I, _]);
3368
+ }, [L, _]);
3369
3369
  let jt = p(null);
3370
3370
  c(() => {
3371
3371
  let e = V.current;
@@ -3620,18 +3620,18 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3620
3620
  chatId: y,
3621
3621
  content: e,
3622
3622
  sender: "user",
3623
- email: M || void 0,
3623
+ email: N || void 0,
3624
3624
  type: i?.type || "text",
3625
3625
  metadata: i?.metadata || {},
3626
3626
  ...n || {}
3627
3627
  });
3628
3628
  return;
3629
3629
  }
3630
- we(!0);
3630
+ Ce(!0);
3631
3631
  try {
3632
3632
  let o = await V.current.sendAiMessage(y, e, r, t, {
3633
3633
  ...n || {},
3634
- ...M ? { email: M } : {}
3634
+ ...N ? { email: N } : {}
3635
3635
  }, {
3636
3636
  ...i,
3637
3637
  currentPageUrl: typeof window < "u" ? window.location.href : void 0,
@@ -3706,10 +3706,10 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3706
3706
  });
3707
3707
  }
3708
3708
  }
3709
- S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"), xe(!1), we(!1), await V.current.updateChatStatus(y, "messageSent");
3709
+ S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"), be(!1), Ce(!1), await V.current.updateChatStatus(y, "messageSent");
3710
3710
  } catch (e) {
3711
- S((e) => e.filter((e) => e.id !== u)), xe(!1), we(!1), e.status === 429 ? (F(!0), Oe(e.message), window.setTimeout(() => {
3712
- F(!1), Oe("");
3711
+ S((e) => e.filter((e) => e.id !== u)), be(!1), Ce(!1), e.status === 429 ? (I(!0), De(e.message), window.setTimeout(() => {
3712
+ I(!1), De("");
3713
3713
  }, te)) : h(e);
3714
3714
  }
3715
3715
  }, Wt = async (e) => {
@@ -3721,12 +3721,12 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3721
3721
  let t = e ? "voice" : "text";
3722
3722
  await V.current.setChatMode(y, t);
3723
3723
  } catch {}
3724
- ke(e), e && (_t.current = !1);
3724
+ Oe(e), e && (_t.current = !1);
3725
3725
  }
3726
3726
  }, Kt = async (e) => {
3727
3727
  if (_t.current) return;
3728
3728
  if (_t.current = !0, !V.current || !y || !e?.length) {
3729
- ke(!1);
3729
+ Oe(!1);
3730
3730
  return;
3731
3731
  }
3732
3732
  let t = () => {
@@ -3750,11 +3750,11 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3750
3750
  } catch {
3751
3751
  t();
3752
3752
  } finally {
3753
- ke(!1);
3753
+ Oe(!1);
3754
3754
  }
3755
3755
  }, qt = async () => {
3756
3756
  if (!(!V.current || !y)) {
3757
- I && !_t.current && gt.current.length > 0 && await Kt(gt.current);
3757
+ L && !_t.current && gt.current.length > 0 && await Kt(gt.current);
3758
3758
  try {
3759
3759
  await V.current.endConversation(y);
3760
3760
  } catch {
@@ -3788,7 +3788,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3788
3788
  let e = () => {
3789
3789
  let e = Xe.current, t = V.current;
3790
3790
  if (!t || !e) return;
3791
- if (vt.current && gt.current.length > 0 && Ee(), !_t.current && gt.current.length > 0 && (t.beaconSyncVoice(e, gt.current) || t.syncVoice(e, gt.current).catch(() => {}), _t.current = !0), G.current) {
3791
+ if (vt.current && gt.current.length > 0 && Te(), !_t.current && gt.current.length > 0 && (t.beaconSyncVoice(e, gt.current) || t.syncVoice(e, gt.current).catch(() => {}), _t.current = !0), G.current) {
3792
3792
  t.beaconEndWebRTCCall(G.current, e);
3793
3793
  return;
3794
3794
  }
@@ -3801,9 +3801,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3801
3801
  }, []);
3802
3802
  let Jt = o(() => {
3803
3803
  let e = i?.siteId;
3804
- de(e), Ze.current = !0, Qe.current = null, B.current?.disconnect(), S([]), b(""), Xe.current = "", Ne(!1), A(!1), j(null), le(null), Ye(!0), s((e) => e + 1);
3804
+ ue(e), Ze.current = !0, Qe.current = null, B.current?.disconnect(), S([]), b(""), Xe.current = "", Ne(!1), A(!1), M(null), ce(null), Ye(!0), s((e) => e + 1);
3805
3805
  }, [i?.siteId]), Yt = o((e) => {
3806
- i?.siteId, Ze.current = !1, Qe.current = e, B.current?.disconnect(), S([]), b(""), Xe.current = "", Ne(!1), A(!1), j(null), le(null), Ye(!0), s((e) => e + 1);
3806
+ i?.siteId, Ze.current = !1, Qe.current = e, B.current?.disconnect(), S([]), b(""), Xe.current = "", Ne(!1), A(!1), M(null), ce(null), Ye(!0), s((e) => e + 1);
3807
3807
  }, [i?.siteId]), Xt = f(() => ({
3808
3808
  status: l,
3809
3809
  error: d,
@@ -3815,19 +3815,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3815
3815
  activeScreen: ee,
3816
3816
  isHumanHandled: k,
3817
3817
  agentName: ie,
3818
- agentHeadshot: ce,
3819
- visitorEmail: M,
3820
- isAgentTyping: N,
3821
- isAiTyping: be,
3822
- connectionStatus: Se,
3823
- isLoading: P,
3824
- isVoiceMode: I,
3825
- isRateLimited: Te,
3826
- rateLimitMessage: De,
3818
+ agentHeadshot: se,
3819
+ visitorEmail: N,
3820
+ isAgentTyping: P,
3821
+ isAiTyping: ye,
3822
+ connectionStatus: xe,
3823
+ isLoading: F,
3824
+ isVoiceMode: L,
3825
+ isRateLimited: we,
3826
+ rateLimitMessage: Ee,
3827
3827
  isConversationEnded: R,
3828
3828
  isSessionRestoring: Je,
3829
- openToChatCounter: Ae,
3830
- voiceEndCounter: L,
3829
+ openToChatCounter: ke,
3830
+ voiceEndCounter: je,
3831
3831
  incomingCall: z,
3832
3832
  activeCallId: Re,
3833
3833
  callConnectionState: Be,
@@ -3876,19 +3876,19 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3876
3876
  ee,
3877
3877
  k,
3878
3878
  ie,
3879
- ce,
3880
- M,
3879
+ se,
3881
3880
  N,
3882
- be,
3883
- Se,
3884
3881
  P,
3885
- I,
3886
- Te,
3887
- De,
3882
+ ye,
3883
+ xe,
3884
+ F,
3885
+ L,
3886
+ we,
3887
+ Ee,
3888
3888
  R,
3889
3889
  Je,
3890
- Ae,
3891
- L,
3890
+ ke,
3891
+ je,
3892
3892
  z,
3893
3893
  Re,
3894
3894
  Be,
@@ -8947,61 +8947,61 @@ async function Lm(e) {
8947
8947
  }
8948
8948
  }, ee = (e, t, n) => {
8949
8949
  t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, Sm));
8950
- }, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, ae = !1, oe = Cm, se = wm, j = null, ce = !1, le = (e = !0) => {
8951
- j && clearTimeout(j);
8950
+ }, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, ae = !1, oe = Cm, j = wm, M = null, se = !1, ce = (e = !0) => {
8951
+ M && clearTimeout(M);
8952
8952
  let t = () => {
8953
8953
  if (!O) {
8954
- if (M.isPlaying()) {
8955
- j = setTimeout(t, 150);
8954
+ if (N.isPlaying()) {
8955
+ M = setTimeout(t, 150);
8956
8956
  return;
8957
8957
  }
8958
- if (j = null, ce) {
8958
+ if (M = null, se) {
8959
8959
  p?.();
8960
8960
  return;
8961
8961
  }
8962
8962
  !O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), e && d?.();
8963
8963
  }
8964
8964
  };
8965
- j = setTimeout(t, 150);
8966
- }, M = Fm(_, () => {
8965
+ M = setTimeout(t, 150);
8966
+ }, N = Fm(_, () => {
8967
8967
  ne && (ne = !1, c?.({ mode: "listening" }));
8968
- }, v), ue = _.createMediaStreamSource(g);
8969
- ue.connect(v);
8970
- let de = _.createScriptProcessor(xm, 1, 1), fe = !1, pe = 0, me = 0;
8971
- de.onaudioprocess = (e) => {
8968
+ }, v), le = _.createMediaStreamSource(g);
8969
+ le.connect(v);
8970
+ let ue = _.createScriptProcessor(xm, 1, 1), de = !1, fe = 0, pe = 0;
8971
+ ue.onaudioprocess = (e) => {
8972
8972
  if (O || C.readyState !== WebSocket.OPEN) return;
8973
8973
  let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
8974
8974
  if (k) {
8975
- te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), fe = !1, pe = 0, me = 0, n();
8975
+ te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), de = !1, fe = 0, pe = 0, n();
8976
8976
  return;
8977
8977
  }
8978
8978
  let r = Om(t);
8979
- if (M.isPlaying() || ae ? (fe = !1, pe = 0, me = 0) : r >= Tm ? (me = 0, pe += 1, !fe && pe >= Em && (fe = !0, c?.({ mode: "user-speaking" }))) : (pe = 0, fe && ++me >= Dm && (fe = !1, me = 0, c?.({
8979
+ if (N.isPlaying() || ae ? (de = !1, fe = 0, pe = 0) : r >= Tm ? (pe = 0, fe += 1, !de && fe >= Em && (de = !0, c?.({ mode: "user-speaking" }))) : (fe = 0, de && ++pe >= Dm && (de = !1, pe = 0, c?.({
8980
8980
  mode: "thinking",
8981
8981
  tentative: !0
8982
- }))), (M.isPlaying() || ae) && !ie) {
8982
+ }))), (N.isPlaying() || ae) && !ie) {
8983
8983
  if (r < oe) {
8984
8984
  A = 0, n();
8985
8985
  return;
8986
8986
  }
8987
- if (A += 1, A < se) {
8987
+ if (A += 1, A < j) {
8988
8988
  n();
8989
8989
  return;
8990
8990
  }
8991
8991
  ie = !0, A = 0;
8992
- let e = M.playedMs();
8993
- M.stop(), re = !1, ae = !1, j && !ce && (clearTimeout(j), j = null), C.send(JSON.stringify({
8992
+ let e = N.playedMs();
8993
+ N.stop(), re = !1, ae = !1, M && !se && (clearTimeout(M), M = null), C.send(JSON.stringify({
8994
8994
  type: "VisitorInterrupted",
8995
8995
  played_ms: Math.round(e)
8996
8996
  })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
8997
8997
  }
8998
8998
  C.send(km(t).buffer);
8999
- }, ue.connect(de), de.connect(_.destination);
9000
- let he = () => {
8999
+ }, le.connect(ue), ue.connect(_.destination);
9000
+ let me = () => {
9001
9001
  if (!O) {
9002
- O = !0, j &&= (clearTimeout(j), null), D(), M.stop();
9002
+ O = !0, M &&= (clearTimeout(M), null), D(), N.stop();
9003
9003
  try {
9004
- de.disconnect(), ue.disconnect();
9004
+ ue.disconnect(), le.disconnect();
9005
9005
  } catch {}
9006
9006
  if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
9007
9007
  x.onstop = () => Pm(t, n, S, b, y);
@@ -9013,7 +9013,7 @@ async function Lm(e) {
9013
9013
  } else b.length && Pm(t, n, S, b, y);
9014
9014
  _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
9015
9015
  }
9016
- }, ge = async (e) => {
9016
+ }, he = async (e) => {
9017
9017
  let t = i[e.name];
9018
9018
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
9019
9019
  let n = {};
@@ -9025,10 +9025,10 @@ async function Lm(e) {
9025
9025
  } catch (e) {
9026
9026
  return { error: e?.message || "Tool execution failed" };
9027
9027
  }
9028
- }, _e = async (e) => {
9028
+ }, ge = async (e) => {
9029
9029
  for (let t of e.functions || []) {
9030
9030
  if (!t.client_side) continue;
9031
- let e = await ge(t);
9031
+ let e = await he(t);
9032
9032
  if (O || C.readyState !== WebSocket.OPEN) return;
9033
9033
  C.send(JSON.stringify({
9034
9034
  type: "FunctionCallResponse",
@@ -9037,10 +9037,10 @@ async function Lm(e) {
9037
9037
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
9038
9038
  }));
9039
9039
  }
9040
- }, N = (e) => {
9040
+ }, P = (e) => {
9041
9041
  switch (e.type) {
9042
9042
  case "Welcome":
9043
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (oe = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (se = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9043
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (oe = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (j = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9044
9044
  break;
9045
9045
  case "ConversationText": {
9046
9046
  let t = String(e.content || "");
@@ -9059,22 +9059,22 @@ async function Lm(e) {
9059
9059
  break;
9060
9060
  }
9061
9061
  case "UserStartedSpeaking":
9062
- D(), M.stop(), ae = !1, re = !1, ne = !1, j && !ce && (clearTimeout(j), j = null), c?.({ mode: "listening" });
9062
+ D(), N.stop(), ae = !1, re = !1, ne = !1, M && !se && (clearTimeout(M), M = null), c?.({ mode: "listening" });
9063
9063
  break;
9064
9064
  case "AgentStartedSpeaking":
9065
9065
  re = !0, ne = !0, ie = !1, A = 0, c?.({ mode: "speaking" });
9066
9066
  break;
9067
9067
  case "AgentAudioDone":
9068
- ae = !1, D(), le(e.turnComplete !== !1), M.isPlaying() || (ne = !1, c?.({ mode: "listening" }));
9068
+ ae = !1, D(), ce(e.turnComplete !== !1), N.isPlaying() || (ne = !1, c?.({ mode: "listening" }));
9069
9069
  break;
9070
9070
  case "FunctionCallRequest":
9071
- _e(e);
9071
+ ge(e);
9072
9072
  break;
9073
9073
  case "AgentPreparing":
9074
9074
  ae = !0;
9075
9075
  break;
9076
9076
  case "SessionEnding":
9077
- console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), ce = !0;
9077
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), se = !0;
9078
9078
  break;
9079
9079
  case "AgentThinking":
9080
9080
  c?.({ mode: "thinking" });
@@ -9091,16 +9091,16 @@ async function Lm(e) {
9091
9091
  };
9092
9092
  return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9093
9093
  if (e.data instanceof ArrayBuffer) {
9094
- re && M.enqueue(new Int16Array(e.data));
9094
+ re && N.enqueue(new Int16Array(e.data));
9095
9095
  return;
9096
9096
  }
9097
9097
  try {
9098
- N(JSON.parse(e.data));
9098
+ P(JSON.parse(e.data));
9099
9099
  } catch {}
9100
9100
  }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9101
- he(), o?.();
9101
+ me(), o?.();
9102
9102
  }, {
9103
- endSession: async () => he(),
9103
+ endSession: async () => me(),
9104
9104
  sendContextualUpdate: (e) => {
9105
9105
  O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9106
9106
  type: "UpdatePrompt",
@@ -12056,7 +12056,7 @@ function bg(e) {
12056
12056
  function xg(e) {
12057
12057
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
12058
12058
  "fwh-navigate-mvp": async (n) => {
12059
- $("fwh-navigate-mvp ▶ raw parameters:", n);
12059
+ if ($("fwh-navigate-mvp ▶ raw parameters:", n), e?.isWalkthroughActive?.()) return $("fwh-navigate-mvp ✖ blocked — walkthrough in progress"), "NAVIGATION_BLOCKED_DURING_WALKTHROUGH. A walkthrough of the current page is in progress, so navigation is not allowed. Do NOT tell the visitor you navigated or offer to. Describe the requested section using the CURRENT page's own content (fwh-read-content-mvp), then stop.";
12060
12060
  let i = gg(n), a = _g(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12061
12061
  if ($("fwh-navigate-mvp · coerced:", {
12062
12062
  url: a,
@@ -12104,10 +12104,10 @@ function xg(e) {
12104
12104
  sender: "user",
12105
12105
  message: e
12106
12106
  }]);
12107
- n && P(t, n);
12107
+ n && F(t, n);
12108
12108
  }
12109
12109
  } catch {}
12110
- Ee();
12110
+ Te();
12111
12111
  let e = a;
12112
12112
  try {
12113
12113
  e = new URL(a, typeof window < "u" ? window.location.href : "").href;
@@ -12117,7 +12117,7 @@ function xg(e) {
12117
12117
  let e = new URL(a, window.location.href).pathname.split("/").filter(Boolean).pop() || "";
12118
12118
  n = e ? e.replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) : "Home";
12119
12119
  } catch {}
12120
- t && typeof window < "u" && L(t, window.location.href, e, n), gr(e), $("fwh-navigate-mvp → real navigation", a);
12120
+ t && typeof window < "u" && je(t, window.location.href, e, n), gr(e), $("fwh-navigate-mvp → real navigation", a);
12121
12121
  let i = typeof window < "u" && !!qn();
12122
12122
  if (typeof window < "u" && window.__fe_triggerVoiceNavHooks && window.__fe_triggerVoiceNavHooks(), i && Rn(12e3), br(a, { voiceActive: !0 }).catch(() => {}), i) try {
12123
12123
  let e = new URL(a, window.location.origin).pathname, t = window.location.pathname, n = Date.now() + 2e3;
@@ -12398,8 +12398,8 @@ function xg(e) {
12398
12398
  var Sg = /^(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;
12399
12399
  function Cg() {
12400
12400
  try {
12401
- let { headings: e } = yg();
12402
- return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !Sg.test(e.trim()));
12401
+ let { headings: e, pageTitleHeading: t } = yg();
12402
+ return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !t || e.trim() !== t.trim()).filter((e) => !Sg.test(e.trim()));
12403
12403
  } catch {
12404
12404
  return [];
12405
12405
  }
@@ -12835,62 +12835,62 @@ function Pg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12835
12835
  }
12836
12836
  function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
12837
12837
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
12838
- let [T, E] = m("idle"), [D, ee] = m(!1), [O, k] = m(!1), [te, ne] = m(!1), [re, A] = m(""), [ie, ae] = m(""), oe = p(!1), se = p(!1), j = p(null), ce = p(0), le = p(""), M = p(!1), ue = p(0), de = p(!1), fe = p(!1), pe = p(!1), me = p([]), he = p(null), ge = (e) => {
12839
- de.current = e, e || (fe.current = !1), N.current?.setWalkthroughActive?.(e);
12838
+ let [T, E] = m("idle"), [D, ee] = m(!1), [O, k] = m(!1), [te, ne] = m(!1), [re, A] = m(""), [ie, ae] = m(""), oe = p(!1), j = p(!1), M = p(null), se = p(0), ce = p(""), N = p(!1), le = p(0), ue = p(!1), de = p(!1), fe = p(!1), pe = p([]), me = p(null), he = (e) => {
12839
+ ue.current = e, e || (de.current = !1), P.current?.setWalkthroughActive?.(e);
12840
12840
  };
12841
- he.current = async () => {
12842
- if (fe.current) return;
12843
- let e = me.current;
12844
- _e.current += 1;
12845
- let t = _e.current, n = e[t];
12841
+ me.current = async () => {
12842
+ if (de.current) return;
12843
+ let e = pe.current;
12844
+ ge.current += 1;
12845
+ let t = ge.current, n = e[t];
12846
12846
  if (!n) {
12847
- ge(!1), e.length && N.current?.sendUserMessage?.("That was the last section. Say so in one short sentence and ask if they want to explore any section further.");
12847
+ 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.");
12848
12848
  return;
12849
12849
  }
12850
12850
  try {
12851
12851
  await toolsRef.current?.highlightOnPage?.({ section_text: n });
12852
12852
  } catch {}
12853
- console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`), N.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t === 0 ? "Starting with" : "Next —"} ${n}. Describe ONLY this section. If this section contains named sub-items (steps, checklist entries, cards, plans, FAQs, team members), name EVERY one of them in order with a short phrase each — never skip or collapse them into a summary; read the section's content silently first (fwh-read-content-mvp) if you don't already have it. Do not mention any other section, do not ask whether to continue, then stop.`, { suppressQuestion: !0 });
12853
+ console.debug(`[FlowEngage] walkthrough step ${t + 1}/${e.length}: ${n}`), 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; read the section's content silently first (fwh-read-content-mvp) if you don't already have it. This section is ON THE PAGE THE VISITOR IS ALREADY ON — do NOT call fwh-navigate-mvp, do not go to a product/detail page, and do not offer to, even if this section's name also matches a page name. Do not mention any other section, do not ask whether to continue, then stop.`, { suppressQuestion: !0 });
12854
12854
  };
12855
- let _e = p(0), N = p(null), ve = p(""), ye = p(async () => {}), be = p(!1), xe = p(!1), Se = p(!1), Ce = p(!1), F = p("minimized"), De = p(null), Oe = p(null), I = p(null), ke = p(0), je = p(!1), L = p("idle"), R = p(null), Ne = p(!1), Pe = p(null), Fe = o((e = "minimized") => {
12855
+ let ge = p(0), P = p(null), _e = p(""), ve = p(async () => {}), ye = p(!1), be = p(!1), xe = p(!1), Se = p(!1), I = p("minimized"), Ee = p(null), De = p(null), L = p(null), Oe = p(0), Ae = p(!1), je = p("idle"), R = p(null), Ne = p(!1), Pe = p(null), Fe = o((e = "minimized") => {
12856
12856
  console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
12857
12857
  destination: e,
12858
12858
  stack: (/* @__PURE__ */ Error()).stack?.split("\n").slice(1, 4).join(" | ")
12859
- }), F.current = e, Ce.current = !0, queueMicrotask(() => {
12860
- be.current || (be.current = !0, ye.current?.());
12859
+ }), I.current = e, Se.current = !0, queueMicrotask(() => {
12860
+ ye.current || (ye.current = !0, ve.current?.());
12861
12861
  });
12862
12862
  }, [l]), Ie = o(() => {
12863
- j.current &&= (clearTimeout(j.current), null);
12863
+ M.current &&= (clearTimeout(M.current), null);
12864
12864
  }, []);
12865
12865
  c(() => {
12866
12866
  if (y) {
12867
12867
  oe.current = !1;
12868
12868
  return;
12869
12869
  }
12870
- if (oe.current = !0, se.current = !1, ne(!1), Ie(), M.current) {
12871
- M.current = !1, N.current?.setMicMuted?.(!1);
12872
- let e = le.current;
12873
- le.current = "", N.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && N.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
12870
+ if (oe.current = !0, j.current = !1, ne(!1), Ie(), N.current) {
12871
+ N.current = !1, P.current?.setMicMuted?.(!1);
12872
+ let e = ce.current;
12873
+ ce.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}"`);
12874
12874
  }
12875
- N.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.");
12875
+ 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.");
12876
12876
  }, [y, Ie]);
12877
12877
  let z = /(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 = o(() => {
12878
- Ie(), j.current = setTimeout(() => {
12879
- if (!(!se.current || oe.current)) if (ce.current < 3) {
12880
- ce.current += 1;
12878
+ Ie(), M.current = setTimeout(() => {
12879
+ if (!(!j.current || oe.current)) if (se.current < 3) {
12880
+ se.current += 1;
12881
12881
  try {
12882
- N.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
12882
+ P.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
12883
12883
  } catch {}
12884
12884
  ze();
12885
12885
  } else {
12886
12886
  try {
12887
- N.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");
12887
+ 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");
12888
12888
  } catch {}
12889
- se.current = !1, ne(!1), Ie(), je.current = !0;
12889
+ j.current = !1, ne(!1), Ie(), Ae.current = !0;
12890
12890
  }
12891
12891
  }, 1e4);
12892
12892
  }, [Ie]), Be = o(async (e) => {
12893
- Ce.current = !0;
12893
+ Se.current = !0;
12894
12894
  try {
12895
12895
  On();
12896
12896
  } catch {}
@@ -12898,9 +12898,9 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12898
12898
  Me(i);
12899
12899
  } catch {}
12900
12900
  try {
12901
- await N.current?.endSession?.();
12901
+ await P.current?.endSession?.();
12902
12902
  } catch {}
12903
- let t = De.current, n = Oe.current;
12903
+ let t = Ee.current, n = De.current;
12904
12904
  if (t && s && a) {
12905
12905
  let e = n ? Math.round((Date.now() - n) / 1e3) : 0;
12906
12906
  fetch(`${a}/api/voice/save-chat-recording`, {
@@ -12914,8 +12914,8 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12914
12914
  })
12915
12915
  }).catch((e) => console.warn("[FlowEngage] save-chat-recording failed:", e.message));
12916
12916
  }
12917
- if (De.current = null, Oe.current = null, N.current = null, E("idle"), ee(!1), be.current = !1, wr(), i) try {
12918
- Te(i);
12917
+ if (Ee.current = null, De.current = null, P.current = null, E("idle"), ee(!1), ye.current = !1, wr(), i) try {
12918
+ we(i);
12919
12919
  } catch {}
12920
12920
  typeof u == "function" && await u(l.current), e?.();
12921
12921
  }, [
@@ -12925,8 +12925,8 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12925
12925
  s,
12926
12926
  a
12927
12927
  ]);
12928
- ye.current = () => Be(F.current === "chat" ? t : n), c(() => {
12929
- xe.current = D;
12928
+ ve.current = () => Be(I.current === "chat" ? t : n), c(() => {
12929
+ be.current = D;
12930
12930
  }, [D]), c(() => {
12931
12931
  d && Fe("chat");
12932
12932
  }, [d]), c(() => {
@@ -12938,13 +12938,13 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12938
12938
  }
12939
12939
  try {
12940
12940
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
12941
- l.current = [], ve.current = "", be.current = !1, Se.current = !1, Ce.current = !1, F.current = "minimized", Cr({ onBeforeNavigate: () => {
12941
+ l.current = [], _e.current = "", ye.current = !1, xe.current = !1, Se.current = !1, I.current = "minimized", Cr({ onBeforeNavigate: () => {
12942
12942
  if (i && l.current.length > 0) try {
12943
12943
  let e = Fh(l.current);
12944
- e && P(i, e);
12944
+ e && F(i, e);
12945
12945
  } catch {}
12946
12946
  if (!qn()) {
12947
- let e = De.current, t = Oe.current;
12947
+ let e = Ee.current, t = De.current;
12948
12948
  if (e && s && a) try {
12949
12949
  let n = t ? Math.round((Date.now() - t) / 1e3) : 0, r = JSON.stringify({
12950
12950
  chatId: s,
@@ -12957,23 +12957,24 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12957
12957
  headers: { "Content-Type": "application/json" },
12958
12958
  body: r,
12959
12959
  keepalive: !0
12960
- }).catch(() => {}), De.current = null, Oe.current = null;
12960
+ }).catch(() => {}), Ee.current = null, De.current = null;
12961
12961
  } catch {}
12962
12962
  }
12963
- Ee();
12963
+ Te();
12964
12964
  } });
12965
12965
  let t = wg(xg({
12966
12966
  siteId: i || null,
12967
12967
  apiBaseUrl: a || null,
12968
12968
  chatId: s || null,
12969
- getLastUserVoiceText: () => ve.current,
12969
+ getLastUserVoiceText: () => _e.current,
12970
+ isWalkthroughActive: () => ue.current && !de.current,
12970
12971
  requestEndSession: () => {
12971
- je.current = !0;
12972
+ Ae.current = !0;
12972
12973
  },
12973
12974
  requestEmailCollection: () => {
12974
- b && (oe.current || se.current || (se.current = !0, ce.current = 0, ne(!0), ze()));
12975
+ b && (oe.current || j.current || (j.current = !0, se.current = 0, ne(!0), ze()));
12975
12976
  }
12976
- })), n = i ? we(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 = {
12977
+ })), n = i ? Ce(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 = {
12977
12978
  apiBaseUrl: a,
12978
12979
  siteId: i,
12979
12980
  chatId: s,
@@ -13004,17 +13005,17 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13004
13005
  let e = f || "";
13005
13006
  x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to the ${w} page!`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
13006
13007
  }
13007
- let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, re = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, A = r && !p, ie = !1, ae = A ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, j = !1, ye = !1, Te = b && !!y && !pe.current, I = await Rm.startSession({
13008
+ let O = !1, k = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, te = !1, re = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, A = r && !p, ie = !1, ae = A ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, M = !1, ve = !1, we = b && !!y && !fe.current, L = await Rm.startSession({
13008
13009
  ...x,
13009
13010
  onConnect: ({ conversationId: e }) => {
13010
- De.current = e, Oe.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13011
+ Ee.current = e, De.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13011
13012
  },
13012
13013
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
13013
13014
  onSessionInfo: ({ emailOnFile: e }) => {
13014
- pe.current = !!e, e && (oe.current = !0, se.current = !1, ne(!1), Ie(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13015
+ fe.current = !!e, e && (oe.current = !0, j.current = !1, ne(!1), Ie(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13015
13016
  },
13016
13017
  onAgentTurnEnd: () => {
13017
- e || de.current && (fe.current || M.current || setTimeout(() => he.current?.(), 250));
13018
+ e || ue.current && (de.current || N.current || setTimeout(() => me.current?.(), 250));
13018
13019
  },
13019
13020
  onSessionEnding: () => {
13020
13021
  e || Fe("minimized");
@@ -13022,124 +13023,124 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13022
13023
  onModeChange: ({ mode: t, tentative: n }) => {
13023
13024
  if (!e) {
13024
13025
  if (t === "speaking") {
13025
- R.current &&= (clearTimeout(R.current), null), Pe.current &&= (clearTimeout(Pe.current), null), E("speaking"), L.current = "speaking", Ne.current = !1;
13026
+ R.current &&= (clearTimeout(R.current), null), Pe.current &&= (clearTimeout(Pe.current), null), E("speaking"), je.current = "speaking", Ne.current = !1;
13026
13027
  return;
13027
13028
  }
13028
13029
  if (t === "user-speaking") {
13029
13030
  try {
13030
13031
  On();
13031
13032
  } catch {}
13032
- if (Pe.current &&= (clearTimeout(Pe.current), null), L.current === "speaking") return;
13033
- R.current &&= (clearTimeout(R.current), null), L.current !== "listening" && (E("listening"), L.current = "listening");
13033
+ if (Pe.current &&= (clearTimeout(Pe.current), null), je.current === "speaking") return;
13034
+ R.current &&= (clearTimeout(R.current), null), je.current !== "listening" && (E("listening"), je.current = "listening");
13034
13035
  return;
13035
13036
  }
13036
13037
  if (t === "thinking") {
13037
- if (R.current &&= (clearTimeout(R.current), null), Pe.current &&= (clearTimeout(Pe.current), null), L.current === "speaking") return;
13038
- E("thinking"), L.current = "thinking", n && (Pe.current = setTimeout(() => {
13039
- Pe.current = null, !(e || L.current !== "thinking") && (L.current = "listening", E("listening"));
13038
+ if (R.current &&= (clearTimeout(R.current), null), Pe.current &&= (clearTimeout(Pe.current), null), je.current === "speaking") return;
13039
+ E("thinking"), je.current = "thinking", n && (Pe.current = setTimeout(() => {
13040
+ Pe.current = null, !(e || je.current !== "thinking") && (je.current = "listening", E("listening"));
13040
13041
  }, 4e3));
13041
13042
  return;
13042
13043
  }
13043
- if (L.current = "listening", je.current) {
13044
- je.current = !1, Fe();
13044
+ if (je.current = "listening", Ae.current) {
13045
+ Ae.current = !1, Fe();
13045
13046
  return;
13046
13047
  }
13047
- if (Te && !ye && !oe.current && !pe.current) {
13048
- ye = !0, O = !0, te = !0;
13048
+ if (we && !ve && !oe.current && !fe.current) {
13049
+ ve = !0, O = !0, te = !0;
13049
13050
  try {
13050
- N.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
13051
+ P.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: \"Before I answer that, could you please enter your email in the text box below?\" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be \"Before\". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.");
13051
13052
  } catch {}
13052
13053
  }
13053
13054
  if (k && !O) {
13054
13055
  O = !0;
13055
13056
  try {
13056
- N.current?.sendContextualUpdate?.(k);
13057
+ P.current?.sendContextualUpdate?.(k);
13057
13058
  } catch {}
13058
13059
  }
13059
13060
  if (ae && !ie) {
13060
13061
  ie = !0;
13061
13062
  try {
13062
- N.current?.sendContextualUpdate?.(ae);
13063
+ P.current?.sendContextualUpdate?.(ae);
13063
13064
  } catch {}
13064
13065
  }
13065
13066
  if (re && !te) {
13066
13067
  te = !0;
13067
13068
  try {
13068
- N.current?.sendContextualUpdate?.(re);
13069
+ P.current?.sendContextualUpdate?.(re);
13069
13070
  } catch {}
13070
13071
  }
13071
13072
  R.current && clearTimeout(R.current), R.current = setTimeout(() => {
13072
- e || L.current !== "speaking" && (Ne.current || (R.current = null, L.current = "listening", E("listening")));
13073
+ e || je.current !== "speaking" && (Ne.current || (R.current = null, je.current = "listening", E("listening")));
13073
13074
  }, 1200);
13074
13075
  }
13075
13076
  },
13076
13077
  onMessage: (t) => {
13077
- if (e || M.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13078
- if (t.role === "user" && z.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), ge(!0), fe.current = !1, ue.current = 0, _e.current = -1, me.current = Cg(), setTimeout(() => he.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${me.current.length} sections on this page`);
13079
- else if (t.role === "user" && de.current) {
13078
+ if (e || N.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13079
+ if (t.role === "user" && z.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 = Cg(), setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${pe.current.length} sections on this page`);
13080
+ else if (t.role === "user" && ue.current) {
13080
13081
  let e = String(t.message || "").trim();
13081
- Re.test(e) ? fe.current && (fe.current = !1, console.debug("[FlowEngage] walkthrough resumed by visitor"), setTimeout(() => he.current?.(), 300)) : (fe.current = !0, console.debug("[FlowEngage] walkthrough paused — visitor interjected"));
13082
+ Re.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"));
13082
13083
  }
13083
13084
  if (t.role !== "user" && Le.test(String(t.message || ""))) {
13084
- let e = me.current.length;
13085
- !e || _e.current >= e - 1 ? ge(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${_e.current + 1}/${e} — ignoring, tour continues`);
13085
+ let e = pe.current.length;
13086
+ !e || ge.current >= e - 1 ? he(!1) : console.debug(`[FlowEngage] agent claimed completion at step ${ge.current + 1}/${e} — ignoring, tour continues`);
13086
13087
  }
13087
13088
  let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
13088
13089
  if (r) {
13089
- if (n === "user" && (ve.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ne.current = !0, R.current &&= (clearTimeout(R.current), null), L.current !== "speaking" && (E("thinking"), L.current = "thinking"), Te && !j && !oe.current && !pe.current && (j = !0, le.current = r, M.current = !0, N.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), N.current?.setMicMuted?.(!0), se.current || (se.current = !0, ce.current = 0, ne(!0), ze()))), l.current = [...l.current, {
13090
+ if (n === "user" && (_e.current = r, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Ne.current = !0, R.current &&= (clearTimeout(R.current), null), je.current !== "speaking" && (E("thinking"), je.current = "thinking"), we && !M && !oe.current && !fe.current && (M = !0, ce.current = r, N.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), j.current || (j.current = !0, se.current = 0, ne(!0), ze()))), l.current = [...l.current, {
13090
13091
  sender: n,
13091
13092
  message: r,
13092
13093
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
13093
13094
  debug: t.debug
13094
13095
  }], i) try {
13095
13096
  let e = Fh(l.current);
13096
- e && P(i, e);
13097
+ e && F(i, e);
13097
13098
  } catch {}
13098
13099
  if (jg(n, r)) {
13099
- je.current = !0;
13100
+ Ae.current = !0;
13100
13101
  return;
13101
13102
  }
13102
- if (xe.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (ke.current += 1, ke.current === 2) try {
13103
- N.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.");
13103
+ if (be.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (Oe.current += 1, Oe.current === 2) try {
13104
+ 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.");
13104
13105
  } catch {}
13105
- else ke.current >= 5 && Fe("minimized");
13106
+ else Oe.current >= 5 && Fe("minimized");
13106
13107
  }
13107
13108
  },
13108
13109
  onError: (t) => {
13109
- if (!e && !Ce.current && !Se.current && !Ae()) {
13110
- Se.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13110
+ if (!e && !Se.current && !xe.current && !ke()) {
13111
+ xe.current = !0, console.error("[FlowEngageVoiceCall] session:error", {
13111
13112
  message: t?.message,
13112
13113
  name: t?.name,
13113
13114
  raw: t
13114
13115
  });
13115
13116
  try {
13116
- N.current?.setMicMuted?.(!0);
13117
+ P.current?.setMicMuted?.(!0);
13117
13118
  } catch {}
13118
13119
  ee(!0), E("error"), Fe("chat");
13119
13120
  }
13120
13121
  },
13121
13122
  onDisconnect: (t) => {
13122
- if (e || Ce.current || Se.current || Ae()) return;
13123
+ if (e || Se.current || xe.current || ke()) return;
13123
13124
  let n = l.current?.length || 0;
13124
13125
  console.warn("[FlowEngageVoiceCall] session:disconnected", {
13125
13126
  historyCount: n,
13126
13127
  reason: t?.reason,
13127
13128
  closeCode: t?.context?.code,
13128
13129
  closeReason: t?.context?.reason || t?.message,
13129
- lastUserText: ve.current || "",
13130
- wasMuted: xe.current
13131
- }), Se.current = !0;
13130
+ lastUserText: _e.current || "",
13131
+ wasMuted: be.current
13132
+ }), xe.current = !0;
13132
13133
  try {
13133
- N.current?.setMicMuted?.(!0);
13134
+ P.current?.setMicMuted?.(!0);
13134
13135
  } catch {}
13135
13136
  ee(!0), Fe("chat");
13136
13137
  }
13137
13138
  });
13138
13139
  if (e) {
13139
- console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), I.endSession().catch(() => {});
13140
+ console.warn("[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately"), L.endSession().catch(() => {});
13140
13141
  return;
13141
13142
  }
13142
- o = I, N.current = I, E("listening");
13143
+ o = L, P.current = L, E("listening");
13143
13144
  try {
13144
13145
  let e = typeof window < "u" ? window.location.href : "", a = "[]";
13145
13146
  try {
@@ -13151,7 +13152,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13151
13152
  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(" | "));
13152
13153
  } catch {}
13153
13154
  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` : "";
13154
- I.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
13155
+ L.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i || "unknown"}. Forms: ${a}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
13155
13156
  } catch {}
13156
13157
  if (typeof window < "u") {
13157
13158
  let t = window.location.pathname, n = Date.now(), r = (e) => {
@@ -13197,7 +13198,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13197
13198
  ts: Date.now()
13198
13199
  }), console.log(`[FlowEngage] visitor navigation detected: "${a}" → "${i}" (agent target: ${D || "none"})`);
13199
13200
  try {
13200
- N.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${d}" only.]`);
13201
+ P.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${d}" page (${o}). Page title: "${s}". Sections: ${JSON.stringify(c)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${d} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call fwh-navigate-mvp, do NOT call fwh-highlight-mvp, the visitor will navigate themselves if needed. IF I want to hear about this page: call fwh-highlight-mvp for sections of "${d}" only.]`);
13201
13202
  } catch {}
13202
13203
  };
13203
13204
  c = window.history.pushState.bind(window.history), window.history.pushState = (...e) => {
@@ -13205,7 +13206,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13205
13206
  }, d = () => setTimeout(i, 50), window.addEventListener("popstate", d);
13206
13207
  }
13207
13208
  } catch (r) {
13208
- e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"), F.current = "chat", window.setTimeout(() => {
13209
+ e || (console.error("[FlowEngage] startSession failed", r), r.message && r.message.includes("Too many voice sessions") ? (alert(r.message), n && n("minimized")) : (E("error"), I.current = "chat", window.setTimeout(() => {
13209
13210
  e || t?.();
13210
13211
  }, 0)));
13211
13212
  }
@@ -13214,15 +13215,15 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13214
13215
  agentId: r,
13215
13216
  siteId: i,
13216
13217
  apiBaseUrl: a
13217
- }), e = !0, Ce.current = !0;
13218
+ }), e = !0, Se.current = !0;
13218
13219
  try {
13219
13220
  On();
13220
13221
  } catch {}
13221
13222
  if (i) try {
13222
13223
  Me(i);
13223
13224
  } catch {}
13224
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), R.current &&= (clearTimeout(R.current), null), Pe.current &&= (clearTimeout(Pe.current), null), j.current &&= (clearTimeout(j.current), null), Ne.current = !1, L.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13225
- let t = o || N.current, n = De.current, f = Oe.current;
13225
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), R.current &&= (clearTimeout(R.current), null), Pe.current &&= (clearTimeout(Pe.current), null), M.current &&= (clearTimeout(M.current), null), Ne.current = !1, je.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13226
+ let t = o || P.current, n = Ee.current, f = De.current;
13226
13227
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13227
13228
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
13228
13229
  chatId: s,
@@ -13235,7 +13236,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13235
13236
  headers: { "Content-Type": "application/json" },
13236
13237
  body: t,
13237
13238
  keepalive: !0
13238
- }).catch(() => {}), De.current = null, Oe.current = null;
13239
+ }).catch(() => {}), Ee.current = null, De.current = null;
13239
13240
  }
13240
13241
  typeof u == "function" && l.current.length > 0 && u(l.current).catch?.(() => {});
13241
13242
  };
@@ -13248,21 +13249,21 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13248
13249
  if (!O) return;
13249
13250
  let e = (e) => {
13250
13251
  let t = e.composedPath?.()?.[0] || e.target;
13251
- I.current && !I.current.contains(t) && k(!1);
13252
+ L.current && !L.current.contains(t) && k(!1);
13252
13253
  };
13253
13254
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13254
13255
  }, [O]);
13255
13256
  let Ve = async () => {
13256
- if (N.current) try {
13257
+ if (P.current) try {
13257
13258
  if (D) {
13258
- ke.current = 0, await N.current.setMicMuted?.(!1), ee(!1);
13259
+ Oe.current = 0, await P.current.setMicMuted?.(!1), ee(!1);
13259
13260
  try {
13260
- N.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13261
+ P.current.sendContextualUpdate?.("The visitor has unmuted. Resume normal interaction and wait for them to speak.");
13261
13262
  } catch {}
13262
13263
  } else {
13263
- ke.current = 0, await N.current.setMicMuted?.(!0), ee(!0);
13264
+ Oe.current = 0, await P.current.setMicMuted?.(!0), ee(!0);
13264
13265
  try {
13265
- N.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.");
13266
+ 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.");
13266
13267
  } catch {}
13267
13268
  }
13268
13269
  } catch {}
@@ -13273,15 +13274,15 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13273
13274
  ae("Please enter a valid email address.");
13274
13275
  return;
13275
13276
  }
13276
- ae(""), oe.current = !0, se.current = !1, Ie(), ne(!1), A(""), M.current = !1;
13277
+ ae(""), oe.current = !0, j.current = !1, Ie(), ne(!1), A(""), N.current = !1;
13277
13278
  try {
13278
13279
  typeof v == "function" && await v(t);
13279
13280
  } catch {}
13280
- N.current?.setMicMuted?.(!1);
13281
- let n = le.current;
13282
- le.current = "";
13281
+ P.current?.setMicMuted?.(!1);
13282
+ let n = ce.current;
13283
+ ce.current = "";
13283
13284
  try {
13284
- N.current?.injectAgentSpeech?.("Thank you for submitting your email."), N.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13285
+ 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.");
13285
13286
  } catch {}
13286
13287
  }, [
13287
13288
  re,
@@ -13289,7 +13290,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13289
13290
  Ie
13290
13291
  ]), Ue = Array.isArray(e) && e[0] || "#3B82F6";
13291
13292
  return /* @__PURE__ */ _("div", {
13292
- ref: I,
13293
+ ref: L,
13293
13294
  style: {
13294
13295
  position: "relative",
13295
13296
  display: "flex",
@@ -13527,7 +13528,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13527
13528
  children: [
13528
13529
  /* @__PURE__ */ _("button", {
13529
13530
  onClick: () => {
13530
- k(!1), F.current = "chat", Be(t);
13531
+ k(!1), I.current = "chat", Be(t);
13531
13532
  },
13532
13533
  style: {
13533
13534
  display: "flex",
@@ -13556,7 +13557,7 @@ function Fg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13556
13557
  }),
13557
13558
  /* @__PURE__ */ _("button", {
13558
13559
  onClick: () => {
13559
- k(!1), F.current = "minimized", Be(n);
13560
+ k(!1), I.current = "minimized", Be(n);
13560
13561
  },
13561
13562
  style: {
13562
13563
  display: "flex",
@@ -13682,8 +13683,8 @@ var Lg = () => /* @__PURE__ */ g("div", {
13682
13683
  } }, e))
13683
13684
  })
13684
13685
  });
13685
- function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: ae, emailCaptureSuccess: oe, replyContext: se, setReplyContext: j, webRTCError: ce, micError: le, setMicError: M, dismissCallError: ue, activeCallId: de, isCallMuted: fe, toggleCallMute: pe, endWebRTCCall: me, formatCallDuration: he, callDurationSeconds: ge, isCallMinimized: _e, onExpand: N, onCollapse: ve, onStartVoice: ye, voiceEnabled: be, headerBgColor: xe, onNewChat: Se, showPoweredBy: Ce, privacyPolicyUrl: P, getVisitorChatHistory: we, resumeChat: Te, isSessionRestoring: F, isClosing: Ee }) {
13686
- let De = l.length > 0, Oe = T || E || w, I = !!de, [ke, Ae] = m(!1), [je, L] = m(!1), [Me, R] = m([]), [Ne, Pe] = m(!1), Fe = p(null), [Ie, z] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Le, Re] = m(0);
13686
+ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: ee, onFileSelect: O, onRemoveSelectedFile: k, attachmentError: te, isUploadingAttachment: ne, requiresEmail: re, emailInput: A, setEmailInput: ie, emailError: ae, emailCaptureSuccess: oe, replyContext: j, setReplyContext: M, webRTCError: se, micError: ce, setMicError: N, 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: xe, showPoweredBy: Se, privacyPolicyUrl: F, getVisitorChatHistory: Ce, resumeChat: we, isSessionRestoring: I, isClosing: Te }) {
13687
+ let Ee = l.length > 0, De = T || E || w, L = !!ue, [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, R] = m([]), [Ne, Pe] = m(!1), Fe = p(null), [Ie, z] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Le, Re] = m(0);
13687
13688
  c(() => {
13688
13689
  if (!s) return;
13689
13690
  let e = window.visualViewport;
@@ -13696,9 +13697,9 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13696
13697
  };
13697
13698
  }, [s]);
13698
13699
  let ze = s && window.innerHeight - Ie > 150, Be = async () => {
13699
- Ae(!1), L(!0), Pe(!0);
13700
+ ke(!1), je(!0), Pe(!0);
13700
13701
  try {
13701
- let e = await we();
13702
+ let e = await Ce();
13702
13703
  e?.data && R(e.data);
13703
13704
  } catch (e) {
13704
13705
  console.error(e);
@@ -13706,16 +13707,16 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13706
13707
  Pe(!1);
13707
13708
  }
13708
13709
  }, Ve = async (e) => {
13709
- L(!1), Te?.(e.chatId);
13710
+ je(!1), we?.(e.chatId);
13710
13711
  };
13711
13712
  return c(() => {
13712
- if (!ke) return;
13713
+ if (!Oe) return;
13713
13714
  let e = (e) => {
13714
13715
  let t = e.composedPath?.()?.[0] || e.target;
13715
- Fe.current && !Fe.current.contains(t) && Ae(!1);
13716
+ Fe.current && !Fe.current.contains(t) && ke(!1);
13716
13717
  };
13717
13718
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13718
- }, [ke]), /* @__PURE__ */ _("div", {
13719
+ }, [Oe]), /* @__PURE__ */ _("div", {
13719
13720
  style: s ? {
13720
13721
  "--flowengage-primary": n,
13721
13722
  "--flowengage-accent": n,
@@ -13729,7 +13730,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13729
13730
  display: "flex",
13730
13731
  flexDirection: "column",
13731
13732
  overflow: "hidden",
13732
- animation: Ee ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)"
13733
+ animation: Te ? "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)"
13733
13734
  } : {
13734
13735
  "--flowengage-primary": n,
13735
13736
  "--flowengage-accent": n,
@@ -13742,7 +13743,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13742
13743
  flexDirection: "column",
13743
13744
  overflow: "hidden",
13744
13745
  position: "relative",
13745
- animation: Ee ? "fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards" : "fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)"
13746
+ animation: Te ? "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)"
13746
13747
  },
13747
13748
  children: [
13748
13749
  /* @__PURE__ */ _("div", {
@@ -13752,7 +13753,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13752
13753
  alignItems: "center",
13753
13754
  columnGap: "14px",
13754
13755
  padding: "16px 10px 14px",
13755
- background: xe || "transparent",
13756
+ background: be || "transparent",
13756
13757
  flexShrink: 0,
13757
13758
  position: "relative",
13758
13759
  zIndex: 30
@@ -13765,7 +13766,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13765
13766
  alignItems: "center"
13766
13767
  },
13767
13768
  children: /* @__PURE__ */ g("button", {
13768
- onClick: ve,
13769
+ onClick: _e,
13769
13770
  style: {
13770
13771
  width: "40px",
13771
13772
  height: "40px",
@@ -13870,7 +13871,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13870
13871
  ref: Fe,
13871
13872
  children: [/* @__PURE__ */ g("button", {
13872
13873
  type: "button",
13873
- onClick: () => Ae((e) => !e),
13874
+ onClick: () => ke((e) => !e),
13874
13875
  style: {
13875
13876
  width: "40px",
13876
13877
  height: "40px",
@@ -13916,7 +13917,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13916
13917
  })
13917
13918
  ]
13918
13919
  })
13919
- }), ke && /* @__PURE__ */ _("div", {
13920
+ }), Oe && /* @__PURE__ */ _("div", {
13920
13921
  style: {
13921
13922
  position: "absolute",
13922
13923
  top: "34px",
@@ -13932,10 +13933,10 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13932
13933
  animation: "fe-orb-fade-in 0.18s ease"
13933
13934
  },
13934
13935
  children: [
13935
- be && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
13936
+ ye && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ _("button", {
13936
13937
  type: "button",
13937
13938
  onClick: () => {
13938
- Ae(!1), ye?.();
13939
+ ke(!1), ve?.();
13939
13940
  },
13940
13941
  style: {
13941
13942
  display: "flex",
@@ -13977,7 +13978,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13977
13978
  /* @__PURE__ */ _("button", {
13978
13979
  type: "button",
13979
13980
  onClick: () => {
13980
- Ae(!1), Se?.();
13981
+ ke(!1), xe?.();
13981
13982
  },
13982
13983
  style: {
13983
13984
  display: "flex",
@@ -14012,7 +14013,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14012
14013
  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" })]
14013
14014
  }), "Start new chat"]
14014
14015
  }),
14015
- we && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
14016
+ Ce && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", { style: {
14016
14017
  height: "1px",
14017
14018
  background: "rgba(255,255,255,0.07)",
14018
14019
  margin: "0 14px"
@@ -14060,7 +14061,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14060
14061
  /* @__PURE__ */ _("button", {
14061
14062
  type: "button",
14062
14063
  onClick: () => {
14063
- Ae(!1), ve?.();
14064
+ ke(!1), _e?.();
14064
14065
  },
14065
14066
  style: {
14066
14067
  display: "flex",
@@ -14119,23 +14120,23 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14119
14120
  ]
14120
14121
  }),
14121
14122
  /* @__PURE__ */ g(_h, {
14122
- webRTCError: ce,
14123
- micError: le,
14124
- setMicError: M,
14125
- dismissCallError: ue,
14123
+ webRTCError: se,
14124
+ micError: ce,
14125
+ setMicError: N,
14126
+ dismissCallError: le,
14126
14127
  isRateLimited: E,
14127
14128
  rateLimitMessage: D
14128
14129
  }),
14129
- _e && /* @__PURE__ */ g(Ph, {
14130
+ ge && /* @__PURE__ */ g(Ph, {
14130
14131
  agentName: v,
14131
14132
  agentHeadshot: y,
14132
14133
  fallbackAgentName: b,
14133
- callDurationSeconds: ge,
14134
- isCallMuted: fe,
14135
- formatCallDuration: he,
14136
- toggleCallMute: pe,
14137
- endWebRTCCall: me,
14138
- onExpand: N,
14134
+ callDurationSeconds: he,
14135
+ isCallMuted: de,
14136
+ formatCallDuration: me,
14137
+ toggleCallMute: fe,
14138
+ endWebRTCCall: pe,
14139
+ onExpand: P,
14139
14140
  primaryColor: n
14140
14141
  }),
14141
14142
  /* @__PURE__ */ _("div", {
@@ -14147,7 +14148,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14147
14148
  background: "transparent",
14148
14149
  position: "relative"
14149
14150
  },
14150
- children: [je ? /* @__PURE__ */ _("div", {
14151
+ children: [Ae ? /* @__PURE__ */ _("div", {
14151
14152
  style: {
14152
14153
  position: "absolute",
14153
14154
  inset: 0,
@@ -14166,7 +14167,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14166
14167
  flexShrink: 0
14167
14168
  },
14168
14169
  children: /* @__PURE__ */ _("button", {
14169
- onClick: () => L(!1),
14170
+ onClick: () => je(!1),
14170
14171
  style: {
14171
14172
  background: "none",
14172
14173
  border: "none",
@@ -14260,18 +14261,18 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14260
14261
  children: "No previous chats found."
14261
14262
  })
14262
14263
  })]
14263
- }) : null, De ? /* @__PURE__ */ g(mh, {
14264
+ }) : null, Ee ? /* @__PURE__ */ g(mh, {
14264
14265
  chatHistory: l,
14265
14266
  isAiTyping: u,
14266
14267
  isLoading: T,
14267
14268
  isAgentTyping: d,
14268
- setReplyContext: j,
14269
+ setReplyContext: M,
14269
14270
  TypingDots: Lg,
14270
14271
  primaryColor: n,
14271
14272
  agentHeadshot: y,
14272
14273
  agentDisplayName: v || b,
14273
14274
  botAvatarNode: /* @__PURE__ */ g(Ig, { orbColors: t })
14274
- }) : F ? /* @__PURE__ */ _("div", {
14275
+ }) : I ? /* @__PURE__ */ _("div", {
14275
14276
  style: {
14276
14277
  flex: 1,
14277
14278
  display: "flex",
@@ -14407,13 +14408,13 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14407
14408
  setInput: S,
14408
14409
  onSubmit: C,
14409
14410
  isConversationEnded: w,
14410
- callUiActive: I,
14411
- handleToggleVoice: ye,
14411
+ callUiActive: L,
14412
+ handleToggleVoice: ve,
14412
14413
  showVoiceToggle: f === "agent",
14413
14414
  activeScreen: f,
14414
- inputDisabled: Oe,
14415
- replyContext: se,
14416
- clearReplyContext: () => j(null),
14415
+ inputDisabled: De,
14416
+ replyContext: j,
14417
+ clearReplyContext: () => M(null),
14417
14418
  onFileSelect: O,
14418
14419
  selectedFile: ee,
14419
14420
  onRemoveSelectedFile: k,
@@ -14434,7 +14435,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14434
14435
  paddingBottom: "max(12px, env(safe-area-inset-bottom, 12px))",
14435
14436
  pointerEvents: "none"
14436
14437
  },
14437
- children: [P && /* @__PURE__ */ _("p", {
14438
+ children: [F && /* @__PURE__ */ _("p", {
14438
14439
  style: {
14439
14440
  margin: "0 0 4px",
14440
14441
  fontSize: "10px",
@@ -14447,7 +14448,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14447
14448
  "This conversation is recorded for quality assurance purposes.",
14448
14449
  " ",
14449
14450
  /* @__PURE__ */ g("a", {
14450
- href: P,
14451
+ href: F,
14451
14452
  target: "_blank",
14452
14453
  rel: "noopener noreferrer",
14453
14454
  style: {
@@ -14457,7 +14458,7 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14457
14458
  children: "See our privacy policy"
14458
14459
  })
14459
14460
  ]
14460
- }), Ce && /* @__PURE__ */ _("span", {
14461
+ }), Se && /* @__PURE__ */ _("span", {
14461
14462
  style: {
14462
14463
  fontSize: "11px",
14463
14464
  color: "#9ca3af",
@@ -14477,33 +14478,33 @@ function Rg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14477
14478
  });
14478
14479
  }
14479
14480
  function zg() {
14480
- let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode: se, endConversation: j, startNewChat: M, acceptCall: ue, rejectCall: de, endWebRTCCall: fe, toggleCallMute: pe, dismissCallError: me, startTyping: he, stopTyping: ge, updateTypingDraft: _e, getVisitorChatHistory: N, resumeChat: ve, isSessionRestoring: ye, openToChatCounter: be, voiceEndCounter: xe } = Cn();
14481
+ let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: ee, webRTCError: O, language: k, chatId: te, historyRef: ne, onMessageSync: re, sendMessage: A, uploadChatFile: ie, openWidget: ae, captureVisitorEmail: oe, setVoiceMode: j, endConversation: M, startNewChat: N, 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();
14481
14482
  c(() => {
14482
14483
  try {
14483
14484
  or();
14484
14485
  } catch {}
14485
14486
  }, []), c(() => {
14486
- be && H !== "voice_mode" && H !== "text_chat" && H !== "call_screen" && (se?.(!1), U("text_chat"));
14487
- }, [be]);
14488
- let Se = t?.widgetSettings || {}, Ce = n?.widgetSettings || {}, P = {
14489
- ...Se.branding || {},
14490
- ...Ce.branding || {}
14491
- }, F = {
14492
- ...Se.theme || {},
14493
- ...Ce.theme || {}
14494
- }, Ee = {
14495
- ...Se.features || {},
14496
- ...Ce.features || {}
14497
- }, Oe = Ee.voice !== !1, I = Array.isArray(F.orbColors) && F.orbColors.length > 0 ? F.orbColors : null, Ae = F.buttonColor || F.primaryColor || I?.[0] || "#3B82F6", je = {
14487
+ ye && H !== "voice_mode" && H !== "text_chat" && H !== "call_screen" && (j?.(!1), U("text_chat"));
14488
+ }, [ye]);
14489
+ let xe = t?.widgetSettings || {}, Se = n?.widgetSettings || {}, F = {
14490
+ ...xe.branding || {},
14491
+ ...Se.branding || {}
14492
+ }, I = {
14493
+ ...xe.theme || {},
14494
+ ...Se.theme || {}
14495
+ }, Te = {
14496
+ ...xe.features || {},
14497
+ ...Se.features || {}
14498
+ }, De = Te.voice !== !1, L = Array.isArray(I.orbColors) && I.orbColors.length > 0 ? I.orbColors : null, ke = I.buttonColor || I.primaryColor || L?.[0] || "#3B82F6", Ae = {
14498
14499
  small: 50,
14499
14500
  medium: 64,
14500
14501
  large: 80
14501
- }, L = je[F.orbSize] || je.small, Me = F.position || "bottom-right", R = P.fallbackAgentName || "Agent", Ne = Eg(I ?? F.chatBgColors), Pe = P.logo || P.logoUrl || null, Fe = k || "en", Ie = Se.recommendations?.[Fe] || [], z = (Ce.recommendations?.[Fe] ?? Ie).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14502
+ }, je = Ae[I.orbSize] || Ae.small, Me = I.position || "bottom-right", R = F.fallbackAgentName || "Agent", Ne = Eg(L ?? I.chatBgColors), Pe = F.logo || F.logoUrl || null, Fe = k || "en", Ie = xe.recommendations?.[Fe] || [], z = (Se.recommendations?.[Fe] ?? Ie).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14502
14503
  id: e.key || `qr-${t}`,
14503
14504
  label: e.label,
14504
14505
  message: e.label,
14505
14506
  text: e.label
14506
- })), Le = Array.isArray(P.quickChatOptions) && P.quickChatOptions.length > 0 ? P.quickChatOptions : z, Re = P.hideWatermark === !0 ? !1 : P.showPoweredBy !== !1, ze = P.headerBgColor || null, Be = F.bottomPosition == null ? "1.5rem" : `${F.bottomPosition}px`, Ve = P.privacyPolicyUrl || null, He = P.chatbotEnabled !== !1 && F.chatbotEnabled !== !1, [Ue, We] = m(() => typeof window < "u" ? window.location.pathname : "/");
14507
+ })), Le = Array.isArray(F.quickChatOptions) && F.quickChatOptions.length > 0 ? F.quickChatOptions : z, Re = F.hideWatermark === !0 ? !1 : F.showPoweredBy !== !1, ze = F.headerBgColor || null, Be = I.bottomPosition == null ? "1.5rem" : `${I.bottomPosition}px`, Ve = F.privacyPolicyUrl || null, He = F.chatbotEnabled !== !1 && I.chatbotEnabled !== !1, [Ue, We] = m(() => typeof window < "u" ? window.location.pathname : "/");
14507
14508
  c(() => {
14508
14509
  if (typeof window > "u") return;
14509
14510
  let e = () => We(window.location.pathname), t = window.history.pushState.bind(window.history);
@@ -14515,24 +14516,24 @@ function zg() {
14515
14516
  }, []);
14516
14517
  let Ge = (() => {
14517
14518
  let e = {
14518
- ...Se.pageVisibility || {},
14519
- ...Ce.pageVisibility || {}
14519
+ ...xe.pageVisibility || {},
14520
+ ...Se.pageVisibility || {}
14520
14521
  };
14521
14522
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
14522
- })(), Ke = Ge.length === 0 || Ge.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ue.startsWith(e.slice(0, -1)) : Ue.replace(/\/$/, "") === e.replace(/\/$/, "")), qe = Se.greetings?.[k] || Ce.greetings?.[k] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Je = {
14523
- entryPrompt: P.entryPrompt || "Do you want to explore in a new way?",
14524
- yesLabel: P.yesLabel || "Yes",
14525
- laterLabel: P.laterLabel || "Later",
14526
- connectionTitle: P.connectionTitle || "How would you like to connect?",
14527
- connectionSubtitle: P.connectionSubtitle || "",
14528
- voiceLabel: P.voiceLabel || "Voice",
14529
- textLabel: P.textLabel || "Text",
14530
- chatTitle: P.headerName || "Chat with FlowEngage",
14531
- hasCustomTitle: !!(P.headerName && String(P.headerName).trim()),
14523
+ })(), Ke = Ge.length === 0 || Ge.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? Ue.startsWith(e.slice(0, -1)) : Ue.replace(/\/$/, "") === e.replace(/\/$/, "")), qe = xe.greetings?.[k] || Se.greetings?.[k] || F.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Je = {
14524
+ entryPrompt: F.entryPrompt || "Do you want to explore in a new way?",
14525
+ yesLabel: F.yesLabel || "Yes",
14526
+ laterLabel: F.laterLabel || "Later",
14527
+ connectionTitle: F.connectionTitle || "How would you like to connect?",
14528
+ connectionSubtitle: F.connectionSubtitle || "",
14529
+ voiceLabel: F.voiceLabel || "Voice",
14530
+ textLabel: F.textLabel || "Text",
14531
+ chatTitle: F.headerName || "Chat with FlowEngage",
14532
+ hasCustomTitle: !!(F.headerName && String(F.headerName).trim()),
14532
14533
  introGreeting: qe,
14533
- inputPlaceholder: P.inputPlaceholder || "Type your message",
14534
- analysingLabel: P.analysingLabel || "analysing..."
14535
- }, Ye = Ce.elevenLabsAgentId || t?.elevenLabsAgentId || null, B = t?.siteId || n?.siteId || null, V = t?.apiBaseUrl || "";
14534
+ inputPlaceholder: F.inputPlaceholder || "Type your message",
14535
+ analysingLabel: F.analysingLabel || "analysing..."
14536
+ }, Ye = Se.elevenLabsAgentId || t?.elevenLabsAgentId || null, B = t?.siteId || n?.siteId || null, V = t?.apiBaseUrl || "";
14536
14537
  c(() => {
14537
14538
  Kn(t?.siteType || null);
14538
14539
  }, [t?.siteType]);
@@ -14543,10 +14544,10 @@ function zg() {
14543
14544
  ]), Ze = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, Qe = r.some((e) => e.sender === "user"), $e = f(() => {
14544
14545
  let e = r.findIndex((e) => e.sender === "user");
14545
14546
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
14546
- }, [r]), et = !!(Ce._dashboardLivePreview || Se._dashboardLivePreview), [H, U] = m(() => et ? "text_chat" : "entry_prompt"), [tt, nt] = m(""), [rt, W] = m(null), [it, at] = m(h || ""), [G, 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 && Qe && $e && H !== "voice_mode";
14547
+ }, [r]), et = !!(Se._dashboardLivePreview || xe._dashboardLivePreview), [H, U] = m(() => et ? "text_chat" : "entry_prompt"), [tt, nt] = m(""), [rt, W] = m(null), [it, at] = m(h || ""), [G, 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 && Qe && $e && H !== "voice_mode";
14547
14548
  d(() => {
14548
14549
  if (e !== "ready" || wt.current) return;
14549
- if (wt.current = !0, !Oe) {
14550
+ if (wt.current = !0, !De) {
14550
14551
  U("minimized_orb");
14551
14552
  return;
14552
14553
  }
@@ -14554,12 +14555,12 @@ function zg() {
14554
14555
  try {
14555
14556
  t = vr().shouldResumeVoice;
14556
14557
  } catch {}
14557
- let n = De(), r = B ? we(B) : null, i = n || !!r?.transcript;
14558
+ let n = Ee(), r = B ? Ce(B) : null, i = n || !!r?.transcript;
14558
14559
  if (t) {
14559
- ae?.({ notifyChatInitiated: !0 }), se?.(!0), U("voice_mode");
14560
+ ae?.({ notifyChatInitiated: !0 }), j?.(!0), U("voice_mode");
14560
14561
  return;
14561
14562
  }
14562
- if (ke()) {
14563
+ if (Oe()) {
14563
14564
  ae?.({ notifyChatInitiated: !1 }), U("text_chat");
14564
14565
  return;
14565
14566
  }
@@ -14568,13 +14569,13 @@ function zg() {
14568
14569
  U("minimized_orb");
14569
14570
  return;
14570
14571
  }
14571
- ae?.({ notifyChatInitiated: !0 }), se?.(!0), U("voice_mode");
14572
+ ae?.({ notifyChatInitiated: !0 }), j?.(!0), U("voice_mode");
14572
14573
  return;
14573
14574
  }
14574
14575
  if (B) try {
14575
- Te(B);
14576
+ we(B);
14576
14577
  } catch {}
14577
- if (ce(B)) {
14578
+ if (se(B)) {
14578
14579
  U("minimized_orb");
14579
14580
  return;
14580
14581
  }
@@ -14632,7 +14633,7 @@ function zg() {
14632
14633
  hasIncomingCall: !!w?.callId,
14633
14634
  activeCallId: T,
14634
14635
  callConnectionState: E
14635
- }), Ct.current = e, H === "voice_mode" && se?.(!1), ae?.(), At());
14636
+ }), Ct.current = e, H === "voice_mode" && j?.(!1), ae?.(), At());
14636
14637
  }
14637
14638
  }, [
14638
14639
  T,
@@ -14641,7 +14642,7 @@ function zg() {
14641
14642
  w?.callId,
14642
14643
  i,
14643
14644
  ae,
14644
- se,
14645
+ j,
14645
14646
  H
14646
14647
  ]), c(() => {
14647
14648
  !w && !T && H === "call_screen" && U("text_chat");
@@ -14653,16 +14654,16 @@ function zg() {
14653
14654
  !T && yt && bt(!1);
14654
14655
  }, [T, yt]), c(() => {
14655
14656
  if (!s || C) {
14656
- _e?.(""), ge?.();
14657
+ ge?.(""), he?.();
14657
14658
  return;
14658
14659
  }
14659
14660
  if (!tt.trim() || pt) {
14660
- _e?.("");
14661
- let e = window.setTimeout(() => ge?.(), 100);
14661
+ ge?.("");
14662
+ let e = window.setTimeout(() => he?.(), 100);
14662
14663
  return () => window.clearTimeout(e);
14663
14664
  }
14664
- he?.();
14665
- let e = window.setTimeout(() => _e?.(tt), 120), t = window.setTimeout(() => ge?.(), 1200);
14665
+ me?.();
14666
+ let e = window.setTimeout(() => ge?.(tt), 120), t = window.setTimeout(() => he?.(), 1200);
14666
14667
  return () => {
14667
14668
  window.clearTimeout(e), window.clearTimeout(t);
14668
14669
  };
@@ -14671,9 +14672,9 @@ function zg() {
14671
14672
  pt,
14672
14673
  s,
14673
14674
  C,
14675
+ me,
14674
14676
  he,
14675
- ge,
14676
- _e
14677
+ ge
14677
14678
  ]);
14678
14679
  let Mt = (e) => e ? {
14679
14680
  replyTo: e.messageId || e.id || null,
@@ -14715,8 +14716,8 @@ function zg() {
14715
14716
  let n = tt.trim();
14716
14717
  nt(""), W(null), await A(n, "", t);
14717
14718
  }, Pt = o(() => {
14718
- r.length !== 0 && M?.();
14719
- }, [r.length, M]), Ft = (e) => {
14719
+ r.length !== 0 && N?.();
14720
+ }, [r.length, N]), Ft = (e) => {
14720
14721
  let t = Math.floor(e / 60);
14721
14722
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
14722
14723
  }, It = o(async (e) => {
@@ -14772,13 +14773,13 @@ function zg() {
14772
14773
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
14773
14774
  }
14774
14775
  } catch {}
14775
- ae({ notifyChatInitiated: !0 }), se?.(!0), U("voice_mode");
14776
+ ae({ notifyChatInitiated: !0 }), j?.(!0), U("voice_mode");
14776
14777
  }, Vt = () => {
14777
- ae({ notifyChatInitiated: !0 }), se?.(!1), U("text_chat");
14778
+ ae({ notifyChatInitiated: !0 }), j?.(!1), U("text_chat");
14778
14779
  }, Ht = () => {
14779
- se?.(!1), Rt();
14780
+ j?.(!1), Rt();
14780
14781
  };
14781
- return e !== "ready" || !He || Ee.chat === !1 || !Ke ? null : /* @__PURE__ */ _("div", {
14782
+ return e !== "ready" || !He || Te.chat === !1 || !Ke ? null : /* @__PURE__ */ _("div", {
14782
14783
  className: "flowengage-widget-root",
14783
14784
  style: {
14784
14785
  position: "fixed",
@@ -14790,13 +14791,13 @@ function zg() {
14790
14791
  children: [
14791
14792
  H === "entry_prompt" && /* @__PURE__ */ g(Ng, {
14792
14793
  copy: Je,
14793
- orbColors: I,
14794
- primaryColor: Ae,
14794
+ orbColors: L,
14795
+ primaryColor: ke,
14795
14796
  onYes: () => {
14796
- le(B), Bt();
14797
+ ce(B), Bt();
14797
14798
  },
14798
14799
  onLater: () => {
14799
- le(B), Rt();
14800
+ ce(B), Rt();
14800
14801
  },
14801
14802
  isMobile: Et,
14802
14803
  isClosing: xt
@@ -14872,15 +14873,15 @@ function zg() {
14872
14873
  })]
14873
14874
  })]
14874
14875
  }), /* @__PURE__ */ g(Mg, {
14875
- size: L,
14876
- orbColors: I,
14877
- onClick: T ? At : Oe ? zt : Vt
14876
+ size: je,
14877
+ orbColors: L,
14878
+ onClick: T ? At : De ? zt : Vt
14878
14879
  })]
14879
14880
  }),
14880
14881
  H === "connection_modal" && /* @__PURE__ */ g(Pg, {
14881
14882
  copy: Je,
14882
- orbColors: I,
14883
- primaryColor: Ae,
14883
+ orbColors: L,
14884
+ primaryColor: ke,
14884
14885
  onVoice: Bt,
14885
14886
  onText: Vt,
14886
14887
  onClose: Rt,
@@ -14888,7 +14889,7 @@ function zg() {
14888
14889
  isClosing: xt
14889
14890
  }),
14890
14891
  H === "voice_mode" && /* @__PURE__ */ g(Fg, {
14891
- orbColors: I,
14892
+ orbColors: L,
14892
14893
  onEnterChat: Vt,
14893
14894
  onEndChat: Ht,
14894
14895
  agentId: Ye,
@@ -14897,16 +14898,16 @@ function zg() {
14897
14898
  chatId: te,
14898
14899
  historyRef: ne,
14899
14900
  onMessageSync: re,
14900
- voiceEndCounter: xe,
14901
+ voiceEndCounter: be,
14901
14902
  websiteName: t?.websiteName,
14902
- voiceFirstMessage: Se.voiceFirstMessage || null,
14903
+ voiceFirstMessage: xe.voiceFirstMessage || null,
14903
14904
  captureVisitorEmail: oe,
14904
14905
  emailRequired: !h,
14905
- emailCaptureEnabled: P.disableEmailCapture !== !0,
14906
- listeningLabel: P.voiceListeningLabel || "Listening...",
14907
- thinkingLabel: P.voiceThinkingLabel || "Thinking...",
14908
- enterChatModeLabel: P.voiceEnterChatLabel || "Enter Chat Mode",
14909
- endConversationLabel: P.voiceEndConversationLabel || "End Conversation"
14906
+ emailCaptureEnabled: F.disableEmailCapture !== !0,
14907
+ listeningLabel: F.voiceListeningLabel || "Listening...",
14908
+ thinkingLabel: F.voiceThinkingLabel || "Thinking...",
14909
+ enterChatModeLabel: F.voiceEnterChatLabel || "Enter Chat Mode",
14910
+ endConversationLabel: F.voiceEndConversationLabel || "End Conversation"
14910
14911
  }, "voice"),
14911
14912
  H === "call_screen" && /* @__PURE__ */ g(Nh, {
14912
14913
  incomingCall: w,
@@ -14917,21 +14918,21 @@ function zg() {
14917
14918
  agentName: Xe,
14918
14919
  agentHeadshot: Ze,
14919
14920
  fallbackAgentName: R,
14920
- acceptCall: ue,
14921
- rejectCall: de,
14922
- endWebRTCCall: fe,
14923
- toggleCallMute: pe,
14921
+ acceptCall: le,
14922
+ rejectCall: ue,
14923
+ endWebRTCCall: de,
14924
+ toggleCallMute: fe,
14924
14925
  formatCallDuration: Ft,
14925
14926
  onMinimize: jt,
14926
- primaryColor: Ae,
14927
- orbColors: I,
14927
+ primaryColor: ke,
14928
+ orbColors: L,
14928
14929
  chatHistory: r
14929
14930
  }),
14930
14931
  H === "text_chat" && /* @__PURE__ */ g(Rg, {
14931
14932
  isClosing: xt,
14932
14933
  copy: Je,
14933
- orbColors: I,
14934
- primaryColor: Ae,
14934
+ orbColors: L,
14935
+ primaryColor: ke,
14935
14936
  chatBgGradient: Ne,
14936
14937
  logo: Pe,
14937
14938
  quickChatOptions: Le,
@@ -14966,16 +14967,16 @@ function zg() {
14966
14967
  webRTCError: O,
14967
14968
  micError: dt,
14968
14969
  setMicError: ft,
14969
- dismissCallError: me,
14970
+ dismissCallError: pe,
14970
14971
  activeCallId: T,
14971
14972
  isCallMuted: ee,
14972
- toggleCallMute: pe,
14973
- endWebRTCCall: fe,
14973
+ toggleCallMute: fe,
14974
+ endWebRTCCall: de,
14974
14975
  formatCallDuration: Ft,
14975
14976
  callDurationSeconds: lt,
14976
14977
  onCollapse: Rt,
14977
14978
  onStartVoice: Bt,
14978
- voiceEnabled: Oe,
14979
+ voiceEnabled: De,
14979
14980
  onNewChat: Pt,
14980
14981
  onMinimize: jt,
14981
14982
  onExpand: At,
@@ -14983,9 +14984,9 @@ function zg() {
14983
14984
  showPoweredBy: Re,
14984
14985
  privacyPolicyUrl: Ve,
14985
14986
  headerBgColor: ze,
14986
- getVisitorChatHistory: N,
14987
- resumeChat: ve,
14988
- isSessionRestoring: ye
14987
+ getVisitorChatHistory: P,
14988
+ resumeChat: _e,
14989
+ isSessionRestoring: ve
14989
14990
  }),
14990
14991
  /* @__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 " })
14991
14992
  ]