@flowengage/react-chatbot 8.0.33 → 8.0.34

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.
@@ -18,7 +18,7 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
18
18
  }, T = (e) => x.call(e, "module.exports") ? e["module.exports"] : w(v({}, "__esModule", { value: !0 }), e), E = (e) => {
19
19
  if (!e || typeof e != "object") throw Error("FlowEngage config is required");
20
20
  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' }}.");
21
- let t = (e.apiBaseUrl || "https://be-flowengage-dev.oslabs.app").replace(/\/+$/, "");
21
+ let t = (e.apiBaseUrl || "https://be-flowengage-stage.oslabs.app").replace(/\/+$/, "");
22
22
  return {
23
23
  siteId: e.siteId.trim(),
24
24
  apiBaseUrl: t
@@ -29146,11 +29146,18 @@ function $O(e, t) {
29146
29146
  for (let e of a) i.includes(e) && (o += 1);
29147
29147
  return o / a.length * 92;
29148
29148
  }
29149
- function ek(e, t) {
29150
- let n = [];
29149
+ function ek(e, t, n = 6) {
29150
+ let r = String(t || "").toLowerCase().trim();
29151
+ if (!r) return !1;
29152
+ let i = e;
29153
+ for (let e = 0; e < n && i && (i = i.parentElement, i); e++) if ((i.innerText || i.textContent || "").toLowerCase().includes(r)) return !0;
29154
+ return !1;
29155
+ }
29156
+ function tk(e, t, n) {
29157
+ let r = [];
29151
29158
  KO((e) => {
29152
29159
  let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
29153
- n.push(...t.filter((e) => {
29160
+ r.push(...t.filter((e) => {
29154
29161
  if (Vn(e) || e.disabled) return !1;
29155
29162
  try {
29156
29163
  let t = GO(e);
@@ -29159,26 +29166,31 @@ function ek(e, t) {
29159
29166
  return !0;
29160
29167
  }));
29161
29168
  });
29162
- let r = 0, i = n.map((t) => ({
29169
+ let i = 0, a = r.map((t) => ({
29163
29170
  el: t,
29164
29171
  s: $O(t, e)
29165
29172
  }));
29166
- for (let { s: e } of i) e > r && (r = e);
29167
- if (r < 28) return null;
29168
- let a = i.filter(({ s: e }) => e === r).map(({ el: e }) => e);
29169
- if (a.length === 1) return a[0];
29170
- let o = Array.isArray(t) ? t.filter((e) => e && e.isConnected) : [];
29171
- if (o.length) {
29172
- let e = a[0], t = Infinity;
29173
- for (let n of a) for (let r of o) {
29173
+ for (let { s: e } of a) e > i && (i = e);
29174
+ if (i < 28) return null;
29175
+ let o = a.filter(({ s: e }) => e === i).map(({ el: e }) => e);
29176
+ if (o.length === 1) return o[0];
29177
+ if (n) {
29178
+ let e = o.filter((e) => ek(e, n));
29179
+ if (e.length === 1) return e[0];
29180
+ e.length > 1 && (o = e);
29181
+ }
29182
+ let s = Array.isArray(t) ? t.filter((e) => e && e.isConnected) : [];
29183
+ if (s.length) {
29184
+ let e = o[0], t = Infinity;
29185
+ for (let n of o) for (let r of s) {
29174
29186
  let i = QO(n, r);
29175
29187
  i < t && (t = i, e = n);
29176
29188
  }
29177
29189
  return e;
29178
29190
  }
29179
- return a[0];
29191
+ return o[0];
29180
29192
  }
29181
- function tk(e) {
29193
+ function nk(e) {
29182
29194
  if (e == null) return {};
29183
29195
  if (typeof e == "string") {
29184
29196
  let t = e.trim();
@@ -29191,12 +29203,12 @@ function tk(e) {
29191
29203
  }
29192
29204
  return e;
29193
29205
  }
29194
- function nk(e) {
29206
+ function rk(e) {
29195
29207
  if (!e || typeof e != "object") return null;
29196
29208
  let t = e.url ?? e.target_url ?? e.page_url ?? e.pageUrl ?? e.link ?? e.href ?? e.path;
29197
29209
  return t == null ? null : String(t).trim() || null;
29198
29210
  }
29199
- function rk() {
29211
+ function ik() {
29200
29212
  let e = {};
29201
29213
  document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t) => {
29202
29214
  if (t.id) return;
@@ -29211,7 +29223,7 @@ function rk() {
29211
29223
  e[r] = !0, t.id = r;
29212
29224
  });
29213
29225
  }
29214
- function ik() {
29226
+ function ak() {
29215
29227
  let e = (e) => {
29216
29228
  let t = Array.from(e).filter((e) => !e.closest("#flowengage-root, .flowengage-shell, .flowengage-widget-root") && !e.closest("nav, footer, header, aside, .nav, .footer, .header, .sidebar")), n = [], r = 0;
29217
29229
  for (; r < t.length;) {
@@ -29254,7 +29266,7 @@ function ik() {
29254
29266
  introText: o
29255
29267
  };
29256
29268
  }
29257
- function ak(e) {
29269
+ function ok(e) {
29258
29270
  if (!e || typeof document > "u") return "";
29259
29271
  let t = new Set([
29260
29272
  "script",
@@ -29340,11 +29352,11 @@ function ak(e) {
29340
29352
  return d.has(t) ? !1 : (d.add(t), !0);
29341
29353
  }).join("\n").replace(/\n{3,}/g, "\n\n").trim();
29342
29354
  }
29343
- function ok(e) {
29355
+ function sk(e) {
29344
29356
  let t = e.siteId || null, n = (e.apiBaseUrl || "").replace(/\/$/, ""), r = typeof e.getLastUserVoiceText == "function" ? e.getLastUserVoiceText : null, i = [], a = {
29345
29357
  "fwh-navigate-mvp": async (n) => {
29346
29358
  $("fwh-navigate-mvp ▶ raw parameters:", n);
29347
- let i = tk(n), a = nk(i);
29359
+ let i = nk(n), a = rk(i);
29348
29360
  if ($("fwh-navigate-mvp · coerced:", {
29349
29361
  url: a,
29350
29362
  sectionText: i.section_text ?? i.sectionText ?? i.section,
@@ -29410,8 +29422,8 @@ function ok(e) {
29410
29422
  typeof window < "u" && window.scrollTo(0, 0);
29411
29423
  } catch {}
29412
29424
  let s = [], c = null, l = "", u = Date.now() + 12e3;
29413
- for (; Date.now() < u && (await new Promise((e) => setTimeout(e, 300)), {headings: s, pageTitleHeading: c, introText: l} = ik(), !(s.length >= 1)););
29414
- rk(), $("fwh-navigate-mvp → page headings collected:", s, "titleHeading:", c);
29425
+ for (; Date.now() < u && (await new Promise((e) => setTimeout(e, 300)), {headings: s, pageTitleHeading: c, introText: l} = ak(), !(s.length >= 1)););
29426
+ ik(), $("fwh-navigate-mvp → page headings collected:", s, "titleHeading:", c);
29415
29427
  let d = s.length ? s.join(" | ") : "none", f = s.length ? "Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate." : "No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.", p = c ? ` "${c}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${l || "(no intro text found)"}"` : l ? ` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${l}"` : "", m = "";
29416
29428
  try {
29417
29429
  if (s.length > 0) {
@@ -29419,7 +29431,7 @@ function ok(e) {
29419
29431
  for (let n of e) {
29420
29432
  let e = br(null, n);
29421
29433
  if (e) {
29422
- let r = ak(e).substring(0, 800);
29434
+ let r = ok(e).substring(0, 800);
29423
29435
  r && t.push(`[Section: ${n}] ${r}`);
29424
29436
  }
29425
29437
  }
@@ -29447,34 +29459,34 @@ function ok(e) {
29447
29459
  },
29448
29460
  "fwh-highlight-mvp": async (e) => {
29449
29461
  $("fwh-highlight-mvp ▶", e);
29450
- let t = tk(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
29462
+ let t = nk(e), n = t?.section_id || t?.sectionId, r = t?.section_text || t?.sectionText;
29451
29463
  if (typeof window < "u" && window.__fe_user_nav_during_speech) {
29452
29464
  let e = window.__fe_user_nav_during_speech, t = window.location.pathname;
29453
29465
  if (Date.now() - e.ts >= 3e4) window.__fe_user_nav_during_speech = null;
29454
29466
  else return $("flowengage_highlight ✖ blocked — user navigated during speech", e), `NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call flowengage_highlight again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`;
29455
29467
  }
29456
- rk();
29468
+ ik();
29457
29469
  let i = ((e) => e && e.replace(/^\d+\.\s*/, "").replace(/^["']|["']$/g, "").trim())(r), a = br(n || null, i || null);
29458
29470
  if (!a && i) {
29459
29471
  let e = Date.now() + 600;
29460
- for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), rk(), a = br(null, i);
29472
+ for (; !a && Date.now() < e;) await new Promise((e) => setTimeout(e, 50)), ik(), a = br(null, i);
29461
29473
  }
29462
29474
  if (!a) {
29463
29475
  $("fwh-highlight-mvp ✖ no element for:", i || n);
29464
- let { headings: e } = ik(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
29476
+ let { headings: e } = ak(), t = e.length ? `Page headings: ${e.map((e) => `"${e}"`).join(" | ")}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.` : "No headings found — skip highlight and continue speaking.";
29465
29477
  return `HIGHLIGHT_NOT_FOUND: "${i || n}" on the current page. ${t}`;
29466
29478
  }
29467
29479
  return Rn(a), $("fwh-highlight-mvp ✓", i || n), `OK_HIGHLIGHT: "${i || n}". WALKTHROUGH: continue immediately to the next section — do NOT pause between sections.`;
29468
29480
  },
29469
29481
  "fwh-read-content-mvp": async (e) => {
29470
29482
  $("fwh-read-content-mvp ▶", e);
29471
- let t = tk(e), n = t?.section_text || t?.sectionText || "";
29483
+ let t = nk(e), n = t?.section_text || t?.sectionText || "";
29472
29484
  try {
29473
29485
  let e = "";
29474
29486
  if (n) {
29475
29487
  let t = br(null, n);
29476
29488
  if (!t) return `Could not find section "${n}" on the page.`;
29477
- e = ak(t);
29489
+ e = ok(t);
29478
29490
  } else {
29479
29491
  let t = (document.querySelector("main") || document.querySelector("article") || document.querySelector("[role=\"main\"]") || document.querySelector("#content") || document.querySelector(".content") || document.body).cloneNode(!0);
29480
29492
  t.querySelectorAll("nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar, #flowengage-root, .flowengage-shell, .flowengage-widget-root").forEach((e) => e.remove()), e = t.textContent.replace(/\s+/g, " ").trim();
@@ -29486,7 +29498,7 @@ function ok(e) {
29486
29498
  },
29487
29499
  "fwh-page-content-mvp": async (e) => {
29488
29500
  $("fwh-page-content-mvp ▶", e);
29489
- let r = tk(e), i = r?.url || r?.page_url || "";
29501
+ let r = nk(e), i = r?.url || r?.page_url || "";
29490
29502
  if ($("fwh-page-content-mvp · url:", i, "siteId:", t, "apiBase:", n || "(empty)"), !i) return $("fwh-page-content-mvp ✖ missing url"), "Missing url parameter.";
29491
29503
  if (!t) return $("fwh-page-content-mvp ✖ no siteId"), "Site is not configured.";
29492
29504
  if (!n) return $("fwh-page-content-mvp ✖ no api base"), "API base URL is missing; cannot fetch page content.";
@@ -29518,7 +29530,7 @@ function ok(e) {
29518
29530
  },
29519
29531
  "fwh-search-mvp": async (e) => {
29520
29532
  $("fwh-search-mvp ▶", e);
29521
- let r = tk(e).query;
29533
+ let r = nk(e).query;
29522
29534
  if (!r) return $("fwh-search-mvp ✖ missing query"), "Missing query parameter.";
29523
29535
  if (!t) return $("fwh-search-mvp ✖ no siteId"), "Search unavailable (no siteId configured).";
29524
29536
  if (!n) return $("fwh-search-mvp ✖ no api base"), "Search unavailable (no API base URL).";
@@ -29597,7 +29609,7 @@ function ok(e) {
29597
29609
  "fwh-request-email-mvp": async () => ($("fwh-request-email-mvp ▶"), typeof e.requestEmailCollection == "function" && e.requestEmailCollection(), "EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: \"Please enter your email in the text box to continue.\" Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message."),
29598
29610
  "fwh-get-current-page-mvp": async () => {
29599
29611
  if ($("fwh-get-current-page-mvp ▶"), typeof window > "u") return "Cannot determine current page (no browser context).";
29600
- let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = ik();
29612
+ let e = window.location.href, t = window.location.pathname, n = document.title || "", { headings: r, pageTitleHeading: i, introText: a } = ak();
29601
29613
  $("fwh-get-current-page-mvp ✓", {
29602
29614
  url: e,
29603
29615
  path: t,
@@ -29623,22 +29635,22 @@ function ok(e) {
29623
29635
  },
29624
29636
  "fwh-fill-form-mvp": async () => "FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.",
29625
29637
  "fwh-click-button-mvp": async (e) => {
29626
- let t = tk(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim();
29627
- if ($("fwh-click-button-mvp ▶", n), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
29628
- let r = ek(n, i);
29629
- if (!r) return $("fwh-click-button-mvp ✖ no match"), `Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;
29638
+ let t = nk(e), n = (t.button_text ?? t.buttonText ?? t.text ?? "").trim(), r = (t.card_context ?? t.cardContext ?? "").trim();
29639
+ if ($("fwh-click-button-mvp ▶", n, r ? `(card_context: ${r})` : ""), !n) return "Missing button_text: pass the visible label, e.g. Conduct Audit.";
29640
+ let a = tk(n, i, r);
29641
+ if (!a) return $("fwh-click-button-mvp ✖ no match"), `Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;
29630
29642
  try {
29631
29643
  kO(`Clicking ${n}...`, { spinner: !0 });
29632
29644
  try {
29633
- r.scrollIntoView({
29645
+ a.scrollIntoView({
29634
29646
  block: "center",
29635
29647
  inline: "nearest"
29636
29648
  });
29637
29649
  } catch {
29638
- r.scrollIntoView(!0);
29650
+ a.scrollIntoView(!0);
29639
29651
  }
29640
- await BO(r), r.focus?.(), await HO(r), UO(r), r.click();
29641
- let e = (r.textContent || r.value || r.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
29652
+ await BO(a), a.focus?.(), await HO(a), UO(a), a.click();
29653
+ let e = (a.textContent || a.value || a.getAttribute("aria-label") || "").trim().slice(0, 80) || "button", t = `OK_CLICK ${e}`;
29642
29654
  return $("fwh-click-button-mvp ✓", t), kO(`Clicked ${e}`, {
29643
29655
  spinner: !1,
29644
29656
  icon: "✅",
@@ -29668,7 +29680,7 @@ function ok(e) {
29668
29680
  }
29669
29681
  //#endregion
29670
29682
  //#region src/utils/wrapVoiceToolsForLogging.js
29671
- function sk(e) {
29683
+ function ck(e) {
29672
29684
  return !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, async (n) => {
29673
29685
  let r = Fn();
29674
29686
  r ? console.log("[FlowEngage:voice-tool] ▶", e, n) : console.info(`[FlowEngage] voice tool » ${e}`);
@@ -29685,7 +29697,7 @@ function sk(e) {
29685
29697
  }
29686
29698
  //#endregion
29687
29699
  //#region src/components/FlowEngageWidget.jsx
29688
- var ck = {
29700
+ var lk = {
29689
29701
  blue: "#135bd8",
29690
29702
  red: "#ef334b",
29691
29703
  yellow: "#ffbd2e",
@@ -29693,7 +29705,7 @@ var ck = {
29693
29705
  highlight: "rgba(255,255,255,0.9)",
29694
29706
  green: "#10b981"
29695
29707
  };
29696
- function lk(e) {
29708
+ function uk(e) {
29697
29709
  if (!Array.isArray(e) || e.length < 2) return "linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa";
29698
29710
  let [t, n, r] = e;
29699
29711
  return e.length >= 3 && r ? [
@@ -29707,12 +29719,12 @@ function lk(e) {
29707
29719
  "#f7f8fa"
29708
29720
  ].join(", ");
29709
29721
  }
29710
- function uk(e) {
29722
+ function dk(e) {
29711
29723
  if (!e || typeof e != "string") return "#1a1a1a";
29712
29724
  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;
29713
29725
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
29714
29726
  }
29715
- function dk(t) {
29727
+ function fk(t) {
29716
29728
  let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
29717
29729
  return e.useEffect(() => {
29718
29730
  if (!i) {
@@ -29730,8 +29742,8 @@ function dk(t) {
29730
29742
  };
29731
29743
  }, [i]), n;
29732
29744
  }
29733
- function fk({ logo: t, style: n }) {
29734
- let r = dk(typeof t == "string" ? t : null);
29745
+ function pk({ logo: t, style: n }) {
29746
+ let r = fk(typeof t == "string" ? t : null);
29735
29747
  if (!t) return null;
29736
29748
  if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
29737
29749
  src: r,
@@ -29756,7 +29768,7 @@ function fk({ logo: t, style: n }) {
29756
29768
  children: i
29757
29769
  }) : null;
29758
29770
  }
29759
- function pk({ title: e }) {
29771
+ function mk({ title: e }) {
29760
29772
  return /* @__PURE__ */ g("div", {
29761
29773
  style: {
29762
29774
  width: "100%",
@@ -29774,18 +29786,18 @@ function pk({ title: e }) {
29774
29786
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
29775
29787
  });
29776
29788
  }
29777
- function mk(e, t) {
29789
+ function hk(e, t) {
29778
29790
  let n = (t || "").trim();
29779
29791
  return n ? !!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n) || /\b(hang\s+up|disconnect)\b/i.test(n) || e === "bot" && (/\b(that'?s all|we'?re done)\b/i.test(n) || /\b(goodbye|bye)\b/i.test(n) || /\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n) || /\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n) || /\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n) || /\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n) || /\b(wrapping\s+up|signing\s+off)\b/i.test(n))) : !1;
29780
29792
  }
29781
- function hk({ orbColors: e, ...t }) {
29793
+ function gk({ orbColors: e, ...t }) {
29782
29794
  return /* @__PURE__ */ g(hO, {
29783
29795
  colors: e,
29784
29796
  ...t
29785
29797
  });
29786
29798
  }
29787
- function gk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
29788
- let s = n || ck.green, c = uk(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
29799
+ function _k({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
29800
+ let s = n || lk.green, c = dk(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
29789
29801
  style: {
29790
29802
  display: "flex",
29791
29803
  alignItems: a ? "flex-end" : "center",
@@ -29911,7 +29923,7 @@ function gk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29911
29923
  delay: 0
29912
29924
  },
29913
29925
  style: { flexShrink: 0 },
29914
- children: /* @__PURE__ */ g(hk, {
29926
+ children: /* @__PURE__ */ g(gk, {
29915
29927
  size: l,
29916
29928
  orbColors: t
29917
29929
  })
@@ -29943,8 +29955,8 @@ function gk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29943
29955
  children: u
29944
29956
  })] });
29945
29957
  }
29946
- function _k({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
29947
- let c = n || ck.green, l = uk(c);
29958
+ function vk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
29959
+ let c = n || lk.green, l = dk(c);
29948
29960
  return /* @__PURE__ */ _(Pm.div, {
29949
29961
  initial: {
29950
29962
  scale: 50 / 350,
@@ -30015,7 +30027,7 @@ function _k({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
30015
30027
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
30016
30028
  })
30017
30029
  }),
30018
- /* @__PURE__ */ g(hk, {
30030
+ /* @__PURE__ */ g(gk, {
30019
30031
  size: 72,
30020
30032
  orbColors: t
30021
30033
  }),
@@ -30095,7 +30107,7 @@ function _k({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
30095
30107
  ]
30096
30108
  });
30097
30109
  }
30098
- function vk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", enterChatModeLabel: S = "Enter Chat Mode", endConversationLabel: C = "End Conversation" }) {
30110
+ function yk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d, websiteName: f, voiceFirstMessage: h, captureVisitorEmail: v, emailRequired: y, emailCaptureEnabled: b = !0, listeningLabel: x = "Listening...", enterChatModeLabel: S = "Enter Chat Mode", endConversationLabel: C = "End Conversation" }) {
30099
30111
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
30100
30112
  let [w, T] = m("idle"), [E, ee] = m(!1), [te, ne] = m(!1), [re, ie] = m(!1), [ae, oe] = m(""), [D, se] = m(""), ce = p(!1), le = p(!1), ue = p(null), de = p(0), fe = p(""), O = p(null), pe = p(""), me = p(async () => {}), he = p(!1), ge = p(!1), _e = p(!1), ve = p(!1), ye = p("minimized"), be = p(null), xe = p(null), Se = p(null), Ce = p(0), we = p(!1), Te = p("idle"), Ee = p(!1), De = p(!1), Oe = p(null), A = p(null), Me = p(!1), Ne = o((e = "minimized") => {
30101
30113
  console.warn("[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called", {
@@ -30194,7 +30206,7 @@ function vk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30194
30206
  }
30195
30207
  je();
30196
30208
  } });
30197
- let t = sk(ok({
30209
+ let t = ck(sk({
30198
30210
  siteId: i || null,
30199
30211
  apiBaseUrl: a || null,
30200
30212
  chatId: s || null,
@@ -30305,7 +30317,7 @@ function vk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30305
30317
  let e = wO(l.current);
30306
30318
  e && k(i, e);
30307
30319
  } catch {}
30308
- if (mk(n, r)) {
30320
+ if (hk(n, r)) {
30309
30321
  we.current = !0;
30310
30322
  return;
30311
30323
  }
@@ -30361,7 +30373,7 @@ function vk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30361
30373
  n.length || (n = Array.from(document.body.querySelectorAll("h1, h2, h3")).filter((t) => !t.closest(e)).map((e) => e.textContent.replace(/\s+/g, " ").trim()).filter((e) => e.length > 2 && e.length < 200)), n.length && (a = [...new Set(n)].slice(0, 15).join(" | "));
30362
30374
  } catch {}
30363
30375
  let o = u && !m ? `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` : "";
30364
- Pe.sendContextualUpdate(`${o}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${a}. SiteId: ${i || "unknown"}. Forms: ${r}. The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
30376
+ Pe.sendContextualUpdate(`${o}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${a}. SiteId: ${i || "unknown"}. Forms: ${r}. ${y ? "" : "Visitor's email is already on file from a prior session — do NOT ask for it again. "}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`);
30365
30377
  } catch {}
30366
30378
  if (typeof window < "u") {
30367
30379
  let t = window.location.pathname, n = () => {
@@ -30602,7 +30614,7 @@ function vk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30602
30614
  },
30603
30615
  children: "Muted"
30604
30616
  }),
30605
- /* @__PURE__ */ g(hk, {
30617
+ /* @__PURE__ */ g(gk, {
30606
30618
  size: 72,
30607
30619
  voiceState: w,
30608
30620
  isMuted: E,
@@ -30826,7 +30838,7 @@ function vk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30826
30838
  ]
30827
30839
  });
30828
30840
  }
30829
- function yk({ orbColors: e }) {
30841
+ function bk({ orbColors: e }) {
30830
30842
  let t = Array.isArray(e) && e.length > 0 ? e : [
30831
30843
  "#135bd8",
30832
30844
  "#ef334b",
@@ -30845,7 +30857,7 @@ function yk({ orbColors: e }) {
30845
30857
  `.replace(/\s+/g, " ").trim()
30846
30858
  } });
30847
30859
  }
30848
- var bk = () => /* @__PURE__ */ g("div", {
30860
+ var xk = () => /* @__PURE__ */ g("div", {
30849
30861
  style: {
30850
30862
  display: "flex",
30851
30863
  marginBottom: "12px",
@@ -30875,7 +30887,7 @@ var bk = () => /* @__PURE__ */ g("div", {
30875
30887
  } }, e))
30876
30888
  })
30877
30889
  });
30878
- function xk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: O, setMicError: pe, dismissCallError: me, activeCallId: he, isCallMuted: ge, toggleCallMute: _e, endWebRTCCall: ve, formatCallDuration: ye, callDurationSeconds: be, isCallMinimized: xe, onExpand: Se, onCollapse: Ce, onStartVoice: we, voiceEnabled: Te, headerBgColor: Ee, onNewChat: De, showPoweredBy: Oe, privacyPolicyUrl: k, getVisitorChatHistory: ke, resumeChat: Ae, isSessionRestoring: A, isClosing: je }) {
30890
+ function Sk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: E, rateLimitMessage: ee, selectedFile: te, onFileSelect: ne, onRemoveSelectedFile: re, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: O, setMicError: pe, dismissCallError: me, activeCallId: he, isCallMuted: ge, toggleCallMute: _e, endWebRTCCall: ve, formatCallDuration: ye, callDurationSeconds: be, isCallMinimized: xe, onExpand: Se, onCollapse: Ce, onStartVoice: we, voiceEnabled: Te, headerBgColor: Ee, onNewChat: De, showPoweredBy: Oe, privacyPolicyUrl: k, getVisitorChatHistory: ke, resumeChat: Ae, isSessionRestoring: A, isClosing: je }) {
30879
30891
  let Me = l.length > 0, Ne = T || E || w, Pe = !!he, [Fe, Ie] = m(!1), [Le, Re] = m(!1), [ze, Be] = m([]), [Ve, He] = m(!1), Ue = p(null), [We, j] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [Ge, Ke] = m(0);
30880
30892
  c(() => {
30881
30893
  if (!s) return;
@@ -31015,7 +31027,7 @@ function xk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31015
31027
  justifyContent: "center",
31016
31028
  height: "40px"
31017
31029
  },
31018
- children: i ? /* @__PURE__ */ g(fk, {
31030
+ children: i ? /* @__PURE__ */ g(pk, {
31019
31031
  logo: i,
31020
31032
  style: {
31021
31033
  height: "34px",
@@ -31028,7 +31040,7 @@ function xk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31028
31040
  height: "40px",
31029
31041
  flexShrink: 0
31030
31042
  },
31031
- children: /* @__PURE__ */ g(pk, { title: e.chatTitle })
31043
+ children: /* @__PURE__ */ g(mk, { title: e.chatTitle })
31032
31044
  })
31033
31045
  }), o && /* @__PURE__ */ g("div", {
31034
31046
  style: {
@@ -31459,11 +31471,11 @@ function xk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31459
31471
  isLoading: T,
31460
31472
  isAgentTyping: d,
31461
31473
  setReplyContext: de,
31462
- TypingDots: bk,
31474
+ TypingDots: xk,
31463
31475
  primaryColor: n,
31464
31476
  agentHeadshot: y,
31465
31477
  agentDisplayName: v || b,
31466
- botAvatarNode: /* @__PURE__ */ g(yk, { orbColors: t })
31478
+ botAvatarNode: /* @__PURE__ */ g(bk, { orbColors: t })
31467
31479
  }) : A ? /* @__PURE__ */ _("div", {
31468
31480
  style: {
31469
31481
  flex: 1,
@@ -31504,7 +31516,7 @@ function xk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31504
31516
  padding: "28px 24px"
31505
31517
  },
31506
31518
  children: [
31507
- /* @__PURE__ */ g(hk, {
31519
+ /* @__PURE__ */ g(gk, {
31508
31520
  size: 94,
31509
31521
  orbColors: t
31510
31522
  }),
@@ -31669,7 +31681,7 @@ function xk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31669
31681
  ]
31670
31682
  });
31671
31683
  }
31672
- function Sk() {
31684
+ function Ck() {
31673
31685
  let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: E, callConnectedAt: ee, isCallMuted: te, webRTCError: ne, language: re, chatId: ie, historyRef: ae, onMessageSync: oe, sendMessage: D, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: pe, acceptCall: me, rejectCall: he, endWebRTCCall: ge, toggleCallMute: _e, dismissCallError: ve, startTyping: ye, stopTyping: be, updateTypingDraft: xe, getVisitorChatHistory: Se, resumeChat: Ce, isSessionRestoring: we, openToChatCounter: Te, voiceEndCounter: Ee } = Pn();
31674
31686
  c(() => {
31675
31687
  try {
@@ -31691,7 +31703,7 @@ function Sk() {
31691
31703
  small: 50,
31692
31704
  medium: 64,
31693
31705
  large: 80
31694
- }, Re = Le[A.orbSize] || Le.small, ze = A.position || "bottom-right", Be = k.fallbackAgentName || "Agent", Ve = lk(Pe ?? A.chatBgColors), He = k.logo || k.logoUrl || null, Ue = re || "en", We = De.recommendations?.[Ue] || [], j = (Oe.recommendations?.[Ue] ?? We).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31706
+ }, Re = Le[A.orbSize] || Le.small, ze = A.position || "bottom-right", Be = k.fallbackAgentName || "Agent", Ve = uk(Pe ?? A.chatBgColors), He = k.logo || k.logoUrl || null, Ue = re || "en", We = De.recommendations?.[Ue] || [], j = (Oe.recommendations?.[Ue] ?? We).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31695
31707
  id: e.key || `qr-${t}`,
31696
31708
  label: e.label,
31697
31709
  message: e.label,
@@ -31981,7 +31993,7 @@ function Sk() {
31981
31993
  onWheel: (e) => e.stopPropagation(),
31982
31994
  onTouchMove: (e) => e.stopPropagation(),
31983
31995
  children: [
31984
- P === "entry_prompt" && /* @__PURE__ */ g(gk, {
31996
+ P === "entry_prompt" && /* @__PURE__ */ g(_k, {
31985
31997
  copy: nt,
31986
31998
  orbColors: Pe,
31987
31999
  primaryColor: Ie,
@@ -32064,13 +32076,13 @@ function Sk() {
32064
32076
  children: E === "connected" ? `${Kt(bt)} with ${it}` : `Tap to return to ${it}`
32065
32077
  })]
32066
32078
  })]
32067
- }), /* @__PURE__ */ g(hk, {
32079
+ }), /* @__PURE__ */ g(gk, {
32068
32080
  size: Re,
32069
32081
  orbColors: Pe,
32070
32082
  onClick: T ? Vt : Ne ? Xt : Qt
32071
32083
  })]
32072
32084
  }),
32073
- P === "connection_modal" && /* @__PURE__ */ g(_k, {
32085
+ P === "connection_modal" && /* @__PURE__ */ g(vk, {
32074
32086
  copy: nt,
32075
32087
  orbColors: Pe,
32076
32088
  primaryColor: Ie,
@@ -32080,7 +32092,7 @@ function Sk() {
32080
32092
  isMobile: Lt,
32081
32093
  isClosing: Mt
32082
32094
  }),
32083
- P === "voice_mode" && /* @__PURE__ */ g(vk, {
32095
+ P === "voice_mode" && /* @__PURE__ */ g(yk, {
32084
32096
  orbColors: Pe,
32085
32097
  onEnterChat: Qt,
32086
32098
  onEndChat: $t,
@@ -32119,7 +32131,7 @@ function Sk() {
32119
32131
  orbColors: Pe,
32120
32132
  chatHistory: r
32121
32133
  }),
32122
- P === "text_chat" && /* @__PURE__ */ g(xk, {
32134
+ P === "text_chat" && /* @__PURE__ */ g(Sk, {
32123
32135
  isClosing: Mt,
32124
32136
  copy: nt,
32125
32137
  orbColors: Pe,
@@ -32185,7 +32197,7 @@ function Sk() {
32185
32197
  }
32186
32198
  //#endregion
32187
32199
  //#region src/components/ErrorBoundary.jsx
32188
- var Ck = class extends e.Component {
32200
+ var wk = class extends e.Component {
32189
32201
  constructor(e) {
32190
32202
  super(e), this.state = { hasError: !1 };
32191
32203
  }
@@ -32200,4 +32212,4 @@ var Ck = class extends e.Component {
32200
32212
  }
32201
32213
  };
32202
32214
  //#endregion
32203
- export { hO as AnimatedOrb, Ck as ErrorBoundary, Wr as FlowEngageProvider, Sk as FlowEngageWidget, Pn as useFlowEngage };
32215
+ export { hO as AnimatedOrb, wk as ErrorBoundary, Wr as FlowEngageProvider, Ck as FlowEngageWidget, Pn as useFlowEngage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "8.0.33",
3
+ "version": "8.0.34",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",