@eloquentai/chat-sdk 0.35.0-dev.5 → 0.35.0-dev.6

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.
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { L as Ct, c as Xe, u as St, g as rt, X as It, i as zt, A as Et, d as J, e as je, f as Rt, h as Pt, r as Tt, t as Mt, j as Ot, N as Ye, k as Oe, l as At, H as Ut, w as nt, m as jt, s as Dt, n as $t, o as Bt, E as Nt, p as Lt, S as Zt, C as Kt, T as Ht } from "./skeleton-CVt31tEo.js";
2
+ import { L as Ct, c as Xe, u as St, g as rt, X as It, i as zt, A as Et, d as W, e as je, f as Rt, h as Pt, r as Tt, t as Mt, j as Ot, N as Ye, k as Oe, l as At, H as Ut, w as nt, m as jt, s as Dt, n as $t, o as Bt, E as Nt, p as Lt, S as Zt, C as Kt, T as Ht } from "./skeleton-Bjh-b-YT.js";
3
3
  import { jsx as q, jsxs as ze, Fragment as at } from "react/jsx-runtime";
4
- import { useState as C, useEffect as H, useMemo as Fe, useCallback as v, useRef as K } from "react";
4
+ import { useState as C, useEffect as K, useMemo as Fe, useCallback as v, useRef as Z } from "react";
5
5
  import { createPortal as Je } from "react-dom";
6
6
  import Vt from "react-dom/client";
7
7
  try {
8
8
  let t = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, e = new t.Error().stack;
9
- e && (t._sentryDebugIds = t._sentryDebugIds || {}, t._sentryDebugIds[e] = "c8ed81b1-fc87-491c-aac1-fa40c3cea5e4", t._sentryDebugIdIdentifier = "sentry-dbid-c8ed81b1-fc87-491c-aac1-fa40c3cea5e4");
9
+ e && (t._sentryDebugIds = t._sentryDebugIds || {}, t._sentryDebugIds[e] = "cac8a06c-1fa8-454e-89a9-c247b981a306", t._sentryDebugIdIdentifier = "sentry-dbid-cac8a06c-1fa8-454e-89a9-c247b981a306");
10
10
  } catch {
11
11
  }
12
12
  if (typeof window < "u") {
@@ -70,7 +70,7 @@ function Gt({
70
70
  autoHideDelay: n
71
71
  }) {
72
72
  const [i, d] = C(!1), [s, c] = C("entering"), a = St();
73
- return H(() => {
73
+ return K(() => {
74
74
  if (e) {
75
75
  d(!0), c("entering");
76
76
  const l = setTimeout(() => {
@@ -371,27 +371,27 @@ function po(t) {
371
371
  f(w instanceof Error ? w : new Error(String(w)));
372
372
  return;
373
373
  }
374
- let h = "connecting", p = !1, g = io, x = Date.now(), b = null, z = null;
375
- const A = () => {
376
- b && (clearTimeout(b), b = null), z && (clearInterval(z), z = null);
374
+ let h = "connecting", p = !1, g = io, k = Date.now(), b = null, I = null;
375
+ const j = () => {
376
+ b && (clearTimeout(b), b = null), I && (clearInterval(I), I = null);
377
377
  }, _ = (w) => {
378
378
  if (h === "closed") return;
379
379
  const y = h === "established";
380
- h = "closed", A();
380
+ h = "closed", j();
381
381
  try {
382
382
  u.close();
383
383
  } catch {
384
384
  }
385
385
  p || (y ? i(w) : f(new Error(w)));
386
- }, I = (w) => {
386
+ }, z = (w) => {
387
387
  u.readyState === lo && u.send(JSON.stringify(w));
388
- }, R = (w) => {
388
+ }, E = (w) => {
389
389
  b && clearTimeout(b), b = setTimeout(() => {
390
390
  _(`Timed out waiting for ${w}`);
391
391
  }, ao);
392
392
  };
393
393
  u.addEventListener("open", () => {
394
- h !== "closed" && (I({ type: "connection_init" }), R("connection_ack"));
394
+ h !== "closed" && (z({ type: "connection_init" }), E("connection_ack"));
395
395
  }), u.addEventListener("message", (w) => {
396
396
  if (h === "closed") return;
397
397
  let y;
@@ -404,12 +404,12 @@ function po(t) {
404
404
  switch (y.type) {
405
405
  case "connection_ack": {
406
406
  if (h !== "connecting") return;
407
- h = "subscribing", typeof y.connectionTimeoutMs == "number" && (g = y.connectionTimeoutMs), I({
407
+ h = "subscribing", typeof y.connectionTimeoutMs == "number" && (g = y.connectionTimeoutMs), z({
408
408
  type: "subscribe",
409
409
  id: a,
410
410
  channel: r,
411
411
  authorization: s
412
- }), R("subscribe_success");
412
+ }), E("subscribe_success");
413
413
  return;
414
414
  }
415
415
  case "connection_error": {
@@ -418,11 +418,11 @@ function po(t) {
418
418
  }
419
419
  case "subscribe_success": {
420
420
  if (h !== "subscribing" || y.id !== a) return;
421
- h = "established", b && (clearTimeout(b), b = null), x = Date.now(), z = setInterval(() => {
422
- Date.now() - x > g && _("Keep-alive timeout");
421
+ h = "established", b && (clearTimeout(b), b = null), k = Date.now(), I = setInterval(() => {
422
+ Date.now() - k > g && _("Keep-alive timeout");
423
423
  }, so), l({
424
424
  close: () => {
425
- p = !0, I({ type: "unsubscribe", id: a }), _("Closed by client");
425
+ p = !0, z({ type: "unsubscribe", id: a }), _("Closed by client");
426
426
  }
427
427
  });
428
428
  return;
@@ -433,23 +433,23 @@ function po(t) {
433
433
  return;
434
434
  }
435
435
  case "ka": {
436
- x = Date.now();
436
+ k = Date.now();
437
437
  return;
438
438
  }
439
439
  case "data": {
440
440
  if (y.id !== a) return;
441
- x = Date.now();
442
- let P = y.event;
443
- if (typeof P == "string")
441
+ k = Date.now();
442
+ let M = y.event;
443
+ if (typeof M == "string")
444
444
  try {
445
- P = JSON.parse(P);
445
+ M = JSON.parse(M);
446
446
  } catch {
447
447
  console.warn(
448
448
  "[EloquentChatSDK] Unparseable realtime event ignored"
449
449
  );
450
450
  return;
451
451
  }
452
- n(P);
452
+ n(M);
453
453
  return;
454
454
  }
455
455
  case "broadcast_error": {
@@ -517,7 +517,7 @@ function wo(t, e, o) {
517
517
  const r = new t._zod.constr(e ?? t._zod.def);
518
518
  return (!e || o?.parent) && (r._zod.parent = t), r;
519
519
  }
520
- function be(t) {
520
+ function ve(t) {
521
521
  const e = t;
522
522
  if (!e)
523
523
  return {};
@@ -533,7 +533,7 @@ function be(t) {
533
533
  function qo(t) {
534
534
  return Object.keys(t).filter((e) => t[e]._zod.optin !== void 0 && t[e]._zod.optout === "optional");
535
535
  }
536
- function me(t, e = 0) {
536
+ function be(t, e = 0) {
537
537
  if (t.aborted === !0)
538
538
  return !0;
539
539
  for (let o = e; o < t.issues.length; o++)
@@ -563,7 +563,7 @@ function lt(t, e, o) {
563
563
  for (let n = e; n < t.length; n++)
564
564
  (r = t[n]).schema ?? (r.schema = o);
565
565
  }
566
- function ve(t, e, o) {
566
+ function we(t, e, o) {
567
567
  var r;
568
568
  const n = t.inst?._zod?.traits;
569
569
  n?.has("$ZodType") && (n.has("$ZodCheck") ? (r = t).schema ?? (r.schema = t.inst) : t.schema = t.inst);
@@ -599,14 +599,14 @@ function Co(t, e) {
599
599
  const o = Object.getPrototypeOf(t);
600
600
  return e in o ? void 0 : o;
601
601
  }
602
- let He, he = !1;
602
+ let He, pe = !1;
603
603
  const So = {
604
604
  configurable: !0,
605
605
  get() {
606
- he = !0;
606
+ pe = !0;
607
607
  }
608
608
  };
609
- function de(t, e, o) {
609
+ function he(t, e, o) {
610
610
  const r = Object.getPrototypeOf(t._zod);
611
611
  if (e in r && He !== t._zod) {
612
612
  He = void 0;
@@ -616,13 +616,13 @@ function de(t, e, o) {
616
616
  configurable: !0,
617
617
  get() {
618
618
  Object.defineProperty(this, e, So);
619
- const n = he;
620
- he = !1;
619
+ const n = pe;
620
+ pe = !1;
621
621
  try {
622
622
  const i = o(this);
623
- return he ? delete this[e] : Object.defineProperty(this, e, { configurable: !0, writable: !0, value: i }), he = he || n, i;
623
+ return pe ? delete this[e] : Object.defineProperty(this, e, { configurable: !0, writable: !0, value: i }), pe = pe || n, i;
624
624
  } catch (i) {
625
- throw delete this[e], he = he || n, i;
625
+ throw delete this[e], pe = pe || n, i;
626
626
  }
627
627
  },
628
628
  set(n) {
@@ -665,7 +665,7 @@ function zo(t) {
665
665
  }
666
666
  return new t();
667
667
  }
668
- function V(t, e, o, r) {
668
+ function H(t, e, o, r) {
669
669
  const n = {};
670
670
  function i(u) {
671
671
  this.def = u, this.constr = f, this.traits = /* @__PURE__ */ new Set();
@@ -685,12 +685,12 @@ function V(t, e, o, r) {
685
685
  }
686
686
  }
687
687
  if (u._zod.traits.add(t), e(u, h), s) {
688
- const g = Object.getPrototypeOf(u), x = u._zod.constr.prototype;
688
+ const g = Object.getPrototypeOf(u), k = u._zod.constr.prototype;
689
689
  let b = g;
690
- for (; b && b !== x; )
690
+ for (; b && b !== k; )
691
691
  b = Object.getPrototypeOf(b);
692
- const z = b ?? g;
693
- s.has(z) || (s.add(z), xo(z, d));
692
+ const I = b ?? g;
693
+ s.has(I) || (s.add(I), xo(I, d));
694
694
  }
695
695
  const p = f.prototype;
696
696
  for (const g in p)
@@ -705,8 +705,8 @@ function V(t, e, o, r) {
705
705
  c(h, u);
706
706
  const p = h._zod.deferred;
707
707
  if (p) {
708
- for (const x of p)
709
- x();
708
+ for (const k of p)
709
+ k();
710
710
  h._zod.deferred = void 0;
711
711
  }
712
712
  const g = globalThis.__zod_globalConfig?.postProcessor;
@@ -723,7 +723,7 @@ class Ie extends Error {
723
723
  }
724
724
  (ct = globalThis).__zod_globalConfig ?? (ct.__zod_globalConfig = {});
725
725
  const Ae = globalThis.__zod_globalConfig;
726
- function pe(t) {
726
+ function fe(t) {
727
727
  return t && Object.assign(Ae, t), Ae;
728
728
  }
729
729
  function Eo() {
@@ -752,7 +752,7 @@ const Po = {
752
752
  Object.defineProperty(this, "toString", { value: r, configurable: !0, writable: !0 });
753
753
  }
754
754
  }));
755
- }, De = V("$ZodError", To, void 0, {
755
+ }, De = H("$ZodError", To, void 0, {
756
756
  Parent: Error
757
757
  }), Mo = (t) => {
758
758
  const e = (o, r, n, i) => {
@@ -760,7 +760,7 @@ const Po = {
760
760
  if (s instanceof Promise)
761
761
  throw new Ie();
762
762
  if (s.issues.length) {
763
- const c = new (i?.Err ?? t)(s.issues.map((a) => ve(a, d, pe())));
763
+ const c = new (i?.Err ?? t)(s.issues.map((a) => we(a, d, fe())));
764
764
  throw bt(c, i?.callee ?? e), c;
765
765
  }
766
766
  return s.value;
@@ -771,7 +771,7 @@ const Po = {
771
771
  const d = n ? { ...n, async: !0 } : { async: !0 };
772
772
  let s = o._zod.run({ value: r, issues: [] }, d);
773
773
  if (s instanceof Promise && (s = await s), s.issues.length) {
774
- const c = new (i?.Err ?? t)(s.issues.map((a) => ve(a, d, pe())));
774
+ const c = new (i?.Err ?? t)(s.issues.map((a) => we(a, d, fe())));
775
775
  throw bt(c, i?.callee ?? e), c;
776
776
  }
777
777
  return s.value;
@@ -788,7 +788,7 @@ function vt(t, e, o) {
788
788
  return {
789
789
  success: !1,
790
790
  get error() {
791
- return r || (r = new t(e.map((n) => ve(n, o, pe()))), e = void 0, o = void 0), r;
791
+ return r || (r = new t(e.map((n) => we(n, o, fe()))), e = void 0, o = void 0), r;
792
792
  },
793
793
  set error(n) {
794
794
  r = n, e = void 0, o = void 0;
@@ -803,7 +803,7 @@ const $o = (t) => async (e, o, r) => {
803
803
  major: 4,
804
804
  minor: 6,
805
805
  patch: 7
806
- }, fe = /* @__PURE__ */ V("$ZodType", (t, e) => {
806
+ }, ge = /* @__PURE__ */ H("$ZodType", (t, e) => {
807
807
  var o;
808
808
  t ?? (t = {}), t._zod.def = e, t._zod.bag = t._zod.bag || {}, t._zod.version = Ko;
809
809
  const r = t._zod.def.checks, n = t._zod.traits.has("$ZodCheck") ? [t, ...r ?? []] : r?.length ? [...r] : [];
@@ -818,7 +818,7 @@ const $o = (t) => async (e, o, r) => {
818
818
  const i = (s, c, a) => {
819
819
  if (s.memo)
820
820
  return s;
821
- let l = me(s), f;
821
+ let l = be(s), f;
822
822
  for (const u of c) {
823
823
  if (u._zod.def.when) {
824
824
  if (yo(s) || !u._zod.def.when(s))
@@ -830,17 +830,17 @@ const $o = (t) => async (e, o, r) => {
830
830
  throw new Ie();
831
831
  if (f || p instanceof Promise)
832
832
  f = (f ?? Promise.resolve()).then(async () => {
833
- await p, s.issues.length !== h && (lt(s.issues, h, t), l || (l = me(s, h)));
833
+ await p, s.issues.length !== h && (lt(s.issues, h, t), l || (l = be(s, h)));
834
834
  });
835
835
  else {
836
836
  if (s.issues.length === h)
837
837
  continue;
838
- lt(s.issues, h, t), l || (l = me(s, h));
838
+ lt(s.issues, h, t), l || (l = be(s, h));
839
839
  }
840
840
  }
841
841
  return f ? f.then(() => s) : s;
842
842
  }, d = (s, c, a) => {
843
- if (me(s))
843
+ if (be(s))
844
844
  return s.aborted = !0, s;
845
845
  const l = i(c, n, a);
846
846
  if (l instanceof Promise) {
@@ -874,7 +874,7 @@ const $o = (t) => async (e, o, r) => {
874
874
  set "~standard"(t) {
875
875
  Ee(this, "~standard", t);
876
876
  }
877
- }), wt = (t, e) => t.issues.length ? { issues: t.issues.map((o) => ve(o, e, pe())) } : { value: t.value };
877
+ }), wt = (t, e) => t.issues.length ? { issues: t.issues.map((o) => we(o, e, fe())) } : { value: t.value };
878
878
  async function Ho(t, e) {
879
879
  const o = { async: !0 };
880
880
  return wt(await t._zod.run({ value: e, issues: [] }, o), o);
@@ -895,8 +895,8 @@ function Vo(t) {
895
895
  version: 1
896
896
  };
897
897
  }
898
- const Wo = /* @__PURE__ */ V("$ZodString", (t, e) => {
899
- fe.init(t, e), t._zod.pattern = e.pattern ?? No, t._zod.parse = (o, r) => {
898
+ const Wo = /* @__PURE__ */ H("$ZodString", (t, e) => {
899
+ ge.init(t, e), t._zod.pattern = e.pattern ?? No, t._zod.parse = (o, r) => {
900
900
  if (e.coerce)
901
901
  try {
902
902
  o.value = String(o.value);
@@ -909,8 +909,8 @@ const Wo = /* @__PURE__ */ V("$ZodString", (t, e) => {
909
909
  inst: t
910
910
  }), o;
911
911
  };
912
- }), Fo = /* @__PURE__ */ V("$ZodNull", (t, e) => {
913
- fe.init(t, e), t._zod.pattern = Zo, t._zod.values = /* @__PURE__ */ new Set([null]), t._zod.parse = (o, r) => {
912
+ }), Fo = /* @__PURE__ */ H("$ZodNull", (t, e) => {
913
+ ge.init(t, e), t._zod.pattern = Zo, t._zod.values = /* @__PURE__ */ new Set([null]), t._zod.parse = (o, r) => {
914
914
  const n = o.value;
915
915
  return n === null || o.issues.push({
916
916
  expected: "null",
@@ -962,7 +962,7 @@ function Xo(t, e, o, r, n, i, d) {
962
962
  let h = 0;
963
963
  for (const p in e) {
964
964
  if (d && o.issues.length !== h) {
965
- if (me(o, h))
965
+ if (be(o, h))
966
966
  break;
967
967
  h = o.issues.length;
968
968
  }
@@ -977,7 +977,7 @@ function Xo(t, e, o, r, n, i, d) {
977
977
  continue;
978
978
  }
979
979
  const g = a.run({ value: e[p], issues: [] }, r);
980
- g instanceof Promise ? t.push(g.then((x) => Ue(x, o, p, e, f, u))) : Ue(g, o, p, e, f, u);
980
+ g instanceof Promise ? t.push(g.then((k) => Ue(k, o, p, e, f, u))) : Ue(g, o, p, e, f, u);
981
981
  }
982
982
  return s.length && o.issues.push({
983
983
  code: "unrecognized_keys",
@@ -988,8 +988,8 @@ function Xo(t, e, o, r, n, i, d) {
988
988
  continue: !0
989
989
  }), t.length ? Promise.all(t).then(() => o) : o;
990
990
  }
991
- const Yo = /* @__PURE__ */ V("$ZodObject", (t, e) => {
992
- fe.init(t, e);
991
+ const Yo = /* @__PURE__ */ H("$ZodObject", (t, e) => {
992
+ ge.init(t, e);
993
993
  const o = Object.getOwnPropertyDescriptor(e, "shape"), r = o?.get ? o.get.raw : e.shape ?? {};
994
994
  if (r) {
995
995
  const a = () => {
@@ -999,7 +999,7 @@ const Yo = /* @__PURE__ */ V("$ZodObject", (t, e) => {
999
999
  a.raw = r, Object.defineProperty(e, "shape", { get: a });
1000
1000
  }
1001
1001
  const n = mo(() => Go(e));
1002
- de(t, "propValues", (a) => {
1002
+ he(t, "propValues", (a) => {
1003
1003
  const l = a.def.shape, f = {};
1004
1004
  for (const u in l) {
1005
1005
  const h = l[u]._zod;
@@ -1028,16 +1028,16 @@ const Yo = /* @__PURE__ */ V("$ZodObject", (t, e) => {
1028
1028
  a.value = c ? c.alloc(t, a, {}, l) : {};
1029
1029
  const u = [], h = s.shape, p = l?.abortEarly;
1030
1030
  let g = a.issues.length;
1031
- for (const x of s.allKeys) {
1031
+ for (const k of s.allKeys) {
1032
1032
  if (p && a.issues.length !== g) {
1033
- if (me(a, g))
1033
+ if (be(a, g))
1034
1034
  break;
1035
1035
  g = a.issues.length;
1036
1036
  }
1037
- if (x === "__proto__")
1037
+ if (k === "__proto__")
1038
1038
  continue;
1039
- const b = h[x], z = b._zod.optin, A = b._zod.optout, _ = b._zod.run({ value: f[x], issues: [] }, l);
1040
- _ instanceof Promise ? u.push(_.then((I) => Ue(I, a, x, f, z, A))) : Ue(_, a, x, f, z, A);
1039
+ const b = h[k], I = b._zod.optin, j = b._zod.optout, _ = b._zod.run({ value: f[k], issues: [] }, l);
1040
+ _ instanceof Promise ? u.push(_.then((z) => Ue(z, a, k, f, I, j))) : Ue(_, a, k, f, I, j);
1041
1041
  }
1042
1042
  return d ? Xo(u, f, a, l, n.value, t, p === !0) : u.length ? Promise.all(u).then(() => a) : a;
1043
1043
  };
@@ -1046,19 +1046,19 @@ function ht(t, e, o, r) {
1046
1046
  for (const i of t)
1047
1047
  if (i.issues.length === 0)
1048
1048
  return e.value = i.value, e;
1049
- const n = t.filter((i) => !me(i));
1049
+ const n = t.filter((i) => !be(i));
1050
1050
  return n.length === 1 ? (e.value = n[0].value, n[0]) : (e.issues.push({
1051
1051
  code: "invalid_union",
1052
1052
  input: e.value,
1053
1053
  inst: o,
1054
- errors: t.map((i) => i.issues.map((d) => ve(d, r, pe())))
1054
+ errors: t.map((i) => i.issues.map((d) => we(d, r, fe())))
1055
1055
  }), e);
1056
1056
  }
1057
- const Qo = /* @__PURE__ */ V("$ZodUnion", (t, e) => {
1058
- fe.init(t, e), de(t, "optin", (r) => r.def.options.some((n) => n._zod.optin === "defaulted") ? "defaulted" : r.def.options.some((n) => n._zod.optin !== void 0) ? "optional" : void 0), de(t, "optout", (r) => r.def.options.some((n) => n._zod.optout === "optional") ? "optional" : void 0), de(t, "values", (r) => {
1057
+ const Qo = /* @__PURE__ */ H("$ZodUnion", (t, e) => {
1058
+ ge.init(t, e), he(t, "optin", (r) => r.def.options.some((n) => n._zod.optin === "defaulted") ? "defaulted" : r.def.options.some((n) => n._zod.optin !== void 0) ? "optional" : void 0), he(t, "optout", (r) => r.def.options.some((n) => n._zod.optout === "optional") ? "optional" : void 0), he(t, "values", (r) => {
1059
1059
  if (r.def.options.every((n) => n._zod.values))
1060
1060
  return new Set(r.def.options.flatMap((n) => Array.from(n._zod.values)));
1061
- }), de(t, "pattern", (r) => {
1061
+ }), he(t, "pattern", (r) => {
1062
1062
  if (r.def.options.every((n) => n._zod.pattern)) {
1063
1063
  const n = r.def.options.map((i) => i._zod.pattern);
1064
1064
  return new RegExp(`^(${n.map((i) => mt(i.source)).join("|")})$`);
@@ -1085,8 +1085,8 @@ const Qo = /* @__PURE__ */ V("$ZodUnion", (t, e) => {
1085
1085
  }
1086
1086
  return i ? Promise.all(d).then((s) => ht(s, r, t, n)) : ht(d, r, t, n);
1087
1087
  };
1088
- }), er = /* @__PURE__ */ V("$ZodRecord", (t, e) => {
1089
- fe.init(t, e);
1088
+ }), er = /* @__PURE__ */ H("$ZodRecord", (t, e) => {
1089
+ ge.init(t, e);
1090
1090
  const o = Ae.memoizer;
1091
1091
  o?.attach(t), t._zod.parse = (r, n) => {
1092
1092
  const i = r.value;
@@ -1112,7 +1112,7 @@ const Qo = /* @__PURE__ */ V("$ZodUnion", (t, e) => {
1112
1112
  r.issues.push({
1113
1113
  code: "invalid_key",
1114
1114
  origin: "record",
1115
- issues: f.issues.map((p) => ve(p, n, pe())),
1115
+ issues: f.issues.map((p) => we(p, n, fe())),
1116
1116
  input: l,
1117
1117
  path: [l],
1118
1118
  inst: t
@@ -1162,7 +1162,7 @@ const Qo = /* @__PURE__ */ V("$ZodUnion", (t, e) => {
1162
1162
  e.mode === "loose" ? r.value[a] = i[a] : s ? (c = c ?? [], c.push(a)) : r.issues.push({
1163
1163
  code: "invalid_key",
1164
1164
  origin: "record",
1165
- issues: l.issues.map((p) => ve(p, n, pe())),
1165
+ issues: l.issues.map((p) => we(p, n, fe())),
1166
1166
  input: a,
1167
1167
  path: [a],
1168
1168
  inst: t
@@ -1187,10 +1187,10 @@ const Qo = /* @__PURE__ */ V("$ZodUnion", (t, e) => {
1187
1187
  }
1188
1188
  return d.length ? Promise.all(d).then(() => r) : r;
1189
1189
  };
1190
- }), tr = /* @__PURE__ */ V("$ZodLiteral", (t, e) => {
1191
- fe.init(t, e);
1190
+ }), tr = /* @__PURE__ */ H("$ZodLiteral", (t, e) => {
1191
+ ge.init(t, e);
1192
1192
  const o = new Set(e.values);
1193
- t._zod.values = o, de(t, "pattern", (r) => {
1193
+ t._zod.values = o, he(t, "pattern", (r) => {
1194
1194
  const n = r.def.values;
1195
1195
  return new RegExp(n.length ? `^(${n.map((i) => typeof i == "string" ? st(i) : i ? st(i.toString()) : String(i)).join("|")})$` : "^[^\\s\\S]$");
1196
1196
  }), t._zod.parse = (r, n) => {
@@ -1202,30 +1202,30 @@ const Qo = /* @__PURE__ */ V("$ZodUnion", (t, e) => {
1202
1202
  inst: t
1203
1203
  }), r;
1204
1204
  };
1205
- }), or = /* @__PURE__ */ V("$ZodNullable", (t, e) => {
1206
- fe.init(t, e), de(t, "optin", (o) => o.def.innerType._zod.optin), de(t, "optout", (o) => o.def.innerType._zod.optout), de(t, "pattern", (o) => {
1205
+ }), or = /* @__PURE__ */ H("$ZodNullable", (t, e) => {
1206
+ ge.init(t, e), he(t, "optin", (o) => o.def.innerType._zod.optin), he(t, "optout", (o) => o.def.innerType._zod.optout), he(t, "pattern", (o) => {
1207
1207
  const r = o.def.innerType._zod.pattern;
1208
1208
  return r ? new RegExp(`^(${mt(r.source)}|null)$`) : void 0;
1209
- }), de(t, "values", (o) => o.def.innerType._zod.values ? /* @__PURE__ */ new Set([...o.def.innerType._zod.values, null]) : void 0), t._zod.parse = (o, r) => o.value === null ? o : e.innerType._zod.run(o, r);
1209
+ }), he(t, "values", (o) => o.def.innerType._zod.values ? /* @__PURE__ */ new Set([...o.def.innerType._zod.values, null]) : void 0), t._zod.parse = (o, r) => o.value === null ? o : e.innerType._zod.run(o, r);
1210
1210
  });
1211
1211
  function rr(t) {
1212
1212
  return t.checks && (t.checks = [...t.checks]), t;
1213
1213
  }
1214
1214
  // @__NO_SIDE_EFFECTS__
1215
1215
  function nr(t, e) {
1216
- return new t(rr({ type: "string", ...be(e) }));
1216
+ return new t(rr({ type: "string", ...ve(e) }));
1217
1217
  }
1218
1218
  // @__NO_SIDE_EFFECTS__
1219
1219
  function ar(t, e) {
1220
1220
  return new t({
1221
1221
  type: "null",
1222
- ...be(e)
1222
+ ...ve(e)
1223
1223
  });
1224
1224
  }
1225
- const we = /* @__PURE__ */ V("ZodMiniType", (t, e) => {
1225
+ const qe = /* @__PURE__ */ H("ZodMiniType", (t, e) => {
1226
1226
  if (!t._zod)
1227
1227
  throw new Error("Uninitialized schema in ZodMiniType.");
1228
- fe.init(t, e), t.def = e, t.type = e.type;
1228
+ ge.init(t, e), t.def = e, t.type = e.type;
1229
1229
  }, {
1230
1230
  // `with` is an alias for `check`: the same function object, not a wrapper.
1231
1231
  get with() {
@@ -1268,73 +1268,73 @@ const we = /* @__PURE__ */ V("ZodMiniType", (t, e) => {
1268
1268
  apply(t, ...e) {
1269
1269
  return e.length === 0 ? t(this) : t(this, ...e);
1270
1270
  }
1271
- }), ir = /* @__PURE__ */ V("ZodMiniString", (t, e) => {
1272
- Wo.init(t, e), we.init(t, e);
1271
+ }), ir = /* @__PURE__ */ H("ZodMiniString", (t, e) => {
1272
+ Wo.init(t, e), qe.init(t, e);
1273
1273
  });
1274
1274
  // @__NO_SIDE_EFFECTS__
1275
- function E(t) {
1275
+ function R(t) {
1276
1276
  return /* @__PURE__ */ nr(ir, t);
1277
1277
  }
1278
- const sr = /* @__PURE__ */ V("ZodMiniNull", (t, e) => {
1279
- Fo.init(t, e), we.init(t, e);
1278
+ const sr = /* @__PURE__ */ H("ZodMiniNull", (t, e) => {
1279
+ Fo.init(t, e), qe.init(t, e);
1280
1280
  });
1281
1281
  // @__NO_SIDE_EFFECTS__
1282
1282
  function lr(t) {
1283
1283
  return /* @__PURE__ */ ar(sr, t);
1284
1284
  }
1285
- const cr = /* @__PURE__ */ V("ZodMiniObject", (t, e) => {
1286
- Yo.init(t, e), we.init(t, e), Io(t, "shape", (o) => o._zod.def.shape, !1);
1285
+ const cr = /* @__PURE__ */ H("ZodMiniObject", (t, e) => {
1286
+ Yo.init(t, e), qe.init(t, e), Io(t, "shape", (o) => o._zod.def.shape, !1);
1287
1287
  });
1288
1288
  // @__NO_SIDE_EFFECTS__
1289
- function O(t, e) {
1289
+ function U(t, e) {
1290
1290
  const o = {
1291
1291
  type: "object",
1292
1292
  shape: t ?? {},
1293
- ...be(e)
1293
+ ...ve(e)
1294
1294
  };
1295
1295
  return new cr(o);
1296
1296
  }
1297
- const dr = /* @__PURE__ */ V("ZodMiniUnion", (t, e) => {
1298
- Qo.init(t, e), we.init(t, e);
1297
+ const dr = /* @__PURE__ */ H("ZodMiniUnion", (t, e) => {
1298
+ Qo.init(t, e), qe.init(t, e);
1299
1299
  });
1300
1300
  // @__NO_SIDE_EFFECTS__
1301
1301
  function ur(t, e) {
1302
1302
  return new dr({
1303
1303
  type: "union",
1304
1304
  options: t,
1305
- ...be(e)
1305
+ ...ve(e)
1306
1306
  });
1307
1307
  }
1308
- const pt = /* @__PURE__ */ V("ZodMiniRecord", (t, e) => {
1309
- er.init(t, e), we.init(t, e);
1308
+ const pt = /* @__PURE__ */ H("ZodMiniRecord", (t, e) => {
1309
+ er.init(t, e), qe.init(t, e);
1310
1310
  });
1311
1311
  // @__NO_SIDE_EFFECTS__
1312
1312
  function hr(t, e, o) {
1313
1313
  return !e || !e._zod ? new pt({
1314
1314
  type: "record",
1315
- keyType: /* @__PURE__ */ E(),
1315
+ keyType: /* @__PURE__ */ R(),
1316
1316
  valueType: t,
1317
- ...be(e)
1317
+ ...ve(e)
1318
1318
  }) : new pt({
1319
1319
  type: "record",
1320
1320
  keyType: t,
1321
1321
  valueType: e,
1322
- ...be(o)
1322
+ ...ve(o)
1323
1323
  });
1324
1324
  }
1325
- const pr = /* @__PURE__ */ V("ZodMiniLiteral", (t, e) => {
1326
- tr.init(t, e), we.init(t, e);
1325
+ const pr = /* @__PURE__ */ H("ZodMiniLiteral", (t, e) => {
1326
+ tr.init(t, e), qe.init(t, e);
1327
1327
  });
1328
1328
  // @__NO_SIDE_EFFECTS__
1329
- function se(t, e) {
1329
+ function le(t, e) {
1330
1330
  return new pr({
1331
1331
  type: "literal",
1332
1332
  values: Array.isArray(t) ? t : [t],
1333
- ...be(e)
1333
+ ...ve(e)
1334
1334
  });
1335
1335
  }
1336
- const fr = /* @__PURE__ */ V("ZodMiniNullable", (t, e) => {
1337
- or.init(t, e), we.init(t, e);
1336
+ const fr = /* @__PURE__ */ H("ZodMiniNullable", (t, e) => {
1337
+ or.init(t, e), qe.init(t, e);
1338
1338
  });
1339
1339
  // @__NO_SIDE_EFFECTS__
1340
1340
  function et(t) {
@@ -1343,70 +1343,70 @@ function et(t) {
1343
1343
  innerType: t
1344
1344
  });
1345
1345
  }
1346
- pe({ jitless: !0 });
1347
- const gr = /* @__PURE__ */ O({
1348
- type: /* @__PURE__ */ se("utterance"),
1349
- content: /* @__PURE__ */ E(),
1350
- role: /* @__PURE__ */ E()
1351
- }), mr = /* @__PURE__ */ O({
1352
- type: /* @__PURE__ */ se("agent_cognition"),
1353
- content: /* @__PURE__ */ E()
1354
- }), br = /* @__PURE__ */ O({
1355
- type: /* @__PURE__ */ se("chat_closed_expired"),
1356
- content: /* @__PURE__ */ E()
1357
- }), vr = /* @__PURE__ */ O({
1358
- type: /* @__PURE__ */ se("agent_captured_url"),
1359
- content: /* @__PURE__ */ E()
1360
- }), wr = /* @__PURE__ */ O({
1361
- type: /* @__PURE__ */ se("agent_topic"),
1362
- content: /* @__PURE__ */ E()
1363
- }), qr = /* @__PURE__ */ O({
1364
- type: /* @__PURE__ */ se("agent_summary"),
1365
- content: /* @__PURE__ */ E()
1366
- }), yr = /* @__PURE__ */ O({
1367
- type: /* @__PURE__ */ se("chat_rating"),
1368
- content: /* @__PURE__ */ E()
1369
- }), xr = /* @__PURE__ */ O({
1370
- type: /* @__PURE__ */ se("breadcrumb"),
1371
- content: /* @__PURE__ */ E()
1372
- }), kr = /* @__PURE__ */ O({
1373
- type: /* @__PURE__ */ se("chat_escalated"),
1346
+ fe({ jitless: !0 });
1347
+ const gr = /* @__PURE__ */ U({
1348
+ type: /* @__PURE__ */ le("utterance"),
1349
+ content: /* @__PURE__ */ R(),
1350
+ role: /* @__PURE__ */ R()
1351
+ }), mr = /* @__PURE__ */ U({
1352
+ type: /* @__PURE__ */ le("agent_cognition"),
1353
+ content: /* @__PURE__ */ R()
1354
+ }), br = /* @__PURE__ */ U({
1355
+ type: /* @__PURE__ */ le("chat_closed_expired"),
1356
+ content: /* @__PURE__ */ R()
1357
+ }), vr = /* @__PURE__ */ U({
1358
+ type: /* @__PURE__ */ le("agent_captured_url"),
1359
+ content: /* @__PURE__ */ R()
1360
+ }), wr = /* @__PURE__ */ U({
1361
+ type: /* @__PURE__ */ le("agent_topic"),
1362
+ content: /* @__PURE__ */ R()
1363
+ }), qr = /* @__PURE__ */ U({
1364
+ type: /* @__PURE__ */ le("agent_summary"),
1365
+ content: /* @__PURE__ */ R()
1366
+ }), yr = /* @__PURE__ */ U({
1367
+ type: /* @__PURE__ */ le("chat_rating"),
1368
+ content: /* @__PURE__ */ R()
1369
+ }), xr = /* @__PURE__ */ U({
1370
+ type: /* @__PURE__ */ le("breadcrumb"),
1371
+ content: /* @__PURE__ */ R()
1372
+ }), kr = /* @__PURE__ */ U({
1373
+ type: /* @__PURE__ */ le("chat_escalated"),
1374
1374
  content: /* @__PURE__ */ lr()
1375
- }), _r = /* @__PURE__ */ O({
1376
- type: /* @__PURE__ */ se("error"),
1377
- code: /* @__PURE__ */ E()
1378
- }), Cr = /* @__PURE__ */ O({
1379
- message_id: /* @__PURE__ */ et(/* @__PURE__ */ E()),
1380
- created_at: /* @__PURE__ */ E(),
1375
+ }), _r = /* @__PURE__ */ U({
1376
+ type: /* @__PURE__ */ le("error"),
1377
+ code: /* @__PURE__ */ R()
1378
+ }), Cr = /* @__PURE__ */ U({
1379
+ message_id: /* @__PURE__ */ et(/* @__PURE__ */ R()),
1380
+ created_at: /* @__PURE__ */ R(),
1381
1381
  data: gr
1382
- }), Sr = /* @__PURE__ */ O({
1383
- created_at: /* @__PURE__ */ E(),
1382
+ }), Sr = /* @__PURE__ */ U({
1383
+ created_at: /* @__PURE__ */ R(),
1384
1384
  data: _r
1385
- }), Ir = /* @__PURE__ */ O({
1386
- created_at: /* @__PURE__ */ E(),
1385
+ }), Ir = /* @__PURE__ */ U({
1386
+ created_at: /* @__PURE__ */ R(),
1387
1387
  data: mr
1388
- }), zr = /* @__PURE__ */ O({
1389
- message_id: /* @__PURE__ */ et(/* @__PURE__ */ E()),
1390
- created_at: /* @__PURE__ */ E(),
1388
+ }), zr = /* @__PURE__ */ U({
1389
+ message_id: /* @__PURE__ */ et(/* @__PURE__ */ R()),
1390
+ created_at: /* @__PURE__ */ R(),
1391
1391
  data: br
1392
- }), Er = /* @__PURE__ */ O({
1393
- created_at: /* @__PURE__ */ E(),
1392
+ }), Er = /* @__PURE__ */ U({
1393
+ created_at: /* @__PURE__ */ R(),
1394
1394
  data: vr
1395
- }), Rr = /* @__PURE__ */ O({
1396
- created_at: /* @__PURE__ */ E(),
1395
+ }), Rr = /* @__PURE__ */ U({
1396
+ created_at: /* @__PURE__ */ R(),
1397
1397
  data: wr
1398
- }), Pr = /* @__PURE__ */ O({
1399
- created_at: /* @__PURE__ */ E(),
1398
+ }), Pr = /* @__PURE__ */ U({
1399
+ created_at: /* @__PURE__ */ R(),
1400
1400
  data: qr
1401
- }), Tr = /* @__PURE__ */ O({
1402
- created_at: /* @__PURE__ */ E(),
1401
+ }), Tr = /* @__PURE__ */ U({
1402
+ created_at: /* @__PURE__ */ R(),
1403
1403
  data: yr
1404
- }), Mr = /* @__PURE__ */ O({
1405
- created_at: /* @__PURE__ */ E(),
1404
+ }), Mr = /* @__PURE__ */ U({
1405
+ created_at: /* @__PURE__ */ R(),
1406
1406
  data: xr
1407
- }), Or = /* @__PURE__ */ O({
1408
- message_id: /* @__PURE__ */ et(/* @__PURE__ */ E()),
1409
- created_at: /* @__PURE__ */ E(),
1407
+ }), Or = /* @__PURE__ */ U({
1408
+ message_id: /* @__PURE__ */ et(/* @__PURE__ */ R()),
1409
+ created_at: /* @__PURE__ */ R(),
1410
1410
  data: kr
1411
1411
  }), Ar = /* @__PURE__ */ ur([
1412
1412
  Cr,
@@ -1419,14 +1419,14 @@ const gr = /* @__PURE__ */ O({
1419
1419
  Tr,
1420
1420
  Mr,
1421
1421
  Or
1422
- ]), Ur = /* @__PURE__ */ O({
1423
- url: /* @__PURE__ */ E(),
1424
- mimeType: /* @__PURE__ */ se(Et),
1425
- name: /* @__PURE__ */ E()
1426
- }), jr = /* @__PURE__ */ O({
1422
+ ]), Ur = /* @__PURE__ */ U({
1423
+ url: /* @__PURE__ */ R(),
1424
+ mimeType: /* @__PURE__ */ le(Et),
1425
+ name: /* @__PURE__ */ R()
1426
+ }), jr = /* @__PURE__ */ U({
1427
1427
  data: Ur
1428
- }), Dr = /* @__PURE__ */ O({
1429
- data: /* @__PURE__ */ O({ urls: /* @__PURE__ */ hr(/* @__PURE__ */ E(), /* @__PURE__ */ E()) })
1428
+ }), Dr = /* @__PURE__ */ U({
1429
+ data: /* @__PURE__ */ U({ urls: /* @__PURE__ */ hr(/* @__PURE__ */ R(), /* @__PURE__ */ R()) })
1430
1430
  }), $r = 500, Br = 3e4, Nr = 6e4;
1431
1431
  function Lr({
1432
1432
  chatSettings: t,
@@ -1446,48 +1446,48 @@ function Lr({
1446
1446
  getChatToken: p,
1447
1447
  backupPollingInterval: g = Nr
1448
1448
  }) {
1449
- const x = K(/* @__PURE__ */ new Set());
1450
- H(() => {
1449
+ const k = Z(/* @__PURE__ */ new Set());
1450
+ K(() => {
1451
1451
  for (const N of o)
1452
- N.id && x.current.add(N.id);
1452
+ N.id && k.current.add(N.id);
1453
1453
  }, [o]);
1454
- const b = K(null), z = K(null), A = K(0), _ = K(null), I = K(null), R = K(!1), w = K(!1), y = J(r), P = J(n), ne = J(i), G = J(d), Y = J(s), M = J(c), Z = J(a), U = J(l), L = J(f), j = J(u), Q = J(h), ee = J(p), { publishError: te } = je(), oe = t?.app_sync_url, W = t?.app_sync_api_key, m = !!(oe && W), k = J(oe), S = J(W), D = v(() => {
1454
+ const b = Z(null), I = Z(null), j = Z(0), _ = Z(null), z = Z(null), E = Z(!1), w = Z(!1), y = W(r), M = W(n), oe = W(i), F = W(d), Y = W(s), Q = W(c), O = W(a), L = W(l), D = W(f), P = W(u), ee = W(h), re = W(p), { publishError: J } = je(), ae = t?.app_sync_url, G = t?.app_sync_api_key, m = !!(ae && G), x = W(ae), S = W(G), A = v(() => {
1455
1455
  b.current && (b.current.close(), b.current = null);
1456
- }, []), B = v(() => {
1457
- I.current && (clearInterval(I.current), I.current = null);
1456
+ }, []), $ = v(() => {
1457
+ z.current && (clearInterval(z.current), z.current = null);
1458
1458
  }, []), T = v(() => {
1459
1459
  _.current && (clearTimeout(_.current), _.current = null);
1460
- }, []), $ = K(() => {
1461
- }), F = v(
1460
+ }, []), B = Z(() => {
1461
+ }), V = v(
1462
1462
  async (N) => {
1463
- D();
1464
- const ae = k.current, re = S.current;
1465
- if (!ae || !re)
1463
+ A();
1464
+ const ne = x.current, te = S.current;
1465
+ if (!ne || !te)
1466
1466
  throw new Error("Cannot connect: AppSync settings not available");
1467
- const Re = ee.current(), Be = await po({
1468
- httpEndpoint: ae,
1469
- auth: Re ? { authorizationToken: Re } : { apiKey: re },
1467
+ const Re = re.current(), Be = await po({
1468
+ httpEndpoint: ne,
1469
+ auth: Re ? { authorizationToken: Re } : { apiKey: te },
1470
1470
  channel: `/default/chat/${N}`,
1471
1471
  onDisconnect: () => {
1472
- b.current = null, $.current();
1472
+ b.current = null, B.current();
1473
1473
  },
1474
1474
  onEvent: (Ne) => {
1475
- const qe = Ar.safeParse(Ne);
1476
- if (!qe.success) {
1477
- console.error("Invalid conversation response:", qe.error);
1475
+ const xe = Ar.safeParse(Ne);
1476
+ if (!xe.success) {
1477
+ console.error("Invalid conversation response:", xe.error);
1478
1478
  return;
1479
1479
  }
1480
- const le = qe.data;
1481
- switch (le.data.type) {
1480
+ const de = xe.data;
1481
+ switch (de.data.type) {
1482
1482
  case "utterance": {
1483
- const X = le, ie = X.message_id ?? crypto.randomUUID();
1484
- if (x.current.has(ie))
1483
+ const X = de, se = X.message_id ?? crypto.randomUUID();
1484
+ if (k.current.has(se))
1485
1485
  return;
1486
- x.current.add(ie), ne.current(), y.current(
1486
+ k.current.add(se), oe.current(), y.current(
1487
1487
  {
1488
- message_id: ie,
1488
+ message_id: se,
1489
1489
  response: {
1490
- id: ie,
1490
+ id: se,
1491
1491
  type: X.data.type,
1492
1492
  content: X.data.content
1493
1493
  }
@@ -1497,50 +1497,50 @@ function Lr({
1497
1497
  return;
1498
1498
  }
1499
1499
  case "error": {
1500
- const ie = parseInt(le.data.code);
1501
- te({ code: ie, message: Rt(ie) }), G.current?.();
1500
+ const se = parseInt(de.data.code);
1501
+ J({ code: se, message: Rt(se) }), F.current?.();
1502
1502
  return;
1503
1503
  }
1504
1504
  case "agent_cognition": {
1505
- const X = le;
1506
- P.current(X.data.content);
1505
+ const X = de;
1506
+ M.current(X.data.content);
1507
1507
  return;
1508
1508
  }
1509
1509
  case "agent_captured_url": {
1510
- const X = le;
1511
- M.current?.(X.data.content);
1510
+ const X = de;
1511
+ Q.current?.(X.data.content);
1512
1512
  return;
1513
1513
  }
1514
1514
  case "agent_topic": {
1515
- const X = le;
1516
- Z.current?.(X.data.content);
1515
+ const X = de;
1516
+ O.current?.(X.data.content);
1517
1517
  return;
1518
1518
  }
1519
1519
  case "agent_summary": {
1520
- const X = le;
1521
- U.current?.(X.data.content);
1520
+ const X = de;
1521
+ L.current?.(X.data.content);
1522
1522
  return;
1523
1523
  }
1524
1524
  case "chat_closed_expired": {
1525
- Y.current?.(), L.current?.();
1525
+ Y.current?.(), D.current?.();
1526
1526
  return;
1527
1527
  }
1528
1528
  case "chat_rating": {
1529
- L.current?.();
1529
+ D.current?.();
1530
1530
  return;
1531
1531
  }
1532
1532
  case "breadcrumb": {
1533
- j.current?.();
1533
+ P.current?.();
1534
1534
  return;
1535
1535
  }
1536
1536
  case "chat_escalated": {
1537
- Y.current?.(), L.current?.();
1537
+ Y.current?.(), D.current?.();
1538
1538
  return;
1539
1539
  }
1540
1540
  default:
1541
1541
  console.warn(
1542
1542
  "Unknown notification type:",
1543
- le.data.type
1543
+ de.data.type
1544
1544
  );
1545
1545
  }
1546
1546
  }
@@ -1550,89 +1550,89 @@ function Lr({
1550
1550
  // The *Ref entries are latest-refs (stable identities); listed to satisfy
1551
1551
  // exhaustive-deps, which can't see that useLatestRef returns a ref.
1552
1552
  [
1553
- D,
1554
- te,
1555
- k,
1553
+ A,
1554
+ J,
1555
+ x,
1556
1556
  S,
1557
- ee,
1557
+ re,
1558
1558
  y,
1559
- P,
1560
- ne,
1561
- G,
1562
- Y,
1563
1559
  M,
1564
- Z,
1565
- U,
1560
+ oe,
1561
+ F,
1562
+ Y,
1563
+ Q,
1564
+ O,
1566
1565
  L,
1567
- j
1566
+ D,
1567
+ P
1568
1568
  ]
1569
- ), ue = v(
1569
+ ), ie = v(
1570
1570
  async (N) => {
1571
1571
  try {
1572
- const ae = await Q.current(N);
1573
- for (const re of ae)
1574
- re.role !== "assistant" || !re.message_id || x.current.has(re.message_id) || (x.current.add(re.message_id), y.current(
1575
- { message_id: re.message_id, response: re.response },
1572
+ const ne = await ee.current(N);
1573
+ for (const te of ne)
1574
+ te.role !== "assistant" || !te.message_id || k.current.has(te.message_id) || (k.current.add(te.message_id), y.current(
1575
+ { message_id: te.message_id, response: te.response },
1576
1576
  N
1577
1577
  ));
1578
- } catch (ae) {
1579
- console.warn("Backup poll failed:", ae);
1578
+ } catch (ne) {
1579
+ console.warn("Backup poll failed:", ne);
1580
1580
  }
1581
1581
  },
1582
- [Q, y]
1583
- ), ge = v(
1582
+ [ee, y]
1583
+ ), ye = v(
1584
1584
  (N) => {
1585
- B(), I.current = setInterval(
1586
- () => ue(N),
1585
+ $(), z.current = setInterval(
1586
+ () => ie(N),
1587
1587
  g
1588
1588
  );
1589
1589
  },
1590
- [B, ue, g]
1591
- ), ye = v(
1590
+ [$, ie, g]
1591
+ ), ce = v(
1592
1592
  function N() {
1593
- if (!R.current || w.current || _.current)
1593
+ if (!E.current || w.current || _.current)
1594
1594
  return;
1595
- const ae = z.current;
1596
- if (!ae) return;
1597
- const re = Math.min(
1598
- $r * Math.pow(2, A.current),
1595
+ const ne = I.current;
1596
+ if (!ne) return;
1597
+ const te = Math.min(
1598
+ $r * Math.pow(2, j.current),
1599
1599
  Br
1600
1600
  );
1601
- A.current += 1, _.current = setTimeout(async () => {
1601
+ j.current += 1, _.current = setTimeout(async () => {
1602
1602
  _.current = null, w.current = !0;
1603
1603
  try {
1604
- await F(ae), A.current = 0, w.current = !1, await ue(ae);
1604
+ await V(ne), j.current = 0, w.current = !1, await ie(ne);
1605
1605
  } catch {
1606
1606
  w.current = !1, N();
1607
1607
  }
1608
- }, re);
1608
+ }, te);
1609
1609
  },
1610
- [F, ue]
1610
+ [V, ie]
1611
1611
  );
1612
- H(() => {
1613
- $.current = ye;
1612
+ K(() => {
1613
+ B.current = ce;
1614
1614
  });
1615
- const xe = v(
1615
+ const me = v(
1616
1616
  async (N) => {
1617
1617
  if (!m || !N)
1618
1618
  throw new Error(
1619
1619
  "Cannot connect: AppSync settings not ready or missing chatId"
1620
1620
  );
1621
- T(), R.current = !0, z.current = N, A.current = 0, ge(N), await F(N);
1621
+ T(), E.current = !0, I.current = N, j.current = 0, ye(N), await V(N);
1622
1622
  },
1623
- [m, T, F, ge]
1623
+ [m, T, V, ye]
1624
1624
  ), ke = v(() => {
1625
- R.current = !1, z.current = null, A.current = 0, T(), B(), D();
1626
- }, [T, B, D]), $e = v(() => {
1627
- x.current.clear();
1625
+ E.current = !1, I.current = null, j.current = 0, T(), $(), A();
1626
+ }, [T, $, A]), $e = v(() => {
1627
+ k.current.clear();
1628
1628
  }, []);
1629
- return H(() => {
1630
- !e || !m || z.current === e || xe(e).catch((N) => {
1631
- console.error("Failed to eagerly connect:", N), z.current = e, R.current = !0, $.current();
1629
+ return K(() => {
1630
+ !e || !m || I.current === e || me(e).catch((N) => {
1631
+ console.error("Failed to eagerly connect:", N), I.current = e, E.current = !0, B.current();
1632
1632
  });
1633
- }, [e, m, xe]), H(() => () => {
1633
+ }, [e, m, me]), K(() => () => {
1634
1634
  ke();
1635
- }, [ke]), { connect: xe, disconnect: ke, clearProcessedIds: $e };
1635
+ }, [ke]), { connect: me, disconnect: ke, clearProcessedIds: $e };
1636
1636
  }
1637
1637
  function Zr(t) {
1638
1638
  return {
@@ -1717,70 +1717,70 @@ function Xr({
1717
1717
  onChatClosed: u,
1718
1718
  isChatClosed: h
1719
1719
  }) {
1720
- const { saveChatData: p, clearChatData: g, updateLastActivity: x, markChatClosed: b } = Qe({
1720
+ const { saveChatData: p, clearChatData: g, updateLastActivity: k, markChatClosed: b } = Qe({
1721
1721
  appId: t
1722
- }), { publishApiError: z, publishNetworkError: A } = je(), { showCognition: _, hideCognition: I } = Pt(), R = J(d), w = v(
1723
- (m, k) => {
1722
+ }), { publishApiError: I, publishNetworkError: j } = je(), { showCognition: _, hideCognition: z } = Pt(), E = W(d), w = v(
1723
+ (m, x) => {
1724
1724
  m.response.content && a((S) => {
1725
1725
  if (S.some((T) => T.isRatingRequest) || s?.welcome_message && m.response.content === s.welcome_message)
1726
1726
  return S;
1727
- const B = [
1727
+ const $ = [
1728
1728
  ...S.filter((T) => !T.isThinking),
1729
1729
  Zr(m)
1730
1730
  ];
1731
1731
  return p(
1732
- k,
1732
+ x,
1733
1733
  e,
1734
- B,
1734
+ $,
1735
1735
  i,
1736
- R.current?.getChatToken()
1737
- ), B;
1736
+ E.current?.getChatToken()
1737
+ ), $;
1738
1738
  });
1739
1739
  },
1740
- [s, i, p, a, e, R]
1740
+ [s, i, p, a, e, E]
1741
1741
  ), y = v(() => {
1742
- I(), a((m) => m.filter((k) => !k.isThinking));
1743
- }, [a, I]), P = v(() => {
1742
+ z(), a((m) => m.filter((x) => !x.isThinking));
1743
+ }, [a, z]), M = v(() => {
1744
1744
  a((m) => [...m.filter((S) => !S.isRatingRequest), Hr()]);
1745
1745
  }, [a]);
1746
- H(() => {
1747
- }, [P]);
1748
- const ne = v(
1749
- (m) => R.current ? R.current.getChatHistory(m) : Promise.resolve([]),
1750
- [R]
1751
- ), G = v(() => R.current?.getChatToken() ?? null, [R]), Y = v(() => {
1746
+ K(() => {
1747
+ }, [M]);
1748
+ const oe = v(
1749
+ (m) => E.current ? E.current.getChatHistory(m) : Promise.resolve([]),
1750
+ [E]
1751
+ ), F = v(() => E.current?.getChatToken() ?? null, [E]), Y = v(() => {
1752
1752
  b(), u?.();
1753
- }, [b, u]), { connect: M, disconnect: Z, clearProcessedIds: U } = Lr({
1753
+ }, [b, u]), { connect: Q, disconnect: O, clearProcessedIds: L } = Lr({
1754
1754
  chatSettings: s,
1755
1755
  chatId: l?.id ?? null,
1756
1756
  messages: c,
1757
1757
  onMessage: w,
1758
1758
  onCognition: _,
1759
- onCognitionComplete: I,
1759
+ onCognitionComplete: z,
1760
1760
  onError: y,
1761
1761
  onChatClosed: Y,
1762
- onRatingRequest: P,
1762
+ onRatingRequest: M,
1763
1763
  onBreadcrumb: Y,
1764
- fetchHistory: ne,
1765
- getChatToken: G
1766
- }), L = v(() => {
1767
- I(), Z(), U(), Tt(c), a(
1768
- (m) => m.filter((k) => Array.isArray(k) ? !1 : k.isWelcomeMessage)
1764
+ fetchHistory: oe,
1765
+ getChatToken: F
1766
+ }), D = v(() => {
1767
+ z(), O(), L(), Tt(c), a(
1768
+ (m) => m.filter((x) => Array.isArray(x) ? !1 : x.isWelcomeMessage)
1769
1769
  ), g(), f(null);
1770
1770
  }, [
1771
- I,
1772
- Z,
1773
- U,
1771
+ z,
1772
+ O,
1773
+ L,
1774
1774
  c,
1775
1775
  g,
1776
1776
  a,
1777
1777
  f
1778
- ]), j = v(
1779
- (m, k) => a((S) => Fr(S, m, k)),
1778
+ ]), P = v(
1779
+ (m, x) => a((S) => Fr(S, m, x)),
1780
1780
  [a]
1781
- ), Q = v(
1781
+ ), ee = v(
1782
1782
  async (m) => {
1783
- const k = await m.createConversation({
1783
+ const x = await m.createConversation({
1784
1784
  userId: n || e,
1785
1785
  deviceId: i,
1786
1786
  userName: o,
@@ -1789,100 +1789,100 @@ function Xr({
1789
1789
  searchParams: eo()
1790
1790
  }
1791
1791
  });
1792
- f({ id: k.chat_id });
1792
+ f({ id: x.chat_id });
1793
1793
  try {
1794
- await M(k.chat_id);
1794
+ await Q(x.chat_id);
1795
1795
  } catch (S) {
1796
1796
  console.warn(
1797
1797
  "Failed to connect realtime channel, continuing with REST-only delivery:",
1798
1798
  S
1799
1799
  );
1800
1800
  }
1801
- return k.chat_id;
1801
+ return x.chat_id;
1802
1802
  },
1803
- [n, e, i, o, r, f, M]
1804
- ), ee = v(
1805
- (m, k, S, D) => Promise.all(
1803
+ [n, e, i, o, r, f, Q]
1804
+ ), re = v(
1805
+ (m, x, S, A) => Promise.all(
1806
1806
  S.map(
1807
- ({ file: B }, T) => m.uploadAttachment({
1808
- conversationId: k,
1809
- file: B,
1810
- onProgress: ($) => j(
1811
- D,
1812
- (F) => Jr(F, T, $)
1807
+ ({ file: $ }, T) => m.uploadAttachment({
1808
+ conversationId: x,
1809
+ file: $,
1810
+ onProgress: (B) => P(
1811
+ A,
1812
+ (V) => Jr(V, T, B)
1813
1813
  )
1814
- }).catch(($) => {
1815
- throw Mt($, B.name);
1814
+ }).catch((B) => {
1815
+ throw Mt(B, $.name);
1816
1816
  })
1817
1817
  )
1818
1818
  ),
1819
- [j]
1820
- ), te = v(
1821
- (m, k, S, D) => {
1822
- I(), D && a((T) => Gr(T, S)), a((T) => T.filter(($) => !$.isThinking));
1823
- const B = () => j(S, (T) => ({ ...T, isFailed: !0 }));
1819
+ [P]
1820
+ ), J = v(
1821
+ (m, x, S, A) => {
1822
+ z(), A && a((T) => Gr(T, S)), a((T) => T.filter((B) => !B.isThinking));
1823
+ const $ = () => P(S, (T) => ({ ...T, isFailed: !0 }));
1824
1824
  if (m instanceof Ot) {
1825
- B();
1825
+ $();
1826
1826
  return;
1827
1827
  }
1828
1828
  if (m instanceof Ye || m instanceof Oe && m.status === 403) {
1829
- A();
1829
+ j();
1830
1830
  return;
1831
1831
  }
1832
- z(m), m instanceof Oe && // A 401 means an expired or closed chat token: drop the session so
1832
+ I(m), m instanceof Oe && // A 401 means an expired or closed chat token: drop the session so
1833
1833
  // the next send starts a fresh one, as for a client-side expiry.
1834
- (m.status >= 500 || m.status === 401) ? (f(null), g(), a((T) => T.filter(($) => $.id !== S)), k.reset()) : B();
1834
+ (m.status >= 500 || m.status === 401) ? (f(null), g(), a((T) => T.filter((B) => B.id !== S)), x.reset()) : $();
1835
1835
  },
1836
1836
  [
1837
- I,
1837
+ z,
1838
1838
  a,
1839
+ P,
1839
1840
  j,
1840
- A,
1841
- z,
1841
+ I,
1842
1842
  f,
1843
1843
  g
1844
1844
  ]
1845
- ), oe = v(
1846
- async (m, k = []) => {
1847
- if (!d || c.some((D) => D.isRatingRequest)) return;
1845
+ ), ae = v(
1846
+ async (m, x = []) => {
1847
+ if (!d || c.some((A) => A.isRatingRequest)) return;
1848
1848
  if (h) {
1849
- a((D) => [...D, Vr()]);
1849
+ a((A) => [...A, Vr()]);
1850
1850
  return;
1851
1851
  }
1852
- const S = Wr(m, k);
1853
- _(), a([...c, S]), x();
1852
+ const S = Wr(m, x);
1853
+ _(), a([...c, S]), k();
1854
1854
  try {
1855
- const D = l?.id || await Q(d), B = await ee(
1855
+ const A = l?.id || await ee(d), $ = await re(
1856
1856
  d,
1857
- D,
1858
- k,
1857
+ A,
1858
+ x,
1859
1859
  S.id
1860
1860
  );
1861
- B.length > 0 && j(S.id, ($) => ({
1862
- ...$,
1863
- attachments: At(B, k)
1861
+ $.length > 0 && P(S.id, (B) => ({
1862
+ ...B,
1863
+ attachments: At($, x)
1864
1864
  }));
1865
1865
  const T = await d.replyToConversation({
1866
1866
  text: m.content,
1867
- attachments: B,
1868
- conversationId: D,
1867
+ attachments: $,
1868
+ conversationId: A,
1869
1869
  userId: n || e,
1870
1870
  deviceId: i,
1871
1871
  userName: o,
1872
1872
  userData: r
1873
1873
  });
1874
- j(S.id, ($) => ({
1875
- ...$,
1874
+ P(S.id, (B) => ({
1875
+ ...B,
1876
1876
  id: T.message_id,
1877
1877
  isNew: !1
1878
1878
  }));
1879
- } catch (D) {
1880
- throw te(
1881
- D,
1879
+ } catch (A) {
1880
+ throw J(
1881
+ A,
1882
1882
  d,
1883
1883
  S.id,
1884
- k.length > 0
1885
- ), D;
1884
+ x.length > 0
1885
+ ), A;
1886
1886
  }
1887
1887
  },
1888
1888
  [
@@ -1891,29 +1891,29 @@ function Xr({
1891
1891
  h,
1892
1892
  a,
1893
1893
  _,
1894
- x,
1894
+ k,
1895
1895
  l?.id,
1896
- Q,
1897
1896
  ee,
1898
- j,
1899
- te,
1897
+ re,
1898
+ P,
1899
+ J,
1900
1900
  n,
1901
1901
  e,
1902
1902
  i,
1903
1903
  o,
1904
1904
  r
1905
1905
  ]
1906
- ), W = v(
1906
+ ), G = v(
1907
1907
  async (m) => {
1908
- const k = l?.id;
1909
- !R.current || !k || await R.current.addRating(k, m);
1908
+ const x = l?.id;
1909
+ !E.current || !x || await E.current.addRating(x, m);
1910
1910
  },
1911
- [l?.id, R]
1911
+ [l?.id, E]
1912
1912
  );
1913
1913
  return {
1914
- onCleanMessages: L,
1915
- onSendMessage: oe,
1916
- onRateChat: W
1914
+ onCleanMessages: D,
1915
+ onSendMessage: ae,
1916
+ onRateChat: G
1917
1917
  };
1918
1918
  }
1919
1919
  const Yr = { BASE_URL: "/", DEV: !1, MODE: "dev", PROD: !0, SSR: !1, VITE_API_URL: "https://chat.eloquentai.dev", VITE_CDN_URL: "https://cdn.eloquentai.dev", VITE_ENVIRONMENT: "dev", VITE_REGION_API_URL: "https://region.eloquentai.dev" };
@@ -2061,8 +2061,8 @@ const Te = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ new Map();
2061
2061
  function ln(t, e, o) {
2062
2062
  const r = o?.dedupe !== !1, [n, i] = C(
2063
2063
  () => Te.get(t)
2064
- ), { publishApiError: d, publishNetworkError: s } = je(), [c, a] = C(void 0), [l, f] = C(!1), u = K(!0);
2065
- K(() => (u.current = !0, () => {
2064
+ ), { publishApiError: d, publishNetworkError: s } = je(), [c, a] = C(void 0), [l, f] = C(!1), u = Z(!0);
2065
+ Z(() => (u.current = !0, () => {
2066
2066
  u.current = !1;
2067
2067
  }));
2068
2068
  const h = v(async () => {
@@ -2121,57 +2121,57 @@ function dn({
2121
2121
  isReady: c
2122
2122
  } = cn({ appId: e, initialUserId: o }), { isChatExpired: a, clearChatData: l, getSavedChatData: f } = Qe({
2123
2123
  appId: e
2124
- }), { current: u } = K(t || tn()), [h] = C(
2124
+ }), { current: u } = Z(t || tn()), [h] = C(
2125
2125
  new rn({
2126
2126
  baseURL: u,
2127
2127
  appId: e
2128
2128
  })
2129
- ), [p, g] = C(null), [x, b] = C(null), [z, A] = C([]), [_, I] = C(!1), [R, w] = C(!1), [y, P] = C(!0), G = ln(`sdk-boot-${e}`, () => h.boot()).fetch;
2130
- H(() => {
2129
+ ), [p, g] = C(null), [k, b] = C(null), [I, j] = C([]), [_, z] = C(!1), [E, w] = C(!1), [y, M] = C(!0), F = ln(`sdk-boot-${e}`, () => h.boot()).fetch;
2130
+ K(() => {
2131
2131
  if (a())
2132
2132
  l();
2133
2133
  else {
2134
2134
  const {
2135
- conversationId: M,
2136
- userId: Z,
2137
- messages: U,
2138
- isChatClosed: L,
2139
- chatToken: j
2135
+ conversationId: Q,
2136
+ userId: O,
2137
+ messages: L,
2138
+ isChatClosed: D,
2139
+ chatToken: P
2140
2140
  } = f();
2141
- M && Z && (b({
2142
- id: M
2143
- }), h.setChatToken(j ?? null), U && U.length > 0 && A(U), L && w(!0));
2141
+ Q && O && (b({
2142
+ id: Q
2143
+ }), h.setChatToken(P ?? null), L && L.length > 0 && j(L), D && w(!0));
2144
2144
  }
2145
2145
  }, [f, a, l, h]);
2146
- const Y = K(!1);
2147
- return H(() => {
2146
+ const Y = Z(!1);
2147
+ return K(() => {
2148
2148
  if (Y.current) return;
2149
2149
  Y.current = !0, (async () => {
2150
- const [Z, U] = await nt(
2150
+ const [O, L] = await nt(
2151
2151
  ft(() => h.getOrganizationByAppId(e))
2152
2152
  );
2153
- if (U) {
2154
- console.error("Failed to fetch organization data:", U), P(!1), I(!0);
2153
+ if (L) {
2154
+ console.error("Failed to fetch organization data:", L), M(!1), z(!0);
2155
2155
  return;
2156
2156
  }
2157
- h.setRegion(Z.region);
2158
- const [L, j] = await nt(ft(G));
2159
- if (j) {
2160
- P(!1), I(!0);
2157
+ h.setRegion(O.region);
2158
+ const [D, P] = await nt(ft(F));
2159
+ if (P) {
2160
+ M(!1), z(!0);
2161
2161
  return;
2162
2162
  }
2163
2163
  const {
2164
- conversationId: Q,
2165
- userId: ee,
2166
- messages: te
2164
+ conversationId: ee,
2165
+ userId: re,
2166
+ messages: J
2167
2167
  } = f();
2168
- Q && ee && te.some(jt) && A(
2169
- await Dt(h, Q, te)
2168
+ ee && re && J.some(jt) && j(
2169
+ await Dt(h, ee, J)
2170
2170
  );
2171
- const oe = L.chat_settings.welcome_message;
2172
- g(L.chat_settings), P(L.chat_settings.is_active ?? !0), oe && A((W) => W.length > 0 || W.some((m) => m.isWelcomeMessage) ? W : [Kr(oe)]), I(!0);
2171
+ const ae = D.chat_settings.welcome_message;
2172
+ g(D.chat_settings), M(D.chat_settings.is_active ?? !0), ae && j((G) => G.length > 0 || G.some((m) => m.isWelcomeMessage) ? G : [Kr(ae)]), z(!0);
2173
2173
  })();
2174
- }, [c, h, e, G, f]), {
2174
+ }, [c, h, e, F, f]), {
2175
2175
  userId: i,
2176
2176
  userName: r,
2177
2177
  userData: n,
@@ -2179,10 +2179,10 @@ function dn({
2179
2179
  deviceId: s,
2180
2180
  apiClient: h,
2181
2181
  chatSettings: p,
2182
- currentChat: x,
2183
- messages: z,
2182
+ currentChat: k,
2183
+ messages: I,
2184
2184
  isReady: _,
2185
- isChatClosed: R,
2185
+ isChatClosed: E,
2186
2186
  isChatActive: y
2187
2187
  };
2188
2188
  }
@@ -2194,13 +2194,13 @@ function hn(t) {
2194
2194
  const [e, o] = C(un), [r, n] = C(
2195
2195
  null
2196
2196
  ), i = t ?? e, d = typeof window > "u";
2197
- return H(() => {
2197
+ return K(() => {
2198
2198
  if (d) return;
2199
2199
  const s = window.matchMedia(yt), c = (a) => {
2200
2200
  o(a.matches);
2201
2201
  };
2202
2202
  return c(s), s.addEventListener("change", c), () => s.removeEventListener("change", c);
2203
- }, [d]), H(() => {
2203
+ }, [d]), K(() => {
2204
2204
  if (d) return;
2205
2205
  const s = document.createElement("div");
2206
2206
  return s.className = "eloquent-ai-chat-portal", s.style.position = "relative", s.style.zIndex = "30", document.body.appendChild(s), n(s), () => {
@@ -2231,18 +2231,18 @@ function gn({
2231
2231
  cleanChatButton: h,
2232
2232
  proactiveMessageHideDelay: p = 5e3,
2233
2233
  isAlwaysOpen: g = !1,
2234
- hasCleanChatButtonOverride: x
2234
+ hasCleanChatButtonOverride: k
2235
2235
  }) {
2236
- const { isMobile: b, portalContainer: z } = hn(s), {
2237
- userId: A,
2236
+ const { isMobile: b, portalContainer: I } = hn(s), {
2237
+ userId: j,
2238
2238
  externalId: _,
2239
- deviceId: I,
2240
- apiClient: R,
2239
+ deviceId: z,
2240
+ apiClient: E,
2241
2241
  chatSettings: w,
2242
2242
  currentChat: y,
2243
- messages: P,
2244
- isReady: ne,
2245
- isChatClosed: G,
2243
+ messages: M,
2244
+ isReady: oe,
2245
+ isChatClosed: F,
2246
2246
  isChatActive: Y
2247
2247
  } = dn({
2248
2248
  apiUrl: e,
@@ -2250,114 +2250,114 @@ function gn({
2250
2250
  initialUserId: r,
2251
2251
  userName: n,
2252
2252
  userData: i
2253
- }), M = Qt({ chatProps: d, chatSettings: w }), Z = c ?? f ?? !1, U = a ?? u ?? !0, L = l ?? h ?? !0, j = fn(o), [Q, ee] = C(() => g ? !0 : it(j) === "true" || b ? !1 : Z ?? b), [te, oe] = C(!1);
2254
- H(() => {
2255
- if (!ne || te || (oe(!0), g)) return;
2256
- const ce = w?.initial_open;
2257
- ce != null && (b || ce && it(j) === "true" || ee(ce));
2253
+ }), Q = Qt({ chatProps: d, chatSettings: w }), O = c ?? f ?? !1, L = a ?? u ?? !0, D = l ?? h ?? !0, P = fn(o), [ee, re] = C(() => g ? !0 : it(P) === "true" || b ? !1 : O ?? b), [J, ae] = C(!1);
2254
+ K(() => {
2255
+ if (!oe || J || (ae(!0), g)) return;
2256
+ const ue = w?.initial_open;
2257
+ ue != null && (b || ue && it(P) === "true" || re(ue));
2258
2258
  }, [
2259
- ne,
2260
- te,
2259
+ oe,
2260
+ J,
2261
2261
  w?.initial_open,
2262
2262
  b,
2263
- j,
2263
+ P,
2264
2264
  g
2265
2265
  ]);
2266
- const W = w?.initial_open ?? Z, m = w?.close_button ?? U, k = x ?? w?.clean_chat_button ?? L, S = w?.proactive_message_hide_delay ?? p, D = v(
2267
- (ce) => {
2268
- g || ee((Pe) => {
2269
- const ot = typeof ce == "function" ? ce(Pe) : ce;
2270
- return ot ? Yt(j) : Xt(j, "true", pn), ot;
2266
+ const G = w?.initial_open ?? O, m = w?.close_button ?? L, x = k ?? w?.clean_chat_button ?? D, S = w?.proactive_message_hide_delay ?? p, A = v(
2267
+ (ue) => {
2268
+ g || re((Pe) => {
2269
+ const ot = typeof ue == "function" ? ue(Pe) : ue;
2270
+ return ot ? Yt(P) : Xt(P, "true", pn), ot;
2271
2271
  });
2272
2272
  },
2273
- [j, g]
2274
- ), B = $t(Q, 400), [T, $] = C(
2273
+ [P, g]
2274
+ ), $ = $t(ee, 400), [T, B] = C(
2275
2275
  d?.messages ?? []
2276
- ), [F, ue] = C(y), [ge, ye] = C(!1), [xe, ke] = C(P);
2277
- xe !== P && (ke(P), P.length > 0 && $(P));
2276
+ ), [V, ie] = C(y), [ye, ce] = C(!1), [me, ke] = C(M);
2277
+ me !== M && (ke(M), M.length > 0 && B(M));
2278
2278
  const [$e, N] = C(y);
2279
- $e !== y && (N(y), y && ue(y));
2280
- const [ae, re] = C(G);
2281
- ae !== G && (re(G), G && ye(!0));
2279
+ $e !== y && (N(y), y && ie(y));
2280
+ const [ne, te] = C(F);
2281
+ ne !== F && (te(F), F && ce(!0));
2282
2282
  const Re = v(() => {
2283
- ye(!0);
2284
- }, []), [Be, Ne] = C(!1), qe = ne && w?.auto_display_welcome_message && w?.welcome_message ? w.welcome_message : "", le = {
2285
- text: qe,
2286
- isVisible: qe !== "" && !Be,
2283
+ ce(!0);
2284
+ }, []), [Be, Ne] = C(!1), xe = oe && w?.auto_display_welcome_message && w?.welcome_message ? w.welcome_message : "", de = {
2285
+ text: xe,
2286
+ isVisible: xe !== "" && !Be,
2287
2287
  autoHideDelay: S
2288
- }, { onSendMessage: X, onCleanMessages: ie, onRateChat: xt } = Xr({
2288
+ }, { onSendMessage: X, onCleanMessages: se, onRateChat: xt } = Xr({
2289
2289
  appId: o,
2290
- userId: A,
2290
+ userId: j,
2291
2291
  userName: n,
2292
2292
  userData: i,
2293
2293
  externalId: _,
2294
- deviceId: I,
2295
- apiClient: R,
2294
+ deviceId: z,
2295
+ apiClient: E,
2296
2296
  chatSettings: w,
2297
- setMessages: $,
2297
+ setMessages: B,
2298
2298
  messages: T,
2299
- currentChat: F,
2300
- setCurrentChat: ue,
2299
+ currentChat: V,
2300
+ setCurrentChat: ie,
2301
2301
  onChatClosed: Re,
2302
- isChatClosed: ge
2302
+ isChatClosed: ye
2303
2303
  });
2304
- H(() => {
2305
- P.length > 0 && $(P);
2306
- }, [P]), H(() => {
2307
- y && ue(y);
2304
+ K(() => {
2305
+ M.length > 0 && B(M);
2306
+ }, [M]), K(() => {
2307
+ y && ie(y);
2308
2308
  }, [y]);
2309
- const tt = K(null);
2310
- H(() => {
2311
- if (!F || !_ || !R) return;
2312
- const ce = {
2313
- userId: A,
2309
+ const tt = Z(null);
2310
+ K(() => {
2311
+ if (!V || !_ || !E) return;
2312
+ const ue = {
2313
+ userId: j,
2314
2314
  userName: n,
2315
2315
  userData: i,
2316
2316
  externalId: _,
2317
- deviceId: I,
2318
- conversationId: F.id
2319
- }, Pe = JSON.stringify(ce);
2320
- tt.current !== Pe && (tt.current = Pe, R.identifyUser(ce));
2317
+ deviceId: z,
2318
+ conversationId: V.id
2319
+ }, Pe = JSON.stringify(ue);
2320
+ tt.current !== Pe && (tt.current = Pe, E.identifyUser(ue));
2321
2321
  }, [
2322
2322
  _,
2323
- A,
2323
+ j,
2324
2324
  n,
2325
2325
  i,
2326
- I,
2327
- F,
2328
- R
2326
+ z,
2327
+ V,
2328
+ E
2329
2329
  ]);
2330
2330
  const kt = v(() => {
2331
- ie(), ye(!1);
2332
- }, [ie]), _t = v(() => {
2331
+ se(), ce(!1);
2332
+ }, [se]), _t = v(() => {
2333
2333
  Ne(!0);
2334
2334
  }, []);
2335
2335
  return {
2336
- isReady: ne,
2336
+ isReady: oe,
2337
2337
  isChatActive: Y,
2338
- isInitiallyOpen: W,
2338
+ isInitiallyOpen: G,
2339
2339
  hasCloseButton: m,
2340
- hasCleanChatButton: k,
2340
+ hasCleanChatButton: x,
2341
2341
  isMobile: b,
2342
- chatId: F?.id ?? null,
2343
- chatInterfaceProps: M,
2344
- chatOpen: Q,
2345
- chatOpenDebounced: B,
2342
+ chatId: V?.id ?? null,
2343
+ chatInterfaceProps: Q,
2344
+ chatOpen: ee,
2345
+ chatOpenDebounced: $,
2346
2346
  messages: T,
2347
- portalContainer: z,
2347
+ portalContainer: I,
2348
2348
  onSendMessage: X,
2349
- setChatOpen: D,
2350
- onCleanMessages: ie,
2351
- proactiveMessage: le,
2349
+ setChatOpen: A,
2350
+ onCleanMessages: se,
2351
+ proactiveMessage: de,
2352
2352
  hideProactiveMessage: _t,
2353
- isChatClosed: ge,
2353
+ isChatClosed: ye,
2354
2354
  onStartNewChat: kt,
2355
2355
  onRateChat: xt
2356
2356
  };
2357
2357
  }
2358
2358
  function mn(t) {
2359
2359
  const [e, o] = C(0);
2360
- return H(() => {
2360
+ return K(() => {
2361
2361
  const r = window.visualViewport;
2362
2362
  if (!t || !r) {
2363
2363
  o(0);
@@ -2373,7 +2373,7 @@ function mn(t) {
2373
2373
  }, [t]), e;
2374
2374
  }
2375
2375
  function bn(t) {
2376
- H(() => {
2376
+ K(() => {
2377
2377
  if (!t) return;
2378
2378
  const { body: e } = document, o = window.scrollY, r = {
2379
2379
  position: e.style.position,
@@ -2388,7 +2388,7 @@ function bn(t) {
2388
2388
  }, [t]);
2389
2389
  }
2390
2390
  function vn() {
2391
- const [t, e] = C(!1), [o, r] = C(null), n = K(null), i = K(null), d = v((c = "...") => {
2391
+ const [t, e] = C(!1), [o, r] = C(null), n = Z(null), i = Z(null), d = v((c = "...") => {
2392
2392
  const a = () => {
2393
2393
  r(c), e(!0), i.current = null, n.current && clearTimeout(n.current), n.current = setTimeout(() => {
2394
2394
  n.current = null, i.current && a();
@@ -2440,37 +2440,38 @@ function xn({
2440
2440
  INTERNAL_ONLY_CHAT_INTERFACE_ONLY: h = !1,
2441
2441
  INTERNAL_ONLY_SHOW_CLEAN_CHAT_BUTTON: p = void 0,
2442
2442
  INTERNAL_ONLY_BLOCK_STYLE: g = !1,
2443
- INTERNAL_ONLY_FEATURE_MESSAGE_CLICK: x = void 0,
2443
+ INTERNAL_ONLY_FEATURE_MESSAGE_CLICK: k = void 0,
2444
2444
  INTERNAL_ONLY_FEATURE_CLEAR_CHAT_CLICK: b = void 0,
2445
- INTERNAL_ONLY_ON_CHAT_ID: z = void 0,
2446
- INTERNAL_ONLY_HIGHLIGHTED_MESSAGE_ID: A = null,
2447
- INTERNAL_ONLY_SHOW_COPY_BUTTON: _ = !1,
2448
- INTERNAL_ONLY_ENVIRONMENT: I = "live",
2449
- INTERNAL_ONLY_API_URL: R
2445
+ INTERNAL_ONLY_ON_CHAT_ID: I = void 0,
2446
+ INTERNAL_ONLY_HIGHLIGHTED_MESSAGE_ID: j = null,
2447
+ INTERNAL_ONLY_ON_MESSAGE_SENT: _ = void 0,
2448
+ INTERNAL_ONLY_SHOW_COPY_BUTTON: z = !1,
2449
+ INTERNAL_ONLY_ENVIRONMENT: E = "live",
2450
+ INTERNAL_ONLY_API_URL: w
2450
2451
  }) {
2451
- const { hideSdk: w } = je(), {
2452
- isReady: y,
2453
- isChatActive: P,
2454
- isInitiallyOpen: ne,
2455
- hasCloseButton: G,
2456
- hasCleanChatButton: Y,
2457
- isMobile: M,
2458
- chatId: Z,
2459
- chatOpen: U,
2460
- chatInterfaceProps: L,
2461
- chatOpenDebounced: j,
2462
- messages: Q,
2463
- portalContainer: ee,
2464
- onSendMessage: te,
2465
- setChatOpen: oe,
2466
- proactiveMessage: W,
2467
- hideProactiveMessage: m,
2468
- isChatClosed: k,
2469
- onStartNewChat: S,
2470
- onRateChat: D
2452
+ const { hideSdk: y } = je(), {
2453
+ isReady: M,
2454
+ isChatActive: oe,
2455
+ isInitiallyOpen: F,
2456
+ hasCloseButton: Y,
2457
+ hasCleanChatButton: Q,
2458
+ isMobile: O,
2459
+ chatId: L,
2460
+ chatOpen: D,
2461
+ chatInterfaceProps: P,
2462
+ chatOpenDebounced: ee,
2463
+ messages: re,
2464
+ portalContainer: J,
2465
+ onSendMessage: ae,
2466
+ setChatOpen: G,
2467
+ proactiveMessage: m,
2468
+ hideProactiveMessage: x,
2469
+ isChatClosed: S,
2470
+ onStartNewChat: A,
2471
+ onRateChat: $
2471
2472
  } = gn({
2472
- environment: I,
2473
- apiUrl: R,
2473
+ environment: E,
2474
+ apiUrl: w,
2474
2475
  appId: t,
2475
2476
  userId: e,
2476
2477
  userName: o,
@@ -2488,15 +2489,15 @@ function xn({
2488
2489
  // it, so nothing (boot initial_open, closed-cookie, props) may close it.
2489
2490
  isAlwaysOpen: h,
2490
2491
  hasCleanChatButtonOverride: p
2491
- }), B = K(void 0);
2492
- H(() => {
2493
- !z || B.current === Z || (B.current = Z, z(Z));
2494
- }, [Z, z]);
2495
- const T = mn(M && U);
2496
- bn(M && U);
2497
- const $ = !y;
2498
- if (w || $ && !h || !$ && !P) return null;
2499
- const F = () => /* @__PURE__ */ ze(
2492
+ }), T = Z(void 0);
2493
+ K(() => {
2494
+ !I || T.current === L || (T.current = L, I(L));
2495
+ }, [L, I]);
2496
+ const B = mn(O && D);
2497
+ bn(O && D);
2498
+ const V = !M;
2499
+ if (y || V && !h || !V && !oe) return null;
2500
+ const ie = () => /* @__PURE__ */ ze(
2500
2501
  "div",
2501
2502
  {
2502
2503
  style: {
@@ -2530,19 +2531,19 @@ function xn({
2530
2531
  /* @__PURE__ */ q("style", { children: Le })
2531
2532
  ] }),
2532
2533
  style: {
2533
- display: U || j ? "block" : "none",
2534
- width: M ? "100vw" : "400px",
2534
+ display: D || ee ? "block" : "none",
2535
+ width: O ? "100vw" : "400px",
2535
2536
  // 100dvh accounts for mobile browser chrome (e.g. address bar); 100vh fallback for older browsers
2536
2537
  "--chat-mobile-viewport-height": "100dvh",
2537
- height: M ? "var(--chat-mobile-viewport-height, 100vh)" : "700px",
2538
- maxHeight: M ? "var(--chat-mobile-viewport-height, 100vh)" : `calc(100% - ${yn}px)`,
2538
+ height: O ? "var(--chat-mobile-viewport-height, 100vh)" : "700px",
2539
+ maxHeight: O ? "var(--chat-mobile-viewport-height, 100vh)" : `calc(100% - ${yn}px)`,
2539
2540
  border: "none",
2540
2541
  zIndex: 2147483e3,
2541
2542
  position: "fixed",
2542
- top: M ? 0 : void 0,
2543
- left: M ? 0 : void 0,
2544
- right: M ? 0 : 16,
2545
- bottom: M ? 0 : 16,
2543
+ top: O ? 0 : void 0,
2544
+ left: O ? 0 : void 0,
2545
+ right: O ? 0 : 16,
2546
+ bottom: O ? 0 : 16,
2546
2547
  ...g ? {
2547
2548
  position: "relative",
2548
2549
  top: 0,
@@ -2555,34 +2556,34 @@ function xn({
2555
2556
  zIndex: 0
2556
2557
  } : {}
2557
2558
  },
2558
- children: $ ? (
2559
+ children: V ? (
2559
2560
  // Only reachable in embedded mode (the launcher returns null while
2560
2561
  // booting): hold the widget's frame with a skeleton so a remount —
2561
2562
  // project/environment switch in the host app — doesn't flash an
2562
2563
  // empty hole where the chat was.
2563
- /* @__PURE__ */ q(Zt, { isOpen: !0, isMobile: M, skipAnimation: !0 })
2564
+ /* @__PURE__ */ q(Zt, { isOpen: !0, isMobile: O, skipAnimation: !0 })
2564
2565
  ) : /* @__PURE__ */ q(
2565
2566
  Kt,
2566
2567
  {
2567
- ...L,
2568
+ ...P,
2568
2569
  hasIntroAnimation: !h,
2569
- isTestMode: I === "test",
2570
- isOpen: U,
2571
- keyboardInset: T,
2572
- messages: Q,
2573
- onSendMessage: te,
2574
- onMessageClick: x,
2575
- highlightedMessageId: A,
2576
- isMobile: M,
2577
- hasCloseButton: G,
2578
- hasCleanChatButton: Y,
2579
- hasCopyButton: _,
2580
- isChatClosed: k,
2581
- onStartNewChat: S,
2582
- onRateChat: D,
2583
- onClose: () => oe(!1),
2570
+ isTestMode: E === "test",
2571
+ isOpen: D,
2572
+ keyboardInset: B,
2573
+ messages: re,
2574
+ onSendMessage: (ce, me) => (_?.(ce), ae(ce, me)),
2575
+ onMessageClick: k,
2576
+ highlightedMessageId: j,
2577
+ isMobile: O,
2578
+ hasCloseButton: Y,
2579
+ hasCleanChatButton: Q,
2580
+ hasCopyButton: z,
2581
+ isChatClosed: S,
2582
+ onStartNewChat: A,
2583
+ onRateChat: $,
2584
+ onClose: () => G(!1),
2584
2585
  onCleanChat: () => {
2585
- S(), b?.();
2586
+ A(), b?.();
2586
2587
  }
2587
2588
  }
2588
2589
  )
@@ -2601,22 +2602,22 @@ function xn({
2601
2602
  width: 48,
2602
2603
  height: 48,
2603
2604
  border: "none",
2604
- zIndex: M ? 2147482999 : 2147483e3,
2605
- opacity: U ? 0 : 1,
2606
- pointerEvents: U ? "none" : "auto",
2607
- transition: U ? "opacity 100ms ease-in" : "opacity 200ms ease-out 320ms"
2605
+ zIndex: O ? 2147482999 : 2147483e3,
2606
+ opacity: D ? 0 : 1,
2607
+ pointerEvents: D ? "none" : "auto",
2608
+ transition: D ? "opacity 100ms ease-in" : "opacity 200ms ease-out 320ms"
2608
2609
  },
2609
2610
  children: /* @__PURE__ */ q(
2610
2611
  Ft,
2611
2612
  {
2612
- isOpen: U,
2613
- toggleBubble: () => oe((ge) => !ge),
2614
- isDarkMode: L?.theme?.mode === "dark"
2613
+ isOpen: D,
2614
+ toggleBubble: () => G((ce) => !ce),
2615
+ isDarkMode: P?.theme?.mode === "dark"
2615
2616
  }
2616
2617
  )
2617
2618
  }
2618
2619
  ),
2619
- L?.displayWelcomeMessages ? /* @__PURE__ */ q(
2620
+ P?.displayWelcomeMessages ? /* @__PURE__ */ q(
2620
2621
  Ze,
2621
2622
  {
2622
2623
  className: "eloquentai-chat-proactive-message",
@@ -2629,22 +2630,22 @@ function xn({
2629
2630
  bottom: 24,
2630
2631
  right: 17
2631
2632
  },
2632
- children: /* @__PURE__ */ q(Ht, { ...L?.theme ?? {}, children: /* @__PURE__ */ q(
2633
+ children: /* @__PURE__ */ q(Ht, { ...P?.theme ?? {}, children: /* @__PURE__ */ q(
2633
2634
  "div",
2634
2635
  {
2635
2636
  className: Xe("eloq:w-full eloq:h-full", {
2636
- dark: L?.theme?.mode === "dark"
2637
+ dark: P?.theme?.mode === "dark"
2637
2638
  }),
2638
- children: W && !ne && /* @__PURE__ */ q(
2639
+ children: m && !F && /* @__PURE__ */ q(
2639
2640
  Gt,
2640
2641
  {
2641
- message: W.text,
2642
- isVisible: W.isVisible,
2643
- onDismiss: m,
2642
+ message: m.text,
2643
+ isVisible: m.isVisible,
2644
+ onDismiss: x,
2644
2645
  onMessageClick: () => {
2645
- oe(!0), m();
2646
+ G(!0), x();
2646
2647
  },
2647
- autoHideDelay: W.autoHideDelay
2648
+ autoHideDelay: m.autoHideDelay
2648
2649
  }
2649
2650
  )
2650
2651
  }
@@ -2654,7 +2655,7 @@ function xn({
2654
2655
  ]
2655
2656
  }
2656
2657
  );
2657
- return /* @__PURE__ */ q(at, { children: g ? F() : ee ? /* @__PURE__ */ q(Jt, { container: ee, children: F() }) : null });
2658
+ return /* @__PURE__ */ q(at, { children: g ? ie() : J ? /* @__PURE__ */ q(Jt, { container: J, children: ie() }) : null });
2658
2659
  }
2659
2660
  function kn(t) {
2660
2661
  return /* @__PURE__ */ q(qn, { children: /* @__PURE__ */ q(wn, { children: /* @__PURE__ */ q(xn, { ...t }) }) });