@opencx/widget 2.6.0 → 2.6.2

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.
Files changed (102) hide show
  1. package/dist/api-BEtFfKMB.cjs +2 -0
  2. package/dist/api-BEtFfKMB.cjs.map +1 -0
  3. package/dist/api-Cez5T-se.js +1393 -0
  4. package/dist/api-Cez5T-se.js.map +1 -0
  5. package/dist/basic.cjs +85 -85
  6. package/dist/basic.cjs.map +1 -1
  7. package/dist/basic.js +13159 -12639
  8. package/dist/basic.js.map +1 -1
  9. package/dist/core/client/api.d.ts +414 -40
  10. package/dist/core/client/chat.d.ts +33 -19
  11. package/dist/core/client/config.d.ts +13 -3
  12. package/dist/core/client/contact.d.ts +9 -13
  13. package/dist/core/client/index.d.ts +1 -1
  14. package/dist/core/index.d.ts +1 -1
  15. package/dist/core/sdk/index.d.ts +11 -0
  16. package/dist/core/types/contact.d.ts +2 -0
  17. package/dist/core/types/helpers.d.ts +5 -2
  18. package/dist/core/types/index.d.ts +6 -6
  19. package/dist/core/types/messages.d.ts +20 -9
  20. package/dist/core/types/schemas-v2.d.ts +10 -713
  21. package/dist/index-BzidnDPX.cjs +18 -0
  22. package/dist/index-BzidnDPX.cjs.map +1 -0
  23. package/dist/index-DUlnC30_.js +1219 -0
  24. package/dist/index-DUlnC30_.js.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +22 -1071
  28. package/dist/index.js.map +1 -1
  29. package/dist/react-web/core-integration/ChatProvider.d.ts +107 -0
  30. package/dist/react-web/core-integration/components.d.ts +11 -0
  31. package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +70 -0
  32. package/dist/react-web/core-integration/hooks/useChatSession.d.ts +83 -0
  33. package/dist/react-web/core-integration/hooks/useConfig.d.ts +1 -0
  34. package/dist/react-web/core-integration/hooks/useContact.d.ts +17 -0
  35. package/dist/react-web/core-integration/hooks/useLocale.d.ts +4 -0
  36. package/dist/react-web/core-integration/hooks/usePreludeData.d.ts +36 -0
  37. package/dist/react-web/core-integration/hooks/usePubsub.d.ts +2 -0
  38. package/dist/react-web/{hooks → core-integration/hooks}/useUploadFiles.d.ts +2 -2
  39. package/dist/react-web/{hooks → core-integration/hooks}/useVote.d.ts +2 -2
  40. package/dist/react-web/core-integration/hooks.d.ts +9 -0
  41. package/dist/react-web/core-integration/index.d.ts +2 -0
  42. package/dist/react-web/index.d.ts +4 -10
  43. package/dist/react-web/types/components.d.ts +6 -3
  44. package/dist/react-web/types/index.d.ts +3 -2
  45. package/dist/react-web/types/options.d.ts +4 -30
  46. package/dist/react.cjs +1 -1
  47. package/dist/react.cjs.map +1 -1
  48. package/dist/react.js +10 -46
  49. package/dist/react.js.map +1 -1
  50. package/dist/src/@components/BotOrAgentMessageGroup.d.ts +1 -2
  51. package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +2 -2
  52. package/dist/src/@components/ChatEvent.component.d.ts +3 -3
  53. package/dist/src/@components/Text.component.d.ts +1 -1
  54. package/dist/src/components/button.d.ts +1 -1
  55. package/dist/src/components/dialog.d.ts +9 -9
  56. package/dist/src/designs/basic/index.d.ts +1 -1
  57. package/dist/style.css +1 -1
  58. package/dist-embed/script.js +119 -124
  59. package/dist-embed/script.js.map +1 -1
  60. package/package.json +7 -4
  61. package/dist/core/tests/utils/create-fetch.test.d.ts +0 -1
  62. package/dist/core/types/schemas.d.ts +0 -543
  63. package/dist/core/utils/create-fetch.d.ts +0 -25
  64. package/dist/core/utils/genId.d.ts +0 -2
  65. package/dist/core/utils/history-to-widget-messages.d.ts +0 -4
  66. package/dist/genUuid-C12yFv3j.js +0 -137
  67. package/dist/genUuid-C12yFv3j.js.map +0 -1
  68. package/dist/genUuid-DdeSE04H.cjs +0 -2
  69. package/dist/genUuid-DdeSE04H.cjs.map +0 -1
  70. package/dist/index-C87obATS.js +0 -2616
  71. package/dist/index-C87obATS.js.map +0 -1
  72. package/dist/index-ChwS_h0D.cjs +0 -18
  73. package/dist/index-ChwS_h0D.cjs.map +0 -1
  74. package/dist/package.json.d.ts +0 -158
  75. package/dist/react-web/Root.d.ts +0 -6
  76. package/dist/react-web/hooks/index.d.ts +0 -6
  77. package/dist/react-web/hooks/use-sound.d.ts +0 -13
  78. package/dist/react-web/hooks/use-sound.test.d.ts +0 -1
  79. package/dist/react-web/hooks/use-sync-state.test.d.ts +0 -1
  80. package/dist/react-web/hooks/useAbstractChat.d.ts +0 -157
  81. package/dist/react-web/hooks/useAxiosInstance.d.ts +0 -190
  82. package/dist/react-web/hooks/useSyncState.d.ts +0 -4
  83. package/dist/react-web/hooks/useTimeoutState.d.ts +0 -3
  84. package/dist/react-web/providers/ChatProvider.d.ts +0 -143
  85. package/dist/react-web/providers/ConfigDataProvider.d.ts +0 -62
  86. package/dist/react-web/providers/ContactProvider.d.ts +0 -58
  87. package/dist/react-web/providers/LocalesProvider.d.ts +0 -11
  88. package/dist/react-web/providers/componentRegistry.d.ts +0 -13
  89. package/dist/react-web/providers/use-widget-sfx.d.ts +0 -7
  90. package/dist/react-web/providers/usePreludeData.d.ts +0 -2
  91. package/dist/react-web/utils/debug.d.ts +0 -2
  92. package/dist/react-web/utils/getters.d.ts +0 -24
  93. package/dist/react-web/utils/index.d.ts +0 -1
  94. package/dist/src/hooks/useShouldCollectData.d.ts +0 -3
  95. /package/dist/react-web/{locales → core-integration/locales}/ar.locale.d.ts +0 -0
  96. /package/dist/react-web/{locales → core-integration/locales}/de.locale.d.ts +0 -0
  97. /package/dist/react-web/{locales → core-integration/locales}/en.locale.d.ts +0 -0
  98. /package/dist/react-web/{locales → core-integration/locales}/fr.locale.d.ts +0 -0
  99. /package/dist/react-web/{locales → core-integration/locales}/helper.d.ts +0 -0
  100. /package/dist/react-web/{locales → core-integration/locales}/index.d.ts +0 -0
  101. /package/dist/react-web/{locales → core-integration/locales}/nl.locale.d.ts +0 -0
  102. /package/dist/react-web/{locales → core-integration/locales}/pt.locale.d.ts +0 -0
@@ -1,2616 +0,0 @@
1
- var ln = Object.defineProperty;
2
- var dn = (e, t, n) => t in e ? ln(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var it = (e, t, n) => dn(e, typeof t != "symbol" ? t + "" : t, n);
4
- import fe, { useMemo as ne, useState as Je, useCallback as me, useEffect as de, createContext as yt, useContext as St, useRef as ae, useReducer as fn, useLayoutEffect as pn, useDebugValue as gn } from "react";
5
- import { jsx as te } from "react/jsx-runtime";
6
- import { create as mn } from "mutative";
7
- import l from "zod";
8
- import { c as vt, g as ve } from "./genUuid-C12yFv3j.js";
9
- import hn from "lodash.set";
10
- import yn from "axios";
11
- const Sn = typeof window > "u", ct = {
12
- getItem: () => null,
13
- setItem: () => {
14
- },
15
- removeItem: () => {
16
- }
17
- };
18
- function vn(e) {
19
- return Sn ? ct : e === "local" ? localStorage : e === "session" ? sessionStorage : ct;
20
- }
21
- function Ze(e, t, n = "session") {
22
- const r = ne(() => vn(n), [n]), [s, o] = Je(() => {
23
- const g = r.getItem(e);
24
- if (g !== null)
25
- try {
26
- return JSON.parse(g);
27
- } catch (u) {
28
- console.error(`Error parsing stored value for key '${e}':`, u);
29
- }
30
- return typeof t == "function" ? t() : t ?? null;
31
- }), a = me(
32
- (g) => {
33
- if (o(g), g === null)
34
- r.removeItem(e);
35
- else
36
- try {
37
- r.setItem(e, JSON.stringify(g));
38
- } catch (u) {
39
- console.error(
40
- `Error saving state to storage for key '${e}':`,
41
- u
42
- );
43
- }
44
- },
45
- [e, r]
46
- ), d = me(() => {
47
- o(null), r.removeItem(e);
48
- }, [e, r]);
49
- return de(() => {
50
- const g = (u) => {
51
- u.key === e && u.newValue !== JSON.stringify(s) && o(u.newValue ? JSON.parse(u.newValue) : null);
52
- };
53
- return window.addEventListener("storage", g), () => {
54
- window.removeEventListener("storage", g);
55
- };
56
- }, [e, s]), [s, a, d];
57
- }
58
- const En = "@opencx/widget", Et = "2.6.0", bn = "module", wn = {
59
- access: "public"
60
- }, On = {
61
- clean: "rm -rf ./dist ./dist-embed",
62
- "clean:dist": "rm -rf ./dist ./dist-embed",
63
- prepublishOnly: "pnpm clean && pnpm test && pnpm batman",
64
- "build:lib": "vite build",
65
- dev: "vite -c vite.config.ts",
66
- "build:embed": "vite build -c vite.embed.config.ts",
67
- test: "vitest run",
68
- batman: "pnpm build:lib && pnpm build:embed",
69
- "test:watch": "vitest --watch",
70
- cs: "changeset",
71
- csv: "changeset version",
72
- csp: "changeset publish",
73
- "type-check": "tsc --noEmit",
74
- lint: "biome lint --fix",
75
- format: "biome format --fix"
76
- }, An = {
77
- "lucide-react": "^0.412.0",
78
- react: "^18.3.1",
79
- "rehype-raw": "^7.0.0"
80
- }, _n = {
81
- react: {
82
- optional: !0
83
- }
84
- }, Rn = {
85
- axios: "^1.7.5",
86
- zod: "^3.23.8"
87
- }, Tn = {
88
- "@radix-ui/react-avatar": "^1.1.0",
89
- "@radix-ui/react-dropdown-menu": "^2.1.4",
90
- "@radix-ui/react-slot": "^1.1.0",
91
- "@radix-ui/react-switch": "^1.1.0",
92
- "@radix-ui/react-tooltip": "^1.1.2",
93
- clsx: "^2.1.1",
94
- "date-fns": "^4.1.0",
95
- "framer-motion": "^11.3.30",
96
- "lodash.isequal": "^4.5.0",
97
- "lodash.set": "^4.3.2",
98
- "lucide-react": "^0.436.0",
99
- mutative: "^1.0.11",
100
- "react-dropzone": "^14.3.5",
101
- "react-hot-toast": "^2.4.1",
102
- tinycolor2: "^1.6.0",
103
- uuid: "^11.0.4",
104
- "whatwg-fetch": "^3.6.20",
105
- zod: "^3.23.8"
106
- }, Dn = {
107
- "@opencx/widget": {
108
- react: {
109
- optional: !0,
110
- dependencies: {
111
- "react-hot-toast": "^2.4.1",
112
- "react-markdown": "^9.0.1",
113
- "framer-motion": "^11.3.30",
114
- "date-fns": "^4.1.0"
115
- }
116
- }
117
- }
118
- }, Nn = {
119
- react: {
120
- "react-hot-toast": "^2.4.1",
121
- "react-markdown": "^9.0.1",
122
- "framer-motion": "^11.3.30",
123
- "date-fns": "^4.1.0"
124
- }
125
- }, Cn = [
126
- "dist",
127
- "dist-embed"
128
- ], xn = {
129
- url: "https://github.com/openchatai/widget/issues"
130
- }, Pn = {
131
- name: "openchatai",
132
- url: "https://github.com/openchatai"
133
- }, In = "./dist/index.js", jn = "./dist/index.js", Ln = "./dist/index.d.ts", kn = !1, Fn = {
134
- ".": {
135
- types: "./dist/index.d.ts",
136
- import: "./dist/index.js",
137
- require: "./dist/index.cjs"
138
- },
139
- "./basic": {
140
- types: "./dist/basic.d.ts",
141
- import: "./dist/basic.js",
142
- require: "./dist/basic.cjs"
143
- },
144
- "./react": {
145
- types: "./dist/react.d.ts",
146
- import: "./dist/react.js",
147
- require: "./dist/react.cjs"
148
- },
149
- "./package.json": "./package.json",
150
- "./dist/*.css": "./dist/*.css"
151
- }, Mn = {
152
- "@biomejs/biome": "1.9.4",
153
- "@changesets/cli": "^2.27.9",
154
- "@radix-ui/react-popover": "^1.1.2",
155
- "@tailwindcss/typography": "^0.5.15",
156
- "@testing-library/dom": "^10.4.0",
157
- "@testing-library/jest-dom": "^6.5.0",
158
- "@testing-library/react": "^16.0.1",
159
- "@types/lodash.debounce": "^4.0.9",
160
- "@types/lodash.isequal": "^4.5.8",
161
- "@types/lodash.set": "^4.3.9",
162
- "@types/node": "^20.14.8",
163
- "@types/react": "^18.3.4",
164
- "@types/react-dom": "^18.3.0",
165
- "@types/tinycolor2": "^1.4.6",
166
- "@uiw/react-iframe": "^1.0.3",
167
- "@vitejs/plugin-react": "^4.3.4",
168
- autoprefixer: "^10.4.20",
169
- axios: "^1.7.5",
170
- "class-variance-authority": "^0.7.0",
171
- jsdom: "^25.0.1",
172
- mutative: "^1.0.11",
173
- postcss: "^8.4.41",
174
- "postcss-prefix-selector": "^1.16.1",
175
- react: "^18.3.1",
176
- "react-dom": "^18.3.1",
177
- "react-markdown": "^9.0.1",
178
- "react-use": "^17.5.1",
179
- "rehype-raw": "^7.0.0",
180
- "remark-gfm": "^4.0.0",
181
- swr: "^2.2.5",
182
- "tailwind-merge": "^2.4.0",
183
- tailwindcss: "^3.4.6",
184
- "tailwindcss-animate": "^1.0.7",
185
- typescript: "^5.5.4",
186
- vite: "^5.4.2",
187
- "vite-plugin-dts": "4.0.3",
188
- "vite-plugin-externalize-deps": "^0.8.0",
189
- "vite-tsconfig-paths": "^5.0.1",
190
- vitest: "^2.0.5"
191
- }, Vn = {
192
- name: En,
193
- private: !1,
194
- version: Et,
195
- type: bn,
196
- publishConfig: wn,
197
- scripts: On,
198
- peerDependencies: An,
199
- peerDependenciesMeta: _n,
200
- optionalDependencies: Rn,
201
- dependencies: Tn,
202
- overrides: Dn,
203
- conditionalDependencies: Nn,
204
- files: Cn,
205
- bugs: xn,
206
- author: Pn,
207
- main: In,
208
- module: jn,
209
- types: Ln,
210
- sideEffects: kn,
211
- exports: Fn,
212
- devDependencies: Mn
213
- }, Un = "X-Bot-Token", Hn = "X-Widget-Version";
214
- function bt(e) {
215
- const t = ne(() => yn.create({
216
- baseURL: e.apiUrl,
217
- headers: {
218
- [Un]: e.botToken,
219
- [Hn]: Et,
220
- "X-Use-Guard": !0
221
- }
222
- }), [e]);
223
- return { apis: ne(
224
- () => ({
225
- createSession: (r) => {
226
- if (!r)
227
- throw new Error("Bot token is required");
228
- return t.post("/chat-session/" + r);
229
- },
230
- /**
231
- * get session data by id
232
- * @param sessionId
233
- */
234
- fetchSession: (r) => {
235
- if (!r)
236
- throw new Error("Session id is required");
237
- return t.get(`widget/session/${r}`);
238
- },
239
- fetchPreludeData: async () => (await t.get("/widget/prelude")).data,
240
- /**
241
- * get the organization office working hours.
242
- */
243
- getOfficeHours: () => t.get("/copilot/office-hours/public"),
244
- // TODO unify with history polling function
245
- fetchHistory: (r) => {
246
- if (!r)
247
- throw new Error("Session id is required");
248
- return t.get(
249
- `widget/session/history/${r}`
250
- );
251
- },
252
- /**
253
- * downvote a message
254
- * @param id
255
- * @returns
256
- * @deprecated use vote instead
257
- */
258
- downvote: (r) => t.delete(`/chat/vote/${r}`),
259
- /**
260
- * upvote a message
261
- * @param id
262
- * @returns
263
- * @deprecated use vote instead
264
- */
265
- upvote: (r) => t.post(`/chat/vote/${r}`),
266
- /**
267
- * given the userData object we will create or update the contact + get the related conversations/tickets/sessions
268
- */
269
- dumpContact: (r) => t.post("/widget/contact/upsert", r),
270
- /**
271
- * get the completions for the given input
272
- */
273
- getCompletions: (r) => t.post("/widget/chat/completions", { input: r }),
274
- /**
275
- * @param file
276
- * @param options
277
- */
278
- uploadFile: async (r, s) => {
279
- const o = new FormData();
280
- return o.append("file", r.file), t.post(`/widget/upload?fileId=${r.id}`, o, {
281
- headers: {
282
- "Content-Type": "multipart/form-data"
283
- },
284
- ...s
285
- });
286
- },
287
- getHistoryPooling: async ({
288
- lastMessageTimestamp: r,
289
- sessionId: s
290
- }) => {
291
- const o = new URLSearchParams();
292
- return o.append("lastMessageTimestamp", r.toString()), t.get(`/widget/session/history/${s}/?${o.toString()}`);
293
- },
294
- /**
295
- * send a message to the chat
296
- * @param message
297
- */
298
- sendMessage: async (r) => t.post("widget/chat/send", r),
299
- /**
300
- * vote on a message
301
- * @param data
302
- */
303
- vote: (r) => t.post("/widget/chat/vote", r)
304
- }),
305
- [t]
306
- ), options: e };
307
- }
308
- function Ne(e) {
309
- const t = yt({});
310
- return [() => {
311
- const r = St(t);
312
- if (r === void 0)
313
- throw new Error("useSafeContext must be used within a Provider");
314
- return r;
315
- }, t.Provider];
316
- }
317
- const Gn = {
318
- ok: "حسنا",
319
- yes: "نعم",
320
- no: "لا",
321
- agree: "موافق",
322
- cancel: "إلغاء",
323
- "yes-exit": "نعم، اخرج",
324
- "yes-reset": "نعم، إعادة تعيين",
325
- "no-cancel": "لا، إلغاء",
326
- "are-you-sure": "هل أنت متأكد؟",
327
- recording: "تسجيل",
328
- "thank-you": "شكرا",
329
- "sorry-try-again": "عذرا، حاول مرة أخرى",
330
- "error-occurred": "حدث خطأ",
331
- "please-try-again": "يرجى المحاولة مرة أخرى",
332
- "write-a-message": "اكتب رسالة...",
333
- "send-message": "إرسال رسالة",
334
- connected: "متصل",
335
- connecting: "جاري الاتصال",
336
- reconnecting: "جاري إعادة الاتصال",
337
- reconnected: "تم إعادة الاتصال",
338
- disconnecting: "جاري قطع الاتصال",
339
- disconnected: "قطع الاتصال",
340
- error: "خطأ",
341
- "persist-session": "حفظ الجلسة",
342
- settings: "إعدادات",
343
- close: "إغلاق",
344
- help: "مساعدة",
345
- chat: "محادثة",
346
- send: "إرسال",
347
- copy: "نسخ",
348
- copied: "تم النسخ",
349
- "sound-effects": "التاثيرات الصوتية",
350
- language: "اللغة",
351
- select: "اختر",
352
- agent: "الوكيل",
353
- user: "المستخدم",
354
- bot: "البوت",
355
- "reset-conversation-confirm": "هل أنت متأكد من أنك تريد إعادة تعيين المحادثة؟",
356
- "close-widget": "إغلاق الودجة",
357
- "got-any-questions": "هل لديك أي أسئلة؟ تحدث معنا!",
358
- "typical-response-time": "عادة ما نرد في أقل من دقيقة واحدة",
359
- "session-closed-lead": "تم حل مشكلتك!",
360
- exit: "خروج",
361
- "create-new-ticket": "إنشاء تذكرة جديدة",
362
- "reset-conversation": "إعادة تعيين المحادثة",
363
- "welcome-title": "مرحبًا بك في دردشة الدعم الخاصة بنا",
364
- "welcome-description": "نحن هنا للمساعدة! ابدأ محادثة وسنرد عليك في أقرب وقت ممكن.",
365
- "your-name": "اسمك",
366
- "your-email": "عنوان بريدك الإلكتروني",
367
- "start-chat": "تحدث إلى الدعم",
368
- "starting-chat": "جاري الاتصال...",
369
- "hello-greeting": "مرحبًا! كيف يمكننا مساعدتك اليوم؟"
370
- }, zn = {
371
- ok: "OK",
372
- yes: "Ja",
373
- no: "Nein",
374
- agree: "Zustimmen",
375
- cancel: "Stornieren",
376
- "yes-exit": "Ja, beenden",
377
- "yes-reset": "Ja, zurücksetzen",
378
- "no-cancel": "Nein, abbrechen",
379
- "are-you-sure": "Sind Sie sicher?",
380
- recording: "Aufnahme läuft",
381
- "thank-you": "Vielen Dank",
382
- "sorry-try-again": "Entschuldigung, bitte versuchen Sie es erneut",
383
- "error-occurred": "Ein Fehler ist aufgetreten",
384
- "please-try-again": "Bitte versuchen Sie es erneut",
385
- "write-a-message": "Nachricht schreiben...",
386
- "send-message": "Nachricht senden",
387
- connected: "Verbunden",
388
- connecting: "Verbindung wird hergestellt",
389
- reconnecting: "Verbindung wird wiederhergestellt",
390
- reconnected: "Wieder verbunden",
391
- disconnecting: "Verbindung wird getrennt",
392
- disconnected: "Verbindung getrennt",
393
- error: "Fehler",
394
- "persist-session": "Sitzung beibehalten",
395
- settings: "Einstellungen",
396
- close: "Schließen",
397
- help: "Hilfe",
398
- chat: "Chat",
399
- send: "Senden",
400
- copy: "Kopieren",
401
- copied: "Kopiert",
402
- "sound-effects": "Soundeffekte",
403
- language: "Sprache",
404
- select: "Auswählen",
405
- agent: "Agent",
406
- user: "Benutzer",
407
- bot: "Bot",
408
- "got-any-questions": "Haben Sie Fragen? Chatten Sie mit uns!",
409
- "typical-response-time": "Üblicherweise antworten wir in weniger als 1 Minute",
410
- "reset-conversation-confirm": "Möchten Sie die Konversation wirklich zurücksetzen?",
411
- "close-widget": "Widget schließen",
412
- "session-closed-lead": "Ihr Problem wurde gelöst!",
413
- "create-new-ticket": "Neues Ticket erstellen",
414
- exit: "Beenden",
415
- "reset-conversation": "Konversation zurücksetzen",
416
- "welcome-title": "Willkommen in unserem Support-Chat",
417
- "welcome-description": "Wir sind hier, um zu helfen! Beginnen Sie ein Gespräch und wir werden so schnell wie möglich antworten.",
418
- "your-name": "Ihr Name",
419
- "your-email": "Ihre E-Mail-Adresse",
420
- "start-chat": "Mit dem Support sprechen",
421
- "starting-chat": "Verbindung wird hergestellt...",
422
- "hello-greeting": "Hallo! Wie können wir Ihnen heute helfen?"
423
- }, Yn = {
424
- ok: "OK",
425
- yes: "Yes",
426
- no: "No",
427
- agree: "Agree",
428
- cancel: "Cancel",
429
- "yes-exit": "Yes, exit",
430
- "yes-reset": "Yes, reset",
431
- "no-cancel": "No, cancel",
432
- "are-you-sure": "Are you sure?",
433
- recording: "Recording...",
434
- "thank-you": "Thank you",
435
- "sorry-try-again": "Sorry, please try again",
436
- "error-occurred": "An error occurred",
437
- "please-try-again": "Please try again",
438
- "write-a-message": "Write a message...",
439
- "send-message": "Send message",
440
- connected: "Connected",
441
- connecting: "Connecting",
442
- reconnecting: "Reconnecting",
443
- reconnected: "Reconnected",
444
- disconnecting: "Disconnecting",
445
- disconnected: "Disconnected",
446
- error: "Error",
447
- "persist-session": "Persist session",
448
- settings: "Settings",
449
- close: "Close",
450
- help: "Help",
451
- chat: "Chat",
452
- send: "Send",
453
- copy: "Copy",
454
- copied: "Copied",
455
- "sound-effects": "Sound effects",
456
- language: "Language",
457
- select: "Select",
458
- agent: "Agent",
459
- user: "User",
460
- bot: "Bot",
461
- "reset-conversation-confirm": "Are you sure you want to reset the conversation?",
462
- "close-widget": "Close widget",
463
- "got-any-questions": "Got any questions? Chat with us!",
464
- "typical-response-time": "Typically respond in less than 1 minute",
465
- "session-closed-lead": "Your issue has been resolved!",
466
- "create-new-ticket": "Create new ticket",
467
- exit: "Exit",
468
- "reset-conversation": "Reset conversation",
469
- "welcome-title": "Welcome to our support chat",
470
- "welcome-description": "We're here to help! Start a conversation and we'll get back to you as soon as possible.",
471
- "your-name": "Your name",
472
- "your-email": "Your email address",
473
- "start-chat": "Talk to support",
474
- "starting-chat": "Connecting...",
475
- "hello-greeting": "Hi there!"
476
- }, qn = {
477
- ok: "D'accord",
478
- yes: "Oui",
479
- no: "Non",
480
- agree: "Accepter",
481
- cancel: "Annuler",
482
- "yes-exit": "Oui, quitter",
483
- "yes-reset": "Oui, réinitialiser",
484
- "no-cancel": "Non, annuler",
485
- "are-you-sure": "Êtes-vous sûr ?",
486
- recording: "Enregistrement...",
487
- "thank-you": "Merci",
488
- "sorry-try-again": "Désolé, veuillez réessayer",
489
- "error-occurred": "Une erreur s'est produite",
490
- "please-try-again": "Veuillez réessayer",
491
- "write-a-message": "Écrivez un message...",
492
- "send-message": "Envoyer le message",
493
- connected: "Connecté",
494
- connecting: "Connexion en cours",
495
- reconnecting: "Reconnexion en cours",
496
- reconnected: "Reconnecté",
497
- disconnecting: "Déconnexion en cours",
498
- disconnected: "Déconnecté",
499
- error: "Erreur",
500
- "persist-session": "Conserver la session",
501
- settings: "Paramètres",
502
- close: "Fermer",
503
- help: "Aide",
504
- chat: "Chat",
505
- send: "Envoyer",
506
- copy: "Copier",
507
- copied: "Copié",
508
- "sound-effects": "Effets sonores",
509
- language: "Langue",
510
- select: "Sélectionner",
511
- agent: "Agent",
512
- user: "Utilisateur",
513
- bot: "Bot",
514
- "reset-conversation-confirm": "Êtes-vous sûr de vouloir réinitialiser la conversation ?",
515
- "close-widget": "Fermer le widget",
516
- "got-any-questions": "Vous avez des questions ? Chattez avec nous !",
517
- "typical-response-time": "Nous répondons généralement en moins d'une minute",
518
- "session-closed-lead": "Votre problème a été résolu !",
519
- "create-new-ticket": "Créer un nouveau ticket",
520
- exit: "Sortie",
521
- "reset-conversation": "Réinitialiser la conversation",
522
- "welcome-title": "Bienvenue dans notre chat de support",
523
- "welcome-description": "Nous sommes là pour vous aider ! Commencez une conversation et nous vous répondrons dès que possible.",
524
- "your-name": "Votre nom",
525
- "your-email": "Votre adresse e-mail",
526
- "start-chat": "Parler au support",
527
- "starting-chat": "Connexion...",
528
- "hello-greeting": "Bonjour ! Comment pouvons-nous vous aider aujourd'hui ?"
529
- }, Bn = {
530
- ok: "OK",
531
- yes: "Ja",
532
- no: "Nee",
533
- agree: "Akkoord",
534
- cancel: "Annuleren",
535
- "yes-exit": "Ja, afsluiten",
536
- "yes-reset": "Ja, resetten",
537
- "no-cancel": "Nee, annuleren",
538
- "are-you-sure": "Weet u het zeker?",
539
- recording: "Opname...",
540
- "thank-you": "Dank u",
541
- "sorry-try-again": "Sorry, probeer het opnieuw",
542
- "error-occurred": "Er is een fout opgetreden",
543
- "please-try-again": "Probeer het opnieuw",
544
- "write-a-message": "Schrijf een bericht...",
545
- "send-message": "Bericht verzenden",
546
- connected: "Verbonden",
547
- connecting: "Verbinding maken",
548
- reconnecting: "Opnieuw verbinding maken",
549
- reconnected: "Opnieuw verbonden",
550
- disconnecting: "Verbinding verbreken",
551
- disconnected: "Verbinding verbroken",
552
- error: "Fout",
553
- "persist-session": "Sessie behouden",
554
- settings: "Instellingen",
555
- close: "Sluiten",
556
- help: "Help",
557
- chat: "Chat",
558
- send: "Verzenden",
559
- copy: "Kopiëren",
560
- copied: "Gekopieerd",
561
- "sound-effects": "Geluidseffecten",
562
- language: "Taal",
563
- select: "Selecteren",
564
- agent: "Agent",
565
- user: "Gebruiker",
566
- bot: "Bot",
567
- "reset-conversation-confirm": "Weet u zeker dat u het gesprek wilt resetten?",
568
- "close-widget": "Widget sluiten",
569
- "got-any-questions": "Heeft u vragen? Chat met ons!",
570
- "typical-response-time": "We reageren doorgaans binnen 1 minuut",
571
- "session-closed-lead": "Uw probleem is opgelost!",
572
- "create-new-ticket": "Nieuw ticket aanmaken",
573
- exit: "Afsluiten",
574
- "reset-conversation": "Gesprek resetten",
575
- "welcome-title": "Welkom bij onze supportchat",
576
- "welcome-description": "We zijn hier om te helpen! Begin een gesprek en we nemen zo snel mogelijk contact met u op.",
577
- "your-name": "Uw naam",
578
- "your-email": "Uw e-mailadres",
579
- "start-chat": "Praat met ondersteuning",
580
- "starting-chat": "Verbinding maken...",
581
- "hello-greeting": "Hallo! Hoe kunnen we u vandaag helpen?"
582
- }, Xn = {
583
- ok: "OK",
584
- yes: "Sim",
585
- no: "Não",
586
- agree: "Concordo",
587
- cancel: "Cancelar",
588
- "yes-exit": "Sim, sair",
589
- "yes-reset": "Sim, redefinir",
590
- "no-cancel": "Não, cancelar",
591
- "are-you-sure": "Você tem certeza?",
592
- recording: "Gravando...",
593
- "thank-you": "Obrigado",
594
- "sorry-try-again": "Desculpe, tente novamente",
595
- "error-occurred": "Ocorreu um erro",
596
- "please-try-again": "Por favor, tente novamente",
597
- "write-a-message": "Escreva uma mensagem...",
598
- "send-message": "Enviar mensagem",
599
- connected: "Conectado",
600
- connecting: "Conectando",
601
- reconnecting: "Reconectando",
602
- reconnected: "Reconectado",
603
- disconnecting: "Desconectando",
604
- disconnected: "Desconectado",
605
- error: "Erro",
606
- "persist-session": "Persistir sessão",
607
- settings: "Configurações",
608
- close: "Fechar",
609
- help: "Ajuda",
610
- chat: "Bate-papo",
611
- send: "Enviar",
612
- copy: "Copiar",
613
- copied: "Copiado",
614
- "sound-effects": "Efeitos sonoros",
615
- language: "Idioma",
616
- select: "Selecionar",
617
- agent: "Agente",
618
- user: "Usuário",
619
- bot: "Bot",
620
- "reset-conversation-confirm": "Você tem certeza de que deseja redefinir a conversa?",
621
- "close-widget": "Fechar widget",
622
- "got-any-questions": "Tem alguma dúvida? Converse conosco!",
623
- "typical-response-time": "Geralmente respondemos em menos de 1 minuto",
624
- "session-closed-lead": "Seu problema foi resolvido!",
625
- "create-new-ticket": "Criar novo ticket",
626
- exit: "Sair",
627
- "reset-conversation": "Redefinir conversa",
628
- "welcome-title": "Bem-vindo ao nosso chat de suporte",
629
- "welcome-description": "Estamos aqui para ajudar! Inicie uma conversa e responderemos o mais rápido possível.",
630
- "your-name": "Seu nome",
631
- "your-email": "Seu endereço de email",
632
- "start-chat": "Falar com o suporte",
633
- "starting-chat": "Conectando...",
634
- "hello-greeting": "Olá! Como podemos ajudar você hoje?"
635
- }, Qn = {
636
- en: Yn,
637
- ar: Gn,
638
- nl: Bn,
639
- fr: qn,
640
- de: zn,
641
- pt: Xn
642
- };
643
- function Wn(e, t) {
644
- const n = Qn[t];
645
- return n && n[e] || "";
646
- }
647
- const [Es, Kn] = Ne();
648
- function wt({ children: e }) {
649
- const t = le();
650
- return /* @__PURE__ */ te(
651
- Kn,
652
- {
653
- value: {
654
- get: (n, r) => Wn(n, t.language ?? "en") + (r ?? ""),
655
- lang: t.language
656
- },
657
- children: e
658
- }
659
- );
660
- }
661
- class Jn {
662
- constructor(t) {
663
- it(this, "components", [
664
- {
665
- key: "FALLBACK",
666
- component: (t) => "fallback"
667
- },
668
- {
669
- key: "LOADING",
670
- component: (t) => "loading"
671
- }
672
- ]);
673
- const { components: n } = t;
674
- if (n && n.forEach((r) => this.register(r)), this.components.length === 0)
675
- throw new Error("No components registered");
676
- if (!this.get("FALLBACK"))
677
- throw new Error("No fallback component registered");
678
- }
679
- register(t) {
680
- const n = this.components.findIndex((r) => r.key === t.key);
681
- return n !== -1 ? this.components[n] = t : this.components.push(t), this;
682
- }
683
- get(t) {
684
- const n = this.components.find(
685
- (r) => r.key.toUpperCase() === t.toUpperCase()
686
- );
687
- return n || null;
688
- }
689
- getOrFallback(t) {
690
- return t ? this.get(t) || this.get("FALLBACK") : this.get("FALLBACK");
691
- }
692
- getComponent(t, n) {
693
- var r;
694
- return n ? this.getOrFallback(t).component : (r = this.get(t)) == null ? void 0 : r.component;
695
- }
696
- }
697
- const Zn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABlCAYAAAC7vkbxAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAACd2SURBVHgB7X15lGZHdd+99b6vu2dfNNIghIgEYonELhkQIGDACB8WOUAsMBgbjA9yYiIHEjA2OO4Tzsk5JCeHBIEd2+AQUBJHAmFAQiBrQ4A2tDHDKEH7vs1oZnqme7q/5dXNrap7a3nf6+nu6ZmR/qD6vP7eV69evXp3+d2l6r0P4FflV+VXZf6C8DQuRGS+dt99Yx/7zuPrBp3hJgN4VLcDGwDN+g7iKiJYwTfQ5ZYVIFogHBLCXF3XM2RpL3/ZXVewq7N/sPN5R6/f9V8/+JLeFsQhPI3L04ohzAB826U3rLntYTqOiX/KjtnBS7n6ZCbyc5FgIxmzlofcWXyPlrj9LN/kk9z3I7y/rVuZX6wbN7etm4V737fzlbsnJ5mRT6PylDPkAqLqC1/dvu7W/q4XD2vaYhBfBmRewJTcjEQrWfY7rAnoyWbceM3Sx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AAAAAElFTkSuQmCC", $n = {
698
- primaryColor: "hsl(0,0%,0%)",
699
- triggerOffset: "20px"
700
- };
701
- function er(e) {
702
- return ne(() => {
703
- var s, o, a, d;
704
- const t = {
705
- messageArrived: "https://cloud.opencopilot.so/sfx/notification3.mp3",
706
- ...e.soundEffectFiles
707
- }, n = Object.assign({}, $n, e.theme ?? {}), r = {
708
- id: "555",
709
- is_ai: !0,
710
- profile_picture: ((s = e.bot) == null ? void 0 : s.avatarUrl) || Zn,
711
- name: ((o = e.bot) == null ? void 0 : o.name) || "Bot"
712
- };
713
- return {
714
- ...e,
715
- bot: r,
716
- apiUrl: e.apiUrl ?? "https://api-v2.opencopilot.so/backend",
717
- socketUrl: e.socketUrl ?? "https://api-v2.opencopilot.so",
718
- language: e.language ?? nr,
719
- botToken: e.token,
720
- headers: e.headers ?? {},
721
- pathParams: e.pathParams ?? {},
722
- queryParams: e.queryParams ?? {},
723
- user: e.user ?? {},
724
- theme: n,
725
- soundEffectFiles: t,
726
- collectUserData: e.collectUserData ?? !1,
727
- defaultSettings: {
728
- persistSession: ((a = e.settings) == null ? void 0 : a.persistSession) ?? !1,
729
- useSoundEffects: ((d = e.settings) == null ? void 0 : d.useSoundEffects) ?? !1
730
- }
731
- };
732
- }, [e]);
733
- }
734
- const [le, tr] = Ne(), nr = "en";
735
- function rr({
736
- children: e,
737
- data: t
738
- }) {
739
- const n = ne(
740
- () => new Jn({
741
- components: t.components
742
- }),
743
- [t]
744
- ), r = er(t), s = bt({
745
- apiUrl: r.apiUrl,
746
- botToken: r.token
747
- }), [o, a] = Ze(
748
- "open_settings",
749
- r.defaultSettings,
750
- "local"
751
- );
752
- return /* @__PURE__ */ te(
753
- tr,
754
- {
755
- value: { ...r, http: s, componentStore: n, widgetSettings: o, setSettings: (g) => {
756
- const u = Object.assign(
757
- {},
758
- r.defaultSettings,
759
- o,
760
- g
761
- );
762
- a(u);
763
- } },
764
- children: /* @__PURE__ */ te(wt, { children: e })
765
- }
766
- );
767
- }
768
- var bs = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
769
- function ws(e) {
770
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
771
- }
772
- function sr(e) {
773
- if (e.__esModule) return e;
774
- var t = e.default;
775
- if (typeof t == "function") {
776
- var n = function r() {
777
- return this instanceof r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
778
- };
779
- n.prototype = t.prototype;
780
- } else n = {};
781
- return Object.defineProperty(n, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
782
- var s = Object.getOwnPropertyDescriptor(e, r);
783
- Object.defineProperty(n, r, s.get ? s : {
784
- enumerable: !0,
785
- get: function() {
786
- return e[r];
787
- }
788
- });
789
- }), n;
790
- }
791
- var Ot = {}, ze = function(e, t) {
792
- return ze = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
793
- n.__proto__ = r;
794
- } || function(n, r) {
795
- for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (n[s] = r[s]);
796
- }, ze(e, t);
797
- };
798
- function At(e, t) {
799
- if (typeof t != "function" && t !== null)
800
- throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
801
- ze(e, t);
802
- function n() {
803
- this.constructor = e;
804
- }
805
- e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
806
- }
807
- var Te = function() {
808
- return Te = Object.assign || function(t) {
809
- for (var n, r = 1, s = arguments.length; r < s; r++) {
810
- n = arguments[r];
811
- for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
812
- }
813
- return t;
814
- }, Te.apply(this, arguments);
815
- };
816
- function _t(e, t) {
817
- var n = {};
818
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
819
- if (e != null && typeof Object.getOwnPropertySymbols == "function")
820
- for (var s = 0, r = Object.getOwnPropertySymbols(e); s < r.length; s++)
821
- t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[s]) && (n[r[s]] = e[r[s]]);
822
- return n;
823
- }
824
- function Rt(e, t, n, r) {
825
- var s = arguments.length, o = s < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, a;
826
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") o = Reflect.decorate(e, t, n, r);
827
- else for (var d = e.length - 1; d >= 0; d--) (a = e[d]) && (o = (s < 3 ? a(o) : s > 3 ? a(t, n, o) : a(t, n)) || o);
828
- return s > 3 && o && Object.defineProperty(t, n, o), o;
829
- }
830
- function Tt(e, t) {
831
- return function(n, r) {
832
- t(n, r, e);
833
- };
834
- }
835
- function Dt(e, t, n, r, s, o) {
836
- function a(h) {
837
- if (h !== void 0 && typeof h != "function") throw new TypeError("Function expected");
838
- return h;
839
- }
840
- for (var d = r.kind, g = d === "getter" ? "get" : d === "setter" ? "set" : "value", u = !t && e ? r.static ? e : e.prototype : null, c = t || (u ? Object.getOwnPropertyDescriptor(u, r.name) : {}), i, m = !1, p = n.length - 1; p >= 0; p--) {
841
- var y = {};
842
- for (var f in r) y[f] = f === "access" ? {} : r[f];
843
- for (var f in r.access) y.access[f] = r.access[f];
844
- y.addInitializer = function(h) {
845
- if (m) throw new TypeError("Cannot add initializers after decoration has completed");
846
- o.push(a(h || null));
847
- };
848
- var v = (0, n[p])(d === "accessor" ? { get: c.get, set: c.set } : c[g], y);
849
- if (d === "accessor") {
850
- if (v === void 0) continue;
851
- if (v === null || typeof v != "object") throw new TypeError("Object expected");
852
- (i = a(v.get)) && (c.get = i), (i = a(v.set)) && (c.set = i), (i = a(v.init)) && s.unshift(i);
853
- } else (i = a(v)) && (d === "field" ? s.unshift(i) : c[g] = i);
854
- }
855
- u && Object.defineProperty(u, r.name, c), m = !0;
856
- }
857
- function Nt(e, t, n) {
858
- for (var r = arguments.length > 2, s = 0; s < t.length; s++)
859
- n = r ? t[s].call(e, n) : t[s].call(e);
860
- return r ? n : void 0;
861
- }
862
- function Ct(e) {
863
- return typeof e == "symbol" ? e : "".concat(e);
864
- }
865
- function xt(e, t, n) {
866
- return typeof t == "symbol" && (t = t.description ? "[".concat(t.description, "]") : ""), Object.defineProperty(e, "name", { configurable: !0, value: n ? "".concat(n, " ", t) : t });
867
- }
868
- function Pt(e, t) {
869
- if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
870
- }
871
- function It(e, t, n, r) {
872
- function s(o) {
873
- return o instanceof n ? o : new n(function(a) {
874
- a(o);
875
- });
876
- }
877
- return new (n || (n = Promise))(function(o, a) {
878
- function d(c) {
879
- try {
880
- u(r.next(c));
881
- } catch (i) {
882
- a(i);
883
- }
884
- }
885
- function g(c) {
886
- try {
887
- u(r.throw(c));
888
- } catch (i) {
889
- a(i);
890
- }
891
- }
892
- function u(c) {
893
- c.done ? o(c.value) : s(c.value).then(d, g);
894
- }
895
- u((r = r.apply(e, t || [])).next());
896
- });
897
- }
898
- function jt(e, t) {
899
- var n = { label: 0, sent: function() {
900
- if (o[0] & 1) throw o[1];
901
- return o[1];
902
- }, trys: [], ops: [] }, r, s, o, a = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
903
- return a.next = d(0), a.throw = d(1), a.return = d(2), typeof Symbol == "function" && (a[Symbol.iterator] = function() {
904
- return this;
905
- }), a;
906
- function d(u) {
907
- return function(c) {
908
- return g([u, c]);
909
- };
910
- }
911
- function g(u) {
912
- if (r) throw new TypeError("Generator is already executing.");
913
- for (; a && (a = 0, u[0] && (n = 0)), n; ) try {
914
- if (r = 1, s && (o = u[0] & 2 ? s.return : u[0] ? s.throw || ((o = s.return) && o.call(s), 0) : s.next) && !(o = o.call(s, u[1])).done) return o;
915
- switch (s = 0, o && (u = [u[0] & 2, o.value]), u[0]) {
916
- case 0:
917
- case 1:
918
- o = u;
919
- break;
920
- case 4:
921
- return n.label++, { value: u[1], done: !1 };
922
- case 5:
923
- n.label++, s = u[1], u = [0];
924
- continue;
925
- case 7:
926
- u = n.ops.pop(), n.trys.pop();
927
- continue;
928
- default:
929
- if (o = n.trys, !(o = o.length > 0 && o[o.length - 1]) && (u[0] === 6 || u[0] === 2)) {
930
- n = 0;
931
- continue;
932
- }
933
- if (u[0] === 3 && (!o || u[1] > o[0] && u[1] < o[3])) {
934
- n.label = u[1];
935
- break;
936
- }
937
- if (u[0] === 6 && n.label < o[1]) {
938
- n.label = o[1], o = u;
939
- break;
940
- }
941
- if (o && n.label < o[2]) {
942
- n.label = o[2], n.ops.push(u);
943
- break;
944
- }
945
- o[2] && n.ops.pop(), n.trys.pop();
946
- continue;
947
- }
948
- u = t.call(e, n);
949
- } catch (c) {
950
- u = [6, c], s = 0;
951
- } finally {
952
- r = o = 0;
953
- }
954
- if (u[0] & 5) throw u[1];
955
- return { value: u[0] ? u[1] : void 0, done: !0 };
956
- }
957
- }
958
- var Ce = Object.create ? function(e, t, n, r) {
959
- r === void 0 && (r = n);
960
- var s = Object.getOwnPropertyDescriptor(t, n);
961
- (!s || ("get" in s ? !t.__esModule : s.writable || s.configurable)) && (s = { enumerable: !0, get: function() {
962
- return t[n];
963
- } }), Object.defineProperty(e, r, s);
964
- } : function(e, t, n, r) {
965
- r === void 0 && (r = n), e[r] = t[n];
966
- };
967
- function Lt(e, t) {
968
- for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && Ce(t, e, n);
969
- }
970
- function De(e) {
971
- var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
972
- if (n) return n.call(e);
973
- if (e && typeof e.length == "number") return {
974
- next: function() {
975
- return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e };
976
- }
977
- };
978
- throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
979
- }
980
- function $e(e, t) {
981
- var n = typeof Symbol == "function" && e[Symbol.iterator];
982
- if (!n) return e;
983
- var r = n.call(e), s, o = [], a;
984
- try {
985
- for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; ) o.push(s.value);
986
- } catch (d) {
987
- a = { error: d };
988
- } finally {
989
- try {
990
- s && !s.done && (n = r.return) && n.call(r);
991
- } finally {
992
- if (a) throw a.error;
993
- }
994
- }
995
- return o;
996
- }
997
- function kt() {
998
- for (var e = [], t = 0; t < arguments.length; t++)
999
- e = e.concat($e(arguments[t]));
1000
- return e;
1001
- }
1002
- function Ft() {
1003
- for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
1004
- for (var r = Array(e), s = 0, t = 0; t < n; t++)
1005
- for (var o = arguments[t], a = 0, d = o.length; a < d; a++, s++)
1006
- r[s] = o[a];
1007
- return r;
1008
- }
1009
- function Mt(e, t, n) {
1010
- if (n || arguments.length === 2) for (var r = 0, s = t.length, o; r < s; r++)
1011
- (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
1012
- return e.concat(o || Array.prototype.slice.call(t));
1013
- }
1014
- function he(e) {
1015
- return this instanceof he ? (this.v = e, this) : new he(e);
1016
- }
1017
- function Vt(e, t, n) {
1018
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1019
- var r = n.apply(e, t || []), s, o = [];
1020
- return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), d("next"), d("throw"), d("return", a), s[Symbol.asyncIterator] = function() {
1021
- return this;
1022
- }, s;
1023
- function a(p) {
1024
- return function(y) {
1025
- return Promise.resolve(y).then(p, i);
1026
- };
1027
- }
1028
- function d(p, y) {
1029
- r[p] && (s[p] = function(f) {
1030
- return new Promise(function(v, h) {
1031
- o.push([p, f, v, h]) > 1 || g(p, f);
1032
- });
1033
- }, y && (s[p] = y(s[p])));
1034
- }
1035
- function g(p, y) {
1036
- try {
1037
- u(r[p](y));
1038
- } catch (f) {
1039
- m(o[0][3], f);
1040
- }
1041
- }
1042
- function u(p) {
1043
- p.value instanceof he ? Promise.resolve(p.value.v).then(c, i) : m(o[0][2], p);
1044
- }
1045
- function c(p) {
1046
- g("next", p);
1047
- }
1048
- function i(p) {
1049
- g("throw", p);
1050
- }
1051
- function m(p, y) {
1052
- p(y), o.shift(), o.length && g(o[0][0], o[0][1]);
1053
- }
1054
- }
1055
- function Ut(e) {
1056
- var t, n;
1057
- return t = {}, r("next"), r("throw", function(s) {
1058
- throw s;
1059
- }), r("return"), t[Symbol.iterator] = function() {
1060
- return this;
1061
- }, t;
1062
- function r(s, o) {
1063
- t[s] = e[s] ? function(a) {
1064
- return (n = !n) ? { value: he(e[s](a)), done: !1 } : o ? o(a) : a;
1065
- } : o;
1066
- }
1067
- }
1068
- function Ht(e) {
1069
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1070
- var t = e[Symbol.asyncIterator], n;
1071
- return t ? t.call(e) : (e = typeof De == "function" ? De(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
1072
- return this;
1073
- }, n);
1074
- function r(o) {
1075
- n[o] = e[o] && function(a) {
1076
- return new Promise(function(d, g) {
1077
- a = e[o](a), s(d, g, a.done, a.value);
1078
- });
1079
- };
1080
- }
1081
- function s(o, a, d, g) {
1082
- Promise.resolve(g).then(function(u) {
1083
- o({ value: u, done: d });
1084
- }, a);
1085
- }
1086
- }
1087
- function Gt(e, t) {
1088
- return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e;
1089
- }
1090
- var or = Object.create ? function(e, t) {
1091
- Object.defineProperty(e, "default", { enumerable: !0, value: t });
1092
- } : function(e, t) {
1093
- e.default = t;
1094
- };
1095
- function zt(e) {
1096
- if (e && e.__esModule) return e;
1097
- var t = {};
1098
- if (e != null) for (var n in e) n !== "default" && Object.prototype.hasOwnProperty.call(e, n) && Ce(t, e, n);
1099
- return or(t, e), t;
1100
- }
1101
- function Yt(e) {
1102
- return e && e.__esModule ? e : { default: e };
1103
- }
1104
- function qt(e, t, n, r) {
1105
- if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
1106
- 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");
1107
- return n === "m" ? r : n === "a" ? r.call(e) : r ? r.value : t.get(e);
1108
- }
1109
- function Bt(e, t, n, r, s) {
1110
- if (r === "m") throw new TypeError("Private method is not writable");
1111
- if (r === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
1112
- 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");
1113
- return r === "a" ? s.call(e, n) : s ? s.value = n : t.set(e, n), n;
1114
- }
1115
- function Xt(e, t) {
1116
- if (t === null || typeof t != "object" && typeof t != "function") throw new TypeError("Cannot use 'in' operator on non-object");
1117
- return typeof e == "function" ? t === e : e.has(t);
1118
- }
1119
- function Qt(e, t, n) {
1120
- if (t != null) {
1121
- if (typeof t != "object" && typeof t != "function") throw new TypeError("Object expected.");
1122
- var r, s;
1123
- if (n) {
1124
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
1125
- r = t[Symbol.asyncDispose];
1126
- }
1127
- if (r === void 0) {
1128
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
1129
- r = t[Symbol.dispose], n && (s = r);
1130
- }
1131
- if (typeof r != "function") throw new TypeError("Object not disposable.");
1132
- s && (r = function() {
1133
- try {
1134
- s.call(this);
1135
- } catch (o) {
1136
- return Promise.reject(o);
1137
- }
1138
- }), e.stack.push({ value: t, dispose: r, async: n });
1139
- } else n && e.stack.push({ async: !0 });
1140
- return t;
1141
- }
1142
- var ar = typeof SuppressedError == "function" ? SuppressedError : function(e, t, n) {
1143
- var r = new Error(n);
1144
- return r.name = "SuppressedError", r.error = e, r.suppressed = t, r;
1145
- };
1146
- function Wt(e) {
1147
- function t(o) {
1148
- e.error = e.hasError ? new ar(o, e.error, "An error was suppressed during disposal.") : o, e.hasError = !0;
1149
- }
1150
- var n, r = 0;
1151
- function s() {
1152
- for (; n = e.stack.pop(); )
1153
- try {
1154
- if (!n.async && r === 1) return r = 0, e.stack.push(n), Promise.resolve().then(s);
1155
- if (n.dispose) {
1156
- var o = n.dispose.call(n.value);
1157
- if (n.async) return r |= 2, Promise.resolve(o).then(s, function(a) {
1158
- return t(a), s();
1159
- });
1160
- } else r |= 1;
1161
- } catch (a) {
1162
- t(a);
1163
- }
1164
- if (r === 1) return e.hasError ? Promise.reject(e.error) : Promise.resolve();
1165
- if (e.hasError) throw e.error;
1166
- }
1167
- return s();
1168
- }
1169
- function Kt(e, t) {
1170
- return typeof e == "string" && /^\.\.?\//.test(e) ? e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(n, r, s, o, a) {
1171
- return r ? t ? ".jsx" : ".js" : s && (!o || !a) ? n : s + o + "." + a.toLowerCase() + "js";
1172
- }) : e;
1173
- }
1174
- const ir = {
1175
- __extends: At,
1176
- __assign: Te,
1177
- __rest: _t,
1178
- __decorate: Rt,
1179
- __param: Tt,
1180
- __esDecorate: Dt,
1181
- __runInitializers: Nt,
1182
- __propKey: Ct,
1183
- __setFunctionName: xt,
1184
- __metadata: Pt,
1185
- __awaiter: It,
1186
- __generator: jt,
1187
- __createBinding: Ce,
1188
- __exportStar: Lt,
1189
- __values: De,
1190
- __read: $e,
1191
- __spread: kt,
1192
- __spreadArrays: Ft,
1193
- __spreadArray: Mt,
1194
- __await: he,
1195
- __asyncGenerator: Vt,
1196
- __asyncDelegator: Ut,
1197
- __asyncValues: Ht,
1198
- __makeTemplateObject: Gt,
1199
- __importStar: zt,
1200
- __importDefault: Yt,
1201
- __classPrivateFieldGet: qt,
1202
- __classPrivateFieldSet: Bt,
1203
- __classPrivateFieldIn: Xt,
1204
- __addDisposableResource: Qt,
1205
- __disposeResources: Wt,
1206
- __rewriteRelativeImportExtension: Kt
1207
- }, cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1208
- __proto__: null,
1209
- __addDisposableResource: Qt,
1210
- get __assign() {
1211
- return Te;
1212
- },
1213
- __asyncDelegator: Ut,
1214
- __asyncGenerator: Vt,
1215
- __asyncValues: Ht,
1216
- __await: he,
1217
- __awaiter: It,
1218
- __classPrivateFieldGet: qt,
1219
- __classPrivateFieldIn: Xt,
1220
- __classPrivateFieldSet: Bt,
1221
- __createBinding: Ce,
1222
- __decorate: Rt,
1223
- __disposeResources: Wt,
1224
- __esDecorate: Dt,
1225
- __exportStar: Lt,
1226
- __extends: At,
1227
- __generator: jt,
1228
- __importDefault: Yt,
1229
- __importStar: zt,
1230
- __makeTemplateObject: Gt,
1231
- __metadata: Pt,
1232
- __param: Tt,
1233
- __propKey: Ct,
1234
- __read: $e,
1235
- __rest: _t,
1236
- __rewriteRelativeImportExtension: Kt,
1237
- __runInitializers: Nt,
1238
- __setFunctionName: xt,
1239
- __spread: kt,
1240
- __spreadArray: Mt,
1241
- __spreadArrays: Ft,
1242
- __values: De,
1243
- default: ir
1244
- }, Symbol.toStringTag, { value: "Module" })), ur = /* @__PURE__ */ sr(cr);
1245
- var Ae = {}, ut;
1246
- function lr() {
1247
- if (ut) return Ae;
1248
- ut = 1, Object.defineProperty(Ae, "__esModule", { value: !0 });
1249
- var e = fe;
1250
- function t() {
1251
- var n = e.useRef(!1), r = e.useCallback(function() {
1252
- return n.current;
1253
- }, []);
1254
- return e.useEffect(function() {
1255
- return n.current = !0, function() {
1256
- n.current = !1;
1257
- };
1258
- }, []), r;
1259
- }
1260
- return Ae.default = t, Ae;
1261
- }
1262
- Object.defineProperty(Ot, "__esModule", { value: !0 });
1263
- var Ye = ur, Le = fe, dr = Ye.__importDefault(lr());
1264
- function fr(e, t, n) {
1265
- t === void 0 && (t = []), n === void 0 && (n = { loading: !1 });
1266
- var r = Le.useRef(0), s = dr.default(), o = Le.useState(n), a = o[0], d = o[1], g = Le.useCallback(function() {
1267
- for (var u = [], c = 0; c < arguments.length; c++)
1268
- u[c] = arguments[c];
1269
- var i = ++r.current;
1270
- return a.loading || d(function(m) {
1271
- return Ye.__assign(Ye.__assign({}, m), { loading: !0 });
1272
- }), e.apply(void 0, u).then(function(m) {
1273
- return s() && i === r.current && d({ value: m, loading: !1 }), m;
1274
- }, function(m) {
1275
- return s() && i === r.current && d({ error: m, loading: !1 }), m;
1276
- });
1277
- }, t);
1278
- return [a, g];
1279
- }
1280
- var ie = Ot.default = fr;
1281
- const pr = (e = 20) => {
1282
- const t = "abcdefghijklmnopqrstuvwxyz0123456789";
1283
- let n = "";
1284
- for (let r = 0; r < e; r++)
1285
- n += t[Math.floor(Math.random() * t.length)];
1286
- return n;
1287
- }, oe = /* @__PURE__ */ new Map();
1288
- function Os() {
1289
- const [e, t] = Je([]), { http: n } = le();
1290
- function r(c) {
1291
- const i = c.map((m) => ({
1292
- file: m,
1293
- id: pr(10),
1294
- status: "pending",
1295
- progress: 0
1296
- }));
1297
- t((m) => [...m, ...i]), i.forEach(a);
1298
- }
1299
- function s(c, i) {
1300
- t(
1301
- (m) => m.map((p) => p.id === c ? { ...p, ...i } : p)
1302
- );
1303
- }
1304
- function o(c) {
1305
- t((i) => i.filter((m) => m.id !== c));
1306
- }
1307
- const a = async (c) => {
1308
- const i = new AbortController();
1309
- oe.set(c.id, i);
1310
- try {
1311
- t(
1312
- (p) => p.map(
1313
- (y) => y.id === c.id ? { ...y, status: "uploading", progress: 0 } : y
1314
- )
1315
- );
1316
- const m = await n.apis.uploadFile(c, {
1317
- signal: i.signal,
1318
- onUploadProgress: (p) => {
1319
- if (!p.total) return;
1320
- const y = Math.round(
1321
- p.loaded * 100 / p.total
1322
- );
1323
- s(c.id, { progress: y });
1324
- }
1325
- });
1326
- s(c.id, {
1327
- status: "success",
1328
- fileUrl: m.data.fileUrl,
1329
- progress: 100
1330
- });
1331
- } catch (m) {
1332
- i.signal.aborted || s(c.id, {
1333
- status: "error",
1334
- error: m instanceof Error ? m.message : "Upload failed",
1335
- progress: 0
1336
- });
1337
- } finally {
1338
- oe.delete(c.id);
1339
- }
1340
- }, d = (c) => {
1341
- const i = oe.get(c);
1342
- i && (i.abort(), oe.delete(c)), o(c);
1343
- }, g = ne(() => e.filter((c) => c.status === "success" && c.fileUrl), [e]);
1344
- function u() {
1345
- oe.forEach((c) => c.abort()), oe.clear(), t([]);
1346
- }
1347
- return de(() => () => {
1348
- oe.forEach((c) => c.abort()), oe.clear();
1349
- }, []), {
1350
- allFiles: e,
1351
- appendFiles: r,
1352
- handleCancelUpload: d,
1353
- successFiles: g,
1354
- emptyTheFiles: u,
1355
- getFileById: (c) => e.find((i) => i.id === c),
1356
- getUploadProgress: (c) => {
1357
- var i;
1358
- return ((i = e.find((m) => m.id === c)) == null ? void 0 : i.progress) ?? 0;
1359
- },
1360
- getUploadStatus: (c) => {
1361
- var i;
1362
- return (i = e.find((m) => m.id === c)) == null ? void 0 : i.status;
1363
- },
1364
- hasErrors: e.some((c) => c.status === "error"),
1365
- isUploading: e.some((c) => c.status === "uploading")
1366
- };
1367
- }
1368
- var xe = /* @__PURE__ */ ((e) => (e[e.OPEN = 0] = "OPEN", e[e.CLOSED_RESOLVED = 1] = "CLOSED_RESOLVED", e[e.CLOSED_UNRESOLVED = 2] = "CLOSED_UNRESOLVED", e))(xe || {}), Jt = /* @__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))(Jt || {}), et = /* @__PURE__ */ ((e) => (e.resolved = "resolved", e.assumed_resolved = "assumed_resolved", e.handed_off = "handed_off", e))(et || {}), Zt = /* @__PURE__ */ ((e) => (e.happy = "happy", e.neutral = "neutral", e.angry = "angry", e))(Zt || {}), $t = /* @__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))($t || {});
1369
- const gr = l.object({
1370
- id: l.string(),
1371
- ai_closure_type: l.nativeEnum(et).nullable(),
1372
- assignee_id: l.number().nullable(),
1373
- channel: l.nativeEnum(Jt),
1374
- summary: l.string().nullable(),
1375
- status: l.nativeEnum(xe),
1376
- language: l.string().nullable(),
1377
- last_message: l.string().nullable(),
1378
- last_message_at: l.date().nullable(),
1379
- assignee: l.object({
1380
- name: l.string(),
1381
- email: l.string(),
1382
- avatar_url: l.string().optional()
1383
- }).nullable().optional(),
1384
- sentiment: l.nativeEnum(Zt).nullable()
1385
- });
1386
- l.object({
1387
- publicId: l.string().uuid(),
1388
- message: l.string().nullable(),
1389
- type: l.string().nullable(),
1390
- agent_avatar: l.string().nullable(),
1391
- agent_id: l.number().nullable(),
1392
- agent_name: l.string().nullable(),
1393
- created_at: l.string(),
1394
- from_user: l.boolean().nullable(),
1395
- handoff_happened_during_office_hours: l.boolean().nullable(),
1396
- session_id: l.string(),
1397
- updated_at: l.string().nullable(),
1398
- attachments: l.array(vt).optional()
1399
- });
1400
- const mr = l.object({
1401
- name: l.string(),
1402
- is_ai: l.boolean(),
1403
- profile_picture: l.string().optional().nullable(),
1404
- id: l.string().nullable()
1405
- }), hr = l.object({
1406
- type: l.literal("message"),
1407
- value: l.string(),
1408
- attachments: l.array(vt).optional(),
1409
- is_stream_chunk: l.boolean().optional(),
1410
- server_session_id: l.string(),
1411
- client_message_id: l.string().optional(),
1412
- server_message_id: l.string()
1413
- }), yr = l.object({
1414
- type: l.literal("info"),
1415
- value: l.string()
1416
- }), Sr = l.object({
1417
- type: l.literal("ui"),
1418
- value: l.object({
1419
- type: l.string(),
1420
- request_response: l.any(),
1421
- name: l.string(),
1422
- content: l.string(),
1423
- message_id: l.string().optional()
1424
- }),
1425
- client_message_id: l.string().optional(),
1426
- server_session_id: l.string()
1427
- }), vr = l.object({
1428
- type: l.literal("chat_event"),
1429
- value: l.object({
1430
- event: l.nativeEnum($t),
1431
- message: l.string()
1432
- })
1433
- }), Er = l.object({
1434
- type: l.literal("options"),
1435
- value: l.object({
1436
- options: l.array(l.string())
1437
- }),
1438
- server_session_id: l.string()
1439
- }), br = l.object({
1440
- type: l.literal("session_update"),
1441
- value: l.object({
1442
- session: gr
1443
- }),
1444
- server_session_id: l.string()
1445
- });
1446
- l.discriminatedUnion("type", [
1447
- hr,
1448
- yr,
1449
- Sr,
1450
- vr,
1451
- Er,
1452
- br
1453
- ]).and(
1454
- l.object({
1455
- timestamp: l.string(),
1456
- agent: mr
1457
- })
1458
- );
1459
- l.object({
1460
- id: l.string(),
1461
- name: l.string().nullable(),
1462
- created_at: l.string(),
1463
- avatar_url: l.string().nullable(),
1464
- email: l.string().nullable()
1465
- });
1466
- function lt(e) {
1467
- var n, r, s;
1468
- const t = [];
1469
- for (let o = 0; o < e.length; o++) {
1470
- const a = e[o];
1471
- if (a.from_user === !0)
1472
- a.message && a.message.length > 0 && t.push({
1473
- type: "FROM_USER",
1474
- content: a.message,
1475
- id: a.publicId,
1476
- deliveredAt: a.created_at || "",
1477
- attachments: a.attachments,
1478
- timestamp: a.created_at || ""
1479
- });
1480
- else
1481
- switch (a.type) {
1482
- case "message":
1483
- t.push({
1484
- type: "FROM_BOT",
1485
- component: "TEXT",
1486
- data: {
1487
- message: a.message ?? ""
1488
- },
1489
- id: a.publicId,
1490
- timestamp: a.created_at || "",
1491
- original: a,
1492
- attachments: a.attachments,
1493
- agent: {
1494
- id: ((n = a.agent_id) == null ? void 0 : n.toString()) ?? null,
1495
- is_ai: !0,
1496
- profile_picture: a.agent_avatar || "",
1497
- name: a.agent_name || ""
1498
- }
1499
- });
1500
- break;
1501
- case "agent_message":
1502
- t.push({
1503
- type: "FROM_AGENT",
1504
- component: "TEXT",
1505
- data: {
1506
- message: a.message ?? ""
1507
- },
1508
- id: a.publicId,
1509
- timestamp: a.created_at || "",
1510
- original: a,
1511
- attachments: a.attachments,
1512
- agent: {
1513
- id: ((r = a.agent_id) == null ? void 0 : r.toString()) ?? null,
1514
- is_ai: !1,
1515
- name: a.agent_name || "",
1516
- profile_picture: a.agent_avatar || ""
1517
- }
1518
- });
1519
- break;
1520
- default:
1521
- t.push({
1522
- type: "FROM_BOT",
1523
- component: "CHAT_EVENT",
1524
- data: {
1525
- event: a.type,
1526
- message: a.message ?? ""
1527
- },
1528
- id: a.publicId || ve(),
1529
- original: a,
1530
- attachments: a.attachments,
1531
- timestamp: a.created_at || "",
1532
- agent: {
1533
- is_ai: !0,
1534
- id: ((s = a.agent_id) == null ? void 0 : s.toString()) ?? null,
1535
- name: a.agent_name || "",
1536
- profile_picture: a.agent_avatar || ""
1537
- }
1538
- });
1539
- }
1540
- }
1541
- return t;
1542
- }
1543
- function wr(e) {
1544
- const t = ae(null);
1545
- return de(() => {
1546
- if (!t.current) {
1547
- const n = new Audio(e.src);
1548
- n.volume = e.volume, n.loop = !1, n.preload = "auto", t.current = n;
1549
- }
1550
- return () => {
1551
- var n, r;
1552
- (n = t.current) == null || n.pause(), (r = t.current) == null || r.remove();
1553
- };
1554
- }, [e]), {
1555
- play: () => {
1556
- var n;
1557
- e.soundEnabled && ((n = t.current) == null || n.play());
1558
- },
1559
- stop: () => {
1560
- var n;
1561
- (n = t.current) == null || n.pause();
1562
- }
1563
- };
1564
- }
1565
- function Or() {
1566
- const { soundEffectFiles: e, widgetSettings: t, defaultSettings: n } = le(), r = (t == null ? void 0 : t.useSoundEffects) ?? n.useSoundEffects;
1567
- return {
1568
- messageArrivedSound: wr({
1569
- src: e.messageArrived,
1570
- soundEnabled: r,
1571
- volume: 0.5
1572
- })
1573
- };
1574
- }
1575
- const Ar = 5e3;
1576
- function _r(e, t) {
1577
- return mn(e, (n) => {
1578
- const r = () => {
1579
- n.lastUpdated = Date.now();
1580
- };
1581
- switch (t.type) {
1582
- case "ADD_RESPONSE_MESSAGE": {
1583
- n.messages.push(t.payload), r();
1584
- break;
1585
- }
1586
- case "APPEND_USER_MESSAGE": {
1587
- n.messages.push(t.payload), r();
1588
- break;
1589
- }
1590
- case "RESET": {
1591
- n.messages = [], n.lastUpdated = null, n.keyboard = null;
1592
- break;
1593
- }
1594
- case "PREPEND_HISTORY": {
1595
- const s = t.payload.map((o) => o.id);
1596
- n.messages = n.messages.filter(
1597
- (o) => !s.includes(o.id)
1598
- ), n.messages = [...t.payload, ...n.messages], r();
1599
- break;
1600
- }
1601
- case "SET_KEYBOARD": {
1602
- n.keyboard = t.payload;
1603
- break;
1604
- }
1605
- case "SET_DELIVERED_AT": {
1606
- const s = n.messages.find((o) => {
1607
- var a;
1608
- if (o.type === "FROM_USER" && o.id === ((a = t.payload) == null ? void 0 : a.clientMessageId))
1609
- return !0;
1610
- });
1611
- (s == null ? void 0 : s.type) === "FROM_USER" && hn(s, "deliveredAt", t.payload.deliveredAt);
1612
- break;
1613
- }
1614
- case "SET_MESSAGES": {
1615
- n.messages = t.payload;
1616
- break;
1617
- }
1618
- case "APPEND_MESSAGES": {
1619
- const s = t.payload.filter((o) => !n.messages.some((a) => a.id === o.id));
1620
- n.messages.push(...s);
1621
- break;
1622
- }
1623
- }
1624
- });
1625
- }
1626
- function Rr({
1627
- persist: e,
1628
- sessionKey: t = (n, { external_id: r }) => `[OPEN_SESSION_${n}]_${r || "session"}`
1629
- }) {
1630
- const { botToken: n, http: r, user: s } = le(), [o, a, d] = Ze(
1631
- t(n, s),
1632
- void 0,
1633
- e ? "local" : "memory"
1634
- ), g = (f) => ({
1635
- ...f,
1636
- isSessionClosed: f.status !== xe.OPEN,
1637
- isAssignedToAi: f.assignee_id === 555,
1638
- isAssignedToHuman: f.assignee_id !== 555,
1639
- isPendingHuman: f.assignee_id === 555 && f.ai_closure_type === et.handed_off
1640
- }), u = ne(() => o ? g(o) : null, [o]), [c, i] = ie(
1641
- async (f) => {
1642
- let v = await r.apis.fetchSession(f);
1643
- return v.data && a(v.data), v.data;
1644
- },
1645
- [r, a]
1646
- ), [m, p] = ie(
1647
- async (f) => {
1648
- try {
1649
- const v = await i(f);
1650
- return v ? g(v) : null;
1651
- } catch (v) {
1652
- throw console.error("Error polling session:", v), v;
1653
- }
1654
- },
1655
- [i, g]
1656
- );
1657
- function y() {
1658
- a(null), d();
1659
- }
1660
- return {
1661
- session: u,
1662
- refreshSession: i,
1663
- refreshSessionState: c,
1664
- deleteSession: y,
1665
- setSession: a,
1666
- transformSession: g,
1667
- pollSession: p
1668
- };
1669
- }
1670
- function Tr({ onSessionDestroy: e }) {
1671
- const [t, n] = fn(_r, {
1672
- lastUpdated: null,
1673
- messages: [],
1674
- keyboard: null
1675
- }), [r, s] = Je({ state: "idle" }), o = t.messages.length === 0, { botToken: a, http: d, widgetSettings: g, defaultSettings: u, language: c, ...i } = le(), { messageArrivedSound: m } = Or(), p = (g == null ? void 0 : g.persistSession) || u.persistSession, { refreshSession: y, session: f, deleteSession: v, setSession: h, pollSession: B } = Rr({
1676
- persist: p
1677
- }), [T, S] = ie(
1678
- async (A) => {
1679
- if (!f) return [];
1680
- try {
1681
- const { data: N } = await d.apis.fetchHistory(A);
1682
- return N ? Array.isArray(N) ? lt(N) : [] : [];
1683
- } catch (N) {
1684
- throw console.error("Error fetching history:", N), N;
1685
- }
1686
- },
1687
- [f, d.apis]
1688
- ), [w, E] = ie(
1689
- async (A, N) => {
1690
- try {
1691
- const M = await d.apis.getHistoryPooling({
1692
- sessionId: A,
1693
- lastMessageTimestamp: N
1694
- });
1695
- if (M.data) {
1696
- const U = lt(M.data);
1697
- if (U.length > 0) {
1698
- n({
1699
- type: "APPEND_MESSAGES",
1700
- payload: U
1701
- });
1702
- try {
1703
- m.play();
1704
- } catch (G) {
1705
- console.error("Error playing sound:", G);
1706
- }
1707
- }
1708
- return U;
1709
- }
1710
- return [];
1711
- } catch (M) {
1712
- throw console.error("Error polling messages:", M), M;
1713
- }
1714
- },
1715
- [d.apis, n, m]
1716
- );
1717
- de(() => {
1718
- let A;
1719
- return f && (A = setInterval(() => {
1720
- var M;
1721
- B(f.id);
1722
- const N = (M = t.messages.at(-1)) == null ? void 0 : M.timestamp;
1723
- N && E(f.id, N);
1724
- }, Ar)), () => {
1725
- clearInterval(A);
1726
- };
1727
- }, [f, B, E]);
1728
- const [F, O] = ie(
1729
- async () => {
1730
- if (f)
1731
- try {
1732
- const A = await y(f.id);
1733
- if (A) {
1734
- const N = await S(A.id);
1735
- N && n({ type: "PREPEND_HISTORY", payload: N });
1736
- }
1737
- } catch (A) {
1738
- throw console.error("Error initializing session:", A), A;
1739
- }
1740
- },
1741
- [f, y, S, n]
1742
- );
1743
- de(() => {
1744
- O();
1745
- }, []);
1746
- const [x, P] = ie(
1747
- async () => {
1748
- try {
1749
- v(), n({ type: "RESET" }), e == null || e(), s({ state: "idle" });
1750
- } catch (A) {
1751
- throw console.error("Error clearing session:", A), A;
1752
- }
1753
- },
1754
- [v, n, e, s]
1755
- ), [X, K] = ie(
1756
- async () => {
1757
- try {
1758
- await P();
1759
- const { data: A } = await d.apis.createSession(a);
1760
- return h(A), A;
1761
- } catch (A) {
1762
- throw console.error("Error recreating session:", A), A;
1763
- }
1764
- },
1765
- [P, d.apis, a, h]
1766
- ), L = async ({ content: A, user: N, attachments: M, ...U }) => {
1767
- try {
1768
- let G = function() {
1769
- var D;
1770
- if (se.data.success) {
1771
- const q = se.data;
1772
- if (q.uiResponse) {
1773
- const Oe = q.uiResponse.value;
1774
- n({
1775
- type: "ADD_RESPONSE_MESSAGE",
1776
- payload: {
1777
- type: "FROM_BOT",
1778
- id: ve(),
1779
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1780
- component: Oe.name,
1781
- data: Oe.request_response
1782
- }
1783
- });
1784
- return;
1785
- }
1786
- if (q.autopilotResponse) {
1787
- n({
1788
- type: "ADD_RESPONSE_MESSAGE",
1789
- payload: {
1790
- type: "FROM_BOT",
1791
- id: q.autopilotResponse.id || ve(),
1792
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1793
- component: "TEXT",
1794
- data: {
1795
- message: q.autopilotResponse.value.content
1796
- }
1797
- }
1798
- });
1799
- return;
1800
- }
1801
- } else {
1802
- const q = ((D = se.data.error) == null ? void 0 : D.message) || "Unknown error occurred";
1803
- n({
1804
- type: "ADD_RESPONSE_MESSAGE",
1805
- payload: {
1806
- type: "FROM_BOT",
1807
- id: ve(),
1808
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1809
- component: "TEXT",
1810
- data: {
1811
- message: q,
1812
- variant: "error"
1813
- }
1814
- }
1815
- }), s({ state: "error", error: q });
1816
- }
1817
- }, z = f, J = !1;
1818
- if ((!f || f != null && f.isAssignedToAi) && s({ state: "loading" }), !f && o)
1819
- try {
1820
- const { data: D } = await d.apis.createSession(a);
1821
- if (D)
1822
- h(D), z = {
1823
- ...D,
1824
- isSessionClosed: D.status !== xe.OPEN,
1825
- isAssignedToAi: D.assignee_id === 555,
1826
- isAssignedToHuman: !1,
1827
- isPendingHuman: !1
1828
- }, J = !0;
1829
- else
1830
- throw new Error("Failed to create new chat session");
1831
- } catch (D) {
1832
- throw s({
1833
- state: "error",
1834
- error: D instanceof Error ? D.message : "Failed to create session"
1835
- }), D;
1836
- }
1837
- if (!z) {
1838
- const D = new Error("No active session available");
1839
- throw s({ state: "error", error: D.message }), D;
1840
- }
1841
- const Y = ve(), { headers: pe, queryParams: we } = i;
1842
- if (n({
1843
- type: "APPEND_USER_MESSAGE",
1844
- payload: {
1845
- type: "FROM_USER",
1846
- id: Y,
1847
- content: A.text,
1848
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1849
- user: {
1850
- ...i.user,
1851
- ...N
1852
- },
1853
- deliveredAt: null,
1854
- attachments: M
1855
- }
1856
- }), t.keyboard && n({
1857
- type: "SET_KEYBOARD",
1858
- payload: null
1859
- }), !J && z.isAssignedToAi)
1860
- try {
1861
- const D = await B(z.id);
1862
- D && (z = D);
1863
- } catch (D) {
1864
- console.error("Error polling session:", D);
1865
- }
1866
- const se = await d.apis.sendMessage({
1867
- id: Y,
1868
- content: A.text,
1869
- session_id: z.id,
1870
- bot_token: a,
1871
- headers: pe,
1872
- query_params: we,
1873
- user: {
1874
- ...i.user,
1875
- ...N
1876
- },
1877
- language: c,
1878
- attachments: M,
1879
- ...U
1880
- });
1881
- return n({
1882
- type: "SET_DELIVERED_AT",
1883
- payload: {
1884
- clientMessageId: Y,
1885
- deliveredAt: (/* @__PURE__ */ new Date()).toISOString()
1886
- }
1887
- }), G(), s({ state: "idle" }), { id: Y };
1888
- } catch (G) {
1889
- const z = G instanceof Error ? G.message : "An unexpected error occurred";
1890
- throw console.error("Error in sendMessage:", z, G), (!f || f != null && f.isAssignedToAi) && s({ state: "error", error: z }), G;
1891
- }
1892
- }, re = me(
1893
- (A) => {
1894
- L({
1895
- content: {
1896
- text: A
1897
- }
1898
- }).catch((N) => {
1899
- console.error("Error handling keyboard input:", N);
1900
- }), n({
1901
- type: "SET_KEYBOARD",
1902
- payload: null
1903
- });
1904
- },
1905
- [n, L]
1906
- );
1907
- return {
1908
- version: Vn.version,
1909
- state: t,
1910
- session: f,
1911
- noMessages: o,
1912
- initState: F,
1913
- clearSessionState: x,
1914
- recreateSessionState: X,
1915
- hookState: r,
1916
- recreateSession: K,
1917
- clearSession: P,
1918
- sendMessage: L,
1919
- handleKeyboard: re
1920
- };
1921
- }
1922
- const [As, Dr] = Ne();
1923
- function Nr({
1924
- children: e
1925
- }) {
1926
- const { settings: t } = le(), n = Tr({
1927
- defaultHookSettings: {
1928
- persistSession: (t == null ? void 0 : t.persistSession) ?? !0,
1929
- useSoundEffects: (t == null ? void 0 : t.useSoundEffects) ?? !1
1930
- }
1931
- });
1932
- return /* @__PURE__ */ te(Dr, { value: n, children: e });
1933
- }
1934
- function Cr() {
1935
- const { http: e, botToken: t, user: n, collectUserData: r } = le(), [s, o] = Ze(
1936
- `${t}:contact:${n.external_id}`,
1937
- null,
1938
- "local"
1939
- ), [a, d] = ie(
1940
- async (u) => {
1941
- var c;
1942
- try {
1943
- if (!u || !u.email) return null;
1944
- const i = await e.apis.dumpContact(u);
1945
- return (c = i == null ? void 0 : i.data) != null && c.id && o(i.data), i == null ? void 0 : i.data;
1946
- } catch (i) {
1947
- console.error(i);
1948
- }
1949
- return null;
1950
- },
1951
- [e.apis]
1952
- );
1953
- de(() => {
1954
- n && t && d(n);
1955
- }, [n, t]);
1956
- const g = ne(() => !(s != null && s.id) && r ? {
1957
- should: !0,
1958
- reason: "No contact id and collectUserData is true"
1959
- } : {
1960
- should: !1
1961
- }, [s]);
1962
- return {
1963
- creatingContactState: a,
1964
- createContactAsync: d,
1965
- contact: s,
1966
- shouldCollectData: g
1967
- };
1968
- }
1969
- const [_s, xr] = Ne();
1970
- function Pr({ children: e }) {
1971
- const t = Cr();
1972
- return /* @__PURE__ */ te(xr, { value: t, children: e });
1973
- }
1974
- function Rs({
1975
- children: e,
1976
- options: t
1977
- }) {
1978
- return /* @__PURE__ */ te(rr, { data: t, children: /* @__PURE__ */ te(Pr, { children: /* @__PURE__ */ te(wt, { children: /* @__PURE__ */ te(Nr, { children: e }) }) }) });
1979
- }
1980
- var qe = { exports: {} }, ke = {};
1981
- /**
1982
- * @license React
1983
- * use-sync-external-store-shim.production.min.js
1984
- *
1985
- * Copyright (c) Facebook, Inc. and its affiliates.
1986
- *
1987
- * This source code is licensed under the MIT license found in the
1988
- * LICENSE file in the root directory of this source tree.
1989
- */
1990
- var dt;
1991
- function Ir() {
1992
- if (dt) return ke;
1993
- dt = 1;
1994
- var e = fe;
1995
- function t(i, m) {
1996
- return i === m && (i !== 0 || 1 / i === 1 / m) || i !== i && m !== m;
1997
- }
1998
- var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, s = e.useEffect, o = e.useLayoutEffect, a = e.useDebugValue;
1999
- function d(i, m) {
2000
- var p = m(), y = r({ inst: { value: p, getSnapshot: m } }), f = y[0].inst, v = y[1];
2001
- return o(function() {
2002
- f.value = p, f.getSnapshot = m, g(f) && v({ inst: f });
2003
- }, [i, p, m]), s(function() {
2004
- return g(f) && v({ inst: f }), i(function() {
2005
- g(f) && v({ inst: f });
2006
- });
2007
- }, [i]), a(p), p;
2008
- }
2009
- function g(i) {
2010
- var m = i.getSnapshot;
2011
- i = i.value;
2012
- try {
2013
- var p = m();
2014
- return !n(i, p);
2015
- } catch {
2016
- return !0;
2017
- }
2018
- }
2019
- function u(i, m) {
2020
- return m();
2021
- }
2022
- var c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? u : d;
2023
- return ke.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : c, ke;
2024
- }
2025
- var Fe = {};
2026
- /**
2027
- * @license React
2028
- * use-sync-external-store-shim.development.js
2029
- *
2030
- * Copyright (c) Facebook, Inc. and its affiliates.
2031
- *
2032
- * This source code is licensed under the MIT license found in the
2033
- * LICENSE file in the root directory of this source tree.
2034
- */
2035
- var ft;
2036
- function jr() {
2037
- return ft || (ft = 1, process.env.NODE_ENV !== "production" && function() {
2038
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2039
- var e = fe, t = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2040
- function n(T) {
2041
- {
2042
- for (var S = arguments.length, w = new Array(S > 1 ? S - 1 : 0), E = 1; E < S; E++)
2043
- w[E - 1] = arguments[E];
2044
- r("error", T, w);
2045
- }
2046
- }
2047
- function r(T, S, w) {
2048
- {
2049
- var E = t.ReactDebugCurrentFrame, F = E.getStackAddendum();
2050
- F !== "" && (S += "%s", w = w.concat([F]));
2051
- var O = w.map(function(x) {
2052
- return String(x);
2053
- });
2054
- O.unshift("Warning: " + S), Function.prototype.apply.call(console[T], console, O);
2055
- }
2056
- }
2057
- function s(T, S) {
2058
- return T === S && (T !== 0 || 1 / T === 1 / S) || T !== T && S !== S;
2059
- }
2060
- var o = typeof Object.is == "function" ? Object.is : s, a = e.useState, d = e.useEffect, g = e.useLayoutEffect, u = e.useDebugValue, c = !1, i = !1;
2061
- function m(T, S, w) {
2062
- 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."));
2063
- var E = S();
2064
- if (!i) {
2065
- var F = S();
2066
- o(E, F) || (n("The result of getSnapshot should be cached to avoid an infinite loop"), i = !0);
2067
- }
2068
- var O = a({
2069
- inst: {
2070
- value: E,
2071
- getSnapshot: S
2072
- }
2073
- }), x = O[0].inst, P = O[1];
2074
- return g(function() {
2075
- x.value = E, x.getSnapshot = S, p(x) && P({
2076
- inst: x
2077
- });
2078
- }, [T, E, S]), d(function() {
2079
- p(x) && P({
2080
- inst: x
2081
- });
2082
- var X = function() {
2083
- p(x) && P({
2084
- inst: x
2085
- });
2086
- };
2087
- return T(X);
2088
- }, [T]), u(E), E;
2089
- }
2090
- function p(T) {
2091
- var S = T.getSnapshot, w = T.value;
2092
- try {
2093
- var E = S();
2094
- return !o(w, E);
2095
- } catch {
2096
- return !0;
2097
- }
2098
- }
2099
- function y(T, S, w) {
2100
- return S();
2101
- }
2102
- var f = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", v = !f, h = v ? y : m, B = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : h;
2103
- Fe.useSyncExternalStore = B, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
2104
- }()), Fe;
2105
- }
2106
- process.env.NODE_ENV === "production" ? qe.exports = Ir() : qe.exports = jr();
2107
- var Lr = qe.exports;
2108
- const ce = () => {
2109
- }, V = (
2110
- /*#__NOINLINE__*/
2111
- ce()
2112
- ), Me = Object, b = (e) => e === V, W = (e) => typeof e == "function", ue = (e, t) => ({
2113
- ...e,
2114
- ...t
2115
- }), kr = (e) => W(e.then), _e = /* @__PURE__ */ new WeakMap();
2116
- let Fr = 0;
2117
- const Ee = (e) => {
2118
- const t = typeof e, n = e && e.constructor, r = n == Date;
2119
- let s, o;
2120
- if (Me(e) === e && !r && n != RegExp) {
2121
- if (s = _e.get(e), s) return s;
2122
- if (s = ++Fr + "~", _e.set(e, s), n == Array) {
2123
- for (s = "@", o = 0; o < e.length; o++)
2124
- s += Ee(e[o]) + ",";
2125
- _e.set(e, s);
2126
- }
2127
- if (n == Me) {
2128
- s = "#";
2129
- const a = Me.keys(e).sort();
2130
- for (; !b(o = a.pop()); )
2131
- b(e[o]) || (s += o + ":" + Ee(e[o]) + ",");
2132
- _e.set(e, s);
2133
- }
2134
- } else
2135
- s = r ? e.toJSON() : t == "symbol" ? e.toString() : t == "string" ? JSON.stringify(e) : "" + e;
2136
- return s;
2137
- }, ee = /* @__PURE__ */ new WeakMap(), Ve = {}, Re = {}, tt = "undefined", Pe = typeof window != tt, Be = typeof document != tt, Mr = () => Pe && typeof window.requestAnimationFrame != tt, en = (e, t) => {
2138
- const n = ee.get(e);
2139
- return [
2140
- // Getter
2141
- () => !b(t) && e.get(t) || Ve,
2142
- // Setter
2143
- (r) => {
2144
- if (!b(t)) {
2145
- const s = e.get(t);
2146
- t in Re || (Re[t] = s), n[5](t, ue(s, r), s || Ve);
2147
- }
2148
- },
2149
- // Subscriber
2150
- n[6],
2151
- // Get server cache snapshot
2152
- () => !b(t) && t in Re ? Re[t] : !b(t) && e.get(t) || Ve
2153
- ];
2154
- };
2155
- let Xe = !0;
2156
- const Vr = () => Xe, [Qe, We] = Pe && window.addEventListener ? [
2157
- window.addEventListener.bind(window),
2158
- window.removeEventListener.bind(window)
2159
- ] : [
2160
- ce,
2161
- ce
2162
- ], Ur = () => {
2163
- const e = Be && document.visibilityState;
2164
- return b(e) || e !== "hidden";
2165
- }, Hr = (e) => (Be && document.addEventListener("visibilitychange", e), Qe("focus", e), () => {
2166
- Be && document.removeEventListener("visibilitychange", e), We("focus", e);
2167
- }), Gr = (e) => {
2168
- const t = () => {
2169
- Xe = !0, e();
2170
- }, n = () => {
2171
- Xe = !1;
2172
- };
2173
- return Qe("online", t), Qe("offline", n), () => {
2174
- We("online", t), We("offline", n);
2175
- };
2176
- }, zr = {
2177
- isOnline: Vr,
2178
- isVisible: Ur
2179
- }, Yr = {
2180
- initFocus: Hr,
2181
- initReconnect: Gr
2182
- }, pt = !fe.useId, be = !Pe || "Deno" in window, qr = (e) => Mr() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Ue = be ? de : pn, He = typeof navigator < "u" && navigator.connection, gt = !be && He && ([
2183
- "slow-2g",
2184
- "2g"
2185
- ].includes(He.effectiveType) || He.saveData), nt = (e) => {
2186
- if (W(e))
2187
- try {
2188
- e = e();
2189
- } catch {
2190
- e = "";
2191
- }
2192
- const t = e;
2193
- return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? Ee(e) : "", [
2194
- e,
2195
- t
2196
- ];
2197
- };
2198
- let Br = 0;
2199
- const Ke = () => ++Br, tn = 0, nn = 1, rn = 2, Xr = 3;
2200
- var Se = {
2201
- __proto__: null,
2202
- ERROR_REVALIDATE_EVENT: Xr,
2203
- FOCUS_EVENT: tn,
2204
- MUTATE_EVENT: rn,
2205
- RECONNECT_EVENT: nn
2206
- };
2207
- async function sn(...e) {
2208
- const [t, n, r, s] = e, o = ue({
2209
- populateCache: !0,
2210
- throwOnError: !0
2211
- }, typeof s == "boolean" ? {
2212
- revalidate: s
2213
- } : s || {});
2214
- let a = o.populateCache;
2215
- const d = o.rollbackOnError;
2216
- let g = o.optimisticData;
2217
- const u = (m) => typeof d == "function" ? d(m) : d !== !1, c = o.throwOnError;
2218
- if (W(n)) {
2219
- const m = n, p = [], y = t.keys();
2220
- for (const f of y)
2221
- // Skip the special useSWRInfinite and useSWRSubscription keys.
2222
- !/^\$(inf|sub)\$/.test(f) && m(t.get(f)._k) && p.push(f);
2223
- return Promise.all(p.map(i));
2224
- }
2225
- return i(n);
2226
- async function i(m) {
2227
- const [p] = nt(m);
2228
- if (!p) return;
2229
- const [y, f] = en(t, p), [v, h, B, T] = ee.get(t), S = () => {
2230
- const L = v[p];
2231
- return (W(o.revalidate) ? o.revalidate(y().data, m) : o.revalidate !== !1) && (delete B[p], delete T[p], L && L[0]) ? L[0](rn).then(() => y().data) : y().data;
2232
- };
2233
- if (e.length < 3)
2234
- return S();
2235
- let w = r, E;
2236
- const F = Ke();
2237
- h[p] = [
2238
- F,
2239
- 0
2240
- ];
2241
- const O = !b(g), x = y(), P = x.data, X = x._c, K = b(X) ? P : X;
2242
- if (O && (g = W(g) ? g(K, P) : g, f({
2243
- data: g,
2244
- _c: K
2245
- })), W(w))
2246
- try {
2247
- w = w(K);
2248
- } catch (L) {
2249
- E = L;
2250
- }
2251
- if (w && kr(w))
2252
- if (w = await w.catch((L) => {
2253
- E = L;
2254
- }), F !== h[p][0]) {
2255
- if (E) throw E;
2256
- return w;
2257
- } else E && O && u(E) && (a = !0, f({
2258
- data: K,
2259
- _c: V
2260
- }));
2261
- if (a && !E)
2262
- if (W(a)) {
2263
- const L = a(w, K);
2264
- f({
2265
- data: L,
2266
- error: V,
2267
- _c: V
2268
- });
2269
- } else
2270
- f({
2271
- data: w,
2272
- error: V,
2273
- _c: V
2274
- });
2275
- if (h[p][1] = Ke(), Promise.resolve(S()).then(() => {
2276
- f({
2277
- _c: V
2278
- });
2279
- }), E) {
2280
- if (c) throw E;
2281
- return;
2282
- }
2283
- return w;
2284
- }
2285
- }
2286
- const mt = (e, t) => {
2287
- for (const n in e)
2288
- e[n][0] && e[n][0](t);
2289
- }, Qr = (e, t) => {
2290
- if (!ee.has(e)) {
2291
- const n = ue(Yr, t), r = {}, s = sn.bind(V, e);
2292
- let o = ce;
2293
- const a = {}, d = (c, i) => {
2294
- const m = a[c] || [];
2295
- return a[c] = m, m.push(i), () => m.splice(m.indexOf(i), 1);
2296
- }, g = (c, i, m) => {
2297
- e.set(c, i);
2298
- const p = a[c];
2299
- if (p)
2300
- for (const y of p)
2301
- y(i, m);
2302
- }, u = () => {
2303
- if (!ee.has(e) && (ee.set(e, [
2304
- r,
2305
- {},
2306
- {},
2307
- {},
2308
- s,
2309
- g,
2310
- d
2311
- ]), !be)) {
2312
- const c = n.initFocus(setTimeout.bind(V, mt.bind(V, r, tn))), i = n.initReconnect(setTimeout.bind(V, mt.bind(V, r, nn)));
2313
- o = () => {
2314
- c && c(), i && i(), ee.delete(e);
2315
- };
2316
- }
2317
- };
2318
- return u(), [
2319
- e,
2320
- s,
2321
- u,
2322
- o
2323
- ];
2324
- }
2325
- return [
2326
- e,
2327
- ee.get(e)[4]
2328
- ];
2329
- }, Wr = (e, t, n, r, s) => {
2330
- const o = n.errorRetryCount, a = s.retryCount, d = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * n.errorRetryInterval;
2331
- !b(o) && a > o || setTimeout(r, d, s);
2332
- }, Kr = (e, t) => Ee(e) == Ee(t), [on, Jr] = Qr(/* @__PURE__ */ new Map()), Zr = ue(
2333
- {
2334
- // events
2335
- onLoadingSlow: ce,
2336
- onSuccess: ce,
2337
- onError: ce,
2338
- onErrorRetry: Wr,
2339
- onDiscarded: ce,
2340
- // switches
2341
- revalidateOnFocus: !0,
2342
- revalidateOnReconnect: !0,
2343
- revalidateIfStale: !0,
2344
- shouldRetryOnError: !0,
2345
- // timeouts
2346
- errorRetryInterval: gt ? 1e4 : 5e3,
2347
- focusThrottleInterval: 5 * 1e3,
2348
- dedupingInterval: 2 * 1e3,
2349
- loadingTimeout: gt ? 5e3 : 3e3,
2350
- // providers
2351
- compare: Kr,
2352
- isPaused: () => !1,
2353
- cache: on,
2354
- mutate: Jr,
2355
- fallback: {}
2356
- },
2357
- // use web preset by default
2358
- zr
2359
- ), $r = (e, t) => {
2360
- const n = ue(e, t);
2361
- if (t) {
2362
- const { use: r, fallback: s } = e, { use: o, fallback: a } = t;
2363
- r && o && (n.use = r.concat(o)), s && a && (n.fallback = ue(s, a));
2364
- }
2365
- return n;
2366
- }, es = yt({}), ts = "$inf$", an = Pe && window.__SWR_DEVTOOLS_USE__, ns = an ? window.__SWR_DEVTOOLS_USE__ : [], rs = () => {
2367
- an && (window.__SWR_DEVTOOLS_REACT__ = fe);
2368
- }, ss = (e) => W(e[1]) ? [
2369
- e[0],
2370
- e[1],
2371
- e[2] || {}
2372
- ] : [
2373
- e[0],
2374
- null,
2375
- (e[1] === null ? e[2] : e[1]) || {}
2376
- ], os = () => ue(Zr, St(es)), as = (e) => (t, n, r) => e(t, n && ((...o) => {
2377
- const [a] = nt(t), [, , , d] = ee.get(on);
2378
- if (a.startsWith(ts))
2379
- return n(...o);
2380
- const g = d[a];
2381
- return b(g) ? n(...o) : (delete d[a], g);
2382
- }), r), is = ns.concat(as), cs = (e) => function(...n) {
2383
- const r = os(), [s, o, a] = ss(n), d = $r(r, a);
2384
- let g = e;
2385
- const { use: u } = d, c = (u || []).concat(is);
2386
- for (let i = c.length; i--; )
2387
- g = c[i](g);
2388
- return g(s, o || d.fetcher || null, d);
2389
- }, us = (e, t, n) => {
2390
- const r = t[e] || (t[e] = []);
2391
- return r.push(n), () => {
2392
- const s = r.indexOf(n);
2393
- s >= 0 && (r[s] = r[r.length - 1], r.pop());
2394
- };
2395
- };
2396
- rs();
2397
- const ht = fe.use || ((e) => {
2398
- if (e.status === "pending")
2399
- throw e;
2400
- if (e.status === "fulfilled")
2401
- return e.value;
2402
- throw e.status === "rejected" ? e.reason : (e.status = "pending", e.then((t) => {
2403
- e.status = "fulfilled", e.value = t;
2404
- }, (t) => {
2405
- e.status = "rejected", e.reason = t;
2406
- }), e);
2407
- }), Ge = {
2408
- dedupe: !0
2409
- }, ls = (e, t, n) => {
2410
- 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] = ee.get(r), [h, B] = nt(e), T = ae(!1), S = ae(!1), w = ae(h), E = ae(t), F = ae(n), O = () => F.current, x = () => O().isVisible() && O().isOnline(), [P, X, K, L] = en(r, h), re = ae({}).current, A = b(a) ? n.fallback[h] : a, N = (_, R) => {
2411
- for (const j in re) {
2412
- const C = j;
2413
- if (C === "data") {
2414
- if (!s(_[C], R[C]) && (!b(_[C]) || !s(se, R[C])))
2415
- return !1;
2416
- } else if (R[C] !== _[C])
2417
- return !1;
2418
- }
2419
- return !0;
2420
- }, M = ne(() => {
2421
- const _ = !h || !t ? !1 : b(d) ? O().isPaused() || o ? !1 : b(g) ? !0 : g : d, R = (k) => {
2422
- const Z = ue(k);
2423
- return delete Z._k, _ ? {
2424
- isValidating: !0,
2425
- isLoading: !0,
2426
- ...Z
2427
- } : Z;
2428
- }, j = P(), C = L(), Q = R(j), ge = j === C ? Q : R(C);
2429
- let I = Q;
2430
- return [
2431
- () => {
2432
- const k = R(P());
2433
- return N(k, I) ? (I.data = k.data, I.isLoading = k.isLoading, I.isValidating = k.isValidating, I.error = k.error, I) : (I = k, k);
2434
- },
2435
- () => ge
2436
- ];
2437
- }, [
2438
- r,
2439
- h
2440
- ]), U = Lr.useSyncExternalStore(me(
2441
- (_) => K(h, (R, j) => {
2442
- N(j, R) || _();
2443
- }),
2444
- // eslint-disable-next-line react-hooks/exhaustive-deps
2445
- [
2446
- r,
2447
- h
2448
- ]
2449
- ), M[0], M[1]), G = !T.current, z = p[h] && p[h].length > 0, J = U.data, Y = b(J) ? A : J, pe = U.error, we = ae(Y), se = m ? b(J) ? we.current : J : Y, D = z && !b(pe) ? !1 : G && !b(d) ? d : O().isPaused() ? !1 : o ? b(Y) ? !1 : g : b(Y) || g, q = !!(h && t && G && D), Oe = b(U.isValidating) ? q : U.isValidating, cn = b(U.isLoading) ? q : U.isLoading, ye = me(
2450
- async (_) => {
2451
- const R = E.current;
2452
- if (!h || !R || S.current || O().isPaused())
2453
- return !1;
2454
- let j, C, Q = !0;
2455
- const ge = _ || {}, I = !f[h] || !ge.dedupe, k = () => pt ? !S.current && h === w.current && T.current : h === w.current, Z = {
2456
- isValidating: !1,
2457
- isLoading: !1
2458
- }, st = () => {
2459
- X(Z);
2460
- }, ot = () => {
2461
- const H = f[h];
2462
- H && H[1] === C && delete f[h];
2463
- }, at = {
2464
- isValidating: !0
2465
- };
2466
- b(P().data) && (at.isLoading = !0);
2467
- try {
2468
- if (I && (X(at), n.loadingTimeout && b(P().data) && setTimeout(() => {
2469
- Q && k() && O().onLoadingSlow(h, n);
2470
- }, n.loadingTimeout), f[h] = [
2471
- R(B),
2472
- Ke()
2473
- ]), [j, C] = f[h], j = await j, I && setTimeout(ot, n.dedupingInterval), !f[h] || f[h][1] !== C)
2474
- return I && k() && O().onDiscarded(h), !1;
2475
- Z.error = V;
2476
- const H = y[h];
2477
- if (!b(H) && // case 1
2478
- (C <= H[0] || // case 2
2479
- C <= H[1] || // case 3
2480
- H[1] === 0))
2481
- return st(), I && k() && O().onDiscarded(h), !1;
2482
- const $ = P().data;
2483
- Z.data = s($, j) ? $ : j, I && k() && O().onSuccess(j, h, n);
2484
- } catch (H) {
2485
- ot();
2486
- const $ = O(), { shouldRetryOnError: Ie } = $;
2487
- $.isPaused() || (Z.error = H, I && k() && ($.onError(H, h, $), (Ie === !0 || W(Ie) && Ie(H)) && (!O().revalidateOnFocus || !O().revalidateOnReconnect || x()) && $.onErrorRetry(H, h, $, (un) => {
2488
- const je = p[h];
2489
- je && je[0] && je[0](Se.ERROR_REVALIDATE_EVENT, un);
2490
- }, {
2491
- retryCount: (ge.retryCount || 0) + 1,
2492
- dedupe: !0
2493
- })));
2494
- }
2495
- return Q = !1, st(), !0;
2496
- },
2497
- // `setState` is immutable, and `eventsCallback`, `fnArg`, and
2498
- // `keyValidating` are depending on `key`, so we can exclude them from
2499
- // the deps array.
2500
- //
2501
- // FIXME:
2502
- // `fn` and `config` might be changed during the lifecycle,
2503
- // but they might be changed every render like this.
2504
- // `useSWR('key', () => fetch('/api/'), { suspense: true })`
2505
- // So we omit the values from the deps array
2506
- // even though it might cause unexpected behaviors.
2507
- // eslint-disable-next-line react-hooks/exhaustive-deps
2508
- [
2509
- h,
2510
- r
2511
- ]
2512
- ), rt = me(
2513
- // Use callback to make sure `keyRef.current` returns latest result every time
2514
- (..._) => sn(r, w.current, ..._),
2515
- // eslint-disable-next-line react-hooks/exhaustive-deps
2516
- []
2517
- );
2518
- if (Ue(() => {
2519
- E.current = t, F.current = n, b(J) || (we.current = J);
2520
- }), Ue(() => {
2521
- if (!h) return;
2522
- const _ = ye.bind(V, Ge);
2523
- let R = 0;
2524
- const C = us(h, p, (Q, ge = {}) => {
2525
- if (Q == Se.FOCUS_EVENT) {
2526
- const I = Date.now();
2527
- O().revalidateOnFocus && I > R && x() && (R = I + O().focusThrottleInterval, _());
2528
- } else if (Q == Se.RECONNECT_EVENT)
2529
- O().revalidateOnReconnect && x() && _();
2530
- else {
2531
- if (Q == Se.MUTATE_EVENT)
2532
- return ye();
2533
- if (Q == Se.ERROR_REVALIDATE_EVENT)
2534
- return ye(ge);
2535
- }
2536
- });
2537
- return S.current = !1, w.current = h, T.current = !0, X({
2538
- _k: B
2539
- }), D && (b(Y) || be ? _() : qr(_)), () => {
2540
- S.current = !0, C();
2541
- };
2542
- }, [
2543
- h
2544
- ]), Ue(() => {
2545
- let _;
2546
- function R() {
2547
- const C = W(u) ? u(P().data) : u;
2548
- C && _ !== -1 && (_ = setTimeout(j, C));
2549
- }
2550
- function j() {
2551
- !P().error && (c || O().isVisible()) && (i || O().isOnline()) ? ye(Ge).then(R) : R();
2552
- }
2553
- return R(), () => {
2554
- _ && (clearTimeout(_), _ = -1);
2555
- };
2556
- }, [
2557
- u,
2558
- c,
2559
- i,
2560
- h
2561
- ]), gn(se), o && b(Y) && h) {
2562
- if (!pt && be)
2563
- throw new Error("Fallback data is required when using suspense in SSR.");
2564
- E.current = t, F.current = n, S.current = !1;
2565
- const _ = v[h];
2566
- if (!b(_)) {
2567
- const R = rt(_);
2568
- ht(R);
2569
- }
2570
- if (b(pe)) {
2571
- const R = ye(Ge);
2572
- b(se) || (R.status = "fulfilled", R.value = !0), ht(R);
2573
- } else
2574
- throw pe;
2575
- }
2576
- return {
2577
- mutate: rt,
2578
- get data() {
2579
- return re.data = !0, se;
2580
- },
2581
- get error() {
2582
- return re.error = !0, pe;
2583
- },
2584
- get isValidating() {
2585
- return re.isValidating = !0, Oe;
2586
- },
2587
- get isLoading() {
2588
- return re.isLoading = !0, cn;
2589
- }
2590
- };
2591
- }, ds = cs(ls);
2592
- function Ts() {
2593
- const { apiUrl: e, botToken: t } = le(), n = bt({
2594
- apiUrl: e,
2595
- botToken: t
2596
- });
2597
- return ds(n.options, n.apis.fetchPreludeData);
2598
- }
2599
- export {
2600
- et as A,
2601
- Rs as W,
2602
- ie as _,
2603
- _s as a,
2604
- As as b,
2605
- bs as c,
2606
- Es as d,
2607
- Os as e,
2608
- Ts as f,
2609
- ws as g,
2610
- Te as h,
2611
- _t as i,
2612
- Mt as j,
2613
- Or as k,
2614
- le as u
2615
- };
2616
- //# sourceMappingURL=index-C87obATS.js.map