@flowengage/react-chatbot 8.0.70 → 8.0.71

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.
@@ -26,7 +26,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
26
26
  }, D = (e, t) => {
27
27
  let n = Number.parseInt(String(e ?? ""), 10);
28
28
  return Number.isFinite(n) && n > 0 ? n : t;
29
- }, O = D(void 0, 1e4), k = D(void 0, 15e3), A = {
29
+ }, ee = D(void 0, 1e4), O = D(void 0, 15e3), k = {
30
30
  chatId: "flowengage.chatId",
31
31
  isOpen: "flowengage.isOpen",
32
32
  activeScreen: "flowengage.activeScreen",
@@ -34,29 +34,29 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
34
34
  agentName: "flowengage.agentName",
35
35
  agentHeadshot: "flowengage.agentHeadshot",
36
36
  visitorEmail: "flowengage.visitorEmail"
37
- }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", re = (e) => e ? `flowengage.visitorEmail.${e}` : null, ie = () => {
38
- if (!j) return null;
39
- let e = window.localStorage.getItem(A.chatId);
37
+ }, te = 6e4, ne = 480 * 60, re = 3e4, A = typeof window < "u", ie = (e) => e ? `flowengage.visitorEmail.${e}` : null, j = () => {
38
+ if (!A) return null;
39
+ let e = window.localStorage.getItem(k.chatId);
40
40
  return e && String(e).trim() ? String(e).trim() : null;
41
- }, M = () => {
42
- if (j) try {
43
- window.localStorage.removeItem(A.chatId);
41
+ }, ae = () => {
42
+ if (A) try {
43
+ window.localStorage.removeItem(k.chatId);
44
44
  } catch {}
45
- }, ae = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", oe = (e) => e ? `flowengage.entrySeen.${e}` : null, se = (e) => {
46
- if (!j || !e) return !1;
45
+ }, oe = () => 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
+ if (!A || !e) return !1;
47
47
  try {
48
- let t = oe(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
53
  }, ce = (e) => {
54
- if (!(!j || !e)) try {
55
- let t = oe(e);
54
+ if (!(!A || !e)) try {
55
+ let t = M(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
58
  }, le = (e) => e ? `flowengage.persistedChatId.${e}` : null, ue = (e) => {
59
- if (!j || !e) return null;
59
+ if (!A || !e) return null;
60
60
  try {
61
61
  let t = le(e), n = t ? window.localStorage.getItem(t) : null;
62
62
  return n && String(n).trim() ? String(n).trim() : null;
@@ -64,21 +64,21 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
64
64
  return null;
65
65
  }
66
66
  }, de = (e) => {
67
- if (!(!j || !e)) try {
67
+ if (!(!A || !e)) try {
68
68
  let t = le(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
71
  }, fe = (e, t) => {
72
- if (!(!j || !e || !t)) try {
72
+ if (!(!A || !e || !t)) try {
73
73
  let n = le(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
- }, pe = () => j ? {
76
+ }, pe = () => A ? {
77
77
  isOpen: !1,
78
- activeScreen: window.sessionStorage.getItem(A.activeScreen) || "ai",
79
- isHumanHandled: window.sessionStorage.getItem(A.isHumanHandled) === "true",
80
- agentName: window.sessionStorage.getItem(A.agentName),
81
- agentHeadshot: window.sessionStorage.getItem(A.agentHeadshot),
78
+ activeScreen: window.sessionStorage.getItem(k.activeScreen) || "ai",
79
+ isHumanHandled: window.sessionStorage.getItem(k.isHumanHandled) === "true",
80
+ agentName: window.sessionStorage.getItem(k.agentName),
81
+ agentHeadshot: window.sessionStorage.getItem(k.agentHeadshot),
82
82
  visitorEmail: ""
83
83
  } : {
84
84
  isOpen: !1,
@@ -88,8 +88,8 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
88
88
  agentHeadshot: null,
89
89
  visitorEmail: ""
90
90
  }, me = (e) => {
91
- j && Object.entries(e).forEach(([e, t]) => {
92
- let n = A[e];
91
+ A && Object.entries(e).forEach(([e, t]) => {
92
+ let n = k[e];
93
93
  if (n) {
94
94
  if (t == null || t === !1) {
95
95
  window.sessionStorage.removeItem(n);
@@ -99,25 +99,25 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
99
99
  }
100
100
  });
101
101
  }, he = (e) => {
102
- if (!j || !e) return "";
103
- let t = re(e), n = window.localStorage.getItem(t);
102
+ if (!A || !e) return "";
103
+ let t = ie(e), n = window.localStorage.getItem(t);
104
104
  if (!n) {
105
- let e = window.sessionStorage.getItem(A.visitorEmail);
106
- e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(A.visitorEmail), n = e);
105
+ let e = window.sessionStorage.getItem(k.visitorEmail);
106
+ e && (window.localStorage.setItem(t, e), window.sessionStorage.removeItem(k.visitorEmail), n = e);
107
107
  }
108
108
  return n || "";
109
109
  }, N = (e, t) => {
110
- if (!j) return;
111
- let n = re(t);
110
+ if (!A) return;
111
+ let n = ie(t);
112
112
  if (!n) return;
113
113
  let r = typeof e == "string" ? e.trim() : "";
114
114
  if (!r) {
115
- window.localStorage.removeItem(n), window.sessionStorage.removeItem(A.visitorEmail);
115
+ window.localStorage.removeItem(n), window.sessionStorage.removeItem(k.visitorEmail);
116
116
  return;
117
117
  }
118
- window.localStorage.setItem(n, r), window.sessionStorage.removeItem(A.visitorEmail);
118
+ window.localStorage.setItem(n, r), window.sessionStorage.removeItem(k.visitorEmail);
119
119
  }, ge = (e) => e ? `flowengage.visitorId.${e}` : null, _e = () => `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) => {
120
- if (!j || !e) return null;
120
+ if (!A || !e) return null;
121
121
  try {
122
122
  let t = ge(e), n = t ? window.localStorage.getItem(t) : null;
123
123
  return n && String(n).trim() ? String(n).trim() : null;
@@ -125,7 +125,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
125
125
  return null;
126
126
  }
127
127
  }, ye = (e) => {
128
- if (!j || !e) return null;
128
+ if (!A || !e) return null;
129
129
  try {
130
130
  let t = ve(e);
131
131
  if (t) return t;
@@ -135,7 +135,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
135
135
  return _e();
136
136
  }
137
137
  }, be = "flowengage.tabId", xe = () => {
138
- if (!j) return "default";
138
+ if (!A) return "default";
139
139
  try {
140
140
  let e = window.sessionStorage.getItem(be);
141
141
  return e || (e = typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID().replace(/-/g, "").slice(0, 12) : Math.random().toString(36).slice(2, 14), window.sessionStorage.setItem(be, e)), e;
@@ -143,7 +143,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
143
143
  return "default";
144
144
  }
145
145
  }, Se = (e) => e ? `flowengage.voice.transcript.${e}.${xe()}` : null, Ce = 600 * 1e3, P = (e, t, n = {}) => {
146
- if (!j || !e) return;
146
+ if (!A || !e) return;
147
147
  let r = typeof t == "string" ? t.trim() : "";
148
148
  if (!r) return;
149
149
  let i = Number.isFinite(n.ttlMs) ? n.ttlMs : Ce, a = {
@@ -155,7 +155,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
155
155
  t && window.localStorage.setItem(t, JSON.stringify(a));
156
156
  } catch {}
157
157
  }, we = (e) => {
158
- if (!j || !e) return null;
158
+ if (!A || !e) return null;
159
159
  try {
160
160
  let t = Se(e), n = t ? window.localStorage.getItem(t) : null;
161
161
  if (!n) return null;
@@ -165,41 +165,41 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
165
165
  return null;
166
166
  }
167
167
  }, Te = (e) => {
168
- if (!(!j || !e)) try {
168
+ if (!(!A || !e)) try {
169
169
  let t = Se(e);
170
170
  t && window.localStorage.removeItem(t);
171
171
  } catch {}
172
172
  }, F = "flowengage.voice.pendingResume", Ee = () => {
173
- if (j) try {
173
+ if (A) try {
174
174
  window.sessionStorage.setItem(F, "1");
175
175
  } catch {}
176
176
  }, De = () => {
177
- if (!j) return !1;
177
+ if (!A) return !1;
178
178
  try {
179
179
  return window.sessionStorage.getItem(F) === "1" ? (window.sessionStorage.removeItem(F), !0) : !1;
180
180
  } catch {
181
181
  return !1;
182
182
  }
183
183
  }, Oe = "flowengage.chat.pendingReopen", I = () => {
184
- if (j) try {
184
+ if (A) try {
185
185
  window.sessionStorage.setItem(Oe, "1");
186
186
  } catch {}
187
187
  }, ke = () => {
188
- if (!j) return !1;
188
+ if (!A) return !1;
189
189
  try {
190
190
  return window.sessionStorage.getItem(Oe) === "1" ? (window.sessionStorage.removeItem(Oe), !0) : !1;
191
191
  } catch {
192
192
  return !1;
193
193
  }
194
194
  }, Ae = () => {
195
- if (!j) return !1;
195
+ if (!A) return !1;
196
196
  try {
197
197
  return window.sessionStorage.getItem(F) === "1";
198
198
  } catch {
199
199
  return !1;
200
200
  }
201
201
  }, je = (e) => e ? `flowengage.voice.navState.${e}.${xe()}` : null, Me = (e, t, n, r) => {
202
- if (!(!j || !e || !t)) try {
202
+ if (!(!A || !e || !t)) try {
203
203
  let i = je(e);
204
204
  i && window.sessionStorage.setItem(i, JSON.stringify({
205
205
  previousPage: String(t),
@@ -209,7 +209,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
209
209
  }));
210
210
  } catch {}
211
211
  }, Ne = (e) => {
212
- if (!j || !e) return null;
212
+ if (!A || !e) return null;
213
213
  try {
214
214
  let t = je(e);
215
215
  if (!t) return null;
@@ -1951,7 +1951,7 @@ var bn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => yn(e, {
1951
1951
  timestamp: Date.now()
1952
1952
  });
1953
1953
  }, u = () => {
1954
- i && window.clearInterval(i), i = window.setInterval(l, O);
1954
+ i && window.clearInterval(i), i = window.setInterval(l, ee);
1955
1955
  }, d = () => {
1956
1956
  i &&= (window.clearInterval(i), null);
1957
1957
  }, f = (r) => {
@@ -1969,7 +1969,7 @@ var bn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => yn(e, {
1969
1969
  if (document.hidden) {
1970
1970
  a && window.clearTimeout(a), a = window.setTimeout(() => {
1971
1971
  a = null, d(), f("hidden");
1972
- }, k);
1972
+ }, O);
1973
1973
  return;
1974
1974
  }
1975
1975
  a &&= (window.clearTimeout(a), null), f("visible"), l(), u();
@@ -2001,7 +2001,7 @@ var bn = ({ apiBaseUrl: e, userId: t, chatId: n, siteId: r }) => yn(e, {
2001
2001
  };
2002
2002
  return window.addEventListener("popstate", m), window.addEventListener("hashchange", m), window.addEventListener("beforeunload", v), window.addEventListener("pagehide", y), window.addEventListener("visibilitychange", p), o(), document.hidden ? a = window.setTimeout(() => {
2003
2003
  a = null, d(), f("hidden");
2004
- }, k) : (l(), u()), {
2004
+ }, O) : (l(), u()), {
2005
2005
  notifyRouteChange: m,
2006
2006
  cleanup: () => {
2007
2007
  a &&= (window.clearTimeout(a), null), d(), window.history.pushState = h, window.history.replaceState = g, window.removeEventListener("popstate", m), window.removeEventListener("hashchange", m), window.removeEventListener("beforeunload", v), window.removeEventListener("pagehide", y), window.removeEventListener("visibilitychange", p);
@@ -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), [O, k] = m(pe().activeScreen), [A, j] = m(pe().isHumanHandled), [re, oe] = m(pe().agentName), [se, ce] = m(pe().agentHeadshot), [le, ge] = m(() => he(i?.siteId)), [_e, 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), [Me, Ne] = m(0), [Pe, L] = m(!1), [R, Re] = m(null), [ze, Be] = m(null), [Ve, He] = m("idle"), [Ue, We] = m(null), [Ge, Ke] = m(!1), [qe, Je] = m(""), [Ye, Xe] = m(!1), z = p(null), B = p(null), Ze = p(""), Qe = p(!1), $e = p(null), et = p(null), tt = p(null), V = p(null), H = p(null), nt = p(null), rt = p(null), it = p(!1), U = p({
2922
+ }, []), [T, D] = m(pe().isOpen), [ee, O] = m(pe().activeScreen), [k, A] = m(pe().isHumanHandled), [ie, M] = m(pe().agentName), [se, ce] = m(pe().agentHeadshot), [le, ge] = m(() => he(i?.siteId)), [_e, 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), [Me, Ne] = m(0), [Pe, L] = m(!1), [R, Re] = m(null), [ze, Be] = m(null), [Ve, He] = m("idle"), [Ue, We] = m(null), [Ge, Ke] = m(!1), [qe, Je] = m(""), [Ye, Xe] = m(!1), z = p(null), B = p(null), Ze = p(""), Qe = p(!1), $e = p(null), et = p(null), tt = p(null), V = p(null), H = p(null), nt = p(null), rt = p(null), it = p(!1), U = p({
2923
2923
  url: null,
2924
2924
  at: 0
2925
2925
  }), at = o((e, t) => {
@@ -2935,21 +2935,21 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
2935
2935
  url: n,
2936
2936
  at: Date.now()
2937
2937
  }, br(e, t));
2938
- }, []), ot = p([]), W = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(re), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
2938
+ }, []), ot = p([]), W = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(ie), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
2939
2939
  notifyRouteChange: () => {},
2940
2940
  cleanup: () => {}
2941
2941
  }), St = o((e = {}) => {
2942
2942
  let t = !!e.is_human_handled;
2943
- return j(t), t ? (k("agent"), e.agent_info?.name && oe(e.agent_info.name), e.agent_info?.headshot && ce(e.agent_info.headshot), t) : (k("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
  }, []), Ct = f(() => {
2945
2945
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
2946
- return Number.isFinite(t) && t > 0 ? t : te;
2946
+ return Number.isFinite(t) && t > 0 ? t : ne;
2947
2947
  }, [i, _]);
2948
2948
  c(() => {
2949
2949
  et.current = R;
2950
2950
  }, [R]), c(() => {
2951
- gt.current = re;
2952
- }, [re]), c(() => {
2951
+ gt.current = ie;
2952
+ }, [ie]), c(() => {
2953
2953
  yt.current = I;
2954
2954
  }, [I]), c(() => {
2955
2955
  bt.current = i;
@@ -3102,16 +3102,16 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3102
3102
  c(() => {
3103
3103
  me({
3104
3104
  isOpen: T,
3105
- activeScreen: O,
3106
- isHumanHandled: A,
3107
- agentName: re,
3105
+ activeScreen: ee,
3106
+ isHumanHandled: k,
3107
+ agentName: ie,
3108
3108
  agentHeadshot: se
3109
3109
  });
3110
3110
  }, [
3111
3111
  T,
3112
- O,
3113
- A,
3114
- re,
3112
+ ee,
3113
+ k,
3114
+ ie,
3115
3115
  se
3116
3116
  ]), c(() => {
3117
3117
  let e = !0;
@@ -3127,14 +3127,14 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3127
3127
  apiBaseUrl: t.apiBaseUrl,
3128
3128
  userId: n.userId,
3129
3129
  siteId: a,
3130
- priorChatId: e || r ? null : o || ie(),
3130
+ priorChatId: e || r ? null : o || j(),
3131
3131
  forceNew: e,
3132
3132
  resumeChatId: r,
3133
3133
  visitorId: s
3134
3134
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3135
- M(), fe(a, c);
3135
+ ae(), fe(a, c);
3136
3136
  } catch (e) {
3137
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ae(), fe(a, c);
3137
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || oe(), fe(a, c);
3138
3138
  }
3139
3139
  Ze.current = c;
3140
3140
  let l = Le({
@@ -3200,7 +3200,7 @@ 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) && (j(!0), k("agent"), oe(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
@@ -3213,7 +3213,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3213
3213
  e.agent_name,
3214
3214
  gt.current
3215
3215
  ], d);
3216
- j(!0), k("agent"), oe(t), ce(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), je((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.`,
@@ -3227,7 +3227,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3227
3227
  e.agent_name,
3228
3228
  gt.current
3229
3229
  ], d);
3230
- j(!1), k("ai"), S((e) => jr(e, {
3230
+ A(!1), O("ai"), S((e) => jr(e, {
3231
3231
  id: `agent-left-${Date.now()}`,
3232
3232
  sender: "system",
3233
3233
  message: `${t} has left the chat.`,
@@ -3247,9 +3247,9 @@ 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 && (L(!1), j(!1), k("ai"), xe(!1), ve(!1));
3250
+ S(t), t.length === 0 && (L(!1), A(!1), O("ai"), xe(!1), ve(!1));
3251
3251
  }), f.on("conversation:reset", () => {
3252
- S([]), L(!1), j(!1), k("ai"), xe(!1), ve(!1);
3252
+ S([]), L(!1), A(!1), O("ai"), xe(!1), ve(!1);
3253
3253
  }), f.on("voice:end_session", (e = {}) => {
3254
3254
  console.log("[FlowEngageProvider] voice:end_session received — ending voice session"), Ne((e) => e + 1), D(!0), je((e) => e + 1);
3255
3255
  }), f.on("typing:start", (e) => {
@@ -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
- }), oe((e) => Ar([t, e], "Agent")), He("incoming"), We(null), D(!0);
3271
+ }), M((e) => Ar([t, e], "Agent")), He("incoming"), We(null), D(!0);
3272
3272
  }), f.on("call:offer", async (e = {}) => {
3273
3273
  nt.current = e;
3274
3274
  try {
@@ -3343,7 +3343,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3343
3343
  });
3344
3344
  let h = await l.loadHistory(c, r);
3345
3345
  if (!e) return;
3346
- S(Er(h.chat_history || [])), j(!!h.is_human_handled), k(h.is_human_handled ? "agent" : O);
3346
+ S(Er(h.chat_history || [])), A(!!h.is_human_handled), O(h.is_human_handled ? "agent" : ee);
3347
3347
  let g = h?.visitor_email || h?.visitorEmail;
3348
3348
  if (g && String(g).trim() && Et(String(g).trim()), await new Promise((e) => setTimeout(e, 500)), !e) return;
3349
3349
  u("ready");
@@ -3499,7 +3499,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3499
3499
  let e = R.callId;
3500
3500
  return Tt(), ct.current = window.setTimeout(() => {
3501
3501
  et.current?.callId === e && st.current !== e && W.current !== e && Pt.current();
3502
- }, ne), () => {
3502
+ }, re), () => {
3503
3503
  ct.current &&= (window.clearTimeout(ct.current), null);
3504
3504
  };
3505
3505
  }, [
@@ -3611,7 +3611,7 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3611
3611
  ...n || {}
3612
3612
  };
3613
3613
  S((e) => [...e, d]);
3614
- let f = A;
3614
+ let f = k;
3615
3615
  if (f) try {
3616
3616
  f = St(await B.current.checkHumanHandled(y));
3617
3617
  } catch {}
@@ -3700,11 +3700,11 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3700
3700
  });
3701
3701
  }
3702
3702
  }
3703
- S(Er(s)), j(!!o.is_human_handled), k(o.is_human_handled ? "agent" : "ai"), xe(!1), we(!1), await B.current.updateChatStatus(y, "messageSent");
3703
+ S(Er(s)), A(!!o.is_human_handled), O(o.is_human_handled ? "agent" : "ai"), xe(!1), we(!1), await B.current.updateChatStatus(y, "messageSent");
3704
3704
  } catch (e) {
3705
3705
  S((e) => e.filter((e) => e.id !== u)), xe(!1), we(!1), e.status === 429 ? (F(!0), Oe(e.message), window.setTimeout(() => {
3706
3706
  F(!1), Oe("");
3707
- }, ee)) : h(e);
3707
+ }, te)) : h(e);
3708
3708
  }
3709
3709
  }, Wt = async (e) => {
3710
3710
  if (!B.current || !e) throw Error("Upload is unavailable right now.");
@@ -3795,9 +3795,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3795
3795
  }, []);
3796
3796
  let Jt = o(() => {
3797
3797
  let e = i?.siteId;
3798
- de(e), Qe.current = !0, $e.current = null, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), j(!1), oe(null), ce(null), Xe(!0), s((e) => e + 1);
3798
+ de(e), Qe.current = !0, $e.current = null, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), A(!1), M(null), ce(null), Xe(!0), s((e) => e + 1);
3799
3799
  }, [i?.siteId]), Yt = o((e) => {
3800
- i?.siteId, Qe.current = !1, $e.current = e, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), j(!1), oe(null), ce(null), Xe(!0), s((e) => e + 1);
3800
+ i?.siteId, Qe.current = !1, $e.current = e, z.current?.disconnect(), S([]), b(""), Ze.current = "", L(!1), A(!1), M(null), ce(null), Xe(!0), s((e) => e + 1);
3801
3801
  }, [i?.siteId]), Xt = f(() => ({
3802
3802
  status: l,
3803
3803
  error: d,
@@ -3806,9 +3806,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3806
3806
  chatId: y,
3807
3807
  chatHistory: x,
3808
3808
  isOpen: T,
3809
- activeScreen: O,
3810
- isHumanHandled: A,
3811
- agentName: re,
3809
+ activeScreen: ee,
3810
+ isHumanHandled: k,
3811
+ agentName: ie,
3812
3812
  agentHeadshot: se,
3813
3813
  visitorEmail: le,
3814
3814
  isAgentTyping: _e,
@@ -3867,9 +3867,9 @@ function Mr({ siteId: e, config: t, children: n, language: r = "en" }) {
3867
3867
  y,
3868
3868
  x,
3869
3869
  T,
3870
- O,
3871
- A,
3872
- re,
3870
+ ee,
3871
+ k,
3872
+ ie,
3873
3873
  se,
3874
3874
  le,
3875
3875
  _e,
@@ -8845,32 +8845,45 @@ function Dm(e) {
8845
8845
  for (let n = 0; n < e.length; n++) t[n] = e[n] / 32768;
8846
8846
  return t;
8847
8847
  }
8848
- var Om = .09;
8849
- function km(e, t) {
8850
- let n = 0, r = 0, i = [], a = () => {
8851
- i.forEach((e) => {
8848
+ var Om = .09, km = ["audio/webm", "audio/mp4"];
8849
+ function Am() {
8850
+ return typeof window > "u" || window.MediaRecorder === void 0 ? null : km.find((e) => window.MediaRecorder.isTypeSupported(e)) || null;
8851
+ }
8852
+ function jm(e, t, n, r, i) {
8853
+ if (!r.length || !n || !e) return;
8854
+ let a = new Blob(r, { type: i }), o = new FormData();
8855
+ o.append("audio", a, `aichat-${n}.webm`), o.append("voiceSessionId", n), o.append("siteId", t || ""), fetch(`${e}/api/voice/upload-chat-recording`, {
8856
+ method: "POST",
8857
+ body: o
8858
+ }).then((e) => {
8859
+ if (!e.ok) throw Error(`HTTP ${e.status}`);
8860
+ }).catch((e) => console.warn("[FlowEngage] voice recording upload failed:", e.message));
8861
+ }
8862
+ function Mm(e, t, n) {
8863
+ let r = 0, i = 0, a = [], o = () => {
8864
+ a.forEach((e) => {
8852
8865
  try {
8853
8866
  e.stop();
8854
8867
  } catch {}
8855
- }), i = [], n = 0;
8856
- }, o = () => n > e.currentTime;
8868
+ }), a = [], r = 0;
8869
+ }, s = () => r > e.currentTime;
8857
8870
  return {
8858
- enqueue: (a) => {
8859
- let s = Dm(a), c = e.createBuffer(1, s.length, bm);
8860
- c.copyToChannel(s, 0);
8861
- let l = e.createBufferSource();
8862
- l.buffer = c, l.connect(e.destination);
8863
- let u = !o(), d = u ? e.currentTime + Om : n;
8864
- u && (r = d), l.start(d), n = d + c.duration, i.push(l), l.onended = () => {
8865
- i = i.filter((e) => e !== l), !i.length && !o() && t?.();
8871
+ enqueue: (o) => {
8872
+ let c = Dm(o), l = e.createBuffer(1, c.length, bm);
8873
+ l.copyToChannel(c, 0);
8874
+ let u = e.createBufferSource();
8875
+ u.buffer = l, u.connect(e.destination), n && u.connect(n);
8876
+ let d = !s(), f = d ? e.currentTime + Om : r;
8877
+ d && (i = f), u.start(f), r = f + l.duration, a.push(u), u.onended = () => {
8878
+ a = a.filter((e) => e !== u), !a.length && !s() && t?.();
8866
8879
  };
8867
8880
  },
8868
- stop: a,
8869
- isPlaying: o,
8870
- playedMs: () => Math.max(0, (e.currentTime - r) * 1e3)
8881
+ stop: o,
8882
+ isPlaying: s,
8883
+ playedMs: () => Math.max(0, (e.currentTime - i) * 1e3)
8871
8884
  };
8872
8885
  }
8873
- async function Am(e, t, n) {
8886
+ async function Nm(e, t, n) {
8874
8887
  let r = new URLSearchParams({ siteId: t || "" });
8875
8888
  n && r.set("chatId", n);
8876
8889
  let i = await fetch(`${e}/api/voice/session?${r.toString()}`, {
@@ -8886,8 +8899,8 @@ async function Am(e, t, n) {
8886
8899
  if (!a?.success || !a.wsUrl) throw Error(a?.error || "Voice session was refused.");
8887
8900
  return a;
8888
8901
  }
8889
- async function jm(e) {
8890
- let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await Am(t, n, r);
8902
+ async function Pm(e) {
8903
+ let { apiBaseUrl: t, siteId: n, chatId: r, clientTools: i = {}, onConnect: a, onDisconnect: o, onMessage: s, onModeChange: c, onError: l, onUnhandledClientToolCall: u, onAgentTurnEnd: d, onSessionInfo: f, onSessionEnding: p } = e, m = await Nm(t, n, r);
8891
8904
  f?.({ emailOnFile: !!m.emailOnFile });
8892
8905
  let h = { type: "Start" };
8893
8906
  e.greeting !== void 0 && (h.greeting = e.greeting || null);
@@ -8898,23 +8911,27 @@ async function jm(e) {
8898
8911
  autoGainControl: !0
8899
8912
  } }), _ = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: bm });
8900
8913
  _.state === "suspended" && await _.resume();
8901
- let v = new WebSocket(m.wsUrl);
8902
- v.binaryType = "arraybuffer";
8903
- let y = /* @__PURE__ */ new Set(), b = {
8914
+ let v = _.createMediaStreamDestination(), y = Am(), b = [], x = null, S = r || n || null;
8915
+ y && (x = new window.MediaRecorder(v.stream, { mimeType: y }), x.ondataavailable = (e) => {
8916
+ e.data && e.data.size > 0 && b.push(e.data);
8917
+ }, x.start());
8918
+ let C = new WebSocket(m.wsUrl);
8919
+ C.binaryType = "arraybuffer";
8920
+ let w = /* @__PURE__ */ new Set(), T = {
8904
8921
  role: null,
8905
8922
  text: "",
8906
8923
  timer: null,
8907
8924
  debug: null
8908
- }, x = "", S = () => {
8909
- b.timer &&= (clearTimeout(b.timer), null);
8910
- let e = b.text.trim(), t = b.role, n = b.debug;
8911
- if (b.text = "", b.role = null, b.debug = null, !(!e || !t)) {
8925
+ }, E = "", D = () => {
8926
+ T.timer &&= (clearTimeout(T.timer), null);
8927
+ let e = T.text.trim(), t = T.role, n = T.debug;
8928
+ if (T.text = "", T.role = null, T.debug = null, !(!e || !t)) {
8912
8929
  if (t === "agent") {
8913
- if (e === x) {
8930
+ if (e === E) {
8914
8931
  console.debug("[FlowEngage] duplicate agent turn suppressed");
8915
8932
  return;
8916
8933
  }
8917
- x = e;
8934
+ E = e;
8918
8935
  }
8919
8936
  s?.({
8920
8937
  role: t,
@@ -8922,61 +8939,71 @@ async function jm(e) {
8922
8939
  debug: n
8923
8940
  });
8924
8941
  }
8925
- }, C = (e, t, n) => {
8926
- t && (b.role && b.role !== e && S(), b.role = e, b.text = b.text ? `${b.text} ${t}`.replace(/\s+/g, " ") : t, n && (b.debug = n), b.timer && clearTimeout(b.timer), b.timer = setTimeout(S, Sm));
8927
- }, w = !1, T = !1, E = !1, D = !1, O = !0, k = 0, A = !1, ee = !1, te = Cm, ne = wm, j = null, re = !1, ie = () => {
8928
- j && clearTimeout(j);
8942
+ }, ee = (e, t, n) => {
8943
+ 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));
8944
+ }, O = !1, k = !1, te = !1, ne = !1, re = !0, A = 0, ie = !1, j = !1, ae = Cm, oe = wm, M = null, se = !1, ce = () => {
8945
+ M && clearTimeout(M);
8929
8946
  let e = () => {
8930
- if (!w) {
8931
- if (M.isPlaying()) {
8932
- j = setTimeout(e, 150);
8947
+ if (!O) {
8948
+ if (le.isPlaying()) {
8949
+ M = setTimeout(e, 150);
8933
8950
  return;
8934
8951
  }
8935
- if (j = null, re) {
8952
+ if (M = null, se) {
8936
8953
  p?.();
8937
8954
  return;
8938
8955
  }
8939
- !w && v.readyState === WebSocket.OPEN && v.send(JSON.stringify({ type: "PlaybackDrained" })), d?.();
8956
+ !O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), d?.();
8940
8957
  }
8941
8958
  };
8942
- j = setTimeout(e, 150);
8943
- }, M = km(_, () => {
8944
- D && (D = !1, c?.({ mode: "listening" }));
8945
- }), ae = _.createMediaStreamSource(g), oe = _.createScriptProcessor(xm, 1, 1);
8946
- oe.onaudioprocess = (e) => {
8947
- if (w || v.readyState !== WebSocket.OPEN) return;
8948
- let t = e.inputBuffer.getChannelData(0), n = () => v.send(new Int16Array(t.length).buffer);
8949
- if (T) {
8950
- E || (E = !0, console.debug("[FlowEngage] mic held streaming silence to keep socket alive")), n();
8959
+ M = setTimeout(e, 150);
8960
+ }, le = Mm(_, () => {
8961
+ ne && (ne = !1, c?.({ mode: "listening" }));
8962
+ }, v), ue = _.createMediaStreamSource(g);
8963
+ ue.connect(v);
8964
+ let de = _.createScriptProcessor(xm, 1, 1);
8965
+ de.onaudioprocess = (e) => {
8966
+ if (O || C.readyState !== WebSocket.OPEN) return;
8967
+ let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
8968
+ if (k) {
8969
+ te || (te = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), n();
8951
8970
  return;
8952
8971
  }
8953
- if ((M.isPlaying() || ee) && !A) {
8954
- if (Tm(t) < te) {
8955
- k = 0, n();
8972
+ if ((le.isPlaying() || j) && !ie) {
8973
+ if (Tm(t) < ae) {
8974
+ A = 0, n();
8956
8975
  return;
8957
8976
  }
8958
- if (k += 1, k < ne) {
8977
+ if (A += 1, A < oe) {
8959
8978
  n();
8960
8979
  return;
8961
8980
  }
8962
- A = !0, k = 0;
8963
- let e = M.playedMs();
8964
- M.stop(), O = !1, ee = !1, v.send(JSON.stringify({
8981
+ ie = !0, A = 0;
8982
+ let e = le.playedMs();
8983
+ le.stop(), re = !1, j = !1, C.send(JSON.stringify({
8965
8984
  type: "VisitorInterrupted",
8966
8985
  played_ms: Math.round(e)
8967
8986
  })), console.debug("[FlowEngage] barge-in — visitor spoke over the agent");
8968
8987
  }
8969
- v.send(Em(t).buffer);
8970
- }, ae.connect(oe), oe.connect(_.destination);
8971
- let se = () => {
8972
- if (!w) {
8973
- w = !0, j &&= (clearTimeout(j), null), S(), M.stop();
8988
+ C.send(Em(t).buffer);
8989
+ }, ue.connect(de), de.connect(_.destination);
8990
+ let fe = () => {
8991
+ if (!O) {
8992
+ O = !0, M &&= (clearTimeout(M), null), D(), le.stop();
8974
8993
  try {
8975
- oe.disconnect(), ae.disconnect();
8994
+ de.disconnect(), ue.disconnect();
8976
8995
  } catch {}
8977
- g.getTracks().forEach((e) => e.stop()), _.close().catch(() => {}), (v.readyState === WebSocket.OPEN || v.readyState === WebSocket.CONNECTING) && v.close();
8996
+ if (g.getTracks().forEach((e) => e.stop()), x && x.state !== "inactive") {
8997
+ x.onstop = () => jm(t, n, S, b, y);
8998
+ try {
8999
+ x.stop();
9000
+ } catch {
9001
+ x.onstop = null;
9002
+ }
9003
+ } else b.length && jm(t, n, S, b, y);
9004
+ _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
8978
9005
  }
8979
- }, ce = async (e) => {
9006
+ }, pe = async (e) => {
8980
9007
  let t = i[e.name];
8981
9008
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
8982
9009
  let n = {};
@@ -8988,29 +9015,29 @@ async function jm(e) {
8988
9015
  } catch (e) {
8989
9016
  return { error: e?.message || "Tool execution failed" };
8990
9017
  }
8991
- }, le = async (e) => {
9018
+ }, me = async (e) => {
8992
9019
  for (let t of e.functions || []) {
8993
9020
  if (!t.client_side) continue;
8994
- let e = await ce(t);
8995
- if (w || v.readyState !== WebSocket.OPEN) return;
8996
- v.send(JSON.stringify({
9021
+ let e = await pe(t);
9022
+ if (O || C.readyState !== WebSocket.OPEN) return;
9023
+ C.send(JSON.stringify({
8997
9024
  type: "FunctionCallResponse",
8998
9025
  id: t.id,
8999
9026
  name: t.name,
9000
9027
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
9001
9028
  }));
9002
9029
  }
9003
- }, ue = (e) => {
9030
+ }, he = (e) => {
9004
9031
  switch (e.type) {
9005
9032
  case "Welcome":
9006
- Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (te = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (ne = e.barge_in_frames), a?.({ conversationId: e.session_id || r || n });
9033
+ Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && (ae = e.barge_in_rms), Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && (oe = e.barge_in_frames), S = e.session_id || r || n || null, a?.({ conversationId: S });
9007
9034
  break;
9008
9035
  case "ConversationText": {
9009
9036
  let t = String(e.content || "");
9010
9037
  if (e.role === "user") {
9011
9038
  let e = t.trim();
9012
- if (y.has(e)) {
9013
- y.delete(e);
9039
+ if (w.has(e)) {
9040
+ w.delete(e);
9014
9041
  break;
9015
9042
  }
9016
9043
  if (/^\[SYSTEM:/i.test(e) || /^Continue (now )?to the next section/i.test(e) || /^That was the last section/i.test(e)) {
@@ -9018,26 +9045,26 @@ async function jm(e) {
9018
9045
  break;
9019
9046
  }
9020
9047
  }
9021
- C(e.role === "user" ? "user" : "agent", t, e.debug);
9048
+ ee(e.role === "user" ? "user" : "agent", t, e.debug);
9022
9049
  break;
9023
9050
  }
9024
9051
  case "UserStartedSpeaking":
9025
- S(), M.stop(), ee = !1, O = !1, D = !1, c?.({ mode: "listening" });
9052
+ D(), le.stop(), j = !1, re = !1, ne = !1, c?.({ mode: "listening" });
9026
9053
  break;
9027
9054
  case "AgentStartedSpeaking":
9028
- O = !0, D = !0, A = !1, k = 0, c?.({ mode: "speaking" });
9055
+ re = !0, ne = !0, ie = !1, A = 0, c?.({ mode: "speaking" });
9029
9056
  break;
9030
9057
  case "AgentAudioDone":
9031
- ee = !1, S(), ie(), M.isPlaying() || (D = !1, c?.({ mode: "listening" }));
9058
+ j = !1, D(), ce(), le.isPlaying() || (ne = !1, c?.({ mode: "listening" }));
9032
9059
  break;
9033
9060
  case "FunctionCallRequest":
9034
- le(e);
9061
+ me(e);
9035
9062
  break;
9036
9063
  case "AgentPreparing":
9037
- ee = !0;
9064
+ j = !0;
9038
9065
  break;
9039
9066
  case "SessionEnding":
9040
- console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), re = !0;
9067
+ console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), se = !0;
9041
9068
  break;
9042
9069
  case "PromptUpdated":
9043
9070
  case "AgentThinking": break;
@@ -9050,56 +9077,56 @@ async function jm(e) {
9050
9077
  default: break;
9051
9078
  }
9052
9079
  };
9053
- return v.onopen = () => v.send(JSON.stringify(h)), v.onmessage = (e) => {
9080
+ return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9054
9081
  if (e.data instanceof ArrayBuffer) {
9055
- O && M.enqueue(new Int16Array(e.data));
9082
+ re && le.enqueue(new Int16Array(e.data));
9056
9083
  return;
9057
9084
  }
9058
9085
  try {
9059
- ue(JSON.parse(e.data));
9086
+ he(JSON.parse(e.data));
9060
9087
  } catch {}
9061
- }, v.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), v.onclose = () => {
9062
- se(), o?.();
9088
+ }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9089
+ fe(), o?.();
9063
9090
  }, {
9064
- endSession: async () => se(),
9091
+ endSession: async () => fe(),
9065
9092
  sendContextualUpdate: (e) => {
9066
- w || v.readyState !== WebSocket.OPEN || !e || v.send(JSON.stringify({
9093
+ O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9067
9094
  type: "UpdatePrompt",
9068
9095
  prompt: e
9069
9096
  }));
9070
9097
  },
9071
9098
  sendUserMessage: (e, { silent: t = !0, suppressQuestion: n = !1 } = {}) => {
9072
- w || v.readyState !== WebSocket.OPEN || !e || (t && y.add(e.trim()), v.send(JSON.stringify({
9099
+ O || C.readyState !== WebSocket.OPEN || !e || (t && w.add(e.trim()), C.send(JSON.stringify({
9073
9100
  type: "InjectUserMessage",
9074
9101
  content: e,
9075
9102
  suppress_question: n
9076
9103
  })));
9077
9104
  },
9078
9105
  injectAgentSpeech: (e, t = "interrupt") => {
9079
- w || v.readyState !== WebSocket.OPEN || !e || v.send(JSON.stringify({
9106
+ O || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9080
9107
  type: "InjectAgentMessage",
9081
9108
  message: e,
9082
9109
  behavior: t
9083
9110
  }));
9084
9111
  },
9085
9112
  setWalkthroughActive: (e) => {
9086
- w || v.readyState !== WebSocket.OPEN || v.send(JSON.stringify({
9113
+ O || C.readyState !== WebSocket.OPEN || C.send(JSON.stringify({
9087
9114
  type: "WalkthroughActive",
9088
9115
  active: !!e
9089
9116
  }));
9090
9117
  },
9091
9118
  setMicMuted: (e) => {
9092
- T = !!e, !w && v.readyState === WebSocket.OPEN && v.send(JSON.stringify({
9119
+ k = !!e, !O && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({
9093
9120
  type: "MicHeld",
9094
- held: T
9121
+ held: k
9095
9122
  }));
9096
9123
  },
9097
9124
  get status() {
9098
- return w ? "disconnected" : "connected";
9125
+ return O ? "disconnected" : "connected";
9099
9126
  }
9100
9127
  };
9101
9128
  }
9102
- var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9129
+ var Fm = { startSession: Pm }, Im = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9103
9130
  width: e,
9104
9131
  height: e,
9105
9132
  viewBox: "0 0 24 24",
@@ -9115,7 +9142,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9115
9142
  strokeLinecap: "round",
9116
9143
  strokeLinejoin: "round"
9117
9144
  })]
9118
- }), Pm = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9145
+ }), Lm = ({ size: e = 20 }) => /* @__PURE__ */ _("svg", {
9119
9146
  width: e,
9120
9147
  height: e,
9121
9148
  viewBox: "0 0 24 24",
@@ -9130,7 +9157,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9130
9157
  x2: "1",
9131
9158
  y2: "23"
9132
9159
  })]
9133
- }), Fm = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9160
+ }), Rm = ({ size: e = 18 }) => /* @__PURE__ */ _("svg", {
9134
9161
  width: e,
9135
9162
  height: e,
9136
9163
  viewBox: "0 0 24 24",
@@ -9145,7 +9172,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9145
9172
  x2: "12",
9146
9173
  y2: "5"
9147
9174
  }), /* @__PURE__ */ g("polyline", { points: "5 12 12 5 19 12" })]
9148
- }), Im = () => /* @__PURE__ */ _("svg", {
9175
+ }), zm = () => /* @__PURE__ */ _("svg", {
9149
9176
  width: "14",
9150
9177
  height: "14",
9151
9178
  viewBox: "0 0 24 24",
@@ -9155,7 +9182,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9155
9182
  strokeLinecap: "round",
9156
9183
  strokeLinejoin: "round",
9157
9184
  children: [/* @__PURE__ */ g("polyline", { points: "9 17 4 12 9 7" }), /* @__PURE__ */ g("path", { d: "M20 18v-2a4 4 0 00-4-4H4" })]
9158
- }), Lm = () => /* @__PURE__ */ g("svg", {
9185
+ }), Bm = () => /* @__PURE__ */ g("svg", {
9159
9186
  width: "18",
9160
9187
  height: "18",
9161
9188
  viewBox: "0 0 24 24",
@@ -9165,7 +9192,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9165
9192
  strokeLinecap: "round",
9166
9193
  strokeLinejoin: "round",
9167
9194
  children: /* @__PURE__ */ g("path", { d: "M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z" })
9168
- }), Rm = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9195
+ }), Vm = ({ className: e = "" }) => /* @__PURE__ */ _("svg", {
9169
9196
  className: e,
9170
9197
  width: "14",
9171
9198
  height: "14",
@@ -9194,7 +9221,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9194
9221
  y2: "16"
9195
9222
  })
9196
9223
  ]
9197
- }), zm = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9224
+ }), Hm = ({ size: e = 14 }) => /* @__PURE__ */ _("svg", {
9198
9225
  width: e,
9199
9226
  height: e,
9200
9227
  viewBox: "0 0 24 24",
@@ -9217,7 +9244,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9217
9244
  /* @__PURE__ */ g("path", { d: "M15 13v2" }),
9218
9245
  /* @__PURE__ */ g("path", { d: "M9 13v2" })
9219
9246
  ]
9220
- }), Bm = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9247
+ }), Um = ({ size: e = 20, strokeWidth: t = 2, color: n = "currentColor" }) => /* @__PURE__ */ _("svg", {
9221
9248
  width: e,
9222
9249
  height: e,
9223
9250
  viewBox: "0 0 24 24",
@@ -9237,7 +9264,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9237
9264
  x2: "19",
9238
9265
  y2: "12"
9239
9266
  })]
9240
- }), Vm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9267
+ }), Wm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9241
9268
  width: e,
9242
9269
  height: e,
9243
9270
  viewBox: "0 0 24 24",
@@ -9263,7 +9290,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9263
9290
  fill: t
9264
9291
  })
9265
9292
  ]
9266
- }), Hm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9293
+ }), Gm = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ _("svg", {
9267
9294
  width: "24",
9268
9295
  height: "24",
9269
9296
  viewBox: "0 0 24 24",
@@ -9281,7 +9308,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9281
9308
  "stroke-linecap": "round",
9282
9309
  "stroke-linejoin": "round"
9283
9310
  })]
9284
- }), Um = () => /* @__PURE__ */ g("svg", {
9311
+ }), Km = () => /* @__PURE__ */ g("svg", {
9285
9312
  width: "24",
9286
9313
  height: "24",
9287
9314
  viewBox: "0 0 24 24",
@@ -9293,7 +9320,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9293
9320
  "stroke-width": "1.5",
9294
9321
  "stroke-linejoin": "round"
9295
9322
  })
9296
- }), Wm = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9323
+ }), qm = ({ size: e = 24 }) => /* @__PURE__ */ _("svg", {
9297
9324
  xmlns: "http://www.w3.org/2000/svg",
9298
9325
  width: e,
9299
9326
  height: e,
@@ -9311,7 +9338,7 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9311
9338
  /* @__PURE__ */ g("path", { d: "m2 2 20 20" }),
9312
9339
  /* @__PURE__ */ g("path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12" })
9313
9340
  ]
9314
- }), Gm = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Km = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), qm = new Set([
9341
+ }), Jm = (e = "") => String(e).replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim(), Ym = (e = "") => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), Xm = new Set([
9315
9342
  "p",
9316
9343
  "br",
9317
9344
  "ul",
@@ -9322,30 +9349,30 @@ var Mm = { startSession: jm }, Nm = ({ size: e = 18, color: t = "currentColor" }
9322
9349
  "b",
9323
9350
  "i",
9324
9351
  "a"
9325
- ]), Jm = /^https?:\/\//i;
9326
- function Ym(e) {
9352
+ ]), Zm = /^https?:\/\//i;
9353
+ function Qm(e) {
9327
9354
  let t = Array.from(e.childNodes);
9328
9355
  for (let n of t) if (n.nodeType === Node.ELEMENT_NODE) {
9329
9356
  let t = n.tagName.toLowerCase();
9330
- if (!qm.has(t)) {
9357
+ if (!Xm.has(t)) {
9331
9358
  e.replaceChild(document.createTextNode(n.textContent), n);
9332
9359
  continue;
9333
9360
  }
9334
9361
  let r = {};
9335
9362
  if (t === "a") {
9336
9363
  let e = n.getAttribute("href") || "";
9337
- Jm.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9364
+ Zm.test(e) && (r.href = e), r.target = "_blank", r.rel = "noopener noreferrer";
9338
9365
  }
9339
9366
  for (; n.attributes.length > 0;) n.removeAttribute(n.attributes[0].name);
9340
9367
  for (let [e, t] of Object.entries(r)) n.setAttribute(e, t);
9341
- Ym(n);
9368
+ Qm(n);
9342
9369
  } else n.nodeType !== Node.TEXT_NODE && e.removeChild(n);
9343
9370
  }
9344
- function Xm(e) {
9371
+ function $m(e) {
9345
9372
  let t = document.createElement("div");
9346
- return t.innerHTML = e, Ym(t), t.innerHTML;
9373
+ return t.innerHTML = e, Qm(t), t.innerHTML;
9347
9374
  }
9348
- function Zm(e) {
9375
+ function eh(e) {
9349
9376
  let t = String(e || "").trim();
9350
9377
  if (!t) return t;
9351
9378
  let n = /^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);
@@ -9357,33 +9384,33 @@ function Zm(e) {
9357
9384
  }
9358
9385
  return e;
9359
9386
  }
9360
- var Qm = (e = "") => {
9387
+ var th = (e = "") => {
9361
9388
  let t = String(e || "").trim();
9362
9389
  if (!t) return "";
9363
- if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return Zm(Xm(t));
9364
- let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) => Km(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*\n]+)\*/g, "<em>$1</em>");
9365
- return Zm(n.map((e) => {
9390
+ if (/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t)) return eh($m(t));
9391
+ let n = t.replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean), r = (e) => Ym(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noopener noreferrer\">$1</a>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*\n]+)\*/g, "<em>$1</em>");
9392
+ return eh(n.map((e) => {
9366
9393
  let t = e.split("\n").map((e) => e.trim()).filter(Boolean), n = t.filter((e) => /^[-*]\s+/.test(e));
9367
9394
  if (n.length >= 2 && n.length === t.length) return `<ul>${n.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>`;
9368
9395
  let i = e.split(/\s+(?=[-*]\s+\*\*?)/).map((e) => e.trim()).filter(Boolean);
9369
9396
  return i.length >= 2 && i.every((e) => /^[-*]\s+/.test(e)) ? `<ul>${i.map((e) => `<li>${r(e.replace(/^[-*]\s+/, ""))}</li>`).join("")}</ul>` : `<p>${r(e).replace(/\n/g, "<br />")}</p>`;
9370
9397
  }).join(""));
9371
- }, $m = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), eh = new Set([
9398
+ }, nh = new Set(["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]), rh = new Set([
9372
9399
  ".pdf",
9373
9400
  ".docx",
9374
9401
  ".png",
9375
9402
  ".jpg",
9376
9403
  ".jpeg"
9377
- ]), th = "image/png,image/jpeg,.pdf,.docx";
9378
- function nh(e) {
9404
+ ]), ih = "image/png,image/jpeg,.pdf,.docx";
9405
+ function ah(e) {
9379
9406
  if (!e) return !1;
9380
9407
  let t = typeof e.name == "string" ? e.name.toLowerCase() : "", n = t.includes(".") ? `.${t.split(".").pop()}` : "", r = typeof e.type == "string" ? e.type.toLowerCase() : "";
9381
- return r === "image/png" || r === "image/jpeg" || $m.has(r) || eh.has(n);
9408
+ return r === "image/png" || r === "image/jpeg" || nh.has(r) || rh.has(n);
9382
9409
  }
9383
- function rh(e) {
9384
- return e ? nh(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9410
+ function oh(e) {
9411
+ return e ? ah(e) ? e.size > 2097152 ? "File must be 2 MB or smaller." : "" : "Only PNG, JPEG, PDF, and DOCX files are allowed." : "No file selected.";
9385
9412
  }
9386
- function ih(e = 0) {
9413
+ function sh(e = 0) {
9387
9414
  if (!Number.isFinite(e) || e <= 0) return "";
9388
9415
  let t = [
9389
9416
  "B",
@@ -9395,12 +9422,12 @@ function ih(e = 0) {
9395
9422
  let i = n >= 10 || r === 0 ? 0 : 1;
9396
9423
  return `${n.toFixed(i)} ${t[r]}`;
9397
9424
  }
9398
- function ah(e) {
9425
+ function ch(e) {
9399
9426
  return e ? e.name || "Attachment" : "";
9400
9427
  }
9401
9428
  //#endregion
9402
9429
  //#region src/utils/avatarHelpers.js
9403
- function oh(e) {
9430
+ function lh(e) {
9404
9431
  if (!e || typeof e != "string") return "?";
9405
9432
  let t = e.trim();
9406
9433
  if (!t) return "?";
@@ -9409,7 +9436,7 @@ function oh(e) {
9409
9436
  }
9410
9437
  //#endregion
9411
9438
  //#region src/components/AvatarImageOrInitials.jsx
9412
- function sh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9439
+ function uh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9413
9440
  let [i, a] = m(null), o = typeof e == "string" ? e.trim() : "";
9414
9441
  return c(() => {
9415
9442
  if (!o) {
@@ -9432,12 +9459,12 @@ function sh({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
9432
9459
  onError: () => a(null)
9433
9460
  }) : /* @__PURE__ */ g("span", {
9434
9461
  style: r,
9435
- children: oh(t)
9462
+ children: lh(t)
9436
9463
  });
9437
9464
  }
9438
9465
  //#endregion
9439
9466
  //#region src/components/MessageList.jsx
9440
- function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9467
+ function dh({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, setReplyContext: i, primaryColor: a = "#3B82F6", agentHeadshot: s = null, agentDisplayName: l = "Agent", botAvatarNode: u = null }) {
9441
9468
  let { resolvedConfig: d } = Cn(), f = p(null), [v, y] = m(null), [b, x] = m(null), S = p(e.length), C = p(!0), w = p(null), T = o((e) => {
9442
9469
  let t = e.target.closest("a[href]");
9443
9470
  if (!t) return;
@@ -9492,7 +9519,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9492
9519
  children: [
9493
9520
  e.map((e) => {
9494
9521
  if (e.type === "call_recording" || typeof e.message == "string" && e.message.includes("AI chat recording")) return null;
9495
- let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m = Gm(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9522
+ let t = e.sender === "system", n = e.sender === "user", r = e.sender === "ai" || e.sender === "bot", o = e.sender === "agent", c = e.isPending, d = e.type === "file" && e.metadata?.fileUrl, f = e.agent_name || e.agentName || e.metadata?.agentName || l, p = typeof e.sender_headshot == "string" && e.sender_headshot.trim() || typeof s == "string" && s.trim() || null, m = Jm(e.replyToContent || e.replyContext?.message || ""), v = e.replyToSender === "user" ? "You" : e.replyToSender === "agent" ? "Agent" : e.replyToSender === "ai" || e.replyToSender === "bot" ? "AI Assistant" : "Message";
9496
9523
  return t ? /* @__PURE__ */ g("div", {
9497
9524
  style: {
9498
9525
  display: "flex",
@@ -9537,7 +9564,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9537
9564
  fontWeight: 800,
9538
9565
  marginTop: !c && (r || o) ? "22px" : "0px"
9539
9566
  },
9540
- children: r ? u || /* @__PURE__ */ g(zm, { size: 16 }) : /* @__PURE__ */ g(sh, {
9567
+ children: r ? u || /* @__PURE__ */ g(Hm, { size: 16 }) : /* @__PURE__ */ g(uh, {
9541
9568
  src: p || "",
9542
9569
  name: f,
9543
9570
  imgStyle: {
@@ -9579,7 +9606,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9579
9606
  onMouseLeave: (e) => {
9580
9607
  e.currentTarget.style.color = "#9ca3af";
9581
9608
  },
9582
- children: [/* @__PURE__ */ g(Im, {}), "Reply"]
9609
+ children: [/* @__PURE__ */ g(zm, {}), "Reply"]
9583
9610
  }),
9584
9611
  /* @__PURE__ */ _("div", {
9585
9612
  style: {
@@ -9623,7 +9650,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9623
9650
  children: m
9624
9651
  })]
9625
9652
  }), d ? (() => {
9626
- let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = ih(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
9653
+ let t = e.metadata.fileType || "", r = e.metadata.fileName || e.message || "File", i = sh(e.metadata.fileSize), a = t.startsWith("image/"), o = `shared file: ${r}`.toLowerCase(), s = (e.message || "").trim(), c = s && s.toLowerCase() !== o && !s.toLowerCase().startsWith("shared file:"), l = t === "application/pdf" ? {
9627
9654
  color: "#ef4444",
9628
9655
  label: "PDF"
9629
9656
  } : t.includes("word") || t.includes("docx") ? {
@@ -9804,7 +9831,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9804
9831
  });
9805
9832
  })() : r ? /* @__PURE__ */ g("div", {
9806
9833
  className: "flowengage-message-content fe-bot-message",
9807
- dangerouslySetInnerHTML: { __html: Qm(e.message) },
9834
+ dangerouslySetInnerHTML: { __html: th(e.message) },
9808
9835
  onClick: T
9809
9836
  }) : /* @__PURE__ */ g("div", {
9810
9837
  style: { whiteSpace: "pre-wrap" },
@@ -9869,7 +9896,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9869
9896
  boxShadow: u ? "none" : "0 8px 20px rgba(59,130,246,0.24)",
9870
9897
  overflow: "hidden"
9871
9898
  },
9872
- children: u || /* @__PURE__ */ g(zm, { size: 16 })
9899
+ children: u || /* @__PURE__ */ g(Hm, { size: 16 })
9873
9900
  }), /* @__PURE__ */ _("div", {
9874
9901
  style: {
9875
9902
  display: "flex",
@@ -9911,7 +9938,7 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
9911
9938
  borderRadius: "50%",
9912
9939
  overflow: "hidden"
9913
9940
  },
9914
- children: /* @__PURE__ */ g(sh, {
9941
+ children: /* @__PURE__ */ g(uh, {
9915
9942
  src: s || "",
9916
9943
  name: l,
9917
9944
  imgStyle: {
@@ -10005,17 +10032,17 @@ function ch({ chatHistory: e, isAiTyping: t, isLoading: n, isAgentTyping: r, set
10005
10032
  }
10006
10033
  //#endregion
10007
10034
  //#region src/components/ChatInput.jsx
10008
- var lh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10009
- function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: l, clearReplyContext: u, requiresEmail: d, emailInput: f, setEmailInput: m, emailError: v, showVoiceToggle: y = !1, voiceEnabled: b = !0, onFileSelect: x, selectedFile: S = null, onRemoveSelectedFile: C, attachmentError: w = "", isUploadingAttachment: T = !1, inputPlaceholder: E = "Type your message" }) {
10010
- let D = p(null), O = p(null), k = (e) => {
10035
+ var fh = typeof window < "u" && (window.matchMedia?.("(pointer: coarse)").matches || navigator.maxTouchPoints > 0);
10036
+ function ph({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUiActive: i, handleToggleVoice: a, activeScreen: o, inputDisabled: s, replyContext: l, clearReplyContext: u, requiresEmail: d, emailInput: f, setEmailInput: m, emailError: v, showVoiceToggle: y = !1, voiceEnabled: b = !0, onFileSelect: x, selectedFile: S = null, onRemoveSelectedFile: C, attachmentError: w = "", isUploadingAttachment: T = !1, inputPlaceholder: E = "Type your message" }) {
10037
+ let D = p(null), ee = p(null), O = (e) => {
10011
10038
  e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 120)}px`);
10012
10039
  };
10013
10040
  c(() => {
10014
- d || k(O.current);
10041
+ d || O(ee.current);
10015
10042
  }, [e, d]);
10016
- let A = (e) => {
10017
- e.key === "Enter" && (lh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10018
- }, ee = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", te = d ? !!f?.trim() : !!e?.trim() || !!S, ne = s || T || !te, j = !d && b && y;
10043
+ let k = (e) => {
10044
+ e.key === "Enter" && (fh || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), e.currentTarget.form?.requestSubmit()));
10045
+ }, te = l?.sender === "user" ? "You" : l?.sender === "agent" ? "Agent" : "AI Assistant", ne = d ? !!f?.trim() : !!e?.trim() || !!S, re = s || T || !ne, A = !d && b && y;
10019
10046
  return /* @__PURE__ */ _("div", {
10020
10047
  style: {
10021
10048
  padding: "0 16px",
@@ -10048,7 +10075,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10048
10075
  fontWeight: 600,
10049
10076
  color: "var(--flowengage-primary)"
10050
10077
  },
10051
- children: ["Replying to ", ee]
10078
+ children: ["Replying to ", te]
10052
10079
  }), /* @__PURE__ */ g("div", {
10053
10080
  style: {
10054
10081
  overflow: "hidden",
@@ -10109,7 +10136,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10109
10136
  background: "rgba(59,130,246,0.08)",
10110
10137
  color: "var(--flowengage-primary)"
10111
10138
  },
10112
- children: /* @__PURE__ */ g(zm, { size: 13 })
10139
+ children: /* @__PURE__ */ g(Hm, { size: 13 })
10113
10140
  }), /* @__PURE__ */ g("span", { children: "Please provide your email address so we can help you." })]
10114
10141
  })
10115
10142
  }),
@@ -10149,7 +10176,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10149
10176
  overflow: "hidden",
10150
10177
  textOverflow: "ellipsis"
10151
10178
  },
10152
- children: ah(S)
10179
+ children: ch(S)
10153
10180
  }),
10154
10181
  /* @__PURE__ */ g("div", {
10155
10182
  style: {
@@ -10157,7 +10184,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10157
10184
  color: "#6b7280",
10158
10185
  marginTop: "2px"
10159
10186
  },
10160
- children: ih(S.size)
10187
+ children: sh(S.size)
10161
10188
  })
10162
10189
  ]
10163
10190
  }), /* @__PURE__ */ g("button", {
@@ -10199,10 +10226,10 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10199
10226
  },
10200
10227
  onSubmit: n,
10201
10228
  children: [
10202
- j ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10229
+ A ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("input", {
10203
10230
  ref: D,
10204
10231
  type: "file",
10205
- accept: th,
10232
+ accept: ih,
10206
10233
  style: { display: "none" },
10207
10234
  onChange: (e) => {
10208
10235
  let t = e.target.files?.[0];
@@ -10234,7 +10261,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10234
10261
  onMouseLeave: (e) => {
10235
10262
  e.currentTarget.style.opacity = "1";
10236
10263
  },
10237
- children: /* @__PURE__ */ g(Bm, {
10264
+ children: /* @__PURE__ */ g(Um, {
10238
10265
  size: 16,
10239
10266
  color: "currentColor"
10240
10267
  })
@@ -10249,7 +10276,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10249
10276
  fontSize: "14px",
10250
10277
  outline: "none",
10251
10278
  padding: 0,
10252
- paddingLeft: j ? "0" : "8px",
10279
+ paddingLeft: A ? "0" : "8px",
10253
10280
  color: "#111827",
10254
10281
  background: "transparent",
10255
10282
  cursor: "text",
@@ -10262,7 +10289,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10262
10289
  type: "email",
10263
10290
  autoComplete: "email"
10264
10291
  }) : /* @__PURE__ */ g("textarea", {
10265
- ref: O,
10292
+ ref: ee,
10266
10293
  className: "flowengage-chat-text-input",
10267
10294
  rows: 1,
10268
10295
  style: {
@@ -10274,7 +10301,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10274
10301
  lineHeight: "20px",
10275
10302
  outline: "none",
10276
10303
  padding: "6px 0",
10277
- paddingLeft: j ? "0" : "8px",
10304
+ paddingLeft: A ? "0" : "8px",
10278
10305
  color: "#111827",
10279
10306
  background: "transparent",
10280
10307
  cursor: "text",
@@ -10284,9 +10311,9 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10284
10311
  },
10285
10312
  value: e,
10286
10313
  onChange: (e) => {
10287
- t(e.target.value), k(e.target);
10314
+ t(e.target.value), O(e.target);
10288
10315
  },
10289
- onKeyDown: A,
10316
+ onKeyDown: k,
10290
10317
  placeholder: o === "agent" ? "Message the agent…" : E,
10291
10318
  disabled: s,
10292
10319
  autoComplete: "off"
@@ -10304,18 +10331,18 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10304
10331
  alignItems: "center",
10305
10332
  justifyContent: "center",
10306
10333
  transition: "opacity 0.2s ease",
10307
- cursor: ne ? "not-allowed" : "pointer",
10308
- opacity: ne ? .45 : 1,
10334
+ cursor: re ? "not-allowed" : "pointer",
10335
+ opacity: re ? .45 : 1,
10309
10336
  flexShrink: 0
10310
10337
  },
10311
- disabled: ne,
10338
+ disabled: re,
10312
10339
  onMouseEnter: (e) => {
10313
- ne || (e.currentTarget.style.opacity = "0.85");
10340
+ re || (e.currentTarget.style.opacity = "0.85");
10314
10341
  },
10315
10342
  onMouseLeave: (e) => {
10316
10343
  e.currentTarget.style.opacity = "1";
10317
10344
  },
10318
- children: /* @__PURE__ */ g(Fm, { size: 16 })
10345
+ children: /* @__PURE__ */ g(Rm, { size: 16 })
10319
10346
  })
10320
10347
  ]
10321
10348
  }),
@@ -10378,7 +10405,7 @@ function uh({ input: e, setInput: t, onSubmit: n, isConversationEnded: r, callUi
10378
10405
  }
10379
10406
  //#endregion
10380
10407
  //#region src/components/StatusBanners.jsx
10381
- function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10408
+ function mh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r, isRateLimited: i, rateLimitMessage: a }) {
10382
10409
  return /* @__PURE__ */ _(h, { children: [(e || t) && /* @__PURE__ */ _("div", {
10383
10410
  style: {
10384
10411
  margin: "0 20px 10px",
@@ -10391,7 +10418,7 @@ function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10391
10418
  gap: "10px"
10392
10419
  },
10393
10420
  children: [
10394
- /* @__PURE__ */ g(Rm, { className: "" }),
10421
+ /* @__PURE__ */ g(Vm, { className: "" }),
10395
10422
  /* @__PURE__ */ g("span", {
10396
10423
  style: {
10397
10424
  fontSize: "12px",
@@ -10437,13 +10464,13 @@ function dh({ webRTCError: e, micError: t, setMicError: n, dismissCallError: r,
10437
10464
  }
10438
10465
  //#endregion
10439
10466
  //#region src/components/AnimatedOrb.jsx
10440
- var fh = [
10467
+ var hh = [
10441
10468
  "#135bd8",
10442
10469
  "#ef334b",
10443
10470
  "#ffbd2e"
10444
10471
  ];
10445
- function ph(e) {
10446
- return !Array.isArray(e) || e.length === 0 ? fh : e.length === 1 ? [
10472
+ function gh(e) {
10473
+ return !Array.isArray(e) || e.length === 0 ? hh : e.length === 1 ? [
10447
10474
  e[0],
10448
10475
  e[0],
10449
10476
  e[0]
@@ -10457,7 +10484,7 @@ function ph(e) {
10457
10484
  e[2]
10458
10485
  ];
10459
10486
  }
10460
- var mh = {
10487
+ var _h = {
10461
10488
  idle: 3,
10462
10489
  listening: .75,
10463
10490
  thinking: 1,
@@ -10465,7 +10492,7 @@ var mh = {
10465
10492
  muted: .75,
10466
10493
  error: .08
10467
10494
  };
10468
- function hh(e) {
10495
+ function vh(e) {
10469
10496
  if (!e || typeof e != "string") return [
10470
10497
  0,
10471
10498
  0,
@@ -10478,14 +10505,14 @@ function hh(e) {
10478
10505
  parseInt(n.slice(4, 6), 16) / 255
10479
10506
  ];
10480
10507
  }
10481
- function gh(e, t) {
10508
+ function yh(e, t) {
10482
10509
  if (!e || typeof e != "string") return `rgba(0,0,0,${t})`;
10483
10510
  if (e.startsWith("rgb")) return e.replace(/[\d.]+\)$/, `${t})`);
10484
10511
  let n = e.replace("#", ""), r = n.length === 3 ? n.split("").map((e) => e + e).join("") : n;
10485
10512
  return `rgba(${parseInt(r.slice(0, 2), 16)},${parseInt(r.slice(2, 4), 16)},${parseInt(r.slice(4, 6), 16)},${t})`;
10486
10513
  }
10487
- var _h = "\n attribute vec2 a_pos;\n varying vec2 v_uv;\n void main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n }\n", vh = "\n precision highp float;\n\n varying vec2 v_uv;\n uniform float u_time;\n uniform float u_speed;\n uniform vec3 u_c1;\n uniform vec3 u_c2;\n uniform vec3 u_c3;\n\n // ── Gradient noise ─────────────────────────────────────────────────────────\n vec2 hash2(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n }\n float gnoise(vec2 p) {\n vec2 i = floor(p), f = fract(p);\n vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0);\n return mix(\n mix(dot(hash2(i), f),\n dot(hash2(i+vec2(1,0)), f-vec2(1,0)), u.x),\n mix(dot(hash2(i+vec2(0,1)), f-vec2(0,1)),\n dot(hash2(i+vec2(1,1)), f-vec2(1,1)), u.x),\n u.y\n ) * 0.5 + 0.5;\n }\n\n // ── 3-octave FBM normalised to [0,1] — fewer octaves → larger, softer blobs\n float fbm(vec2 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 3; i++) {\n v += a * gnoise(p);\n p = p * 2.1 + vec2(100.0);\n a *= 0.5;\n }\n return v / 0.875;\n }\n\n // ── Scalar hash for grain ──────────────────────────────────────────────────\n float hash1(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = v_uv;\n float t = u_time * u_speed + 47.3;\n\n // ── ① Two-level domain warp — deep organic folding and swirling ───────────\n // First pass: large-scale sweep\n vec2 q = vec2(\n fbm(uv * 1.8 + vec2( t * 0.13, t * 0.11)) * 2.0 - 1.0,\n fbm(uv * 1.8 + vec2( t * 0.11 + 3.7, -t * 0.14 + 1.1)) * 2.0 - 1.0\n );\n // Second pass: warp the warp — creates curling, folding sub-currents\n vec2 r = vec2(\n fbm(uv * 1.8 + q * 0.55 + vec2( t * 0.09, t * 0.07)) * 2.0 - 1.0,\n fbm(uv * 1.8 + q * 0.55 + vec2(-t * 0.07 + 5.1, t * 0.10 + 2.3)) * 2.0 - 1.0\n );\n vec2 wp = uv + r * 0.38;\n\n // ── ② Three independent fields — each drifts inward from its source edge ──\n // Asymmetric velocities: dominant axis matches the inflow direction so the\n // noise texture visually streams inward (left→right, right→left, bottom→top).\n float f1 = fbm(wp * 0.85 + vec2(-t * 0.18, t * 0.04)); // LEFT → right\n float f2 = fbm(wp * 0.85 + vec2( t * 0.18 + 5.3, t * 0.04 + 1.7)); // RIGHT → left\n float f3 = fbm(wp * 0.85 + vec2( t * 0.04 - 3.2, -t * 0.18 + 6.4)); // BOTTOM → up\n\n // ── ③ Breathing blobs — sin pulse makes each field expand and contract ────\n float p1 = 0.88 + 0.12 * sin(t * 0.61);\n float p2 = 0.88 + 0.12 * sin(t * 0.47 + 2.09);\n float p3 = 0.88 + 0.12 * sin(t * 0.53 + 4.19);\n\n // Wide smoothstep (0.26 → 0.70) → soft, diffused blob edges that dissolve\n // gradually into each other, like dye spreading through water.\n float b1 = smoothstep(0.26, 0.70, f1 * p1);\n float b2 = smoothstep(0.26, 0.70, f2 * p2);\n float b3 = smoothstep(0.26, 0.70, f3 * p3);\n\n // ── ④ Directional origin gradients.\n // Each color owns its home edge (value = 1.0) and smoothly fades to zero\n // before reaching the opposite side. The transition windows are offset so\n // they overlap only in the center third — that overlap zone is where the\n // three colors meet and blend, while the edges stay uncontaminated.\n float d1 = 1.0 - smoothstep(0.20, 0.74, uv.x); // c1: LEFT → full at x<0.20, zero by x=0.74\n float d2 = 1.0 - smoothstep(0.20, 0.74, 1.0 - uv.x); // c2: RIGHT → full at x>0.80, zero by x=0.26\n float d3 = 1.0 - smoothstep(0.18, 0.68, uv.y); // c3: BOTTOM → full at y<0.18, zero by y=0.68\n\n float w1 = b1 * d1;\n float w2 = b2 * d2;\n float w3 = b3 * d3;\n\n // ── ⑤ Dye-mixing colour blend ──────────────────────────────────────────────\n // dyeColor is the weighted average of all active colours — exactly how dyes\n // mix in water: overlapping streams blend smoothly, no hard edges.\n float total = w1 + w2 + w3;\n vec3 dyeColor = (u_c1 * w1 + u_c2 * w2 + u_c3 * w3) / max(total, 0.001);\n\n // Boost brightness of the dye to make colors pop and seem less dull\n dyeColor *= 1.65;\n\n // Exponential coverage: cores are rich and opaque; edges dissolve into the\n // near-white base. White only shows through where dye concentration is thin.\n float coverage = 1.0 - exp(-total * 5.0);\n vec3 col = mix(vec3(1.0, 1.0, 1.0), dyeColor, coverage);\n col = clamp(col, 0.0, 1.0);\n\n // ── ⑥ Sphere shading — subtle edge vignette only, no specular ─────────────\n vec2 uvc = v_uv * 2.0 - 1.0;\n\n // ── ⑦ Subtle grain — breaks gradient banding, adds filmic texture ──────────\n float grain = hash1(v_uv * 437.3 + fract(t)) * 2.0 - 1.0;\n col += grain * 0.018;\n\n gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n }\n";
10488
- function yh(e, t, n) {
10514
+ var bh = "\n attribute vec2 a_pos;\n varying vec2 v_uv;\n void main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n }\n", xh = "\n precision highp float;\n\n varying vec2 v_uv;\n uniform float u_time;\n uniform float u_speed;\n uniform vec3 u_c1;\n uniform vec3 u_c2;\n uniform vec3 u_c3;\n\n // ── Gradient noise ─────────────────────────────────────────────────────────\n vec2 hash2(vec2 p) {\n p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n }\n float gnoise(vec2 p) {\n vec2 i = floor(p), f = fract(p);\n vec2 u = f*f*f*(f*(f*6.0-15.0)+10.0);\n return mix(\n mix(dot(hash2(i), f),\n dot(hash2(i+vec2(1,0)), f-vec2(1,0)), u.x),\n mix(dot(hash2(i+vec2(0,1)), f-vec2(0,1)),\n dot(hash2(i+vec2(1,1)), f-vec2(1,1)), u.x),\n u.y\n ) * 0.5 + 0.5;\n }\n\n // ── 3-octave FBM normalised to [0,1] — fewer octaves → larger, softer blobs\n float fbm(vec2 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 3; i++) {\n v += a * gnoise(p);\n p = p * 2.1 + vec2(100.0);\n a *= 0.5;\n }\n return v / 0.875;\n }\n\n // ── Scalar hash for grain ──────────────────────────────────────────────────\n float hash1(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n }\n\n void main() {\n vec2 uv = v_uv;\n float t = u_time * u_speed + 47.3;\n\n // ── ① Two-level domain warp — deep organic folding and swirling ───────────\n // First pass: large-scale sweep\n vec2 q = vec2(\n fbm(uv * 1.8 + vec2( t * 0.13, t * 0.11)) * 2.0 - 1.0,\n fbm(uv * 1.8 + vec2( t * 0.11 + 3.7, -t * 0.14 + 1.1)) * 2.0 - 1.0\n );\n // Second pass: warp the warp — creates curling, folding sub-currents\n vec2 r = vec2(\n fbm(uv * 1.8 + q * 0.55 + vec2( t * 0.09, t * 0.07)) * 2.0 - 1.0,\n fbm(uv * 1.8 + q * 0.55 + vec2(-t * 0.07 + 5.1, t * 0.10 + 2.3)) * 2.0 - 1.0\n );\n vec2 wp = uv + r * 0.38;\n\n // ── ② Three independent fields — each drifts inward from its source edge ──\n // Asymmetric velocities: dominant axis matches the inflow direction so the\n // noise texture visually streams inward (left→right, right→left, bottom→top).\n float f1 = fbm(wp * 0.85 + vec2(-t * 0.18, t * 0.04)); // LEFT → right\n float f2 = fbm(wp * 0.85 + vec2( t * 0.18 + 5.3, t * 0.04 + 1.7)); // RIGHT → left\n float f3 = fbm(wp * 0.85 + vec2( t * 0.04 - 3.2, -t * 0.18 + 6.4)); // BOTTOM → up\n\n // ── ③ Breathing blobs — sin pulse makes each field expand and contract ────\n float p1 = 0.88 + 0.12 * sin(t * 0.61);\n float p2 = 0.88 + 0.12 * sin(t * 0.47 + 2.09);\n float p3 = 0.88 + 0.12 * sin(t * 0.53 + 4.19);\n\n // Wide smoothstep (0.26 → 0.70) → soft, diffused blob edges that dissolve\n // gradually into each other, like dye spreading through water.\n float b1 = smoothstep(0.26, 0.70, f1 * p1);\n float b2 = smoothstep(0.26, 0.70, f2 * p2);\n float b3 = smoothstep(0.26, 0.70, f3 * p3);\n\n // ── ④ Directional origin gradients.\n // Each color owns its home edge (value = 1.0) and smoothly fades to zero\n // before reaching the opposite side. The transition windows are offset so\n // they overlap only in the center third — that overlap zone is where the\n // three colors meet and blend, while the edges stay uncontaminated.\n float d1 = 1.0 - smoothstep(0.20, 0.74, uv.x); // c1: LEFT → full at x<0.20, zero by x=0.74\n float d2 = 1.0 - smoothstep(0.20, 0.74, 1.0 - uv.x); // c2: RIGHT → full at x>0.80, zero by x=0.26\n float d3 = 1.0 - smoothstep(0.18, 0.68, uv.y); // c3: BOTTOM → full at y<0.18, zero by y=0.68\n\n float w1 = b1 * d1;\n float w2 = b2 * d2;\n float w3 = b3 * d3;\n\n // ── ⑤ Dye-mixing colour blend ──────────────────────────────────────────────\n // dyeColor is the weighted average of all active colours — exactly how dyes\n // mix in water: overlapping streams blend smoothly, no hard edges.\n float total = w1 + w2 + w3;\n vec3 dyeColor = (u_c1 * w1 + u_c2 * w2 + u_c3 * w3) / max(total, 0.001);\n\n // Boost brightness of the dye to make colors pop and seem less dull\n dyeColor *= 1.65;\n\n // Exponential coverage: cores are rich and opaque; edges dissolve into the\n // near-white base. White only shows through where dye concentration is thin.\n float coverage = 1.0 - exp(-total * 5.0);\n vec3 col = mix(vec3(1.0, 1.0, 1.0), dyeColor, coverage);\n col = clamp(col, 0.0, 1.0);\n\n // ── ⑥ Sphere shading — subtle edge vignette only, no specular ─────────────\n vec2 uvc = v_uv * 2.0 - 1.0;\n\n // ── ⑦ Subtle grain — breaks gradient banding, adds filmic texture ──────────\n float grain = hash1(v_uv * 437.3 + fract(t)) * 2.0 - 1.0;\n col += grain * 0.018;\n\n gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n }\n";
10515
+ function Sh(e, t, n) {
10489
10516
  let r = (t, n) => {
10490
10517
  let r = e.createShader(t);
10491
10518
  return e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (console.error("[AnimatedOrb shader]", e.getShaderInfoLog(r)), null);
@@ -10494,10 +10521,10 @@ function yh(e, t, n) {
10494
10521
  let o = e.createProgram();
10495
10522
  return e.attachShader(o, i), e.attachShader(o, a), e.linkProgram(o), e.getProgramParameter(o, e.LINK_STATUS) ? o : (console.error("[AnimatedOrb link]", e.getProgramInfoLog(o)), null);
10496
10523
  }
10497
- function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10498
- let [s, l, u] = ph(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(mh[t] ?? .35);
10524
+ function Ch({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r, onClick: i, style: a, className: o }) {
10525
+ let [s, l, u] = gh(r), d = t === "speaking", f = e <= 50, m = p(null), h = p(_h[t] ?? .35);
10499
10526
  c(() => {
10500
- h.current = mh[t] ?? .35;
10527
+ h.current = _h[t] ?? .35;
10501
10528
  }, [t]), c(() => {
10502
10529
  let t = m.current;
10503
10530
  if (!t) return;
@@ -10514,7 +10541,7 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10514
10541
  console.warn("[AnimatedOrb] WebGL unavailable.");
10515
10542
  return;
10516
10543
  }
10517
- let i = yh(r, _h, vh);
10544
+ let i = Sh(r, bh, xh);
10518
10545
  if (!i) {
10519
10546
  console.error("[AnimatedOrb] WebGL program failed to compile/link");
10520
10547
  return;
@@ -10544,7 +10571,7 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10544
10571
  c2: r.getUniformLocation(i, "u_c2"),
10545
10572
  c3: r.getUniformLocation(i, "u_c3")
10546
10573
  };
10547
- r.uniform3fv(c.c1, hh(s)), r.uniform3fv(c.c2, hh(l)), r.uniform3fv(c.c3, hh(u)), r.viewport(0, 0, t.width, t.height);
10574
+ r.uniform3fv(c.c1, vh(s)), r.uniform3fv(c.c2, vh(l)), r.uniform3fv(c.c3, vh(u)), r.viewport(0, 0, t.width, t.height);
10548
10575
  let d = performance.now(), f, p = (e) => {
10549
10576
  r.uniform1f(c.time, (e - d) / 1e3), r.uniform1f(c.speed, h.current), r.drawArrays(r.TRIANGLES, 0, 6), f = requestAnimationFrame(p);
10550
10577
  };
@@ -10575,7 +10602,7 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10575
10602
  position: "absolute",
10576
10603
  inset: -10,
10577
10604
  borderRadius: "50%",
10578
- background: `radial-gradient(circle, ${gh(s, .18)} 0%, transparent 70%)`,
10605
+ background: `radial-gradient(circle, ${yh(s, .18)} 0%, transparent 70%)`,
10579
10606
  pointerEvents: "none"
10580
10607
  },
10581
10608
  animate: { opacity: [.3, .75] },
@@ -10653,17 +10680,17 @@ function bh({ size: e = 94, voiceState: t = "idle", isMuted: n = !1, colors: r,
10653
10680
  }
10654
10681
  //#endregion
10655
10682
  //#region src/components/CallScreen.jsx
10656
- var xh = "\n @keyframes fe-call-ring-pulse {\n 0% { transform: scale(1); opacity: 0.55; }\n 70% { transform: scale(1.85); opacity: 0; }\n 100% { transform: scale(1.85); opacity: 0; }\n }\n @keyframes fe-call-spin {\n to { transform: rotate(360deg); }\n }\n @keyframes fe-call-slide-up {\n from { opacity: 0; transform: translateY(24px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes fe-call-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes fe-call-bar-slide-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes fe-call-dot-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.35; }\n }\n @keyframes fe-call-avatar-breathe {\n 0%, 100% { opacity: 0.5; transform: scale(1); }\n 50% { opacity: 0.9; transform: scale(1.12); }\n }\n";
10657
- function Sh(e) {
10683
+ var wh = "\n @keyframes fe-call-ring-pulse {\n 0% { transform: scale(1); opacity: 0.55; }\n 70% { transform: scale(1.85); opacity: 0; }\n 100% { transform: scale(1.85); opacity: 0; }\n }\n @keyframes fe-call-spin {\n to { transform: rotate(360deg); }\n }\n @keyframes fe-call-slide-up {\n from { opacity: 0; transform: translateY(24px); }\n to { opacity: 1; transform: translateY(0); }\n }\n @keyframes fe-call-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes fe-call-bar-slide-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n @keyframes fe-call-dot-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.35; }\n }\n @keyframes fe-call-avatar-breathe {\n 0%, 100% { opacity: 0.5; transform: scale(1); }\n 50% { opacity: 0.9; transform: scale(1.12); }\n }\n";
10684
+ function Th(e) {
10658
10685
  let t = (e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
10659
10686
  return `${parseInt(n.slice(0, 2), 16)},${parseInt(n.slice(2, 4), 16)},${parseInt(n.slice(4, 6), 16)}`;
10660
10687
  }
10661
- function Ch(e) {
10688
+ function Eh(e) {
10662
10689
  if (!e || typeof e != "string") return "#1a1a1a";
10663
10690
  let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
10664
10691
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
10665
10692
  }
10666
- function wh(e, t) {
10693
+ function Dh(e, t) {
10667
10694
  let n = Array.isArray(e) && e.length > 0 ? e : [t || "#3B82F6"], [r, i, a] = n;
10668
10695
  return n.length === 1 ? [
10669
10696
  `radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,
@@ -10680,8 +10707,8 @@ function wh(e, t) {
10680
10707
  "#f7f8fa"
10681
10708
  ].join(", ");
10682
10709
  }
10683
- function Th({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
10684
- let i = (t || "A")[0].toUpperCase(), a = Ch(r), o = n > 48 ? {
10710
+ function Oh({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" }) {
10711
+ let i = (t || "A")[0].toUpperCase(), a = Eh(r), o = n > 48 ? {
10685
10712
  boxShadow: `0 0 0 3px ${r}44`,
10686
10713
  border: "3px solid rgba(255,255,255,0.15)"
10687
10714
  } : { border: `1.5px solid ${r}55` };
@@ -10718,7 +10745,7 @@ function Th({ headshot: e, name: t, size: n = 80, primaryColor: r = "#3B82F6" })
10718
10745
  children: i
10719
10746
  });
10720
10747
  }
10721
- function Eh(e) {
10748
+ function kh(e) {
10722
10749
  let t = p(null), n = o(() => {
10723
10750
  if (!t.current) return;
10724
10751
  let { audioContext: e, oscillator: n, interval: r, toneTimeout: i } = t.current;
@@ -10765,8 +10792,8 @@ function Eh(e) {
10765
10792
  n
10766
10793
  ]), c(() => () => n(), [n]), n;
10767
10794
  }
10768
- function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDurationSeconds: r, isCallMuted: i, agentName: a, agentHeadshot: o, fallbackAgentName: s, acceptCall: c, rejectCall: l, endWebRTCCall: u, toggleCallMute: d, formatCallDuration: f, onMinimize: p, primaryColor: m = "#3B82F6", orbColors: h, chatHistory: v = [] }) {
10769
- let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = Eh(!!e), S = async () => {
10795
+ function Ah({ incomingCall: e, activeCallId: t, callConnectionState: n, callDurationSeconds: r, isCallMuted: i, agentName: a, agentHeadshot: o, fallbackAgentName: s, acceptCall: c, rejectCall: l, endWebRTCCall: u, toggleCallMute: d, formatCallDuration: f, onMinimize: p, primaryColor: m = "#3B82F6", orbColors: h, chatHistory: v = [] }) {
10796
+ let y = a || s || "Agent", b = e ? "incoming" : n === "connecting" ? "connecting" : "ongoing", x = kh(!!e), S = async () => {
10770
10797
  x(), await c();
10771
10798
  }, C = async () => {
10772
10799
  x(), await l();
@@ -10778,14 +10805,14 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10778
10805
  flexDirection: "column",
10779
10806
  borderRadius: "inherit",
10780
10807
  overflow: "hidden",
10781
- background: wh(h, m),
10808
+ background: Dh(h, m),
10782
10809
  animation: T ? "fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)" : "fe-call-fade-in 0.32s ease"
10783
10810
  };
10784
10811
  if (b === "incoming") {
10785
10812
  let e = Array.isArray(h) && h.length > 0 ? h : [m];
10786
10813
  return /* @__PURE__ */ _("div", {
10787
10814
  style: E,
10788
- children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
10815
+ children: [/* @__PURE__ */ g("style", { children: wh }), /* @__PURE__ */ _("div", {
10789
10816
  style: {
10790
10817
  flex: 1,
10791
10818
  display: "flex",
@@ -10816,7 +10843,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10816
10843
  width: "96px",
10817
10844
  height: "96px",
10818
10845
  borderRadius: "50%",
10819
- background: `radial-gradient(circle, rgba(${Sh(e[0])},0.2) 0%, transparent 70%)`,
10846
+ background: `radial-gradient(circle, rgba(${Th(e[0])},0.2) 0%, transparent 70%)`,
10820
10847
  filter: "blur(10px)",
10821
10848
  zIndex: 0
10822
10849
  } }),
@@ -10833,7 +10860,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10833
10860
  animation: `fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,
10834
10861
  zIndex: 1
10835
10862
  } }, n)),
10836
- /* @__PURE__ */ g(Th, {
10863
+ /* @__PURE__ */ g(Oh, {
10837
10864
  headshot: o,
10838
10865
  name: y,
10839
10866
  size: 82,
@@ -10913,7 +10940,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10913
10940
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(239,68,68,0.5)";
10914
10941
  },
10915
10942
  "aria-label": "Decline call",
10916
- children: /* @__PURE__ */ g(Pm, { size: 26 })
10943
+ children: /* @__PURE__ */ g(Lm, { size: 26 })
10917
10944
  }), /* @__PURE__ */ g("span", {
10918
10945
  style: {
10919
10946
  fontSize: "12px",
@@ -10954,7 +10981,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10954
10981
  e.currentTarget.style.transform = "scale(1)", e.currentTarget.style.boxShadow = "0 6px 24px rgba(34,197,94,0.5)";
10955
10982
  },
10956
10983
  "aria-label": "Accept call",
10957
- children: /* @__PURE__ */ g(Lm, {})
10984
+ children: /* @__PURE__ */ g(Bm, {})
10958
10985
  }), /* @__PURE__ */ g("span", {
10959
10986
  style: {
10960
10987
  fontSize: "12px",
@@ -10971,7 +10998,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10971
10998
  }
10972
10999
  return b === "connecting" ? /* @__PURE__ */ _("div", {
10973
11000
  style: E,
10974
- children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
11001
+ children: [/* @__PURE__ */ g("style", { children: wh }), /* @__PURE__ */ _("div", {
10975
11002
  style: {
10976
11003
  flex: 1,
10977
11004
  display: "flex",
@@ -10981,7 +11008,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
10981
11008
  gap: "24px"
10982
11009
  },
10983
11010
  children: [
10984
- /* @__PURE__ */ g(Th, {
11011
+ /* @__PURE__ */ g(Oh, {
10985
11012
  headshot: o,
10986
11013
  name: y,
10987
11014
  size: 64,
@@ -11008,7 +11035,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11008
11035
  }) : /* @__PURE__ */ _("div", {
11009
11036
  style: E,
11010
11037
  children: [
11011
- /* @__PURE__ */ g("style", { children: xh }),
11038
+ /* @__PURE__ */ g("style", { children: wh }),
11012
11039
  /* @__PURE__ */ _("div", {
11013
11040
  style: {
11014
11041
  display: "flex",
@@ -11054,7 +11081,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11054
11081
  children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" })
11055
11082
  })
11056
11083
  }),
11057
- /* @__PURE__ */ g(bh, {
11084
+ /* @__PURE__ */ g(Ch, {
11058
11085
  colors: h,
11059
11086
  size: 36,
11060
11087
  voiceState: w
@@ -11105,7 +11132,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11105
11132
  gap: "16px",
11106
11133
  padding: "0 24px 16px"
11107
11134
  },
11108
- children: [/* @__PURE__ */ g(Th, {
11135
+ children: [/* @__PURE__ */ g(Oh, {
11109
11136
  headshot: o,
11110
11137
  name: y,
11111
11138
  size: 116,
@@ -11160,7 +11187,7 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11160
11187
  transition: "all 0.2s ease"
11161
11188
  },
11162
11189
  "aria-label": i ? "Unmute" : "Mute",
11163
- children: [g(i ? Wm : Nm, { size: 18 }), i ? "Unmute" : "Mute"]
11190
+ children: [g(i ? qm : Im, { size: 18 }), i ? "Unmute" : "Mute"]
11164
11191
  }), /* @__PURE__ */ _("button", {
11165
11192
  type: "button",
11166
11193
  onClick: u,
@@ -11188,15 +11215,15 @@ function Dh({ incomingCall: e, activeCallId: t, callConnectionState: n, callDura
11188
11215
  e.currentTarget.style.background = "rgba(239,68,68,0.9)", e.currentTarget.style.transform = "scale(1)";
11189
11216
  },
11190
11217
  "aria-label": "End call",
11191
- children: [/* @__PURE__ */ g(Pm, { size: 18 }), "End Call"]
11218
+ children: [/* @__PURE__ */ g(Lm, { size: 18 }), "End Call"]
11192
11219
  })]
11193
11220
  })
11194
11221
  ]
11195
11222
  });
11196
11223
  }
11197
- function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11224
+ function jh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDurationSeconds: r, isCallMuted: i, formatCallDuration: a, toggleCallMute: o, endWebRTCCall: s, onExpand: c, primaryColor: l = "#3B82F6" }) {
11198
11225
  let u = e || n || "Agent";
11199
- return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: xh }), /* @__PURE__ */ _("div", {
11226
+ return /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("style", { children: wh }), /* @__PURE__ */ _("div", {
11200
11227
  role: "button",
11201
11228
  tabIndex: 0,
11202
11229
  onClick: c,
@@ -11253,7 +11280,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11253
11280
  borderRadius: "50%",
11254
11281
  border: `1.5px solid ${l}55`
11255
11282
  } }),
11256
- /* @__PURE__ */ g(Th, {
11283
+ /* @__PURE__ */ g(Oh, {
11257
11284
  headshot: t,
11258
11285
  name: u,
11259
11286
  size: 38,
@@ -11337,7 +11364,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11337
11364
  boxShadow: i ? `0 0 0 3px ${l}12` : "none"
11338
11365
  },
11339
11366
  "aria-label": i ? "Unmute" : "Mute",
11340
- children: g(i ? Wm : Nm, { size: 15 })
11367
+ children: g(i ? qm : Im, { size: 15 })
11341
11368
  }), /* @__PURE__ */ g("button", {
11342
11369
  type: "button",
11343
11370
  onClick: (e) => {
@@ -11365,7 +11392,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11365
11392
  transition: "all 0.18s ease"
11366
11393
  },
11367
11394
  "aria-label": "End call",
11368
- children: /* @__PURE__ */ g(Pm, { size: 16 })
11395
+ children: /* @__PURE__ */ g(Lm, { size: 16 })
11369
11396
  })]
11370
11397
  })
11371
11398
  ]
@@ -11373,7 +11400,7 @@ function Oh({ agentName: e, agentHeadshot: t, fallbackAgentName: n, callDuration
11373
11400
  }
11374
11401
  //#endregion
11375
11402
  //#region src/utils/voicePriorContext.js
11376
- function kh(e, t = {}) {
11403
+ function Mh(e, t = {}) {
11377
11404
  let n = t.maxChars ?? 4500;
11378
11405
  if (!Array.isArray(e) || e.length === 0) return "";
11379
11406
  let r = [];
@@ -11391,7 +11418,7 @@ function kh(e, t = {}) {
11391
11418
  //#endregion
11392
11419
  //#region src/utils/voiceActionVisuals.js
11393
11420
  var Q = "fe-vv";
11394
- function Ah() {
11421
+ function Nh() {
11395
11422
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
11396
11423
  let e = `
11397
11424
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -11536,14 +11563,14 @@ function Ah() {
11536
11563
  `, t = document.createElement("style");
11537
11564
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
11538
11565
  }
11539
- var jh = null, Mh = null;
11540
- function Nh() {
11541
- return (!jh || !jh.isConnected) && (jh = document.createElement("div"), jh.id = `${Q}-toast`, document.body.appendChild(jh)), jh;
11566
+ var Ph = null, Fh = null;
11567
+ function Ih() {
11568
+ return (!Ph || !Ph.isConnected) && (Ph = document.createElement("div"), Ph.id = `${Q}-toast`, document.body.appendChild(Ph)), Ph;
11542
11569
  }
11543
- function Ph(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11570
+ function Lh(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11544
11571
  if (typeof document > "u") return;
11545
- Ah(), Mh &&= (clearTimeout(Mh), null);
11546
- let i = Nh();
11572
+ Nh(), Fh &&= (clearTimeout(Fh), null);
11573
+ let i = Ih();
11547
11574
  if (i.innerHTML = "", n) {
11548
11575
  let e = document.createElement("span");
11549
11576
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -11552,71 +11579,71 @@ function Ph(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
11552
11579
  e.className = `${Q}-spin`, i.appendChild(e);
11553
11580
  }
11554
11581
  let a = document.createElement("span");
11555
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Mh = setTimeout(() => Fh(), r));
11582
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (Fh = setTimeout(() => Rh(), r));
11556
11583
  }
11557
- function Fh(e = 0) {
11558
- jh && (e > 0 ? Mh = setTimeout(() => {
11559
- jh && jh.classList.remove(`${Q}-show`);
11560
- }, e) : jh && jh.classList.remove(`${Q}-show`));
11584
+ function Rh(e = 0) {
11585
+ Ph && (e > 0 ? Fh = setTimeout(() => {
11586
+ Ph && Ph.classList.remove(`${Q}-show`);
11587
+ }, e) : Ph && Ph.classList.remove(`${Q}-show`));
11561
11588
  }
11562
- var Ih = null, Lh = [];
11563
- function Rh() {
11564
- return (!Ih || !Ih.isConnected) && (Ih = document.createElement("div"), Ih.id = `${Q}-bar`, document.body.appendChild(Ih)), Ih;
11589
+ var zh = null, Bh = [];
11590
+ function Vh() {
11591
+ return (!zh || !zh.isConnected) && (zh = document.createElement("div"), zh.id = `${Q}-bar`, document.body.appendChild(zh)), zh;
11565
11592
  }
11566
- function zh() {
11593
+ function Hh() {
11567
11594
  if (typeof document > "u") return;
11568
- Ah(), Lh.forEach(clearTimeout), Lh = [];
11569
- let e = Rh();
11595
+ Nh(), Bh.forEach(clearTimeout), Bh = [];
11596
+ let e = Vh();
11570
11597
  e.style.transition = "none", e.style.width = "0%", e.classList.add(`${Q}-bar-active`), e.offsetHeight, e.style.transition = "width 0.35s ease, opacity 0.25s ease";
11571
11598
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
11572
11599
  for (let [e, r] of t) {
11573
11600
  let t = n, i = e, a = r;
11574
- Lh.push(setTimeout(() => {
11575
- Ih && (Ih.style.transition = a, Ih.style.width = `${i}%`);
11601
+ Bh.push(setTimeout(() => {
11602
+ zh && (zh.style.transition = a, zh.style.width = `${i}%`);
11576
11603
  }, t)), n += 800;
11577
11604
  }
11578
11605
  }
11579
- function Bh() {
11580
- Ih && (Lh.forEach(clearTimeout), Lh = [], Ih.style.transition = "width 0.2s ease", Ih.style.width = "100%", Lh.push(setTimeout(() => {
11581
- Ih && (Ih.style.transition = "opacity 0.35s ease", Ih.style.opacity = "0", Lh.push(setTimeout(() => {
11582
- Ih && (Ih.style.width = "0%", Ih.classList.remove(`${Q}-bar-active`));
11606
+ function Uh() {
11607
+ zh && (Bh.forEach(clearTimeout), Bh = [], zh.style.transition = "width 0.2s ease", zh.style.width = "100%", Bh.push(setTimeout(() => {
11608
+ zh && (zh.style.transition = "opacity 0.35s ease", zh.style.opacity = "0", Bh.push(setTimeout(() => {
11609
+ zh && (zh.style.width = "0%", zh.classList.remove(`${Q}-bar-active`));
11583
11610
  }, 380)));
11584
11611
  }, 220)));
11585
11612
  }
11586
- var Vh = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
11613
+ var Wh = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
11587
11614
  <filter id="${Q}-csh">
11588
11615
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
11589
11616
  </filter>
11590
11617
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
11591
11618
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
11592
11619
  filter="url(#${Q}-csh)"/>
11593
- </svg>`, Hh = null, Uh = !1;
11594
- function Wh() {
11595
- return (!Hh || !Hh.isConnected) && (Hh = document.createElement("div"), Hh.id = `${Q}-cursor`, Hh.innerHTML = Vh, document.body.appendChild(Hh), Uh = !1), Hh;
11620
+ </svg>`, Gh = null, Kh = !1;
11621
+ function qh() {
11622
+ return (!Gh || !Gh.isConnected) && (Gh = document.createElement("div"), Gh.id = `${Q}-cursor`, Gh.innerHTML = Wh, document.body.appendChild(Gh), Kh = !1), Gh;
11596
11623
  }
11597
- async function Gh(e) {
11624
+ async function Jh(e) {
11598
11625
  if (typeof document > "u" || !e) return;
11599
- Ah();
11626
+ Nh();
11600
11627
  let t;
11601
11628
  try {
11602
11629
  t = e.getBoundingClientRect();
11603
11630
  } catch {
11604
11631
  return;
11605
11632
  }
11606
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = Wh();
11607
- Uh ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await Yh(360);
11633
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = qh();
11634
+ Kh ||= (i.style.transition = "none", i.style.left = `${window.innerWidth / 2}px`, i.style.top = `${window.innerHeight * .4}px`, i.classList.add(`${Q}-cursor-visible`), i.offsetHeight, i.style.transition = "left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease", !0), i.style.left = `${n}px`, i.style.top = `${r}px`, await Qh(360);
11608
11635
  }
11609
- function Kh(e = !1) {
11610
- Hh && (e ? (Hh.classList.remove(`${Q}-cursor-visible`), Uh = !1) : (Hh.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
11611
- Uh = !1;
11636
+ function Yh(e = !1) {
11637
+ Gh && (e ? (Gh.classList.remove(`${Q}-cursor-visible`), Kh = !1) : (Gh.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
11638
+ Kh = !1;
11612
11639
  }, 250)));
11613
11640
  }
11614
- async function qh(e) {
11615
- Hh && (Hh.classList.add(`${Q}-cursor-click`), await Yh(280), Hh.classList.remove(`${Q}-cursor-click`));
11641
+ async function Xh(e) {
11642
+ Gh && (Gh.classList.add(`${Q}-cursor-click`), await Qh(280), Gh.classList.remove(`${Q}-cursor-click`));
11616
11643
  }
11617
- function Jh(e) {
11644
+ function Zh(e) {
11618
11645
  if (!e || typeof document > "u") return;
11619
- Ah();
11646
+ Nh();
11620
11647
  let t;
11621
11648
  try {
11622
11649
  t = e.getBoundingClientRect();
@@ -11642,29 +11669,29 @@ function Jh(e) {
11642
11669
  a.remove(), e.style.position = n, e.style.overflow = r;
11643
11670
  }, 650);
11644
11671
  }
11645
- function Yh(e) {
11672
+ function Qh(e) {
11646
11673
  return new Promise((t) => setTimeout(t, e));
11647
11674
  }
11648
11675
  //#endregion
11649
11676
  //#region src/utils/voiceClientTools.js
11650
- var Xh = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
11651
- function Zh(e) {
11652
- return String(e || "").replace(Xh, "").replace(/\/+$/, "").toLowerCase() || "/";
11677
+ var $h = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
11678
+ function eg(e) {
11679
+ return String(e || "").replace($h, "").replace(/\/+$/, "").toLowerCase() || "/";
11653
11680
  }
11654
- function Qh(e, t) {
11655
- return Zh(e) === Zh(t);
11681
+ function tg(e, t) {
11682
+ return eg(e) === eg(t);
11656
11683
  }
11657
11684
  function $(...e) {
11658
11685
  wn() && console.log("[FlowEngage:voice-tools]", ...e);
11659
11686
  }
11660
- function $h(e) {
11687
+ function ng(e) {
11661
11688
  try {
11662
11689
  let t = e.ownerDocument?.defaultView;
11663
11690
  if (t) return t.getComputedStyle(e);
11664
11691
  } catch {}
11665
11692
  return window.getComputedStyle(e);
11666
11693
  }
11667
- function eg(e) {
11694
+ function rg(e) {
11668
11695
  let t = /* @__PURE__ */ new Set();
11669
11696
  function n(r) {
11670
11697
  if (!r || t.has(r)) return;
@@ -11677,10 +11704,10 @@ function eg(e) {
11677
11704
  }
11678
11705
  typeof document < "u" && n(document);
11679
11706
  }
11680
- function tg(e) {
11707
+ function ig(e) {
11681
11708
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
11682
11709
  }
11683
- function ng(e) {
11710
+ function ag(e) {
11684
11711
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
11685
11712
  if (n) {
11686
11713
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -11688,40 +11715,40 @@ function ng(e) {
11688
11715
  let e = t.getElementById(n);
11689
11716
  e?.textContent && r.push(e.textContent.trim());
11690
11717
  } catch {}
11691
- if (r.length) return tg(r.join(" "));
11718
+ if (r.length) return ig(r.join(" "));
11692
11719
  }
11693
- if (e.labels && e.labels.length) return tg(e.labels[0].textContent);
11720
+ if (e.labels && e.labels.length) return ig(e.labels[0].textContent);
11694
11721
  let r = e.id;
11695
11722
  if (r) try {
11696
11723
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
11697
- if (e) return tg(e.textContent);
11724
+ if (e) return ig(e.textContent);
11698
11725
  } catch {
11699
11726
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
11700
- if (e) return tg(e.textContent);
11727
+ if (e) return ig(e.textContent);
11701
11728
  }
11702
11729
  let i = e.previousElementSibling;
11703
11730
  for (let e = 0; e < 6 && i; e += 1) {
11704
- if (i.tagName === "LABEL") return tg(i.textContent);
11731
+ if (i.tagName === "LABEL") return ig(i.textContent);
11705
11732
  let e = (i.className || "").toString().toLowerCase();
11706
11733
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
11707
- let e = tg(i.textContent);
11734
+ let e = ig(i.textContent);
11708
11735
  if (e) return e;
11709
11736
  }
11710
11737
  i = i.previousElementSibling;
11711
11738
  }
11712
11739
  let a = e.parentElement;
11713
11740
  for (let e = 0; e < 5 && a; e += 1) {
11714
- if (a.tagName === "LABEL") return tg(a.textContent);
11741
+ if (a.tagName === "LABEL") return ig(a.textContent);
11715
11742
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
11716
- if (e?.textContent) return tg(e.textContent);
11743
+ if (e?.textContent) return ig(e.textContent);
11717
11744
  a = a.parentElement;
11718
11745
  }
11719
11746
  let o = e.getAttribute("aria-label");
11720
- return o ? tg(o) : null;
11747
+ return o ? ig(o) : null;
11721
11748
  }
11722
- function rg() {
11749
+ function og() {
11723
11750
  let e = [];
11724
- return eg((t) => {
11751
+ return rg((t) => {
11725
11752
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
11726
11753
  if (An(e)) return !1;
11727
11754
  let t = (e.type || "").toLowerCase();
@@ -11732,15 +11759,15 @@ function rg() {
11732
11759
  "image"
11733
11760
  ].includes(t) || e.disabled || e.readOnly) return !1;
11734
11761
  try {
11735
- let t = $h(e);
11762
+ let t = ng(e);
11736
11763
  if (t.display === "none" || t.visibility === "hidden") return !1;
11737
11764
  } catch {}
11738
11765
  return !0;
11739
11766
  }));
11740
11767
  }), e;
11741
11768
  }
11742
- function ig() {
11743
- return rg().map((e, t) => {
11769
+ function sg() {
11770
+ return og().map((e, t) => {
11744
11771
  let n = {
11745
11772
  formIndex: 0,
11746
11773
  fieldIndex: t,
@@ -11748,7 +11775,7 @@ function ig() {
11748
11775
  type: e.type || "text",
11749
11776
  name: e.name || null,
11750
11777
  id: e.id || null,
11751
- label: ng(e),
11778
+ label: ag(e),
11752
11779
  placeholder: e.placeholder || null
11753
11780
  };
11754
11781
  return e.tagName === "SELECT" && (n.options = Array.from(e.options).filter((e) => e.value !== "" && !e.disabled).map((e) => ({
@@ -11757,13 +11784,13 @@ function ig() {
11757
11784
  })), n.currentValue = e.value || null), n;
11758
11785
  });
11759
11786
  }
11760
- function ag() {
11787
+ function cg() {
11761
11788
  let e = [];
11762
- return eg((t) => {
11789
+ return rg((t) => {
11763
11790
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
11764
11791
  if (An(e) || e.disabled) return !1;
11765
11792
  try {
11766
- let t = $h(e);
11793
+ let t = ng(e);
11767
11794
  if (t.display === "none" || t.visibility === "hidden") return !1;
11768
11795
  } catch {}
11769
11796
  return !0;
@@ -11775,7 +11802,7 @@ function ag() {
11775
11802
  type: e.type || e.tagName
11776
11803
  }));
11777
11804
  }
11778
- function og(e, t) {
11805
+ function lg(e, t) {
11779
11806
  try {
11780
11807
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
11781
11808
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -11790,7 +11817,7 @@ function og(e, t) {
11790
11817
  return Infinity;
11791
11818
  }
11792
11819
  }
11793
- function sg(e, t) {
11820
+ function ug(e, t) {
11794
11821
  let n = String(t || "").toLowerCase().trim();
11795
11822
  if (!n) return 0;
11796
11823
  let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
@@ -11808,21 +11835,21 @@ function sg(e, t) {
11808
11835
  for (let e of a) i.includes(e) && (o += 1);
11809
11836
  return o / a.length * 92;
11810
11837
  }
11811
- function cg(e, t, n = 6) {
11838
+ function dg(e, t, n = 6) {
11812
11839
  let r = String(t || "").toLowerCase().trim();
11813
11840
  if (!r) return !1;
11814
11841
  let i = e;
11815
11842
  for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
11816
11843
  return !1;
11817
11844
  }
11818
- function lg(e, t, n) {
11845
+ function fg(e, t, n) {
11819
11846
  let r = [];
11820
- eg((e) => {
11847
+ rg((e) => {
11821
11848
  let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
11822
11849
  r.push(...t.filter((e) => {
11823
11850
  if (An(e) || e.disabled) return !1;
11824
11851
  try {
11825
- let t = $h(e);
11852
+ let t = ng(e);
11826
11853
  if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
11827
11854
  } catch {}
11828
11855
  return !0;
@@ -11830,14 +11857,14 @@ function lg(e, t, n) {
11830
11857
  });
11831
11858
  let i = 0, a = r.map((t) => ({
11832
11859
  el: t,
11833
- s: sg(t, e)
11860
+ s: ug(t, e)
11834
11861
  }));
11835
11862
  for (let { s: e } of a) e > i && (i = e);
11836
11863
  if (i < 28) return null;
11837
11864
  let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
11838
11865
  if (o.length === 1) return o[0];
11839
11866
  if (n) {
11840
- let e = o.filter((e) => cg(e, n));
11867
+ let e = o.filter((e) => dg(e, n));
11841
11868
  if (e.length === 1) return e[0];
11842
11869
  e.length > 1 && (o = e);
11843
11870
  }
@@ -11845,14 +11872,14 @@ function lg(e, t, n) {
11845
11872
  if (s.length) {
11846
11873
  let e = o[0], t = Infinity;
11847
11874
  for (let n of o) for (let r of s) {
11848
- let i = og(n, r);
11875
+ let i = lg(n, r);
11849
11876
  i < t && (t = i, e = n);
11850
11877
  }
11851
11878
  return e;
11852
11879
  }
11853
11880
  return o[0];
11854
11881
  }
11855
- function ug(e) {
11882
+ function pg(e) {
11856
11883
  if (e == null) return {};
11857
11884
  if (typeof e == "string") {
11858
11885
  let t = e.trim();
@@ -11865,12 +11892,12 @@ function ug(e) {
11865
11892
  }
11866
11893
  return e;
11867
11894
  }
11868
- function dg(e) {
11895
+ function mg(e) {
11869
11896
  if (!e || typeof e != "object") return null;
11870
11897
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
11871
11898
  return t == null ? null : String(t).trim() || null;
11872
11899
  }
11873
- function fg() {
11900
+ function hg() {
11874
11901
  let e = {};
11875
11902
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
11876
11903
  if (t.id) return;
@@ -11885,7 +11912,7 @@ function fg() {
11885
11912
  e[r] = !0, t.id = r;
11886
11913
  });
11887
11914
  }
11888
- function pg() {
11915
+ function gg() {
11889
11916
  let e = (e) => {
11890
11917
  let t = Array.from(e).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, .flowengage-widget-root") && !e.closest("nav, footer, header, aside, .nav, .footer, .header, .sidebar")), n = [], r = 0;
11891
11918
  for (; r < t.length;) {
@@ -11928,7 +11955,7 @@ function pg() {
11928
11955
  introText: o
11929
11956
  };
11930
11957
  }
11931
- function mg(e) {
11958
+ function _g(e) {
11932
11959
  if (!e || typeof document > "u") return "";
11933
11960
  let t = new Set([
11934
11961
  "script",
@@ -12014,11 +12041,11 @@ function mg(e) {
12014
12041
  return d.has(t) ? !1 : (d.add(t), !0);
12015
12042
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
12016
12043
  }
12017
- function hg(e) {
12044
+ function vg(e) {
12018
12045
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
12019
12046
  "fwh-navigate-mvp": async (n) => {
12020
12047
  $("fwh-navigate-mvp ▶ raw parameters:", n);
12021
- let i = ug(n), a = dg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12048
+ let i = pg(n), a = mg(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
12022
12049
  if ($("fwh-navigate-mvp · coerced:", {
12023
12050
  url: a,
12024
12051
  sectionText: o,
@@ -12057,11 +12084,11 @@ function hg(e) {
12057
12084
  correctedUrl: l
12058
12085
  }), a = l);
12059
12086
  try {
12060
- Ph(`Navigating to ${a}...`, { spinner: !0 }), zh(), On();
12087
+ Lh(`Navigating to ${a}...`, { spinner: !0 }), Hh(), On();
12061
12088
  try {
12062
12089
  let e = r ? r() : "";
12063
12090
  if (e && t) {
12064
- let n = kh([{
12091
+ let n = Mh([{
12065
12092
  sender: "user",
12066
12093
  message: e
12067
12094
  }]);
@@ -12089,8 +12116,8 @@ function hg(e) {
12089
12116
  typeof window < "u" && window.scrollTo(0, 0);
12090
12117
  } catch {}
12091
12118
  let o = [], s = null, c = "", l = Date.now() + 12e3;
12092
- for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = pg(), !(o.length >= 1)););
12093
- fg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12119
+ for (; Date.now() < l && (await new Promise((e) => setTimeout(e, 300)), {headings: o, pageTitleHeading: s, introText: c} = gg(), !(o.length >= 1)););
12120
+ hg(), $("fwh-navigate-mvp → page headings collected:", o, "titleHeading:", s);
12094
12121
  let u = o.length ? o.join(" | ") : "none", d = o.length ? "Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate." : "No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.", f = s ? ` "${s}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${c || "(no intro text found)"}"` : c ? ` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${c}"` : "", p = "";
12095
12122
  try {
12096
12123
  if (o.length > 0) {
@@ -12098,7 +12125,7 @@ function hg(e) {
12098
12125
  for (let n of e) {
12099
12126
  let e = cr(null, n);
12100
12127
  if (e) {
12101
- let r = mg(e).substring(0, 800);
12128
+ let r = _g(e).substring(0, 800);
12102
12129
  r && t.push(`[Section: ${n}] ${r}`);
12103
12130
  }
12104
12131
  }
@@ -12107,13 +12134,13 @@ function hg(e) {
12107
12134
  } catch {}
12108
12135
  if (yr()) return _r(), $("fwh-navigate-mvp ✖ landed on a not-found/404 page:", i), `NAVIGATION_PAGE_NOT_FOUND. The page at ${i} does not exist — it shows a "not found"/404 error, not real content. Do NOT offer a page overview, do NOT describe or highlight any sections, do NOT claim the navigation succeeded. Tell the visitor EXACTLY: "It looks like that page doesn't exist — I couldn't find it. Would you like me to take you somewhere else?" Then STOP and wait for their reply.`;
12109
12136
  let m = Date.now() + 4e3, h = typeof window < "u" ? window.location.pathname : r;
12110
- for (; Date.now() < m && !Qh(h, e) && Qh(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12137
+ for (; Date.now() < m && !tg(h, e) && tg(h, t);) await new Promise((e) => setTimeout(e, 120)), h = window.location.pathname;
12111
12138
  $("fwh-navigate-mvp route settle:", {
12112
12139
  startPath: t,
12113
12140
  targetPath: e,
12114
12141
  settledPath: h
12115
12142
  });
12116
- let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = Qh(h, e), y = !Qh(h, t), b = v || y;
12143
+ let g = typeof window < "u" ? window.location.href : i, _ = (h.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home", v = tg(h, e), y = !tg(h, t), b = v || y;
12117
12144
  return $("fwh-navigate-mvp settled:", h, "target:", e, "match:", b), b ? (_r(), `OK_NAVIGATE_SPA. Visitor is now on: ${g} (page: "${_}") | Section headings: ${u}.${f} ${d}${p} Now confirm the arrival in ONE short sentence phrased for what the visitor actually asked for — mention the page by name and what it lets them do (e.g. for a contact request: "I've taken you to the Contact Us page — filling in this form sends your query straight to our team."). Do NOT use a fixed template. Then, in the same breath, offer either a specific section or a full overview. Then STOP — wait for their reply.`) : (_r(), `NAVIGATION_DID_NOT_HAPPEN. The visitor is STILL on ${g} (page: "${_}") — the navigation did not go through. Do NOT say "I have navigated you". Do NOT claim success. Tell the visitor EXACTLY: "Sorry, I couldn't open that page just now. Would you like me to try again, or is there something else I can help with?" Then STOP and wait for their reply.`);
12118
12145
  } catch {}
12119
12146
  let o = "this";
@@ -12124,45 +12151,45 @@ function hg(e) {
12124
12151
  return `OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, say EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for the visitor's reply.`;
12125
12152
  } catch (e) {
12126
12153
  let t = `Navigation error: ${e?.message || String(e)}`;
12127
- return $("fwh-navigate-mvp ✖", t), Ph("Navigation failed", {
12154
+ return $("fwh-navigate-mvp ✖", t), Lh("Navigation failed", {
12128
12155
  spinner: !1,
12129
12156
  icon: "⚠️",
12130
12157
  duration: 1800
12131
12158
  }), t;
12132
12159
  } finally {
12133
- Bh(), Fh(900);
12160
+ Uh(), Rh(900);
12134
12161
  }
12135
12162
  },
12136
12163
  "fwh-highlight-mvp": async (e) => {
12137
12164
  $("fwh-highlight-mvp ▶", e);
12138
- let t = ug(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12165
+ let t = pg(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
12139
12166
  if (typeof window < "u" && window.__fe_user_nav_during_speech) {
12140
12167
  let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
12141
12168
  if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
12142
12169
  else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call flowengage_highlight again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`;
12143
12170
  }
12144
- fg();
12171
+ hg();
12145
12172
  let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = cr(n || null, i || null);
12146
12173
  if (!a && i) {
12147
12174
  let e = Date.now() + 600;
12148
- for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), fg(), a = cr(null, i);
12175
+ for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), hg(), a = cr(null, i);
12149
12176
  }
12150
12177
  if (!a) {
12151
12178
  $("fwh-highlight-mvp ✖ no element for:", i || n);
12152
- let { headings: e } = pg(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
12179
+ let { headings: e } = gg(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
12153
12180
  return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
12154
12181
  }
12155
12182
  return Dn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}". Your NEXT response must be speech only (no tool call) describing THIS section — "${i || n}" — using its own content. Do not ask whether to continue.`;
12156
12183
  },
12157
12184
  "fwh-read-content-mvp": async (e) => {
12158
12185
  $("fwh-read-content-mvp ▶", e);
12159
- let t = ug(e), n = t?.section_text || t?.sectionText || "";
12186
+ let t = pg(e), n = t?.section_text || t?.sectionText || "";
12160
12187
  try {
12161
12188
  let e = "";
12162
12189
  if (n) {
12163
12190
  let t = cr(null, n);
12164
12191
  if (!t) return `Could not find section "${n}" on the page.`;
12165
- e = mg(t);
12192
+ e = _g(t);
12166
12193
  } else {
12167
12194
  let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
12168
12195
  t.querySelectorAll("nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar, #flowengage-root, .flowengage-shell, .flowengage-widget-root").forEach((e) => e.remove()), e = t.textContent.replace(/\s+/g, " ").trim();
@@ -12174,7 +12201,7 @@ function hg(e) {
12174
12201
  },
12175
12202
  "fwh-page-content-mvp": async (e) => {
12176
12203
  $("fwh-page-content-mvp ▶", e);
12177
- let r = ug(e), i = r?.url || r?.page_url || "";
12204
+ let r = pg(e), i = r?.url || r?.page_url || "";
12178
12205
  if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
12179
12206
  if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
12180
12207
  if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -12206,7 +12233,7 @@ function hg(e) {
12206
12233
  },
12207
12234
  "fwh-search-mvp": async (e) => {
12208
12235
  $("fwh-search-mvp ▶", e);
12209
- let r = ug(e).query;
12236
+ let r = pg(e).query;
12210
12237
  if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
12211
12238
  if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
12212
12239
  if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
@@ -12244,7 +12271,7 @@ function hg(e) {
12244
12271
  "[class*='menu'] a",
12245
12272
  "[class*='header'] a"
12246
12273
  ];
12247
- if (eg((t) => {
12274
+ if (rg((t) => {
12248
12275
  for (let r of n) try {
12249
12276
  t.querySelectorAll(r).forEach((t) => {
12250
12277
  if (An(t)) return;
@@ -12252,7 +12279,7 @@ function hg(e) {
12252
12279
  if (!r || !n || n === "#" || n.startsWith("javascript:")) return;
12253
12280
  try {
12254
12281
  let e = t.parentElement;
12255
- if (e && $h(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12282
+ if (e && ng(e).display === "none" && !e.closest("nav, [role='navigation'], header, [class*='nav'], [class*='menu']")) return;
12256
12283
  } catch {}
12257
12284
  let i = r.toLowerCase() + "|" + n;
12258
12285
  e.has(i) || e.set(i, {
@@ -12263,7 +12290,7 @@ function hg(e) {
12263
12290
  } catch {}
12264
12291
  t.querySelectorAll("select").forEach((t) => {
12265
12292
  if (An(t)) return;
12266
- let n = ng(t);
12293
+ let n = ag(t);
12267
12294
  /nav|menu|page|section|go to/i.test(n || t.name || t.id || "") && Array.from(t.options).forEach((r) => {
12268
12295
  if (!r.value || r.disabled) return;
12269
12296
  let i = r.text.trim();
@@ -12285,7 +12312,7 @@ function hg(e) {
12285
12312
  "fwh-request-email-mvp": async () => ($("fwh-request-email-mvp ▶"), typeof e.requestEmailCollection == "function" && e.requestEmailCollection(), "EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: \"Please enter your email in the text box to continue.\" Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message."),
12286
12313
  "fwh-get-current-page-mvp": async () => {
12287
12314
  if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
12288
- let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = pg();
12315
+ let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = gg();
12289
12316
  $("fwh-get-current-page-mvp ✓", {
12290
12317
  url: e,
12291
12318
  path: t,
@@ -12297,7 +12324,7 @@ function hg(e) {
12297
12324
  return `CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o} *** WALKTHROUGH: do NOT drive it yourself. Do not call fwh-highlight-mvp and do not decide the order — highlighting and section order are handled for you. You will be told which section to describe, one at a time. When told, describe ONLY that section in 3-4 sentences and then stop; never announce another section, never ask whether to continue. ***`;
12298
12325
  },
12299
12326
  "fwh-list-forms-mvp": async () => {
12300
- let e = ig(), t = ag();
12327
+ let e = sg(), t = cg();
12301
12328
  $("fwh-list-forms-mvp ✓", `${e.length} field(s)`, `${t.length} button(s)`);
12302
12329
  let n = e.map((e) => ({
12303
12330
  ...e,
@@ -12311,12 +12338,12 @@ function hg(e) {
12311
12338
  },
12312
12339
  "fwh-fill-form-mvp": async () => "FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.",
12313
12340
  "fwh-click-button-mvp": async (e) => {
12314
- let t = ug(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12341
+ let t = pg(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
12315
12342
  if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
12316
- let a = lg(n, i, r);
12343
+ let a = fg(n, i, r);
12317
12344
  if (!a) return $("fwh-click-button-mvp ✖ no match"), `Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;
12318
12345
  try {
12319
- Ph(`Clicking ${n}...`, { spinner: !0 });
12346
+ Lh(`Clicking ${n}...`, { spinner: !0 });
12320
12347
  try {
12321
12348
  a.scrollIntoView({
12322
12349
  block: "center",
@@ -12325,22 +12352,22 @@ function hg(e) {
12325
12352
  } catch {
12326
12353
  a.scrollIntoView(!0);
12327
12354
  }
12328
- await Gh(a), a.focus?.(), await qh(a), Jh(a), a.click();
12355
+ await Jh(a), a.focus?.(), await Xh(a), Zh(a), a.click();
12329
12356
  let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
12330
- return $("fwh-click-button-mvp ✓", t), Ph(`Clicked ${e}`, {
12357
+ return $("fwh-click-button-mvp ✓", t), Lh(`Clicked ${e}`, {
12331
12358
  spinner: !1,
12332
12359
  icon: "✅",
12333
12360
  duration: 1200
12334
12361
  }), t;
12335
12362
  } catch (e) {
12336
12363
  let t = `Click failed: ${e?.message || String(e)}`;
12337
- return $("fwh-click-button-mvp ✖", t), Ph("Click failed", {
12364
+ return $("fwh-click-button-mvp ✖", t), Lh("Click failed", {
12338
12365
  spinner: !1,
12339
12366
  icon: "⚠️",
12340
12367
  duration: 1800
12341
12368
  }), t;
12342
12369
  } finally {
12343
- Kh(), Fh(700);
12370
+ Yh(), Rh(700);
12344
12371
  }
12345
12372
  }
12346
12373
  };
@@ -12354,18 +12381,18 @@ function hg(e) {
12354
12381
  clickPageButton: a["fwh-click-button-mvp"]
12355
12382
  };
12356
12383
  }
12357
- var gg = /^(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;
12358
- function _g() {
12384
+ var yg = /^(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;
12385
+ function bg() {
12359
12386
  try {
12360
- let { headings: e } = pg();
12361
- return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !gg.test(e.trim()));
12387
+ let { headings: e } = gg();
12388
+ return (e || []).map((e) => typeof e == "string" ? e : e?.text || "").filter(Boolean).filter((e) => !yg.test(e.trim()));
12362
12389
  } catch {
12363
12390
  return [];
12364
12391
  }
12365
12392
  }
12366
12393
  //#endregion
12367
12394
  //#region src/utils/wrapVoiceToolsForLogging.js
12368
- function vg(e) {
12395
+ function xg(e) {
12369
12396
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
12370
12397
  let r = wn();
12371
12398
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -12382,7 +12409,7 @@ function vg(e) {
12382
12409
  }
12383
12410
  //#endregion
12384
12411
  //#region src/components/FlowEngageWidget.jsx
12385
- var yg = {
12412
+ var Sg = {
12386
12413
  blue: "#135bd8",
12387
12414
  red: "#ef334b",
12388
12415
  yellow: "#ffbd2e",
@@ -12390,7 +12417,7 @@ var yg = {
12390
12417
  highlight: "rgba(255,255,255,0.9)",
12391
12418
  green: "#10b981"
12392
12419
  };
12393
- function bg(e) {
12420
+ function Cg(e) {
12394
12421
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
12395
12422
  let [t, n, r] = e;
12396
12423
  return e.length >= 3 && r ? [
@@ -12404,12 +12431,12 @@ function bg(e) {
12404
12431
  "#f7f8fa"
12405
12432
  ].join(", ");
12406
12433
  }
12407
- function xg(e) {
12434
+ function wg(e) {
12408
12435
  if (!e || typeof e != "string") return "#1a1a1a";
12409
12436
  let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = parseInt(n.slice(0, 2), 16) / 255, i = parseInt(n.slice(2, 4), 16) / 255, a = parseInt(n.slice(4, 6), 16) / 255, o = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
12410
12437
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
12411
12438
  }
12412
- function Sg(t) {
12439
+ function Tg(t) {
12413
12440
  let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
12414
12441
  return e.useEffect(() => {
12415
12442
  if (!i) {
@@ -12427,8 +12454,8 @@ function Sg(t) {
12427
12454
  };
12428
12455
  }, [i]), n;
12429
12456
  }
12430
- function Cg({ logo: t, style: n }) {
12431
- let r = Sg(typeof t == "string" ? t : null);
12457
+ function Eg({ logo: t, style: n }) {
12458
+ let r = Tg(typeof t == "string" ? t : null);
12432
12459
  if (!t) return null;
12433
12460
  if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
12434
12461
  src: r,
@@ -12453,7 +12480,7 @@ function Cg({ logo: t, style: n }) {
12453
12480
  children: i
12454
12481
  }) : null;
12455
12482
  }
12456
- function wg({ title: e }) {
12483
+ function Dg({ title: e }) {
12457
12484
  return /* @__PURE__ */ g("div", {
12458
12485
  style: {
12459
12486
  width: "100%",
@@ -12471,18 +12498,18 @@ function wg({ title: e }) {
12471
12498
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
12472
12499
  });
12473
12500
  }
12474
- function Tg(e, t) {
12501
+ function Og(e, t) {
12475
12502
  let n = (t || "").trim();
12476
12503
  return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || e === "bot" && (/\b(that'?s all|we'?re done)\b/i.test(n) || /\b(goodbye|bye)\b/i.test(n) || /\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n))) : !1;
12477
12504
  }
12478
- function Eg({ orbColors: e, ...t }) {
12479
- return /* @__PURE__ */ g(bh, {
12505
+ function kg({ orbColors: e, ...t }) {
12506
+ return /* @__PURE__ */ g(Ch, {
12480
12507
  colors: e,
12481
12508
  ...t
12482
12509
  });
12483
12510
  }
12484
- function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
12485
- let s = n || yg.green, c = xg(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
12511
+ function Ag({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
12512
+ let s = n || Sg.green, c = wg(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
12486
12513
  style: {
12487
12514
  display: "flex",
12488
12515
  alignItems: a ? "flex-end" : "center",
@@ -12608,7 +12635,7 @@ function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
12608
12635
  delay: 0
12609
12636
  },
12610
12637
  style: { flexShrink: 0 },
12611
- children: /* @__PURE__ */ g(Eg, {
12638
+ children: /* @__PURE__ */ g(kg, {
12612
12639
  size: l,
12613
12640
  orbColors: t
12614
12641
  })
@@ -12640,8 +12667,8 @@ function Dg({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
12640
12667
  children: u
12641
12668
  })] });
12642
12669
  }
12643
- function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
12644
- let c = n || yg.green, l = xg(c);
12670
+ function jg({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
12671
+ let c = n || Sg.green, l = wg(c);
12645
12672
  return /* @__PURE__ */ _(ym.div, {
12646
12673
  initial: {
12647
12674
  scale: 50 / 350,
@@ -12712,7 +12739,7 @@ function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12712
12739
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
12713
12740
  })
12714
12741
  }),
12715
- /* @__PURE__ */ g(Eg, {
12742
+ /* @__PURE__ */ g(kg, {
12716
12743
  size: 72,
12717
12744
  orbColors: t
12718
12745
  }),
@@ -12792,9 +12819,9 @@ function Og({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
12792
12819
  ]
12793
12820
  });
12794
12821
  }
12795
- function kg({ 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...", enterChatModeLabel: S = "Enter Chat Mode", endConversationLabel: C = "End Conversation" }) {
12822
+ function Mg({ 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...", enterChatModeLabel: S = "Enter Chat Mode", endConversationLabel: C = "End Conversation" }) {
12796
12823
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
12797
- let [w, T] = m("idle"), [E, D] = m(!1), [O, k] = m(!1), [A, ee] = m(!1), [te, ne] = m(""), [j, re] = m(""), ie = p(!1), M = p(!1), ae = p(null), oe = p(0), se = p(""), ce = p(!1), le = p(0), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = (e) => {
12824
+ let [w, T] = m("idle"), [E, D] = m(!1), [ee, O] = m(!1), [k, te] = m(!1), [ne, re] = m(""), [A, ie] = m(""), j = p(!1), ae = p(!1), oe = p(null), M = p(0), se = p(""), ce = p(!1), le = p(0), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = (e) => {
12798
12825
  ue.current = e, N.current?.setWalkthroughActive?.(e);
12799
12826
  };
12800
12827
  pe.current = async () => {
@@ -12818,14 +12845,14 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12818
12845
  ve.current || (ve.current = !0, _e.current?.());
12819
12846
  });
12820
12847
  }, [l]), L = o(() => {
12821
- ae.current &&= (clearTimeout(ae.current), null);
12848
+ oe.current &&= (clearTimeout(oe.current), null);
12822
12849
  }, []);
12823
12850
  c(() => {
12824
12851
  if (y) {
12825
- ie.current = !1;
12852
+ j.current = !1;
12826
12853
  return;
12827
12854
  }
12828
- if (ie.current = !0, M.current = !1, ee(!1), L(), ce.current) {
12855
+ if (j.current = !0, ae.current = !1, te(!1), L(), ce.current) {
12829
12856
  ce.current = !1, N.current?.setMicMuted?.(!1);
12830
12857
  let e = se.current;
12831
12858
  se.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}"`);
@@ -12833,9 +12860,9 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12833
12860
  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.");
12834
12861
  }, [y, L]);
12835
12862
  let Fe = /(walk\s*(me\s*)?through|walkthrough|take me through|complete overview|full overview|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|show me (each|all|around))/i, Ie = /(that covers everything|that was all|covered everything|anything else)/i, Le = o(() => {
12836
- L(), ae.current = setTimeout(() => {
12837
- if (!(!M.current || ie.current)) if (oe.current < 3) {
12838
- oe.current += 1;
12863
+ L(), oe.current = setTimeout(() => {
12864
+ if (!(!ae.current || j.current)) if (M.current < 3) {
12865
+ M.current += 1;
12839
12866
  try {
12840
12867
  N.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
12841
12868
  } catch {}
@@ -12844,7 +12871,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12844
12871
  try {
12845
12872
  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");
12846
12873
  } catch {}
12847
- M.current = !1, ee(!1), L(), I.current = !0;
12874
+ ae.current = !1, te(!1), L(), I.current = !0;
12848
12875
  }
12849
12876
  }, 1e4);
12850
12877
  }, [L]), R = o(async (e) => {
@@ -12898,7 +12925,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12898
12925
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
12899
12926
  l.current = [], ge.current = "", ve.current = !1, be.current = !1, xe.current = !1, Se.current = "minimized", Cr({ onBeforeNavigate: () => {
12900
12927
  if (i && l.current.length > 0) try {
12901
- let e = kh(l.current);
12928
+ let e = Mh(l.current);
12902
12929
  e && P(i, e);
12903
12930
  } catch {}
12904
12931
  if (!qn()) {
@@ -12920,7 +12947,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12920
12947
  }
12921
12948
  Ee();
12922
12949
  } });
12923
- let t = vg(hg({
12950
+ let t = xg(vg({
12924
12951
  siteId: i || null,
12925
12952
  apiBaseUrl: a || null,
12926
12953
  chatId: s || null,
@@ -12929,7 +12956,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12929
12956
  I.current = !0;
12930
12957
  },
12931
12958
  requestEmailCollection: () => {
12932
- b && (ie.current || M.current || (M.current = !0, oe.current = 0, ee(!0), Le()));
12959
+ b && (j.current || ae.current || (ae.current = !0, M.current = 0, te(!0), Le()));
12933
12960
  }
12934
12961
  })), n = i ? we(i) : null, r = !!n?.transcript, u = i ? Ne(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
12935
12962
  apiBaseUrl: a,
@@ -12955,14 +12982,14 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12955
12982
  let e = f || "";
12956
12983
  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}`);
12957
12984
  }
12958
- 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, A = !1, te = !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, ne = r && !p, j = !1, re = ne ? `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, ae = !1, _e = !1, Te = b && !!y && !de.current, De = await Mm.startSession({
12985
+ let ee = !1, O = 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, k = !1, ne = !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, re = r && !p, A = !1, ie = re ? `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, oe = !1, _e = !1, Te = b && !!y && !de.current, De = await Fm.startSession({
12959
12986
  ...x,
12960
12987
  onConnect: ({ conversationId: e }) => {
12961
12988
  Ce.current = e, F.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
12962
12989
  },
12963
12990
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
12964
12991
  onSessionInfo: ({ emailOnFile: e }) => {
12965
- de.current = !!e, e && (ie.current = !0, M.current = !1, ee(!1), L(), console.log("[FlowEngage] email already on file per server — gate disabled"));
12992
+ de.current = !!e, e && (j.current = !0, ae.current = !1, te(!1), L(), console.log("[FlowEngage] email already on file per server — gate disabled"));
12966
12993
  },
12967
12994
  onAgentTurnEnd: () => {
12968
12995
  e || ue.current && (ce.current || setTimeout(() => pe.current?.(), 250));
@@ -12980,28 +13007,28 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
12980
13007
  I.current = !1, Pe();
12981
13008
  return;
12982
13009
  }
12983
- if (Te && !_e && !ie.current && !de.current) {
12984
- _e = !0, O = !0, A = !0;
13010
+ if (Te && !_e && !j.current && !de.current) {
13011
+ _e = !0, ee = !0, k = !0;
12985
13012
  try {
12986
13013
  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.");
12987
13014
  } catch {}
12988
13015
  }
12989
- if (k && !O) {
12990
- O = !0;
13016
+ if (O && !ee) {
13017
+ ee = !0;
12991
13018
  try {
12992
- N.current?.sendContextualUpdate?.(k);
13019
+ N.current?.sendContextualUpdate?.(O);
12993
13020
  } catch {}
12994
13021
  }
12995
- if (re && !j) {
12996
- j = !0;
13022
+ if (ie && !A) {
13023
+ A = !0;
12997
13024
  try {
12998
- N.current?.sendContextualUpdate?.(re);
13025
+ N.current?.sendContextualUpdate?.(ie);
12999
13026
  } catch {}
13000
13027
  }
13001
- if (te && !A) {
13002
- A = !0;
13028
+ if (ne && !k) {
13029
+ k = !0;
13003
13030
  try {
13004
- N.current?.sendContextualUpdate?.(te);
13031
+ N.current?.sendContextualUpdate?.(ne);
13005
13032
  } catch {}
13006
13033
  }
13007
13034
  je.current && clearTimeout(je.current), je.current = setTimeout(() => {
@@ -13011,7 +13038,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13011
13038
  },
13012
13039
  onMessage: (t) => {
13013
13040
  if (e || ce.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13014
- t.role === "user" && Fe.test(String(t.message || "")) && (typeof window < "u" && (window.__fe_user_nav_during_speech = null), me(!0), le.current = 0, he.current = -1, fe.current = _g(), setTimeout(() => pe.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`)), t.role !== "user" && Ie.test(String(t.message || "")) && me(!1);
13041
+ t.role === "user" && Fe.test(String(t.message || "")) && (typeof window < "u" && (window.__fe_user_nav_during_speech = null), me(!0), le.current = 0, he.current = -1, fe.current = bg(), setTimeout(() => pe.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`)), t.role !== "user" && Ie.test(String(t.message || "")) && me(!1);
13015
13042
  let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
13016
13043
  if (r) {
13017
13044
  if (n === "user") {
@@ -13019,7 +13046,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13019
13046
  try {
13020
13047
  On();
13021
13048
  } catch {}
13022
- Te && !ae && !ie.current && !de.current && (ae = !0, se.current = r, ce.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), M.current || (M.current = !0, oe.current = 0, ee(!0), Le()));
13049
+ Te && !oe && !j.current && !de.current && (oe = !0, se.current = r, ce.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), ae.current || (ae.current = !0, M.current = 0, te(!0), Le()));
13023
13050
  }
13024
13051
  if (l.current = [...l.current, {
13025
13052
  sender: n,
@@ -13027,10 +13054,10 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13027
13054
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
13028
13055
  debug: t.debug
13029
13056
  }], i) try {
13030
- let e = kh(l.current);
13057
+ let e = Mh(l.current);
13031
13058
  e && P(i, e);
13032
13059
  } catch {}
13033
- if (Tg(n, r)) {
13060
+ if (Og(n, r)) {
13034
13061
  I.current = !0;
13035
13062
  return;
13036
13063
  }
@@ -13139,7 +13166,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13139
13166
  if (i) try {
13140
13167
  Ne(i);
13141
13168
  } catch {}
13142
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), je.current &&= (clearTimeout(je.current), null), ae.current &&= (clearTimeout(ae.current), null), Me.current = !1, ke.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13169
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), wr(), je.current &&= (clearTimeout(je.current), null), oe.current &&= (clearTimeout(oe.current), null), Me.current = !1, ke.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13143
13170
  let t = o || N.current, n = Ce.current, f = F.current;
13144
13171
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13145
13172
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
@@ -13163,13 +13190,13 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13163
13190
  a,
13164
13191
  Pe
13165
13192
  ]), c(() => {
13166
- if (!O) return;
13193
+ if (!ee) return;
13167
13194
  let e = (e) => {
13168
13195
  let t = e.composedPath?.()?.[0] || e.target;
13169
- De.current && !De.current.contains(t) && k(!1);
13196
+ De.current && !De.current.contains(t) && O(!1);
13170
13197
  };
13171
13198
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
13172
- }, [O]);
13199
+ }, [ee]);
13173
13200
  let Re = async () => {
13174
13201
  if (N.current) try {
13175
13202
  if (E) {
@@ -13186,23 +13213,23 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13186
13213
  } catch {}
13187
13214
  }, ze = o(async (e) => {
13188
13215
  e?.preventDefault?.();
13189
- let t = te.trim().toLowerCase();
13216
+ let t = ne.trim().toLowerCase();
13190
13217
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13191
- re("Please enter a valid email address.");
13218
+ ie("Please enter a valid email address.");
13192
13219
  return;
13193
13220
  }
13194
- re("");
13221
+ ie("");
13195
13222
  try {
13196
13223
  typeof v == "function" && await v(t);
13197
13224
  } catch {}
13198
- ie.current = !0, M.current = !1, L(), ee(!1), ne(""), ce.current = !1, N.current?.setMicMuted?.(!1);
13225
+ j.current = !0, ae.current = !1, L(), te(!1), re(""), ce.current = !1, N.current?.setMicMuted?.(!1);
13199
13226
  let n = se.current;
13200
13227
  se.current = "";
13201
13228
  try {
13202
13229
  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.");
13203
13230
  } catch {}
13204
13231
  }, [
13205
- te,
13232
+ ne,
13206
13233
  v,
13207
13234
  L
13208
13235
  ]), Be = Array.isArray(e) && e[0] || "#3B82F6";
@@ -13217,7 +13244,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13217
13244
  animation: "fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)"
13218
13245
  },
13219
13246
  children: [
13220
- A && /* @__PURE__ */ _("form", {
13247
+ k && /* @__PURE__ */ _("form", {
13221
13248
  onSubmit: ze,
13222
13249
  style: {
13223
13250
  width: "270px",
@@ -13249,9 +13276,9 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13249
13276
  inputMode: "email",
13250
13277
  autoComplete: "email",
13251
13278
  autoFocus: !0,
13252
- value: te,
13279
+ value: ne,
13253
13280
  onChange: (e) => {
13254
- ne(e.target.value), j && re("");
13281
+ re(e.target.value), A && ie("");
13255
13282
  },
13256
13283
  placeholder: "you@example.com",
13257
13284
  style: {
@@ -13259,33 +13286,33 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13259
13286
  boxSizing: "border-box",
13260
13287
  padding: "10px 12px",
13261
13288
  borderRadius: "10px",
13262
- border: j ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
13289
+ border: A ? "1.5px solid #ef4444" : "1.5px solid #4b5563",
13263
13290
  background: "#1f2937",
13264
13291
  color: "white",
13265
13292
  fontSize: "14px",
13266
13293
  outline: "none"
13267
13294
  }
13268
13295
  }),
13269
- j && /* @__PURE__ */ g("span", {
13296
+ A && /* @__PURE__ */ g("span", {
13270
13297
  style: {
13271
13298
  color: "#f87171",
13272
13299
  fontSize: "12px"
13273
13300
  },
13274
- children: j
13301
+ children: A
13275
13302
  }),
13276
13303
  /* @__PURE__ */ g("button", {
13277
13304
  type: "submit",
13278
- disabled: !te.trim(),
13305
+ disabled: !ne.trim(),
13279
13306
  style: {
13280
13307
  width: "100%",
13281
13308
  padding: "10px 12px",
13282
13309
  borderRadius: "10px",
13283
13310
  border: "none",
13284
- background: te.trim() ? Be : "#374151",
13311
+ background: ne.trim() ? Be : "#374151",
13285
13312
  color: "white",
13286
13313
  fontSize: "14px",
13287
13314
  fontWeight: 600,
13288
- cursor: te.trim() ? "pointer" : "default",
13315
+ cursor: ne.trim() ? "pointer" : "default",
13289
13316
  transition: "background 0.2s ease"
13290
13317
  },
13291
13318
  children: "Submit"
@@ -13327,7 +13354,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13327
13354
  },
13328
13355
  children: "Muted"
13329
13356
  }),
13330
- /* @__PURE__ */ g(Eg, {
13357
+ /* @__PURE__ */ g(kg, {
13331
13358
  size: 72,
13332
13359
  voiceState: w,
13333
13360
  isMuted: E,
@@ -13399,12 +13426,12 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13399
13426
  y2: "23"
13400
13427
  })
13401
13428
  ]
13402
- }) : /* @__PURE__ */ g(Nm, {
13429
+ }) : /* @__PURE__ */ g(Im, {
13403
13430
  size: 16,
13404
13431
  color: "currentColor"
13405
13432
  })
13406
13433
  }), /* @__PURE__ */ g("button", {
13407
- onClick: () => k((e) => !e),
13434
+ onClick: () => O((e) => !e),
13408
13435
  style: {
13409
13436
  width: "24px",
13410
13437
  height: "24px",
@@ -13421,13 +13448,13 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13421
13448
  padding: 0,
13422
13449
  flexShrink: 0
13423
13450
  },
13424
- children: /* @__PURE__ */ g(Vm, {
13451
+ children: /* @__PURE__ */ g(Wm, {
13425
13452
  size: 16,
13426
13453
  color: "currentColor"
13427
13454
  })
13428
13455
  })]
13429
13456
  }),
13430
- O && /* @__PURE__ */ _("div", {
13457
+ ee && /* @__PURE__ */ _("div", {
13431
13458
  style: {
13432
13459
  position: "absolute",
13433
13460
  bottom: 0,
@@ -13445,7 +13472,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13445
13472
  children: [
13446
13473
  /* @__PURE__ */ _("button", {
13447
13474
  onClick: () => {
13448
- k(!1), Se.current = "chat", R(t);
13475
+ O(!1), Se.current = "chat", R(t);
13449
13476
  },
13450
13477
  style: {
13451
13478
  display: "flex",
@@ -13470,11 +13497,11 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13470
13497
  onMouseLeave: (e) => {
13471
13498
  e.currentTarget.style.background = "none";
13472
13499
  },
13473
- children: [/* @__PURE__ */ g(Hm, {}), S]
13500
+ children: [/* @__PURE__ */ g(Gm, {}), S]
13474
13501
  }),
13475
13502
  /* @__PURE__ */ _("button", {
13476
13503
  onClick: () => {
13477
- k(!1), Se.current = "minimized", R(n);
13504
+ O(!1), Se.current = "minimized", R(n);
13478
13505
  },
13479
13506
  style: {
13480
13507
  display: "flex",
@@ -13499,10 +13526,10 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13499
13526
  onMouseLeave: (e) => {
13500
13527
  e.currentTarget.style.background = "none";
13501
13528
  },
13502
- children: [/* @__PURE__ */ g(Um, {}), C]
13529
+ children: [/* @__PURE__ */ g(Km, {}), C]
13503
13530
  }),
13504
13531
  /* @__PURE__ */ g("button", {
13505
- onClick: () => k(!1),
13532
+ onClick: () => O(!1),
13506
13533
  style: {
13507
13534
  position: "absolute",
13508
13535
  bottom: "8px",
@@ -13551,7 +13578,7 @@ function kg({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13551
13578
  ]
13552
13579
  });
13553
13580
  }
13554
- function Ag({ orbColors: e }) {
13581
+ function Ng({ orbColors: e }) {
13555
13582
  let t = Array.isArray(e) && e.length > 0 ? e : [
13556
13583
  "#135bd8",
13557
13584
  "#ef334b",
@@ -13570,7 +13597,7 @@ function Ag({ orbColors: e }) {
13570
13597
  `.replace(/\s+/g, " ").trim()
13571
13598
  } });
13572
13599
  }
13573
- var jg = () => /* @__PURE__ */ g("div", {
13600
+ var Pg = () => /* @__PURE__ */ g("div", {
13574
13601
  style: {
13575
13602
  display: "flex",
13576
13603
  marginBottom: "12px",
@@ -13600,7 +13627,7 @@ var jg = () => /* @__PURE__ */ g("div", {
13600
13627
  } }, e))
13601
13628
  })
13602
13629
  });
13603
- function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: re, emailError: ie, emailCaptureSuccess: M, replyContext: ae, setReplyContext: oe, webRTCError: se, micError: ce, setMicError: le, dismissCallError: ue, activeCallId: de, isCallMuted: fe, toggleCallMute: pe, endWebRTCCall: me, formatCallDuration: he, callDurationSeconds: N, isCallMinimized: ge, onExpand: _e, onCollapse: ve, onStartVoice: ye, voiceEnabled: be, headerBgColor: xe, onNewChat: Se, showPoweredBy: Ce, privacyPolicyUrl: P, getVisitorChatHistory: we, resumeChat: Te, isSessionRestoring: F, isClosing: Ee }) {
13630
+ function Fg({ 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: j, emailCaptureSuccess: ae, replyContext: oe, setReplyContext: M, webRTCError: se, micError: ce, setMicError: le, dismissCallError: ue, activeCallId: de, isCallMuted: fe, toggleCallMute: pe, endWebRTCCall: me, formatCallDuration: he, callDurationSeconds: N, isCallMinimized: ge, onExpand: _e, onCollapse: ve, onStartVoice: ye, voiceEnabled: be, headerBgColor: xe, onNewChat: Se, showPoweredBy: Ce, privacyPolicyUrl: P, getVisitorChatHistory: we, resumeChat: Te, isSessionRestoring: F, isClosing: Ee }) {
13604
13631
  let De = l.length > 0, Oe = T || E || w, I = !!de, [ke, Ae] = m(!1), [je, Me] = m(!1), [Ne, Pe] = m([]), [L, Fe] = m(!1), Ie = p(null), [Le, R] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Re, ze] = m(0);
13605
13632
  c(() => {
13606
13633
  if (!s) return;
@@ -13740,7 +13767,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13740
13767
  justifyContent: "center",
13741
13768
  height: "40px"
13742
13769
  },
13743
- children: i ? /* @__PURE__ */ g(Cg, {
13770
+ children: i ? /* @__PURE__ */ g(Eg, {
13744
13771
  logo: i,
13745
13772
  style: {
13746
13773
  height: "34px",
@@ -13753,7 +13780,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
13753
13780
  height: "40px",
13754
13781
  flexShrink: 0
13755
13782
  },
13756
- children: /* @__PURE__ */ g(wg, { title: e.chatTitle })
13783
+ children: /* @__PURE__ */ g(Dg, { title: e.chatTitle })
13757
13784
  })
13758
13785
  }), o && /* @__PURE__ */ g("div", {
13759
13786
  style: {
@@ -14036,7 +14063,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14036
14063
  })
14037
14064
  ]
14038
14065
  }),
14039
- /* @__PURE__ */ g(dh, {
14066
+ /* @__PURE__ */ g(mh, {
14040
14067
  webRTCError: se,
14041
14068
  micError: ce,
14042
14069
  setMicError: le,
@@ -14044,7 +14071,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14044
14071
  isRateLimited: E,
14045
14072
  rateLimitMessage: D
14046
14073
  }),
14047
- ge && /* @__PURE__ */ g(Oh, {
14074
+ ge && /* @__PURE__ */ g(jh, {
14048
14075
  agentName: v,
14049
14076
  agentHeadshot: y,
14050
14077
  fallbackAgentName: b,
@@ -14178,17 +14205,17 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14178
14205
  children: "No previous chats found."
14179
14206
  })
14180
14207
  })]
14181
- }) : null, De ? /* @__PURE__ */ g(ch, {
14208
+ }) : null, De ? /* @__PURE__ */ g(dh, {
14182
14209
  chatHistory: l,
14183
14210
  isAiTyping: u,
14184
14211
  isLoading: T,
14185
14212
  isAgentTyping: d,
14186
- setReplyContext: oe,
14187
- TypingDots: jg,
14213
+ setReplyContext: M,
14214
+ TypingDots: Pg,
14188
14215
  primaryColor: n,
14189
14216
  agentHeadshot: y,
14190
14217
  agentDisplayName: v || b,
14191
- botAvatarNode: /* @__PURE__ */ g(Ag, { orbColors: t })
14218
+ botAvatarNode: /* @__PURE__ */ g(Ng, { orbColors: t })
14192
14219
  }) : F ? /* @__PURE__ */ _("div", {
14193
14220
  style: {
14194
14221
  flex: 1,
@@ -14229,7 +14256,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14229
14256
  padding: "28px 24px"
14230
14257
  },
14231
14258
  children: [
14232
- /* @__PURE__ */ g(Eg, {
14259
+ /* @__PURE__ */ g(kg, {
14233
14260
  size: 94,
14234
14261
  orbColors: t
14235
14262
  }),
@@ -14279,7 +14306,7 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14279
14306
  ]
14280
14307
  })]
14281
14308
  }),
14282
- M && /* @__PURE__ */ _("div", {
14309
+ ae && /* @__PURE__ */ _("div", {
14283
14310
  style: {
14284
14311
  margin: "0 16px 8px",
14285
14312
  padding: "9px 14px",
@@ -14318,9 +14345,9 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14318
14345
  flexShrink: 0,
14319
14346
  position: "relative",
14320
14347
  zIndex: 1,
14321
- padding: ne ? "6px 0 0" : "12px 0 0"
14348
+ padding: re ? "6px 0 0" : "12px 0 0"
14322
14349
  },
14323
- children: /* @__PURE__ */ g(uh, {
14350
+ children: /* @__PURE__ */ g(ph, {
14324
14351
  input: x,
14325
14352
  setInput: S,
14326
14353
  onSubmit: C,
@@ -14330,17 +14357,17 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14330
14357
  showVoiceToggle: f === "agent",
14331
14358
  activeScreen: f,
14332
14359
  inputDisabled: Oe,
14333
- replyContext: ae,
14334
- clearReplyContext: () => oe(null),
14335
- onFileSelect: k,
14336
- selectedFile: O,
14337
- onRemoveSelectedFile: A,
14338
- attachmentError: ee,
14339
- isUploadingAttachment: te,
14340
- requiresEmail: ne,
14341
- emailInput: j,
14342
- setEmailInput: re,
14343
- emailError: ie,
14360
+ replyContext: oe,
14361
+ clearReplyContext: () => M(null),
14362
+ onFileSelect: O,
14363
+ selectedFile: ee,
14364
+ onRemoveSelectedFile: k,
14365
+ attachmentError: te,
14366
+ isUploadingAttachment: ne,
14367
+ requiresEmail: re,
14368
+ emailInput: A,
14369
+ setEmailInput: ie,
14370
+ emailError: j,
14344
14371
  inputPlaceholder: e.inputPlaceholder
14345
14372
  })
14346
14373
  }),
@@ -14394,14 +14421,14 @@ function Mg({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14394
14421
  ]
14395
14422
  });
14396
14423
  }
14397
- function Ng() {
14398
- let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: re, openWidget: ie, captureVisitorEmail: M, setVoiceMode: ae, endConversation: oe, startNewChat: le, acceptCall: ue, rejectCall: de, endWebRTCCall: fe, toggleCallMute: pe, dismissCallError: me, startTyping: he, stopTyping: N, updateTypingDraft: ge, getVisitorChatHistory: _e, resumeChat: ve, isSessionRestoring: ye, openToChatCounter: be, voiceEndCounter: xe } = Cn();
14424
+ function Ig() {
14425
+ 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: j, captureVisitorEmail: ae, setVoiceMode: oe, endConversation: M, startNewChat: le, acceptCall: ue, rejectCall: de, endWebRTCCall: fe, toggleCallMute: pe, dismissCallError: me, startTyping: he, stopTyping: N, updateTypingDraft: ge, getVisitorChatHistory: _e, resumeChat: ve, isSessionRestoring: ye, openToChatCounter: be, voiceEndCounter: xe } = Cn();
14399
14426
  c(() => {
14400
14427
  try {
14401
14428
  or();
14402
14429
  } catch {}
14403
14430
  }, []), c(() => {
14404
- be && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (ae?.(!1), H("text_chat"));
14431
+ be && V !== "voice_mode" && V !== "text_chat" && V !== "call_screen" && (oe?.(!1), H("text_chat"));
14405
14432
  }, [be]);
14406
14433
  let Se = t?.widgetSettings || {}, Ce = n?.widgetSettings || {}, P = {
14407
14434
  ...Se.branding || {},
@@ -14416,7 +14443,7 @@ function Ng() {
14416
14443
  small: 50,
14417
14444
  medium: 64,
14418
14445
  large: 80
14419
- }, Me = je[F.orbSize] || je.small, Ne = F.position || "bottom-right", Pe = P.fallbackAgentName || "Agent", L = bg(I ?? F.chatBgColors), Fe = P.logo || P.logoUrl || null, Ie = A || "en", Le = Se.recommendations?.[Ie] || [], R = (Ce.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14446
+ }, Me = je[F.orbSize] || je.small, Ne = F.position || "bottom-right", Pe = P.fallbackAgentName || "Agent", L = Cg(I ?? F.chatBgColors), Fe = P.logo || P.logoUrl || null, Ie = k || "en", Le = Se.recommendations?.[Ie] || [], R = (Ce.recommendations?.[Ie] ?? Le).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
14420
14447
  id: e.key || `qr-${t}`,
14421
14448
  label: e.label,
14422
14449
  message: e.label,
@@ -14437,7 +14464,7 @@ function Ng() {
14437
14464
  ...Ce.pageVisibility || {}
14438
14465
  };
14439
14466
  return Array.isArray(e.allowedPaths) ? e.allowedPaths.filter(Boolean) : [];
14440
- })(), qe = Ke.length === 0 || Ke.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? We.startsWith(e.slice(0, -1)) : We.replace(/\/$/, "") === e.replace(/\/$/, "")), Je = Se.greetings?.[A] || Ce.greetings?.[A] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
14467
+ })(), qe = Ke.length === 0 || Ke.some((e) => e === "*" || e === "/*" ? !0 : e.endsWith("/*") ? We.startsWith(e.slice(0, -1)) : We.replace(/\/$/, "") === e.replace(/\/$/, "")), Je = Se.greetings?.[k] || Ce.greetings?.[k] || P.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Ye = {
14441
14468
  entryPrompt: P.entryPrompt || "Do you want to explore in a new way?",
14442
14469
  yesLabel: P.yesLabel || "Yes",
14443
14470
  laterLabel: P.laterLabel || "Later",
@@ -14474,11 +14501,11 @@ function Ng() {
14474
14501
  } catch {}
14475
14502
  let n = De(), r = z ? we(z) : null, i = n || !!r?.transcript;
14476
14503
  if (t) {
14477
- ie?.({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14504
+ j?.({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14478
14505
  return;
14479
14506
  }
14480
14507
  if (ke()) {
14481
- ie?.({ notifyChatInitiated: !1 }), H("text_chat");
14508
+ j?.({ notifyChatInitiated: !1 }), H("text_chat");
14482
14509
  return;
14483
14510
  }
14484
14511
  if (i) {
@@ -14486,7 +14513,7 @@ function Ng() {
14486
14513
  H("minimized_orb");
14487
14514
  return;
14488
14515
  }
14489
- ie?.({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14516
+ j?.({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14490
14517
  return;
14491
14518
  }
14492
14519
  if (z) try {
@@ -14507,7 +14534,7 @@ function Ng() {
14507
14534
  let Ot = o(() => {
14508
14535
  ht(null), _t("");
14509
14536
  }, []), kt = o((e) => {
14510
- let t = rh(e);
14537
+ let t = oh(e);
14511
14538
  if (t) {
14512
14539
  ht(null), _t(t);
14513
14540
  return;
@@ -14550,7 +14577,7 @@ function Ng() {
14550
14577
  hasIncomingCall: !!w?.callId,
14551
14578
  activeCallId: T,
14552
14579
  callConnectionState: E
14553
- }), wt.current = e, V === "voice_mode" && ae?.(!1), ie?.(), At());
14580
+ }), wt.current = e, V === "voice_mode" && oe?.(!1), j?.(), At());
14554
14581
  }
14555
14582
  }, [
14556
14583
  T,
@@ -14558,8 +14585,8 @@ function Ng() {
14558
14585
  At,
14559
14586
  w?.callId,
14560
14587
  i,
14561
- ie,
14562
- ae,
14588
+ j,
14589
+ oe,
14563
14590
  V
14564
14591
  ]), c(() => {
14565
14592
  !w && !T && V === "call_screen" && H("text_chat");
@@ -14605,7 +14632,7 @@ function Ng() {
14605
14632
  st("Please enter a valid email so we can continue helping you.");
14606
14633
  return;
14607
14634
  }
14608
- await M(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
14635
+ await ae(e), st(""), lt(!0), setTimeout(() => lt(!1), 3e3);
14609
14636
  return;
14610
14637
  }
14611
14638
  let t = Mt(it);
@@ -14613,8 +14640,8 @@ function Ng() {
14613
14640
  if (mt) {
14614
14641
  try {
14615
14642
  yt(!0), _t("");
14616
- let e = await re(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${ah(mt)}`;
14617
- rt(""), U(null), Ot(), await j(r, "", t, {
14643
+ let e = await ie(mt), n = e?.data || e, r = nt.trim() || `Shared file: ${ch(mt)}`;
14644
+ rt(""), U(null), Ot(), await A(r, "", t, {
14618
14645
  type: "file",
14619
14646
  metadata: {
14620
14647
  fileUrl: n?.fileUrl,
@@ -14631,7 +14658,7 @@ function Ng() {
14631
14658
  return;
14632
14659
  }
14633
14660
  let n = nt.trim();
14634
- rt(""), U(null), await j(n, "", t);
14661
+ rt(""), U(null), await A(n, "", t);
14635
14662
  }, Pt = o(() => {
14636
14663
  r.length !== 0 && le?.();
14637
14664
  }, [r.length, le]), Ft = (e) => {
@@ -14640,11 +14667,11 @@ function Ng() {
14640
14667
  }, It = o(async (e) => {
14641
14668
  if (C || b) return;
14642
14669
  let t = e.message || e.label || e.text || "";
14643
- t.trim() && await j(t.trim(), "");
14670
+ t.trim() && await A(t.trim(), "");
14644
14671
  }, [
14645
14672
  C,
14646
14673
  b,
14647
- j
14674
+ A
14648
14675
  ]), Lt = G && V === "entry_prompt" ? { inset: 0 } : G && V === "text_chat" ? {
14649
14676
  left: 0,
14650
14677
  right: 0,
@@ -14690,11 +14717,11 @@ function Ng() {
14690
14717
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
14691
14718
  }
14692
14719
  } catch {}
14693
- ie({ notifyChatInitiated: !0 }), ae?.(!0), H("voice_mode");
14720
+ j({ notifyChatInitiated: !0 }), oe?.(!0), H("voice_mode");
14694
14721
  }, Vt = () => {
14695
- ie({ notifyChatInitiated: !0 }), ae?.(!1), H("text_chat");
14722
+ j({ notifyChatInitiated: !0 }), oe?.(!1), H("text_chat");
14696
14723
  }, Ht = () => {
14697
- ae?.(!1), Rt();
14724
+ oe?.(!1), Rt();
14698
14725
  };
14699
14726
  return e !== "ready" || !Ue || Ee.chat === !1 || !qe ? null : /* @__PURE__ */ _("div", {
14700
14727
  className: "flowengage-widget-root",
@@ -14706,7 +14733,7 @@ function Ng() {
14706
14733
  onWheel: (e) => e.stopPropagation(),
14707
14734
  onTouchMove: (e) => e.stopPropagation(),
14708
14735
  children: [
14709
- V === "entry_prompt" && /* @__PURE__ */ g(Dg, {
14736
+ V === "entry_prompt" && /* @__PURE__ */ g(Ag, {
14710
14737
  copy: Ye,
14711
14738
  orbColors: I,
14712
14739
  primaryColor: Ae,
@@ -14789,13 +14816,13 @@ function Ng() {
14789
14816
  children: E === "connected" ? `${Ft(ut)} with ${Ze}` : `Tap to return to ${Ze}`
14790
14817
  })]
14791
14818
  })]
14792
- }), /* @__PURE__ */ g(Eg, {
14819
+ }), /* @__PURE__ */ g(kg, {
14793
14820
  size: Me,
14794
14821
  orbColors: I,
14795
14822
  onClick: T ? At : Oe ? zt : Vt
14796
14823
  })]
14797
14824
  }),
14798
- V === "connection_modal" && /* @__PURE__ */ g(Og, {
14825
+ V === "connection_modal" && /* @__PURE__ */ g(jg, {
14799
14826
  copy: Ye,
14800
14827
  orbColors: I,
14801
14828
  primaryColor: Ae,
@@ -14805,32 +14832,32 @@ function Ng() {
14805
14832
  isMobile: G,
14806
14833
  isClosing: St
14807
14834
  }),
14808
- V === "voice_mode" && /* @__PURE__ */ g(kg, {
14835
+ V === "voice_mode" && /* @__PURE__ */ g(Mg, {
14809
14836
  orbColors: I,
14810
14837
  onEnterChat: Vt,
14811
14838
  onEndChat: Ht,
14812
14839
  agentId: Xe,
14813
14840
  siteId: z,
14814
14841
  apiBaseUrl: B,
14815
- chatId: ee,
14816
- historyRef: te,
14817
- onMessageSync: ne,
14842
+ chatId: te,
14843
+ historyRef: ne,
14844
+ onMessageSync: re,
14818
14845
  voiceEndCounter: xe,
14819
14846
  websiteName: t?.websiteName,
14820
14847
  voiceFirstMessage: Se.voiceFirstMessage || null,
14821
- captureVisitorEmail: M,
14848
+ captureVisitorEmail: ae,
14822
14849
  emailRequired: !h,
14823
14850
  emailCaptureEnabled: P.disableEmailCapture !== !0,
14824
14851
  listeningLabel: P.voiceListeningLabel || "Listening...",
14825
14852
  enterChatModeLabel: P.voiceEnterChatLabel || "Enter Chat Mode",
14826
14853
  endConversationLabel: P.voiceEndConversationLabel || "End Conversation"
14827
14854
  }, "voice"),
14828
- V === "call_screen" && /* @__PURE__ */ g(Dh, {
14855
+ V === "call_screen" && /* @__PURE__ */ g(Ah, {
14829
14856
  incomingCall: w,
14830
14857
  activeCallId: T,
14831
14858
  callConnectionState: E,
14832
14859
  callDurationSeconds: ut,
14833
- isCallMuted: O,
14860
+ isCallMuted: ee,
14834
14861
  agentName: Ze,
14835
14862
  agentHeadshot: Qe,
14836
14863
  fallbackAgentName: Pe,
@@ -14844,7 +14871,7 @@ function Ng() {
14844
14871
  orbColors: I,
14845
14872
  chatHistory: r
14846
14873
  }),
14847
- V === "text_chat" && /* @__PURE__ */ g(Mg, {
14874
+ V === "text_chat" && /* @__PURE__ */ g(Fg, {
14848
14875
  isClosing: St,
14849
14876
  copy: Ye,
14850
14877
  orbColors: I,
@@ -14880,12 +14907,12 @@ function Ng() {
14880
14907
  emailCaptureSuccess: ct,
14881
14908
  replyContext: it,
14882
14909
  setReplyContext: U,
14883
- webRTCError: k,
14910
+ webRTCError: O,
14884
14911
  micError: ft,
14885
14912
  setMicError: pt,
14886
14913
  dismissCallError: me,
14887
14914
  activeCallId: T,
14888
- isCallMuted: O,
14915
+ isCallMuted: ee,
14889
14916
  toggleCallMute: pe,
14890
14917
  endWebRTCCall: fe,
14891
14918
  formatCallDuration: Ft,
@@ -14910,7 +14937,7 @@ function Ng() {
14910
14937
  }
14911
14938
  //#endregion
14912
14939
  //#region src/components/ErrorBoundary.jsx
14913
- var Pg = class extends e.Component {
14940
+ var Lg = class extends e.Component {
14914
14941
  constructor(e) {
14915
14942
  super(e), this.state = { hasError: !1 };
14916
14943
  }
@@ -14925,4 +14952,4 @@ var Pg = class extends e.Component {
14925
14952
  }
14926
14953
  };
14927
14954
  //#endregion
14928
- export { bh as AnimatedOrb, Pg as ErrorBoundary, Mr as FlowEngageProvider, Ng as FlowEngageWidget, Cn as useFlowEngage };
14955
+ export { Ch as AnimatedOrb, Lg as ErrorBoundary, Mr as FlowEngageProvider, Ig as FlowEngageWidget, Cn as useFlowEngage };