@eloquentai/chat-sdk 0.36.0-dev.2 → 0.36.0
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 +171 -171
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,11 +6,11 @@ import { createPortal as Ge } from "react-dom";
|
|
|
6
6
|
import Xt from "react-dom/client";
|
|
7
7
|
try {
|
|
8
8
|
let e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, t = new e.Error().stack;
|
|
9
|
-
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "
|
|
9
|
+
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "0f0cacb8-b6c4-4392-a4a8-2de01d4f72f9", e._sentryDebugIdIdentifier = "sentry-dbid-0f0cacb8-b6c4-4392-a4a8-2de01d4f72f9");
|
|
10
10
|
} catch {
|
|
11
11
|
}
|
|
12
12
|
if (typeof window < "u") {
|
|
13
|
-
const e = "
|
|
13
|
+
const e = "production";
|
|
14
14
|
import("./index-hFbiYJI3.js").then(({ init: t }) => {
|
|
15
15
|
t({
|
|
16
16
|
dsn: void 0,
|
|
@@ -69,26 +69,26 @@ function oo({
|
|
|
69
69
|
onMessageClick: r,
|
|
70
70
|
autoHideDelay: n
|
|
71
71
|
}) {
|
|
72
|
-
const [i, c] = _(!1), [s,
|
|
72
|
+
const [i, c] = _(!1), [s, u] = _("entering"), a = Mt();
|
|
73
73
|
return Z(() => {
|
|
74
74
|
if (t) {
|
|
75
|
-
c(!0),
|
|
75
|
+
c(!0), u("entering");
|
|
76
76
|
const l = setTimeout(() => {
|
|
77
|
-
|
|
77
|
+
u("visible");
|
|
78
78
|
}, 50);
|
|
79
|
-
let
|
|
79
|
+
let d;
|
|
80
80
|
const p = setTimeout(() => {
|
|
81
|
-
|
|
81
|
+
u("exiting"), d = setTimeout(() => {
|
|
82
82
|
o();
|
|
83
83
|
}, 300);
|
|
84
84
|
}, n);
|
|
85
85
|
return () => {
|
|
86
|
-
clearTimeout(l), clearTimeout(p), clearTimeout(
|
|
86
|
+
clearTimeout(l), clearTimeout(p), clearTimeout(d);
|
|
87
87
|
};
|
|
88
88
|
} else {
|
|
89
|
-
|
|
89
|
+
u("exiting");
|
|
90
90
|
const l = setTimeout(() => {
|
|
91
|
-
c(!1),
|
|
91
|
+
c(!1), u("entering");
|
|
92
92
|
}, 300);
|
|
93
93
|
return () => clearTimeout(l);
|
|
94
94
|
}
|
|
@@ -256,14 +256,14 @@ function tt({ appId: e }) {
|
|
|
256
256
|
return console.error("Error checking conversation expiration:", a), !0;
|
|
257
257
|
}
|
|
258
258
|
}, [r]), i = w(
|
|
259
|
-
(a, l,
|
|
259
|
+
(a, l, d, p, h) => {
|
|
260
260
|
try {
|
|
261
261
|
if (!Ce) return;
|
|
262
262
|
const f = {
|
|
263
263
|
conversationId: a,
|
|
264
264
|
userId: l,
|
|
265
265
|
deviceId: p,
|
|
266
|
-
messages: co(
|
|
266
|
+
messages: co(d),
|
|
267
267
|
lastActivity: Date.now(),
|
|
268
268
|
chatToken: h
|
|
269
269
|
};
|
|
@@ -308,7 +308,7 @@ function tt({ appId: e }) {
|
|
|
308
308
|
a
|
|
309
309
|
);
|
|
310
310
|
}
|
|
311
|
-
}, [t, o]),
|
|
311
|
+
}, [t, o]), u = w(() => {
|
|
312
312
|
try {
|
|
313
313
|
if (!Ce) return;
|
|
314
314
|
const a = r();
|
|
@@ -322,7 +322,7 @@ function tt({ appId: e }) {
|
|
|
322
322
|
saveChatData: i,
|
|
323
323
|
clearChatData: s,
|
|
324
324
|
getSavedChatData: r,
|
|
325
|
-
updateLastActivity:
|
|
325
|
+
updateLastActivity: u,
|
|
326
326
|
markChatClosed: c
|
|
327
327
|
};
|
|
328
328
|
}
|
|
@@ -358,17 +358,17 @@ function wo(e) {
|
|
|
358
358
|
channel: r,
|
|
359
359
|
onEvent: n,
|
|
360
360
|
onDisconnect: i,
|
|
361
|
-
createWebSocket: c = (l,
|
|
362
|
-
} = e, s = bo(t, o),
|
|
363
|
-
return new Promise((l,
|
|
361
|
+
createWebSocket: c = (l, d) => new WebSocket(l, d)
|
|
362
|
+
} = e, s = bo(t, o), u = mo(t), a = crypto.randomUUID();
|
|
363
|
+
return new Promise((l, d) => {
|
|
364
364
|
let p;
|
|
365
365
|
try {
|
|
366
|
-
p = c(
|
|
366
|
+
p = c(u, [
|
|
367
367
|
uo,
|
|
368
368
|
vo(s)
|
|
369
369
|
]);
|
|
370
370
|
} catch (m) {
|
|
371
|
-
|
|
371
|
+
d(m instanceof Error ? m : new Error(String(m)));
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
374
|
let h = "connecting", f = !1, g = ho, k = Date.now(), q = null, I = null;
|
|
@@ -382,7 +382,7 @@ function wo(e) {
|
|
|
382
382
|
p.close();
|
|
383
383
|
} catch {
|
|
384
384
|
}
|
|
385
|
-
f || (y ? i(m) :
|
|
385
|
+
f || (y ? i(m) : d(new Error(m)));
|
|
386
386
|
}, $ = (m) => {
|
|
387
387
|
p.readyState === go && p.send(JSON.stringify(m));
|
|
388
388
|
}, R = (m) => {
|
|
@@ -558,7 +558,7 @@ function Ie(e, t) {
|
|
|
558
558
|
function Se(e) {
|
|
559
559
|
return typeof e == "string" ? e : e?.message;
|
|
560
560
|
}
|
|
561
|
-
function
|
|
561
|
+
function ut(e, t, o) {
|
|
562
562
|
var r;
|
|
563
563
|
for (let n = t; n < e.length; n++)
|
|
564
564
|
(r = e[n]).schema ?? (r.schema = o);
|
|
@@ -568,8 +568,8 @@ function xe(e, t, o) {
|
|
|
568
568
|
const n = e.inst?._zod?.traits;
|
|
569
569
|
n?.has("$ZodType") && (n.has("$ZodCheck") ? (r = e).schema ?? (r.schema = e.inst) : e.schema = e.inst);
|
|
570
570
|
const i = e.schema !== e.inst ? e.schema?._zod.def?.error : void 0, c = e.message ? e.message : Se(e.inst?._zod.def?.error?.(e)) ?? Se(i?.(e)) ?? Se(t?.error?.(e)) ?? Se(o.customError?.(e)) ?? Se(o.localeError?.(e)) ?? "Invalid input", s = {};
|
|
571
|
-
for (const
|
|
572
|
-
|
|
571
|
+
for (const u of Object.keys(e))
|
|
572
|
+
u === "inst" || u === "schema" || u === "continue" || u === "input" || u === "__proto__" || (s[u] = e[u]);
|
|
573
573
|
return s.path ?? (s.path = []), s.message = c, t?.reportInput && (s.input = e.input), s;
|
|
574
574
|
}
|
|
575
575
|
function Eo(e, t) {
|
|
@@ -606,7 +606,7 @@ const Mo = {
|
|
|
606
606
|
be = !0;
|
|
607
607
|
}
|
|
608
608
|
};
|
|
609
|
-
function
|
|
609
|
+
function ue(e, t, o) {
|
|
610
610
|
const r = Object.getPrototypeOf(e._zod);
|
|
611
611
|
if (t in r && He !== e._zod) {
|
|
612
612
|
He = void 0;
|
|
@@ -643,7 +643,7 @@ function Po(e, t, o, r) {
|
|
|
643
643
|
}
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
|
-
var
|
|
646
|
+
var dt;
|
|
647
647
|
const We = { value: void 0, enumerable: !1 };
|
|
648
648
|
let pt = "captureStackTrace" in Error ? Error : null;
|
|
649
649
|
function Ao(e) {
|
|
@@ -668,11 +668,11 @@ function Ao(e) {
|
|
|
668
668
|
function F(e, t, o, r) {
|
|
669
669
|
const n = {};
|
|
670
670
|
function i(p) {
|
|
671
|
-
this.def = p, this.constr =
|
|
671
|
+
this.def = p, this.constr = d, this.traits = /* @__PURE__ */ new Set();
|
|
672
672
|
}
|
|
673
673
|
i.prototype = n;
|
|
674
674
|
const c = o, s = c && /* @__PURE__ */ new WeakSet();
|
|
675
|
-
function
|
|
675
|
+
function u(p, h) {
|
|
676
676
|
if (p._zod) {
|
|
677
677
|
if (p._zod.traits.has(e))
|
|
678
678
|
return;
|
|
@@ -692,7 +692,7 @@ function F(e, t, o, r) {
|
|
|
692
692
|
const I = q ?? g;
|
|
693
693
|
s.has(I) || (s.add(I), Eo(I, c));
|
|
694
694
|
}
|
|
695
|
-
const f =
|
|
695
|
+
const f = d.prototype;
|
|
696
696
|
for (const g in f)
|
|
697
697
|
Object.prototype.hasOwnProperty.call(f, g) && (g in p || (p[g] = f[g].bind(p)));
|
|
698
698
|
}
|
|
@@ -700,9 +700,9 @@ function F(e, t, o, r) {
|
|
|
700
700
|
class l extends a {
|
|
701
701
|
}
|
|
702
702
|
Object.defineProperty(l, "name", { value: e });
|
|
703
|
-
function
|
|
703
|
+
function d(p) {
|
|
704
704
|
const h = r?.Parent ? Ao(l) : this;
|
|
705
|
-
|
|
705
|
+
u(h, p);
|
|
706
706
|
const f = h._zod.deferred;
|
|
707
707
|
if (f) {
|
|
708
708
|
for (const k of f)
|
|
@@ -712,16 +712,16 @@ function F(e, t, o, r) {
|
|
|
712
712
|
const g = globalThis.__zod_globalConfig?.postProcessor;
|
|
713
713
|
return g && g(h), h;
|
|
714
714
|
}
|
|
715
|
-
return Object.defineProperty(
|
|
715
|
+
return Object.defineProperty(d, "init", { value: u }), Object.defineProperty(d, Symbol.hasInstance, {
|
|
716
716
|
value: (p) => r?.Parent && p instanceof r.Parent ? !0 : p?._zod?.traits?.has(e)
|
|
717
|
-
}), Object.defineProperty(
|
|
717
|
+
}), Object.defineProperty(d, "name", { value: e }), d;
|
|
718
718
|
}
|
|
719
719
|
class Ee extends Error {
|
|
720
720
|
constructor() {
|
|
721
721
|
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
|
-
(
|
|
724
|
+
(dt = globalThis).__zod_globalConfig ?? (dt.__zod_globalConfig = {});
|
|
725
725
|
const Ue = globalThis.__zod_globalConfig;
|
|
726
726
|
function ve(e) {
|
|
727
727
|
return e && Object.assign(Ue, e), Ue;
|
|
@@ -760,8 +760,8 @@ const jo = {
|
|
|
760
760
|
if (s instanceof Promise)
|
|
761
761
|
throw new Ee();
|
|
762
762
|
if (s.issues.length) {
|
|
763
|
-
const
|
|
764
|
-
throw xt(
|
|
763
|
+
const u = new (i?.Err ?? e)(s.issues.map((a) => xe(a, c, ve())));
|
|
764
|
+
throw xt(u, i?.callee ?? t), u;
|
|
765
765
|
}
|
|
766
766
|
return s.value;
|
|
767
767
|
};
|
|
@@ -771,8 +771,8 @@ const jo = {
|
|
|
771
771
|
const c = n ? { ...n, async: !0 } : { async: !0 };
|
|
772
772
|
let s = o._zod.run({ value: r, issues: [] }, c);
|
|
773
773
|
if (s instanceof Promise && (s = await s), s.issues.length) {
|
|
774
|
-
const
|
|
775
|
-
throw xt(
|
|
774
|
+
const u = new (i?.Err ?? e)(s.issues.map((a) => xe(a, c, ve())));
|
|
775
|
+
throw xt(u, i?.callee ?? t), u;
|
|
776
776
|
}
|
|
777
777
|
return s.value;
|
|
778
778
|
};
|
|
@@ -815,11 +815,11 @@ const Vo = (e) => async (t, o, r) => {
|
|
|
815
815
|
e._zod.run = e._zod.parse;
|
|
816
816
|
});
|
|
817
817
|
else {
|
|
818
|
-
const i = (s,
|
|
818
|
+
const i = (s, u, a) => {
|
|
819
819
|
if (s.memo)
|
|
820
820
|
return s;
|
|
821
|
-
let l = qe(s),
|
|
822
|
-
for (const p of
|
|
821
|
+
let l = qe(s), d;
|
|
822
|
+
for (const p of u) {
|
|
823
823
|
if (p._zod.def.when) {
|
|
824
824
|
if (Io(s) || !p._zod.def.when(s))
|
|
825
825
|
continue;
|
|
@@ -828,42 +828,42 @@ const Vo = (e) => async (t, o, r) => {
|
|
|
828
828
|
const h = s.issues.length, f = p._zod.check(s);
|
|
829
829
|
if (f instanceof Promise && a?.async === !1)
|
|
830
830
|
throw new Ee();
|
|
831
|
-
if (
|
|
832
|
-
|
|
833
|
-
await f, s.issues.length !== h && (
|
|
831
|
+
if (d || f instanceof Promise)
|
|
832
|
+
d = (d ?? Promise.resolve()).then(async () => {
|
|
833
|
+
await f, s.issues.length !== h && (ut(s.issues, h, e), l || (l = qe(s, h)));
|
|
834
834
|
});
|
|
835
835
|
else {
|
|
836
836
|
if (s.issues.length === h)
|
|
837
837
|
continue;
|
|
838
|
-
|
|
838
|
+
ut(s.issues, h, e), l || (l = qe(s, h));
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
|
-
return
|
|
842
|
-
}, c = (s,
|
|
841
|
+
return d ? d.then(() => s) : s;
|
|
842
|
+
}, c = (s, u, a) => {
|
|
843
843
|
if (qe(s))
|
|
844
844
|
return s.aborted = !0, s;
|
|
845
|
-
const l = i(
|
|
845
|
+
const l = i(u, n, a);
|
|
846
846
|
if (l instanceof Promise) {
|
|
847
847
|
if (a.async === !1)
|
|
848
848
|
throw new Ee();
|
|
849
|
-
return l.then((
|
|
849
|
+
return l.then((d) => e._zod.parse(d, a));
|
|
850
850
|
}
|
|
851
851
|
return e._zod.parse(l, a);
|
|
852
852
|
};
|
|
853
|
-
e._zod.run = (s,
|
|
854
|
-
if (
|
|
855
|
-
return e._zod.parse(s,
|
|
856
|
-
if (
|
|
857
|
-
const l = e._zod.parse({ value: s.value, issues: [] }, { ...
|
|
858
|
-
return l instanceof Promise ? l.then((
|
|
853
|
+
e._zod.run = (s, u) => {
|
|
854
|
+
if (u.skipChecks)
|
|
855
|
+
return e._zod.parse(s, u);
|
|
856
|
+
if (u.direction === "backward") {
|
|
857
|
+
const l = e._zod.parse({ value: s.value, issues: [] }, { ...u, skipChecks: !0 });
|
|
858
|
+
return l instanceof Promise ? l.then((d) => c(d, s, u)) : c(l, s, u);
|
|
859
859
|
}
|
|
860
|
-
const a = e._zod.parse(s,
|
|
860
|
+
const a = e._zod.parse(s, u);
|
|
861
861
|
if (a instanceof Promise) {
|
|
862
|
-
if (
|
|
862
|
+
if (u.async === !1)
|
|
863
863
|
throw new Ee();
|
|
864
|
-
return a.then((l) => i(l, n,
|
|
864
|
+
return a.then((l) => i(l, n, u));
|
|
865
865
|
}
|
|
866
|
-
return i(a, n,
|
|
866
|
+
return i(a, n, u);
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
869
|
}, {
|
|
@@ -958,7 +958,7 @@ function or(e) {
|
|
|
958
958
|
};
|
|
959
959
|
}
|
|
960
960
|
function rr(e, t, o, r, n, i, c) {
|
|
961
|
-
const s = [],
|
|
961
|
+
const s = [], u = n.keySet, a = n.catchall._zod, l = a.def.type, d = a.optin, p = a.optout;
|
|
962
962
|
let h = 0;
|
|
963
963
|
for (const f in t) {
|
|
964
964
|
if (c && o.issues.length !== h) {
|
|
@@ -966,7 +966,7 @@ function rr(e, t, o, r, n, i, c) {
|
|
|
966
966
|
break;
|
|
967
967
|
h = o.issues.length;
|
|
968
968
|
}
|
|
969
|
-
if (
|
|
969
|
+
if (u.has(f))
|
|
970
970
|
continue;
|
|
971
971
|
if (f === "__proto__") {
|
|
972
972
|
l === "never" && s.push(f);
|
|
@@ -977,7 +977,7 @@ function rr(e, t, o, r, n, i, c) {
|
|
|
977
977
|
continue;
|
|
978
978
|
}
|
|
979
979
|
const g = a.run({ value: t[f], issues: [] }, r);
|
|
980
|
-
g instanceof Promise ? e.push(g.then((k) => je(k, o, f, t,
|
|
980
|
+
g instanceof Promise ? e.push(g.then((k) => je(k, o, f, t, d, p))) : je(g, o, f, t, d, p);
|
|
981
981
|
}
|
|
982
982
|
return s.length && o.issues.push({
|
|
983
983
|
code: "unrecognized_keys",
|
|
@@ -999,33 +999,33 @@ const nr = /* @__PURE__ */ F("$ZodObject", (e, t) => {
|
|
|
999
999
|
a.raw = r, Object.defineProperty(t, "shape", { get: a });
|
|
1000
1000
|
}
|
|
1001
1001
|
const n = xo(() => or(t));
|
|
1002
|
-
|
|
1003
|
-
const l = a.def.shape,
|
|
1002
|
+
ue(e, "propValues", (a) => {
|
|
1003
|
+
const l = a.def.shape, d = {};
|
|
1004
1004
|
for (const p in l) {
|
|
1005
1005
|
const h = l[p]._zod;
|
|
1006
1006
|
if (h.values) {
|
|
1007
|
-
Object.prototype.hasOwnProperty.call(
|
|
1007
|
+
Object.prototype.hasOwnProperty.call(d, p) || ko(d, p, /* @__PURE__ */ new Set());
|
|
1008
1008
|
for (const f of h.values)
|
|
1009
|
-
|
|
1010
|
-
h.optin !== void 0 &&
|
|
1009
|
+
d[p].add(f);
|
|
1010
|
+
h.optin !== void 0 && d[p].add(void 0);
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
|
-
return
|
|
1013
|
+
return d;
|
|
1014
1014
|
});
|
|
1015
1015
|
const i = Ye, c = t.catchall;
|
|
1016
1016
|
let s;
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1017
|
+
const u = Ue.memoizer;
|
|
1018
|
+
u?.attach(e), e._zod.parse = (a, l) => {
|
|
1019
1019
|
s ?? (s = n.value);
|
|
1020
|
-
const
|
|
1021
|
-
if (!i(
|
|
1020
|
+
const d = a.value;
|
|
1021
|
+
if (!i(d))
|
|
1022
1022
|
return a.issues.push({
|
|
1023
1023
|
expected: "object",
|
|
1024
1024
|
code: "invalid_type",
|
|
1025
|
-
input:
|
|
1025
|
+
input: d,
|
|
1026
1026
|
inst: e
|
|
1027
1027
|
}), a;
|
|
1028
|
-
a.value =
|
|
1028
|
+
a.value = u ? u.alloc(e, a, {}, l) : {};
|
|
1029
1029
|
const p = [], h = s.shape, f = l?.abortEarly;
|
|
1030
1030
|
let g = a.issues.length;
|
|
1031
1031
|
for (const k of s.allKeys) {
|
|
@@ -1036,10 +1036,10 @@ const nr = /* @__PURE__ */ F("$ZodObject", (e, t) => {
|
|
|
1036
1036
|
}
|
|
1037
1037
|
if (k === "__proto__")
|
|
1038
1038
|
continue;
|
|
1039
|
-
const q = h[k], I = q._zod.optin, j = q._zod.optout, S = q._zod.run({ value:
|
|
1040
|
-
S instanceof Promise ? p.push(S.then(($) => je($, a, k,
|
|
1039
|
+
const q = h[k], I = q._zod.optin, j = q._zod.optout, S = q._zod.run({ value: d[k], issues: [] }, l);
|
|
1040
|
+
S instanceof Promise ? p.push(S.then(($) => je($, a, k, d, I, j))) : je(S, a, k, d, I, j);
|
|
1041
1041
|
}
|
|
1042
|
-
return c ? rr(p,
|
|
1042
|
+
return c ? rr(p, d, a, l, n.value, e, f === !0) : p.length ? Promise.all(p).then(() => a) : a;
|
|
1043
1043
|
};
|
|
1044
1044
|
});
|
|
1045
1045
|
function ft(e, t, o, r) {
|
|
@@ -1055,10 +1055,10 @@ function ft(e, t, o, r) {
|
|
|
1055
1055
|
}), t);
|
|
1056
1056
|
}
|
|
1057
1057
|
const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
1058
|
-
we.init(e, t),
|
|
1058
|
+
we.init(e, t), ue(e, "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), ue(e, "optout", (r) => r.def.options.some((n) => n._zod.optout === "optional") ? "optional" : void 0), ue(e, "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
|
-
}),
|
|
1061
|
+
}), ue(e, "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) => yt(i.source)).join("|")})$`);
|
|
@@ -1071,16 +1071,16 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1071
1071
|
let i = !1;
|
|
1072
1072
|
const c = [];
|
|
1073
1073
|
for (const s of t.options) {
|
|
1074
|
-
const
|
|
1074
|
+
const u = s._zod.run({
|
|
1075
1075
|
value: r.value,
|
|
1076
1076
|
issues: []
|
|
1077
1077
|
}, n);
|
|
1078
|
-
if (
|
|
1079
|
-
c.push(
|
|
1078
|
+
if (u instanceof Promise)
|
|
1079
|
+
c.push(u), i = !0;
|
|
1080
1080
|
else {
|
|
1081
|
-
if (
|
|
1082
|
-
return
|
|
1083
|
-
c.push(
|
|
1081
|
+
if (u.issues.length === 0)
|
|
1082
|
+
return u;
|
|
1083
|
+
c.push(u);
|
|
1084
1084
|
}
|
|
1085
1085
|
}
|
|
1086
1086
|
return i ? Promise.all(c).then((s) => ft(s, r, e, n)) : ft(c, r, e, n);
|
|
@@ -1100,26 +1100,26 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1100
1100
|
const c = [], s = t.keyType._zod.values;
|
|
1101
1101
|
if (s && !t.partial) {
|
|
1102
1102
|
r.value = o ? o.alloc(e, r, {}, n) : {};
|
|
1103
|
-
const
|
|
1103
|
+
const u = /* @__PURE__ */ new Set();
|
|
1104
1104
|
for (const l of s)
|
|
1105
1105
|
if (typeof l == "string" || typeof l == "number" || typeof l == "symbol") {
|
|
1106
|
-
if (
|
|
1106
|
+
if (u.add(typeof l == "number" ? l.toString() : l), l === "__proto__")
|
|
1107
1107
|
continue;
|
|
1108
|
-
const
|
|
1109
|
-
if (
|
|
1108
|
+
const d = t.keyType._zod.run({ value: l, issues: [] }, n);
|
|
1109
|
+
if (d instanceof Promise)
|
|
1110
1110
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1111
|
-
if (
|
|
1111
|
+
if (d.issues.length) {
|
|
1112
1112
|
r.issues.push({
|
|
1113
1113
|
code: "invalid_key",
|
|
1114
1114
|
origin: "record",
|
|
1115
|
-
issues:
|
|
1115
|
+
issues: d.issues.map((f) => xe(f, n, ve())),
|
|
1116
1116
|
input: l,
|
|
1117
1117
|
path: [l],
|
|
1118
1118
|
inst: e
|
|
1119
1119
|
});
|
|
1120
1120
|
continue;
|
|
1121
1121
|
}
|
|
1122
|
-
const p =
|
|
1122
|
+
const p = d.value;
|
|
1123
1123
|
if (p === "__proto__")
|
|
1124
1124
|
continue;
|
|
1125
1125
|
const h = t.valueType._zod.run({ value: i[l], issues: [] }, n);
|
|
@@ -1129,7 +1129,7 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
let a;
|
|
1131
1131
|
for (const l in i)
|
|
1132
|
-
if (!
|
|
1132
|
+
if (!u.has(l))
|
|
1133
1133
|
if (t.mode === "loose") {
|
|
1134
1134
|
if (l === "__proto__")
|
|
1135
1135
|
continue;
|
|
@@ -1145,7 +1145,7 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1145
1145
|
});
|
|
1146
1146
|
} else {
|
|
1147
1147
|
r.value = o ? o.alloc(e, r, {}, n) : {};
|
|
1148
|
-
let
|
|
1148
|
+
let u;
|
|
1149
1149
|
for (const a of Reflect.ownKeys(i)) {
|
|
1150
1150
|
if (a === "__proto__" || !Object.prototype.propertyIsEnumerable.call(i, a))
|
|
1151
1151
|
continue;
|
|
@@ -1159,7 +1159,7 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1159
1159
|
f.issues.length === 0 && (l = f);
|
|
1160
1160
|
}
|
|
1161
1161
|
if (l.issues.length) {
|
|
1162
|
-
t.mode === "loose" ? r.value[a] = i[a] : s ? (
|
|
1162
|
+
t.mode === "loose" ? r.value[a] = i[a] : s ? (u = u ?? [], u.push(a)) : r.issues.push({
|
|
1163
1163
|
code: "invalid_key",
|
|
1164
1164
|
origin: "record",
|
|
1165
1165
|
issues: l.issues.map((f) => xe(f, n, ve())),
|
|
@@ -1177,11 +1177,11 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1177
1177
|
f.issues.length && r.issues.push(...Ie(a, f.issues)), r.value[p] = f.value;
|
|
1178
1178
|
})) : (h.issues.length && r.issues.push(...Ie(a, h.issues)), r.value[p] = h.value);
|
|
1179
1179
|
}
|
|
1180
|
-
|
|
1180
|
+
u && u.length > 0 && r.issues.push({
|
|
1181
1181
|
code: "unrecognized_keys",
|
|
1182
1182
|
input: i,
|
|
1183
1183
|
inst: e,
|
|
1184
|
-
keys:
|
|
1184
|
+
keys: u,
|
|
1185
1185
|
continue: !0
|
|
1186
1186
|
});
|
|
1187
1187
|
}
|
|
@@ -1190,7 +1190,7 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1190
1190
|
}), sr = /* @__PURE__ */ F("$ZodLiteral", (e, t) => {
|
|
1191
1191
|
we.init(e, t);
|
|
1192
1192
|
const o = new Set(t.values);
|
|
1193
|
-
e._zod.values = o,
|
|
1193
|
+
e._zod.values = o, ue(e, "pattern", (r) => {
|
|
1194
1194
|
const n = r.def.values;
|
|
1195
1195
|
return new RegExp(n.length ? `^(${n.map((i) => typeof i == "string" ? ct(i) : i ? ct(i.toString()) : String(i)).join("|")})$` : "^[^\\s\\S]$");
|
|
1196
1196
|
}), e._zod.parse = (r, n) => {
|
|
@@ -1203,20 +1203,20 @@ const ar = /* @__PURE__ */ F("$ZodUnion", (e, t) => {
|
|
|
1203
1203
|
}), r;
|
|
1204
1204
|
};
|
|
1205
1205
|
}), lr = /* @__PURE__ */ F("$ZodNullable", (e, t) => {
|
|
1206
|
-
we.init(e, t),
|
|
1206
|
+
we.init(e, t), ue(e, "optin", (o) => o.def.innerType._zod.optin), ue(e, "optout", (o) => o.def.innerType._zod.optout), ue(e, "pattern", (o) => {
|
|
1207
1207
|
const r = o.def.innerType._zod.pattern;
|
|
1208
1208
|
return r ? new RegExp(`^(${yt(r.source)}|null)$`) : void 0;
|
|
1209
|
-
}),
|
|
1209
|
+
}), ue(e, "values", (o) => o.def.innerType._zod.values ? /* @__PURE__ */ new Set([...o.def.innerType._zod.values, null]) : void 0), e._zod.parse = (o, r) => o.value === null ? o : t.innerType._zod.run(o, r);
|
|
1210
1210
|
});
|
|
1211
1211
|
function cr(e) {
|
|
1212
1212
|
return e.checks && (e.checks = [...e.checks]), e;
|
|
1213
1213
|
}
|
|
1214
1214
|
// @__NO_SIDE_EFFECTS__
|
|
1215
|
-
function
|
|
1215
|
+
function ur(e, t) {
|
|
1216
1216
|
return new e(cr({ type: "string", ...ye(t) }));
|
|
1217
1217
|
}
|
|
1218
1218
|
// @__NO_SIDE_EFFECTS__
|
|
1219
|
-
function
|
|
1219
|
+
function dr(e, t) {
|
|
1220
1220
|
return new e({
|
|
1221
1221
|
type: "null",
|
|
1222
1222
|
...ye(t)
|
|
@@ -1273,14 +1273,14 @@ const ke = /* @__PURE__ */ F("ZodMiniType", (e, t) => {
|
|
|
1273
1273
|
});
|
|
1274
1274
|
// @__NO_SIDE_EFFECTS__
|
|
1275
1275
|
function E(e) {
|
|
1276
|
-
return /* @__PURE__ */
|
|
1276
|
+
return /* @__PURE__ */ ur(pr, e);
|
|
1277
1277
|
}
|
|
1278
1278
|
const hr = /* @__PURE__ */ F("ZodMiniNull", (e, t) => {
|
|
1279
1279
|
er.init(e, t), ke.init(e, t);
|
|
1280
1280
|
});
|
|
1281
1281
|
// @__NO_SIDE_EFFECTS__
|
|
1282
1282
|
function fr(e) {
|
|
1283
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ dr(hr, e);
|
|
1284
1284
|
}
|
|
1285
1285
|
const gr = /* @__PURE__ */ F("ZodMiniObject", (e, t) => {
|
|
1286
1286
|
nr.init(e, t), ke.init(e, t), Po(e, "shape", (o) => o._zod.def.shape, !1);
|
|
@@ -1437,10 +1437,10 @@ function Fr({
|
|
|
1437
1437
|
onCognitionComplete: i,
|
|
1438
1438
|
onError: c,
|
|
1439
1439
|
onChatClosed: s,
|
|
1440
|
-
onAgentCapturedUrl:
|
|
1440
|
+
onAgentCapturedUrl: u,
|
|
1441
1441
|
onAgentTopic: a,
|
|
1442
1442
|
onAgentSummary: l,
|
|
1443
|
-
onRatingRequest:
|
|
1443
|
+
onRatingRequest: d,
|
|
1444
1444
|
onBreadcrumb: p,
|
|
1445
1445
|
fetchHistory: h,
|
|
1446
1446
|
getChatToken: f,
|
|
@@ -1451,7 +1451,7 @@ function Fr({
|
|
|
1451
1451
|
for (const D of o)
|
|
1452
1452
|
D.id && k.current.add(D.id);
|
|
1453
1453
|
}, [o]);
|
|
1454
|
-
const q = N(null), I = N(null), j = N(0), S = N(null), $ = N(null), R = N(!1), m = N(!1), y = V(r), P = V(n), oe = V(i), G = V(c), re = V(s), ne = V(
|
|
1454
|
+
const q = N(null), I = N(null), j = N(0), S = N(null), $ = N(null), R = N(!1), m = N(!1), y = V(r), P = V(n), oe = V(i), G = V(c), re = V(s), ne = V(u), T = V(a), L = V(l), A = V(d), K = V(p), X = V(h), H = V(f), { publishError: W } = De(), ae = e?.app_sync_url, Q = e?.app_sync_api_key, ee = !!(ae && Q), fe = V(ae), b = V(Q), v = w(() => {
|
|
1455
1455
|
q.current && (q.current.close(), q.current = null);
|
|
1456
1456
|
}, []), C = w(() => {
|
|
1457
1457
|
$.current && (clearInterval($.current), $.current = null);
|
|
@@ -1588,7 +1588,7 @@ function Fr({
|
|
|
1588
1588
|
);
|
|
1589
1589
|
},
|
|
1590
1590
|
[C, z, g]
|
|
1591
|
-
),
|
|
1591
|
+
), de = w(
|
|
1592
1592
|
function D() {
|
|
1593
1593
|
if (!R.current || m.current || S.current)
|
|
1594
1594
|
return;
|
|
@@ -1610,7 +1610,7 @@ function Fr({
|
|
|
1610
1610
|
[B, z]
|
|
1611
1611
|
);
|
|
1612
1612
|
Z(() => {
|
|
1613
|
-
M.current =
|
|
1613
|
+
M.current = de;
|
|
1614
1614
|
});
|
|
1615
1615
|
const pe = w(
|
|
1616
1616
|
async (D) => {
|
|
@@ -1710,17 +1710,17 @@ function rn({
|
|
|
1710
1710
|
deviceId: i,
|
|
1711
1711
|
apiClient: c,
|
|
1712
1712
|
chatSettings: s,
|
|
1713
|
-
messages:
|
|
1713
|
+
messages: u,
|
|
1714
1714
|
setMessages: a,
|
|
1715
1715
|
currentChat: l,
|
|
1716
|
-
setCurrentChat:
|
|
1716
|
+
setCurrentChat: d,
|
|
1717
1717
|
onChatClosed: p,
|
|
1718
1718
|
isChatClosed: h,
|
|
1719
1719
|
onAgentMessage: f
|
|
1720
1720
|
}) {
|
|
1721
1721
|
const { saveChatData: g, clearChatData: k, updateLastActivity: q, markChatClosed: I } = tt({
|
|
1722
1722
|
appId: e
|
|
1723
|
-
}), { publishApiError: j, publishNetworkError: S } = De(), { showCognition: $, hideCognition: R } = jt(), m = V(c), y = V(
|
|
1723
|
+
}), { publishApiError: j, publishNetworkError: S } = De(), { showCognition: $, hideCognition: R } = jt(), m = V(c), y = V(u), P = w(
|
|
1724
1724
|
(b, v) => {
|
|
1725
1725
|
if (!b.response.content) return;
|
|
1726
1726
|
const C = !!s?.welcome_message && b.response.content === s.welcome_message, O = y.current.some(
|
|
@@ -1767,7 +1767,7 @@ function rn({
|
|
|
1767
1767
|
}, [I, p]), { connect: L, disconnect: A, clearProcessedIds: K } = Fr({
|
|
1768
1768
|
chatSettings: s,
|
|
1769
1769
|
chatId: l?.id ?? null,
|
|
1770
|
-
messages:
|
|
1770
|
+
messages: u,
|
|
1771
1771
|
onMessage: P,
|
|
1772
1772
|
onCognition: $,
|
|
1773
1773
|
onCognitionComplete: R,
|
|
@@ -1778,17 +1778,17 @@ function rn({
|
|
|
1778
1778
|
fetchHistory: re,
|
|
1779
1779
|
getChatToken: ne
|
|
1780
1780
|
}), X = w(() => {
|
|
1781
|
-
R(), A(), K(), Dt(
|
|
1781
|
+
R(), A(), K(), Dt(u), a(
|
|
1782
1782
|
(b) => b.filter((v) => Array.isArray(v) ? !1 : v.isWelcomeMessage)
|
|
1783
|
-
), k(),
|
|
1783
|
+
), k(), d(null);
|
|
1784
1784
|
}, [
|
|
1785
1785
|
R,
|
|
1786
1786
|
A,
|
|
1787
1787
|
K,
|
|
1788
|
-
|
|
1788
|
+
u,
|
|
1789
1789
|
k,
|
|
1790
1790
|
a,
|
|
1791
|
-
|
|
1791
|
+
d
|
|
1792
1792
|
]), H = w(
|
|
1793
1793
|
(b, v) => a((C) => en(C, b, v)),
|
|
1794
1794
|
[a]
|
|
@@ -1803,7 +1803,7 @@ function rn({
|
|
|
1803
1803
|
searchParams: io()
|
|
1804
1804
|
}
|
|
1805
1805
|
});
|
|
1806
|
-
|
|
1806
|
+
d({ id: v.chat_id });
|
|
1807
1807
|
try {
|
|
1808
1808
|
await L(v.chat_id);
|
|
1809
1809
|
} catch (C) {
|
|
@@ -1814,7 +1814,7 @@ function rn({
|
|
|
1814
1814
|
}
|
|
1815
1815
|
return v.chat_id;
|
|
1816
1816
|
},
|
|
1817
|
-
[n, t, i, o, r,
|
|
1817
|
+
[n, t, i, o, r, d, L]
|
|
1818
1818
|
), ae = w(
|
|
1819
1819
|
(b, v, C, O) => Promise.all(
|
|
1820
1820
|
C.map(
|
|
@@ -1845,7 +1845,7 @@ function rn({
|
|
|
1845
1845
|
}
|
|
1846
1846
|
j(b), b instanceof Oe && // A 401 means an expired or closed chat token: drop the session so
|
|
1847
1847
|
// the next send starts a fresh one, as for a client-side expiry.
|
|
1848
|
-
(b.status >= 500 || b.status === 401) ? (
|
|
1848
|
+
(b.status >= 500 || b.status === 401) ? (d(null), k(), a((B) => B.filter((z) => z.id !== C)), v.reset()) : M();
|
|
1849
1849
|
},
|
|
1850
1850
|
[
|
|
1851
1851
|
R,
|
|
@@ -1853,18 +1853,18 @@ function rn({
|
|
|
1853
1853
|
H,
|
|
1854
1854
|
S,
|
|
1855
1855
|
j,
|
|
1856
|
-
|
|
1856
|
+
d,
|
|
1857
1857
|
k
|
|
1858
1858
|
]
|
|
1859
1859
|
), ee = w(
|
|
1860
1860
|
async (b, v = []) => {
|
|
1861
|
-
if (!c ||
|
|
1861
|
+
if (!c || u.some((O) => O.isRatingRequest)) return;
|
|
1862
1862
|
if (h) {
|
|
1863
1863
|
a((O) => [...O, Xr()]);
|
|
1864
1864
|
return;
|
|
1865
1865
|
}
|
|
1866
1866
|
const C = Qr(b, v);
|
|
1867
|
-
a([...
|
|
1867
|
+
a([...u, C]), q();
|
|
1868
1868
|
try {
|
|
1869
1869
|
const O = l?.id || await W(c), M = await ae(
|
|
1870
1870
|
c,
|
|
@@ -1901,7 +1901,7 @@ function rn({
|
|
|
1901
1901
|
},
|
|
1902
1902
|
[
|
|
1903
1903
|
c,
|
|
1904
|
-
|
|
1904
|
+
u,
|
|
1905
1905
|
h,
|
|
1906
1906
|
a,
|
|
1907
1907
|
q,
|
|
@@ -1929,7 +1929,7 @@ function rn({
|
|
|
1929
1929
|
onRateChat: fe
|
|
1930
1930
|
};
|
|
1931
1931
|
}
|
|
1932
|
-
const nn = { BASE_URL: "/", DEV: !1, MODE: "
|
|
1932
|
+
const nn = { BASE_URL: "/", DEV: !1, MODE: "prod", PROD: !0, SSR: !1, VITE_API_URL: "https://chat.eloquentai.co", VITE_CDN_URL: "https://cdn.eloquentai.co", VITE_ENVIRONMENT: "prod", VITE_REGION_API_URL: "https://region.eloquentai.co" };
|
|
1933
1933
|
function Ct(e) {
|
|
1934
1934
|
return typeof window > "u" || typeof import.meta > "u" ? "" : nn[e] || "";
|
|
1935
1935
|
}
|
|
@@ -1940,7 +1940,7 @@ function ln() {
|
|
|
1940
1940
|
function cn() {
|
|
1941
1941
|
return sn || "";
|
|
1942
1942
|
}
|
|
1943
|
-
class
|
|
1943
|
+
class un {
|
|
1944
1944
|
httpClient;
|
|
1945
1945
|
userId = null;
|
|
1946
1946
|
conversationId = null;
|
|
@@ -2044,7 +2044,7 @@ class dn {
|
|
|
2044
2044
|
)).data;
|
|
2045
2045
|
}
|
|
2046
2046
|
}
|
|
2047
|
-
const
|
|
2047
|
+
const dn = {
|
|
2048
2048
|
retries: 3,
|
|
2049
2049
|
minDelayMs: 200,
|
|
2050
2050
|
maxDelayMs: 1e3,
|
|
@@ -2058,7 +2058,7 @@ function hn(e, t) {
|
|
|
2058
2058
|
return Math.random() * r;
|
|
2059
2059
|
}
|
|
2060
2060
|
async function mt(e, t = {}) {
|
|
2061
|
-
const o = { ...
|
|
2061
|
+
const o = { ...dn, ...t };
|
|
2062
2062
|
for (let r = 0; ; r++)
|
|
2063
2063
|
try {
|
|
2064
2064
|
return await e();
|
|
@@ -2074,7 +2074,7 @@ const Pe = /* @__PURE__ */ new Map(), Ae = /* @__PURE__ */ new Map();
|
|
|
2074
2074
|
function fn(e, t, o) {
|
|
2075
2075
|
const r = o?.dedupe !== !1, [n, i] = _(
|
|
2076
2076
|
() => Pe.get(e)
|
|
2077
|
-
), { publishApiError: c, publishNetworkError: s } = De(), [
|
|
2077
|
+
), { publishApiError: c, publishNetworkError: s } = De(), [u, a] = _(void 0), [l, d] = _(!1), p = N(!0);
|
|
2078
2078
|
N(() => (p.current = !0, () => {
|
|
2079
2079
|
p.current = !1;
|
|
2080
2080
|
}));
|
|
@@ -2083,7 +2083,7 @@ function fn(e, t, o) {
|
|
|
2083
2083
|
const f = Pe.get(e);
|
|
2084
2084
|
return i(f), f;
|
|
2085
2085
|
}
|
|
2086
|
-
|
|
2086
|
+
d(!0), a(void 0);
|
|
2087
2087
|
try {
|
|
2088
2088
|
if (r && Ae.has(e))
|
|
2089
2089
|
return await Ae.get(e);
|
|
@@ -2094,10 +2094,10 @@ function fn(e, t, o) {
|
|
|
2094
2094
|
} catch (f) {
|
|
2095
2095
|
throw f instanceof et || f instanceof Oe && f.status === 403 ? s() : c(f), p.current && a(f), f;
|
|
2096
2096
|
} finally {
|
|
2097
|
-
Ae.delete(e), p.current &&
|
|
2097
|
+
Ae.delete(e), p.current && d(!1);
|
|
2098
2098
|
}
|
|
2099
2099
|
}, [e, r, t, c, s]);
|
|
2100
|
-
return { data: n, error:
|
|
2100
|
+
return { data: n, error: u, isLoading: l, fetch: h };
|
|
2101
2101
|
}
|
|
2102
2102
|
function bt(e, t) {
|
|
2103
2103
|
const o = e?.deviceId || crypto.randomUUID();
|
|
@@ -2131,11 +2131,11 @@ function mn({
|
|
|
2131
2131
|
userId: i,
|
|
2132
2132
|
externalId: c,
|
|
2133
2133
|
deviceId: s,
|
|
2134
|
-
isReady:
|
|
2135
|
-
} = gn({ appId: t, initialUserId: o }), { isChatExpired: a, clearChatData: l, getSavedChatData:
|
|
2134
|
+
isReady: u
|
|
2135
|
+
} = gn({ appId: t, initialUserId: o }), { isChatExpired: a, clearChatData: l, getSavedChatData: d } = tt({
|
|
2136
2136
|
appId: t
|
|
2137
2137
|
}), { current: p } = N(e || ln()), [h] = _(
|
|
2138
|
-
new
|
|
2138
|
+
new un({
|
|
2139
2139
|
baseURL: p,
|
|
2140
2140
|
appId: t
|
|
2141
2141
|
})
|
|
@@ -2150,12 +2150,12 @@ function mn({
|
|
|
2150
2150
|
messages: L,
|
|
2151
2151
|
isChatClosed: A,
|
|
2152
2152
|
chatToken: K
|
|
2153
|
-
} =
|
|
2153
|
+
} = d();
|
|
2154
2154
|
ne && T && (q({
|
|
2155
2155
|
id: ne
|
|
2156
2156
|
}), h.setChatToken(K ?? null), L && L.length > 0 && j(L), A && m(!0));
|
|
2157
2157
|
}
|
|
2158
|
-
}, [
|
|
2158
|
+
}, [d, a, l, h]);
|
|
2159
2159
|
const re = N(!1);
|
|
2160
2160
|
return Z(() => {
|
|
2161
2161
|
if (re.current) return;
|
|
@@ -2177,14 +2177,14 @@ function mn({
|
|
|
2177
2177
|
conversationId: X,
|
|
2178
2178
|
userId: H,
|
|
2179
2179
|
messages: W
|
|
2180
|
-
} =
|
|
2180
|
+
} = d();
|
|
2181
2181
|
X && H && W.some(Zt) && j(
|
|
2182
2182
|
await Kt(h, X, W)
|
|
2183
2183
|
);
|
|
2184
2184
|
const ae = A.chat_settings.welcome_message;
|
|
2185
2185
|
g(A.chat_settings), P(A.chat_settings.is_active ?? !0), ae && j((Q) => Q.length > 0 || Q.some((ee) => ee.isWelcomeMessage) ? Q : [Gr(ae)]), $(!0);
|
|
2186
2186
|
})();
|
|
2187
|
-
}, [
|
|
2187
|
+
}, [u, h, t, G, d]), {
|
|
2188
2188
|
userId: i,
|
|
2189
2189
|
userName: r,
|
|
2190
2190
|
userData: n,
|
|
@@ -2209,10 +2209,10 @@ function vn(e) {
|
|
|
2209
2209
|
), i = e ?? t, c = typeof window > "u";
|
|
2210
2210
|
return Z(() => {
|
|
2211
2211
|
if (c) return;
|
|
2212
|
-
const s = window.matchMedia(St),
|
|
2212
|
+
const s = window.matchMedia(St), u = (a) => {
|
|
2213
2213
|
o(a.matches);
|
|
2214
2214
|
};
|
|
2215
|
-
return
|
|
2215
|
+
return u(s), s.addEventListener("change", u), () => s.removeEventListener("change", u);
|
|
2216
2216
|
}, [c]), Z(() => {
|
|
2217
2217
|
if (c) return;
|
|
2218
2218
|
const s = document.createElement("div");
|
|
@@ -2287,12 +2287,12 @@ function zn({
|
|
|
2287
2287
|
isEnabled: e,
|
|
2288
2288
|
isOpen: t
|
|
2289
2289
|
}) {
|
|
2290
|
-
const [o, r] = _(Cn), n = N(null), i = N(0), c = V(t), s = V(o),
|
|
2290
|
+
const [o, r] = _(Cn), n = N(null), i = N(0), c = V(t), s = V(o), u = w(() => {
|
|
2291
2291
|
if (!e) return;
|
|
2292
|
-
const
|
|
2293
|
-
if (!
|
|
2292
|
+
const d = En();
|
|
2293
|
+
if (!d) return;
|
|
2294
2294
|
try {
|
|
2295
|
-
n.current ??= new
|
|
2295
|
+
n.current ??= new d();
|
|
2296
2296
|
} catch {
|
|
2297
2297
|
return;
|
|
2298
2298
|
}
|
|
@@ -2302,23 +2302,23 @@ function zn({
|
|
|
2302
2302
|
}, [e]);
|
|
2303
2303
|
Z(() => {
|
|
2304
2304
|
if (!e) return;
|
|
2305
|
-
const
|
|
2306
|
-
return window.addEventListener("pointerdown", p,
|
|
2307
|
-
window.removeEventListener("pointerdown", p,
|
|
2305
|
+
const d = { capture: !0 }, p = () => u();
|
|
2306
|
+
return window.addEventListener("pointerdown", p, d), window.addEventListener("keydown", p, d), () => {
|
|
2307
|
+
window.removeEventListener("pointerdown", p, d), window.removeEventListener("keydown", p, d);
|
|
2308
2308
|
};
|
|
2309
|
-
}, [e,
|
|
2309
|
+
}, [e, u]);
|
|
2310
2310
|
const a = w(() => {
|
|
2311
2311
|
if (!e || s.current || In(c.current)) return;
|
|
2312
|
-
const
|
|
2313
|
-
if (!
|
|
2312
|
+
const d = n.current;
|
|
2313
|
+
if (!d || d.state !== "running") return;
|
|
2314
2314
|
const p = Date.now();
|
|
2315
|
-
p - i.current < _n || (i.current = p, kn(
|
|
2315
|
+
p - i.current < _n || (i.current = p, kn(d));
|
|
2316
2316
|
}, [e, s, c]), l = w(() => {
|
|
2317
|
-
r((
|
|
2317
|
+
r((d) => !d);
|
|
2318
2318
|
}, []);
|
|
2319
2319
|
return Z(() => {
|
|
2320
2320
|
Sn(o);
|
|
2321
|
-
}, [o]), { notify: a, unlock:
|
|
2321
|
+
}, [o]), { notify: a, unlock: u, isMuted: o, toggleMuted: l };
|
|
2322
2322
|
}
|
|
2323
2323
|
const Rn = 2, Tn = (e) => `eloquent-ai:chat-widget-closed-${e}`;
|
|
2324
2324
|
function Mn({
|
|
@@ -2330,11 +2330,11 @@ function Mn({
|
|
|
2330
2330
|
userData: i,
|
|
2331
2331
|
chatProps: c,
|
|
2332
2332
|
isMobile: s,
|
|
2333
|
-
isInitiallyOpen:
|
|
2333
|
+
isInitiallyOpen: u,
|
|
2334
2334
|
hasCloseButton: a,
|
|
2335
2335
|
hasCleanChatButton: l,
|
|
2336
2336
|
// Deprecated aliases, kept until hosts migrate to the is/has names above.
|
|
2337
|
-
initialOpen:
|
|
2337
|
+
initialOpen: d,
|
|
2338
2338
|
closeButton: p,
|
|
2339
2339
|
cleanChatButton: h,
|
|
2340
2340
|
proactiveMessageHideDelay: f = 5e3,
|
|
@@ -2358,7 +2358,7 @@ function Mn({
|
|
|
2358
2358
|
initialUserId: r,
|
|
2359
2359
|
userName: n,
|
|
2360
2360
|
userData: i
|
|
2361
|
-
}), ne = ao({ chatProps: c, chatSettings: m }), T =
|
|
2361
|
+
}), ne = ao({ chatProps: c, chatSettings: m }), T = u ?? d ?? !1, L = a ?? p ?? !0, A = l ?? h ?? !0, K = Tn(o), [X, H] = _(() => g ? !0 : lt(K) === "true" || q ? !1 : T ?? q), [W, ae] = _(!1);
|
|
2362
2362
|
Z(() => {
|
|
2363
2363
|
if (!oe || W || (ae(!0), g)) return;
|
|
2364
2364
|
const ce = m?.initial_open;
|
|
@@ -2384,10 +2384,10 @@ function Mn({
|
|
|
2384
2384
|
[K, g, C]
|
|
2385
2385
|
), M = Vt(X, 400), [B, z] = _(
|
|
2386
2386
|
c?.messages ?? []
|
|
2387
|
-
), [J,
|
|
2387
|
+
), [J, de] = _(y), [pe, ge] = _(!1), [me, D] = _(P);
|
|
2388
2388
|
me !== P && (D(P), P.length > 0 && z(P));
|
|
2389
2389
|
const [ie, te] = _(y);
|
|
2390
|
-
ie !== y && (te(y), y &&
|
|
2390
|
+
ie !== y && (te(y), y && de(y));
|
|
2391
2391
|
const [Te, Be] = _(G);
|
|
2392
2392
|
Te !== G && (Be(G), G && ge(!0));
|
|
2393
2393
|
const Le = w(() => {
|
|
@@ -2408,7 +2408,7 @@ function Mn({
|
|
|
2408
2408
|
setMessages: z,
|
|
2409
2409
|
messages: B,
|
|
2410
2410
|
currentChat: J,
|
|
2411
|
-
setCurrentChat:
|
|
2411
|
+
setCurrentChat: de,
|
|
2412
2412
|
onChatClosed: Le,
|
|
2413
2413
|
isChatClosed: pe,
|
|
2414
2414
|
onAgentMessage: v.notify
|
|
@@ -2416,7 +2416,7 @@ function Mn({
|
|
|
2416
2416
|
Z(() => {
|
|
2417
2417
|
P.length > 0 && z(P);
|
|
2418
2418
|
}, [P]), Z(() => {
|
|
2419
|
-
y &&
|
|
2419
|
+
y && de(y);
|
|
2420
2420
|
}, [y]);
|
|
2421
2421
|
const rt = N(null);
|
|
2422
2422
|
Z(() => {
|
|
@@ -2503,15 +2503,15 @@ function An(e) {
|
|
|
2503
2503
|
}, [e]);
|
|
2504
2504
|
}
|
|
2505
2505
|
function On() {
|
|
2506
|
-
const [e, t] = _(!1), [o, r] = _(null), n = N(null), i = N(null), c = w((
|
|
2506
|
+
const [e, t] = _(!1), [o, r] = _(null), n = N(null), i = N(null), c = w((u) => {
|
|
2507
2507
|
const a = (l) => {
|
|
2508
2508
|
r(l), t(!0), i.current = null, n.current && clearTimeout(n.current), n.current = setTimeout(() => {
|
|
2509
2509
|
n.current = null;
|
|
2510
|
-
const
|
|
2511
|
-
|
|
2510
|
+
const d = i.current;
|
|
2511
|
+
d && a(d);
|
|
2512
2512
|
}, 1e3);
|
|
2513
2513
|
};
|
|
2514
|
-
n.current ? i.current =
|
|
2514
|
+
n.current ? i.current = u : a(u);
|
|
2515
2515
|
}, []), s = w(() => {
|
|
2516
2516
|
n.current && (clearTimeout(n.current), n.current = null), i.current = null, t(!1), r(null);
|
|
2517
2517
|
}, []);
|
|
@@ -2548,11 +2548,11 @@ function $n({
|
|
|
2548
2548
|
proactiveMessageHideDelay: i = 5e3,
|
|
2549
2549
|
isMobile: c,
|
|
2550
2550
|
hasCloseButton: s,
|
|
2551
|
-
hasCleanChatButton:
|
|
2551
|
+
hasCleanChatButton: u,
|
|
2552
2552
|
isInitiallyOpen: a,
|
|
2553
2553
|
// Deprecated aliases, resolved in useChat (new name wins).
|
|
2554
2554
|
closeButton: l,
|
|
2555
|
-
cleanChatButton:
|
|
2555
|
+
cleanChatButton: d,
|
|
2556
2556
|
initialOpen: p,
|
|
2557
2557
|
INTERNAL_ONLY_CHAT_INTERFACE_ONLY: h = !1,
|
|
2558
2558
|
INTERNAL_ONLY_SHOW_CLEAN_CHAT_BUTTON: f = void 0,
|
|
@@ -2600,10 +2600,10 @@ function $n({
|
|
|
2600
2600
|
isMobile: c,
|
|
2601
2601
|
isInitiallyOpen: a,
|
|
2602
2602
|
hasCloseButton: s,
|
|
2603
|
-
hasCleanChatButton:
|
|
2603
|
+
hasCleanChatButton: u,
|
|
2604
2604
|
initialOpen: p,
|
|
2605
2605
|
closeButton: l,
|
|
2606
|
-
cleanChatButton:
|
|
2606
|
+
cleanChatButton: d,
|
|
2607
2607
|
proactiveMessageHideDelay: i,
|
|
2608
2608
|
// Embedded: the interface is the page content with no launcher to reopen
|
|
2609
2609
|
// it, so nothing (boot initial_open, closed-cookie, props) may close it.
|
|
@@ -2615,8 +2615,8 @@ function $n({
|
|
|
2615
2615
|
}, [L, I]);
|
|
2616
2616
|
const J = Pn(T && A);
|
|
2617
2617
|
An(T && A);
|
|
2618
|
-
const
|
|
2619
|
-
if (y ||
|
|
2618
|
+
const de = !P;
|
|
2619
|
+
if (y || de && !h || !de && !oe) return null;
|
|
2620
2620
|
const pe = () => /* @__PURE__ */ ze(
|
|
2621
2621
|
"div",
|
|
2622
2622
|
{
|
|
@@ -2676,7 +2676,7 @@ function $n({
|
|
|
2676
2676
|
zIndex: 0
|
|
2677
2677
|
} : {}
|
|
2678
2678
|
},
|
|
2679
|
-
children:
|
|
2679
|
+
children: de ? (
|
|
2680
2680
|
// Only reachable in embedded mode (the launcher returns null while
|
|
2681
2681
|
// booting): hold the widget's frame with a skeleton so a remount —
|
|
2682
2682
|
// project/environment switch in the host app — doesn't flash an
|