@flowengage/react-chatbot 6.0.14 → 6.0.15

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);
@@ -3435,10 +3435,10 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3435
3435
  }
3436
3436
  }, qt = async (e) => {
3437
3437
  let t = Nt(e);
3438
- if (!t || !k.current || !A.current) return t;
3438
+ if (!t || !k.current || !ot.current) return t;
3439
3439
  try {
3440
3440
  await k.current.trackVisitor({
3441
- chatId: A.current,
3441
+ chatId: ot.current,
3442
3442
  currentPagePath: typeof window < "u" && window.location.pathname || "/",
3443
3443
  email: t
3444
3444
  });
@@ -3598,7 +3598,7 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3598
3598
  At
3599
3599
  ]), c(() => {
3600
3600
  let e = () => {
3601
- let e = A.current, t = k.current;
3601
+ let e = ot.current, t = k.current;
3602
3602
  if (!t || !e) return;
3603
3603
  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
3604
  t.beaconEndWebRTCCall(mt.current, e);
@@ -3613,9 +3613,9 @@ function Rr({ siteId: e, config: t, children: n, language: r = "en" }) {
3613
3613
  }, []);
3614
3614
  let nn = o(() => {
3615
3615
  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);
3616
+ 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
3617
  }, [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);
3618
+ 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
3619
  }, [i?.siteId]), an = f(() => ({
3620
3620
  status: l,
3621
3621
  error: d,
@@ -29386,7 +29386,7 @@ function Ck(e) {
29386
29386
  for (; Date.now() < c && (await new Promise((e) => setTimeout(e, 250)), s = Sk(), !(s.length >= 1)););
29387
29387
  xk(), $("flowengage_navigate → page headings collected:", s);
29388
29388
  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.`);
29389
+ 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
29390
  } catch {}
29391
29391
  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
29392
  } catch (e) {
@@ -30104,6 +30104,7 @@ function Pk({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
30104
30104
  let v = {
30105
30105
  clientTools: t,
30106
30106
  connectionType: "websocket",
30107
+ minSpeechDurationMs: 100,
30107
30108
  ..._ ? { signedUrl: _ } : { agentId: r }
30108
30109
  }, b = (p.split("/").filter(Boolean).pop() || "").replace(/[-_]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), x = "";
30109
30110
  m && m.includes("|") && (x = m.split("|").map((e) => e.trim()).filter(Boolean).reduce((e, t) => e.length <= t.length ? e : t));
@@ -31361,7 +31362,7 @@ function Rk() {
31361
31362
  pr();
31362
31363
  } catch {}
31363
31364
  }, []), c(() => {
31364
- Ee && k !== "text_chat" && k !== "call_screen" && (ue?.(!1), A("text_chat"));
31365
+ Ee && A !== "text_chat" && A !== "call_screen" && (ue?.(!1), st("text_chat"));
31365
31366
  }, [Ee]);
31366
31367
  let Oe = t?.widgetSettings || {}, ke = n?.widgetSettings || {}, Ae = {
31367
31368
  ...Oe.branding || {},
@@ -31372,12 +31373,16 @@ function Rk() {
31372
31373
  }, Pe = {
31373
31374
  ...Oe.features || {},
31374
31375
  ...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) => ({
31376
+ }, 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 = {
31377
+ small: 50,
31378
+ medium: 64,
31379
+ large: 80
31380
+ }, 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
31381
  id: e.key || `qr-${t}`,
31377
31382
  label: e.label,
31378
31383
  message: e.label,
31379
31384
  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 = {
31385
+ })), 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
31386
  entryPrompt: Ae.entryPrompt || "Do you want to explore in a new way?",
31382
31387
  yesLabel: Ae.yesLabel || "Yes",
31383
31388
  laterLabel: Ae.laterLabel || "Later",
@@ -31385,189 +31390,189 @@ function Rk() {
31385
31390
  voiceLabel: Ae.voiceLabel || "Voice",
31386
31391
  textLabel: Ae.textLabel || "Text",
31387
31392
  chatTitle: Ae.headerName || "Chat with FlowEngage",
31388
- introGreeting: Ye,
31393
+ introGreeting: Ze,
31389
31394
  inputPlaceholder: Ae.inputPlaceholder || "Type your message",
31390
31395
  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", [
31396
+ }, $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
31397
  l,
31393
31398
  t?.ownerName,
31394
31399
  t?.websiteName
31395
- ]), tt = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, nt = r.some((e) => e.sender === "user"), rt = f(() => {
31400
+ ]), rt = u && String(u).trim() || t?.ownerProfileImageUrl && String(t.ownerProfileImageUrl).trim() || null, it = r.some((e) => e.sender === "user"), at = f(() => {
31396
31401
  let e = r.findIndex((e) => e.sender === "user");
31397
31402
  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);
31403
+ }, [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
31404
  d(() => {
31400
- if (e !== "ready" || At.current) return;
31401
- if (At.current = !0, !Ie) {
31402
- A("minimized_orb");
31405
+ if (e !== "ready" || Mt.current) return;
31406
+ if (Mt.current = !0, !Ie) {
31407
+ st("minimized_orb");
31403
31408
  return;
31404
31409
  }
31405
31410
  let t = !1;
31406
31411
  try {
31407
31412
  t = Tr().shouldResumeVoice;
31408
31413
  } catch {}
31409
- let n = Fe(), r = Qe ? je(Qe) : null, i = n || !!r?.transcript;
31414
+ let n = Fe(), r = et ? je(et) : null, i = n || !!r?.transcript;
31410
31415
  if (t) {
31411
- ce?.({ notifyChatInitiated: !0 }), ue?.(!0), A("voice_mode");
31416
+ ce?.({ notifyChatInitiated: !0 }), ue?.(!0), st("voice_mode");
31412
31417
  return;
31413
31418
  }
31414
31419
  if (Re()) {
31415
- ce?.({ notifyChatInitiated: !1 }), A("text_chat");
31420
+ ce?.({ notifyChatInitiated: !1 }), st("text_chat");
31416
31421
  return;
31417
31422
  }
31418
- if (Qe) try {
31419
- Me(Qe);
31423
+ if (et) try {
31424
+ Me(et);
31420
31425
  } catch {}
31421
31426
  if (i) {
31422
- A("minimized_orb");
31427
+ st("minimized_orb");
31423
31428
  return;
31424
31429
  }
31425
- if (fe(Qe)) {
31426
- A("minimized_orb");
31430
+ if (fe(et)) {
31431
+ st("minimized_orb");
31427
31432
  return;
31428
31433
  }
31429
31434
  }, [e, r]);
31430
- let [jt, Mt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
31435
+ let [Nt, Pt] = m(() => typeof window < "u" && window.matchMedia("(max-width: 640px)").matches);
31431
31436
  c(() => {
31432
- let e = window.matchMedia("(max-width: 640px)"), t = (e) => Mt(e.matches);
31437
+ let e = window.matchMedia("(max-width: 640px)"), t = (e) => Pt(e.matches);
31433
31438
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
31434
31439
  }, []), c(() => {
31435
- dt(h || ""), h && pt("");
31440
+ pt(h || ""), h && ht("");
31436
31441
  }, [h]);
31437
- let Nt = o(() => {
31438
- bt(null), St("");
31439
- }, []), Pt = o((e) => {
31442
+ let Ft = o(() => {
31443
+ St(null), wt("");
31444
+ }, []), It = o((e) => {
31440
31445
  let t = qD(e);
31441
31446
  if (t) {
31442
- bt(null), St(t);
31447
+ St(null), wt(t);
31443
31448
  return;
31444
31449
  }
31445
- bt(e), St("");
31450
+ St(e), wt("");
31446
31451
  }, []);
31447
31452
  c(() => {
31448
31453
  if (!te || ee !== "connected") {
31449
- j(0);
31454
+ vt(0);
31450
31455
  return;
31451
31456
  }
31452
31457
  let e = () => {
31453
31458
  let e = new Date(te).getTime();
31454
- isNaN(e) || j(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
31459
+ isNaN(e) || vt(Math.max(0, Math.floor((Date.now() - e) / 1e3)));
31455
31460
  };
31456
31461
  e();
31457
31462
  let t = window.setInterval(e, 1e3);
31458
31463
  return () => window.clearInterval(t);
31459
31464
  }, [te, ee]);
31460
- let Ft = o(() => {
31461
- A("call_screen"), Et(!1);
31462
- }, []), It = o(() => {
31463
- A("text_chat"), Et(!0);
31465
+ let Lt = o(() => {
31466
+ st("call_screen"), Ot(!1);
31467
+ }, []), Rt = o(() => {
31468
+ st("text_chat"), Ot(!0);
31464
31469
  }, []);
31465
31470
  c(() => {
31466
31471
  let e = w?.callId || T || null;
31467
31472
  if (!e) {
31468
- kt.current = null;
31473
+ jt.current = null;
31469
31474
  return;
31470
31475
  }
31471
31476
  if (w?.callId || ee === "connecting" || ee === "connected") {
31472
- if (k === "minimized_orb" && Tt && T && !w?.callId) {
31473
- kt.current = e;
31477
+ if (A === "minimized_orb" && Dt && T && !w?.callId) {
31478
+ jt.current = e;
31474
31479
  return;
31475
31480
  }
31476
- !(!i || k === "minimized_orb" || k === "voice_mode") && kt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
31481
+ !(!i || A === "minimized_orb" || A === "voice_mode") && jt.current === e || (console.log("[FlowEngageWidget] forcing call UI to front", {
31477
31482
  forcedKey: e,
31478
31483
  isOpen: i,
31479
- surface: k,
31484
+ surface: A,
31480
31485
  hasIncomingCall: !!w?.callId,
31481
31486
  activeCallId: T,
31482
31487
  callConnectionState: ee
31483
- }), kt.current = e, k === "voice_mode" && ue?.(!1), ce?.(), Ft());
31488
+ }), jt.current = e, A === "voice_mode" && ue?.(!1), ce?.(), Lt());
31484
31489
  }
31485
31490
  }, [
31486
31491
  T,
31487
31492
  ee,
31488
- Ft,
31493
+ Lt,
31489
31494
  w?.callId,
31490
31495
  i,
31491
31496
  ce,
31492
31497
  ue,
31493
- k
31498
+ A
31494
31499
  ]), c(() => {
31495
- !w && !T && k === "call_screen" && A("text_chat");
31500
+ !w && !T && A === "call_screen" && st("text_chat");
31496
31501
  }, [
31497
31502
  w,
31498
31503
  T,
31499
- k
31504
+ A
31500
31505
  ]), c(() => {
31501
- !T && Tt && Et(!1);
31502
- }, [T, Tt]), c(() => {
31506
+ !T && Dt && Ot(!1);
31507
+ }, [T, Dt]), c(() => {
31503
31508
  if (!s || C) {
31504
31509
  Se?.(""), xe?.();
31505
31510
  return;
31506
31511
  }
31507
- if (!ot.trim() || yt) {
31512
+ if (!ct.trim() || xt) {
31508
31513
  Se?.("");
31509
31514
  let e = window.setTimeout(() => xe?.(), 100);
31510
31515
  return () => window.clearTimeout(e);
31511
31516
  }
31512
31517
  be?.();
31513
- let e = window.setTimeout(() => Se?.(ot), 120), t = window.setTimeout(() => xe?.(), 1200);
31518
+ let e = window.setTimeout(() => Se?.(ct), 120), t = window.setTimeout(() => xe?.(), 1200);
31514
31519
  return () => {
31515
31520
  window.clearTimeout(e), window.clearTimeout(t);
31516
31521
  };
31517
31522
  }, [
31518
- ot,
31519
- yt,
31523
+ ct,
31524
+ xt,
31520
31525
  s,
31521
31526
  C,
31522
31527
  be,
31523
31528
  xe,
31524
31529
  Se
31525
31530
  ]);
31526
- let Lt = (e) => e ? {
31531
+ let zt = (e) => e ? {
31527
31532
  replyTo: e.messageId || e.id || null,
31528
31533
  replyToContent: (e.replyToContent || e.message || "").replace(/<[^>]+>/g, "").trim().slice(0, 200),
31529
31534
  replyToSender: e.sender || null
31530
- } : null, Rt = async (e) => {
31535
+ } : null, Bt = async (e) => {
31531
31536
  if (e.preventDefault(), C) return;
31532
- if (it) {
31533
- let e = ut.trim().toLowerCase();
31537
+ if (k) {
31538
+ let e = ft.trim().toLowerCase();
31534
31539
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
31535
- pt("Please enter a valid email so we can continue helping you.");
31540
+ ht("Please enter a valid email so we can continue helping you.");
31536
31541
  return;
31537
31542
  }
31538
- await le(e), pt(""), ht(!0), setTimeout(() => ht(!1), 3e3);
31543
+ await le(e), ht(""), j(!0), setTimeout(() => j(!1), 3e3);
31539
31544
  return;
31540
31545
  }
31541
- let t = Lt(ct);
31542
- if (!ot.trim() && !yt) return;
31543
- if (yt) {
31546
+ let t = zt(ut);
31547
+ if (!ct.trim() && !xt) return;
31548
+ if (xt) {
31544
31549
  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, {
31550
+ Et(!0), wt("");
31551
+ let e = await se(xt), n = e?.data || e, r = ct.trim() || `Shared file: ${YD(xt)}`;
31552
+ lt(""), dt(null), Ft(), await D(r, "", t, {
31548
31553
  type: "file",
31549
31554
  metadata: {
31550
31555
  fileUrl: n?.fileUrl,
31551
- fileName: n?.fileName || yt.name,
31552
- fileType: n?.fileType || yt.type,
31553
- fileSize: n?.fileSize || yt.size
31556
+ fileName: n?.fileName || xt.name,
31557
+ fileType: n?.fileType || xt.type,
31558
+ fileSize: n?.fileSize || xt.size
31554
31559
  }
31555
31560
  });
31556
31561
  } catch (e) {
31557
- St(e?.message || "Failed to upload the selected file.");
31562
+ wt(e?.message || "Failed to upload the selected file.");
31558
31563
  } finally {
31559
- wt(!1);
31564
+ Et(!1);
31560
31565
  }
31561
31566
  return;
31562
31567
  }
31563
- let n = ot.trim();
31564
- st(""), lt(null), await D(n, "", t);
31565
- }, zt = o(() => {
31568
+ let n = ct.trim();
31569
+ lt(""), dt(null), await D(n, "", t);
31570
+ }, Vt = o(() => {
31566
31571
  r.length !== 0 && me?.();
31567
- }, [r.length, me]), Bt = (e) => {
31572
+ }, [r.length, me]), Ht = (e) => {
31568
31573
  let t = Math.floor(e / 60);
31569
31574
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
31570
- }, Vt = o(async (e) => {
31575
+ }, Ut = o(async (e) => {
31571
31576
  if (C || b) return;
31572
31577
  let t = e.message || e.label || e.text || "";
31573
31578
  t.trim() && await D(t.trim(), "");
@@ -31575,44 +31580,44 @@ function Rk() {
31575
31580
  C,
31576
31581
  b,
31577
31582
  D
31578
- ]), Ht = jt && k === "entry_prompt" ? { inset: 0 } : jt && k === "text_chat" ? {
31583
+ ]), Wt = Nt && A === "entry_prompt" ? { inset: 0 } : Nt && A === "text_chat" ? {
31579
31584
  left: 0,
31580
31585
  right: 0,
31581
31586
  bottom: 0
31582
- } : jt && k === "call_screen" ? {
31587
+ } : Nt && A === "call_screen" ? {
31583
31588
  left: 0,
31584
31589
  right: 0,
31585
31590
  bottom: 0,
31586
31591
  height: "90dvh",
31587
31592
  overflow: "hidden",
31588
31593
  borderRadius: "16px 16px 0 0"
31589
- } : jt && k === "connection_modal" ? {
31594
+ } : Nt && A === "connection_modal" ? {
31590
31595
  left: "28px",
31591
31596
  right: "12px",
31592
31597
  bottom: "12px"
31593
- } : k === "call_screen" ? {
31598
+ } : A === "call_screen" ? {
31594
31599
  width: "min(350px, calc(100vw - 40px))",
31595
31600
  height: "min(640px, calc(100vh - 120px))",
31596
31601
  borderRadius: "22px",
31597
31602
  overflow: "hidden",
31598
- ...Be === "bottom-left" ? {
31603
+ ...He === "bottom-left" ? {
31599
31604
  left: "1.5rem",
31600
31605
  bottom: "1.5rem"
31601
31606
  } : {
31602
31607
  right: "1.5rem",
31603
31608
  bottom: "1.5rem"
31604
31609
  }
31605
- } : Be === "bottom-left" ? {
31610
+ } : He === "bottom-left" ? {
31606
31611
  left: "1.5rem",
31607
31612
  bottom: "1.5rem"
31608
31613
  } : {
31609
31614
  right: "1.5rem",
31610
31615
  bottom: "1.5rem"
31611
- }, Ut = o(() => {
31612
- k !== "minimized_orb" && (Ot(!0), setTimeout(() => {
31613
- A("minimized_orb"), Ot(!1);
31616
+ }, Gt = o(() => {
31617
+ A !== "minimized_orb" && (At(!0), setTimeout(() => {
31618
+ st("minimized_orb"), At(!1);
31614
31619
  }, 280));
31615
- }, [k]), Wt = () => A("connection_modal"), Gt = () => {
31620
+ }, [A]), Kt = () => st("connection_modal"), qt = () => {
31616
31621
  try {
31617
31622
  let e = window.AudioContext || window.webkitAudioContext;
31618
31623
  if (e) {
@@ -31620,36 +31625,36 @@ function Rk() {
31620
31625
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
31621
31626
  }
31622
31627
  } 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();
31628
+ ce({ notifyChatInitiated: !0 }), ue?.(!0), st("voice_mode");
31629
+ }, Jt = () => {
31630
+ ce({ notifyChatInitiated: !0 }), ue?.(!1), st("text_chat");
31631
+ }, Yt = () => {
31632
+ ue?.(!1), Gt();
31628
31633
  };
31629
- return e !== "ready" || !Je || Pe.chat === !1 ? null : /* @__PURE__ */ _("div", {
31634
+ return e !== "ready" || !Xe || Pe.chat === !1 ? null : /* @__PURE__ */ _("div", {
31630
31635
  className: "flowengage-widget-root",
31631
31636
  style: {
31632
31637
  position: "fixed",
31633
31638
  zIndex: 999999,
31634
- ...Ht
31639
+ ...Wt
31635
31640
  },
31636
31641
  onWheel: (e) => e.stopPropagation(),
31637
31642
  onTouchMove: (e) => e.stopPropagation(),
31638
31643
  children: [
31639
- k === "entry_prompt" && /* @__PURE__ */ g(Mk, {
31640
- copy: Xe,
31644
+ A === "entry_prompt" && /* @__PURE__ */ g(Mk, {
31645
+ copy: Qe,
31641
31646
  orbColors: Le,
31642
31647
  primaryColor: ze,
31643
31648
  onYes: () => {
31644
- pe(Qe), Gt();
31649
+ pe(et), qt();
31645
31650
  },
31646
31651
  onLater: () => {
31647
- pe(Qe), Ut();
31652
+ pe(et), Gt();
31648
31653
  },
31649
- isMobile: jt,
31650
- isClosing: Dt
31654
+ isMobile: Nt,
31655
+ isClosing: kt
31651
31656
  }),
31652
- k === "minimized_orb" && /* @__PURE__ */ _(Dm.div, {
31657
+ A === "minimized_orb" && /* @__PURE__ */ _(Dm.div, {
31653
31658
  layoutId: "fe-main-orb",
31654
31659
  initial: {
31655
31660
  scale: .4,
@@ -31668,14 +31673,14 @@ function Rk() {
31668
31673
  transformOrigin: "bottom right",
31669
31674
  display: "inline-flex",
31670
31675
  flexDirection: "column",
31671
- alignItems: Be === "bottom-left" ? "flex-start" : "flex-end",
31676
+ alignItems: He === "bottom-left" ? "flex-start" : "flex-end",
31672
31677
  gap: "10px"
31673
31678
  },
31674
- children: [T && Tt && /* @__PURE__ */ _("button", {
31679
+ children: [T && Dt && /* @__PURE__ */ _("button", {
31675
31680
  type: "button",
31676
- onClick: Ft,
31681
+ onClick: Lt,
31677
31682
  style: {
31678
- maxWidth: jt ? "220px" : "240px",
31683
+ maxWidth: Nt ? "220px" : "240px",
31679
31684
  padding: "10px 14px",
31680
31685
  borderRadius: "18px",
31681
31686
  border: "1px solid rgba(255,255,255,0.7)",
@@ -31716,109 +31721,109 @@ function Rk() {
31716
31721
  marginTop: "2px",
31717
31722
  whiteSpace: "nowrap"
31718
31723
  },
31719
- children: ee === "connected" ? `${Bt(gt)} with ${et}` : `Tap to return to ${et}`
31724
+ children: ee === "connected" ? `${Ht(_t)} with ${nt}` : `Tap to return to ${nt}`
31720
31725
  })]
31721
31726
  })]
31722
31727
  }), /* @__PURE__ */ g(jk, {
31723
- size: 50,
31728
+ size: Ve,
31724
31729
  orbColors: Le,
31725
- onClick: T && Tt ? Ft : Ie ? Wt : Kt
31730
+ onClick: T && Dt ? Lt : Ie ? Kt : Jt
31726
31731
  })]
31727
31732
  }),
31728
- k === "connection_modal" && /* @__PURE__ */ g(Nk, {
31729
- copy: Xe,
31733
+ A === "connection_modal" && /* @__PURE__ */ g(Nk, {
31734
+ copy: Qe,
31730
31735
  orbColors: Le,
31731
31736
  primaryColor: ze,
31732
- onVoice: Gt,
31733
- onText: Kt,
31734
- onClose: Ut,
31735
- isMobile: jt,
31736
- isClosing: Dt
31737
+ onVoice: qt,
31738
+ onText: Jt,
31739
+ onClose: Gt,
31740
+ isMobile: Nt,
31741
+ isClosing: kt
31737
31742
  }),
31738
- k === "voice_mode" && /* @__PURE__ */ g(Pk, {
31743
+ A === "voice_mode" && /* @__PURE__ */ g(Pk, {
31739
31744
  orbColors: Le,
31740
- onEnterChat: Kt,
31741
- onEndChat: qt,
31742
- agentId: Ze,
31743
- siteId: Qe,
31744
- apiBaseUrl: $e,
31745
+ onEnterChat: Jt,
31746
+ onEndChat: Yt,
31747
+ agentId: $e,
31748
+ siteId: et,
31749
+ apiBaseUrl: tt,
31745
31750
  chatId: ie,
31746
31751
  historyRef: ae,
31747
31752
  onMessageSync: oe,
31748
31753
  voiceEndCounter: De
31749
31754
  }, "voice"),
31750
- k === "call_screen" && /* @__PURE__ */ g(gO, {
31755
+ A === "call_screen" && /* @__PURE__ */ g(gO, {
31751
31756
  incomingCall: w,
31752
31757
  activeCallId: T,
31753
31758
  callConnectionState: ee,
31754
- callDurationSeconds: gt,
31759
+ callDurationSeconds: _t,
31755
31760
  isCallMuted: ne,
31756
- agentName: et,
31757
- agentHeadshot: tt,
31758
- fallbackAgentName: Ve,
31761
+ agentName: nt,
31762
+ agentHeadshot: rt,
31763
+ fallbackAgentName: O,
31759
31764
  acceptCall: he,
31760
31765
  rejectCall: ge,
31761
31766
  endWebRTCCall: _e,
31762
31767
  toggleCallMute: ve,
31763
- formatCallDuration: Bt,
31764
- onMinimize: It,
31768
+ formatCallDuration: Ht,
31769
+ onMinimize: Rt,
31765
31770
  primaryColor: ze,
31766
31771
  orbColors: Le,
31767
31772
  chatHistory: r
31768
31773
  }),
31769
- k === "text_chat" && /* @__PURE__ */ g(Lk, {
31770
- isClosing: Dt,
31771
- copy: Xe,
31774
+ A === "text_chat" && /* @__PURE__ */ g(Lk, {
31775
+ isClosing: kt,
31776
+ copy: Qe,
31772
31777
  orbColors: Le,
31773
31778
  primaryColor: ze,
31774
- chatBgGradient: He,
31775
- logo: O,
31776
- quickChatOptions: Ke,
31777
- onQuickChatSelect: Vt,
31778
- isMobile: jt,
31779
+ chatBgGradient: Ue,
31780
+ logo: We,
31781
+ quickChatOptions: Je,
31782
+ onQuickChatSelect: Ut,
31783
+ isMobile: Nt,
31779
31784
  chatHistory: r,
31780
31785
  isAiTyping: y,
31781
31786
  isAgentTyping: v,
31782
31787
  activeScreen: a,
31783
- agentName: et,
31784
- agentHeadshot: tt,
31785
- fallbackAgentName: Ve,
31786
- input: ot,
31787
- setInput: st,
31788
- onSubmit: Rt,
31788
+ agentName: nt,
31789
+ agentHeadshot: rt,
31790
+ fallbackAgentName: O,
31791
+ input: ct,
31792
+ setInput: lt,
31793
+ onSubmit: Bt,
31789
31794
  isConversationEnded: C,
31790
31795
  isLoading: b,
31791
31796
  isRateLimited: x,
31792
31797
  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,
31798
+ selectedFile: xt,
31799
+ onFileSelect: It,
31800
+ onRemoveSelectedFile: Ft,
31801
+ attachmentError: Ct,
31802
+ isUploadingAttachment: Tt,
31803
+ requiresEmail: k,
31804
+ emailInput: ft,
31805
+ setEmailInput: pt,
31806
+ emailError: mt,
31807
+ emailCaptureSuccess: gt,
31808
+ replyContext: ut,
31809
+ setReplyContext: dt,
31805
31810
  webRTCError: re,
31806
- micError: _t,
31807
- setMicError: vt,
31811
+ micError: yt,
31812
+ setMicError: bt,
31808
31813
  dismissCallError: ye,
31809
31814
  activeCallId: T,
31810
31815
  isCallMuted: ne,
31811
31816
  toggleCallMute: ve,
31812
31817
  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,
31818
+ formatCallDuration: Ht,
31819
+ callDurationSeconds: _t,
31820
+ onCollapse: Gt,
31821
+ onStartVoice: qt,
31822
+ onNewChat: Vt,
31823
+ onMinimize: Rt,
31824
+ onExpand: Lt,
31825
+ isCallMinimized: Dt && !!T,
31826
+ showPoweredBy: Ye,
31822
31827
  getVisitorChatHistory: Ce,
31823
31828
  resumeChat: we,
31824
31829
  isSessionRestoring: Te