@flowengage/react-chatbot 6.0.14 → 6.0.16

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.
@@ -506,7 +506,7 @@ var k = (e) => {
506
506
  let l = new ArrayBuffer(t), u = new Uint8Array(l);
507
507
  for (r = 0; r < n; r += 4) a = at[e.charCodeAt(r)], o = at[e.charCodeAt(r + 1)], s = at[e.charCodeAt(r + 2)], c = at[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
508
508
  return l;
509
- }, A = typeof ArrayBuffer == "function", ot = (e, t) => {
509
+ }, ot = typeof ArrayBuffer == "function", A = (e, t) => {
510
510
  if (typeof e != "string") return {
511
511
  type: "message",
512
512
  data: ct(e, t)
@@ -519,7 +519,7 @@ var k = (e) => {
519
519
  type: Je[n],
520
520
  data: e.substring(1)
521
521
  } : { type: Je[n] } : Ye;
522
- }, st = (e, t) => A ? ct(k(e), t) : {
522
+ }, st = (e, t) => ot ? ct(k(e), t) : {
523
523
  base64: !0,
524
524
  data: e
525
525
  }, ct = (e, t) => {
@@ -537,7 +537,7 @@ var k = (e) => {
537
537
  }, dt = (e, t) => {
538
538
  let n = e.split(lt), r = [];
539
539
  for (let e = 0; e < n.length; e++) {
540
- let i = ot(n[e], t);
540
+ let i = A(n[e], t);
541
541
  if (r.push(i), i.type === "error") break;
542
542
  }
543
543
  return r;
@@ -594,7 +594,7 @@ function gt(e, t) {
594
594
  } else {
595
595
  if (mt(n) < i) break;
596
596
  let e = ht(n, i);
597
- s.enqueue(ot(a ? e : pt.decode(e), t)), r = 0;
597
+ s.enqueue(A(a ? e : pt.decode(e), t)), r = 0;
598
598
  }
599
599
  if (i === 0 || i > e) {
600
600
  s.enqueue(Ye);
@@ -707,7 +707,7 @@ var jt = class extends Error {
707
707
  this.readyState = "open", this.writable = !0, super.emitReserved("open");
708
708
  }
709
709
  onData(e) {
710
- let t = ot(e, this.socket.binaryType);
710
+ let t = A(e, this.socket.binaryType);
711
711
  this.onPacket(t);
712
712
  }
713
713
  onPacket(e) {
@@ -2836,7 +2836,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2836
2836
  let i = f(() => e ? {
2837
2837
  ...t || {},
2838
2838
  siteId: e
2839
- } : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, Re] = m(0), [ze, Be] = m(0), [Ve, He] = m(!1), [O, Ue] = m(null), [qe, Je] = m(null), [Ye, Xe] = m("idle"), [Ze, Qe] = m(null), [$e, et] = m(!1), [tt, nt] = m(""), [rt, it] = m(!1), at = p(null), k = p(null), A = p(""), ot = p(!1), st = p(null), ct = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(null), pt = p([]), mt = p(null), ht = p(null), gt = p(null), j = p(!1), _t = p(!1), vt = p(""), yt = p(null), bt = p(null), xt = p([]), St = p(0), Ct = p(E), wt = p([]), Tt = p(!1), Et = p(!1), Dt = p(i), Ot = p({
2839
+ } : t || null, [e, t]), [a, s] = m(0), [l, u] = m("booting"), [d, h] = m(null), [_, v] = m(null), [y, b] = m(""), [x, S] = m([]), [C, w] = m(ve().isOpen), [T, te] = m(ve().activeScreen), [ne, re] = m(ve().isHumanHandled), [E, D] = m(ve().agentName), [se, de] = m(ve().agentHeadshot), [fe, pe] = m(() => be(i?.siteId)), [me, Se] = m(!1), [Ce, we] = m(!1), [Ee, De] = m("idle"), [Oe, ke] = m(!1), [Ae, je] = m(!1), [Me, Ne] = m(""), [Fe, Ie] = m(!1), [Le, Re] = m(0), [ze, Be] = m(0), [Ve, He] = m(!1), [O, Ue] = m(null), [qe, Je] = m(null), [Ye, Xe] = m("idle"), [Ze, Qe] = m(null), [$e, et] = m(!1), [tt, nt] = m(""), [rt, it] = m(!1), at = p(null), k = p(null), ot = p(""), A = p(!1), st = p(null), ct = p(null), lt = p(null), ut = p(null), dt = p(null), ft = p(null), pt = p([]), mt = p(null), ht = p(null), gt = p(null), j = p(!1), _t = p(!1), vt = p(""), yt = p(null), bt = p(null), xt = p([]), St = p(0), Ct = p(E), wt = p([]), Tt = p(!1), Et = p(!1), Dt = p(i), Ot = p({
2840
2840
  notifyRouteChange: () => {},
2841
2841
  cleanup: () => {}
2842
2842
  }), kt = o((e = {}) => {
@@ -2901,7 +2901,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2901
2901
  if (!(!t?.connected || !n || j.current)) {
2902
2902
  j.current = !0, t.emit("call:connected", {
2903
2903
  callId: n,
2904
- chatId: A.current,
2904
+ chatId: ot.current,
2905
2905
  connectedAt: e
2906
2906
  });
2907
2907
  try {
@@ -2968,7 +2968,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2968
2968
  if (!t || !n?.connected || !r || !e.callId) {
2969
2969
  console.log("[FlowEngageProvider] deferring remote offer until peer/socket ready", {
2970
2970
  callId: e.callId,
2971
- chatId: A.current,
2971
+ chatId: ot.current,
2972
2972
  hasPeerConnection: !!t,
2973
2973
  socketConnected: !!n?.connected,
2974
2974
  hasOffer: !!r
@@ -2981,7 +2981,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2981
2981
  })), pt.current.length > 0) {
2982
2982
  console.log("[FlowEngageProvider] flushing queued agent ICE candidates after remote offer", {
2983
2983
  callId: e.callId,
2984
- chatId: A.current,
2984
+ chatId: ot.current,
2985
2985
  queuedCount: pt.current.length
2986
2986
  });
2987
2987
  for (let e of pt.current) await t.addIceCandidate(new RTCIceCandidate(e));
@@ -2991,7 +2991,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
2991
2991
  await t.setLocalDescription(i), n.emit("call:answer", {
2992
2992
  callId: e.callId,
2993
2993
  sdpAnswer: i.sdp,
2994
- chatId: A.current
2994
+ chatId: ot.current
2995
2995
  });
2996
2996
  };
2997
2997
  c(() => {
@@ -3017,8 +3017,8 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3017
3017
  if (!e) return;
3018
3018
  let a = t.siteId, o = he(a), s = Te(a), c = "";
3019
3019
  try {
3020
- let e = ot.current, r = st.current;
3021
- if (ot.current = !1, st.current = null, c = (await We({
3020
+ let e = A.current, r = st.current;
3021
+ if (A.current = !1, st.current = null, c = (await We({
3022
3022
  apiBaseUrl: t.apiBaseUrl,
3023
3023
  userId: n.userId,
3024
3024
  siteId: a,
@@ -3031,7 +3031,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3031
3031
  } catch (e) {
3032
3032
  console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ue(), _e(a, c);
3033
3033
  }
3034
- A.current = c;
3034
+ ot.current = c;
3035
3035
  let l = Ke({
3036
3036
  apiBaseUrl: t.apiBaseUrl,
3037
3037
  userId: n.userId,
@@ -3177,7 +3177,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3177
3177
  if (!lt.current || !lt.current.remoteDescription) {
3178
3178
  console.log("[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready", {
3179
3179
  callId: e.callId,
3180
- chatId: e.chatId || A.current,
3180
+ chatId: e.chatId || ot.current,
3181
3181
  queueSize: pt.current.length + 1
3182
3182
  }), pt.current.push(t);
3183
3183
  return;
@@ -3252,7 +3252,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3252
3252
  a
3253
3253
  ]), c(() => () => {
3254
3254
  if (Fe && !Tt.current && wt.current.length > 0) {
3255
- let e = A.current, t = wt.current, n = k.current;
3255
+ let e = ot.current, t = wt.current, n = k.current;
3256
3256
  n && e && t.length > 0 && (console.log("[FlowEngageProvider] safety-net: syncing voice transcript on unmount"), n.beaconSyncVoice(e, t) || n.syncVoice(e, t).catch(() => {}), Tt.current = !0);
3257
3257
  }
3258
3258
  }, [Fe, _]);
@@ -3262,7 +3262,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3262
3262
  !e || !y || zt.current !== C && (C && zt.current !== null ? (e.updateChatStatus(y, "open").catch(() => {}), Bt.current = !0) : zt.current === !0 && e.updateChatStatus(y, "widget_closed").catch(() => {}), zt.current = C);
3263
3263
  }, [C, y]), c(() => {
3264
3264
  let e = () => {
3265
- let e = A.current, t = k.current;
3265
+ let e = ot.current, t = k.current;
3266
3266
  !e || !t || typeof navigator > "u" || t.beaconWidgetClosed?.(e) || t.updateChatStatus(e, "widget_closed").catch(() => {});
3267
3267
  };
3268
3268
  return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
@@ -3305,6 +3305,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3305
3305
  Xe((e) => e === "connected" ? e : "connecting");
3306
3306
  return;
3307
3307
  }
3308
+ (e === "failed" || e === "closed") && Pt(`peer:connection_${e}`);
3308
3309
  }, n.oniceconnectionstatechange = () => {
3309
3310
  let e = n.iceConnectionState;
3310
3311
  if (e === "connected" || e === "completed") {
@@ -3316,6 +3317,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3316
3317
  Xe((e) => e === "connected" ? e : "connecting");
3317
3318
  return;
3318
3319
  }
3320
+ (e === "failed" || e === "closed") && Pt(`peer:ice_${e}`);
3319
3321
  }, n.onsignalingstatechange = () => {}, n.onicegatheringstatechange = () => {}, e.getTracks().forEach((t) => {
3320
3322
  n.addTrack(t, e);
3321
3323
  }), n.onicecandidate = (e) => {
@@ -3435,10 +3437,10 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3435
3437
  }
3436
3438
  }, qt = async (e) => {
3437
3439
  let t = Nt(e);
3438
- if (!t || !k.current || !A.current) return t;
3440
+ if (!t || !k.current || !ot.current) return t;
3439
3441
  try {
3440
3442
  await k.current.trackVisitor({
3441
- chatId: A.current,
3443
+ chatId: ot.current,
3442
3444
  currentPagePath: typeof window < "u" && window.location.pathname || "/",
3443
3445
  email: t
3444
3446
  });
@@ -3598,7 +3600,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3598
3600
  At
3599
3601
  ]), c(() => {
3600
3602
  let e = () => {
3601
- let e = A.current, t = k.current;
3603
+ let e = ot.current, t = k.current;
3602
3604
  if (!t || !e) return;
3603
3605
  if (Et.current && wt.current.length > 0 && Pe(), !Tt.current && wt.current.length > 0 && (t.beaconSyncVoice(e, wt.current) || t.syncVoice(e, wt.current).catch(() => {}), Tt.current = !0), mt.current) {
3604
3606
  t.beaconEndWebRTCCall(mt.current, e);
@@ -3613,9 +3615,9 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3613
3615
  }, []);
3614
3616
  let nn = o(() => {
3615
3617
  let e = i?.siteId;
3616
- ge(e), ot.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), A.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3618
+ ge(e), A.current = !0, st.current = null, at.current?.disconnect(), S([]), b(""), ot.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3617
3619
  }, [i?.siteId]), rn = o((e) => {
3618
- i?.siteId, ot.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), A.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3620
+ i?.siteId, A.current = !1, st.current = e, at.current?.disconnect(), S([]), b(""), ot.current = "", He(!1), re(!1), D(null), de(null), it(!0), s((e) => e + 1);
3619
3621
  }, [i?.siteId]), an = f(() => ({
3620
3622
  status: l,
3621
3623
  error: d,
@@ -26622,7 +26624,8 @@ function ZD({ src: e, name: t, imgStyle: n, initialsSpanStyle: r }) {
26622
26624
  }, [o]), i ? /* @__PURE__ */ g("img", {
26623
26625
  src: i,
26624
26626
  alt: "",
26625
- style: n
26627
+ style: n,
26628
+ onError: () => a(null)
26626
26629
  }) : /* @__PURE__ */ g("span", {
26627
26630
  style: r,
26628
26631
  children: XD(t)
@@ -29105,27 +29108,30 @@ function dk(e, t) {
29105
29108
  function fk(e, t) {
29106
29109
  let n = String(t || "").toLowerCase().trim();
29107
29110
  if (!n) return 0;
29108
- let r = [
29109
- e.textContent,
29111
+ let r = (e.innerText || e.textContent || "").replace(/\s+/g, " ").trim(), i = [
29112
+ r,
29110
29113
  e.value,
29111
29114
  e.getAttribute("aria-label"),
29112
- e.getAttribute("title")
29115
+ e.getAttribute("title"),
29116
+ e.getAttribute("data-text"),
29117
+ e.getAttribute("data-label")
29113
29118
  ].filter(Boolean).join(" ").toLowerCase().replace(/\s+/g, " ");
29114
- if (r.includes(n)) return 100;
29115
- let i = n.split(/\s+/).filter((e) => e.length > 1);
29116
- if (!i.length) return 0;
29117
- let a = 0;
29118
- for (let e of i) r.includes(e) && (a += 1);
29119
- return a / i.length * 92;
29119
+ if (i.includes(n) || r.toLowerCase() === n) return 100;
29120
+ let a = n.split(/\s+/).filter((e) => e.length > 1);
29121
+ if (!a.length) return 0;
29122
+ let o = 0;
29123
+ for (let e of a) i.includes(e) && (o += 1);
29124
+ return o / a.length * 92;
29120
29125
  }
29121
29126
  function pk(e, t) {
29122
29127
  let n = [];
29123
29128
  KO((e) => {
29124
- n.push(...Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"]")).filter((e) => {
29129
+ let t = Array.from(e.querySelectorAll("button, [role=\"button\"], input[type=\"submit\"], input[type=\"button\"], a[href]"));
29130
+ n.push(...t.filter((e) => {
29125
29131
  if (WO(e) || e.disabled) return !1;
29126
29132
  try {
29127
29133
  let t = GO(e);
29128
- if (t.display === "none" || t.visibility === "hidden") return !1;
29134
+ if (t.display === "none" || t.visibility === "hidden" || t.opacity === "0") return !1;
29129
29135
  } catch {}
29130
29136
  return !0;
29131
29137
  }));
@@ -29135,7 +29141,7 @@ function pk(e, t) {
29135
29141
  s: fk(t, e)
29136
29142
  }));
29137
29143
  for (let { s: e } of i) e > r && (r = e);
29138
- if (r < 36) return null;
29144
+ if (r < 28) return null;
29139
29145
  let a = i.filter(({ s: e }) => e === r).map(({ el: e }) => e);
29140
29146
  if (a.length === 1) return a[0];
29141
29147
  let o = Array.isArray(t) ? t.filter((e) => e && e.isConnected) : [];
@@ -29386,7 +29392,7 @@ function Ck(e) {
29386
29392
  for (; Date.now() < c && (await new Promise((e) => setTimeout(e, 250)), s = Sk(), !(s.length >= 1)););
29387
29393
  xk(), $("flowengage_navigate → page headings collected:", s);
29388
29394
  let l = s.length ? s.join(" | ") : "none", u = s.length ? "Use ONLY these exact heading strings for flowengage_highlight." : "No headings were collected from the live DOM — use your knowledge base heading strings for this page to call flowengage_highlight. Follow RULE 1: call each highlight BEFORE describing its section (transition → highlight → content).";
29389
- return i ? (wr(), `OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${l}. ${u} Do NOT say "I have navigated you" or "I've taken you to" — start immediately with highlights and content about THIS page.`) : (wr(), `OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${l}. ${u} Describe THIS page only — do not mention the page you tried to navigate to.`);
29395
+ return i ? (wr(), `OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${l}. ${u} MANDATORY: call flowengage_highlight for EVERY section before describing it — never give a plain summary. Do NOT say "I have navigated you" or "I've taken you to" — start the highlighted walkthrough immediately.`) : (wr(), `OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${l}. ${u} MANDATORY: call flowengage_highlight for EVERY section before describing it — never give a plain summary. Describe THIS page only — do not mention the page you tried to navigate to.`);
29390
29396
  } catch {}
29391
29397
  return "OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, immediately introduce the new page and continue guiding the visitor — do not wait for the user to speak first.";
29392
29398
  } catch (e) {
@@ -29653,10 +29659,29 @@ function Dk(e) {
29653
29659
  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;
29654
29660
  return .2126 * o(r) + .7152 * o(i) + .0722 * o(a) > .179 ? "#1a1a1a" : "#ffffff";
29655
29661
  }
29656
- function Ok({ logo: t, style: n }) {
29662
+ function Ok(t) {
29663
+ let [n, r] = e.useState(null), i = typeof t == "string" ? t.trim() : "";
29664
+ return e.useEffect(() => {
29665
+ if (!i) {
29666
+ r(null);
29667
+ return;
29668
+ }
29669
+ r(null);
29670
+ let e = !1, t = new window.Image();
29671
+ return t.onload = () => {
29672
+ e || r(i);
29673
+ }, t.onerror = () => {
29674
+ e || r(null);
29675
+ }, t.src = i, () => {
29676
+ e = !0;
29677
+ };
29678
+ }, [i]), n;
29679
+ }
29680
+ function kk({ logo: t, style: n }) {
29681
+ let r = Ok(typeof t == "string" ? t : null);
29657
29682
  if (!t) return null;
29658
- if (typeof t == "string") return /* @__PURE__ */ g("img", {
29659
- src: t,
29683
+ if (typeof t == "string") return r ? /* @__PURE__ */ g("img", {
29684
+ src: r,
29660
29685
  alt: "",
29661
29686
  style: {
29662
29687
  objectFit: "contain",
@@ -29664,9 +29689,9 @@ function Ok({ logo: t, style: n }) {
29664
29689
  display: "block",
29665
29690
  ...n
29666
29691
  }
29667
- });
29668
- let r = typeof t == "function" ? e.createElement(t) : e.isValidElement(t) ? t : null;
29669
- return r ? /* @__PURE__ */ g("span", {
29692
+ }) : null;
29693
+ let i = typeof t == "function" ? e.createElement(t) : e.isValidElement(t) ? t : null;
29694
+ return i ? /* @__PURE__ */ g("span", {
29670
29695
  className: "fe-logo-slot",
29671
29696
  style: {
29672
29697
  display: "inline-flex",
@@ -29675,10 +29700,10 @@ function Ok({ logo: t, style: n }) {
29675
29700
  overflow: "hidden",
29676
29701
  ...n
29677
29702
  },
29678
- children: r
29703
+ children: i
29679
29704
  }) : null;
29680
29705
  }
29681
- function kk({ title: e }) {
29706
+ function Ak({ title: e }) {
29682
29707
  return /* @__PURE__ */ g("div", {
29683
29708
  style: {
29684
29709
  width: "100%",
@@ -29696,17 +29721,17 @@ function kk({ title: e }) {
29696
29721
  children: String(e || "FE").split(/\s+/).filter(Boolean).slice(0, 2).map((e) => e[0]?.toUpperCase() || "").join("") || "FE"
29697
29722
  });
29698
29723
  }
29699
- function Ak(e, t) {
29724
+ function jk(e, t) {
29700
29725
  let n = (t || "").trim();
29701
29726
  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;
29702
29727
  }
29703
- function jk({ orbColors: e, ...t }) {
29728
+ function Mk({ orbColors: e, ...t }) {
29704
29729
  return /* @__PURE__ */ g(lO, {
29705
29730
  colors: e,
29706
29731
  ...t
29707
29732
  });
29708
29733
  }
29709
- function Mk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
29734
+ function Nk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMobile: a, isClosing: o }) {
29710
29735
  let s = n || Tk.green, c = Dk(s), l = a ? 72 : 94, u = /* @__PURE__ */ _("div", {
29711
29736
  style: {
29712
29737
  display: "flex",
@@ -29828,7 +29853,7 @@ function Mk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29828
29853
  delay: 0
29829
29854
  },
29830
29855
  style: { flexShrink: 0 },
29831
- children: /* @__PURE__ */ g(jk, {
29856
+ children: /* @__PURE__ */ g(Mk, {
29832
29857
  size: l,
29833
29858
  orbColors: t
29834
29859
  })
@@ -29860,7 +29885,7 @@ function Mk({ copy: e, orbColors: t, primaryColor: n, onYes: r, onLater: i, isMo
29860
29885
  children: u
29861
29886
  })] });
29862
29887
  }
29863
- function Nk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
29888
+ function Pk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onClose: a, isMobile: o, isClosing: s }) {
29864
29889
  let c = n || Tk.green, l = Dk(c);
29865
29890
  return /* @__PURE__ */ _(Dm.div, {
29866
29891
  initial: {
@@ -29932,7 +29957,7 @@ function Nk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
29932
29957
  children: /* @__PURE__ */ g("polyline", { points: "6 9 12 15 18 9" })
29933
29958
  })
29934
29959
  }),
29935
- /* @__PURE__ */ g(jk, {
29960
+ /* @__PURE__ */ g(Mk, {
29936
29961
  size: 72,
29937
29962
  orbColors: t
29938
29963
  }),
@@ -30001,7 +30026,7 @@ function Nk({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
30001
30026
  ]
30002
30027
  });
30003
30028
  }
30004
- function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d }) {
30029
+ function Fk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i, apiBaseUrl: a, chatId: s, historyRef: l, onMessageSync: u, voiceEndCounter: d }) {
30005
30030
  let [f, h] = m("idle"), [v, y] = m(!1), [b, x] = m(!1), S = p(null), C = p(""), w = p(async () => {}), T = p(!1), ee = p(!1), te = p(!1), ne = p(!1), re = p("minimized"), E = p(null), ie = p(null), ae = p(null), oe = p(0), D = p(!1), se = p("idle"), ce = p(!1), le = p(null), ue = p(null), de = p(!1), fe = o((e = "minimized") => {
30006
30031
  re.current = e, ne.current = !0, queueMicrotask(() => {
30007
30032
  T.current || (T.current = !0, w.current?.());
@@ -30104,6 +30129,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30104
30129
  let v = {
30105
30130
  clientTools: t,
30106
30131
  connectionType: "websocket",
30132
+ minSpeechDurationMs: 100,
30107
30133
  ..._ ? { signedUrl: _ } : { agentId: r }
30108
30134
  }, b = (p.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), x = "";
30109
30135
  m && m.includes("|") && (x = m.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
@@ -30152,7 +30178,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30152
30178
  let e = vO(l.current);
30153
30179
  e && Ae(i, e);
30154
30180
  } catch {}
30155
- if (Ak(n, r)) {
30181
+ if (jk(n, r)) {
30156
30182
  fe("minimized");
30157
30183
  return;
30158
30184
  }
@@ -30316,7 +30342,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30316
30342
  },
30317
30343
  children: "Muted"
30318
30344
  }),
30319
- /* @__PURE__ */ g(jk, {
30345
+ /* @__PURE__ */ g(Mk, {
30320
30346
  size: 72,
30321
30347
  voiceState: f,
30322
30348
  isMuted: v,
@@ -30554,7 +30580,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30554
30580
  ]
30555
30581
  });
30556
30582
  }
30557
- function Fk({ orbColors: e }) {
30583
+ function Ik({ orbColors: e }) {
30558
30584
  return /* @__PURE__ */ g("div", {
30559
30585
  style: {
30560
30586
  flexShrink: 0,
@@ -30564,13 +30590,13 @@ function Fk({ orbColors: e }) {
30564
30590
  alignItems: "center",
30565
30591
  justifyContent: "center"
30566
30592
  },
30567
- children: /* @__PURE__ */ g(jk, {
30593
+ children: /* @__PURE__ */ g(Mk, {
30568
30594
  size: 36,
30569
30595
  orbColors: e
30570
30596
  })
30571
30597
  });
30572
30598
  }
30573
- var Ik = () => /* @__PURE__ */ g("div", {
30599
+ var Lk = () => /* @__PURE__ */ g("div", {
30574
30600
  style: {
30575
30601
  display: "flex",
30576
30602
  marginBottom: "12px",
@@ -30600,7 +30626,7 @@ var Ik = () => /* @__PURE__ */ g("div", {
30600
30626
  } }, e))
30601
30627
  })
30602
30628
  });
30603
- function Lk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: E, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, activeCallId: ge, isCallMuted: _e, toggleCallMute: ve, endWebRTCCall: ye, formatCallDuration: be, callDurationSeconds: xe, isCallMinimized: Se, onExpand: Ce, onCollapse: we, onStartVoice: Te, onNewChat: Ee, showPoweredBy: De, getVisitorChatHistory: Oe, resumeChat: ke, isSessionRestoring: Ae, isClosing: je }) {
30629
+ function Rk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i, quickChatOptions: a, onQuickChatSelect: o, isMobile: s, chatHistory: l, isAiTyping: u, isAgentTyping: d, activeScreen: f, agentName: v, agentHeadshot: y, fallbackAgentName: b, input: x, setInput: S, onSubmit: C, isConversationEnded: w, isLoading: T, isRateLimited: ee, rateLimitMessage: te, selectedFile: ne, onFileSelect: re, onRemoveSelectedFile: E, attachmentError: ie, isUploadingAttachment: ae, requiresEmail: oe, emailInput: D, setEmailInput: se, emailError: ce, emailCaptureSuccess: le, replyContext: ue, setReplyContext: de, webRTCError: fe, micError: pe, setMicError: me, dismissCallError: he, activeCallId: ge, isCallMuted: _e, toggleCallMute: ve, endWebRTCCall: ye, formatCallDuration: be, callDurationSeconds: xe, isCallMinimized: Se, onExpand: Ce, onCollapse: we, onStartVoice: Te, onNewChat: Ee, showPoweredBy: De, getVisitorChatHistory: Oe, resumeChat: ke, isSessionRestoring: Ae, isClosing: je }) {
30604
30630
  let Me = l.length > 0, Ne = T || ee || w, Pe = !!ge, [Fe, Ie] = m(!1), [Le, Re] = m(!1), [ze, Be] = m([]), [Ve, He] = m(!1), O = p(null), Ue = async () => {
30605
30631
  Ie(!1), Re(!0), He(!0);
30606
30632
  try {
@@ -30725,7 +30751,7 @@ function Lk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30725
30751
  justifyContent: "center",
30726
30752
  height: "40px"
30727
30753
  },
30728
- children: i ? /* @__PURE__ */ g(Ok, {
30754
+ children: i ? /* @__PURE__ */ g(kk, {
30729
30755
  logo: i,
30730
30756
  style: {
30731
30757
  height: "34px",
@@ -30738,7 +30764,7 @@ function Lk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
30738
30764
  height: "40px",
30739
30765
  flexShrink: 0
30740
30766
  },
30741
- children: /* @__PURE__ */ g(kk, { title: e.chatTitle })
30767
+ children: /* @__PURE__ */ g(Ak, { title: e.chatTitle })
30742
30768
  })
30743
30769
  }), /* @__PURE__ */ g("div", {
30744
30770
  style: {
@@ -31168,11 +31194,11 @@ function Lk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31168
31194
  isLoading: T,
31169
31195
  isAgentTyping: d,
31170
31196
  setReplyContext: de,
31171
- TypingDots: Ik,
31197
+ TypingDots: Lk,
31172
31198
  primaryColor: n,
31173
31199
  agentHeadshot: y,
31174
31200
  agentDisplayName: v || b,
31175
- botAvatarNode: /* @__PURE__ */ g(Fk, { orbColors: t })
31201
+ botAvatarNode: /* @__PURE__ */ g(Ik, { orbColors: t })
31176
31202
  }) : Ae ? /* @__PURE__ */ _("div", {
31177
31203
  style: {
31178
31204
  flex: 1,
@@ -31213,7 +31239,7 @@ function Lk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31213
31239
  padding: "28px 24px"
31214
31240
  },
31215
31241
  children: [
31216
- /* @__PURE__ */ g(jk, {
31242
+ /* @__PURE__ */ g(Mk, {
31217
31243
  size: 94,
31218
31244
  orbColors: t
31219
31245
  }),
@@ -31354,14 +31380,14 @@ function Lk({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
31354
31380
  ]
31355
31381
  });
31356
31382
  }
31357
- function Rk() {
31383
+ function zk() {
31358
31384
  let { status: e, runtimeConfig: t, resolvedConfig: n, chatHistory: r, isOpen: i, activeScreen: a, isHumanHandled: s, agentName: l, agentHeadshot: u, visitorEmail: h, isAgentTyping: v, isAiTyping: y, isLoading: b, isRateLimited: x, rateLimitMessage: S, isConversationEnded: C, incomingCall: w, activeCallId: T, callConnectionState: ee, callConnectedAt: te, isCallMuted: ne, webRTCError: re, language: E, chatId: ie, historyRef: ae, onMessageSync: oe, sendMessage: D, uploadChatFile: se, openWidget: ce, captureVisitorEmail: le, setVoiceMode: ue, endConversation: de, startNewChat: me, acceptCall: he, rejectCall: ge, endWebRTCCall: _e, toggleCallMute: ve, dismissCallError: ye, startTyping: be, stopTyping: xe, updateTypingDraft: Se, getVisitorChatHistory: Ce, resumeChat: we, isSessionRestoring: Te, openToChatCounter: Ee, voiceEndCounter: De } = Ln();
31359
31385
  c(() => {
31360
31386
  try {
31361
31387
  pr();
31362
31388
  } catch {}
31363
31389
  }, []), c(() => {
31364
- Ee && k !== "text_chat" && k !== "call_screen" && (ue?.(!1), A("text_chat"));
31390
+ Ee && A !== "text_chat" && A !== "call_screen" && (ue?.(!1), st("text_chat"));
31365
31391
  }, [Ee]);
31366
31392
  let Oe = t?.widgetSettings || {}, ke = n?.widgetSettings || {}, Ae = {
31367
31393
  ...Oe.branding || {},
@@ -31372,12 +31398,16 @@ function Rk() {
31372
31398
  }, Pe = {
31373
31399
  ...Oe.features || {},
31374
31400
  ...ke.features || {}
31375
- }, Ie = Pe.voice !== !1, Le = Array.isArray(Ne.orbColors) && Ne.orbColors.length > 0 ? Ne.orbColors : null, ze = Ne.buttonColor || Ne.primaryColor || Le?.[0] || "#3B82F6", Be = Ne.position || "bottom-right", Ve = Ae.fallbackAgentName || "Agent", He = Ek(Le ?? Ne.chatBgColors), O = Ae.logo || Ae.logoUrl || null, Ue = E || "en", We = Oe.recommendations?.[Ue] || [], Ge = (ke.recommendations?.[Ue] ?? We).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31401
+ }, Ie = Pe.voice !== !1, Le = Array.isArray(Ne.orbColors) && Ne.orbColors.length > 0 ? Ne.orbColors : null, ze = Ne.buttonColor || Ne.primaryColor || Le?.[0] || "#3B82F6", Be = {
31402
+ small: 50,
31403
+ medium: 64,
31404
+ large: 80
31405
+ }, Ve = Be[Ne.orbSize] || Be.small, He = Ne.position || "bottom-right", O = Ae.fallbackAgentName || "Agent", Ue = Ek(Le ?? Ne.chatBgColors), We = Ae.logo || Ae.logoUrl || null, Ge = E || "en", Ke = Oe.recommendations?.[Ge] || [], qe = (ke.recommendations?.[Ge] ?? Ke).filter((e) => String(e?.label ?? "").trim()).map((e, t) => ({
31376
31406
  id: e.key || `qr-${t}`,
31377
31407
  label: e.label,
31378
31408
  message: e.label,
31379
31409
  text: e.label
31380
- })), Ke = Array.isArray(Ae.quickChatOptions) && Ae.quickChatOptions.length > 0 ? Ae.quickChatOptions : Ge, qe = Ae.hideWatermark === !0 ? !1 : Ae.showPoweredBy !== !1, Je = Ae.chatbotEnabled !== !1 && Ne.chatbotEnabled !== !1, Ye = Oe.greetings?.[E] || ke.greetings?.[E] || Ae.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Xe = {
31410
+ })), Je = Array.isArray(Ae.quickChatOptions) && Ae.quickChatOptions.length > 0 ? Ae.quickChatOptions : qe, Ye = Ae.hideWatermark === !0 ? !1 : Ae.showPoweredBy !== !1, Xe = Ae.chatbotEnabled !== !1 && Ne.chatbotEnabled !== !1, Ze = Oe.greetings?.[E] || ke.greetings?.[E] || Ae.introGreeting || "Hello, I'm here to help you know more about OpenSense Labs.", Qe = {
31381
31411
  entryPrompt: Ae.entryPrompt || "Do you want to explore in a new way?",
31382
31412
  yesLabel: Ae.yesLabel || "Yes",
31383
31413
  laterLabel: Ae.laterLabel || "Later",
@@ -31385,189 +31415,189 @@ function Rk() {
31385
31415
  voiceLabel: Ae.voiceLabel || "Voice",
31386
31416
  textLabel: Ae.textLabel || "Text",
31387
31417
  chatTitle: Ae.headerName || "Chat with FlowEngage",
31388
- introGreeting: Ye,
31418
+ introGreeting: Ze,
31389
31419
  inputPlaceholder: Ae.inputPlaceholder || "Type your message",
31390
31420
  analysingLabel: Ae.analysingLabel || "analysing..."
31391
- }, Ze = ke.elevenLabsAgentId || t?.elevenLabsAgentId || null, Qe = t?.siteId || n?.siteId || null, $e = t?.apiBaseUrl || "", et = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
31421
+ }, $e = ke.elevenLabsAgentId || t?.elevenLabsAgentId || null, et = t?.siteId || n?.siteId || null, tt = t?.apiBaseUrl || "", nt = f(() => l && String(l).trim() || t?.ownerName && String(t.ownerName).trim() || t?.websiteName && String(t.websiteName).trim() || "Agent", [
31392
31422
  l,
31393
31423
  t?.ownerName,
31394
31424
  t?.websiteName
31395
- ]), tt = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, nt = r.some((e) => e.sender === "user"), rt = f(() => {
31425
+ ]), rt = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, it = r.some((e) => e.sender === "user"), at = f(() => {
31396
31426
  let e = r.findIndex((e) => e.sender === "user");
31397
31427
  return e === -1 ? !1 : r.slice(e + 1).some((e) => e.sender === "bot" || e.sender === "ai" || e.sender === "agent");
31398
- }, [r]), it = !h && nt && rt, at = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [k, A] = m(() => at ? "text_chat" : "entry_prompt"), [ot, st] = m(""), [ct, lt] = m(null), [ut, dt] = m(h || ""), [ft, pt] = m(""), [mt, ht] = m(!1), [gt, j] = m(0), [_t, vt] = m(null), [yt, bt] = m(null), [xt, St] = m(""), [Ct, wt] = m(!1), [Tt, Et] = m(!1), [Dt, Ot] = m(!1), kt = p(null), At = p(!1);
31428
+ }, [r]), k = !h && it && at, ot = !!(ke._dashboardLivePreview || Oe._dashboardLivePreview), [A, st] = m(() => ot ? "text_chat" : "entry_prompt"), [ct, lt] = m(""), [ut, dt] = m(null), [ft, pt] = m(h || ""), [mt, ht] = m(""), [gt, j] = m(!1), [_t, vt] = m(0), [yt, bt] = m(null), [xt, St] = m(null), [Ct, wt] = m(""), [Tt, Et] = m(!1), [Dt, Ot] = m(!1), [kt, At] = m(!1), jt = p(null), Mt = p(!1);
31399
31429
  d(() => {
31400
- if (e !== "ready" || At.current) return;
31401
- if (At.current = !0, !Ie) {
31402
- A("minimized_orb");
31430
+ if (e !== "ready" || Mt.current) return;
31431
+ if (Mt.current = !0, !Ie) {
31432
+ st("minimized_orb");
31403
31433
  return;
31404
31434
  }
31405
31435
  let t = !1;
31406
31436
  try {
31407
31437
  t = Tr().shouldResumeVoice;
31408
31438
  } catch {}
31409
- let n = Fe(), r = Qe ? je(Qe) : null, i = n || !!r?.transcript;
31439
+ let n = Fe(), r = et ? je(et) : null, i = n || !!r?.transcript;
31410
31440
  if (t) {
31411
- ce?.({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
31441
+ ce?.({ notifyChatInitiated: !0 }), ue?.(!0), st("voice_mode");
31412
31442
  return;
31413
31443
  }
31414
31444
  if (Re()) {
31415
- ce?.({ notifyChatInitiated: !1 }), A("text_chat");
31445
+ ce?.({ notifyChatInitiated: !1 }), st("text_chat");
31416
31446
  return;
31417
31447
  }
31418
- if (Qe) try {
31419
- Me(Qe);
31448
+ if (et) try {
31449
+ Me(et);
31420
31450
  } catch {}
31421
31451
  if (i) {
31422
- A("minimized_orb");
31452
+ st("minimized_orb");
31423
31453
  return;
31424
31454
  }
31425
- if (fe(Qe)) {
31426
- A("minimized_orb");
31455
+ if (fe(et)) {
31456
+ st("minimized_orb");
31427
31457
  return;
31428
31458
  }
31429
31459
  }, [e, r]);
31430
- let [jt, Mt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
31460
+ let [Nt, Pt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
31431
31461
  c(() => {
31432
- let e = window.matchMedia("(max-width: 640px)"), t = (e) => Mt(e.matches);
31462
+ let e = window.matchMedia("(max-width: 640px)"), t = (e) => Pt(e.matches);
31433
31463
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
31434
31464
  }, []), c(() => {
31435
- dt(h || ""), h && pt("");
31465
+ pt(h || ""), h && ht("");
31436
31466
  }, [h]);
31437
- let Nt = o(() => {
31438
- bt(null), St("");
31439
- }, []), Pt = o((e) => {
31467
+ let Ft = o(() => {
31468
+ St(null), wt("");
31469
+ }, []), It = o((e) => {
31440
31470
  let t = qD(e);
31441
31471
  if (t) {
31442
- bt(null), St(t);
31472
+ St(null), wt(t);
31443
31473
  return;
31444
31474
  }
31445
- bt(e), St("");
31475
+ St(e), wt("");
31446
31476
  }, []);
31447
31477
  c(() => {
31448
31478
  if (!te || ee !== "connected") {
31449
- j(0);
31479
+ vt(0);
31450
31480
  return;
31451
31481
  }
31452
31482
  let e = () => {
31453
31483
  let e = new Date(te).getTime();
31454
- isNaN(e) || j(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
31484
+ isNaN(e) || vt(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
31455
31485
  };
31456
31486
  e();
31457
31487
  let t = window.setInterval(e, 1e3);
31458
31488
  return () => window.clearInterval(t);
31459
31489
  }, [te, ee]);
31460
- let Ft = o(() => {
31461
- A("call_screen"), Et(!1);
31462
- }, []), It = o(() => {
31463
- A("text_chat"), Et(!0);
31490
+ let Lt = o(() => {
31491
+ st("call_screen"), Ot(!1);
31492
+ }, []), Rt = o(() => {
31493
+ st("text_chat"), Ot(!0);
31464
31494
  }, []);
31465
31495
  c(() => {
31466
31496
  let e = w?.callId || T || null;
31467
31497
  if (!e) {
31468
- kt.current = null;
31498
+ jt.current = null;
31469
31499
  return;
31470
31500
  }
31471
31501
  if (w?.callId || ee === "connecting" || ee === "connected") {
31472
- if (k === "minimized_orb" && Tt && T && !w?.callId) {
31473
- kt.current = e;
31502
+ if (A === "minimized_orb" && Dt && T && !w?.callId) {
31503
+ jt.current = e;
31474
31504
  return;
31475
31505
  }
31476
- !(!i || k === "minimized_orb" || k === "voice_mode") && kt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
31506
+ !(!i || A === "minimized_orb" || A === "voice_mode") && jt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
31477
31507
  forcedKey: e,
31478
31508
  isOpen: i,
31479
- surface: k,
31509
+ surface: A,
31480
31510
  hasIncomingCall: !!w?.callId,
31481
31511
  activeCallId: T,
31482
31512
  callConnectionState: ee
31483
- }), kt.current = e, k === "voice_mode" && ue?.(!1), ce?.(), Ft());
31513
+ }), jt.current = e, A === "voice_mode" && ue?.(!1), ce?.(), Lt());
31484
31514
  }
31485
31515
  }, [
31486
31516
  T,
31487
31517
  ee,
31488
- Ft,
31518
+ Lt,
31489
31519
  w?.callId,
31490
31520
  i,
31491
31521
  ce,
31492
31522
  ue,
31493
- k
31523
+ A
31494
31524
  ]), c(() => {
31495
- !w && !T && k === "call_screen" && A("text_chat");
31525
+ !w && !T && A === "call_screen" && st("text_chat");
31496
31526
  }, [
31497
31527
  w,
31498
31528
  T,
31499
- k
31529
+ A
31500
31530
  ]), c(() => {
31501
- !T && Tt && Et(!1);
31502
- }, [T, Tt]), c(() => {
31531
+ !T && Dt && Ot(!1);
31532
+ }, [T, Dt]), c(() => {
31503
31533
  if (!s || C) {
31504
31534
  Se?.(""), xe?.();
31505
31535
  return;
31506
31536
  }
31507
- if (!ot.trim() || yt) {
31537
+ if (!ct.trim() || xt) {
31508
31538
  Se?.("");
31509
31539
  let e = window.setTimeout(() => xe?.(), 100);
31510
31540
  return () => window.clearTimeout(e);
31511
31541
  }
31512
31542
  be?.();
31513
- let e = window.setTimeout(() => Se?.(ot), 120), t = window.setTimeout(() => xe?.(), 1200);
31543
+ let e = window.setTimeout(() => Se?.(ct), 120), t = window.setTimeout(() => xe?.(), 1200);
31514
31544
  return () => {
31515
31545
  window.clearTimeout(e), window.clearTimeout(t);
31516
31546
  };
31517
31547
  }, [
31518
- ot,
31519
- yt,
31548
+ ct,
31549
+ xt,
31520
31550
  s,
31521
31551
  C,
31522
31552
  be,
31523
31553
  xe,
31524
31554
  Se
31525
31555
  ]);
31526
- let Lt = (e) => e ? {
31556
+ let zt = (e) => e ? {
31527
31557
  replyTo: e.messageId || e.id || null,
31528
31558
  replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
31529
31559
  replyToSender: e.sender || null
31530
- } : null, Rt = async (e) => {
31560
+ } : null, Bt = async (e) => {
31531
31561
  if (e.preventDefault(), C) return;
31532
- if (it) {
31533
- let e = ut.trim().toLowerCase();
31562
+ if (k) {
31563
+ let e = ft.trim().toLowerCase();
31534
31564
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
31535
- pt("Please enter a valid email so we can continue helping you.");
31565
+ ht("Please enter a valid email so we can continue helping you.");
31536
31566
  return;
31537
31567
  }
31538
- await le(e), pt(""), ht(!0), setTimeout(() => ht(!1), 3e3);
31568
+ await le(e), ht(""), j(!0), setTimeout(() => j(!1), 3e3);
31539
31569
  return;
31540
31570
  }
31541
- let t = Lt(ct);
31542
- if (!ot.trim() && !yt) return;
31543
- if (yt) {
31571
+ let t = zt(ut);
31572
+ if (!ct.trim() && !xt) return;
31573
+ if (xt) {
31544
31574
  try {
31545
- wt(!0), St("");
31546
- let e = await se(yt), n = e?.data || e, r = ot.trim() || `Shared file: ${YD(yt)}`;
31547
- st(""), lt(null), Nt(), await D(r, "", t, {
31575
+ Et(!0), wt("");
31576
+ let e = await se(xt), n = e?.data || e, r = ct.trim() || `Shared file: ${YD(xt)}`;
31577
+ lt(""), dt(null), Ft(), await D(r, "", t, {
31548
31578
  type: "file",
31549
31579
  metadata: {
31550
31580
  fileUrl: n?.fileUrl,
31551
- fileName: n?.fileName || yt.name,
31552
- fileType: n?.fileType || yt.type,
31553
- fileSize: n?.fileSize || yt.size
31581
+ fileName: n?.fileName || xt.name,
31582
+ fileType: n?.fileType || xt.type,
31583
+ fileSize: n?.fileSize || xt.size
31554
31584
  }
31555
31585
  });
31556
31586
  } catch (e) {
31557
- St(e?.message || "Failed to upload the selected file.");
31587
+ wt(e?.message || "Failed to upload the selected file.");
31558
31588
  } finally {
31559
- wt(!1);
31589
+ Et(!1);
31560
31590
  }
31561
31591
  return;
31562
31592
  }
31563
- let n = ot.trim();
31564
- st(""), lt(null), await D(n, "", t);
31565
- }, zt = o(() => {
31593
+ let n = ct.trim();
31594
+ lt(""), dt(null), await D(n, "", t);
31595
+ }, Vt = o(() => {
31566
31596
  r.length !== 0 && me?.();
31567
- }, [r.length, me]), Bt = (e) => {
31597
+ }, [r.length, me]), Ht = (e) => {
31568
31598
  let t = Math.floor(e / 60);
31569
31599
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
31570
- }, Vt = o(async (e) => {
31600
+ }, Ut = o(async (e) => {
31571
31601
  if (C || b) return;
31572
31602
  let t = e.message || e.label || e.text || "";
31573
31603
  t.trim() && await D(t.trim(), "");
@@ -31575,44 +31605,44 @@ function Rk() {
31575
31605
  C,
31576
31606
  b,
31577
31607
  D
31578
- ]), Ht = jt && k === "entry_prompt" ? { inset: 0 } : jt && k === "text_chat" ? {
31608
+ ]), Wt = Nt && A === "entry_prompt" ? { inset: 0 } : Nt && A === "text_chat" ? {
31579
31609
  left: 0,
31580
31610
  right: 0,
31581
31611
  bottom: 0
31582
- } : jt && k === "call_screen" ? {
31612
+ } : Nt && A === "call_screen" ? {
31583
31613
  left: 0,
31584
31614
  right: 0,
31585
31615
  bottom: 0,
31586
31616
  height: "90dvh",
31587
31617
  overflow: "hidden",
31588
31618
  borderRadius: "16px 16px 0 0"
31589
- } : jt && k === "connection_modal" ? {
31619
+ } : Nt && A === "connection_modal" ? {
31590
31620
  left: "28px",
31591
31621
  right: "12px",
31592
31622
  bottom: "12px"
31593
- } : k === "call_screen" ? {
31623
+ } : A === "call_screen" ? {
31594
31624
  width: "min(350px, calc(100vw - 40px))",
31595
31625
  height: "min(640px, calc(100vh - 120px))",
31596
31626
  borderRadius: "22px",
31597
31627
  overflow: "hidden",
31598
- ...Be === "bottom-left" ? {
31628
+ ...He === "bottom-left" ? {
31599
31629
  left: "1.5rem",
31600
31630
  bottom: "1.5rem"
31601
31631
  } : {
31602
31632
  right: "1.5rem",
31603
31633
  bottom: "1.5rem"
31604
31634
  }
31605
- } : Be === "bottom-left" ? {
31635
+ } : He === "bottom-left" ? {
31606
31636
  left: "1.5rem",
31607
31637
  bottom: "1.5rem"
31608
31638
  } : {
31609
31639
  right: "1.5rem",
31610
31640
  bottom: "1.5rem"
31611
- }, Ut = o(() => {
31612
- k !== "minimized_orb" && (Ot(!0), setTimeout(() => {
31613
- A("minimized_orb"), Ot(!1);
31641
+ }, Gt = o(() => {
31642
+ A !== "minimized_orb" && (At(!0), setTimeout(() => {
31643
+ st("minimized_orb"), At(!1), T && Ot(!0);
31614
31644
  }, 280));
31615
- }, [k]), Wt = () => A("connection_modal"), Gt = () => {
31645
+ }, [T, A]), Kt = () => st("connection_modal"), qt = () => {
31616
31646
  try {
31617
31647
  let e = window.AudioContext || window.webkitAudioContext;
31618
31648
  if (e) {
@@ -31620,36 +31650,36 @@ function Rk() {
31620
31650
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
31621
31651
  }
31622
31652
  } catch {}
31623
- ce({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
31624
- }, Kt = () => {
31625
- ce({ notifyChatInitiated: !0 }), ue?.(!1), A("text_chat");
31626
- }, qt = () => {
31627
- ue?.(!1), Ut();
31653
+ ce({ notifyChatInitiated: !0 }), ue?.(!0), st("voice_mode");
31654
+ }, Jt = () => {
31655
+ ce({ notifyChatInitiated: !0 }), ue?.(!1), st("text_chat");
31656
+ }, Yt = () => {
31657
+ ue?.(!1), Gt();
31628
31658
  };
31629
- return e !== "ready" || !Je || Pe.chat === !1 ? null : /* @__PURE__ */ _("div", {
31659
+ return e !== "ready" || !Xe || Pe.chat === !1 ? null : /* @__PURE__ */ _("div", {
31630
31660
  className: "flowengage-widget-root",
31631
31661
  style: {
31632
31662
  position: "fixed",
31633
31663
  zIndex: 999999,
31634
- ...Ht
31664
+ ...Wt
31635
31665
  },
31636
31666
  onWheel: (e) => e.stopPropagation(),
31637
31667
  onTouchMove: (e) => e.stopPropagation(),
31638
31668
  children: [
31639
- k === "entry_prompt" && /* @__PURE__ */ g(Mk, {
31640
- copy: Xe,
31669
+ A === "entry_prompt" && /* @__PURE__ */ g(Nk, {
31670
+ copy: Qe,
31641
31671
  orbColors: Le,
31642
31672
  primaryColor: ze,
31643
31673
  onYes: () => {
31644
- pe(Qe), Gt();
31674
+ pe(et), qt();
31645
31675
  },
31646
31676
  onLater: () => {
31647
- pe(Qe), Ut();
31677
+ pe(et), Gt();
31648
31678
  },
31649
- isMobile: jt,
31650
- isClosing: Dt
31679
+ isMobile: Nt,
31680
+ isClosing: kt
31651
31681
  }),
31652
- k === "minimized_orb" && /* @__PURE__ */ _(Dm.div, {
31682
+ A === "minimized_orb" && /* @__PURE__ */ _(Dm.div, {
31653
31683
  layoutId: "fe-main-orb",
31654
31684
  initial: {
31655
31685
  scale: .4,
@@ -31668,14 +31698,14 @@ function Rk() {
31668
31698
  transformOrigin: "bottom right",
31669
31699
  display: "inline-flex",
31670
31700
  flexDirection: "column",
31671
- alignItems: Be === "bottom-left" ? "flex-start" : "flex-end",
31701
+ alignItems: He === "bottom-left" ? "flex-start" : "flex-end",
31672
31702
  gap: "10px"
31673
31703
  },
31674
- children: [T && Tt && /* @__PURE__ */ _("button", {
31704
+ children: [T && /* @__PURE__ */ _("button", {
31675
31705
  type: "button",
31676
- onClick: Ft,
31706
+ onClick: Lt,
31677
31707
  style: {
31678
- maxWidth: jt ? "220px" : "240px",
31708
+ maxWidth: Nt ? "220px" : "240px",
31679
31709
  padding: "10px 14px",
31680
31710
  borderRadius: "18px",
31681
31711
  border: "1px solid rgba(255,255,255,0.7)",
@@ -31716,109 +31746,109 @@ function Rk() {
31716
31746
  marginTop: "2px",
31717
31747
  whiteSpace: "nowrap"
31718
31748
  },
31719
- children: ee === "connected" ? `${Bt(gt)} with ${et}` : `Tap to return to ${et}`
31749
+ children: ee === "connected" ? `${Ht(_t)} with ${nt}` : `Tap to return to ${nt}`
31720
31750
  })]
31721
31751
  })]
31722
- }), /* @__PURE__ */ g(jk, {
31723
- size: 50,
31752
+ }), /* @__PURE__ */ g(Mk, {
31753
+ size: Ve,
31724
31754
  orbColors: Le,
31725
- onClick: T && Tt ? Ft : Ie ? Wt : Kt
31755
+ onClick: T ? Lt : Ie ? Kt : Jt
31726
31756
  })]
31727
31757
  }),
31728
- k === "connection_modal" && /* @__PURE__ */ g(Nk, {
31729
- copy: Xe,
31758
+ A === "connection_modal" && /* @__PURE__ */ g(Pk, {
31759
+ copy: Qe,
31730
31760
  orbColors: Le,
31731
31761
  primaryColor: ze,
31732
- onVoice: Gt,
31733
- onText: Kt,
31734
- onClose: Ut,
31735
- isMobile: jt,
31736
- isClosing: Dt
31762
+ onVoice: qt,
31763
+ onText: Jt,
31764
+ onClose: Gt,
31765
+ isMobile: Nt,
31766
+ isClosing: kt
31737
31767
  }),
31738
- k === "voice_mode" && /* @__PURE__ */ g(Pk, {
31768
+ A === "voice_mode" && /* @__PURE__ */ g(Fk, {
31739
31769
  orbColors: Le,
31740
- onEnterChat: Kt,
31741
- onEndChat: qt,
31742
- agentId: Ze,
31743
- siteId: Qe,
31744
- apiBaseUrl: $e,
31770
+ onEnterChat: Jt,
31771
+ onEndChat: Yt,
31772
+ agentId: $e,
31773
+ siteId: et,
31774
+ apiBaseUrl: tt,
31745
31775
  chatId: ie,
31746
31776
  historyRef: ae,
31747
31777
  onMessageSync: oe,
31748
31778
  voiceEndCounter: De
31749
31779
  }, "voice"),
31750
- k === "call_screen" && /* @__PURE__ */ g(gO, {
31780
+ A === "call_screen" && /* @__PURE__ */ g(gO, {
31751
31781
  incomingCall: w,
31752
31782
  activeCallId: T,
31753
31783
  callConnectionState: ee,
31754
- callDurationSeconds: gt,
31784
+ callDurationSeconds: _t,
31755
31785
  isCallMuted: ne,
31756
- agentName: et,
31757
- agentHeadshot: tt,
31758
- fallbackAgentName: Ve,
31786
+ agentName: nt,
31787
+ agentHeadshot: rt,
31788
+ fallbackAgentName: O,
31759
31789
  acceptCall: he,
31760
31790
  rejectCall: ge,
31761
31791
  endWebRTCCall: _e,
31762
31792
  toggleCallMute: ve,
31763
- formatCallDuration: Bt,
31764
- onMinimize: It,
31793
+ formatCallDuration: Ht,
31794
+ onMinimize: Rt,
31765
31795
  primaryColor: ze,
31766
31796
  orbColors: Le,
31767
31797
  chatHistory: r
31768
31798
  }),
31769
- k === "text_chat" && /* @__PURE__ */ g(Lk, {
31770
- isClosing: Dt,
31771
- copy: Xe,
31799
+ A === "text_chat" && /* @__PURE__ */ g(Rk, {
31800
+ isClosing: kt,
31801
+ copy: Qe,
31772
31802
  orbColors: Le,
31773
31803
  primaryColor: ze,
31774
- chatBgGradient: He,
31775
- logo: O,
31776
- quickChatOptions: Ke,
31777
- onQuickChatSelect: Vt,
31778
- isMobile: jt,
31804
+ chatBgGradient: Ue,
31805
+ logo: We,
31806
+ quickChatOptions: Je,
31807
+ onQuickChatSelect: Ut,
31808
+ isMobile: Nt,
31779
31809
  chatHistory: r,
31780
31810
  isAiTyping: y,
31781
31811
  isAgentTyping: v,
31782
31812
  activeScreen: a,
31783
- agentName: et,
31784
- agentHeadshot: tt,
31785
- fallbackAgentName: Ve,
31786
- input: ot,
31787
- setInput: st,
31788
- onSubmit: Rt,
31813
+ agentName: nt,
31814
+ agentHeadshot: rt,
31815
+ fallbackAgentName: O,
31816
+ input: ct,
31817
+ setInput: lt,
31818
+ onSubmit: Bt,
31789
31819
  isConversationEnded: C,
31790
31820
  isLoading: b,
31791
31821
  isRateLimited: x,
31792
31822
  rateLimitMessage: S,
31793
- selectedFile: yt,
31794
- onFileSelect: Pt,
31795
- onRemoveSelectedFile: Nt,
31796
- attachmentError: xt,
31797
- isUploadingAttachment: Ct,
31798
- requiresEmail: it,
31799
- emailInput: ut,
31800
- setEmailInput: dt,
31801
- emailError: ft,
31802
- emailCaptureSuccess: mt,
31803
- replyContext: ct,
31804
- setReplyContext: lt,
31823
+ selectedFile: xt,
31824
+ onFileSelect: It,
31825
+ onRemoveSelectedFile: Ft,
31826
+ attachmentError: Ct,
31827
+ isUploadingAttachment: Tt,
31828
+ requiresEmail: k,
31829
+ emailInput: ft,
31830
+ setEmailInput: pt,
31831
+ emailError: mt,
31832
+ emailCaptureSuccess: gt,
31833
+ replyContext: ut,
31834
+ setReplyContext: dt,
31805
31835
  webRTCError: re,
31806
- micError: _t,
31807
- setMicError: vt,
31836
+ micError: yt,
31837
+ setMicError: bt,
31808
31838
  dismissCallError: ye,
31809
31839
  activeCallId: T,
31810
31840
  isCallMuted: ne,
31811
31841
  toggleCallMute: ve,
31812
31842
  endWebRTCCall: _e,
31813
- formatCallDuration: Bt,
31814
- callDurationSeconds: gt,
31815
- onCollapse: Ut,
31816
- onStartVoice: Gt,
31817
- onNewChat: zt,
31818
- onMinimize: It,
31819
- onExpand: Ft,
31820
- isCallMinimized: Tt && !!T,
31821
- showPoweredBy: qe,
31843
+ formatCallDuration: Ht,
31844
+ callDurationSeconds: _t,
31845
+ onCollapse: Gt,
31846
+ onStartVoice: qt,
31847
+ onNewChat: Vt,
31848
+ onMinimize: Rt,
31849
+ onExpand: Lt,
31850
+ isCallMinimized: !!T,
31851
+ showPoweredBy: Ye,
31822
31852
  getVisitorChatHistory: Ce,
31823
31853
  resumeChat: we,
31824
31854
  isSessionRestoring: Te
@@ -31829,7 +31859,7 @@ function Rk() {
31829
31859
  }
31830
31860
  //#endregion
31831
31861
  //#region src/components/ErrorBoundary.jsx
31832
- var zk = class extends e.Component {
31862
+ var Bk = class extends e.Component {
31833
31863
  constructor(e) {
31834
31864
  super(e), this.state = { hasError: !1 };
31835
31865
  }
@@ -31844,4 +31874,4 @@ var zk = class extends e.Component {
31844
31874
  }
31845
31875
  };
31846
31876
  //#endregion
31847
- export { lO as AnimatedOrb, zk as ErrorBoundary, Rr as FlowEngageProvider, Rk as FlowEngageWidget, Ln as useFlowEngage };
31877
+ export { lO as AnimatedOrb, Bk as ErrorBoundary, Rr as FlowEngageProvider, zk as FlowEngageWidget, Ln as useFlowEngage };