@opencx/widget 2.4.4 → 2.5.1
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/README.md +30 -30
- package/dist/basic.cjs +74 -74
- package/dist/basic.cjs.map +1 -1
- package/dist/basic.js +9385 -9395
- package/dist/basic.js.map +1 -1
- package/dist/core/types/messages.d.ts +11 -1
- package/dist/core/types/schemas-v2.d.ts +3 -3
- package/dist/core/utils/genUuid.d.ts +1 -0
- package/dist/genUuid-BkZtn1k9.cjs +2 -0
- package/dist/genUuid-BkZtn1k9.cjs.map +1 -0
- package/dist/{schemas-v2-DZ3nwfID.js → genUuid-CDpI3ugS.js} +17 -19
- package/dist/genUuid-CDpI3ugS.js.map +1 -0
- package/dist/index-1bY4_hBw.cjs +18 -0
- package/dist/index-1bY4_hBw.cjs.map +1 -0
- package/dist/{index-B6Q20SQP.js → index-D84Xc70r.js} +327 -344
- package/dist/index-D84Xc70r.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +141 -131
- package/dist/index.js.map +1 -1
- package/dist/package.json.d.ts +2 -1
- package/dist/react-web/utils/getters.d.ts +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +34 -12
- package/dist/react.js.map +1 -1
- package/dist/src/@components/BotOrAgentMessage.d.ts +9 -0
- package/dist/src/@components/BotOrAgentMessageGroup.d.ts +7 -0
- package/dist/src/@components/{BotMessageWrapper.d.ts → BotOrAgentMessageWrapper.d.ts} +1 -1
- package/dist/src/@components/index.d.ts +2 -2
- package/dist/src/components/UserMessageGroup.d.ts +5 -0
- package/dist/src/designs/basic/screens/chat-screen/ChatMain.d.ts +2 -0
- package/dist/src/designs/basic/utils/group-messages-by-type.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist-embed/script.js +134 -144
- package/dist-embed/script.js.map +1 -1
- package/package.json +2 -1
- package/dist/index-B6Q20SQP.js.map +0 -1
- package/dist/index-DAb3AX4O.cjs +0 -18
- package/dist/index-DAb3AX4O.cjs.map +0 -1
- package/dist/schemas-v2-BiJWHypc.cjs +0 -2
- package/dist/schemas-v2-BiJWHypc.cjs.map +0 -1
- package/dist/schemas-v2-DZ3nwfID.js.map +0 -1
- package/dist/src/@components/BotMessage.d.ts +0 -9
- package/dist/src/components/userMessage.d.ts +0 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var ln = Object.defineProperty;
|
|
2
2
|
var dn = (e, t, n) => t in e ? ln(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var at = (e, t, n) => dn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { jsx as ne } from "react/jsx-runtime";
|
|
4
|
+
import de, { useMemo as ee, useState as Ke, useCallback as ge, useEffect as le, createContext as ht, useContext as yt, useRef as se, useReducer as fn, useLayoutEffect as pn, useDebugValue as gn } from "react";
|
|
5
|
+
import { jsx as $ } from "react/jsx-runtime";
|
|
7
6
|
import { create as mn } from "mutative";
|
|
8
7
|
import l from "zod";
|
|
8
|
+
import { c as St, g as ve } from "./genUuid-CDpI3ugS.js";
|
|
9
9
|
import hn from "lodash.set";
|
|
10
10
|
import yn from "axios";
|
|
11
11
|
const Sn = typeof window > "u", it = {
|
|
@@ -19,7 +19,7 @@ function vn(e) {
|
|
|
19
19
|
return Sn ? it : e === "local" ? localStorage : e === "session" ? sessionStorage : it;
|
|
20
20
|
}
|
|
21
21
|
function Je(e, t, n = "session") {
|
|
22
|
-
const r =
|
|
22
|
+
const r = ee(() => vn(n), [n]), [s, o] = Ke(() => {
|
|
23
23
|
const g = r.getItem(e);
|
|
24
24
|
if (g !== null)
|
|
25
25
|
try {
|
|
@@ -28,7 +28,7 @@ function Je(e, t, n = "session") {
|
|
|
28
28
|
console.error(`Error parsing stored value for key '${e}':`, u);
|
|
29
29
|
}
|
|
30
30
|
return typeof t == "function" ? t() : t ?? null;
|
|
31
|
-
}), a =
|
|
31
|
+
}), a = ge(
|
|
32
32
|
(g) => {
|
|
33
33
|
if (o(g), g === null)
|
|
34
34
|
r.removeItem(e);
|
|
@@ -43,10 +43,10 @@ function Je(e, t, n = "session") {
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
[e, r]
|
|
46
|
-
), d =
|
|
46
|
+
), d = ge(() => {
|
|
47
47
|
o(null), r.removeItem(e);
|
|
48
48
|
}, [e, r]);
|
|
49
|
-
return
|
|
49
|
+
return le(() => {
|
|
50
50
|
const g = (u) => {
|
|
51
51
|
u.key === e && u.newValue !== JSON.stringify(s) && o(u.newValue ? JSON.parse(u.newValue) : null);
|
|
52
52
|
};
|
|
@@ -55,7 +55,7 @@ function Je(e, t, n = "session") {
|
|
|
55
55
|
};
|
|
56
56
|
}, [e, s]), [s, a, d];
|
|
57
57
|
}
|
|
58
|
-
const En = "@opencx/widget", vt = "2.
|
|
58
|
+
const En = "@opencx/widget", vt = "2.5.1", bn = "module", wn = {
|
|
59
59
|
access: "public"
|
|
60
60
|
}, On = {
|
|
61
61
|
clean: "rm -rf ./dist ./dist-embed",
|
|
@@ -100,6 +100,7 @@ const En = "@opencx/widget", vt = "2.4.4", bn = "module", wn = {
|
|
|
100
100
|
"react-dropzone": "^14.3.5",
|
|
101
101
|
"react-hot-toast": "^2.4.1",
|
|
102
102
|
tinycolor2: "^1.6.0",
|
|
103
|
+
uuid: "^11.0.4",
|
|
103
104
|
zod: "^3.23.8"
|
|
104
105
|
}, Dn = {
|
|
105
106
|
"@opencx/widget": {
|
|
@@ -123,12 +124,12 @@ const En = "@opencx/widget", vt = "2.4.4", bn = "module", wn = {
|
|
|
123
124
|
}, Cn = [
|
|
124
125
|
"dist",
|
|
125
126
|
"dist-embed"
|
|
126
|
-
],
|
|
127
|
+
], xn = {
|
|
127
128
|
url: "https://github.com/openchatai/widget/issues"
|
|
128
129
|
}, Pn = {
|
|
129
130
|
name: "openchatai",
|
|
130
131
|
url: "https://github.com/openchatai"
|
|
131
|
-
},
|
|
132
|
+
}, In = "./dist/index.js", jn = "./dist/index.js", Ln = "./dist/index.d.ts", kn = !1, Fn = {
|
|
132
133
|
".": {
|
|
133
134
|
types: "./dist/index.d.ts",
|
|
134
135
|
import: "./dist/index.js",
|
|
@@ -200,9 +201,9 @@ const En = "@opencx/widget", vt = "2.4.4", bn = "module", wn = {
|
|
|
200
201
|
overrides: Dn,
|
|
201
202
|
conditionalDependencies: Nn,
|
|
202
203
|
files: Cn,
|
|
203
|
-
bugs:
|
|
204
|
+
bugs: xn,
|
|
204
205
|
author: Pn,
|
|
205
|
-
main:
|
|
206
|
+
main: In,
|
|
206
207
|
module: jn,
|
|
207
208
|
types: Ln,
|
|
208
209
|
sideEffects: kn,
|
|
@@ -210,7 +211,7 @@ const En = "@opencx/widget", vt = "2.4.4", bn = "module", wn = {
|
|
|
210
211
|
devDependencies: Mn
|
|
211
212
|
}, Un = "X-Bot-Token", Hn = "X-Widget-Version";
|
|
212
213
|
function Et(e) {
|
|
213
|
-
const t =
|
|
214
|
+
const t = ee(() => yn.create({
|
|
214
215
|
baseURL: e.apiUrl,
|
|
215
216
|
headers: {
|
|
216
217
|
[Un]: e.botToken,
|
|
@@ -218,7 +219,7 @@ function Et(e) {
|
|
|
218
219
|
"X-Use-Guard": !0
|
|
219
220
|
}
|
|
220
221
|
}), [e]);
|
|
221
|
-
return { apis:
|
|
222
|
+
return { apis: ee(
|
|
222
223
|
() => ({
|
|
223
224
|
createSession: (r) => {
|
|
224
225
|
if (!r)
|
|
@@ -239,6 +240,7 @@ function Et(e) {
|
|
|
239
240
|
* get the organization office working hours.
|
|
240
241
|
*/
|
|
241
242
|
getOfficeHours: () => t.get("/copilot/office-hours/public"),
|
|
243
|
+
// TODO unify with history polling function
|
|
242
244
|
fetchHistory: (r) => {
|
|
243
245
|
if (!r)
|
|
244
246
|
throw new Error("Session id is required");
|
|
@@ -303,9 +305,9 @@ function Et(e) {
|
|
|
303
305
|
), options: e };
|
|
304
306
|
}
|
|
305
307
|
function De(e) {
|
|
306
|
-
const t =
|
|
308
|
+
const t = ht({});
|
|
307
309
|
return [() => {
|
|
308
|
-
const r =
|
|
310
|
+
const r = yt(t);
|
|
309
311
|
if (r === void 0)
|
|
310
312
|
throw new Error("useSafeContext must be used within a Provider");
|
|
311
313
|
return r;
|
|
@@ -470,7 +472,7 @@ const Gn = {
|
|
|
470
472
|
"start-chat": "Talk to support",
|
|
471
473
|
"starting-chat": "Connecting...",
|
|
472
474
|
"hello-greeting": "Hi there!"
|
|
473
|
-
},
|
|
475
|
+
}, qn = {
|
|
474
476
|
ok: "D'accord",
|
|
475
477
|
yes: "Oui",
|
|
476
478
|
no: "Non",
|
|
@@ -523,7 +525,7 @@ const Gn = {
|
|
|
523
525
|
"start-chat": "Parler au support",
|
|
524
526
|
"starting-chat": "Connexion...",
|
|
525
527
|
"hello-greeting": "Bonjour ! Comment pouvons-nous vous aider aujourd'hui ?"
|
|
526
|
-
},
|
|
528
|
+
}, Bn = {
|
|
527
529
|
ok: "OK",
|
|
528
530
|
yes: "Ja",
|
|
529
531
|
no: "Nee",
|
|
@@ -632,8 +634,8 @@ const Gn = {
|
|
|
632
634
|
}, Qn = {
|
|
633
635
|
en: Yn,
|
|
634
636
|
ar: Gn,
|
|
635
|
-
nl:
|
|
636
|
-
fr:
|
|
637
|
+
nl: Bn,
|
|
638
|
+
fr: qn,
|
|
637
639
|
de: zn,
|
|
638
640
|
pt: Xn
|
|
639
641
|
};
|
|
@@ -643,8 +645,8 @@ function Wn(e, t) {
|
|
|
643
645
|
}
|
|
644
646
|
const [Es, Kn] = De();
|
|
645
647
|
function bt({ children: e }) {
|
|
646
|
-
const t =
|
|
647
|
-
return /* @__PURE__ */
|
|
648
|
+
const t = ce();
|
|
649
|
+
return /* @__PURE__ */ $(
|
|
648
650
|
Kn,
|
|
649
651
|
{
|
|
650
652
|
value: {
|
|
@@ -696,7 +698,7 @@ const Zn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABlCAYAAAC7vkbxAA
|
|
|
696
698
|
triggerOffset: "20px"
|
|
697
699
|
};
|
|
698
700
|
function er(e) {
|
|
699
|
-
return
|
|
701
|
+
return ee(() => {
|
|
700
702
|
var s, o, a, d;
|
|
701
703
|
const t = {
|
|
702
704
|
messageArrived: "https://cloud.opencopilot.so/sfx/notification3.mp3",
|
|
@@ -728,12 +730,12 @@ function er(e) {
|
|
|
728
730
|
};
|
|
729
731
|
}, [e]);
|
|
730
732
|
}
|
|
731
|
-
const [
|
|
733
|
+
const [ce, tr] = De(), nr = "en";
|
|
732
734
|
function rr({
|
|
733
735
|
children: e,
|
|
734
736
|
data: t
|
|
735
737
|
}) {
|
|
736
|
-
const n =
|
|
738
|
+
const n = ee(
|
|
737
739
|
() => new Jn({
|
|
738
740
|
components: t.components
|
|
739
741
|
}),
|
|
@@ -746,7 +748,7 @@ function rr({
|
|
|
746
748
|
r.defaultSettings,
|
|
747
749
|
"local"
|
|
748
750
|
);
|
|
749
|
-
return /* @__PURE__ */
|
|
751
|
+
return /* @__PURE__ */ $(
|
|
750
752
|
tr,
|
|
751
753
|
{
|
|
752
754
|
value: { ...r, http: s, componentStore: n, widgetSettings: o, setSettings: (g) => {
|
|
@@ -758,7 +760,7 @@ function rr({
|
|
|
758
760
|
);
|
|
759
761
|
a(u);
|
|
760
762
|
} },
|
|
761
|
-
children: /* @__PURE__ */
|
|
763
|
+
children: /* @__PURE__ */ $(bt, { children: e })
|
|
762
764
|
}
|
|
763
765
|
);
|
|
764
766
|
}
|
|
@@ -862,7 +864,7 @@ function Nt(e) {
|
|
|
862
864
|
function Ct(e, t, n) {
|
|
863
865
|
return typeof t == "symbol" && (t = t.description ? "[".concat(t.description, "]") : ""), Object.defineProperty(e, "name", { configurable: !0, value: n ? "".concat(n, " ", t) : t });
|
|
864
866
|
}
|
|
865
|
-
function
|
|
867
|
+
function xt(e, t) {
|
|
866
868
|
if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
|
|
867
869
|
}
|
|
868
870
|
function Pt(e, t, n, r) {
|
|
@@ -892,7 +894,7 @@ function Pt(e, t, n, r) {
|
|
|
892
894
|
u((r = r.apply(e, t || [])).next());
|
|
893
895
|
});
|
|
894
896
|
}
|
|
895
|
-
function
|
|
897
|
+
function It(e, t) {
|
|
896
898
|
var n = { label: 0, sent: function() {
|
|
897
899
|
if (o[0] & 1) throw o[1];
|
|
898
900
|
return o[1];
|
|
@@ -1008,8 +1010,8 @@ function Ft(e, t, n) {
|
|
|
1008
1010
|
(o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
|
|
1009
1011
|
return e.concat(o || Array.prototype.slice.call(t));
|
|
1010
1012
|
}
|
|
1011
|
-
function
|
|
1012
|
-
return this instanceof
|
|
1013
|
+
function me(e) {
|
|
1014
|
+
return this instanceof me ? (this.v = e, this) : new me(e);
|
|
1013
1015
|
}
|
|
1014
1016
|
function Mt(e, t, n) {
|
|
1015
1017
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
@@ -1037,7 +1039,7 @@ function Mt(e, t, n) {
|
|
|
1037
1039
|
}
|
|
1038
1040
|
}
|
|
1039
1041
|
function u(p) {
|
|
1040
|
-
p.value instanceof
|
|
1042
|
+
p.value instanceof me ? Promise.resolve(p.value.v).then(c, i) : m(o[0][2], p);
|
|
1041
1043
|
}
|
|
1042
1044
|
function c(p) {
|
|
1043
1045
|
g("next", p);
|
|
@@ -1058,7 +1060,7 @@ function Vt(e) {
|
|
|
1058
1060
|
}, t;
|
|
1059
1061
|
function r(s, o) {
|
|
1060
1062
|
t[s] = e[s] ? function(a) {
|
|
1061
|
-
return (n = !n) ? { value:
|
|
1063
|
+
return (n = !n) ? { value: me(e[s](a)), done: !1 } : o ? o(a) : a;
|
|
1062
1064
|
} : o;
|
|
1063
1065
|
}
|
|
1064
1066
|
}
|
|
@@ -1103,13 +1105,13 @@ function Yt(e, t, n, r) {
|
|
|
1103
1105
|
if (typeof t == "function" ? e !== t || !r : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1104
1106
|
return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
|
|
1105
1107
|
}
|
|
1106
|
-
function
|
|
1108
|
+
function qt(e, t, n, r, s) {
|
|
1107
1109
|
if (r === "m") throw new TypeError("Private method is not writable");
|
|
1108
1110
|
if (r === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
|
|
1109
1111
|
if (typeof t == "function" ? e !== t || !s : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1110
1112
|
return r === "a" ? s.call(e, n) : s ? s.value = n : t.set(e, n), n;
|
|
1111
1113
|
}
|
|
1112
|
-
function
|
|
1114
|
+
function Bt(e, t) {
|
|
1113
1115
|
if (t === null || typeof t != "object" && typeof t != "function") throw new TypeError("Cannot use 'in' operator on non-object");
|
|
1114
1116
|
return typeof e == "function" ? t === e : e.has(t);
|
|
1115
1117
|
}
|
|
@@ -1178,9 +1180,9 @@ const ir = {
|
|
|
1178
1180
|
__runInitializers: Dt,
|
|
1179
1181
|
__propKey: Nt,
|
|
1180
1182
|
__setFunctionName: Ct,
|
|
1181
|
-
__metadata:
|
|
1183
|
+
__metadata: xt,
|
|
1182
1184
|
__awaiter: Pt,
|
|
1183
|
-
__generator:
|
|
1185
|
+
__generator: It,
|
|
1184
1186
|
__createBinding: Ne,
|
|
1185
1187
|
__exportStar: jt,
|
|
1186
1188
|
__values: Te,
|
|
@@ -1188,7 +1190,7 @@ const ir = {
|
|
|
1188
1190
|
__spread: Lt,
|
|
1189
1191
|
__spreadArrays: kt,
|
|
1190
1192
|
__spreadArray: Ft,
|
|
1191
|
-
__await:
|
|
1193
|
+
__await: me,
|
|
1192
1194
|
__asyncGenerator: Mt,
|
|
1193
1195
|
__asyncDelegator: Vt,
|
|
1194
1196
|
__asyncValues: Ut,
|
|
@@ -1196,8 +1198,8 @@ const ir = {
|
|
|
1196
1198
|
__importStar: Gt,
|
|
1197
1199
|
__importDefault: zt,
|
|
1198
1200
|
__classPrivateFieldGet: Yt,
|
|
1199
|
-
__classPrivateFieldSet:
|
|
1200
|
-
__classPrivateFieldIn:
|
|
1201
|
+
__classPrivateFieldSet: qt,
|
|
1202
|
+
__classPrivateFieldIn: Bt,
|
|
1201
1203
|
__addDisposableResource: Xt,
|
|
1202
1204
|
__disposeResources: Qt,
|
|
1203
1205
|
__rewriteRelativeImportExtension: Wt
|
|
@@ -1210,22 +1212,22 @@ const ir = {
|
|
|
1210
1212
|
__asyncDelegator: Vt,
|
|
1211
1213
|
__asyncGenerator: Mt,
|
|
1212
1214
|
__asyncValues: Ut,
|
|
1213
|
-
__await:
|
|
1215
|
+
__await: me,
|
|
1214
1216
|
__awaiter: Pt,
|
|
1215
1217
|
__classPrivateFieldGet: Yt,
|
|
1216
|
-
__classPrivateFieldIn:
|
|
1217
|
-
__classPrivateFieldSet:
|
|
1218
|
+
__classPrivateFieldIn: Bt,
|
|
1219
|
+
__classPrivateFieldSet: qt,
|
|
1218
1220
|
__createBinding: Ne,
|
|
1219
1221
|
__decorate: _t,
|
|
1220
1222
|
__disposeResources: Qt,
|
|
1221
1223
|
__esDecorate: Tt,
|
|
1222
1224
|
__exportStar: jt,
|
|
1223
1225
|
__extends: Ot,
|
|
1224
|
-
__generator:
|
|
1226
|
+
__generator: It,
|
|
1225
1227
|
__importDefault: zt,
|
|
1226
1228
|
__importStar: Gt,
|
|
1227
1229
|
__makeTemplateObject: Ht,
|
|
1228
|
-
__metadata:
|
|
1230
|
+
__metadata: xt,
|
|
1229
1231
|
__param: Rt,
|
|
1230
1232
|
__propKey: Nt,
|
|
1231
1233
|
__read: Ze,
|
|
@@ -1243,7 +1245,7 @@ var Oe = {}, ct;
|
|
|
1243
1245
|
function lr() {
|
|
1244
1246
|
if (ct) return Oe;
|
|
1245
1247
|
ct = 1, Object.defineProperty(Oe, "__esModule", { value: !0 });
|
|
1246
|
-
var e =
|
|
1248
|
+
var e = de;
|
|
1247
1249
|
function t() {
|
|
1248
1250
|
var n = e.useRef(!1), r = e.useCallback(function() {
|
|
1249
1251
|
return n.current;
|
|
@@ -1257,7 +1259,7 @@ function lr() {
|
|
|
1257
1259
|
return Oe.default = t, Oe;
|
|
1258
1260
|
}
|
|
1259
1261
|
Object.defineProperty(wt, "__esModule", { value: !0 });
|
|
1260
|
-
var ze = ur, je =
|
|
1262
|
+
var ze = ur, je = de, dr = ze.__importDefault(lr());
|
|
1261
1263
|
function fr(e, t, n) {
|
|
1262
1264
|
t === void 0 && (t = []), n === void 0 && (n = { loading: !1 });
|
|
1263
1265
|
var r = je.useRef(0), s = dr.default(), o = je.useState(n), a = o[0], d = o[1], g = je.useCallback(function() {
|
|
@@ -1274,35 +1276,20 @@ function fr(e, t, n) {
|
|
|
1274
1276
|
}, t);
|
|
1275
1277
|
return [a, g];
|
|
1276
1278
|
}
|
|
1277
|
-
var
|
|
1278
|
-
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
[
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1285
|
-
function
|
|
1286
|
-
const { http: n } =
|
|
1287
|
-
return B(
|
|
1288
|
-
async () => n.apis.upvote(e).then(t),
|
|
1289
|
-
[n.options, e, t]
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
function _s(e, t) {
|
|
1293
|
-
const { http: n } = q();
|
|
1294
|
-
return B(
|
|
1295
|
-
async () => n.apis.downvote(e).then(t),
|
|
1296
|
-
[n.options, e]
|
|
1297
|
-
);
|
|
1298
|
-
}
|
|
1299
|
-
const ae = /* @__PURE__ */ new Map();
|
|
1300
|
-
function Rs() {
|
|
1301
|
-
const [e, t] = Ke([]), { http: n } = q();
|
|
1279
|
+
var oe = wt.default = fr;
|
|
1280
|
+
const pr = (e = 20) => {
|
|
1281
|
+
const t = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
1282
|
+
let n = "";
|
|
1283
|
+
for (let r = 0; r < e; r++)
|
|
1284
|
+
n += t[Math.floor(Math.random() * t.length)];
|
|
1285
|
+
return n;
|
|
1286
|
+
}, re = /* @__PURE__ */ new Map();
|
|
1287
|
+
function Os() {
|
|
1288
|
+
const [e, t] = Ke([]), { http: n } = ce();
|
|
1302
1289
|
function r(c) {
|
|
1303
1290
|
const i = c.map((m) => ({
|
|
1304
1291
|
file: m,
|
|
1305
|
-
id:
|
|
1292
|
+
id: pr(10),
|
|
1306
1293
|
status: "pending",
|
|
1307
1294
|
progress: 0
|
|
1308
1295
|
}));
|
|
@@ -1318,7 +1305,7 @@ function Rs() {
|
|
|
1318
1305
|
}
|
|
1319
1306
|
const a = async (c) => {
|
|
1320
1307
|
const i = new AbortController();
|
|
1321
|
-
|
|
1308
|
+
re.set(c.id, i);
|
|
1322
1309
|
try {
|
|
1323
1310
|
t(
|
|
1324
1311
|
(p) => p.map(
|
|
@@ -1347,17 +1334,17 @@ function Rs() {
|
|
|
1347
1334
|
progress: 0
|
|
1348
1335
|
});
|
|
1349
1336
|
} finally {
|
|
1350
|
-
|
|
1337
|
+
re.delete(c.id);
|
|
1351
1338
|
}
|
|
1352
1339
|
}, d = (c) => {
|
|
1353
|
-
const i =
|
|
1354
|
-
i && (i.abort(),
|
|
1355
|
-
}, g =
|
|
1340
|
+
const i = re.get(c);
|
|
1341
|
+
i && (i.abort(), re.delete(c)), o(c);
|
|
1342
|
+
}, g = ee(() => e.filter((c) => c.status === "success" && c.fileUrl), [e]);
|
|
1356
1343
|
function u() {
|
|
1357
|
-
|
|
1344
|
+
re.forEach((c) => c.abort()), re.clear(), t([]);
|
|
1358
1345
|
}
|
|
1359
|
-
return
|
|
1360
|
-
|
|
1346
|
+
return le(() => () => {
|
|
1347
|
+
re.forEach((c) => c.abort()), re.clear();
|
|
1361
1348
|
}, []), {
|
|
1362
1349
|
allFiles: e,
|
|
1363
1350
|
appendFiles: r,
|
|
@@ -1378,7 +1365,7 @@ function Rs() {
|
|
|
1378
1365
|
};
|
|
1379
1366
|
}
|
|
1380
1367
|
var Ce = /* @__PURE__ */ ((e) => (e[e.OPEN = 0] = "OPEN", e[e.CLOSED_RESOLVED = 1] = "CLOSED_RESOLVED", e[e.CLOSED_UNRESOLVED = 2] = "CLOSED_UNRESOLVED", e))(Ce || {}), Kt = /* @__PURE__ */ ((e) => (e.WEB = "web", e.WEB_VOICE = "web_voice", e.PHONE_VOICE = "phone_voice", e.EMAIL = "email", e.SMS = "sms", e.WHATSAPP = "whatsapp", e.API = "api", e))(Kt || {}), $e = /* @__PURE__ */ ((e) => (e.resolved = "resolved", e.assumed_resolved = "assumed_resolved", e.handed_off = "handed_off", e))($e || {}), Jt = /* @__PURE__ */ ((e) => (e.happy = "happy", e.neutral = "neutral", e.angry = "angry", e))(Jt || {}), Zt = /* @__PURE__ */ ((e) => (e.MESSAGE = "message", e.HANDOFF = "handoff", e.HANDOFF_TO_ZENDESK = "handoff_to_zendesk", e.AGENT_MESSAGE = "agent_message", e.AGENT_JOINED = "agent_joined", e.AGENT_TOOK_SESSION_FROM_AI = "agent_took_session_from_ai", e.AI_DECIDED_TO_RESOLVE_THE_ISSUE = "ai_decided_to_resolve_the_issue", e.EMAIL_DRAFT_MESSAGE = "email_draft_message", e.FOLLOWUP = "followup", e))(Zt || {});
|
|
1381
|
-
const
|
|
1368
|
+
const gr = l.object({
|
|
1382
1369
|
id: l.string(),
|
|
1383
1370
|
ai_closure_type: l.nativeEnum($e).nullable(),
|
|
1384
1371
|
assignee_id: l.number().nullable(),
|
|
@@ -1407,25 +1394,25 @@ l.object({
|
|
|
1407
1394
|
handoff_happened_during_office_hours: l.boolean().nullable(),
|
|
1408
1395
|
session_id: l.string(),
|
|
1409
1396
|
updated_at: l.string().nullable(),
|
|
1410
|
-
attachments: l.array(
|
|
1397
|
+
attachments: l.array(St).optional()
|
|
1411
1398
|
});
|
|
1412
|
-
const
|
|
1399
|
+
const mr = l.object({
|
|
1413
1400
|
name: l.string(),
|
|
1414
1401
|
is_ai: l.boolean(),
|
|
1415
1402
|
profile_picture: l.string().optional().nullable(),
|
|
1416
1403
|
id: l.string().nullable()
|
|
1417
|
-
}),
|
|
1404
|
+
}), hr = l.object({
|
|
1418
1405
|
type: l.literal("message"),
|
|
1419
1406
|
value: l.string(),
|
|
1420
|
-
attachments: l.array(
|
|
1407
|
+
attachments: l.array(St).optional(),
|
|
1421
1408
|
is_stream_chunk: l.boolean().optional(),
|
|
1422
1409
|
server_session_id: l.string(),
|
|
1423
1410
|
client_message_id: l.string().optional(),
|
|
1424
1411
|
server_message_id: l.string()
|
|
1425
|
-
}),
|
|
1412
|
+
}), yr = l.object({
|
|
1426
1413
|
type: l.literal("info"),
|
|
1427
1414
|
value: l.string()
|
|
1428
|
-
}),
|
|
1415
|
+
}), Sr = l.object({
|
|
1429
1416
|
type: l.literal("ui"),
|
|
1430
1417
|
value: l.object({
|
|
1431
1418
|
type: l.string(),
|
|
@@ -1436,36 +1423,36 @@ const gr = l.object({
|
|
|
1436
1423
|
}),
|
|
1437
1424
|
client_message_id: l.string().optional(),
|
|
1438
1425
|
server_session_id: l.string()
|
|
1439
|
-
}),
|
|
1426
|
+
}), vr = l.object({
|
|
1440
1427
|
type: l.literal("chat_event"),
|
|
1441
1428
|
value: l.object({
|
|
1442
1429
|
event: l.nativeEnum(Zt),
|
|
1443
1430
|
message: l.string()
|
|
1444
1431
|
})
|
|
1445
|
-
}),
|
|
1432
|
+
}), Er = l.object({
|
|
1446
1433
|
type: l.literal("options"),
|
|
1447
1434
|
value: l.object({
|
|
1448
1435
|
options: l.array(l.string())
|
|
1449
1436
|
}),
|
|
1450
1437
|
server_session_id: l.string()
|
|
1451
|
-
}),
|
|
1438
|
+
}), br = l.object({
|
|
1452
1439
|
type: l.literal("session_update"),
|
|
1453
1440
|
value: l.object({
|
|
1454
|
-
session:
|
|
1441
|
+
session: gr
|
|
1455
1442
|
}),
|
|
1456
1443
|
server_session_id: l.string()
|
|
1457
1444
|
});
|
|
1458
1445
|
l.discriminatedUnion("type", [
|
|
1459
|
-
mr,
|
|
1460
1446
|
hr,
|
|
1461
1447
|
yr,
|
|
1462
1448
|
Sr,
|
|
1463
1449
|
vr,
|
|
1464
|
-
Er
|
|
1450
|
+
Er,
|
|
1451
|
+
br
|
|
1465
1452
|
]).and(
|
|
1466
1453
|
l.object({
|
|
1467
1454
|
timestamp: l.string(),
|
|
1468
|
-
agent:
|
|
1455
|
+
agent: mr
|
|
1469
1456
|
})
|
|
1470
1457
|
);
|
|
1471
1458
|
l.object({
|
|
@@ -1484,7 +1471,7 @@ function ut(e) {
|
|
|
1484
1471
|
a.message && a.message.length > 0 && t.push({
|
|
1485
1472
|
type: "FROM_USER",
|
|
1486
1473
|
content: a.message,
|
|
1487
|
-
id: a.publicId
|
|
1474
|
+
id: a.publicId,
|
|
1488
1475
|
deliveredAt: a.created_at || "",
|
|
1489
1476
|
attachments: a.attachments,
|
|
1490
1477
|
timestamp: a.created_at || ""
|
|
@@ -1498,7 +1485,7 @@ function ut(e) {
|
|
|
1498
1485
|
data: {
|
|
1499
1486
|
message: a.message ?? ""
|
|
1500
1487
|
},
|
|
1501
|
-
id: a.publicId
|
|
1488
|
+
id: a.publicId,
|
|
1502
1489
|
timestamp: a.created_at || "",
|
|
1503
1490
|
original: a,
|
|
1504
1491
|
attachments: a.attachments,
|
|
@@ -1512,12 +1499,12 @@ function ut(e) {
|
|
|
1512
1499
|
break;
|
|
1513
1500
|
case "agent_message":
|
|
1514
1501
|
t.push({
|
|
1515
|
-
type: "
|
|
1502
|
+
type: "FROM_AGENT",
|
|
1516
1503
|
component: "TEXT",
|
|
1517
1504
|
data: {
|
|
1518
1505
|
message: a.message ?? ""
|
|
1519
1506
|
},
|
|
1520
|
-
id: a.publicId
|
|
1507
|
+
id: a.publicId,
|
|
1521
1508
|
timestamp: a.created_at || "",
|
|
1522
1509
|
original: a,
|
|
1523
1510
|
attachments: a.attachments,
|
|
@@ -1537,7 +1524,7 @@ function ut(e) {
|
|
|
1537
1524
|
event: a.type,
|
|
1538
1525
|
message: a.message ?? ""
|
|
1539
1526
|
},
|
|
1540
|
-
id: a.publicId ||
|
|
1527
|
+
id: a.publicId || ve(),
|
|
1541
1528
|
original: a,
|
|
1542
1529
|
attachments: a.attachments,
|
|
1543
1530
|
timestamp: a.created_at || "",
|
|
@@ -1552,9 +1539,9 @@ function ut(e) {
|
|
|
1552
1539
|
}
|
|
1553
1540
|
return t;
|
|
1554
1541
|
}
|
|
1555
|
-
function
|
|
1556
|
-
const t =
|
|
1557
|
-
return
|
|
1542
|
+
function wr(e) {
|
|
1543
|
+
const t = se(null);
|
|
1544
|
+
return le(() => {
|
|
1558
1545
|
if (!t.current) {
|
|
1559
1546
|
const n = new Audio(e.src);
|
|
1560
1547
|
n.volume = e.volume, n.loop = !1, n.preload = "auto", t.current = n;
|
|
@@ -1574,17 +1561,17 @@ function br(e) {
|
|
|
1574
1561
|
}
|
|
1575
1562
|
};
|
|
1576
1563
|
}
|
|
1577
|
-
function
|
|
1578
|
-
const { soundEffectFiles: e, widgetSettings: t, defaultSettings: n } =
|
|
1564
|
+
function Or() {
|
|
1565
|
+
const { soundEffectFiles: e, widgetSettings: t, defaultSettings: n } = ce(), r = (t == null ? void 0 : t.useSoundEffects) ?? n.useSoundEffects;
|
|
1579
1566
|
return {
|
|
1580
|
-
messageArrivedSound:
|
|
1567
|
+
messageArrivedSound: wr({
|
|
1581
1568
|
src: e.messageArrived,
|
|
1582
1569
|
soundEnabled: r,
|
|
1583
1570
|
volume: 0.5
|
|
1584
1571
|
})
|
|
1585
1572
|
};
|
|
1586
1573
|
}
|
|
1587
|
-
const
|
|
1574
|
+
const Ar = 5e3;
|
|
1588
1575
|
function _r(e, t) {
|
|
1589
1576
|
return mn(e, (n) => {
|
|
1590
1577
|
const r = () => {
|
|
@@ -1639,7 +1626,7 @@ function Rr({
|
|
|
1639
1626
|
persist: e,
|
|
1640
1627
|
sessionKey: t = (n, { external_id: r }) => `[OPEN_SESSION_${n}]_${r || "session"}`
|
|
1641
1628
|
}) {
|
|
1642
|
-
const { botToken: n, http: r, user: s } =
|
|
1629
|
+
const { botToken: n, http: r, user: s } = ce(), [o, a, d] = Je(
|
|
1643
1630
|
t(n, s),
|
|
1644
1631
|
void 0,
|
|
1645
1632
|
e ? "local" : "memory"
|
|
@@ -1649,13 +1636,13 @@ function Rr({
|
|
|
1649
1636
|
isAssignedToAi: f.assignee_id === 555,
|
|
1650
1637
|
isAssignedToHuman: f.assignee_id !== 555,
|
|
1651
1638
|
isPendingHuman: f.assignee_id === 555 && f.ai_closure_type === $e.handed_off
|
|
1652
|
-
}), u =
|
|
1639
|
+
}), u = ee(() => o ? g(o) : null, [o]), [c, i] = oe(
|
|
1653
1640
|
async (f) => {
|
|
1654
1641
|
let v = await r.apis.fetchSession(f);
|
|
1655
1642
|
return v.data && a(v.data), v.data;
|
|
1656
1643
|
},
|
|
1657
1644
|
[r, a]
|
|
1658
|
-
), [m, p] =
|
|
1645
|
+
), [m, p] = oe(
|
|
1659
1646
|
async (f) => {
|
|
1660
1647
|
try {
|
|
1661
1648
|
const v = await i(f);
|
|
@@ -1684,9 +1671,9 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1684
1671
|
lastUpdated: null,
|
|
1685
1672
|
messages: [],
|
|
1686
1673
|
keyboard: null
|
|
1687
|
-
}), [r, s] = Ke({ state: "idle" }), o = t.messages.length === 0, { botToken: a, http: d, widgetSettings: g, defaultSettings: u, language: c, ...i } =
|
|
1674
|
+
}), [r, s] = Ke({ state: "idle" }), o = t.messages.length === 0, { botToken: a, http: d, widgetSettings: g, defaultSettings: u, language: c, ...i } = ce(), { messageArrivedSound: m } = Or(), p = (g == null ? void 0 : g.persistSession) || u.persistSession, { refreshSession: y, session: f, deleteSession: v, setSession: h, pollSession: q } = Rr({
|
|
1688
1675
|
persist: p
|
|
1689
|
-
}), [D, S] =
|
|
1676
|
+
}), [D, S] = oe(
|
|
1690
1677
|
async (_) => {
|
|
1691
1678
|
if (!f) return [];
|
|
1692
1679
|
try {
|
|
@@ -1697,48 +1684,47 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1697
1684
|
}
|
|
1698
1685
|
},
|
|
1699
1686
|
[f, d.apis]
|
|
1700
|
-
), [O, E] =
|
|
1687
|
+
), [O, E] = oe(
|
|
1701
1688
|
async (_, N) => {
|
|
1702
1689
|
try {
|
|
1703
|
-
const
|
|
1690
|
+
const M = await d.apis.getHistoryPooling({
|
|
1704
1691
|
sessionId: _,
|
|
1705
1692
|
lastMessageTimestamp: N
|
|
1706
1693
|
});
|
|
1707
|
-
if (
|
|
1708
|
-
const
|
|
1709
|
-
if (
|
|
1694
|
+
if (M.data) {
|
|
1695
|
+
const H = ut(M.data);
|
|
1696
|
+
if (H.length > 0) {
|
|
1710
1697
|
n({
|
|
1711
1698
|
type: "APPEND_MESSAGES",
|
|
1712
|
-
payload:
|
|
1699
|
+
payload: H
|
|
1713
1700
|
});
|
|
1714
1701
|
try {
|
|
1715
1702
|
m.play();
|
|
1716
|
-
} catch (
|
|
1717
|
-
console.error("Error playing sound:",
|
|
1703
|
+
} catch (ue) {
|
|
1704
|
+
console.error("Error playing sound:", ue);
|
|
1718
1705
|
}
|
|
1719
1706
|
}
|
|
1720
|
-
return
|
|
1707
|
+
return H;
|
|
1721
1708
|
}
|
|
1722
1709
|
return [];
|
|
1723
|
-
} catch (
|
|
1724
|
-
throw console.error("Error polling messages:",
|
|
1710
|
+
} catch (M) {
|
|
1711
|
+
throw console.error("Error polling messages:", M), M;
|
|
1725
1712
|
}
|
|
1726
1713
|
},
|
|
1727
1714
|
[d.apis, n, m]
|
|
1728
1715
|
);
|
|
1729
|
-
|
|
1730
|
-
let _
|
|
1716
|
+
le(() => {
|
|
1717
|
+
let _;
|
|
1731
1718
|
return f && (_ = setInterval(() => {
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
V && E(f.id, V);
|
|
1719
|
+
var M;
|
|
1720
|
+
q(f.id);
|
|
1721
|
+
const N = (M = t.messages.at(-1)) == null ? void 0 : M.timestamp;
|
|
1722
|
+
N && E(f.id, N);
|
|
1737
1723
|
}, Ar)), () => {
|
|
1738
|
-
clearInterval(_)
|
|
1724
|
+
clearInterval(_);
|
|
1739
1725
|
};
|
|
1740
|
-
}, [f,
|
|
1741
|
-
const [
|
|
1726
|
+
}, [f, q, E]);
|
|
1727
|
+
const [F, A] = oe(
|
|
1742
1728
|
async () => {
|
|
1743
1729
|
if (f)
|
|
1744
1730
|
try {
|
|
@@ -1753,10 +1739,10 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1753
1739
|
},
|
|
1754
1740
|
[f, y, S, n]
|
|
1755
1741
|
);
|
|
1756
|
-
|
|
1742
|
+
le(() => {
|
|
1757
1743
|
A();
|
|
1758
1744
|
}, []);
|
|
1759
|
-
const [
|
|
1745
|
+
const [x, P] = oe(
|
|
1760
1746
|
async () => {
|
|
1761
1747
|
try {
|
|
1762
1748
|
v(), n({ type: "RESET" }), e == null || e(), s({ state: "idle" });
|
|
@@ -1765,7 +1751,7 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1765
1751
|
}
|
|
1766
1752
|
},
|
|
1767
1753
|
[v, n, e, s]
|
|
1768
|
-
), [
|
|
1754
|
+
), [B, W] = oe(
|
|
1769
1755
|
async () => {
|
|
1770
1756
|
try {
|
|
1771
1757
|
await P();
|
|
@@ -1776,15 +1762,15 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1776
1762
|
}
|
|
1777
1763
|
},
|
|
1778
1764
|
[P, d.apis, a, h]
|
|
1779
|
-
), L = async ({ content: _, user: N, attachments:
|
|
1780
|
-
var
|
|
1765
|
+
), L = async ({ content: _, user: N, attachments: M, ...H }) => {
|
|
1766
|
+
var ue;
|
|
1781
1767
|
try {
|
|
1782
|
-
let
|
|
1768
|
+
let U = f, G = !1;
|
|
1783
1769
|
if ((!f || f != null && f.isAssignedToAi) && s({ state: "loading" }), !f && o)
|
|
1784
1770
|
try {
|
|
1785
1771
|
const { data: w } = await d.apis.createSession(a);
|
|
1786
1772
|
if (w)
|
|
1787
|
-
h(w),
|
|
1773
|
+
h(w), U = {
|
|
1788
1774
|
...w,
|
|
1789
1775
|
isSessionClosed: w.status !== Ce.OPEN,
|
|
1790
1776
|
isAssignedToAi: w.assignee_id === 555,
|
|
@@ -1799,11 +1785,11 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1799
1785
|
error: w instanceof Error ? w.message : "Failed to create session"
|
|
1800
1786
|
}), w;
|
|
1801
1787
|
}
|
|
1802
|
-
if (!
|
|
1788
|
+
if (!U) {
|
|
1803
1789
|
const w = new Error("No active session available");
|
|
1804
1790
|
throw s({ state: "error", error: w.message }), w;
|
|
1805
1791
|
}
|
|
1806
|
-
const Y =
|
|
1792
|
+
const Y = ve(), { headers: fe, queryParams: we } = i;
|
|
1807
1793
|
if (n({
|
|
1808
1794
|
type: "APPEND_USER_MESSAGE",
|
|
1809
1795
|
payload: {
|
|
@@ -1816,32 +1802,32 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1816
1802
|
...N
|
|
1817
1803
|
},
|
|
1818
1804
|
deliveredAt: null,
|
|
1819
|
-
attachments:
|
|
1805
|
+
attachments: M
|
|
1820
1806
|
}
|
|
1821
1807
|
}), t.keyboard && n({
|
|
1822
1808
|
type: "SET_KEYBOARD",
|
|
1823
1809
|
payload: null
|
|
1824
|
-
}), !G &&
|
|
1810
|
+
}), !G && U.isAssignedToAi)
|
|
1825
1811
|
try {
|
|
1826
|
-
const w = await
|
|
1827
|
-
w && (
|
|
1812
|
+
const w = await q(U.id);
|
|
1813
|
+
w && (U = w);
|
|
1828
1814
|
} catch (w) {
|
|
1829
1815
|
console.error("Error polling session:", w);
|
|
1830
1816
|
}
|
|
1831
|
-
const
|
|
1817
|
+
const ne = await d.apis.sendMessage({
|
|
1832
1818
|
id: Y,
|
|
1833
1819
|
content: _.text,
|
|
1834
|
-
session_id:
|
|
1820
|
+
session_id: U.id,
|
|
1835
1821
|
bot_token: a,
|
|
1836
|
-
headers:
|
|
1822
|
+
headers: fe,
|
|
1837
1823
|
query_params: we,
|
|
1838
1824
|
user: {
|
|
1839
1825
|
...i.user,
|
|
1840
1826
|
...N
|
|
1841
1827
|
},
|
|
1842
1828
|
language: c,
|
|
1843
|
-
attachments:
|
|
1844
|
-
...
|
|
1829
|
+
attachments: M,
|
|
1830
|
+
...H
|
|
1845
1831
|
});
|
|
1846
1832
|
if (n({
|
|
1847
1833
|
type: "SET_DELIVERED_AT",
|
|
@@ -1849,13 +1835,13 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1849
1835
|
clientMessageId: Y,
|
|
1850
1836
|
deliveredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1851
1837
|
}
|
|
1852
|
-
}),
|
|
1853
|
-
const w =
|
|
1838
|
+
}), ne.data.success) {
|
|
1839
|
+
const w = ne.data;
|
|
1854
1840
|
if (w.autopilotResponse && n({
|
|
1855
1841
|
type: "ADD_RESPONSE_MESSAGE",
|
|
1856
1842
|
payload: {
|
|
1857
1843
|
type: "FROM_BOT",
|
|
1858
|
-
id: w.autopilotResponse.id ||
|
|
1844
|
+
id: w.autopilotResponse.id || ve(),
|
|
1859
1845
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1860
1846
|
component: "TEXT",
|
|
1861
1847
|
data: {
|
|
@@ -1863,25 +1849,25 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1863
1849
|
}
|
|
1864
1850
|
}
|
|
1865
1851
|
}), w.uiResponse) {
|
|
1866
|
-
const
|
|
1852
|
+
const he = w.uiResponse.value;
|
|
1867
1853
|
n({
|
|
1868
1854
|
type: "ADD_RESPONSE_MESSAGE",
|
|
1869
1855
|
payload: {
|
|
1870
1856
|
type: "FROM_BOT",
|
|
1871
|
-
id:
|
|
1857
|
+
id: ve(),
|
|
1872
1858
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1873
|
-
component:
|
|
1874
|
-
data:
|
|
1859
|
+
component: he.name,
|
|
1860
|
+
data: he.request_response
|
|
1875
1861
|
}
|
|
1876
1862
|
});
|
|
1877
1863
|
}
|
|
1878
1864
|
} else {
|
|
1879
|
-
const w = ((
|
|
1865
|
+
const w = ((ue = ne.data.error) == null ? void 0 : ue.message) || "Unknown error occurred";
|
|
1880
1866
|
n({
|
|
1881
1867
|
type: "ADD_RESPONSE_MESSAGE",
|
|
1882
1868
|
payload: {
|
|
1883
1869
|
type: "FROM_BOT",
|
|
1884
|
-
id:
|
|
1870
|
+
id: ve(),
|
|
1885
1871
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1886
1872
|
component: "TEXT",
|
|
1887
1873
|
data: {
|
|
@@ -1892,11 +1878,11 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1892
1878
|
}), s({ state: "error", error: w });
|
|
1893
1879
|
}
|
|
1894
1880
|
return s({ state: "idle" }), { id: Y };
|
|
1895
|
-
} catch (
|
|
1896
|
-
const G =
|
|
1897
|
-
throw console.error("Error in sendMessage:", G,
|
|
1881
|
+
} catch (U) {
|
|
1882
|
+
const G = U instanceof Error ? U.message : "An unexpected error occurred";
|
|
1883
|
+
throw console.error("Error in sendMessage:", G, U), (!f || f != null && f.isAssignedToAi) && s({ state: "error", error: G }), U;
|
|
1898
1884
|
}
|
|
1899
|
-
},
|
|
1885
|
+
}, te = ge(
|
|
1900
1886
|
(_) => {
|
|
1901
1887
|
L({
|
|
1902
1888
|
content: {
|
|
@@ -1916,34 +1902,34 @@ function Tr({ onSessionDestroy: e }) {
|
|
|
1916
1902
|
state: t,
|
|
1917
1903
|
session: f,
|
|
1918
1904
|
noMessages: o,
|
|
1919
|
-
initState:
|
|
1920
|
-
clearSessionState:
|
|
1921
|
-
recreateSessionState:
|
|
1905
|
+
initState: F,
|
|
1906
|
+
clearSessionState: x,
|
|
1907
|
+
recreateSessionState: B,
|
|
1922
1908
|
hookState: r,
|
|
1923
|
-
recreateSession:
|
|
1909
|
+
recreateSession: W,
|
|
1924
1910
|
clearSession: P,
|
|
1925
1911
|
sendMessage: L,
|
|
1926
|
-
handleKeyboard:
|
|
1912
|
+
handleKeyboard: te
|
|
1927
1913
|
};
|
|
1928
1914
|
}
|
|
1929
|
-
const [
|
|
1915
|
+
const [As, Dr] = De();
|
|
1930
1916
|
function Nr({
|
|
1931
1917
|
children: e
|
|
1932
1918
|
}) {
|
|
1933
|
-
const { settings: t } =
|
|
1919
|
+
const { settings: t } = ce(), n = Tr({
|
|
1934
1920
|
defaultHookSettings: {
|
|
1935
1921
|
persistSession: (t == null ? void 0 : t.persistSession) ?? !0,
|
|
1936
1922
|
useSoundEffects: (t == null ? void 0 : t.useSoundEffects) ?? !1
|
|
1937
1923
|
}
|
|
1938
1924
|
});
|
|
1939
|
-
return /* @__PURE__ */
|
|
1925
|
+
return /* @__PURE__ */ $(Dr, { value: n, children: e });
|
|
1940
1926
|
}
|
|
1941
1927
|
function Cr() {
|
|
1942
|
-
const { http: e, botToken: t, user: n, collectUserData: r } =
|
|
1928
|
+
const { http: e, botToken: t, user: n, collectUserData: r } = ce(), [s, o] = Je(
|
|
1943
1929
|
`${t}:contact:${n.external_id}`,
|
|
1944
1930
|
null,
|
|
1945
1931
|
"local"
|
|
1946
|
-
), [a, d] =
|
|
1932
|
+
), [a, d] = oe(
|
|
1947
1933
|
async (u) => {
|
|
1948
1934
|
var c;
|
|
1949
1935
|
try {
|
|
@@ -1957,10 +1943,10 @@ function Cr() {
|
|
|
1957
1943
|
},
|
|
1958
1944
|
[e.apis]
|
|
1959
1945
|
);
|
|
1960
|
-
|
|
1946
|
+
le(() => {
|
|
1961
1947
|
n && t && d(n);
|
|
1962
1948
|
}, [n, t]);
|
|
1963
|
-
const g =
|
|
1949
|
+
const g = ee(() => !(s != null && s.id) && r ? {
|
|
1964
1950
|
should: !0,
|
|
1965
1951
|
reason: "No contact id and collectUserData is true"
|
|
1966
1952
|
} : {
|
|
@@ -1973,16 +1959,16 @@ function Cr() {
|
|
|
1973
1959
|
shouldCollectData: g
|
|
1974
1960
|
};
|
|
1975
1961
|
}
|
|
1976
|
-
const [
|
|
1962
|
+
const [_s, xr] = De();
|
|
1977
1963
|
function Pr({ children: e }) {
|
|
1978
1964
|
const t = Cr();
|
|
1979
|
-
return /* @__PURE__ */
|
|
1965
|
+
return /* @__PURE__ */ $(xr, { value: t, children: e });
|
|
1980
1966
|
}
|
|
1981
|
-
function
|
|
1967
|
+
function Rs({
|
|
1982
1968
|
children: e,
|
|
1983
1969
|
options: t
|
|
1984
1970
|
}) {
|
|
1985
|
-
return /* @__PURE__ */
|
|
1971
|
+
return /* @__PURE__ */ $(rr, { data: t, children: /* @__PURE__ */ $(Pr, { children: /* @__PURE__ */ $(bt, { children: /* @__PURE__ */ $(Nr, { children: e }) }) }) });
|
|
1986
1972
|
}
|
|
1987
1973
|
var Ye = { exports: {} }, Le = {};
|
|
1988
1974
|
/**
|
|
@@ -1995,10 +1981,10 @@ var Ye = { exports: {} }, Le = {};
|
|
|
1995
1981
|
* LICENSE file in the root directory of this source tree.
|
|
1996
1982
|
*/
|
|
1997
1983
|
var lt;
|
|
1998
|
-
function
|
|
1984
|
+
function Ir() {
|
|
1999
1985
|
if (lt) return Le;
|
|
2000
1986
|
lt = 1;
|
|
2001
|
-
var e =
|
|
1987
|
+
var e = de;
|
|
2002
1988
|
function t(i, m) {
|
|
2003
1989
|
return i === m && (i !== 0 || 1 / i === 1 / m) || i !== i && m !== m;
|
|
2004
1990
|
}
|
|
@@ -2043,7 +2029,7 @@ var dt;
|
|
|
2043
2029
|
function jr() {
|
|
2044
2030
|
return dt || (dt = 1, process.env.NODE_ENV !== "production" && function() {
|
|
2045
2031
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
2046
|
-
var e =
|
|
2032
|
+
var e = de, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
2047
2033
|
function n(D) {
|
|
2048
2034
|
{
|
|
2049
2035
|
for (var S = arguments.length, O = new Array(S > 1 ? S - 1 : 0), E = 1; E < S; E++)
|
|
@@ -2053,10 +2039,10 @@ function jr() {
|
|
|
2053
2039
|
}
|
|
2054
2040
|
function r(D, S, O) {
|
|
2055
2041
|
{
|
|
2056
|
-
var E = t.ReactDebugCurrentFrame,
|
|
2057
|
-
|
|
2058
|
-
var A = O.map(function(
|
|
2059
|
-
return String(
|
|
2042
|
+
var E = t.ReactDebugCurrentFrame, F = E.getStackAddendum();
|
|
2043
|
+
F !== "" && (S += "%s", O = O.concat([F]));
|
|
2044
|
+
var A = O.map(function(x) {
|
|
2045
|
+
return String(x);
|
|
2060
2046
|
});
|
|
2061
2047
|
A.unshift("Warning: " + S), Function.prototype.apply.call(console[D], console, A);
|
|
2062
2048
|
}
|
|
@@ -2069,29 +2055,29 @@ function jr() {
|
|
|
2069
2055
|
c || e.startTransition !== void 0 && (c = !0, n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
2070
2056
|
var E = S();
|
|
2071
2057
|
if (!i) {
|
|
2072
|
-
var
|
|
2073
|
-
o(E,
|
|
2058
|
+
var F = S();
|
|
2059
|
+
o(E, F) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), i = !0);
|
|
2074
2060
|
}
|
|
2075
2061
|
var A = a({
|
|
2076
2062
|
inst: {
|
|
2077
2063
|
value: E,
|
|
2078
2064
|
getSnapshot: S
|
|
2079
2065
|
}
|
|
2080
|
-
}),
|
|
2066
|
+
}), x = A[0].inst, P = A[1];
|
|
2081
2067
|
return g(function() {
|
|
2082
|
-
|
|
2083
|
-
inst:
|
|
2068
|
+
x.value = E, x.getSnapshot = S, p(x) && P({
|
|
2069
|
+
inst: x
|
|
2084
2070
|
});
|
|
2085
2071
|
}, [D, E, S]), d(function() {
|
|
2086
|
-
p(
|
|
2087
|
-
inst:
|
|
2072
|
+
p(x) && P({
|
|
2073
|
+
inst: x
|
|
2088
2074
|
});
|
|
2089
|
-
var
|
|
2090
|
-
p(
|
|
2091
|
-
inst:
|
|
2075
|
+
var B = function() {
|
|
2076
|
+
p(x) && P({
|
|
2077
|
+
inst: x
|
|
2092
2078
|
});
|
|
2093
2079
|
};
|
|
2094
|
-
return D(
|
|
2080
|
+
return D(B);
|
|
2095
2081
|
}, [D]), u(E), E;
|
|
2096
2082
|
}
|
|
2097
2083
|
function p(D) {
|
|
@@ -2106,20 +2092,20 @@ function jr() {
|
|
|
2106
2092
|
function y(D, S, O) {
|
|
2107
2093
|
return S();
|
|
2108
2094
|
}
|
|
2109
|
-
var f = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", v = !f, h = v ? y : m,
|
|
2110
|
-
ke.useSyncExternalStore =
|
|
2095
|
+
var f = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", v = !f, h = v ? y : m, q = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : h;
|
|
2096
|
+
ke.useSyncExternalStore = q, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
2111
2097
|
}()), ke;
|
|
2112
2098
|
}
|
|
2113
|
-
process.env.NODE_ENV === "production" ? Ye.exports =
|
|
2099
|
+
process.env.NODE_ENV === "production" ? Ye.exports = Ir() : Ye.exports = jr();
|
|
2114
2100
|
var Lr = Ye.exports;
|
|
2115
|
-
const
|
|
2116
|
-
},
|
|
2101
|
+
const ae = () => {
|
|
2102
|
+
}, V = (
|
|
2117
2103
|
/*#__NOINLINE__*/
|
|
2118
|
-
|
|
2119
|
-
), Fe = Object, b = (e) => e ===
|
|
2104
|
+
ae()
|
|
2105
|
+
), Fe = Object, b = (e) => e === V, Q = (e) => typeof e == "function", ie = (e, t) => ({
|
|
2120
2106
|
...e,
|
|
2121
2107
|
...t
|
|
2122
|
-
}), kr = (e) =>
|
|
2108
|
+
}), kr = (e) => Q(e.then), Ae = /* @__PURE__ */ new WeakMap();
|
|
2123
2109
|
let Fr = 0;
|
|
2124
2110
|
const Ee = (e) => {
|
|
2125
2111
|
const t = typeof e, n = e && e.constructor, r = n == Date;
|
|
@@ -2141,8 +2127,8 @@ const Ee = (e) => {
|
|
|
2141
2127
|
} else
|
|
2142
2128
|
s = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
|
|
2143
2129
|
return s;
|
|
2144
|
-
},
|
|
2145
|
-
const n =
|
|
2130
|
+
}, Z = /* @__PURE__ */ new WeakMap(), Me = {}, _e = {}, et = "undefined", xe = typeof window != et, qe = typeof document != et, Mr = () => xe && typeof window.requestAnimationFrame != et, $t = (e, t) => {
|
|
2131
|
+
const n = Z.get(e);
|
|
2146
2132
|
return [
|
|
2147
2133
|
// Getter
|
|
2148
2134
|
() => !b(t) && e.get(t) || Me,
|
|
@@ -2150,7 +2136,7 @@ const Ee = (e) => {
|
|
|
2150
2136
|
(r) => {
|
|
2151
2137
|
if (!b(t)) {
|
|
2152
2138
|
const s = e.get(t);
|
|
2153
|
-
t in _e || (_e[t] = s), n[5](t,
|
|
2139
|
+
t in _e || (_e[t] = s), n[5](t, ie(s, r), s || Me);
|
|
2154
2140
|
}
|
|
2155
2141
|
},
|
|
2156
2142
|
// Subscriber
|
|
@@ -2159,23 +2145,23 @@ const Ee = (e) => {
|
|
|
2159
2145
|
() => !b(t) && t in _e ? _e[t] : !b(t) && e.get(t) || Me
|
|
2160
2146
|
];
|
|
2161
2147
|
};
|
|
2162
|
-
let
|
|
2163
|
-
const Vr = () =>
|
|
2148
|
+
let Be = !0;
|
|
2149
|
+
const Vr = () => Be, [Xe, Qe] = xe && window.addEventListener ? [
|
|
2164
2150
|
window.addEventListener.bind(window),
|
|
2165
2151
|
window.removeEventListener.bind(window)
|
|
2166
2152
|
] : [
|
|
2167
|
-
|
|
2168
|
-
|
|
2153
|
+
ae,
|
|
2154
|
+
ae
|
|
2169
2155
|
], Ur = () => {
|
|
2170
|
-
const e =
|
|
2156
|
+
const e = qe && document.visibilityState;
|
|
2171
2157
|
return b(e) || e !== "hidden";
|
|
2172
|
-
}, Hr = (e) => (
|
|
2173
|
-
|
|
2158
|
+
}, Hr = (e) => (qe && document.addEventListener("visibilitychange", e), Xe("focus", e), () => {
|
|
2159
|
+
qe && document.removeEventListener("visibilitychange", e), Qe("focus", e);
|
|
2174
2160
|
}), Gr = (e) => {
|
|
2175
2161
|
const t = () => {
|
|
2176
|
-
|
|
2162
|
+
Be = !0, e();
|
|
2177
2163
|
}, n = () => {
|
|
2178
|
-
|
|
2164
|
+
Be = !1;
|
|
2179
2165
|
};
|
|
2180
2166
|
return Xe("online", t), Xe("offline", n), () => {
|
|
2181
2167
|
Qe("online", t), Qe("offline", n);
|
|
@@ -2186,11 +2172,11 @@ const Vr = () => qe, [Xe, Qe] = Ie && window.addEventListener ? [
|
|
|
2186
2172
|
}, Yr = {
|
|
2187
2173
|
initFocus: Hr,
|
|
2188
2174
|
initReconnect: Gr
|
|
2189
|
-
}, ft = !
|
|
2175
|
+
}, ft = !de.useId, be = !xe || "Deno" in window, qr = (e) => Mr() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Ve = be ? le : pn, Ue = typeof navigator < "u" && navigator.connection, pt = !be && Ue && ([
|
|
2190
2176
|
"slow-2g",
|
|
2191
2177
|
"2g"
|
|
2192
2178
|
].includes(Ue.effectiveType) || Ue.saveData), tt = (e) => {
|
|
2193
|
-
if (
|
|
2179
|
+
if (Q(e))
|
|
2194
2180
|
try {
|
|
2195
2181
|
e = e();
|
|
2196
2182
|
} catch {
|
|
@@ -2202,9 +2188,9 @@ const Vr = () => qe, [Xe, Qe] = Ie && window.addEventListener ? [
|
|
|
2202
2188
|
t
|
|
2203
2189
|
];
|
|
2204
2190
|
};
|
|
2205
|
-
let
|
|
2206
|
-
const We = () => ++
|
|
2207
|
-
var
|
|
2191
|
+
let Br = 0;
|
|
2192
|
+
const We = () => ++Br, en = 0, tn = 1, nn = 2, Xr = 3;
|
|
2193
|
+
var Se = {
|
|
2208
2194
|
__proto__: null,
|
|
2209
2195
|
ERROR_REVALIDATE_EVENT: Xr,
|
|
2210
2196
|
FOCUS_EVENT: en,
|
|
@@ -2212,7 +2198,7 @@ var ve = {
|
|
|
2212
2198
|
RECONNECT_EVENT: tn
|
|
2213
2199
|
};
|
|
2214
2200
|
async function rn(...e) {
|
|
2215
|
-
const [t, n, r, s] = e, o =
|
|
2201
|
+
const [t, n, r, s] = e, o = ie({
|
|
2216
2202
|
populateCache: !0,
|
|
2217
2203
|
throwOnError: !0
|
|
2218
2204
|
}, typeof s == "boolean" ? {
|
|
@@ -2222,7 +2208,7 @@ async function rn(...e) {
|
|
|
2222
2208
|
const d = o.rollbackOnError;
|
|
2223
2209
|
let g = o.optimisticData;
|
|
2224
2210
|
const u = (m) => typeof d == "function" ? d(m) : d !== !1, c = o.throwOnError;
|
|
2225
|
-
if (
|
|
2211
|
+
if (Q(n)) {
|
|
2226
2212
|
const m = n, p = [], y = t.keys();
|
|
2227
2213
|
for (const f of y)
|
|
2228
2214
|
// Skip the special useSWRInfinite and useSWRSubscription keys.
|
|
@@ -2233,55 +2219,55 @@ async function rn(...e) {
|
|
|
2233
2219
|
async function i(m) {
|
|
2234
2220
|
const [p] = tt(m);
|
|
2235
2221
|
if (!p) return;
|
|
2236
|
-
const [y, f] = $t(t, p), [v, h,
|
|
2222
|
+
const [y, f] = $t(t, p), [v, h, q, D] = Z.get(t), S = () => {
|
|
2237
2223
|
const L = v[p];
|
|
2238
|
-
return (
|
|
2224
|
+
return (Q(o.revalidate) ? o.revalidate(y().data, m) : o.revalidate !== !1) && (delete q[p], delete D[p], L && L[0]) ? L[0](nn).then(() => y().data) : y().data;
|
|
2239
2225
|
};
|
|
2240
2226
|
if (e.length < 3)
|
|
2241
2227
|
return S();
|
|
2242
2228
|
let O = r, E;
|
|
2243
|
-
const
|
|
2229
|
+
const F = We();
|
|
2244
2230
|
h[p] = [
|
|
2245
|
-
|
|
2231
|
+
F,
|
|
2246
2232
|
0
|
|
2247
2233
|
];
|
|
2248
|
-
const A = !b(g),
|
|
2249
|
-
if (A && (g =
|
|
2234
|
+
const A = !b(g), x = y(), P = x.data, B = x._c, W = b(B) ? P : B;
|
|
2235
|
+
if (A && (g = Q(g) ? g(W, P) : g, f({
|
|
2250
2236
|
data: g,
|
|
2251
|
-
_c:
|
|
2252
|
-
})),
|
|
2237
|
+
_c: W
|
|
2238
|
+
})), Q(O))
|
|
2253
2239
|
try {
|
|
2254
|
-
O = O(
|
|
2240
|
+
O = O(W);
|
|
2255
2241
|
} catch (L) {
|
|
2256
2242
|
E = L;
|
|
2257
2243
|
}
|
|
2258
2244
|
if (O && kr(O))
|
|
2259
2245
|
if (O = await O.catch((L) => {
|
|
2260
2246
|
E = L;
|
|
2261
|
-
}),
|
|
2247
|
+
}), F !== h[p][0]) {
|
|
2262
2248
|
if (E) throw E;
|
|
2263
2249
|
return O;
|
|
2264
2250
|
} else E && A && u(E) && (a = !0, f({
|
|
2265
|
-
data:
|
|
2266
|
-
_c:
|
|
2251
|
+
data: W,
|
|
2252
|
+
_c: V
|
|
2267
2253
|
}));
|
|
2268
2254
|
if (a && !E)
|
|
2269
|
-
if (
|
|
2270
|
-
const L = a(O,
|
|
2255
|
+
if (Q(a)) {
|
|
2256
|
+
const L = a(O, W);
|
|
2271
2257
|
f({
|
|
2272
2258
|
data: L,
|
|
2273
|
-
error:
|
|
2274
|
-
_c:
|
|
2259
|
+
error: V,
|
|
2260
|
+
_c: V
|
|
2275
2261
|
});
|
|
2276
2262
|
} else
|
|
2277
2263
|
f({
|
|
2278
2264
|
data: O,
|
|
2279
|
-
error:
|
|
2280
|
-
_c:
|
|
2265
|
+
error: V,
|
|
2266
|
+
_c: V
|
|
2281
2267
|
});
|
|
2282
2268
|
if (h[p][1] = We(), Promise.resolve(S()).then(() => {
|
|
2283
2269
|
f({
|
|
2284
|
-
_c:
|
|
2270
|
+
_c: V
|
|
2285
2271
|
});
|
|
2286
2272
|
}), E) {
|
|
2287
2273
|
if (c) throw E;
|
|
@@ -2294,9 +2280,9 @@ const gt = (e, t) => {
|
|
|
2294
2280
|
for (const n in e)
|
|
2295
2281
|
e[n][0] && e[n][0](t);
|
|
2296
2282
|
}, Qr = (e, t) => {
|
|
2297
|
-
if (!
|
|
2298
|
-
const n =
|
|
2299
|
-
let o =
|
|
2283
|
+
if (!Z.has(e)) {
|
|
2284
|
+
const n = ie(Yr, t), r = {}, s = rn.bind(V, e);
|
|
2285
|
+
let o = ae;
|
|
2300
2286
|
const a = {}, d = (c, i) => {
|
|
2301
2287
|
const m = a[c] || [];
|
|
2302
2288
|
return a[c] = m, m.push(i), () => m.splice(m.indexOf(i), 1);
|
|
@@ -2307,7 +2293,7 @@ const gt = (e, t) => {
|
|
|
2307
2293
|
for (const y of p)
|
|
2308
2294
|
y(i, m);
|
|
2309
2295
|
}, u = () => {
|
|
2310
|
-
if (!
|
|
2296
|
+
if (!Z.has(e) && (Z.set(e, [
|
|
2311
2297
|
r,
|
|
2312
2298
|
{},
|
|
2313
2299
|
{},
|
|
@@ -2316,9 +2302,9 @@ const gt = (e, t) => {
|
|
|
2316
2302
|
g,
|
|
2317
2303
|
d
|
|
2318
2304
|
]), !be)) {
|
|
2319
|
-
const c = n.initFocus(setTimeout.bind(
|
|
2305
|
+
const c = n.initFocus(setTimeout.bind(V, gt.bind(V, r, en))), i = n.initReconnect(setTimeout.bind(V, gt.bind(V, r, tn)));
|
|
2320
2306
|
o = () => {
|
|
2321
|
-
c && c(), i && i(),
|
|
2307
|
+
c && c(), i && i(), Z.delete(e);
|
|
2322
2308
|
};
|
|
2323
2309
|
}
|
|
2324
2310
|
};
|
|
@@ -2331,19 +2317,19 @@ const gt = (e, t) => {
|
|
|
2331
2317
|
}
|
|
2332
2318
|
return [
|
|
2333
2319
|
e,
|
|
2334
|
-
|
|
2320
|
+
Z.get(e)[4]
|
|
2335
2321
|
];
|
|
2336
2322
|
}, Wr = (e, t, n, r, s) => {
|
|
2337
2323
|
const o = n.errorRetryCount, a = s.retryCount, d = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * n.errorRetryInterval;
|
|
2338
2324
|
!b(o) && a > o || setTimeout(r, d, s);
|
|
2339
|
-
}, Kr = (e, t) => Ee(e) == Ee(t), [sn, Jr] = Qr(/* @__PURE__ */ new Map()), Zr =
|
|
2325
|
+
}, Kr = (e, t) => Ee(e) == Ee(t), [sn, Jr] = Qr(/* @__PURE__ */ new Map()), Zr = ie(
|
|
2340
2326
|
{
|
|
2341
2327
|
// events
|
|
2342
|
-
onLoadingSlow:
|
|
2343
|
-
onSuccess:
|
|
2344
|
-
onError:
|
|
2328
|
+
onLoadingSlow: ae,
|
|
2329
|
+
onSuccess: ae,
|
|
2330
|
+
onError: ae,
|
|
2345
2331
|
onErrorRetry: Wr,
|
|
2346
|
-
onDiscarded:
|
|
2332
|
+
onDiscarded: ae,
|
|
2347
2333
|
// switches
|
|
2348
2334
|
revalidateOnFocus: !0,
|
|
2349
2335
|
revalidateOnReconnect: !0,
|
|
@@ -2364,15 +2350,15 @@ const gt = (e, t) => {
|
|
|
2364
2350
|
// use web preset by default
|
|
2365
2351
|
zr
|
|
2366
2352
|
), $r = (e, t) => {
|
|
2367
|
-
const n =
|
|
2353
|
+
const n = ie(e, t);
|
|
2368
2354
|
if (t) {
|
|
2369
2355
|
const { use: r, fallback: s } = e, { use: o, fallback: a } = t;
|
|
2370
|
-
r && o && (n.use = r.concat(o)), s && a && (n.fallback =
|
|
2356
|
+
r && o && (n.use = r.concat(o)), s && a && (n.fallback = ie(s, a));
|
|
2371
2357
|
}
|
|
2372
2358
|
return n;
|
|
2373
|
-
}, es =
|
|
2374
|
-
on && (window.__SWR_DEVTOOLS_REACT__ =
|
|
2375
|
-
}, ss = (e) =>
|
|
2359
|
+
}, es = ht({}), ts = "$inf$", on = xe && window.__SWR_DEVTOOLS_USE__, ns = on ? window.__SWR_DEVTOOLS_USE__ : [], rs = () => {
|
|
2360
|
+
on && (window.__SWR_DEVTOOLS_REACT__ = de);
|
|
2361
|
+
}, ss = (e) => Q(e[1]) ? [
|
|
2376
2362
|
e[0],
|
|
2377
2363
|
e[1],
|
|
2378
2364
|
e[2] || {}
|
|
@@ -2380,8 +2366,8 @@ const gt = (e, t) => {
|
|
|
2380
2366
|
e[0],
|
|
2381
2367
|
null,
|
|
2382
2368
|
(e[1] === null ? e[2] : e[1]) || {}
|
|
2383
|
-
], os = () =>
|
|
2384
|
-
const [a] = tt(t), [, , , d] =
|
|
2369
|
+
], os = () => ie(Zr, yt(es)), as = (e) => (t, n, r) => e(t, n && ((...o) => {
|
|
2370
|
+
const [a] = tt(t), [, , , d] = Z.get(sn);
|
|
2385
2371
|
if (a.startsWith(ts))
|
|
2386
2372
|
return n(...o);
|
|
2387
2373
|
const g = d[a];
|
|
@@ -2401,7 +2387,7 @@ const gt = (e, t) => {
|
|
|
2401
2387
|
};
|
|
2402
2388
|
};
|
|
2403
2389
|
rs();
|
|
2404
|
-
const mt =
|
|
2390
|
+
const mt = de.use || ((e) => {
|
|
2405
2391
|
if (e.status === "pending")
|
|
2406
2392
|
throw e;
|
|
2407
2393
|
if (e.status === "fulfilled")
|
|
@@ -2414,38 +2400,38 @@ const mt = fe.use || ((e) => {
|
|
|
2414
2400
|
}), He = {
|
|
2415
2401
|
dedupe: !0
|
|
2416
2402
|
}, ls = (e, t, n) => {
|
|
2417
|
-
const { cache: r, compare: s, suspense: o, fallbackData: a, revalidateOnMount: d, revalidateIfStale: g, refreshInterval: u, refreshWhenHidden: c, refreshWhenOffline: i, keepPreviousData: m } = n, [p, y, f, v] =
|
|
2418
|
-
for (const j in
|
|
2403
|
+
const { cache: r, compare: s, suspense: o, fallbackData: a, revalidateOnMount: d, revalidateIfStale: g, refreshInterval: u, refreshWhenHidden: c, refreshWhenOffline: i, keepPreviousData: m } = n, [p, y, f, v] = Z.get(r), [h, q] = tt(e), D = se(!1), S = se(!1), O = se(h), E = se(t), F = se(n), A = () => F.current, x = () => A().isVisible() && A().isOnline(), [P, B, W, L] = $t(r, h), te = se({}).current, _ = b(a) ? n.fallback[h] : a, N = (R, T) => {
|
|
2404
|
+
for (const j in te) {
|
|
2419
2405
|
const C = j;
|
|
2420
2406
|
if (C === "data") {
|
|
2421
|
-
if (!s(R[C], T[C]) && (!b(R[C]) || !s(
|
|
2407
|
+
if (!s(R[C], T[C]) && (!b(R[C]) || !s(ne, T[C])))
|
|
2422
2408
|
return !1;
|
|
2423
2409
|
} else if (T[C] !== R[C])
|
|
2424
2410
|
return !1;
|
|
2425
2411
|
}
|
|
2426
2412
|
return !0;
|
|
2427
|
-
},
|
|
2428
|
-
const R = !h || !t ? !1 : b(d) ? A().isPaused() || o ? !1 : b(g) ? !0 : g : d, T = (
|
|
2429
|
-
const
|
|
2430
|
-
return delete
|
|
2413
|
+
}, M = ee(() => {
|
|
2414
|
+
const R = !h || !t ? !1 : b(d) ? A().isPaused() || o ? !1 : b(g) ? !0 : g : d, T = (k) => {
|
|
2415
|
+
const K = ie(k);
|
|
2416
|
+
return delete K._k, R ? {
|
|
2431
2417
|
isValidating: !0,
|
|
2432
2418
|
isLoading: !0,
|
|
2433
|
-
...
|
|
2434
|
-
} :
|
|
2435
|
-
}, j = P(), C = L(),
|
|
2436
|
-
let
|
|
2419
|
+
...K
|
|
2420
|
+
} : K;
|
|
2421
|
+
}, j = P(), C = L(), X = T(j), pe = j === C ? X : T(C);
|
|
2422
|
+
let I = X;
|
|
2437
2423
|
return [
|
|
2438
2424
|
() => {
|
|
2439
|
-
const
|
|
2440
|
-
return N(
|
|
2425
|
+
const k = T(P());
|
|
2426
|
+
return N(k, I) ? (I.data = k.data, I.isLoading = k.isLoading, I.isValidating = k.isValidating, I.error = k.error, I) : (I = k, k);
|
|
2441
2427
|
},
|
|
2442
|
-
() =>
|
|
2428
|
+
() => pe
|
|
2443
2429
|
];
|
|
2444
2430
|
}, [
|
|
2445
2431
|
r,
|
|
2446
2432
|
h
|
|
2447
|
-
]),
|
|
2448
|
-
(R) =>
|
|
2433
|
+
]), H = Lr.useSyncExternalStore(ge(
|
|
2434
|
+
(R) => W(h, (T, j) => {
|
|
2449
2435
|
N(j, T) || R();
|
|
2450
2436
|
}),
|
|
2451
2437
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2453,17 +2439,17 @@ const mt = fe.use || ((e) => {
|
|
|
2453
2439
|
r,
|
|
2454
2440
|
h
|
|
2455
2441
|
]
|
|
2456
|
-
),
|
|
2442
|
+
), M[0], M[1]), ue = !D.current, U = p[h] && p[h].length > 0, G = H.data, Y = b(G) ? _ : G, fe = H.error, we = se(Y), ne = m ? b(G) ? we.current : G : Y, w = U && !b(fe) ? !1 : ue && !b(d) ? d : A().isPaused() ? !1 : o ? b(Y) ? !1 : g : b(Y) || g, he = !!(h && t && ue && w), an = b(H.isValidating) ? he : H.isValidating, cn = b(H.isLoading) ? he : H.isLoading, ye = ge(
|
|
2457
2443
|
async (R) => {
|
|
2458
2444
|
const T = E.current;
|
|
2459
2445
|
if (!h || !T || S.current || A().isPaused())
|
|
2460
2446
|
return !1;
|
|
2461
|
-
let j, C,
|
|
2462
|
-
const
|
|
2447
|
+
let j, C, X = !0;
|
|
2448
|
+
const pe = R || {}, I = !f[h] || !pe.dedupe, k = () => ft ? !S.current && h === O.current && D.current : h === O.current, K = {
|
|
2463
2449
|
isValidating: !1,
|
|
2464
2450
|
isLoading: !1
|
|
2465
2451
|
}, rt = () => {
|
|
2466
|
-
|
|
2452
|
+
B(K);
|
|
2467
2453
|
}, st = () => {
|
|
2468
2454
|
const z = f[h];
|
|
2469
2455
|
z && z[1] === C && delete f[h];
|
|
@@ -2472,34 +2458,34 @@ const mt = fe.use || ((e) => {
|
|
|
2472
2458
|
};
|
|
2473
2459
|
b(P().data) && (ot.isLoading = !0);
|
|
2474
2460
|
try {
|
|
2475
|
-
if (
|
|
2476
|
-
|
|
2461
|
+
if (I && (B(ot), n.loadingTimeout && b(P().data) && setTimeout(() => {
|
|
2462
|
+
X && k() && A().onLoadingSlow(h, n);
|
|
2477
2463
|
}, n.loadingTimeout), f[h] = [
|
|
2478
|
-
T(
|
|
2464
|
+
T(q),
|
|
2479
2465
|
We()
|
|
2480
|
-
]), [j, C] = f[h], j = await j,
|
|
2481
|
-
return
|
|
2482
|
-
|
|
2466
|
+
]), [j, C] = f[h], j = await j, I && setTimeout(st, n.dedupingInterval), !f[h] || f[h][1] !== C)
|
|
2467
|
+
return I && k() && A().onDiscarded(h), !1;
|
|
2468
|
+
K.error = V;
|
|
2483
2469
|
const z = y[h];
|
|
2484
2470
|
if (!b(z) && // case 1
|
|
2485
2471
|
(C <= z[0] || // case 2
|
|
2486
2472
|
C <= z[1] || // case 3
|
|
2487
2473
|
z[1] === 0))
|
|
2488
|
-
return rt(),
|
|
2489
|
-
const
|
|
2490
|
-
|
|
2474
|
+
return rt(), I && k() && A().onDiscarded(h), !1;
|
|
2475
|
+
const J = P().data;
|
|
2476
|
+
K.data = s(J, j) ? J : j, I && k() && A().onSuccess(j, h, n);
|
|
2491
2477
|
} catch (z) {
|
|
2492
2478
|
st();
|
|
2493
|
-
const
|
|
2494
|
-
|
|
2495
|
-
const
|
|
2496
|
-
|
|
2479
|
+
const J = A(), { shouldRetryOnError: Pe } = J;
|
|
2480
|
+
J.isPaused() || (K.error = z, I && k() && (J.onError(z, h, J), (Pe === !0 || Q(Pe) && Pe(z)) && (!A().revalidateOnFocus || !A().revalidateOnReconnect || x()) && J.onErrorRetry(z, h, J, (un) => {
|
|
2481
|
+
const Ie = p[h];
|
|
2482
|
+
Ie && Ie[0] && Ie[0](Se.ERROR_REVALIDATE_EVENT, un);
|
|
2497
2483
|
}, {
|
|
2498
|
-
retryCount: (
|
|
2484
|
+
retryCount: (pe.retryCount || 0) + 1,
|
|
2499
2485
|
dedupe: !0
|
|
2500
2486
|
})));
|
|
2501
2487
|
}
|
|
2502
|
-
return
|
|
2488
|
+
return X = !1, rt(), !0;
|
|
2503
2489
|
},
|
|
2504
2490
|
// `setState` is immutable, and `eventsCallback`, `fnArg`, and
|
|
2505
2491
|
// `keyValidating` are depending on `key`, so we can exclude them from
|
|
@@ -2516,34 +2502,34 @@ const mt = fe.use || ((e) => {
|
|
|
2516
2502
|
h,
|
|
2517
2503
|
r
|
|
2518
2504
|
]
|
|
2519
|
-
), nt =
|
|
2505
|
+
), nt = ge(
|
|
2520
2506
|
// Use callback to make sure `keyRef.current` returns latest result every time
|
|
2521
2507
|
(...R) => rn(r, O.current, ...R),
|
|
2522
2508
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2523
2509
|
[]
|
|
2524
2510
|
);
|
|
2525
2511
|
if (Ve(() => {
|
|
2526
|
-
E.current = t,
|
|
2512
|
+
E.current = t, F.current = n, b(G) || (we.current = G);
|
|
2527
2513
|
}), Ve(() => {
|
|
2528
2514
|
if (!h) return;
|
|
2529
|
-
const R =
|
|
2515
|
+
const R = ye.bind(V, He);
|
|
2530
2516
|
let T = 0;
|
|
2531
|
-
const C = us(h, p, (
|
|
2532
|
-
if (
|
|
2533
|
-
const
|
|
2534
|
-
A().revalidateOnFocus &&
|
|
2535
|
-
} else if (
|
|
2536
|
-
A().revalidateOnReconnect &&
|
|
2517
|
+
const C = us(h, p, (X, pe = {}) => {
|
|
2518
|
+
if (X == Se.FOCUS_EVENT) {
|
|
2519
|
+
const I = Date.now();
|
|
2520
|
+
A().revalidateOnFocus && I > T && x() && (T = I + A().focusThrottleInterval, R());
|
|
2521
|
+
} else if (X == Se.RECONNECT_EVENT)
|
|
2522
|
+
A().revalidateOnReconnect && x() && R();
|
|
2537
2523
|
else {
|
|
2538
|
-
if (
|
|
2539
|
-
return
|
|
2540
|
-
if (
|
|
2541
|
-
return
|
|
2524
|
+
if (X == Se.MUTATE_EVENT)
|
|
2525
|
+
return ye();
|
|
2526
|
+
if (X == Se.ERROR_REVALIDATE_EVENT)
|
|
2527
|
+
return ye(pe);
|
|
2542
2528
|
}
|
|
2543
2529
|
});
|
|
2544
|
-
return S.current = !1, O.current = h, D.current = !0,
|
|
2545
|
-
_k:
|
|
2546
|
-
}), w && (b(Y) || be ? R() :
|
|
2530
|
+
return S.current = !1, O.current = h, D.current = !0, B({
|
|
2531
|
+
_k: q
|
|
2532
|
+
}), w && (b(Y) || be ? R() : qr(R)), () => {
|
|
2547
2533
|
S.current = !0, C();
|
|
2548
2534
|
};
|
|
2549
2535
|
}, [
|
|
@@ -2551,11 +2537,11 @@ const mt = fe.use || ((e) => {
|
|
|
2551
2537
|
]), Ve(() => {
|
|
2552
2538
|
let R;
|
|
2553
2539
|
function T() {
|
|
2554
|
-
const C =
|
|
2540
|
+
const C = Q(u) ? u(P().data) : u;
|
|
2555
2541
|
C && R !== -1 && (R = setTimeout(j, C));
|
|
2556
2542
|
}
|
|
2557
2543
|
function j() {
|
|
2558
|
-
!P().error && (c || A().isVisible()) && (i || A().isOnline()) ?
|
|
2544
|
+
!P().error && (c || A().isVisible()) && (i || A().isOnline()) ? ye(He).then(T) : T();
|
|
2559
2545
|
}
|
|
2560
2546
|
return T(), () => {
|
|
2561
2547
|
R && (clearTimeout(R), R = -1);
|
|
@@ -2565,39 +2551,39 @@ const mt = fe.use || ((e) => {
|
|
|
2565
2551
|
c,
|
|
2566
2552
|
i,
|
|
2567
2553
|
h
|
|
2568
|
-
]), gn(
|
|
2554
|
+
]), gn(ne), o && b(Y) && h) {
|
|
2569
2555
|
if (!ft && be)
|
|
2570
2556
|
throw new Error("Fallback data is required when using suspense in SSR.");
|
|
2571
|
-
E.current = t,
|
|
2557
|
+
E.current = t, F.current = n, S.current = !1;
|
|
2572
2558
|
const R = v[h];
|
|
2573
2559
|
if (!b(R)) {
|
|
2574
2560
|
const T = nt(R);
|
|
2575
2561
|
mt(T);
|
|
2576
2562
|
}
|
|
2577
|
-
if (b(
|
|
2578
|
-
const T =
|
|
2579
|
-
b(
|
|
2563
|
+
if (b(fe)) {
|
|
2564
|
+
const T = ye(He);
|
|
2565
|
+
b(ne) || (T.status = "fulfilled", T.value = !0), mt(T);
|
|
2580
2566
|
} else
|
|
2581
|
-
throw
|
|
2567
|
+
throw fe;
|
|
2582
2568
|
}
|
|
2583
2569
|
return {
|
|
2584
2570
|
mutate: nt,
|
|
2585
2571
|
get data() {
|
|
2586
|
-
return
|
|
2572
|
+
return te.data = !0, ne;
|
|
2587
2573
|
},
|
|
2588
2574
|
get error() {
|
|
2589
|
-
return
|
|
2575
|
+
return te.error = !0, fe;
|
|
2590
2576
|
},
|
|
2591
2577
|
get isValidating() {
|
|
2592
|
-
return
|
|
2578
|
+
return te.isValidating = !0, an;
|
|
2593
2579
|
},
|
|
2594
2580
|
get isLoading() {
|
|
2595
|
-
return
|
|
2581
|
+
return te.isLoading = !0, cn;
|
|
2596
2582
|
}
|
|
2597
2583
|
};
|
|
2598
2584
|
}, ds = cs(ls);
|
|
2599
|
-
function
|
|
2600
|
-
const { apiUrl: e, botToken: t } =
|
|
2585
|
+
function Ts() {
|
|
2586
|
+
const { apiUrl: e, botToken: t } = ce(), n = Et({
|
|
2601
2587
|
apiUrl: e,
|
|
2602
2588
|
botToken: t
|
|
2603
2589
|
});
|
|
@@ -2605,22 +2591,19 @@ function Cs() {
|
|
|
2605
2591
|
}
|
|
2606
2592
|
export {
|
|
2607
2593
|
$e as A,
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2594
|
+
Rs as W,
|
|
2595
|
+
oe as _,
|
|
2596
|
+
_s as a,
|
|
2597
|
+
As as b,
|
|
2612
2598
|
bs as c,
|
|
2613
|
-
|
|
2614
|
-
|
|
2599
|
+
Es as d,
|
|
2600
|
+
Os as e,
|
|
2615
2601
|
Ts as f,
|
|
2616
2602
|
ws as g,
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
_s as m,
|
|
2623
|
-
wr as n,
|
|
2624
|
-
Os as u
|
|
2603
|
+
Re as h,
|
|
2604
|
+
At as i,
|
|
2605
|
+
Ft as j,
|
|
2606
|
+
Or as k,
|
|
2607
|
+
ce as u
|
|
2625
2608
|
};
|
|
2626
|
-
//# sourceMappingURL=index-
|
|
2609
|
+
//# sourceMappingURL=index-D84Xc70r.js.map
|