@flowengage/react-chatbot 5.0.63 → 5.0.65

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.
@@ -214,9 +214,13 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
214
214
  if (!t) return null;
215
215
  let n = window.sessionStorage.getItem(t);
216
216
  if (!n) return null;
217
- window.sessionStorage.removeItem(t);
218
- let r = JSON.parse(n);
219
- return !r || typeof r.previousPage != "string" || Number.isFinite(r.ts) && Date.now() - r.ts > 6e4 || r.targetPath && (window.location.pathname.replace(/\/$/, "") || "/") !== (r.targetPath.replace(/\/$/, "") || "/") ? null : { previousPage: r.previousPage };
217
+ let r;
218
+ try {
219
+ r = JSON.parse(n);
220
+ } catch {
221
+ return window.sessionStorage.removeItem(t), null;
222
+ }
223
+ return !r || typeof r.previousPage != "string" || Number.isFinite(r.ts) && Date.now() - r.ts > 6e4 ? (window.sessionStorage.removeItem(t), null) : r.targetPath && (window.location.pathname.replace(/\/$/, "") || "/") !== (r.targetPath.replace(/\/$/, "") || "/") ? null : (window.sessionStorage.removeItem(t), { previousPage: r.previousPage });
220
224
  } catch {
221
225
  return null;
222
226
  }
@@ -28832,53 +28836,39 @@ function $(...e) {
28832
28836
  function WO(e) {
28833
28837
  return new Promise((t) => setTimeout(t, e));
28834
28838
  }
28835
- function GO(e = 10) {
28836
- if (typeof document > "u") return [];
28837
- try {
28838
- let t = /* @__PURE__ */ new Set(), n = [], r = document.querySelectorAll("h1, h2, h3");
28839
- for (let i of r) {
28840
- if (qO(i)) continue;
28841
- let r = (i.textContent || "").trim().replace(/\s+/g, " ");
28842
- if (!(!r || r.length < 3 || r.length > 120) && !t.has(r.toLowerCase()) && (t.add(r.toLowerCase()), n.push(r), n.length >= e)) break;
28843
- }
28844
- return n;
28845
- } catch {
28846
- return [];
28847
- }
28848
- }
28849
- var KO = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
28850
- function qO(e) {
28839
+ var GO = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
28840
+ function KO(e) {
28851
28841
  if (!e || typeof e.closest != "function") return !1;
28852
28842
  try {
28853
- return !!e.closest(KO);
28843
+ return !!e.closest(GO);
28854
28844
  } catch {
28855
28845
  return !1;
28856
28846
  }
28857
28847
  }
28858
- function JO(e) {
28848
+ function qO(e) {
28859
28849
  try {
28860
28850
  let t = e.ownerDocument?.defaultView;
28861
28851
  if (t) return t.getComputedStyle(e);
28862
28852
  } catch {}
28863
28853
  return window.getComputedStyle(e);
28864
28854
  }
28865
- function YO(e) {
28855
+ function JO(e) {
28866
28856
  let t = /* @__PURE__ */ new Set();
28867
28857
  function n(r) {
28868
28858
  if (!r || t.has(r)) return;
28869
28859
  t.add(r), e(r);
28870
28860
  let i = r.querySelectorAll("iframe");
28871
- for (let e of i) if (!qO(e)) try {
28861
+ for (let e of i) if (!KO(e)) try {
28872
28862
  let t = e.contentDocument;
28873
28863
  t && n(t);
28874
28864
  } catch {}
28875
28865
  }
28876
28866
  typeof document < "u" && n(document);
28877
28867
  }
28878
- function XO(e) {
28868
+ function YO(e) {
28879
28869
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
28880
28870
  }
28881
- function ZO(e) {
28871
+ function XO(e) {
28882
28872
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
28883
28873
  if (n) {
28884
28874
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -28886,42 +28876,42 @@ function ZO(e) {
28886
28876
  let e = t.getElementById(n);
28887
28877
  e?.textContent && r.push(e.textContent.trim());
28888
28878
  } catch {}
28889
- if (r.length) return XO(r.join(" "));
28879
+ if (r.length) return YO(r.join(" "));
28890
28880
  }
28891
- if (e.labels && e.labels.length) return XO(e.labels[0].textContent);
28881
+ if (e.labels && e.labels.length) return YO(e.labels[0].textContent);
28892
28882
  let r = e.id;
28893
28883
  if (r) try {
28894
28884
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
28895
- if (e) return XO(e.textContent);
28885
+ if (e) return YO(e.textContent);
28896
28886
  } catch {
28897
28887
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
28898
- if (e) return XO(e.textContent);
28888
+ if (e) return YO(e.textContent);
28899
28889
  }
28900
28890
  let i = e.previousElementSibling;
28901
28891
  for (let e = 0; e < 6 && i; e += 1) {
28902
- if (i.tagName === "LABEL") return XO(i.textContent);
28892
+ if (i.tagName === "LABEL") return YO(i.textContent);
28903
28893
  let e = (i.className || "").toString().toLowerCase();
28904
28894
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
28905
- let e = XO(i.textContent);
28895
+ let e = YO(i.textContent);
28906
28896
  if (e) return e;
28907
28897
  }
28908
28898
  i = i.previousElementSibling;
28909
28899
  }
28910
28900
  let a = e.parentElement;
28911
28901
  for (let e = 0; e < 5 && a; e += 1) {
28912
- if (a.tagName === "LABEL") return XO(a.textContent);
28902
+ if (a.tagName === "LABEL") return YO(a.textContent);
28913
28903
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
28914
- if (e?.textContent) return XO(e.textContent);
28904
+ if (e?.textContent) return YO(e.textContent);
28915
28905
  a = a.parentElement;
28916
28906
  }
28917
28907
  let o = e.getAttribute("aria-label");
28918
- return o ? XO(o) : null;
28908
+ return o ? YO(o) : null;
28919
28909
  }
28920
- function QO() {
28910
+ function ZO() {
28921
28911
  let e = [];
28922
- return YO((t) => {
28912
+ return JO((t) => {
28923
28913
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
28924
- if (qO(e)) return !1;
28914
+ if (KO(e)) return !1;
28925
28915
  let t = (e.type || "").toLowerCase();
28926
28916
  if ([
28927
28917
  "hidden",
@@ -28930,32 +28920,32 @@ function QO() {
28930
28920
  "image"
28931
28921
  ].includes(t) || e.disabled || e.readOnly) return !1;
28932
28922
  try {
28933
- let t = JO(e);
28923
+ let t = qO(e);
28934
28924
  if (t.display === "none" || t.visibility === "hidden") return !1;
28935
28925
  } catch {}
28936
28926
  return !0;
28937
28927
  }));
28938
28928
  }), e;
28939
28929
  }
28940
- function $O() {
28941
- return QO().map((e, t) => ({
28930
+ function QO() {
28931
+ return ZO().map((e, t) => ({
28942
28932
  formIndex: 0,
28943
28933
  fieldIndex: t,
28944
28934
  tag: e.tagName,
28945
28935
  type: e.type || "text",
28946
28936
  name: e.name || null,
28947
28937
  id: e.id || null,
28948
- label: ZO(e),
28938
+ label: XO(e),
28949
28939
  placeholder: e.placeholder || null
28950
28940
  }));
28951
28941
  }
28952
- function ek() {
28942
+ function $O() {
28953
28943
  let e = [];
28954
- return YO((t) => {
28944
+ return JO((t) => {
28955
28945
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
28956
- if (qO(e) || e.disabled) return !1;
28946
+ if (KO(e) || e.disabled) return !1;
28957
28947
  try {
28958
- let t = JO(e);
28948
+ let t = qO(e);
28959
28949
  if (t.display === "none" || t.visibility === "hidden") return !1;
28960
28950
  } catch {}
28961
28951
  return !0;
@@ -28967,15 +28957,15 @@ function ek() {
28967
28957
  type: e.type || e.tagName
28968
28958
  }));
28969
28959
  }
28970
- function tk(e) {
28960
+ function ek(e) {
28971
28961
  return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
28972
28962
  }
28973
- function nk(e) {
28974
- let t = tk(e);
28963
+ function tk(e) {
28964
+ let t = ek(e);
28975
28965
  return t = t.replace(/\s+field\s*$/i, "").trim(), t;
28976
28966
  }
28977
- function rk(e, t) {
28978
- let n = nk(t);
28967
+ function nk(e, t) {
28968
+ let n = tk(t);
28979
28969
  if (!n) return 0;
28980
28970
  let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
28981
28971
  if (r === "url" && /url|website|domain|site|audit/.test(n) || (i === "url-input" || i.endsWith("-url-input")) && /url|website|domain|site|audit/.test(n)) return 100;
@@ -28983,12 +28973,12 @@ function rk(e, t) {
28983
28973
  e.name,
28984
28974
  e.id,
28985
28975
  e.placeholder,
28986
- ZO(e),
28976
+ XO(e),
28987
28977
  e.getAttribute("aria-label"),
28988
28978
  e.getAttribute("title"),
28989
28979
  e.getAttribute("data-testid"),
28990
28980
  e.getAttribute("autocomplete")
28991
- ].filter(Boolean).map((e) => tk(e)), o = 0;
28981
+ ].filter(Boolean).map((e) => ek(e)), o = 0;
28992
28982
  for (let e of a) {
28993
28983
  if (!e) continue;
28994
28984
  if (e.includes(n) || n.includes(e)) {
@@ -29003,16 +28993,16 @@ function rk(e, t) {
29003
28993
  }
29004
28994
  return o;
29005
28995
  }
29006
- var ik = 28;
29007
- function ak(e, t) {
28996
+ var rk = 28;
28997
+ function ik(e, t) {
29008
28998
  let n = null, r = 0;
29009
28999
  for (let i of e) {
29010
- let e = rk(i, t);
29000
+ let e = nk(i, t);
29011
29001
  e > r && (r = e, n = i);
29012
29002
  }
29013
- return !n || r < ik ? null : n;
29003
+ return !n || r < rk ? null : n;
29014
29004
  }
29015
- function ok(e, t, n) {
29005
+ function ak(e, t, n) {
29016
29006
  let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
29017
29007
  if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
29018
29008
  let a = null, o = 0;
@@ -29032,7 +29022,7 @@ function ok(e, t, n) {
29032
29022
  t.name,
29033
29023
  t.id,
29034
29024
  t.placeholder,
29035
- ZO(t),
29025
+ XO(t),
29036
29026
  t.getAttribute("aria-label"),
29037
29027
  t.getAttribute("autocomplete")
29038
29028
  ].filter(Boolean).join(" ").toLowerCase();
@@ -29040,15 +29030,15 @@ function ok(e, t, n) {
29040
29030
  }
29041
29031
  return !a || o < 42 ? null : a;
29042
29032
  }
29043
- function sk(e) {
29033
+ function ok(e) {
29044
29034
  let t = String(e ?? "").trim();
29045
29035
  return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
29046
29036
  }
29047
- function ck(e) {
29037
+ function sk(e) {
29048
29038
  let t = String(e ?? "").toLowerCase().trim();
29049
29039
  return t ? !!(t === "url" || t === "website" || t === "website url" || t === "website_url" || t === "enter website url" || t.includes("website") || t.includes("domain") || /(enter\s+website|site\s*url|page\s*url)/.test(t)) : !1;
29050
29040
  }
29051
- function lk(e) {
29041
+ function ck(e) {
29052
29042
  if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
29053
29043
  let t = (e.type || "").toLowerCase();
29054
29044
  return ![
@@ -29060,22 +29050,22 @@ function lk(e) {
29060
29050
  "file"
29061
29051
  ].includes(t);
29062
29052
  }
29063
- function uk(e) {
29064
- if (!lk(e)) return !1;
29053
+ function lk(e) {
29054
+ if (!ck(e)) return !1;
29065
29055
  let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
29066
29056
  e.name,
29067
29057
  e.id,
29068
29058
  e.placeholder,
29069
- ZO(e),
29059
+ XO(e),
29070
29060
  e.getAttribute("aria-label")
29071
29061
  ].filter(Boolean).join(" ").toLowerCase();
29072
29062
  return t === "url" || n === "url-input" || n.endsWith("-url-input") || /(website\s*url|enter\s+website|site\s*url)/.test(r) || /(website|domain)/.test(r) && /(url|site)/.test(r);
29073
29063
  }
29074
- function dk(e, t, n) {
29075
- let r = String(t ?? ""), i = String(n ?? ""), a = mk(e, r) || ak(e, r) || ok(e, r, i);
29064
+ function uk(e, t, n) {
29065
+ let r = String(t ?? ""), i = String(n ?? ""), a = pk(e, r) || ik(e, r) || ak(e, r, i);
29076
29066
  if (!a) return [];
29077
29067
  let o = new Set([a]);
29078
- if (sk(i) && ck(r)) for (let t of e) t !== a && uk(t) && o.add(t);
29068
+ if (ok(i) && sk(r)) for (let t of e) t !== a && lk(t) && o.add(t);
29079
29069
  let s = Array.from(o);
29080
29070
  return s.sort((e, t) => {
29081
29071
  if (e === t) return 0;
@@ -29083,7 +29073,7 @@ function dk(e, t, n) {
29083
29073
  return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
29084
29074
  }), s;
29085
29075
  }
29086
- function fk(e, t) {
29076
+ function dk(e, t) {
29087
29077
  try {
29088
29078
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
29089
29079
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -29098,17 +29088,17 @@ function fk(e, t) {
29098
29088
  return Infinity;
29099
29089
  }
29100
29090
  }
29101
- function pk(e) {
29091
+ function fk(e) {
29102
29092
  if (!e || typeof e != "string") return null;
29103
29093
  let t = null;
29104
- return YO((n) => {
29094
+ return JO((n) => {
29105
29095
  try {
29106
29096
  let r = n.getElementById(e);
29107
- r && !qO(r) && r.matches?.("input, select, textarea") && (t = r);
29097
+ r && !KO(r) && r.matches?.("input, select, textarea") && (t = r);
29108
29098
  } catch {}
29109
29099
  }), t;
29110
29100
  }
29111
- function mk(e, t) {
29101
+ function pk(e, t) {
29112
29102
  let n = String(t ?? "").trim();
29113
29103
  if (!n) return null;
29114
29104
  let r = n.match(/^name:\s*([\w.-]+)$/i);
@@ -29118,12 +29108,12 @@ function mk(e, t) {
29118
29108
  }
29119
29109
  let i = n.match(/^id:\s*([\w.-]+)$/i);
29120
29110
  if (i) {
29121
- let e = pk(i[1]);
29111
+ let e = fk(i[1]);
29122
29112
  if (e) return e;
29123
29113
  }
29124
29114
  let a = n.startsWith("#") ? n.slice(1) : n;
29125
29115
  if (/^[\w-]+$/.test(a)) {
29126
- let e = pk(a);
29116
+ let e = fk(a);
29127
29117
  if (e) return e;
29128
29118
  }
29129
29119
  let o = n.toLowerCase().replace(/\s+/g, " ");
@@ -29133,7 +29123,7 @@ function mk(e, t) {
29133
29123
  }
29134
29124
  return null;
29135
29125
  }
29136
- function hk(e, t) {
29126
+ function mk(e, t) {
29137
29127
  let n = String(t || "").toLowerCase().trim();
29138
29128
  if (!n) return 0;
29139
29129
  let r = [
@@ -29149,13 +29139,13 @@ function hk(e, t) {
29149
29139
  for (let e of i) r.includes(e) && (a += 1);
29150
29140
  return a / i.length * 92;
29151
29141
  }
29152
- function gk(e, t) {
29142
+ function hk(e, t) {
29153
29143
  let n = [];
29154
- YO((e) => {
29144
+ JO((e) => {
29155
29145
  n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
29156
- if (qO(e) || e.disabled) return !1;
29146
+ if (KO(e) || e.disabled) return !1;
29157
29147
  try {
29158
- let t = JO(e);
29148
+ let t = qO(e);
29159
29149
  if (t.display === "none" || t.visibility === "hidden") return !1;
29160
29150
  } catch {}
29161
29151
  return !0;
@@ -29163,7 +29153,7 @@ function gk(e, t) {
29163
29153
  });
29164
29154
  let r = 0, i = n.map((t) => ({
29165
29155
  el: t,
29166
- s: hk(t, e)
29156
+ s: mk(t, e)
29167
29157
  }));
29168
29158
  for (let { s: e } of i) e > r && (r = e);
29169
29159
  if (r < 36) return null;
@@ -29173,14 +29163,14 @@ function gk(e, t) {
29173
29163
  if (o.length) {
29174
29164
  let e = a[0], t = Infinity;
29175
29165
  for (let n of a) for (let r of o) {
29176
- let i = fk(n, r);
29166
+ let i = dk(n, r);
29177
29167
  i < t && (t = i, e = n);
29178
29168
  }
29179
29169
  return e;
29180
29170
  }
29181
29171
  return a[0];
29182
29172
  }
29183
- function _k(e) {
29173
+ function gk(e) {
29184
29174
  if (e == null) return {};
29185
29175
  if (typeof e == "string") {
29186
29176
  let t = e.trim();
@@ -29193,8 +29183,8 @@ function _k(e) {
29193
29183
  }
29194
29184
  return e;
29195
29185
  }
29196
- function vk(e) {
29197
- let t = _k(e);
29186
+ function _k(e) {
29187
+ let t = gk(e);
29198
29188
  if (Array.isArray(t) && t.length > 0) {
29199
29189
  let e = t[0];
29200
29190
  if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
@@ -29222,7 +29212,7 @@ function vk(e) {
29222
29212
  value: e?.value ?? e?.Value
29223
29213
  })) : [];
29224
29214
  }
29225
- function yk(e) {
29215
+ function vk(e) {
29226
29216
  if (!e || typeof e != "string") return [];
29227
29217
  let t = e.trim();
29228
29218
  if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
@@ -29241,7 +29231,7 @@ function yk(e) {
29241
29231
  }
29242
29232
  return [];
29243
29233
  }
29244
- function bk(e) {
29234
+ function yk(e) {
29245
29235
  if (!e || typeof e != "string") return [];
29246
29236
  let t = e.trim();
29247
29237
  if (!t) return [];
@@ -29277,17 +29267,17 @@ function bk(e) {
29277
29267
  }
29278
29268
  return n;
29279
29269
  }
29280
- function xk(e) {
29270
+ function bk(e) {
29281
29271
  if (!e || typeof e != "object") return null;
29282
29272
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
29283
29273
  return t == null ? null : String(t).trim() || null;
29284
29274
  }
29285
- function Sk(e) {
29275
+ function xk(e) {
29286
29276
  if (!e || typeof e != "object") return null;
29287
29277
  let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
29288
29278
  return t == null ? null : String(t).trim() || null;
29289
29279
  }
29290
- function Ck(e, t, n) {
29280
+ function Sk(e, t, n) {
29291
29281
  if (!n?.skipScroll) try {
29292
29282
  e.scrollIntoView({
29293
29283
  block: "center",
@@ -29342,7 +29332,7 @@ function Ck(e, t, n) {
29342
29332
  } catch {}
29343
29333
  return !0;
29344
29334
  }
29345
- function wk() {
29335
+ function Ck() {
29346
29336
  let e = {};
29347
29337
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
29348
29338
  if (t.id) return;
@@ -29357,40 +29347,11 @@ function wk() {
29357
29347
  e[r] = !0, t.id = r;
29358
29348
  });
29359
29349
  }
29360
- var Tk = [], Ek = 2.5;
29361
- function Dk(e) {
29362
- if (!e || Tk.length === 0) return;
29363
- let t = e.toLowerCase(), n = [];
29364
- for (let r of Tk) {
29365
- let i = r.label.toLowerCase().split(/\s+/), a = -1, o = i.length >= 3 ? 3 : i.length;
29366
- for (let e = Math.min(5, i.length); e >= o; e--) {
29367
- let n = i.slice(0, e).join(" "), r = t.indexOf(n);
29368
- if (r >= 0) {
29369
- a = r;
29370
- break;
29371
- }
29372
- }
29373
- let s = a > 0 ? e.slice(0, a).split(/\s+/).filter(Boolean).length : 0;
29374
- n.push({
29375
- el: r.el,
29376
- label: r.label,
29377
- delay: Math.round(s / Ek * 1e3)
29378
- });
29379
- }
29380
- Tk.length = 0, n.sort((e, t) => e.delay - t.delay);
29381
- for (let e = 1; e < n.length; e++) n[e].delay < n[e - 1].delay + 400 && (n[e].delay = n[e - 1].delay + 400);
29382
- for (let { el: e, label: t, delay: r } of n) setTimeout(() => {
29383
- CD(e), $(`highlight ✓ word-sync +${r}ms`, t);
29384
- }, r);
29385
- }
29386
- function Ok() {
29387
- Tk.length = 0;
29388
- }
29389
- function kk(e) {
29350
+ function wk(e) {
29390
29351
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
29391
29352
  flowengage_navigate: async (n) => {
29392
29353
  $("flowengage_navigate ▶ raw parameters:", n);
29393
- let i = _k(n), a = xk(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
29354
+ let i = gk(n), a = bk(i), o = i.section_text ?? i.sectionText ?? i.section, s = Array.isArray(i.expected_landmarks) ? i.expected_landmarks : Array.isArray(i.expectedLandmarks) ? i.expectedLandmarks : [];
29394
29355
  if ($("flowengage_navigate · coerced:", {
29395
29356
  url: a,
29396
29357
  sectionText: o,
@@ -29437,15 +29398,7 @@ function kk(e) {
29437
29398
  let e = new URL(a, window.location.origin).pathname, t = Date.now() + 2e3;
29438
29399
  for (; Date.now() < t && !(typeof window < "u" && window.location.pathname === e);) await new Promise((e) => setTimeout(e, 80));
29439
29400
  let n = typeof window < "u" ? window.location.pathname : e, r = typeof window < "u" ? window.location.href : a, i = n === e, o = (n.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()) || "Home";
29440
- if ($("flowengage_navigate → SPA nav complete. target:", e, "actual:", n), i) {
29441
- wr();
29442
- let e = GO();
29443
- return `OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}").${e.length > 0 ? ` Section headings on this page (use these EXACTLY for flowengage_highlight — do not guess): ${e.map((e) => `"${e}"`).join(", ")}.` : ""} Do NOT say "I have navigated you" or "I've taken you to" — the page is already loaded visually. Speak about this page immediately and highlight the first relevant section.`;
29444
- } else {
29445
- wr();
29446
- let e = GO();
29447
- return `OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}").${e.length > 0 ? ` Section headings on this page: ${e.map((e) => `"${e}"`).join(", ")}.` : ""} The visitor manually navigated here. Describe THIS page only — do not mention the page you tried to navigate to.`;
29448
- }
29401
+ return $("flowengage_navigate → SPA nav complete. target:", e, "actual:", n), i ? (wr(), `OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}"). Do NOT say "I have navigated you" or "I've taken you to" — the page is already loaded visually. Start immediately with highlights and content about THIS page.`) : (wr(), `OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}"). The visitor manually navigated here. Describe THIS page only — do not mention the page you tried to navigate to.`);
29449
29402
  } catch {}
29450
29403
  return "OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, immediately introduce the new page and continue guiding the visitor — do not wait for the user to speak first.";
29451
29404
  } catch (e) {
@@ -29461,17 +29414,14 @@ function kk(e) {
29461
29414
  },
29462
29415
  flowengage_highlight: async (e) => {
29463
29416
  $("flowengage_highlight ▶", e);
29464
- let t = _k(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText, i = r || n || "";
29465
- wk();
29466
- let a = hr(n || null, r || null);
29467
- return !a && r && (await new Promise((e) => setTimeout(e, 500)), wk(), a = hr(null, r)), a ? (Tk.push({
29468
- el: a,
29469
- label: i
29470
- }), $("flowengage_highlight ◷ queued for word-sync", i), `OK_HIGHLIGHT: "${i}" queued. Continue speaking — highlights are timed automatically.`) : ($("flowengage_highlight ✖ no element for:", i), `HIGHLIGHT_NOT_FOUND: "${i}" — section not found. Do NOT apologize or mention this. Continue speaking naturally. Try a shorter phrase (first 2-3 words) next time.`);
29417
+ let t = gk(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
29418
+ Ck();
29419
+ let i = hr(n || null, r || null);
29420
+ return !i && r && (await new Promise((e) => setTimeout(e, 500)), Ck(), i = hr(null, r)), i ? (CD(i), $("flowengage_highlight ✓", r || n), `OK_HIGHLIGHT: "${r || n}". WALKTHROUGH: If you are mid-walkthrough and have more sections to cover, continue immediately to the next section — do NOT pause or wait for the visitor to speak between sections.`) : ($("flowengage_highlight ✖ no element for:", r || n), `Could not find "${r || n}" on the current page. Try a shorter phrase matching a visible heading.`);
29471
29421
  },
29472
29422
  flowengage_read_content: async (e) => {
29473
29423
  $("flowengage_read_content ▶", e);
29474
- let t = _k(e), n = t?.section_text || t?.sectionText || "";
29424
+ let t = gk(e), n = t?.section_text || t?.sectionText || "";
29475
29425
  try {
29476
29426
  let e = "";
29477
29427
  if (n) {
@@ -29494,7 +29444,7 @@ function kk(e) {
29494
29444
  },
29495
29445
  flowengage_search: async (e) => {
29496
29446
  $("flowengage_search ▶", e);
29497
- let r = Sk(_k(e));
29447
+ let r = xk(gk(e));
29498
29448
  if ($("flowengage_search · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), !r) return $("flowengage_search ✖ missing query"), "Missing query parameter.";
29499
29449
  if (!t) return $("flowengage_search ✖ no siteId"), "Site is not configured for search.";
29500
29450
  if (!n) return $("flowengage_search ✖ no api base"), "API base URL is missing; cannot search.";
@@ -29526,7 +29476,7 @@ function kk(e) {
29526
29476
  },
29527
29477
  flowengage_page_content: async (e) => {
29528
29478
  $("flowengage_page_content ▶", e);
29529
- let r = _k(e), i = r?.url || r?.page_url || "";
29479
+ let r = gk(e), i = r?.url || r?.page_url || "";
29530
29480
  if ($("flowengage_page_content · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("flowengage_page_content ✖ missing url"), "Missing url parameter.";
29531
29481
  if (!t) return $("flowengage_page_content ✖ no siteId"), "Site is not configured.";
29532
29482
  if (!n) return $("flowengage_page_content ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -29567,7 +29517,7 @@ function kk(e) {
29567
29517
  }), `CURRENT_PAGE. URL: ${e} | Path: ${t} | Title: ${n}. Use THIS as the definitive current page — not any previously navigated URL.`;
29568
29518
  },
29569
29519
  flowengage_list_forms: async () => {
29570
- let e = $O(), t = ek();
29520
+ let e = QO(), t = $O();
29571
29521
  return $("flowengage_list_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), JSON.stringify({
29572
29522
  fields: e,
29573
29523
  buttons: t,
@@ -29577,10 +29527,10 @@ function kk(e) {
29577
29527
  flowengage_fill_form: async (e) => {
29578
29528
  try {
29579
29529
  $("flowengage_fill_form ▶ raw:", e), MO();
29580
- let t = vk(e);
29530
+ let t = _k(e);
29581
29531
  if (!t.length && r) {
29582
- let e = r(), n = yk(e);
29583
- n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = bk(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
29532
+ let e = r(), n = vk(e);
29533
+ n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = yk(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
29584
29534
  }
29585
29535
  if ($("flowengage_fill_form · normalized fields:", t), !t.length) return "No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { \"fields\": [ { \"field_key\": \"<label or placeholder from list>\", \"value\": \"<user value>\" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.";
29586
29536
  let n = [];
@@ -29588,14 +29538,14 @@ function kk(e) {
29588
29538
  let t = e?.field_key ?? e?.fieldKey, r = e?.value;
29589
29539
  if (t == null || r == null) continue;
29590
29540
  TO(`Filling ${String(t)}...`, { spinner: !0 });
29591
- let a = QO(), o = dk(a, String(t), r);
29541
+ let a = ZO(), o = uk(a, String(t), r);
29592
29542
  if (o.length) {
29593
- for (let [e, t] of o.entries()) NO(t), await zO(t), Ck(t, r, { skipScroll: e > 0 }), PO(t), await WO(120);
29543
+ for (let [e, t] of o.entries()) NO(t), await zO(t), Sk(t, r, { skipScroll: e > 0 }), PO(t), await WO(120);
29594
29544
  i = o, n.push(String(t));
29595
29545
  continue;
29596
29546
  }
29597
- let s = mk(a, String(t));
29598
- s ||= ak(a, String(t)), s ||= ok(a, String(t), r), s && (NO(s), await zO(s), Ck(s, r), PO(s), await WO(120), i = [s], n.push(String(t)));
29547
+ let s = pk(a, String(t));
29548
+ s ||= ik(a, String(t)), s ||= ak(a, String(t), r), s && (NO(s), await zO(s), Sk(s, r), PO(s), await WO(120), i = [s], n.push(String(t)));
29599
29549
  }
29600
29550
  if (!n.length) return $("flowengage_fill_form ✖ no matches"), "Could not match any fields. Call flowengage_list_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.";
29601
29551
  let a = `OK_FILLED: ${n.join(", ")}`;
@@ -29616,9 +29566,9 @@ function kk(e) {
29616
29566
  }
29617
29567
  },
29618
29568
  flowengage_click_button: async (e) => {
29619
- let t = _k(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
29569
+ let t = gk(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
29620
29570
  if ($("flowengage_click_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
29621
- let r = gk(n, i);
29571
+ let r = hk(n, i);
29622
29572
  if (!r) return $("flowengage_click_button ✖ no match"), `Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;
29623
29573
  try {
29624
29574
  TO(`Clicking ${n}...`, { spinner: !0 });
@@ -29662,7 +29612,7 @@ function kk(e) {
29662
29612
  }
29663
29613
  //#endregion
29664
29614
  //#region src/utils/wrapVoiceToolsForLogging.js
29665
- function Ak(e) {
29615
+ function Tk(e) {
29666
29616
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
29667
29617
  let r = Rn();
29668
29618
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -29679,7 +29629,7 @@ function Ak(e) {
29679
29629
  }
29680
29630
  //#endregion
29681
29631
  //#region src/components/FlowEngageWidget.jsx
29682
- var jk = {
29632
+ var Ek = {
29683
29633
  blue: "#135bd8",
29684
29634
  red: "#ef334b",
29685
29635
  yellow: "#ffbd2e",
@@ -29687,7 +29637,7 @@ var jk = {
29687
29637
  highlight: "rgba(255,255,255,0.9)",
29688
29638
  green: "#10b981"
29689
29639
  };
29690
- function Mk(e) {
29640
+ function Dk(e) {
29691
29641
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
29692
29642
  let [t, n, r] = e;
29693
29643
  return e.length >= 3 && r ? [
@@ -29701,12 +29651,12 @@ function Mk(e) {
29701
29651
  "#f7f8fa"
29702
29652
  ].join(", ");
29703
29653
  }
29704
- function Nk(e) {
29654
+ function Ok(e) {
29705
29655
  if (!e || typeof e != "string") return "#1a1a1a";
29706
29656
  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;
29707
29657
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
29708
29658
  }
29709
- function Pk({ logo: t, style: n }) {
29659
+ function kk({ logo: t, style: n }) {
29710
29660
  if (!t) return null;
29711
29661
  if (typeof t == "string") return /* @__PURE__ */ g("img", {
29712
29662
  src: t,
@@ -29731,7 +29681,7 @@ function Pk({ logo: t, style: n }) {
29731
29681
  children: r
29732
29682
  }) : null;
29733
29683
  }
29734
- function Fk({ title: e }) {
29684
+ function Ak({ title: e }) {
29735
29685
  return /* @__PURE__ */ g("div", {
29736
29686
  style: {
29737
29687
  width: "100%",
@@ -29749,18 +29699,18 @@ function Fk({ title: e }) {
29749
29699
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
29750
29700
  });
29751
29701
  }
29752
- function Ik(e, t) {
29702
+ function jk(e, t) {
29753
29703
  let n = (t || "").trim();
29754
29704
  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) || /\b(that'?s all|we'?re done)\b/i.test(n) || e === "bot" && (/\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)) || /^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)) : !1;
29755
29705
  }
29756
- function Lk({ orbColors: e, ...t }) {
29706
+ function Mk({ orbColors: e, ...t }) {
29757
29707
  return /* @__PURE__ */ g(dO, {
29758
29708
  colors: e,
29759
29709
  ...t
29760
29710
  });
29761
29711
  }
29762
- function Rk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
29763
- let s = n || jk.green, c = Nk(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
29712
+ function Nk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
29713
+ let s = n || Ek.green, c = Ok(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
29764
29714
  style: {
29765
29715
  display: "flex",
29766
29716
  alignItems: a ? "flex-end" : "center",
@@ -29881,7 +29831,7 @@ function Rk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29881
29831
  delay: 0
29882
29832
  },
29883
29833
  style: { flexShrink: 0 },
29884
- children: /* @__PURE__ */ g(Lk, {
29834
+ children: /* @__PURE__ */ g(Mk, {
29885
29835
  size: l,
29886
29836
  orbColors: t
29887
29837
  })
@@ -29913,8 +29863,8 @@ function Rk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29913
29863
  children: u
29914
29864
  })] });
29915
29865
  }
29916
- function zk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
29917
- let c = n || jk.green, l = Nk(c);
29866
+ function Pk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
29867
+ let c = n || Ek.green, l = Ok(c);
29918
29868
  return /* @__PURE__ */ _(Dm.div, {
29919
29869
  initial: {
29920
29870
  scale: 50 / 350,
@@ -29985,7 +29935,7 @@ function zk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
29985
29935
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
29986
29936
  })
29987
29937
  }),
29988
- /* @__PURE__ */ g(Lk, {
29938
+ /* @__PURE__ */ g(Mk, {
29989
29939
  size: 72,
29990
29940
  orbColors: t
29991
29941
  }),
@@ -30054,20 +30004,17 @@ function zk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
30054
30004
  ]
30055
30005
  });
30056
30006
  }
30057
- function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i, siteId: a, apiBaseUrl: s, chatId: l, historyRef: u, onMessageSync: d, voiceEndCounter: f }) {
30058
- let [h, v] = m("idle"), [y, b] = m(!1), [x, S] = m(!1), C = p(null), w = p(""), T = p(async () => {}), ee = p(!1), te = p(!1), ne = p(!1), re = p(!1), E = p("minimized"), ie = p(null), ae = p(null), oe = p(null), D = p(0), se = p(!1), ce = p("idle"), le = p(!1), ue = p(null), de = p(null), fe = p(!1), pe = p(""), me = o((e = "minimized") => {
30007
+ function Fk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i, siteId: a, apiBaseUrl: s, chatId: l, historyRef: u, onMessageSync: d, voiceEndCounter: f }) {
30008
+ let [h, v] = m("idle"), [y, b] = m(!1), [x, S] = m(!1), C = p(null), w = p(""), T = p(async () => {}), ee = p(!1), te = p(!1), ne = p(!1), re = p(!1), E = p("minimized"), ie = p(null), ae = p(null), oe = p(null), D = p(0), se = p(!1), ce = p("idle"), le = p(!1), ue = p(null), de = p(null), fe = p(!1), pe = o((e = "minimized") => {
30059
30009
  E.current = e, re.current = !0, queueMicrotask(() => {
30060
30010
  ee.current || (ee.current = !0, T.current?.());
30061
30011
  });
30062
- }, [u]), he = o(async (e) => {
30012
+ }, [u]), me = o(async (e) => {
30063
30013
  re.current = !0;
30064
30014
  try {
30065
30015
  wD();
30066
30016
  } catch {}
30067
- try {
30068
- Ok();
30069
- } catch {}
30070
- if (pe.current = "", a) try {
30017
+ if (a) try {
30071
30018
  Ve(a);
30072
30019
  } catch {}
30073
30020
  try {
@@ -30098,10 +30045,10 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30098
30045
  l,
30099
30046
  s
30100
30047
  ]);
30101
- return T.current = () => he(E.current === "chat" ? t : n), c(() => {
30048
+ return T.current = () => me(E.current === "chat" ? t : n), c(() => {
30102
30049
  te.current = y;
30103
30050
  }, [y]), c(() => {
30104
- f && me("chat");
30051
+ f && pe("chat");
30105
30052
  }, [f]), c(() => {
30106
30053
  let e = !1, i = null, o = null, c = null;
30107
30054
  return (async () => {
@@ -30110,11 +30057,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30110
30057
  return;
30111
30058
  }
30112
30059
  try {
30113
- if ((await navigator.mediaDevices.getUserMedia({ audio: {
30114
- noiseSuppression: !0,
30115
- echoCancellation: !0,
30116
- autoGainControl: !0
30117
- } })).getTracks().forEach((e) => e.stop()), e) return;
30060
+ if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
30118
30061
  u.current = [], w.current = "", ee.current = !1, ne.current = !1, re.current = !1, E.current = "minimized", kr({ onBeforeNavigate: () => {
30119
30062
  if (a && u.current.length > 0) try {
30120
30063
  let e = bO(u.current);
@@ -30139,7 +30082,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30139
30082
  }
30140
30083
  Ne();
30141
30084
  } });
30142
- let t = Ak(kk({
30085
+ let t = Tk(wk({
30143
30086
  siteId: a || null,
30144
30087
  apiBaseUrl: s || null,
30145
30088
  getLastUserVoiceText: () => w.current,
@@ -30169,7 +30112,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30169
30112
  m && m.includes("|") && (x = m.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
30170
30113
  let S = x || y || "this page";
30171
30114
  g ? f ? (_.overrides = { agent: { firstMessage: `I've navigated you to the ${S} page. Let me walk you through what's here.` } }, console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${S}" (${p})`)) : d ? _.overrides = { agent: { firstMessage: "I'm still here. Go ahead!" } } : h || (_.overrides = { agent: { firstMessage: `Hi! I see you are currently on the ${S} page. Are you looking for something specific here?` } }, console.log(`[FlowEngage] 🏠 Page-context override: "${S}" for ${p}`)) : d && (_.overrides = { agent: { firstMessage: "" } });
30172
- let T = !1, oe = f ? `NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(a ? je(a) : null)?.transcript || ""}\n\n` : null, he = await vD.startSession({
30115
+ let T = !1, oe = f ? `NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(a ? je(a) : null)?.transcript || ""}\n\n` : null, me = await vD.startSession({
30173
30116
  ..._,
30174
30117
  onConnect: ({ conversationId: e }) => {
30175
30118
  ie.current = e, ae.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
@@ -30178,11 +30121,11 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30178
30121
  onModeChange: ({ mode: t }) => {
30179
30122
  if (!e) {
30180
30123
  if (t === "speaking") {
30181
- de.current &&= (clearTimeout(de.current), null), v("speaking"), ce.current = "speaking", le.current = !0, fe.current = !1, ue.current &&= (clearTimeout(ue.current), null), pe.current &&= (Dk(pe.current), "");
30124
+ de.current &&= (clearTimeout(de.current), null), v("speaking"), ce.current = "speaking", le.current = !0, fe.current = !1, ue.current &&= (clearTimeout(ue.current), null);
30182
30125
  return;
30183
30126
  }
30184
30127
  if (ce.current = "listening", se.current) {
30185
- se.current = !1, me();
30128
+ se.current = !1, pe();
30186
30129
  return;
30187
30130
  }
30188
30131
  if (oe && !T) {
@@ -30197,14 +30140,14 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30197
30140
  C.current?.sendContextualUpdate?.("The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.");
30198
30141
  } catch {}
30199
30142
  }, 4e3))));
30200
- }, 2500);
30143
+ }, 1200);
30201
30144
  }
30202
30145
  },
30203
30146
  onMessage: (t) => {
30204
30147
  if (e) return;
30205
30148
  let n = t.role === "user" ? "user" : "bot", r = t.message || t.text || t.content || "";
30206
30149
  if (r) {
30207
- if (n === "bot" && (ce.current === "speaking" ? Dk(r) : pe.current = r), n === "user" && (w.current = r, fe.current = !0, de.current &&= (clearTimeout(de.current), null), ue.current &&= (clearTimeout(ue.current), null)), u.current = [...u.current, {
30150
+ if (n === "user" && (w.current = r, fe.current = !0, de.current &&= (clearTimeout(de.current), null), ue.current &&= (clearTimeout(ue.current), null)), u.current = [...u.current, {
30208
30151
  sender: n,
30209
30152
  message: r,
30210
30153
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
@@ -30212,14 +30155,14 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30212
30155
  let e = bO(u.current);
30213
30156
  e && Ae(a, e);
30214
30157
  } catch {}
30215
- if (Ik(n, r)) {
30216
- me("minimized");
30158
+ if (jk(n, r)) {
30159
+ pe("minimized");
30217
30160
  return;
30218
30161
  }
30219
30162
  if (te.current && n === "bot" && /are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r)) if (D.current += 1, D.current === 2) try {
30220
30163
  C.current?.sendContextualUpdate?.("IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the flowengage_end_session tool to end the voice session. Do NOT ask again after that.");
30221
30164
  } catch {}
30222
- else D.current >= 5 && me("minimized");
30165
+ else D.current >= 5 && pe("minimized");
30223
30166
  }
30224
30167
  },
30225
30168
  onError: (t) => {
@@ -30232,7 +30175,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30232
30175
  try {
30233
30176
  C.current?.setMicMuted?.(!0);
30234
30177
  } catch {}
30235
- b(!0), v("error"), me("chat");
30178
+ b(!0), v("error"), pe("chat");
30236
30179
  }
30237
30180
  },
30238
30181
  onDisconnect: (t) => {
@@ -30249,21 +30192,21 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30249
30192
  try {
30250
30193
  C.current?.setMicMuted?.(!0);
30251
30194
  } catch {}
30252
- b(!0), me("chat");
30195
+ b(!0), pe("chat");
30253
30196
  }
30254
30197
  });
30255
30198
  if (e) {
30256
- he.endSession().catch(() => {});
30199
+ me.endSession().catch(() => {});
30257
30200
  return;
30258
30201
  }
30259
- i = he, C.current = he, v("listening");
30202
+ i = me, C.current = me, v("listening");
30260
30203
  try {
30261
30204
  let e = typeof window < "u" ? window.location.href : "", r = "[]";
30262
30205
  try {
30263
30206
  r = await t.list_page_forms();
30264
30207
  } catch {}
30265
30208
  let i = d && !f ? `RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript || ""}\n\n` : "";
30266
- he.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
30209
+ me.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a || "unknown"}. Forms: ${r}. Voice: call end_voice_session or say you are ending the session to stop.`);
30267
30210
  } catch {}
30268
30211
  if (typeof window < "u") {
30269
30212
  let t = window.location.pathname, n = () => {
@@ -30322,7 +30265,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30322
30265
  r,
30323
30266
  a,
30324
30267
  s,
30325
- me
30268
+ pe
30326
30269
  ]), c(() => {
30327
30270
  if (!x) return;
30328
30271
  let e = (e) => {
@@ -30376,7 +30319,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30376
30319
  },
30377
30320
  children: "Muted"
30378
30321
  }),
30379
- /* @__PURE__ */ g(Lk, {
30322
+ /* @__PURE__ */ g(Mk, {
30380
30323
  size: 72,
30381
30324
  voiceState: h,
30382
30325
  isMuted: y,
@@ -30508,7 +30451,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30508
30451
  children: [
30509
30452
  /* @__PURE__ */ _("button", {
30510
30453
  onClick: () => {
30511
- S(!1), E.current = "chat", he(t);
30454
+ S(!1), E.current = "chat", me(t);
30512
30455
  },
30513
30456
  style: {
30514
30457
  display: "flex",
@@ -30537,7 +30480,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30537
30480
  }),
30538
30481
  /* @__PURE__ */ _("button", {
30539
30482
  onClick: () => {
30540
- S(!1), E.current = "minimized", he(n);
30483
+ S(!1), E.current = "minimized", me(n);
30541
30484
  },
30542
30485
  style: {
30543
30486
  display: "flex",
@@ -30614,7 +30557,7 @@ function Bk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, voiceId: i
30614
30557
  ]
30615
30558
  });
30616
30559
  }
30617
- function Vk({ orbColors: e }) {
30560
+ function Ik({ orbColors: e }) {
30618
30561
  return /* @__PURE__ */ g("div", {
30619
30562
  style: {
30620
30563
  flexShrink: 0,
@@ -30624,13 +30567,13 @@ function Vk({ orbColors: e }) {
30624
30567
  alignItems: "center",
30625
30568
  justifyContent: "center"
30626
30569
  },
30627
- children: /* @__PURE__ */ g(Lk, {
30570
+ children: /* @__PURE__ */ g(Mk, {
30628
30571
  size: 36,
30629
30572
  orbColors: e
30630
30573
  })
30631
30574
  });
30632
30575
  }
30633
- var Hk = () => /* @__PURE__ */ g("div", {
30576
+ var Lk = () => /* @__PURE__ */ g("div", {
30634
30577
  style: {
30635
30578
  display: "flex",
30636
30579
  marginBottom: "12px",
@@ -30660,7 +30603,7 @@ var Hk = () => /* @__PURE__ */ g("div", {
30660
30603
  } }, e))
30661
30604
  })
30662
30605
  });
30663
- function Uk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: E, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, activeCallId: ge, isCallMuted: _e, toggleCallMute: ve, endWebRTCCall: ye, formatCallDuration: be, callDurationSeconds: xe, isCallMinimized: Se, onExpand: Ce, onCollapse: we, onStartVoice: Te, onNewChat: Ee, onEndConversation: De, showPoweredBy: Oe, getVisitorChatHistory: ke, getVisitorChatThread: Ae, resumeChat: je, isSessionRestoring: Me, isClosing: O }) {
30606
+ function Rk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: E, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, activeCallId: ge, isCallMuted: _e, toggleCallMute: ve, endWebRTCCall: ye, formatCallDuration: be, callDurationSeconds: xe, isCallMinimized: Se, onExpand: Ce, onCollapse: we, onStartVoice: Te, onNewChat: Ee, onEndConversation: De, showPoweredBy: Oe, getVisitorChatHistory: ke, getVisitorChatThread: Ae, resumeChat: je, isSessionRestoring: Me, isClosing: O }) {
30664
30607
  let Ne = l.length > 0, Pe = T || ee || w, Fe = !!ge, [Ie, Le] = m(!1), [Re, ze] = m(!1), [Be, Ve] = m([]), [He, Ue] = m(!1), [We, Ge] = m(null), [Ke, qe] = m([]), Je = p(null), Ye = async () => {
30665
30608
  Le(!1), ze(!0), Ue(!0), Ge(null);
30666
30609
  try {
@@ -30785,7 +30728,7 @@ function Uk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30785
30728
  justifyContent: "center",
30786
30729
  height: "40px"
30787
30730
  },
30788
- children: i ? /* @__PURE__ */ g(Pk, {
30731
+ children: i ? /* @__PURE__ */ g(kk, {
30789
30732
  logo: i,
30790
30733
  style: {
30791
30734
  height: "34px",
@@ -30798,7 +30741,7 @@ function Uk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30798
30741
  height: "40px",
30799
30742
  flexShrink: 0
30800
30743
  },
30801
- children: /* @__PURE__ */ g(Fk, { title: e.chatTitle })
30744
+ children: /* @__PURE__ */ g(Ak, { title: e.chatTitle })
30802
30745
  })
30803
30746
  }), /* @__PURE__ */ g("div", {
30804
30747
  style: {
@@ -31286,11 +31229,11 @@ function Uk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31286
31229
  isLoading: T,
31287
31230
  isAgentTyping: d,
31288
31231
  setReplyContext: de,
31289
- TypingDots: Hk,
31232
+ TypingDots: Lk,
31290
31233
  primaryColor: n,
31291
31234
  agentHeadshot: y,
31292
31235
  agentDisplayName: v || b,
31293
- botAvatarNode: /* @__PURE__ */ g(Vk, { orbColors: t })
31236
+ botAvatarNode: /* @__PURE__ */ g(Ik, { orbColors: t })
31294
31237
  }) : Me ? /* @__PURE__ */ _("div", {
31295
31238
  style: {
31296
31239
  flex: 1,
@@ -31331,7 +31274,7 @@ function Uk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31331
31274
  padding: "28px 24px"
31332
31275
  },
31333
31276
  children: [
31334
- /* @__PURE__ */ g(Lk, {
31277
+ /* @__PURE__ */ g(Mk, {
31335
31278
  size: 94,
31336
31279
  orbColors: t
31337
31280
  }),
@@ -31472,7 +31415,7 @@ function Uk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31472
31415
  ]
31473
31416
  });
31474
31417
  }
31475
- function Wk() {
31418
+ function zk() {
31476
31419
  let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, chatId: ie, historyRef: ae, onMessageSync: oe, sendMessage: D, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: me, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se, getVisitorChatHistory: Ce, getVisitorChatThread: we, resumeChat: Te, isSessionRestoring: Ee, openToChatCounter: De, voiceEndCounter: Oe } = Ln();
31477
31420
  c(() => {
31478
31421
  try {
@@ -31490,7 +31433,7 @@ function Wk() {
31490
31433
  }, Fe = {
31491
31434
  ...ke.features || {},
31492
31435
  ...Ae.features || {}
31493
- }, Ie = Fe.voice !== !1, Re = Array.isArray(Ne.orbColors) && Ne.orbColors.length > 0 ? Ne.orbColors : null, ze = Ne.buttonColor || Ne.primaryColor || Re?.[0] || "#3B82F6", Be = Ne.position || "bottom-right", Ve = O.fallbackAgentName || "Agent", He = Mk(Re ?? Ne.chatBgColors), Ue = O.logo || O.logoUrl || null, We = E || "en", Ge = ke.recommendations?.[We] || [], Ke = (Ae.recommendations?.[We] ?? Ge).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31436
+ }, Ie = Fe.voice !== !1, Re = Array.isArray(Ne.orbColors) && Ne.orbColors.length > 0 ? Ne.orbColors : null, ze = Ne.buttonColor || Ne.primaryColor || Re?.[0] || "#3B82F6", Be = Ne.position || "bottom-right", Ve = O.fallbackAgentName || "Agent", He = Dk(Re ?? Ne.chatBgColors), Ue = O.logo || O.logoUrl || null, We = E || "en", Ge = ke.recommendations?.[We] || [], Ke = (Ae.recommendations?.[We] ?? Ge).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31494
31437
  id: e.key || `qr-${t}`,
31495
31438
  label: e.label,
31496
31439
  message: e.label,
@@ -31754,7 +31697,7 @@ function Wk() {
31754
31697
  onWheel: (e) => e.stopPropagation(),
31755
31698
  onTouchMove: (e) => e.stopPropagation(),
31756
31699
  children: [
31757
- A === "entry_prompt" && /* @__PURE__ */ g(Rk, {
31700
+ A === "entry_prompt" && /* @__PURE__ */ g(Nk, {
31758
31701
  copy: Ze,
31759
31702
  orbColors: Re,
31760
31703
  primaryColor: ze,
@@ -31837,13 +31780,13 @@ function Wk() {
31837
31780
  children: ee === "connected" ? `${Ht(_t)} with ${nt}` : `Tap to return to ${nt}`
31838
31781
  })]
31839
31782
  })]
31840
- }), /* @__PURE__ */ g(Lk, {
31783
+ }), /* @__PURE__ */ g(Mk, {
31841
31784
  size: 50,
31842
31785
  orbColors: Re,
31843
31786
  onClick: T && Dt ? Lt : Ie ? Kt : Jt
31844
31787
  })]
31845
31788
  }),
31846
- A === "connection_modal" && /* @__PURE__ */ g(zk, {
31789
+ A === "connection_modal" && /* @__PURE__ */ g(Pk, {
31847
31790
  copy: Ze,
31848
31791
  orbColors: Re,
31849
31792
  primaryColor: ze,
@@ -31853,7 +31796,7 @@ function Wk() {
31853
31796
  isMobile: Nt,
31854
31797
  isClosing: kt
31855
31798
  }),
31856
- A === "voice_mode" && /* @__PURE__ */ g(Bk, {
31799
+ A === "voice_mode" && /* @__PURE__ */ g(Fk, {
31857
31800
  orbColors: Re,
31858
31801
  onEnterChat: Jt,
31859
31802
  onEndChat: Yt,
@@ -31885,7 +31828,7 @@ function Wk() {
31885
31828
  orbColors: Re,
31886
31829
  chatHistory: r
31887
31830
  }),
31888
- A === "text_chat" && /* @__PURE__ */ g(Uk, {
31831
+ A === "text_chat" && /* @__PURE__ */ g(Rk, {
31889
31832
  isClosing: kt,
31890
31833
  copy: Ze,
31891
31834
  orbColors: Re,
@@ -31950,7 +31893,7 @@ function Wk() {
31950
31893
  }
31951
31894
  //#endregion
31952
31895
  //#region src/components/ErrorBoundary.jsx
31953
- var Gk = class extends e.Component {
31896
+ var Bk = class extends e.Component {
31954
31897
  constructor(e) {
31955
31898
  super(e), this.state = { hasError: !1 };
31956
31899
  }
@@ -31965,4 +31908,4 @@ var Gk = class extends e.Component {
31965
31908
  }
31966
31909
  };
31967
31910
  //#endregion
31968
- export { dO as AnimatedOrb, Gk as ErrorBoundary, Rr as FlowEngageProvider, Wk as FlowEngageWidget, Ln as useFlowEngage };
31911
+ export { dO as AnimatedOrb, Bk as ErrorBoundary, Rr as FlowEngageProvider, zk as FlowEngageWidget, Ln as useFlowEngage };