@flowengage/react-chatbot 8.0.110 → 8.0.111

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.
@@ -34,43 +34,43 @@ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = Object.g
34
34
  agentName: "flowengage.agentName",
35
35
  agentHeadshot: "flowengage.agentHeadshot",
36
36
  visitorEmail: "flowengage.visitorEmail"
37
- }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", M = (e) => e ? `flowengage.visitorEmail.${e}` : null, re = () => {
37
+ }, ee = 6e4, te = 480 * 60, ne = 3e4, j = typeof window < "u", M = (e) => e ? `flowengage.visitorEmail.${e}` : null, N = () => {
38
38
  if (!j) return null;
39
39
  let e = window.localStorage.getItem(A.chatId);
40
40
  return e && String(e).trim() ? String(e).trim() : null;
41
- }, ie = () => {
41
+ }, re = () => {
42
42
  if (j) try {
43
43
  window.localStorage.removeItem(A.chatId);
44
44
  } catch {}
45
- }, ae = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", N = (e) => e ? `flowengage.entrySeen.${e}` : null, oe = (e) => {
45
+ }, P = () => j ? typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}` : "server-chat-id", ie = (e) => e ? `flowengage.entrySeen.${e}` : null, ae = (e) => {
46
46
  if (!j || !e) return !1;
47
47
  try {
48
- let t = N(e);
48
+ let t = ie(e);
49
49
  return t ? window.localStorage.getItem(t) === "1" : !1;
50
50
  } catch {
51
51
  return !1;
52
52
  }
53
- }, se = (e) => {
53
+ }, oe = (e) => {
54
54
  if (!(!j || !e)) try {
55
- let t = N(e);
55
+ let t = ie(e);
56
56
  t && window.localStorage.setItem(t, "1");
57
57
  } catch {}
58
- }, P = (e) => e ? `flowengage.persistedChatId.${e}` : null, ce = (e) => {
58
+ }, se = (e) => e ? `flowengage.persistedChatId.${e}` : null, ce = (e) => {
59
59
  if (!j || !e) return null;
60
60
  try {
61
- let t = P(e), n = t ? window.localStorage.getItem(t) : null;
61
+ let t = se(e), n = t ? window.localStorage.getItem(t) : null;
62
62
  return n && String(n).trim() ? String(n).trim() : null;
63
63
  } catch {
64
64
  return null;
65
65
  }
66
66
  }, le = (e) => {
67
67
  if (!(!j || !e)) try {
68
- let t = P(e);
68
+ let t = se(e);
69
69
  t && window.localStorage.removeItem(t);
70
70
  } catch {}
71
71
  }, ue = (e, t) => {
72
72
  if (!(!j || !e || !t)) try {
73
- let n = P(e);
73
+ let n = se(e);
74
74
  n && window.localStorage.setItem(n, String(t).trim());
75
75
  } catch {}
76
76
  }, de = () => j ? {
@@ -3296,7 +3296,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3296
3296
  message: "Looks like you're already on this page!",
3297
3297
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3298
3298
  }]);
3299
- }, []), [D, O] = m(de().isOpen), [k, A] = m(de().activeScreen), [j, M] = m(de().isHumanHandled), [N, oe] = m(de().agentName), [se, P] = m(de().agentHeadshot), [he, ge] = m(() => pe(i?.siteId)), [F, ve] = m(!1), [ye, I] = m(!1), [be, L] = m("idle"), [xe, Se] = m(!1), [R, we] = m(!1), [Te, Ee] = m(""), [De, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3299
+ }, []), [D, O] = m(de().isOpen), [k, A] = m(de().activeScreen), [j, M] = m(de().isHumanHandled), [ie, ae] = m(de().agentName), [oe, se] = m(de().agentHeadshot), [he, ge] = m(() => pe(i?.siteId)), [F, ve] = m(!1), [ye, I] = m(!1), [be, L] = m("idle"), [xe, Se] = m(!1), [R, we] = m(!1), [Te, Ee] = m(""), [De, Oe] = m(!1), [ke, Ae] = m(0), [je, Me] = m(0), [z, B] = m(!1), [V, Ie] = m(null), [Le, Re] = m(null), [ze, Be] = m("idle"), [Ve, He] = m(null), [Ue, We] = m(!1), [Ge, Ke] = m(""), [qe, Je] = m(!1), H = p(null), U = p(null), Ye = p(""), Xe = p(!1), Ze = p(null), Qe = p(null), W = p(null), $e = p(null), et = p(null), tt = p(null), nt = p(null), G = p(!1), rt = p({
3300
3300
  url: null,
3301
3301
  at: 0
3302
3302
  }), it = o((e, t) => {
@@ -3313,12 +3313,12 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3313
3313
  url: n,
3314
3314
  at: Date.now()
3315
3315
  }, wr(e, t));
3316
- }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(N), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3316
+ }, []), at = p([]), ot = p(null), st = p(null), ct = p(null), lt = p(!1), ut = p(!1), dt = p(""), ft = p(null), pt = p(null), mt = p([]), ht = p(0), gt = p(ie), _t = p([]), vt = p(!1), yt = p(!1), bt = p(i), xt = p({
3317
3317
  notifyRouteChange: () => {},
3318
3318
  cleanup: () => {}
3319
3319
  }), St = o((e = {}) => {
3320
3320
  let t = !!e.is_human_handled;
3321
- return M(t), t ? (A("agent"), e.agent_info?.name && oe(e.agent_info.name), e.agent_info?.headshot && P(e.agent_info.headshot), t) : (A("ai"), t);
3321
+ return M(t), t ? (A("agent"), e.agent_info?.name && ae(e.agent_info.name), e.agent_info?.headshot && se(e.agent_info.headshot), t) : (A("ai"), t);
3322
3322
  }, []), Ct = f(() => {
3323
3323
  let e = _?.widgetSettings?.call?.maxDurationSeconds ?? i?.widgetSettings?.call?.maxDurationSeconds ?? i?.callMaxDurationSeconds, t = Number(e);
3324
3324
  return Number.isFinite(t) && t > 0 ? t : te;
@@ -3326,8 +3326,8 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3326
3326
  c(() => {
3327
3327
  Qe.current = V;
3328
3328
  }, [V]), c(() => {
3329
- gt.current = N;
3330
- }, [N]), c(() => {
3329
+ gt.current = ie;
3330
+ }, [ie]), c(() => {
3331
3331
  yt.current = De;
3332
3332
  }, [De]), c(() => {
3333
3333
  bt.current = i;
@@ -3482,15 +3482,15 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3482
3482
  isOpen: D,
3483
3483
  activeScreen: k,
3484
3484
  isHumanHandled: j,
3485
- agentName: N,
3486
- agentHeadshot: se
3485
+ agentName: ie,
3486
+ agentHeadshot: oe
3487
3487
  });
3488
3488
  }, [
3489
3489
  D,
3490
3490
  k,
3491
3491
  j,
3492
- N,
3493
- se
3492
+ ie,
3493
+ oe
3494
3494
  ]), c(() => {
3495
3495
  let e = !0;
3496
3496
  return (async () => {
@@ -3505,14 +3505,14 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3505
3505
  apiBaseUrl: t.apiBaseUrl,
3506
3506
  userId: n.userId,
3507
3507
  siteId: a,
3508
- priorChatId: e || r ? null : o || re(),
3508
+ priorChatId: e || r ? null : o || N(),
3509
3509
  forceNew: e,
3510
3510
  resumeChatId: r,
3511
3511
  visitorId: s
3512
3512
  }))?.data?.chatId, !c) throw Error("resolve-session returned no chatId");
3513
- ie(), ue(a, c);
3513
+ re(), ue(a, c);
3514
3514
  } catch (e) {
3515
- console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || ae(), ue(a, c);
3515
+ console.warn("[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id", e?.message || e), c = o || P(), ue(a, c);
3516
3516
  }
3517
3517
  Ye.current = c;
3518
3518
  let l = Fe({
@@ -3578,11 +3578,11 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3578
3578
  ...n,
3579
3579
  isPending: !1,
3580
3580
  id: n.messageId || `${n.sender}-${Date.now()}-${Math.random()}`
3581
- }]), (n.sender === "agent" || n.agent_name) && (M(!0), A("agent"), oe(di([
3581
+ }]), (n.sender === "agent" || n.agent_name) && (M(!0), A("agent"), ae(di([
3582
3582
  n.agent_name,
3583
3583
  n.agentName,
3584
3584
  n.metadata?.agentName
3585
- ], d)), n.sender_headshot && P(n.sender_headshot), O(!0), Ae((e) => e + 1)));
3585
+ ], d)), n.sender_headshot && se(n.sender_headshot), O(!0), Ae((e) => e + 1)));
3586
3586
  });
3587
3587
  let p = (e = {}) => {
3588
3588
  let t = di([
@@ -3591,7 +3591,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3591
3591
  e.agent_name,
3592
3592
  gt.current
3593
3593
  ], d);
3594
- M(!0), A("agent"), oe(t), P(e.agent?.headshot || null), O(!0), Ae((e) => e + 1), S((e) => fi(e, {
3594
+ M(!0), A("agent"), ae(t), se(e.agent?.headshot || null), O(!0), Ae((e) => e + 1), S((e) => fi(e, {
3595
3595
  id: `agent-joined-${Date.now()}`,
3596
3596
  sender: "system",
3597
3597
  message: `${t} has joined the chat.`,
@@ -3646,7 +3646,7 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
3646
3646
  from: e.from || "owner",
3647
3647
  agentId: e.agentId || null,
3648
3648
  agentName: t
3649
- }), oe((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
3649
+ }), ae((e) => di([t, e], "Agent")), Be("incoming"), He(null), O(!0);
3650
3650
  }), f.on("call:offer", async (e = {}) => {
3651
3651
  tt.current = e;
3652
3652
  try {
@@ -4197,9 +4197,9 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4197
4197
  }, []);
4198
4198
  let Yt = o(() => {
4199
4199
  let e = i?.siteId;
4200
- le(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), oe(null), P(null), Je(!0), s((e) => e + 1);
4200
+ le(e), Xe.current = !0, Ze.current = null, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), ae(null), se(null), Je(!0), s((e) => e + 1);
4201
4201
  }, [i?.siteId]), Xt = o((e) => {
4202
- i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), oe(null), P(null), Je(!0), s((e) => e + 1);
4202
+ i?.siteId, Xe.current = !1, Ze.current = e, H.current?.disconnect(), S([]), b(""), Ye.current = "", B(!1), M(!1), ae(null), se(null), Je(!0), s((e) => e + 1);
4203
4203
  }, [i?.siteId]), Zt = f(() => ({
4204
4204
  status: l,
4205
4205
  error: d,
@@ -4210,8 +4210,8 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4210
4210
  isOpen: D,
4211
4211
  activeScreen: k,
4212
4212
  isHumanHandled: j,
4213
- agentName: N,
4214
- agentHeadshot: se,
4213
+ agentName: ie,
4214
+ agentHeadshot: oe,
4215
4215
  visitorEmail: he,
4216
4216
  isAgentTyping: F,
4217
4217
  isAiTyping: ye,
@@ -4271,8 +4271,8 @@ function pi({ siteId: e, config: t, children: n, language: r = "en" }) {
4271
4271
  D,
4272
4272
  k,
4273
4273
  j,
4274
- N,
4275
- se,
4274
+ ie,
4275
+ oe,
4276
4276
  he,
4277
4277
  F,
4278
4278
  ye,
@@ -9354,45 +9354,42 @@ async function _h(e) {
9354
9354
  }
9355
9355
  }, O = (e, t, n) => {
9356
9356
  t && (T.role && T.role !== e && D(), T.role = e, T.text = T.text ? `${T.text} ${t}`.replace(/\s+/g, " ") : t, n && (T.debug = n), T.timer && clearTimeout(T.timer), T.timer = setTimeout(D, rh));
9357
- }, k = !1, A = !1, ee = !1, te = !1, ne = !0, j = !1, M = null, re = !1, ie = !1, ae = () => {
9358
- M && clearTimeout(M);
9357
+ }, k = !1, A = !1, ee = !1, te = !1, ne = !1, j = !0, M = !1, N = null, re = !1, P = !1, ie = () => {
9358
+ N && clearTimeout(N);
9359
9359
  let e = () => {
9360
9360
  if (!k) {
9361
- if (N.isPlaying()) {
9362
- M = setTimeout(e, 150);
9361
+ if (ae.isPlaying()) {
9362
+ N = setTimeout(e, 150);
9363
9363
  return;
9364
9364
  }
9365
- if (M = null, re) {
9365
+ if (N = null, re) {
9366
9366
  p?.();
9367
9367
  return;
9368
9368
  }
9369
- !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), ie && (ie = !1, d?.());
9369
+ !k && C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "PlaybackDrained" })), P && (P = !1, d?.());
9370
9370
  }
9371
9371
  };
9372
- M = setTimeout(e, 150);
9373
- }, N = hh(_, () => {
9374
- te && (te = !1, c?.({ mode: "listening" }));
9372
+ N = setTimeout(e, 150);
9373
+ }, ae = hh(_, () => {
9374
+ te && (te = !1, c?.({ mode: ne ? "thinking" : "listening" }));
9375
9375
  }, v);
9376
- typeof window < "u" && (window.__fe_agentAudioPlaying = () => N.isPlaying());
9376
+ typeof window < "u" && (window.__fe_agentAudioPlaying = () => ae.isPlaying());
9377
9377
  let oe = _.createMediaStreamSource(g);
9378
9378
  oe.connect(v);
9379
- let se = _.createScriptProcessor(nh, 1, 1), P = !1, ce = 0, le = 0;
9379
+ let se = _.createScriptProcessor(nh, 1, 1), ce = !1, le = 0, ue = 0;
9380
9380
  se.onaudioprocess = (e) => {
9381
9381
  if (k || C.readyState !== WebSocket.OPEN) return;
9382
9382
  let t = e.inputBuffer.getChannelData(0), n = () => C.send(new Int16Array(t.length).buffer);
9383
9383
  if (A) {
9384
- ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), P = !1, ce = 0, le = 0, n();
9384
+ ee || (ee = !0, console.debug("[FlowEngage] mic held — streaming silence to keep socket alive")), ce = !1, le = 0, ue = 0, n();
9385
9385
  return;
9386
9386
  }
9387
9387
  let r = sh(t);
9388
- N.isPlaying() || j ? (P = !1, ce = 0, le = 0) : r >= ih ? (le = 0, ce += 1, !P && ce >= ah && (P = !0, c?.({ mode: "user-speaking" }))) : (ce = 0, P && ++le >= oh && (P = !1, le = 0, c?.({
9389
- mode: "thinking",
9390
- tentative: !0
9391
- }))), C.send(ch(t).buffer);
9388
+ ae.isPlaying() || M ? (ce = !1, le = 0, ue = 0) : r >= ih ? (ue = 0, le += 1, !ce && le >= ah && (ce = !0, c?.({ mode: "user-speaking" }))) : (le = 0, ce && ++ue >= oh && (ce = !1, ue = 0)), C.send(ch(t).buffer);
9392
9389
  }, oe.connect(se), se.connect(_.destination);
9393
- let ue = () => {
9390
+ let de = () => {
9394
9391
  if (!k) {
9395
- k = !0, M &&= (clearTimeout(M), null), D(), N.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9392
+ k = !0, N &&= (clearTimeout(N), null), D(), ae.stop(), typeof window < "u" && delete window.__fe_agentAudioPlaying;
9396
9393
  try {
9397
9394
  se.disconnect(), oe.disconnect();
9398
9395
  } catch {}
@@ -9406,7 +9403,7 @@ async function _h(e) {
9406
9403
  } else b.length && ph(t, n, S, b, y);
9407
9404
  _.close().catch(() => {}), (C.readyState === WebSocket.OPEN || C.readyState === WebSocket.CONNECTING) && C.close();
9408
9405
  }
9409
- }, de = async (e) => {
9406
+ }, fe = async (e) => {
9410
9407
  let t = i[e.name];
9411
9408
  if (!t) return u?.({ tool_name: e.name }), { error: `Unknown tool ${e.name}` };
9412
9409
  let n = {};
@@ -9418,10 +9415,10 @@ async function _h(e) {
9418
9415
  } catch (e) {
9419
9416
  return { error: e?.message || "Tool execution failed" };
9420
9417
  }
9421
- }, fe = async (e) => {
9418
+ }, pe = async (e) => {
9422
9419
  for (let t of e.functions || []) {
9423
9420
  if (!t.client_side) continue;
9424
- let e = await de(t);
9421
+ let e = await fe(t);
9425
9422
  if (k || C.readyState !== WebSocket.OPEN) return;
9426
9423
  C.send(JSON.stringify({
9427
9424
  type: "FunctionCallResponse",
@@ -9430,7 +9427,7 @@ async function _h(e) {
9430
9427
  content: typeof e == "string" ? e : JSON.stringify(e ?? {})
9431
9428
  }));
9432
9429
  }
9433
- }, pe = (e) => {
9430
+ }, me = (e) => {
9434
9431
  switch (e.type) {
9435
9432
  case "Welcome":
9436
9433
  Number.isFinite(e.barge_in_rms) && e.barge_in_rms > 0 && e.barge_in_rms, Number.isFinite(e.barge_in_frames) && e.barge_in_frames > 0 && e.barge_in_frames, S = e.session_id || r || n || null, a?.({ conversationId: S });
@@ -9452,28 +9449,28 @@ async function _h(e) {
9452
9449
  break;
9453
9450
  }
9454
9451
  case "UserStartedSpeaking":
9455
- D(), N.stop(), j = !1, ne = !1, te = !1, M && !re && (clearTimeout(M), M = null), ie = !1, c?.({ mode: "listening" });
9452
+ D(), ae.stop(), M = !1, j = !1, te = !1, ne = !1, N && !re && (clearTimeout(N), N = null), P = !1, c?.({ mode: "listening" });
9456
9453
  break;
9457
9454
  case "AgentStartedSpeaking":
9458
- ne = !0, te = !0, c?.({ mode: "speaking" });
9455
+ j = !0, te = !0, c?.({ mode: "speaking" });
9459
9456
  break;
9460
9457
  case "AgentAudioDone":
9461
- j = !1, D(), ae(), N.isPlaying() || (te = !1, c?.({ mode: "listening" }));
9458
+ M = !1, D(), ie(), ae.isPlaying() || (te = !1, c?.({ mode: ne ? "thinking" : "listening" }));
9462
9459
  break;
9463
9460
  case "FunctionCallRequest":
9464
- fe(e);
9461
+ pe(e);
9465
9462
  break;
9466
9463
  case "AgentPreparing":
9467
- j = !0;
9464
+ M = !0;
9468
9465
  break;
9469
9466
  case "AgentTurnComplete":
9470
- ie = !0, ae();
9467
+ ne = !1, P = !0, ie();
9471
9468
  break;
9472
9469
  case "SessionEnding":
9473
9470
  console.debug("[FlowEngage] server is ending the session:", e.reason || "unspecified"), re = !0;
9474
9471
  break;
9475
9472
  case "AgentThinking":
9476
- c?.({ mode: "thinking" });
9473
+ ne = !0, c?.({ mode: "thinking" });
9477
9474
  break;
9478
9475
  case "PromptUpdated": break;
9479
9476
  case "Error":
@@ -9487,16 +9484,16 @@ async function _h(e) {
9487
9484
  };
9488
9485
  return C.onopen = () => C.send(JSON.stringify(h)), C.onmessage = (e) => {
9489
9486
  if (e.data instanceof ArrayBuffer) {
9490
- ne && N.enqueue(new Int16Array(e.data));
9487
+ j && ae.enqueue(new Int16Array(e.data));
9491
9488
  return;
9492
9489
  }
9493
9490
  try {
9494
- pe(JSON.parse(e.data));
9491
+ me(JSON.parse(e.data));
9495
9492
  } catch {}
9496
9493
  }, C.onerror = () => l?.(/* @__PURE__ */ Error("Voice connection failed")), C.onclose = () => {
9497
- ue(), o?.();
9494
+ de(), o?.();
9498
9495
  }, {
9499
- endSession: async () => ue(),
9496
+ endSession: async () => de(),
9500
9497
  sendContextualUpdate: (e) => {
9501
9498
  k || C.readyState !== WebSocket.OPEN || !e || C.send(JSON.stringify({
9502
9499
  type: "UpdatePrompt",
@@ -13355,7 +13352,7 @@ function g_({ copy: e, orbColors: t, primaryColor: n, onVoice: r, onText: i, onC
13355
13352
  }
13356
13353
  function __({ 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...", thinkingLabel: S = "Thinking...", enterChatModeLabel: C = "Enter Chat Mode", endConversationLabel: w = "End Conversation" }) {
13357
13354
  c(() => (console.log("[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED"), () => console.log("[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED")), []);
13358
- let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, re] = m(""), ie = p(!1), ae = p(!1), N = p(null), oe = p(0), se = p(""), P = p(!1), ce = p(0), le = p(!1), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = p(null), he = (e) => {
13355
+ let [T, E] = m("idle"), [D, O] = m(!1), [k, A] = m(!1), [ee, te] = m(!1), [ne, j] = m(""), [M, N] = m(""), re = p(!1), P = p(!1), ie = p(null), ae = p(0), oe = p(""), se = p(!1), ce = p(0), le = p(!1), ue = p(!1), de = p(!1), fe = p([]), pe = p(null), me = p(null), he = (e) => {
13359
13356
  le.current = e, e || (ue.current = !1), F.current?.setWalkthroughActive?.(e);
13360
13357
  };
13361
13358
  me.current = async () => {
@@ -13402,24 +13399,24 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13402
13399
  I.current || (I.current = !0, ye.current?.());
13403
13400
  });
13404
13401
  }, [l]), V = o(() => {
13405
- N.current &&= (clearTimeout(N.current), null);
13402
+ ie.current &&= (clearTimeout(ie.current), null);
13406
13403
  }, []);
13407
13404
  c(() => {
13408
13405
  if (y) {
13409
- ie.current = !1;
13406
+ re.current = !1;
13410
13407
  return;
13411
13408
  }
13412
- if (ie.current = !0, ae.current = !1, te(!1), V(), P.current) {
13413
- P.current = !1, F.current?.setMicMuted?.(!1);
13414
- let e = se.current;
13415
- se.current = "", F.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && F.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13409
+ if (re.current = !0, P.current = !1, te(!1), V(), se.current) {
13410
+ se.current = !1, F.current?.setMicMuted?.(!1);
13411
+ let e = oe.current;
13412
+ oe.current = "", F.current?.injectAgentSpeech?.("Thanks — I already have your email on file.", "interrupt"), e && F.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`);
13416
13413
  }
13417
13414
  F.current?.sendContextualUpdate?.("EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.");
13418
13415
  }, [y, V]);
13419
13416
  let Ie = /(walk\s*(me\s*)?through|walkthrough|take me through|(complete|full|detailed) (overview|understanding|walkthrough|picture|breakdown|explanation)|give me (a|an|the) (overview|tour|walk)|tell me about (each|all)|go through (it|them|each|all)|overview of|one by one|tell me everything|explain (me )?(this|the) (whole |entire |full )?page|everything (about|on) this page|show me (each|all|around))/i, Le = /(that covers everything|that was all|covered everything|that(?:'|’)?s everything)/i, Re = /^((uh+|um+|so|well|okay|ok|yeah)[,.\s]+)*(yes|yeah|yep|yup|sure|ok(ay)?|please|continue|go on|next|keep going|carry on|go ahead|resume|back to the tour)[\s.!,]*$/i, ze = /^((uh+|um+|oh|ah|so|well)[,.\s]+)*(cool|nice|great|awesome|wow|lovely|perfect|got it|gotcha|i see|understood|makes sense|interesting|right|alright|sounds good|mm+-?hmm+|hmm+|k)[\s.!,]*$/i, Be = (e) => String(e || "").replace(/[\s.,!?]*((uh+|um+|er+|hmm+|mm+)[\s.,!?]*)+$/i, "").trim(), Ve = o(() => {
13420
- V(), N.current = setTimeout(() => {
13421
- if (!(!ae.current || ie.current)) if (oe.current < 3) {
13422
- oe.current += 1;
13417
+ V(), ie.current = setTimeout(() => {
13418
+ if (!(!P.current || re.current)) if (ae.current < 3) {
13419
+ ae.current += 1;
13423
13420
  try {
13424
13421
  F.current?.injectAgentSpeech?.("I still need your email in the box below to continue — could you enter it, please?", "queue");
13425
13422
  } catch {}
@@ -13428,7 +13425,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13428
13425
  try {
13429
13426
  F.current?.injectAgentSpeech?.("Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!", "queue");
13430
13427
  } catch {}
13431
- ae.current = !1, te(!1), V(), Me.current = !0;
13428
+ P.current = !1, te(!1), V(), Me.current = !0;
13432
13429
  }
13433
13430
  }, 1e4);
13434
13431
  }, [V]), He = o(async (e) => {
@@ -13514,7 +13511,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13514
13511
  Me.current = !0;
13515
13512
  },
13516
13513
  requestEmailCollection: () => {
13517
- b && (ie.current || ae.current || (ae.current = !0, oe.current = 0, te(!0), Ve()));
13514
+ b && (re.current || P.current || (P.current = !0, ae.current = 0, te(!0), Ve()));
13518
13515
  }
13519
13516
  })), n = i ? xe(i) : null, r = !!n?.transcript, u = i ? je(i) : null, p = !!u, m = typeof window < "u" ? window.location.pathname : "/", g = typeof document < "u" ? document.title : "", _ = m.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/", v = _ === "/" || _ === "", x = {
13520
13517
  apiBaseUrl: a,
@@ -13549,17 +13546,17 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13549
13546
  let e = f || "";
13550
13547
  x.greeting = h || (v ? e ? `Hi, welcome to ${e}! How may I help you?` : "Hi, welcome! How may I help you?" : `Welcome to ${T}! How may I help you?`), v || console.log(`[FlowEngage] 🏠 Page-context greeting: "${w}" for ${m}`);
13551
13548
  }
13552
- let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, re = !1, N = M ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, ye = !1, Se = !1, ke = b && !!y && !de.current, He = await vh.startSession({
13549
+ let A = !1, ee = p ? `NAVIGATION COMPLETE — The exact phrase "I have navigated you to the [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.` : null, ne = !1, j = !p && !r ? "Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead." : null, M = r && !p, N = !1, ie = M ? `The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript ? `Prior transcript:\n${n.transcript}\n` : "(no prior transcript, or the visitor navigated before saying much)"}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.` : null, ye = !1, Se = !1, ke = b && !!y && !de.current, He = await vh.startSession({
13553
13550
  ...x,
13554
13551
  onConnect: ({ conversationId: e }) => {
13555
13552
  Ee.current = e, De.current = Date.now(), console.log("[FlowEngage] 🎙️ AI chat session connected:", e);
13556
13553
  },
13557
13554
  onUnhandledClientToolCall: (e) => console.error("[FlowEngage] Unhandled tool:", e?.tool_name),
13558
13555
  onSessionInfo: ({ emailOnFile: e }) => {
13559
- de.current = !!e, e && (ie.current = !0, ae.current = !1, te(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13556
+ de.current = !!e, e && (re.current = !0, P.current = !1, te(!1), V(), console.log("[FlowEngage] email already on file per server — gate disabled"));
13560
13557
  },
13561
13558
  onAgentTurnEnd: () => {
13562
- e || le.current && (ue.current || P.current || setTimeout(() => me.current?.(), 250));
13559
+ e || le.current && (ue.current || se.current || setTimeout(() => me.current?.(), 250));
13563
13560
  },
13564
13561
  onSessionEnding: () => {
13565
13562
  e || B("minimized");
@@ -13571,7 +13568,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13571
13568
  return;
13572
13569
  }
13573
13570
  if (t === "user-speaking") {
13574
- if (ae.current && !ie.current && Ve(), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13571
+ if (P.current && !re.current && Ve(), Fe.current &&= (clearTimeout(Fe.current), null), z.current === "speaking") return;
13575
13572
  try {
13576
13573
  On();
13577
13574
  } catch {}
@@ -13589,7 +13586,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13589
13586
  Me.current = !1, B();
13590
13587
  return;
13591
13588
  }
13592
- if (ke && !Se && !ie.current && !de.current) {
13589
+ if (ke && !Se && !re.current && !de.current) {
13593
13590
  Se = !0, A = !0, ne = !0;
13594
13591
  try {
13595
13592
  F.current?.sendContextualUpdate?.("CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. The app itself speaks the email request out loud — you must NOT say it, and you must NOT answer. Stay completely silent from now until you receive an EMAIL_SAVED message: produce no speech and call no tools, no matter what the visitor says. Remember their question. On EMAIL_SAVED, thank them briefly and answer that remembered question in full.");
@@ -13601,10 +13598,10 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13601
13598
  F.current?.sendContextualUpdate?.(ee);
13602
13599
  } catch {}
13603
13600
  }
13604
- if (N && !re) {
13605
- re = !0;
13601
+ if (ie && !N) {
13602
+ N = !0;
13606
13603
  try {
13607
- F.current?.sendContextualUpdate?.(N);
13604
+ F.current?.sendContextualUpdate?.(ie);
13608
13605
  } catch {}
13609
13606
  }
13610
13607
  if (j && !ne) {
@@ -13619,7 +13616,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13619
13616
  }
13620
13617
  },
13621
13618
  onMessage: (t) => {
13622
- if (e || P.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13619
+ if (e || se.current && t.role !== "user" && !/email/i.test(String(t.message || ""))) return;
13623
13620
  let n = t.role === "user" && /^(Describe the section titled "|\[SYSTEM:|Give the visitor a complete spoken overview|That was the last section)/.test(String(t.message || "").trim()), r = /\b(?:this|that|the)\s+(?:case\s*stud(?:y|ies)|product|article|blog|post|item|service)\b/i.test(String(t.message || ""));
13624
13621
  if (!n && !r && t.role === "user" && Ie.test(String(t.message || ""))) typeof window < "u" && (window.__fe_user_nav_during_speech = null), he(!0), ue.current = !1, ce.current = 0, ge.current = -1, fe.current = r_(), pe.current = typeof window < "u" ? window.location.pathname : null, setTimeout(() => me.current?.(), 400), console.log(`[FlowEngage] walkthrough armed — ${fe.current.length} sections on this page`);
13625
13622
  else if (!n && t.role === "user" && le.current) {
@@ -13632,7 +13629,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13632
13629
  }
13633
13630
  let a = t.role === "user" ? "user" : "bot", o = t.message || t.text || t.content || "";
13634
13631
  if (o) {
13635
- if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), ke && !ye && !ie.current && !de.current && (ye = !0, se.current = o, P.current = !0, F.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), F.current?.setMicMuted?.(!0), ae.current || (ae.current = !0, oe.current = 0, te(!0), Ve()))), l.current = [...l.current, {
13632
+ if (a === "user" && (ve.current = o, typeof window < "u" && (window.__fe_user_nav_during_speech = null), Pe.current = !0, Ne.current &&= (clearTimeout(Ne.current), null), z.current !== "speaking" && (E("thinking"), z.current = "thinking"), ke && !ye && !re.current && !de.current && (ye = !0, oe.current = o, se.current = !0, F.current?.injectAgentSpeech?.("Before I answer that, could you please enter your email in the text box below?", "interrupt"), F.current?.setMicMuted?.(!0), P.current || (P.current = !0, ae.current = 0, te(!0), Ve()))), l.current = [...l.current, {
13636
13633
  sender: a,
13637
13634
  message: o,
13638
13635
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -13776,7 +13773,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13776
13773
  if (i) try {
13777
13774
  je(i);
13778
13775
  } catch {}
13779
- typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), N.current &&= (clearTimeout(N.current), null), Pe.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13776
+ typeof window < "u" && (window.__fe_user_nav_during_speech = null), Or(), Ne.current &&= (clearTimeout(Ne.current), null), Fe.current &&= (clearTimeout(Fe.current), null), ie.current &&= (clearTimeout(ie.current), null), Pe.current = !1, z.current = "idle", c && typeof window < "u" && (window.history.pushState = c), d && typeof window < "u" && window.removeEventListener("popstate", d);
13780
13777
  let t = o || F.current, n = Ee.current, f = De.current;
13781
13778
  if (t?.endSession?.().catch(() => {}), n && s && a) {
13782
13779
  let e = f ? Math.round((Date.now() - f) / 1e3) : 0, t = JSON.stringify({
@@ -13825,16 +13822,16 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13825
13822
  e?.preventDefault?.();
13826
13823
  let t = ne.trim().toLowerCase();
13827
13824
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
13828
- re("Please enter a valid email address.");
13825
+ N("Please enter a valid email address.");
13829
13826
  return;
13830
13827
  }
13831
- re(""), ie.current = !0, ae.current = !1, V(), te(!1), j(""), P.current = !1;
13828
+ N(""), re.current = !0, P.current = !1, V(), te(!1), j(""), se.current = !1;
13832
13829
  try {
13833
13830
  typeof v == "function" && await v(t);
13834
13831
  } catch {}
13835
13832
  F.current?.setMicMuted?.(!1);
13836
- let n = se.current;
13837
- se.current = "";
13833
+ let n = oe.current;
13834
+ oe.current = "";
13838
13835
  try {
13839
13836
  F.current?.injectAgentSpeech?.("Thank you for submitting your email."), F.current?.sendUserMessage?.(n || "The visitor's email is on file. Carry on helping them and never ask for it again.");
13840
13837
  } catch {}
@@ -13888,7 +13885,7 @@ function __({ orbColors: e, onEnterChat: t, onEndChat: n, agentId: r, siteId: i,
13888
13885
  autoFocus: !0,
13889
13886
  value: ne,
13890
13887
  onChange: (e) => {
13891
- j(e.target.value), M && re("");
13888
+ j(e.target.value), M && N("");
13892
13889
  },
13893
13890
  placeholder: "you@example.com",
13894
13891
  style: {
@@ -14237,7 +14234,7 @@ var y_ = () => /* @__PURE__ */ g("div", {
14237
14234
  } }, e))
14238
14235
  })
14239
14236
  });
14240
- function b_({ 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: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: re, emailCaptureSuccess: ie, replyContext: ae, setReplyContext: N, webRTCError: oe, micError: se, setMicError: P, dismissCallError: ce, activeCallId: le, isCallMuted: ue, toggleCallMute: de, endWebRTCCall: fe, formatCallDuration: pe, callDurationSeconds: me, isCallMinimized: he, onExpand: ge, onCollapse: F, onStartVoice: _e, voiceEnabled: ve, headerBgColor: ye, onNewChat: I, showPoweredBy: be, privacyPolicyUrl: L, getVisitorChatHistory: xe, resumeChat: Se, isSessionRestoring: R, isClosing: Ce }) {
14237
+ function b_({ 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: D, selectedFile: O, onFileSelect: k, onRemoveSelectedFile: A, attachmentError: ee, isUploadingAttachment: te, requiresEmail: ne, emailInput: j, setEmailInput: M, emailError: N, emailCaptureSuccess: re, replyContext: P, setReplyContext: ie, webRTCError: ae, micError: oe, setMicError: se, dismissCallError: ce, activeCallId: le, isCallMuted: ue, toggleCallMute: de, endWebRTCCall: fe, formatCallDuration: pe, callDurationSeconds: me, isCallMinimized: he, onExpand: ge, onCollapse: F, onStartVoice: _e, voiceEnabled: ve, headerBgColor: ye, onNewChat: I, showPoweredBy: be, privacyPolicyUrl: L, getVisitorChatHistory: xe, resumeChat: Se, isSessionRestoring: R, isClosing: Ce }) {
14241
14238
  let we = l.length > 0, Te = T || E || w, Ee = !!le, [De, Oe] = m(!1), [ke, Ae] = m(!1), [je, Me] = m([]), [z, Ne] = m(!1), Pe = p(null), [Fe, B] = m(() => typeof window < "u" ? window.visualViewport?.height ?? window.innerHeight : 600), [V, Ie] = m(0);
14242
14239
  c(() => {
14243
14240
  if (!s) return;
@@ -14674,9 +14671,9 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14674
14671
  ]
14675
14672
  }),
14676
14673
  /* @__PURE__ */ g(Zh, {
14677
- webRTCError: oe,
14678
- micError: se,
14679
- setMicError: P,
14674
+ webRTCError: ae,
14675
+ micError: oe,
14676
+ setMicError: se,
14680
14677
  dismissCallError: ce,
14681
14678
  isRateLimited: E,
14682
14679
  rateLimitMessage: D
@@ -14820,7 +14817,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14820
14817
  isAiTyping: u,
14821
14818
  isLoading: T,
14822
14819
  isAgentTyping: d,
14823
- setReplyContext: N,
14820
+ setReplyContext: ie,
14824
14821
  TypingDots: y_,
14825
14822
  primaryColor: n,
14826
14823
  agentHeadshot: y,
@@ -14916,7 +14913,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14916
14913
  ]
14917
14914
  })]
14918
14915
  }),
14919
- ie && /* @__PURE__ */ _("div", {
14916
+ re && /* @__PURE__ */ _("div", {
14920
14917
  style: {
14921
14918
  margin: "0 16px 8px",
14922
14919
  padding: "9px 14px",
@@ -14967,8 +14964,8 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14967
14964
  showVoiceToggle: f === "agent",
14968
14965
  activeScreen: f,
14969
14966
  inputDisabled: Te,
14970
- replyContext: ae,
14971
- clearReplyContext: () => N(null),
14967
+ replyContext: P,
14968
+ clearReplyContext: () => ie(null),
14972
14969
  onFileSelect: k,
14973
14970
  selectedFile: O,
14974
14971
  onRemoveSelectedFile: A,
@@ -14977,7 +14974,7 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
14977
14974
  requiresEmail: ne,
14978
14975
  emailInput: j,
14979
14976
  setEmailInput: M,
14980
- emailError: re,
14977
+ emailError: N,
14981
14978
  inputPlaceholder: e.inputPlaceholder
14982
14979
  })
14983
14980
  }),
@@ -15032,13 +15029,13 @@ function b_({ copy: e, orbColors: t, primaryColor: n, chatBgGradient: r, logo: i
15032
15029
  });
15033
15030
  }
15034
15031
  function x_() {
15035
- 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: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: M, openWidget: re, captureVisitorEmail: ie, setVoiceMode: ae, endConversation: N, startNewChat: P, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: F, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = Cn();
15032
+ 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: D, isCallMuted: O, webRTCError: k, language: A, chatId: ee, historyRef: te, onMessageSync: ne, sendMessage: j, uploadChatFile: M, openWidget: N, captureVisitorEmail: re, setVoiceMode: P, endConversation: ie, startNewChat: se, acceptCall: ce, rejectCall: le, endWebRTCCall: ue, toggleCallMute: de, dismissCallError: fe, startTyping: pe, stopTyping: me, updateTypingDraft: he, getVisitorChatHistory: ge, resumeChat: F, isSessionRestoring: _e, openToChatCounter: ve, voiceEndCounter: ye } = Cn();
15036
15033
  c(() => {
15037
15034
  try {
15038
15035
  or();
15039
15036
  } catch {}
15040
15037
  }, []), c(() => {
15041
- ve && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (ae?.(!1), $e("text_chat"));
15038
+ ve && W !== "voice_mode" && W !== "text_chat" && W !== "call_screen" && (P?.(!1), $e("text_chat"));
15042
15039
  }, [ve]);
15043
15040
  let I = t?.widgetSettings || {}, be = n?.widgetSettings || {}, L = {
15044
15041
  ...I.branding || {},
@@ -15111,11 +15108,11 @@ function x_() {
15111
15108
  } catch {}
15112
15109
  let n = we(), r = Je ? xe(Je) : null, i = n || !!r?.transcript;
15113
15110
  if (t) {
15114
- re?.({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15111
+ N?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15115
15112
  return;
15116
15113
  }
15117
15114
  if (De()) {
15118
- re?.({ notifyChatInitiated: !1 }), $e("text_chat");
15115
+ N?.({ notifyChatInitiated: !1 }), $e("text_chat");
15119
15116
  return;
15120
15117
  }
15121
15118
  if (i) {
@@ -15123,13 +15120,13 @@ function x_() {
15123
15120
  $e("minimized_orb");
15124
15121
  return;
15125
15122
  }
15126
- re?.({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15123
+ N?.({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15127
15124
  return;
15128
15125
  }
15129
15126
  if (Je) try {
15130
15127
  Se(Je);
15131
15128
  } catch {}
15132
- if (oe(Je)) {
15129
+ if (ae(Je)) {
15133
15130
  $e("minimized_orb");
15134
15131
  return;
15135
15132
  }
@@ -15187,7 +15184,7 @@ function x_() {
15187
15184
  hasIncomingCall: !!w?.callId,
15188
15185
  activeCallId: T,
15189
15186
  callConnectionState: E
15190
- }), Ct.current = e, W === "voice_mode" && ae?.(!1), re?.(), At());
15187
+ }), Ct.current = e, W === "voice_mode" && P?.(!1), N?.(), At());
15191
15188
  }
15192
15189
  }, [
15193
15190
  T,
@@ -15195,8 +15192,8 @@ function x_() {
15195
15192
  At,
15196
15193
  w?.callId,
15197
15194
  i,
15198
- re,
15199
- ae,
15195
+ N,
15196
+ P,
15200
15197
  W
15201
15198
  ]), c(() => {
15202
15199
  !w && !T && W === "call_screen" && $e("text_chat");
@@ -15242,7 +15239,7 @@ function x_() {
15242
15239
  ot("Please enter a valid email so we can continue helping you.");
15243
15240
  return;
15244
15241
  }
15245
- await ie(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
15242
+ await re(e), ot(""), ct(!0), setTimeout(() => ct(!1), 3e3);
15246
15243
  return;
15247
15244
  }
15248
15245
  let t = Mt(nt);
@@ -15270,8 +15267,8 @@ function x_() {
15270
15267
  let n = et.trim();
15271
15268
  tt(""), G(null), await j(n, "", t);
15272
15269
  }, Pt = o(() => {
15273
- r.length !== 0 && P?.();
15274
- }, [r.length, P]), Ft = (e) => {
15270
+ r.length !== 0 && se?.();
15271
+ }, [r.length, se]), Ft = (e) => {
15275
15272
  let t = Math.floor(e / 60);
15276
15273
  return `${String(t).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
15277
15274
  }, It = o(async (e) => {
@@ -15327,11 +15324,11 @@ function x_() {
15327
15324
  t.resume().catch(() => {}), setTimeout(() => t.close().catch(() => {}), 3e3);
15328
15325
  }
15329
15326
  } catch {}
15330
- re({ notifyChatInitiated: !0 }), ae?.(!0), $e("voice_mode");
15327
+ N({ notifyChatInitiated: !0 }), P?.(!0), $e("voice_mode");
15331
15328
  }, Vt = () => {
15332
- re({ notifyChatInitiated: !0 }), ae?.(!1), $e("text_chat");
15329
+ N({ notifyChatInitiated: !0 }), P?.(!1), $e("text_chat");
15333
15330
  }, Ht = () => {
15334
- ae?.(!1), Rt();
15331
+ P?.(!1), Rt();
15335
15332
  };
15336
15333
  return e !== "ready" || !Be || Ce.chat === !1 || !We ? null : /* @__PURE__ */ _("div", {
15337
15334
  className: "flowengage-widget-root",
@@ -15348,10 +15345,10 @@ function x_() {
15348
15345
  orbColors: Ee,
15349
15346
  primaryColor: Oe,
15350
15347
  onYes: () => {
15351
- se(Je), Bt();
15348
+ oe(Je), Bt();
15352
15349
  },
15353
15350
  onLater: () => {
15354
- se(Je), Rt();
15351
+ oe(Je), Rt();
15355
15352
  },
15356
15353
  isMobile: Et,
15357
15354
  isClosing: xt
@@ -15455,7 +15452,7 @@ function x_() {
15455
15452
  voiceEndCounter: ye,
15456
15453
  websiteName: t?.websiteName,
15457
15454
  voiceFirstMessage: I.voiceFirstMessage || null,
15458
- captureVisitorEmail: ie,
15455
+ captureVisitorEmail: re,
15459
15456
  emailRequired: !h,
15460
15457
  emailCaptureEnabled: Ce.emailCapture !== !1 && L.disableEmailCapture !== !0,
15461
15458
  listeningLabel: L.voiceListeningLabel || "Listening...",