@flowengage/react-chatbot 1.6.7 → 1.6.9

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.
@@ -17,7 +17,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
17
17
  }, w = (e) => x.call(e, "module.exports") ? e["module.exports"] : ee(v({}, "__esModule", { value: !0 }), e), te = (e) => {
18
18
  if (!e || typeof e != "object") throw Error("FlowEngage config is required");
19
19
  if (!e.siteId || typeof e.siteId != "string") throw Error("[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId=\"your-site-id\" /> or config={{ siteId: 'your-site-id' }}.");
20
- let t = (e.apiBaseUrl || "https://be-flowengage.oslabs.app").replace(/\/+$/, "");
20
+ let t = (e.apiBaseUrl || "https://be-flowengage-stage.oslabs.app").replace(/\/+$/, "");
21
21
  return {
22
22
  siteId: e.siteId.trim(),
23
23
  apiBaseUrl: t
@@ -3485,7 +3485,7 @@ function ur({ siteId: e, config: t, children: n, language: r = "en" }) {
3485
3485
  let e = () => {
3486
3486
  let e = O.current, t = D.current;
3487
3487
  if (!t || !e) return;
3488
- if (nt.current) {
3488
+ if (!lt.current && ct.current.length > 0 && (t.beaconSyncVoice(e, ct.current) || t.syncVoice(e, ct.current).catch(() => {}), lt.current = !0), nt.current) {
3489
3489
  t.beaconEndWebRTCCall(nt.current, e);
3490
3490
  return;
3491
3491
  }
@@ -27693,8 +27693,8 @@ function OD() {
27693
27693
  }
27694
27694
  //#endregion
27695
27695
  //#region src/utils/highlightEngine.js
27696
- var kD = 80, AD = null;
27697
- function jD(e) {
27696
+ var kD = 80;
27697
+ function AD(e) {
27698
27698
  requestAnimationFrame(() => {
27699
27699
  let t = e.getBoundingClientRect(), n = t.top + t.height / 2, r = kD, i = r + (window.innerHeight - r) / 2, a = window.pageYOffset + n - i;
27700
27700
  window.scrollTo({
@@ -27703,35 +27703,20 @@ function jD(e) {
27703
27703
  });
27704
27704
  });
27705
27705
  }
27706
- function MD(e) {
27707
- ND(), AD = document.createElement("div"), AD.id = "fe-spotlight-overlay", AD.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.35);z-index:9998;pointer-events:none;transition:opacity 0.4s ease;opacity:0;", document.body.appendChild(AD), AD.offsetHeight, AD.style.opacity = "1", e.style.position = "relative", e.style.zIndex = "9999";
27708
- }
27709
- function ND() {
27710
- if (AD) {
27711
- AD.style.opacity = "0";
27712
- let e = AD;
27713
- setTimeout(() => {
27714
- e.parentNode && e.parentNode.removeChild(e);
27715
- }, 400), AD = null;
27716
- }
27717
- document.querySelectorAll("[data-fe-highlighted]").forEach((e) => {
27718
- e.style.zIndex = "", e.style.position = "";
27719
- });
27720
- }
27721
- function PD(e) {
27706
+ function jD(e) {
27722
27707
  if (!e || e.hasAttribute("data-fe-highlighted")) return;
27723
- FD(), e.classList?.remove("fe-highlight-section", "fe-highlight-speaking", "fe-highlight-exiting"), jD(e);
27708
+ MD(), e.classList?.remove("fe-highlight-section", "fe-highlight-speaking", "fe-highlight-exiting"), AD(e);
27724
27709
  let t = e.style.cssText;
27725
- e.setAttribute("data-fe-highlighted", "true"), e.setAttribute("data-fe-orig-style", t), e.style.outline = "3px solid #2563eb", e.style.outlineOffset = "8px", e.style.background = "rgba(37, 99, 235, 0.08)", e.style.borderRadius = "8px", e.style.padding = "12px 16px", e.style.transition = "all 0.4s ease", MD(e);
27710
+ e.setAttribute("data-fe-highlighted", "true"), e.setAttribute("data-fe-orig-style", t), e.style.outline = "3px solid #2563eb", e.style.outlineOffset = "8px", e.style.background = "rgba(37, 99, 235, 0.08)", e.style.borderRadius = "8px", e.style.padding = "12px 16px", e.style.transition = "all 0.4s ease";
27726
27711
  }
27727
- function FD() {
27712
+ function MD() {
27728
27713
  let e = document.querySelector("[data-fe-highlighted]");
27729
- e && (e.style.cssText = e.getAttribute("data-fe-orig-style") || "", e.removeAttribute("data-fe-highlighted"), e.removeAttribute("data-fe-orig-style")), ND();
27714
+ e && (e.style.cssText = e.getAttribute("data-fe-orig-style") || "", e.removeAttribute("data-fe-highlighted"), e.removeAttribute("data-fe-orig-style"));
27730
27715
  }
27731
27716
  //#endregion
27732
27717
  //#region src/utils/voiceActionVisuals.js
27733
27718
  var Q = "fe-vv";
27734
- function ID() {
27719
+ function ND() {
27735
27720
  if (typeof document > "u" || document.getElementById(`${Q}-styles`)) return;
27736
27721
  let e = `
27737
27722
  /* ── Action toast ───────────────────────────────────────────────────────────── */
@@ -27876,14 +27861,14 @@ function ID() {
27876
27861
  `, t = document.createElement("style");
27877
27862
  t.id = `${Q}-styles`, t.textContent = e, (document.head || document.documentElement).appendChild(t);
27878
27863
  }
27879
- var LD = null, RD = null;
27880
- function zD() {
27881
- return (!LD || !LD.isConnected) && (LD = document.createElement("div"), LD.id = `${Q}-toast`, document.body.appendChild(LD)), LD;
27864
+ var PD = null, FD = null;
27865
+ function ID() {
27866
+ return (!PD || !PD.isConnected) && (PD = document.createElement("div"), PD.id = `${Q}-toast`, document.body.appendChild(PD)), PD;
27882
27867
  }
27883
- function BD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27868
+ function LD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27884
27869
  if (typeof document > "u") return;
27885
- ID(), RD &&= (clearTimeout(RD), null);
27886
- let i = zD();
27870
+ ND(), FD &&= (clearTimeout(FD), null);
27871
+ let i = ID();
27887
27872
  if (i.innerHTML = "", n) {
27888
27873
  let e = document.createElement("span");
27889
27874
  e.className = `${Q}-icon`, e.textContent = n, i.appendChild(e);
@@ -27892,82 +27877,82 @@ function BD(e, { spinner: t = !0, icon: n = null, duration: r = 0 } = {}) {
27892
27877
  e.className = `${Q}-spin`, i.appendChild(e);
27893
27878
  }
27894
27879
  let a = document.createElement("span");
27895
- a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (RD = setTimeout(() => VD(), r));
27880
+ a.textContent = e, i.appendChild(a), i.classList.remove(`${Q}-show`), i.offsetHeight, i.classList.add(`${Q}-show`), r > 0 && (FD = setTimeout(() => RD(), r));
27896
27881
  }
27897
- function VD(e = 0) {
27898
- LD && (e > 0 ? RD = setTimeout(() => {
27899
- LD && LD.classList.remove(`${Q}-show`);
27900
- }, e) : LD && LD.classList.remove(`${Q}-show`));
27882
+ function RD(e = 0) {
27883
+ PD && (e > 0 ? FD = setTimeout(() => {
27884
+ PD && PD.classList.remove(`${Q}-show`);
27885
+ }, e) : PD && PD.classList.remove(`${Q}-show`));
27901
27886
  }
27902
- var HD = null, UD = [];
27903
- function WD() {
27904
- return (!HD || !HD.isConnected) && (HD = document.createElement("div"), HD.id = `${Q}-bar`, document.body.appendChild(HD)), HD;
27887
+ var zD = null, BD = [];
27888
+ function VD() {
27889
+ return (!zD || !zD.isConnected) && (zD = document.createElement("div"), zD.id = `${Q}-bar`, document.body.appendChild(zD)), zD;
27905
27890
  }
27906
- function GD() {
27891
+ function HD() {
27907
27892
  if (typeof document > "u") return;
27908
- ID(), UD.forEach(clearTimeout), UD = [];
27909
- let e = WD();
27893
+ ND(), BD.forEach(clearTimeout), BD = [];
27894
+ let e = VD();
27910
27895
  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";
27911
27896
  let t = [[80, "width 0.6s ease"], [92, "width 1.2s ease"]], n = 50;
27912
27897
  for (let [e, r] of t) {
27913
27898
  let t = n, i = e, a = r;
27914
- UD.push(setTimeout(() => {
27915
- HD && (HD.style.transition = a, HD.style.width = `${i}%`);
27899
+ BD.push(setTimeout(() => {
27900
+ zD && (zD.style.transition = a, zD.style.width = `${i}%`);
27916
27901
  }, t)), n += 800;
27917
27902
  }
27918
27903
  }
27919
- function KD() {
27920
- HD && (UD.forEach(clearTimeout), UD = [], HD.style.transition = "width 0.2s ease", HD.style.width = "100%", UD.push(setTimeout(() => {
27921
- HD && (HD.style.transition = "opacity 0.35s ease", HD.style.opacity = "0", UD.push(setTimeout(() => {
27922
- HD && (HD.style.width = "0%", HD.classList.remove(`${Q}-bar-active`));
27904
+ function UD() {
27905
+ zD && (BD.forEach(clearTimeout), BD = [], zD.style.transition = "width 0.2s ease", zD.style.width = "100%", BD.push(setTimeout(() => {
27906
+ zD && (zD.style.transition = "opacity 0.35s ease", zD.style.opacity = "0", BD.push(setTimeout(() => {
27907
+ zD && (zD.style.width = "0%", zD.classList.remove(`${Q}-bar-active`));
27923
27908
  }, 380)));
27924
27909
  }, 220)));
27925
27910
  }
27926
- function qD() {
27911
+ function WD() {
27927
27912
  typeof document > "u" || document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach((e) => e.classList.remove(`${Q}-field-active`, `${Q}-field-filled`));
27928
27913
  }
27929
- function JD(e) {
27930
- !e || typeof document > "u" || (ID(), qD(), e.classList.add(`${Q}-field-active`));
27914
+ function GD(e) {
27915
+ !e || typeof document > "u" || (ND(), WD(), e.classList.add(`${Q}-field-active`));
27931
27916
  }
27932
- function YD(e) {
27917
+ function KD(e) {
27933
27918
  e && (e.classList.remove(`${Q}-field-active`), e.classList.add(`${Q}-field-filled`), setTimeout(() => {
27934
27919
  e.isConnected && e.classList.remove(`${Q}-field-filled`);
27935
27920
  }, 1400));
27936
27921
  }
27937
- var XD = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
27922
+ var qD = `<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
27938
27923
  <filter id="${Q}-csh">
27939
27924
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
27940
27925
  </filter>
27941
27926
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
27942
27927
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
27943
27928
  filter="url(#${Q}-csh)"/>
27944
- </svg>`, ZD = null, QD = !1;
27945
- function $D() {
27946
- return (!ZD || !ZD.isConnected) && (ZD = document.createElement("div"), ZD.id = `${Q}-cursor`, ZD.innerHTML = XD, document.body.appendChild(ZD), QD = !1), ZD;
27929
+ </svg>`, JD = null, YD = !1;
27930
+ function XD() {
27931
+ return (!JD || !JD.isConnected) && (JD = document.createElement("div"), JD.id = `${Q}-cursor`, JD.innerHTML = qD, document.body.appendChild(JD), YD = !1), JD;
27947
27932
  }
27948
- async function eO(e) {
27933
+ async function ZD(e) {
27949
27934
  if (typeof document > "u" || !e) return;
27950
- ID();
27935
+ ND();
27951
27936
  let t;
27952
27937
  try {
27953
27938
  t = e.getBoundingClientRect();
27954
27939
  } catch {
27955
27940
  return;
27956
27941
  }
27957
- let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = $D();
27958
- QD ||= (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 iO(360);
27942
+ let n = t.left + Math.min(16, t.width * .2), r = t.top + Math.min(12, t.height * .25), i = XD();
27943
+ YD ||= (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 tO(360);
27959
27944
  }
27960
- function tO(e = !1) {
27961
- ZD && (e ? (ZD.classList.remove(`${Q}-cursor-visible`), QD = !1) : (ZD.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
27962
- QD = !1;
27945
+ function QD(e = !1) {
27946
+ JD && (e ? (JD.classList.remove(`${Q}-cursor-visible`), YD = !1) : (JD.classList.remove(`${Q}-cursor-visible`), setTimeout(() => {
27947
+ YD = !1;
27963
27948
  }, 250)));
27964
27949
  }
27965
- async function nO(e) {
27966
- ZD && (ZD.classList.add(`${Q}-cursor-click`), await iO(280), ZD.classList.remove(`${Q}-cursor-click`));
27950
+ async function $D(e) {
27951
+ JD && (JD.classList.add(`${Q}-cursor-click`), await tO(280), JD.classList.remove(`${Q}-cursor-click`));
27967
27952
  }
27968
- function rO(e) {
27953
+ function eO(e) {
27969
27954
  if (!e || typeof document > "u") return;
27970
- ID();
27955
+ ND();
27971
27956
  let t;
27972
27957
  try {
27973
27958
  t = e.getBoundingClientRect();
@@ -27993,7 +27978,7 @@ function rO(e) {
27993
27978
  a.remove(), e.style.position = n, e.style.overflow = r;
27994
27979
  }, 650);
27995
27980
  }
27996
- function iO(e) {
27981
+ function tO(e) {
27997
27982
  return new Promise((t) => setTimeout(t, e));
27998
27983
  }
27999
27984
  //#endregion
@@ -28001,10 +27986,10 @@ function iO(e) {
28001
27986
  function $(...e) {
28002
27987
  vn() && console.log("[FlowEngage:voice-tools]", ...e);
28003
27988
  }
28004
- function aO(e) {
27989
+ function nO(e) {
28005
27990
  return new Promise((t) => setTimeout(t, e));
28006
27991
  }
28007
- function oO(e = 3e3) {
27992
+ function rO(e = 3e3) {
28008
27993
  return new Promise((t) => {
28009
27994
  if (typeof document > "u") {
28010
27995
  t();
@@ -28026,39 +28011,39 @@ function oO(e = 3e3) {
28026
28011
  }, e);
28027
28012
  });
28028
28013
  }
28029
- var sO = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
28030
- function cO(e) {
28014
+ var iO = "#flowengage-root, .flowengage-shell, .flowengage-widget-root";
28015
+ function aO(e) {
28031
28016
  if (!e || typeof e.closest != "function") return !1;
28032
28017
  try {
28033
- return !!e.closest(sO);
28018
+ return !!e.closest(iO);
28034
28019
  } catch {
28035
28020
  return !1;
28036
28021
  }
28037
28022
  }
28038
- function lO(e) {
28023
+ function oO(e) {
28039
28024
  try {
28040
28025
  let t = e.ownerDocument?.defaultView;
28041
28026
  if (t) return t.getComputedStyle(e);
28042
28027
  } catch {}
28043
28028
  return window.getComputedStyle(e);
28044
28029
  }
28045
- function uO(e) {
28030
+ function sO(e) {
28046
28031
  let t = /* @__PURE__ */ new Set();
28047
28032
  function n(r) {
28048
28033
  if (!r || t.has(r)) return;
28049
28034
  t.add(r), e(r);
28050
28035
  let i = r.querySelectorAll("iframe");
28051
- for (let e of i) if (!cO(e)) try {
28036
+ for (let e of i) if (!aO(e)) try {
28052
28037
  let t = e.contentDocument;
28053
28038
  t && n(t);
28054
28039
  } catch {}
28055
28040
  }
28056
28041
  typeof document < "u" && n(document);
28057
28042
  }
28058
- function dO(e) {
28043
+ function cO(e) {
28059
28044
  return e == null ? null : String(e).replace(/\u00a0/g, " ").replace(/\s*\*+\s*$/u, "").replace(/\s+/g, " ").trim();
28060
28045
  }
28061
- function fO(e) {
28046
+ function lO(e) {
28062
28047
  let t = e.ownerDocument || document, n = e.getAttribute("aria-labelledby");
28063
28048
  if (n) {
28064
28049
  let e = n.trim().split(/\s+/).filter(Boolean), r = [];
@@ -28066,42 +28051,42 @@ function fO(e) {
28066
28051
  let e = t.getElementById(n);
28067
28052
  e?.textContent && r.push(e.textContent.trim());
28068
28053
  } catch {}
28069
- if (r.length) return dO(r.join(" "));
28054
+ if (r.length) return cO(r.join(" "));
28070
28055
  }
28071
- if (e.labels && e.labels.length) return dO(e.labels[0].textContent);
28056
+ if (e.labels && e.labels.length) return cO(e.labels[0].textContent);
28072
28057
  let r = e.id;
28073
28058
  if (r) try {
28074
28059
  let e = t.querySelector(`label[for="${CSS.escape(r)}"]`);
28075
- if (e) return dO(e.textContent);
28060
+ if (e) return cO(e.textContent);
28076
28061
  } catch {
28077
28062
  let e = t.querySelector(`label[for="${r.replace(/"/g, "\\\"")}"]`);
28078
- if (e) return dO(e.textContent);
28063
+ if (e) return cO(e.textContent);
28079
28064
  }
28080
28065
  let i = e.previousElementSibling;
28081
28066
  for (let e = 0; e < 6 && i; e += 1) {
28082
- if (i.tagName === "LABEL") return dO(i.textContent);
28067
+ if (i.tagName === "LABEL") return cO(i.textContent);
28083
28068
  let e = (i.className || "").toString().toLowerCase();
28084
28069
  if (/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)) {
28085
- let e = dO(i.textContent);
28070
+ let e = cO(i.textContent);
28086
28071
  if (e) return e;
28087
28072
  }
28088
28073
  i = i.previousElementSibling;
28089
28074
  }
28090
28075
  let a = e.parentElement;
28091
28076
  for (let e = 0; e < 5 && a; e += 1) {
28092
- if (a.tagName === "LABEL") return dO(a.textContent);
28077
+ if (a.tagName === "LABEL") return cO(a.textContent);
28093
28078
  let e = a.querySelector?.(":scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']");
28094
- if (e?.textContent) return dO(e.textContent);
28079
+ if (e?.textContent) return cO(e.textContent);
28095
28080
  a = a.parentElement;
28096
28081
  }
28097
28082
  let o = e.getAttribute("aria-label");
28098
- return o ? dO(o) : null;
28083
+ return o ? cO(o) : null;
28099
28084
  }
28100
- function pO() {
28085
+ function uO() {
28101
28086
  let e = [];
28102
- return uO((t) => {
28087
+ return sO((t) => {
28103
28088
  e.push(...Array.from(t.querySelectorAll("input, select, textarea")).filter((e) => {
28104
- if (cO(e)) return !1;
28089
+ if (aO(e)) return !1;
28105
28090
  let t = (e.type || "").toLowerCase();
28106
28091
  if ([
28107
28092
  "hidden",
@@ -28110,32 +28095,32 @@ function pO() {
28110
28095
  "image"
28111
28096
  ].includes(t) || e.disabled || e.readOnly) return !1;
28112
28097
  try {
28113
- let t = lO(e);
28098
+ let t = oO(e);
28114
28099
  if (t.display === "none" || t.visibility === "hidden") return !1;
28115
28100
  } catch {}
28116
28101
  return !0;
28117
28102
  }));
28118
28103
  }), e;
28119
28104
  }
28120
- function mO() {
28121
- return pO().map((e, t) => ({
28105
+ function dO() {
28106
+ return uO().map((e, t) => ({
28122
28107
  formIndex: 0,
28123
28108
  fieldIndex: t,
28124
28109
  tag: e.tagName,
28125
28110
  type: e.type || "text",
28126
28111
  name: e.name || null,
28127
28112
  id: e.id || null,
28128
- label: fO(e),
28113
+ label: lO(e),
28129
28114
  placeholder: e.placeholder || null
28130
28115
  }));
28131
28116
  }
28132
- function hO() {
28117
+ function fO() {
28133
28118
  let e = [];
28134
- return uO((t) => {
28119
+ return sO((t) => {
28135
28120
  e.push(...Array.from(t.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
28136
- if (cO(e) || e.disabled) return !1;
28121
+ if (aO(e) || e.disabled) return !1;
28137
28122
  try {
28138
- let t = lO(e);
28123
+ let t = oO(e);
28139
28124
  if (t.display === "none" || t.visibility === "hidden") return !1;
28140
28125
  } catch {}
28141
28126
  return !0;
@@ -28147,15 +28132,15 @@ function hO() {
28147
28132
  type: e.type || e.tagName
28148
28133
  }));
28149
28134
  }
28150
- function gO(e) {
28135
+ function pO(e) {
28151
28136
  return String(e || "").toLowerCase().replace(/\u00a0/g, " ").replace(/\*/g, "").replace(/\s+/g, " ").trim();
28152
28137
  }
28153
- function _O(e) {
28154
- let t = gO(e);
28138
+ function mO(e) {
28139
+ let t = pO(e);
28155
28140
  return t = t.replace(/\s+field\s*$/i, "").trim(), t;
28156
28141
  }
28157
- function vO(e, t) {
28158
- let n = _O(t);
28142
+ function hO(e, t) {
28143
+ let n = mO(t);
28159
28144
  if (!n) return 0;
28160
28145
  let r = (e.name || "").toLowerCase(), i = (e.id || "").toLowerCase();
28161
28146
  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;
@@ -28163,12 +28148,12 @@ function vO(e, t) {
28163
28148
  e.name,
28164
28149
  e.id,
28165
28150
  e.placeholder,
28166
- fO(e),
28151
+ lO(e),
28167
28152
  e.getAttribute("aria-label"),
28168
28153
  e.getAttribute("title"),
28169
28154
  e.getAttribute("data-testid"),
28170
28155
  e.getAttribute("autocomplete")
28171
- ].filter(Boolean).map((e) => gO(e)), o = 0;
28156
+ ].filter(Boolean).map((e) => pO(e)), o = 0;
28172
28157
  for (let e of a) {
28173
28158
  if (!e) continue;
28174
28159
  if (e.includes(n) || n.includes(e)) {
@@ -28183,16 +28168,16 @@ function vO(e, t) {
28183
28168
  }
28184
28169
  return o;
28185
28170
  }
28186
- var yO = 28;
28187
- function bO(e, t) {
28171
+ var gO = 28;
28172
+ function _O(e, t) {
28188
28173
  let n = null, r = 0;
28189
28174
  for (let i of e) {
28190
- let e = vO(i, t);
28175
+ let e = hO(i, t);
28191
28176
  e > r && (r = e, n = i);
28192
28177
  }
28193
- return !n || r < yO ? null : n;
28178
+ return !n || r < gO ? null : n;
28194
28179
  }
28195
- function xO(e, t, n) {
28180
+ function vO(e, t, n) {
28196
28181
  let r = String(t || "").toLowerCase().trim(), i = String(n || "").trim();
28197
28182
  if (!(/^https?:\/\//i.test(i) || /\.\w{2,}(\/|\s|$)/.test(i) || r.includes("url") || r.includes("website") || r.includes("domain") || r.includes("site"))) return null;
28198
28183
  let a = null, o = 0;
@@ -28212,7 +28197,7 @@ function xO(e, t, n) {
28212
28197
  t.name,
28213
28198
  t.id,
28214
28199
  t.placeholder,
28215
- fO(t),
28200
+ lO(t),
28216
28201
  t.getAttribute("aria-label"),
28217
28202
  t.getAttribute("autocomplete")
28218
28203
  ].filter(Boolean).join(" ").toLowerCase();
@@ -28220,15 +28205,15 @@ function xO(e, t, n) {
28220
28205
  }
28221
28206
  return !a || o < 42 ? null : a;
28222
28207
  }
28223
- function SO(e) {
28208
+ function yO(e) {
28224
28209
  let t = String(e ?? "").trim();
28225
28210
  return t ? /^https?:\/\//i.test(t) ? !0 : /\.\w{2,}(\/|\s|$)/.test(t) : !1;
28226
28211
  }
28227
- function CO(e) {
28212
+ function bO(e) {
28228
28213
  let t = String(e ?? "").toLowerCase().trim();
28229
28214
  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;
28230
28215
  }
28231
- function wO(e) {
28216
+ function xO(e) {
28232
28217
  if (!e || e.tagName !== "INPUT" && e.tagName !== "TEXTAREA") return !1;
28233
28218
  let t = (e.type || "").toLowerCase();
28234
28219
  return ![
@@ -28240,22 +28225,22 @@ function wO(e) {
28240
28225
  "file"
28241
28226
  ].includes(t);
28242
28227
  }
28243
- function TO(e) {
28244
- if (!wO(e)) return !1;
28228
+ function SO(e) {
28229
+ if (!xO(e)) return !1;
28245
28230
  let t = (e.name || "").toLowerCase(), n = (e.id || "").toLowerCase(), r = [
28246
28231
  e.name,
28247
28232
  e.id,
28248
28233
  e.placeholder,
28249
- fO(e),
28234
+ lO(e),
28250
28235
  e.getAttribute("aria-label")
28251
28236
  ].filter(Boolean).join(" ").toLowerCase();
28252
28237
  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);
28253
28238
  }
28254
- function EO(e, t, n) {
28255
- let r = String(t ?? ""), i = String(n ?? ""), a = kO(e, r) || bO(e, r) || xO(e, r, i);
28239
+ function CO(e, t, n) {
28240
+ let r = String(t ?? ""), i = String(n ?? ""), a = EO(e, r) || _O(e, r) || vO(e, r, i);
28256
28241
  if (!a) return [];
28257
28242
  let o = new Set([a]);
28258
- if (SO(i) && CO(r)) for (let t of e) t !== a && TO(t) && o.add(t);
28243
+ if (yO(i) && bO(r)) for (let t of e) t !== a && SO(t) && o.add(t);
28259
28244
  let s = Array.from(o);
28260
28245
  return s.sort((e, t) => {
28261
28246
  if (e === t) return 0;
@@ -28263,7 +28248,7 @@ function EO(e, t, n) {
28263
28248
  return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
28264
28249
  }), s;
28265
28250
  }
28266
- function DO(e, t) {
28251
+ function wO(e, t) {
28267
28252
  try {
28268
28253
  if (!e?.getBoundingClientRect || !t?.getBoundingClientRect) return Infinity;
28269
28254
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), i = {
@@ -28278,17 +28263,17 @@ function DO(e, t) {
28278
28263
  return Infinity;
28279
28264
  }
28280
28265
  }
28281
- function OO(e) {
28266
+ function TO(e) {
28282
28267
  if (!e || typeof e != "string") return null;
28283
28268
  let t = null;
28284
- return uO((n) => {
28269
+ return sO((n) => {
28285
28270
  try {
28286
28271
  let r = n.getElementById(e);
28287
- r && !cO(r) && r.matches?.("input, select, textarea") && (t = r);
28272
+ r && !aO(r) && r.matches?.("input, select, textarea") && (t = r);
28288
28273
  } catch {}
28289
28274
  }), t;
28290
28275
  }
28291
- function kO(e, t) {
28276
+ function EO(e, t) {
28292
28277
  let n = String(t ?? "").trim();
28293
28278
  if (!n) return null;
28294
28279
  let r = n.match(/^name:\s*([\w.-]+)$/i);
@@ -28298,12 +28283,12 @@ function kO(e, t) {
28298
28283
  }
28299
28284
  let i = n.match(/^id:\s*([\w.-]+)$/i);
28300
28285
  if (i) {
28301
- let e = OO(i[1]);
28286
+ let e = TO(i[1]);
28302
28287
  if (e) return e;
28303
28288
  }
28304
28289
  let a = n.startsWith("#") ? n.slice(1) : n;
28305
28290
  if (/^[\w-]+$/.test(a)) {
28306
- let e = OO(a);
28291
+ let e = TO(a);
28307
28292
  if (e) return e;
28308
28293
  }
28309
28294
  let o = n.toLowerCase().replace(/\s+/g, " ");
@@ -28313,7 +28298,7 @@ function kO(e, t) {
28313
28298
  }
28314
28299
  return null;
28315
28300
  }
28316
- function AO(e, t) {
28301
+ function DO(e, t) {
28317
28302
  let n = String(t || "").toLowerCase().trim();
28318
28303
  if (!n) return 0;
28319
28304
  let r = [
@@ -28329,13 +28314,13 @@ function AO(e, t) {
28329
28314
  for (let e of i) r.includes(e) && (a += 1);
28330
28315
  return a / i.length * 92;
28331
28316
  }
28332
- function jO(e, t) {
28317
+ function OO(e, t) {
28333
28318
  let n = [];
28334
- uO((e) => {
28319
+ sO((e) => {
28335
28320
  n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
28336
- if (cO(e) || e.disabled) return !1;
28321
+ if (aO(e) || e.disabled) return !1;
28337
28322
  try {
28338
- let t = lO(e);
28323
+ let t = oO(e);
28339
28324
  if (t.display === "none" || t.visibility === "hidden") return !1;
28340
28325
  } catch {}
28341
28326
  return !0;
@@ -28343,7 +28328,7 @@ function jO(e, t) {
28343
28328
  });
28344
28329
  let r = 0, i = n.map((t) => ({
28345
28330
  el: t,
28346
- s: AO(t, e)
28331
+ s: DO(t, e)
28347
28332
  }));
28348
28333
  for (let { s: e } of i) e > r && (r = e);
28349
28334
  if (r < 36) return null;
@@ -28353,14 +28338,14 @@ function jO(e, t) {
28353
28338
  if (o.length) {
28354
28339
  let e = a[0], t = Infinity;
28355
28340
  for (let n of a) for (let r of o) {
28356
- let i = DO(n, r);
28341
+ let i = wO(n, r);
28357
28342
  i < t && (t = i, e = n);
28358
28343
  }
28359
28344
  return e;
28360
28345
  }
28361
28346
  return a[0];
28362
28347
  }
28363
- function MO(e) {
28348
+ function kO(e) {
28364
28349
  if (e == null) return {};
28365
28350
  if (typeof e == "string") {
28366
28351
  let t = e.trim();
@@ -28373,8 +28358,8 @@ function MO(e) {
28373
28358
  }
28374
28359
  return e;
28375
28360
  }
28376
- function NO(e) {
28377
- let t = MO(e);
28361
+ function AO(e) {
28362
+ let t = kO(e);
28378
28363
  if (Array.isArray(t) && t.length > 0) {
28379
28364
  let e = t[0];
28380
28365
  if (e?.field_key != null || e?.fieldKey != null) return t.map((e) => ({
@@ -28402,7 +28387,7 @@ function NO(e) {
28402
28387
  value: e?.value ?? e?.Value
28403
28388
  })) : [];
28404
28389
  }
28405
- function PO(e) {
28390
+ function jO(e) {
28406
28391
  if (!e || typeof e != "string") return [];
28407
28392
  let t = e.trim();
28408
28393
  if (!t || /\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t)) return [];
@@ -28421,7 +28406,7 @@ function PO(e) {
28421
28406
  }
28422
28407
  return [];
28423
28408
  }
28424
- function FO(e) {
28409
+ function MO(e) {
28425
28410
  if (!e || typeof e != "string") return [];
28426
28411
  let t = e.trim();
28427
28412
  if (!t) return [];
@@ -28457,17 +28442,17 @@ function FO(e) {
28457
28442
  }
28458
28443
  return n;
28459
28444
  }
28460
- function IO(e) {
28445
+ function NO(e) {
28461
28446
  if (!e || typeof e != "object") return null;
28462
28447
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
28463
28448
  return t == null ? null : String(t).trim() || null;
28464
28449
  }
28465
- function LO(e) {
28450
+ function PO(e) {
28466
28451
  if (!e || typeof e != "object") return null;
28467
28452
  let t = e.query ?? e.q ?? e.search ?? e.text ?? e.keywords;
28468
28453
  return t == null ? null : String(t).trim() || null;
28469
28454
  }
28470
- function RO(e, t, n) {
28455
+ function FO(e, t, n) {
28471
28456
  if (!n?.skipScroll) try {
28472
28457
  e.scrollIntoView({
28473
28458
  block: "center",
@@ -28522,7 +28507,7 @@ function RO(e, t, n) {
28522
28507
  } catch {}
28523
28508
  return !0;
28524
28509
  }
28525
- function zO() {
28510
+ function IO() {
28526
28511
  let e = {};
28527
28512
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
28528
28513
  if (t.id) return;
@@ -28537,11 +28522,11 @@ function zO() {
28537
28522
  e[r] = !0, t.id = r;
28538
28523
  });
28539
28524
  }
28540
- function BO(e) {
28525
+ function LO(e) {
28541
28526
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
28542
28527
  flowengage_navigate: async (n) => {
28543
28528
  $("flowengage_navigate ▶ raw parameters:", n);
28544
- let r = MO(n), i = IO(r), a = r.section_text ?? r.sectionText ?? r.section;
28529
+ let r = kO(n), i = NO(r), a = r.section_text ?? r.sectionText ?? r.section;
28545
28530
  if ($("flowengage_navigate · coerced:", {
28546
28531
  url: i,
28547
28532
  sectionText: a
@@ -28557,45 +28542,45 @@ function BO(e) {
28557
28542
  return $("flowengage_navigate ✖ blocked", e), e;
28558
28543
  }
28559
28544
  try {
28560
- if (BD(`Navigating to ${i}...`, { spinner: !0 }), GD(), OD(), FD(), $("flowengage_navigate → shadowNavigate", i), await nr(i, {
28545
+ if (LD(`Navigating to ${i}...`, { spinner: !0 }), HD(), OD(), MD(), $("flowengage_navigate → shadowNavigate", i), await nr(i, {
28561
28546
  sectionText: typeof a == "string" ? a : void 0,
28562
28547
  voiceActive: !0
28563
- }), await oO(), zO(), a && typeof a == "string") {
28548
+ }), await rO(), IO(), a && typeof a == "string") {
28564
28549
  let e = null;
28565
- for (let t = 0; t < 5 && !e; t++) e = Gn(null, a), e || await aO(300);
28566
- e && PD(e), $("flowengage_navigate · highlight", {
28550
+ for (let t = 0; t < 5 && !e; t++) e = Gn(null, a), e || await nO(300);
28551
+ e && jD(e), $("flowengage_navigate · highlight", {
28567
28552
  sectionText: a,
28568
28553
  found: !!e,
28569
28554
  attempts: e ? "ok" : 5
28570
28555
  });
28571
28556
  }
28572
28557
  let e = Array.from(document.querySelectorAll("h1, h2, h3, h4")).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, nav, footer, header")).map((e) => e.textContent.trim()).filter((e) => e.length > 0 && e.length < 150).slice(0, 20), t = `OK_NAVIGATION ${i}. Page sections: ${JSON.stringify(e)}. For each section: call flowengage_highlight, speak 2-3 sentences about ONLY that section, then highlight the next. One section per speech turn.`;
28573
- return $("flowengage_navigate ✓", t), BD("Navigation complete", {
28558
+ return $("flowengage_navigate ✓", t), LD("Navigation complete", {
28574
28559
  spinner: !1,
28575
28560
  icon: "✅",
28576
28561
  duration: 1200
28577
28562
  }), t;
28578
28563
  } catch (e) {
28579
28564
  let t = `Navigation error: ${e?.message || String(e)}`;
28580
- return $("flowengage_navigate ✖", t), BD("Navigation failed", {
28565
+ return $("flowengage_navigate ✖", t), LD("Navigation failed", {
28581
28566
  spinner: !1,
28582
28567
  icon: "⚠️",
28583
28568
  duration: 1800
28584
28569
  }), t;
28585
28570
  } finally {
28586
- KD(), VD(900);
28571
+ UD(), RD(900);
28587
28572
  }
28588
28573
  },
28589
28574
  flowengage_highlight: async (e) => {
28590
28575
  $("flowengage_highlight ▶", e);
28591
- let t = MO(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
28592
- zO();
28576
+ let t = kO(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
28577
+ IO();
28593
28578
  let i = Gn(n || null, r || null);
28594
- return !i && r && (await new Promise((e) => setTimeout(e, 500)), zO(), i = Gn(null, r)), i ? (PD(i), $("flowengage_highlight ✓", r || n), `OK_HIGHLIGHT: "${r || n}"`) : ($("flowengage_highlight ✖ no element for:", r || n), `Could not find "${r || n}" on the current page. Try a shorter phrase matching a visible heading.`);
28579
+ return !i && r && (await new Promise((e) => setTimeout(e, 500)), IO(), i = Gn(null, r)), i ? (jD(i), $("flowengage_highlight ✓", r || n), `OK_HIGHLIGHT: "${r || n}"`) : ($("flowengage_highlight ✖ no element for:", r || n), `Could not find "${r || n}" on the current page. Try a shorter phrase matching a visible heading.`);
28595
28580
  },
28596
28581
  flowengage_read_content: async (e) => {
28597
28582
  $("flowengage_read_content ▶", e);
28598
- let t = MO(e), n = t?.section_text || t?.sectionText || "";
28583
+ let t = kO(e), n = t?.section_text || t?.sectionText || "";
28599
28584
  try {
28600
28585
  let e = "";
28601
28586
  if (n) {
@@ -28618,7 +28603,7 @@ function BO(e) {
28618
28603
  },
28619
28604
  flowengage_search: async (e) => {
28620
28605
  $("flowengage_search ▶", e);
28621
- let r = LO(MO(e));
28606
+ let r = PO(kO(e));
28622
28607
  if ($("flowengage_search · query:", r, "siteId:", t, "apiBase:", n || "(empty)"), !r) return $("flowengage_search ✖ missing query"), "Missing query parameter.";
28623
28608
  if (!t) return $("flowengage_search ✖ no siteId"), "Site is not configured for search.";
28624
28609
  if (!n) return $("flowengage_search ✖ no api base"), "API base URL is missing; cannot search.";
@@ -28647,7 +28632,7 @@ function BO(e) {
28647
28632
  },
28648
28633
  flowengage_page_content: async (e) => {
28649
28634
  $("flowengage_page_content ▶", e);
28650
- let r = MO(e), i = r?.url || r?.page_url || "";
28635
+ let r = kO(e), i = r?.url || r?.page_url || "";
28651
28636
  if ($("flowengage_page_content · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("flowengage_page_content ✖ missing url"), "Missing url parameter.";
28652
28637
  if (!t) return $("flowengage_page_content ✖ no siteId"), "Site is not configured.";
28653
28638
  if (!n) return $("flowengage_page_content ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -28679,7 +28664,7 @@ function BO(e) {
28679
28664
  },
28680
28665
  flowengage_end_session: async () => ($("flowengage_end_session ▶"), typeof e.requestEndSession == "function" && e.requestEndSession(), "Voice session is ending."),
28681
28666
  flowengage_list_forms: async () => {
28682
- let e = mO(), t = hO();
28667
+ let e = dO(), t = fO();
28683
28668
  return $("flowengage_list_forms ✓", `${e.length} field(s)`, `${t.length} button(s)`), JSON.stringify({
28684
28669
  fields: e,
28685
28670
  buttons: t,
@@ -28688,52 +28673,52 @@ function BO(e) {
28688
28673
  },
28689
28674
  flowengage_fill_form: async (e) => {
28690
28675
  try {
28691
- $("flowengage_fill_form ▶ raw:", e), qD();
28692
- let t = NO(e);
28676
+ $("flowengage_fill_form ▶ raw:", e), WD();
28677
+ let t = AO(e);
28693
28678
  if (!t.length && r) {
28694
- let e = r(), n = PO(e);
28695
- n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = FO(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
28679
+ let e = r(), n = jO(e);
28680
+ n.length ? $("flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):", n) : (n = MO(e), n.length && $("flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):", n)), n.length && (t = n);
28696
28681
  }
28697
28682
  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.";
28698
28683
  let n = [];
28699
28684
  for (let e of t) {
28700
28685
  let t = e?.field_key ?? e?.fieldKey, r = e?.value;
28701
28686
  if (t == null || r == null) continue;
28702
- BD(`Filling ${String(t)}...`, { spinner: !0 });
28703
- let a = pO(), o = EO(a, String(t), r);
28687
+ LD(`Filling ${String(t)}...`, { spinner: !0 });
28688
+ let a = uO(), o = CO(a, String(t), r);
28704
28689
  if (o.length) {
28705
- for (let [e, t] of o.entries()) JD(t), await eO(t), RO(t, r, { skipScroll: e > 0 }), YD(t), await aO(120);
28690
+ for (let [e, t] of o.entries()) GD(t), await ZD(t), FO(t, r, { skipScroll: e > 0 }), KD(t), await nO(120);
28706
28691
  i = o, n.push(String(t));
28707
28692
  continue;
28708
28693
  }
28709
- let s = kO(a, String(t));
28710
- s ||= bO(a, String(t)), s ||= xO(a, String(t), r), s && (JD(s), await eO(s), RO(s, r), YD(s), await aO(120), i = [s], n.push(String(t)));
28694
+ let s = EO(a, String(t));
28695
+ s ||= _O(a, String(t)), s ||= vO(a, String(t), r), s && (GD(s), await ZD(s), FO(s, r), KD(s), await nO(120), i = [s], n.push(String(t)));
28711
28696
  }
28712
28697
  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.";
28713
28698
  let a = `OK_FILLED: ${n.join(", ")}`;
28714
- return $("flowengage_fill_form ✓", a), BD("Form filled", {
28699
+ return $("flowengage_fill_form ✓", a), LD("Form filled", {
28715
28700
  spinner: !1,
28716
28701
  icon: "✅",
28717
28702
  duration: 1100
28718
28703
  }), a;
28719
28704
  } catch (e) {
28720
28705
  let t = `flowengage_fill_form error: ${e?.message || String(e)}`;
28721
- return $("flowengage_fill_form ✖", t), BD("Failed to fill form", {
28706
+ return $("flowengage_fill_form ✖", t), LD("Failed to fill form", {
28722
28707
  spinner: !1,
28723
28708
  icon: "⚠️",
28724
28709
  duration: 1800
28725
28710
  }), t;
28726
28711
  } finally {
28727
- tO(), qD(), VD(700);
28712
+ QD(), WD(), RD(700);
28728
28713
  }
28729
28714
  },
28730
28715
  flowengage_click_button: async (e) => {
28731
- let t = MO(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
28716
+ let t = kO(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
28732
28717
  if ($("flowengage_click_button ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
28733
- let r = jO(n, i);
28718
+ let r = OO(n, i);
28734
28719
  if (!r) return $("flowengage_click_button ✖ no match"), `Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;
28735
28720
  try {
28736
- BD(`Clicking ${n}...`, { spinner: !0 });
28721
+ LD(`Clicking ${n}...`, { spinner: !0 });
28737
28722
  try {
28738
28723
  r.scrollIntoView({
28739
28724
  block: "center",
@@ -28742,22 +28727,22 @@ function BO(e) {
28742
28727
  } catch {
28743
28728
  r.scrollIntoView(!0);
28744
28729
  }
28745
- await eO(r), r.focus?.(), await nO(r), rO(r), r.click();
28730
+ await ZD(r), r.focus?.(), await $D(r), eO(r), r.click();
28746
28731
  let e = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
28747
- return $("flowengage_click_button ✓", t), BD(`Clicked ${e}`, {
28732
+ return $("flowengage_click_button ✓", t), LD(`Clicked ${e}`, {
28748
28733
  spinner: !1,
28749
28734
  icon: "✅",
28750
28735
  duration: 1200
28751
28736
  }), t;
28752
28737
  } catch (e) {
28753
28738
  let t = `Click failed: ${e?.message || String(e)}`;
28754
- return $("flowengage_click_button ✖", t), BD("Click failed", {
28739
+ return $("flowengage_click_button ✖", t), LD("Click failed", {
28755
28740
  spinner: !1,
28756
28741
  icon: "⚠️",
28757
28742
  duration: 1800
28758
28743
  }), t;
28759
28744
  } finally {
28760
- tO(), VD(700);
28745
+ QD(), RD(700);
28761
28746
  }
28762
28747
  }
28763
28748
  };
@@ -28775,7 +28760,7 @@ function BO(e) {
28775
28760
  }
28776
28761
  //#endregion
28777
28762
  //#region src/utils/wrapVoiceToolsForLogging.js
28778
- function VO(e) {
28763
+ function RO(e) {
28779
28764
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
28780
28765
  let r = vn();
28781
28766
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -28792,7 +28777,7 @@ function VO(e) {
28792
28777
  }
28793
28778
  //#endregion
28794
28779
  //#region src/components/FlowEngageWidget.jsx
28795
- var HO = {
28780
+ var zO = {
28796
28781
  blue: "#135bd8",
28797
28782
  red: "#ef334b",
28798
28783
  yellow: "#ffbd2e",
@@ -28800,7 +28785,7 @@ var HO = {
28800
28785
  highlight: "rgba(255,255,255,0.9)",
28801
28786
  green: "#10b981"
28802
28787
  };
28803
- function UO(e) {
28788
+ function BO(e) {
28804
28789
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
28805
28790
  let [t, n, r] = e;
28806
28791
  return e.length >= 3 && r ? [
@@ -28814,12 +28799,12 @@ function UO(e) {
28814
28799
  "#f7f8fa"
28815
28800
  ].join(", ");
28816
28801
  }
28817
- function WO(e) {
28802
+ function VO(e) {
28818
28803
  if (!e || typeof e != "string") return "#1a1a1a";
28819
28804
  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;
28820
28805
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
28821
28806
  }
28822
- function GO({ logo: t, style: n }) {
28807
+ function HO({ logo: t, style: n }) {
28823
28808
  if (!t) return null;
28824
28809
  if (typeof t == "string") return /* @__PURE__ */ g("img", {
28825
28810
  src: t,
@@ -28844,7 +28829,7 @@ function GO({ logo: t, style: n }) {
28844
28829
  children: r
28845
28830
  }) : null;
28846
28831
  }
28847
- function KO({ title: e }) {
28832
+ function UO({ title: e }) {
28848
28833
  return /* @__PURE__ */ g("div", {
28849
28834
  style: {
28850
28835
  width: "100%",
@@ -28862,18 +28847,18 @@ function KO({ title: e }) {
28862
28847
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
28863
28848
  });
28864
28849
  }
28865
- function qO(e, t) {
28850
+ function WO(e, t) {
28866
28851
  let n = (t || "").trim();
28867
28852
  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;
28868
28853
  }
28869
- function JO({ orbColors: e, ...t }) {
28854
+ function GO({ orbColors: e, ...t }) {
28870
28855
  return /* @__PURE__ */ g(ED, {
28871
28856
  colors: e,
28872
28857
  ...t
28873
28858
  });
28874
28859
  }
28875
- function YO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a }) {
28876
- let o = n || HO.green, s = WO(o), c = a ? 72 : 94, l = /* @__PURE__ */ _("div", {
28860
+ function KO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a }) {
28861
+ let o = n || zO.green, s = VO(o), c = a ? 72 : 94, l = /* @__PURE__ */ _("div", {
28877
28862
  style: {
28878
28863
  display: "flex",
28879
28864
  alignItems: "center",
@@ -28994,7 +28979,7 @@ function YO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
28994
28979
  delay: 0
28995
28980
  },
28996
28981
  style: { flexShrink: 0 },
28997
- children: /* @__PURE__ */ g(JO, {
28982
+ children: /* @__PURE__ */ g(GO, {
28998
28983
  size: c,
28999
28984
  orbColors: t
29000
28985
  })
@@ -29022,8 +29007,8 @@ function YO({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29022
29007
  children: l
29023
29008
  }) : l] });
29024
29009
  }
29025
- function XO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o }) {
29026
- let s = n || HO.green, c = WO(s);
29010
+ function qO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o }) {
29011
+ let s = n || zO.green, c = VO(s);
29027
29012
  return /* @__PURE__ */ _($p.div, {
29028
29013
  initial: {
29029
29014
  scale: 50 / 350,
@@ -29089,7 +29074,7 @@ function XO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
29089
29074
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
29090
29075
  })
29091
29076
  }),
29092
- /* @__PURE__ */ g(JO, {
29077
+ /* @__PURE__ */ g(GO, {
29093
29078
  size: 72,
29094
29079
  orbColors: t
29095
29080
  }),
@@ -29158,7 +29143,7 @@ function XO({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
29158
29143
  ]
29159
29144
  });
29160
29145
  }
29161
- function ZO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, historyRef: s, onMessageSync: l }) {
29146
+ function JO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, historyRef: s, onMessageSync: l }) {
29162
29147
  let [u, d] = m("idle"), [f, h] = m(!1), [v, y] = m(!1), b = p(null), x = p(""), S = p(async () => {}), C = p(!1), ee = p(!1), w = p(!1), te = p(!1), ne = p("minimized"), re = p(null), ie = o((e = "minimized") => {
29163
29148
  ne.current = e, te.current = !0, queueMicrotask(() => {
29164
29149
  C.current || (C.current = !0, S.current?.());
@@ -29182,7 +29167,7 @@ function ZO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29182
29167
  try {
29183
29168
  if ((await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), e) return;
29184
29169
  s.current = [], x.current = "", C.current = !1, w.current = !1, te.current = !1, ne.current = "minimized";
29185
- let t = VO(BO({
29170
+ let t = RO(LO({
29186
29171
  siteId: i || null,
29187
29172
  apiBaseUrl: a || null,
29188
29173
  getLastUserVoiceText: () => x.current,
@@ -29203,7 +29188,7 @@ function ZO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29203
29188
  sender: n,
29204
29189
  message: r,
29205
29190
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
29206
- }], qO(n, r) && ie("minimized"));
29191
+ }], WO(n, r) && ie("minimized"));
29207
29192
  },
29208
29193
  onError: (t) => {
29209
29194
  if (!e && !te.current && !w.current) {
@@ -29292,7 +29277,7 @@ function ZO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29292
29277
  whiteSpace: "nowrap"
29293
29278
  },
29294
29279
  children: "Listening..."
29295
- }), /* @__PURE__ */ g(JO, {
29280
+ }), /* @__PURE__ */ g(GO, {
29296
29281
  size: 72,
29297
29282
  voiceState: u,
29298
29283
  isMuted: f,
@@ -29519,7 +29504,7 @@ function ZO({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
29519
29504
  ]
29520
29505
  });
29521
29506
  }
29522
- function QO({ orbColors: e }) {
29507
+ function YO({ orbColors: e }) {
29523
29508
  return /* @__PURE__ */ g("div", {
29524
29509
  style: {
29525
29510
  flexShrink: 0,
@@ -29529,13 +29514,13 @@ function QO({ orbColors: e }) {
29529
29514
  alignItems: "center",
29530
29515
  justifyContent: "center"
29531
29516
  },
29532
- children: /* @__PURE__ */ g(JO, {
29517
+ children: /* @__PURE__ */ g(GO, {
29533
29518
  size: 36,
29534
29519
  orbColors: e
29535
29520
  })
29536
29521
  });
29537
29522
  }
29538
- var $O = () => /* @__PURE__ */ g("div", {
29523
+ var XO = () => /* @__PURE__ */ g("div", {
29539
29524
  style: {
29540
29525
  display: "flex",
29541
29526
  marginBottom: "12px",
@@ -29565,7 +29550,7 @@ var $O = () => /* @__PURE__ */ g("div", {
29565
29550
  } }, e))
29566
29551
  })
29567
29552
  });
29568
- function ek({ 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: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: ee, isRateLimited: w, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: ie, attachmentError: T, isUploadingAttachment: ae, requiresEmail: oe, emailInput: se, setEmailInput: ce, emailError: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, incomingCall: ge, rejectCall: _e, acceptCall: ve, activeCallId: ye, callConnectionState: be, isCallMuted: xe, toggleCallMute: Se, endWebRTCCall: Ce, formatCallDuration: we, callDurationSeconds: Te, onCollapse: Ee, onStartVoice: De, showPoweredBy: Oe }) {
29553
+ function ZO({ 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: h, agentHeadshot: v, fallbackAgentName: y, input: b, setInput: x, onSubmit: S, isConversationEnded: C, isLoading: ee, isRateLimited: w, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: ie, attachmentError: T, isUploadingAttachment: ae, requiresEmail: oe, emailInput: se, setEmailInput: ce, emailError: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, incomingCall: ge, rejectCall: _e, acceptCall: ve, activeCallId: ye, callConnectionState: be, isCallMuted: xe, toggleCallMute: Se, endWebRTCCall: Ce, formatCallDuration: we, callDurationSeconds: Te, onCollapse: Ee, onStartVoice: De, showPoweredBy: Oe }) {
29569
29554
  let ke = l.length > 0, Ae = ee || w || C, je = !!(ge || ye), [Me, Ne] = m(!1), Pe = p(null);
29570
29555
  return c(() => {
29571
29556
  if (!Me) return;
@@ -29669,7 +29654,7 @@ function ek({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29669
29654
  justifyContent: "center",
29670
29655
  height: "40px"
29671
29656
  },
29672
- children: i ? /* @__PURE__ */ g(GO, {
29657
+ children: i ? /* @__PURE__ */ g(HO, {
29673
29658
  logo: i,
29674
29659
  style: {
29675
29660
  height: "34px",
@@ -29682,7 +29667,7 @@ function ek({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29682
29667
  height: "40px",
29683
29668
  flexShrink: 0
29684
29669
  },
29685
- children: /* @__PURE__ */ g(KO, { title: e.chatTitle })
29670
+ children: /* @__PURE__ */ g(UO, { title: e.chatTitle })
29686
29671
  })
29687
29672
  }), /* @__PURE__ */ g("div", {
29688
29673
  style: {
@@ -29901,11 +29886,11 @@ function ek({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29901
29886
  isAiTyping: u,
29902
29887
  isAgentTyping: d,
29903
29888
  setReplyContext: de,
29904
- TypingDots: $O,
29889
+ TypingDots: XO,
29905
29890
  primaryColor: n,
29906
29891
  agentHeadshot: v,
29907
29892
  agentDisplayName: h || y,
29908
- botAvatarNode: /* @__PURE__ */ g(QO, { orbColors: t })
29893
+ botAvatarNode: /* @__PURE__ */ g(YO, { orbColors: t })
29909
29894
  }) : /* @__PURE__ */ _("div", {
29910
29895
  style: {
29911
29896
  flex: 1,
@@ -29918,7 +29903,7 @@ function ek({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
29918
29903
  padding: "28px 24px"
29919
29904
  },
29920
29905
  children: [
29921
- /* @__PURE__ */ g(JO, {
29906
+ /* @__PURE__ */ g(GO, {
29922
29907
  size: 94,
29923
29908
  orbColors: t
29924
29909
  }),
@@ -30026,7 +30011,7 @@ function ek({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30026
30011
  ]
30027
30012
  });
30028
30013
  }
30029
- function tk() {
30014
+ function QO() {
30030
30015
  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: ee, activeCallId: w, callConnectionState: te, callConnectedAt: ne, isCallMuted: re, webRTCError: ie, language: T, historyRef: ae, onMessageSync: oe, sendMessage: se, uploadChatFile: ce, openWidget: le, captureVisitorEmail: ue, setVoiceMode: de, endConversation: fe, acceptCall: pe, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se } = _n();
30031
30016
  c(() => {
30032
30017
  try {
@@ -30042,7 +30027,7 @@ function tk() {
30042
30027
  }, De = {
30043
30028
  ...Ce.features || {},
30044
30029
  ...we.features || {}
30045
- }, Oe = De.voice !== !1, ke = Array.isArray(Ee.orbColors) && Ee.orbColors.length > 0 ? Ee.orbColors : null, Ae = ke?.[0] || Ee.primaryColor || "#3B82F6", je = Ee.position || "bottom-right", Me = Te.fallbackAgentName || "Agent", Ne = UO(ke ?? Ee.chatBgColors), Pe = Te.logo || Te.logoUrl || null, Fe = T || "en", Ie = Ce.recommendations?.[Fe] || [], Le = (we.recommendations?.[Fe] ?? Ie).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
30030
+ }, Oe = De.voice !== !1, ke = Array.isArray(Ee.orbColors) && Ee.orbColors.length > 0 ? Ee.orbColors : null, Ae = ke?.[0] || Ee.primaryColor || "#3B82F6", je = Ee.position || "bottom-right", Me = Te.fallbackAgentName || "Agent", Ne = BO(ke ?? Ee.chatBgColors), Pe = Te.logo || Te.logoUrl || null, Fe = T || "en", Ie = Ce.recommendations?.[Fe] || [], Le = (we.recommendations?.[Fe] ?? Ie).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
30046
30031
  id: e.key || `qr-${t}`,
30047
30032
  label: e.label,
30048
30033
  message: e.label,
@@ -30231,7 +30216,7 @@ function tk() {
30231
30216
  ...wt
30232
30217
  },
30233
30218
  children: [
30234
- D === "entry_prompt" && /* @__PURE__ */ g(YO, {
30219
+ D === "entry_prompt" && /* @__PURE__ */ g(KO, {
30235
30220
  copy: Ve,
30236
30221
  orbColors: ke,
30237
30222
  primaryColor: Ae,
@@ -30256,13 +30241,13 @@ function tk() {
30256
30241
  transformOrigin: "bottom right",
30257
30242
  display: "inline-block"
30258
30243
  },
30259
- children: /* @__PURE__ */ g(JO, {
30244
+ children: /* @__PURE__ */ g(GO, {
30260
30245
  size: 50,
30261
30246
  orbColors: ke,
30262
30247
  onClick: Oe ? Et : Ot
30263
30248
  })
30264
30249
  }),
30265
- D === "connection_modal" && /* @__PURE__ */ g(XO, {
30250
+ D === "connection_modal" && /* @__PURE__ */ g(qO, {
30266
30251
  copy: Ve,
30267
30252
  orbColors: ke,
30268
30253
  primaryColor: Ae,
@@ -30271,7 +30256,7 @@ function tk() {
30271
30256
  onClose: Tt,
30272
30257
  isMobile: gt
30273
30258
  }),
30274
- D === "voice_mode" && /* @__PURE__ */ g(ZO, {
30259
+ D === "voice_mode" && /* @__PURE__ */ g(JO, {
30275
30260
  orbColors: ke,
30276
30261
  onEnterChat: Ot,
30277
30262
  onEndChat: kt,
@@ -30281,7 +30266,7 @@ function tk() {
30281
30266
  historyRef: ae,
30282
30267
  onMessageSync: oe
30283
30268
  }, "voice"),
30284
- D === "text_chat" && /* @__PURE__ */ g(ek, {
30269
+ D === "text_chat" && /* @__PURE__ */ g(ZO, {
30285
30270
  copy: Ve,
30286
30271
  orbColors: ke,
30287
30272
  primaryColor: Ae,
@@ -30339,4 +30324,4 @@ function tk() {
30339
30324
  });
30340
30325
  }
30341
30326
  //#endregion
30342
- export { ED as AnimatedOrb, ur as FlowEngageProvider, tk as FlowEngageWidget, _n as useFlowEngage };
30327
+ export { ED as AnimatedOrb, ur as FlowEngageProvider, QO as FlowEngageWidget, _n as useFlowEngage };