@opencx/widget 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-CAm3rFZk.js +1070 -0
- package/dist/api-CAm3rFZk.js.map +1 -0
- package/dist/api-oIDR-KZx.cjs +2 -0
- package/dist/api-oIDR-KZx.cjs.map +1 -0
- package/dist/basic.cjs +39 -39
- package/dist/basic.cjs.map +1 -1
- package/dist/basic.js +1214 -1213
- package/dist/basic.js.map +1 -1
- package/dist/core/client/api.d.ts +55 -42
- package/dist/core/client/chat.d.ts +10 -4
- package/dist/core/client/contact.d.ts +9 -3
- package/dist/core/client/index.d.ts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/sdk/index.d.ts +5 -4
- package/dist/core/types/contact.d.ts +2 -0
- package/dist/core/types/helpers.d.ts +2 -2
- package/dist/{index-B5YLfjom.cjs → index-CSptf_Dw.cjs} +4 -4
- package/dist/index-CSptf_Dw.cjs.map +1 -0
- package/dist/{index-EZN9_jan.js → index-cUkS-tdv.js} +237 -224
- package/dist/index-cUkS-tdv.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/dist/react-web/core-integration/ChatProvider.d.ts +11 -5
- package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +10 -4
- package/dist/react-web/core-integration/hooks/useChatSession.d.ts +10 -4
- package/dist/react-web/core-integration/hooks/useContact.d.ts +10 -4
- package/dist/react-web/core-integration/hooks/usePreludeData.d.ts +1 -1
- package/dist/react-web/core-integration/hooks/useUploadFiles.d.ts +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist-embed/script.js +117 -112
- package/dist-embed/script.js.map +1 -1
- package/package.json +5 -6
- package/dist/api-BwKgAJ6p.cjs +0 -2
- package/dist/api-BwKgAJ6p.cjs.map +0 -1
- package/dist/api-DRZ9vPwy.js +0 -1360
- package/dist/api-DRZ9vPwy.js.map +0 -1
- package/dist/index-B5YLfjom.cjs.map +0 -1
- package/dist/index-EZN9_jan.js.map +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { User } from '../types';
|
|
1
2
|
import { SendChatDto, WidgetVoteDto } from '../types/schemas-v2';
|
|
2
3
|
import { NormalizedConfig } from './config';
|
|
3
4
|
import { Dto } from '../sdk';
|
|
5
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
4
6
|
export interface ApiCallerOptions {
|
|
5
7
|
config: NormalizedConfig;
|
|
6
8
|
}
|
|
@@ -8,6 +10,19 @@ export declare class ApiCaller {
|
|
|
8
10
|
#private;
|
|
9
11
|
private readonly options;
|
|
10
12
|
constructor(options: ApiCallerOptions);
|
|
13
|
+
constructClientOptions: (user: User) => {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
headers: {
|
|
16
|
+
"X-Bot-Token": string;
|
|
17
|
+
"X-Consumer-Id": string;
|
|
18
|
+
"Content-Type": string;
|
|
19
|
+
Accept: string;
|
|
20
|
+
Authorization: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
createOpenAPIClient: ({ baseUrl, headers, }: ReturnType<typeof this.constructClientOptions>) => import('openapi-fetch').Client<import('../sdk/schema').paths, `${string}/${string}`>;
|
|
24
|
+
createAxiosUploadClient: ({ baseUrl, headers, }: ReturnType<typeof this.constructClientOptions>) => AxiosInstance;
|
|
25
|
+
setUser: (user: User) => void;
|
|
11
26
|
me: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
12
27
|
parameters: {
|
|
13
28
|
query?: never;
|
|
@@ -92,7 +107,7 @@ export declare class ApiCaller {
|
|
|
92
107
|
}, {
|
|
93
108
|
params: {
|
|
94
109
|
header: {
|
|
95
|
-
|
|
110
|
+
"X-Bot-Token": string;
|
|
96
111
|
};
|
|
97
112
|
};
|
|
98
113
|
}, `${string}/${string}`>>;
|
|
@@ -198,21 +213,27 @@ export declare class ApiCaller {
|
|
|
198
213
|
} | undefined;
|
|
199
214
|
};
|
|
200
215
|
}, `${string}/${string}`>>;
|
|
201
|
-
|
|
216
|
+
createContact: (body: Dto["CreateContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
|
|
202
217
|
parameters: {
|
|
203
218
|
query?: never;
|
|
204
|
-
header
|
|
219
|
+
header: {
|
|
220
|
+
"x-bot-token": string;
|
|
221
|
+
};
|
|
205
222
|
path?: never;
|
|
206
223
|
cookie?: never;
|
|
207
224
|
};
|
|
208
|
-
requestBody
|
|
225
|
+
requestBody: {
|
|
226
|
+
content: {
|
|
227
|
+
"application/json": import('../sdk/schema').components["schemas"]["CreateContactDto"];
|
|
228
|
+
};
|
|
229
|
+
};
|
|
209
230
|
responses: {
|
|
210
231
|
200: {
|
|
211
232
|
headers: {
|
|
212
233
|
[name: string]: unknown;
|
|
213
234
|
};
|
|
214
235
|
content: {
|
|
215
|
-
"application/json": import('../sdk/schema').components["schemas"]["
|
|
236
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
|
|
216
237
|
};
|
|
217
238
|
};
|
|
218
239
|
500: {
|
|
@@ -224,7 +245,18 @@ export declare class ApiCaller {
|
|
|
224
245
|
};
|
|
225
246
|
};
|
|
226
247
|
};
|
|
227
|
-
},
|
|
248
|
+
}, {
|
|
249
|
+
params: {
|
|
250
|
+
header: {
|
|
251
|
+
"x-bot-token": string;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
body: {
|
|
255
|
+
email: string;
|
|
256
|
+
name: string;
|
|
257
|
+
};
|
|
258
|
+
}, `${string}/${string}`>>;
|
|
259
|
+
createSession: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
228
260
|
parameters: {
|
|
229
261
|
query?: never;
|
|
230
262
|
header?: never;
|
|
@@ -250,14 +282,11 @@ export declare class ApiCaller {
|
|
|
250
282
|
};
|
|
251
283
|
};
|
|
252
284
|
};
|
|
253
|
-
}
|
|
254
|
-
getSession: (sessionId: string) => Promise<import('openapi-fetch').FetchResponse<{
|
|
285
|
+
}, import('openapi-fetch').FetchOptions<{
|
|
255
286
|
parameters: {
|
|
256
287
|
query?: never;
|
|
257
288
|
header?: never;
|
|
258
|
-
path
|
|
259
|
-
sessionId: string;
|
|
260
|
-
};
|
|
289
|
+
path?: never;
|
|
261
290
|
cookie?: never;
|
|
262
291
|
};
|
|
263
292
|
requestBody?: never;
|
|
@@ -279,41 +308,24 @@ export declare class ApiCaller {
|
|
|
279
308
|
};
|
|
280
309
|
};
|
|
281
310
|
};
|
|
282
|
-
}, {
|
|
283
|
-
|
|
284
|
-
path: {
|
|
285
|
-
sessionId: string;
|
|
286
|
-
};
|
|
287
|
-
};
|
|
288
|
-
}, `${string}/${string}`>>;
|
|
289
|
-
uploadFile: ({ file, abortSignal }: {
|
|
290
|
-
file: {
|
|
291
|
-
id: string;
|
|
292
|
-
file: File;
|
|
293
|
-
};
|
|
294
|
-
abortSignal?: AbortSignal;
|
|
295
|
-
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
311
|
+
}> | undefined, `${string}/${string}`>>;
|
|
312
|
+
getSession: (sessionId: string) => Promise<import('openapi-fetch').FetchResponse<{
|
|
296
313
|
parameters: {
|
|
297
|
-
query
|
|
298
|
-
|
|
314
|
+
query?: never;
|
|
315
|
+
header?: never;
|
|
316
|
+
path: {
|
|
299
317
|
sessionId: string;
|
|
300
318
|
};
|
|
301
|
-
header?: never;
|
|
302
|
-
path?: never;
|
|
303
319
|
cookie?: never;
|
|
304
320
|
};
|
|
305
|
-
requestBody
|
|
306
|
-
content: {
|
|
307
|
-
"multipart/form-data": import('../sdk/schema').components["schemas"]["FileUploadDto"];
|
|
308
|
-
};
|
|
309
|
-
};
|
|
321
|
+
requestBody?: never;
|
|
310
322
|
responses: {
|
|
311
323
|
200: {
|
|
312
324
|
headers: {
|
|
313
325
|
[name: string]: unknown;
|
|
314
326
|
};
|
|
315
327
|
content: {
|
|
316
|
-
"application/json": import('../sdk/schema').components["schemas"]["
|
|
328
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
317
329
|
};
|
|
318
330
|
};
|
|
319
331
|
500: {
|
|
@@ -327,17 +339,18 @@ export declare class ApiCaller {
|
|
|
327
339
|
};
|
|
328
340
|
}, {
|
|
329
341
|
params: {
|
|
330
|
-
|
|
331
|
-
fileId: string;
|
|
342
|
+
path: {
|
|
332
343
|
sessionId: string;
|
|
333
344
|
};
|
|
334
345
|
};
|
|
335
|
-
body: Dto["FileUploadDto"];
|
|
336
|
-
signal: AbortSignal | undefined;
|
|
337
|
-
headers: {
|
|
338
|
-
'Content-Type': string;
|
|
339
|
-
};
|
|
340
346
|
}, `${string}/${string}`>>;
|
|
347
|
+
uploadFile: (file: {
|
|
348
|
+
id: string;
|
|
349
|
+
file: File;
|
|
350
|
+
}, config?: Partial<AxiosRequestConfig>) => Promise<{
|
|
351
|
+
fileName: string;
|
|
352
|
+
fileUrl: string;
|
|
353
|
+
}>;
|
|
341
354
|
vote: (body: WidgetVoteDto) => Promise<import('openapi-fetch').FetchResponse<{
|
|
342
355
|
parameters: {
|
|
343
356
|
query?: never;
|
|
@@ -83,13 +83,19 @@ export declare function createChat(options: ChatOptions): {
|
|
|
83
83
|
sessionStorageKey: string;
|
|
84
84
|
recreateSession: () => Promise<void>;
|
|
85
85
|
contactState: PubSub<{
|
|
86
|
-
contact:
|
|
86
|
+
contact: import('../types/contact').Contact | null;
|
|
87
87
|
loading: LoadingState;
|
|
88
88
|
error: ErrorState;
|
|
89
89
|
}>;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
contactManager: {
|
|
91
|
+
shouldCollectData: () => {
|
|
92
|
+
should: boolean;
|
|
93
|
+
reason: string;
|
|
94
|
+
} | {
|
|
95
|
+
should: boolean;
|
|
96
|
+
reason?: undefined;
|
|
97
|
+
};
|
|
98
|
+
createUnauthenticatedContact: (payload: import('../sdk').Dto["CreateContactDto"]) => Promise<import('../sdk').Dto["WidgetContactDto"] | null>;
|
|
93
99
|
};
|
|
94
100
|
};
|
|
95
101
|
export {};
|
|
@@ -3,8 +3,10 @@ import { ApiCaller } from './api';
|
|
|
3
3
|
import { Platform } from '../platform';
|
|
4
4
|
import { LoadingState, ErrorState } from '../types/helpers';
|
|
5
5
|
import { ConfigInstance } from './config';
|
|
6
|
+
import { Contact } from '../types/contact';
|
|
7
|
+
import { Dto } from '../sdk';
|
|
6
8
|
type ContactState = {
|
|
7
|
-
contact:
|
|
9
|
+
contact: Contact | null;
|
|
8
10
|
loading: LoadingState;
|
|
9
11
|
error: ErrorState;
|
|
10
12
|
};
|
|
@@ -12,12 +14,16 @@ export type CreateContactOptions = {
|
|
|
12
14
|
api: ApiCaller;
|
|
13
15
|
config: ConfigInstance;
|
|
14
16
|
};
|
|
15
|
-
export declare function
|
|
17
|
+
export declare function createContactHandler({ config, api }: CreateContactOptions, platform: Platform): {
|
|
16
18
|
contactState: PubSub<ContactState>;
|
|
17
19
|
shouldCollectData: () => {
|
|
18
20
|
should: boolean;
|
|
19
|
-
reason
|
|
21
|
+
reason: string;
|
|
22
|
+
} | {
|
|
23
|
+
should: boolean;
|
|
24
|
+
reason?: undefined;
|
|
20
25
|
};
|
|
21
26
|
cleanup: () => Promise<void>;
|
|
27
|
+
createUnauthenticatedContact: (payload: Dto["CreateContactDto"]) => Promise<Dto["WidgetContactDto"] | null>;
|
|
22
28
|
};
|
|
23
29
|
export {};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './errors';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './platform';
|
|
4
4
|
export { createChat } from './client/chat';
|
|
5
|
-
export {
|
|
5
|
+
export { createContactHandler } from './client/contact';
|
|
6
6
|
export { createConfig } from './client/config';
|
|
7
7
|
export { ApiCaller } from './client/api';
|
|
8
8
|
export { createLogger } from './platform/logger';
|
package/dist/core/sdk/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { Middleware } from 'openapi-fetch';
|
|
|
2
2
|
import { paths, components } from './schema';
|
|
3
3
|
type Options = {
|
|
4
4
|
baseUrl: string;
|
|
5
|
-
onRequest?: Middleware[
|
|
6
|
-
onResponse?: Middleware[
|
|
7
|
-
onError?: Middleware[
|
|
5
|
+
onRequest?: Middleware["onRequest"];
|
|
6
|
+
onResponse?: Middleware["onResponse"];
|
|
7
|
+
onError?: Middleware["onError"];
|
|
8
8
|
};
|
|
9
9
|
export declare const basicClient: (options: Options) => import('openapi-fetch').Client<paths, `${string}/${string}`>;
|
|
10
|
-
export type
|
|
10
|
+
export type Endpoint = keyof paths;
|
|
11
|
+
export type Dto = components["schemas"];
|
|
11
12
|
export {};
|
|
@@ -3,12 +3,12 @@ export type FunctionReturningPromise = (...args: any[]) => Promise<any>;
|
|
|
3
3
|
export type MakeKeysNotNullable<T, K extends keyof T> = Omit<T, K> & {
|
|
4
4
|
[P in K]-?: NonNullable<T[P]>;
|
|
5
5
|
};
|
|
6
|
-
export type LoadingReason = 'sending_message_to_bot' | 'sending_message_to_agent' | 'creating_session' | 'polling' | 'loading_contact' | 'saving_contact' | 'cleaning_up' | null;
|
|
6
|
+
export type LoadingReason = 'sending_message_to_bot' | 'sending_message_to_agent' | 'creating_session' | 'polling' | 'loading_contact' | 'saving_contact' | 'cleaning_up' | 'creating_unauthenticated_contact' | null;
|
|
7
7
|
export type LoadingState = {
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
reason: LoadingReason;
|
|
10
10
|
};
|
|
11
|
-
export type ErrorCode = 'SESSION_CREATION_FAILED' | 'SESSION_CLEAR_FAILED' | 'SESSION_PERSISTENCE_FAILED' | 'SESSION_POLLING_FAILED' | 'MESSAGES_POLLING_FAILED' | 'MESSAGE_SEND_FAILED' | 'NO_ACTIVE_SESSION' | 'CONTACT_PERSISTENCE_FAILED' | 'CONTACT_LOAD_FAILED' | 'CONTACT_SAVE_FAILED' | 'CONTACT_CLEANUP_FAILED';
|
|
11
|
+
export type ErrorCode = 'SESSION_CREATION_FAILED' | 'SESSION_CLEAR_FAILED' | 'SESSION_PERSISTENCE_FAILED' | 'SESSION_POLLING_FAILED' | 'MESSAGES_POLLING_FAILED' | 'MESSAGE_SEND_FAILED' | 'NO_ACTIVE_SESSION' | 'CONTACT_PERSISTENCE_FAILED' | 'CONTACT_LOAD_FAILED' | 'CONTACT_SAVE_FAILED' | 'CONTACT_CLEANUP_FAILED' | 'CONTACT_CREATION_FAILED';
|
|
12
12
|
export type ErrorState = {
|
|
13
13
|
hasError: boolean;
|
|
14
14
|
message?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var it=Object.defineProperty;var at=(e,t,n)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qe=(e,t,n)=>at(e,typeof t!="symbol"?t+"":t,n);const f=require("react"),ct=require("uuid"),ut=require("react/jsx-runtime"),ne=require("./api-BwKgAJ6p.cjs"),pe=require("zod");function lt(e){const t=f.createContext({});return[()=>{const i=f.useContext(t);if(i===void 0)throw new Error("useSafeContext must be used within a Provider");return i},t.Provider]}class dt{constructor(t){qe(this,"components",[{key:"fallback",component:t=>"fallback"},{key:"loading",component:t=>"loading"}]);const{components:n}=t;if(n&&n.forEach(i=>this.register(i)),this.components.length===0)throw new Error("No components registered");if(!this.get("fallback"))throw new Error("No fallback component registered")}register(t){const n=this.components.findIndex(i=>i.key===t.key);return n!==-1?this.components[n]=t:this.components.push(t),this}get(t){const n=this.components.find(i=>i.key.toUpperCase()===t.toUpperCase());return n||null}getOrFallback(t){return t?this.get(t)||this.get("fallback"):this.get("fallback")}getComponent(t,n){var i;return n?this.getOrFallback(t).component:(i=this.get(t))==null?void 0:i.component}}const ft={ok:"حسنا",yes:"نعم",no:"لا",agree:"موافق",cancel:"إلغاء","yes-exit":"نعم، اخرج","yes-reset":"نعم، إعادة تعيين","no-cancel":"لا، إلغاء","are-you-sure":"هل أنت متأكد؟",recording:"تسجيل","thank-you":"شكرا","sorry-try-again":"عذرا، حاول مرة أخرى","error-occurred":"حدث خطأ","please-try-again":"يرجى المحاولة مرة أخرى","write-a-message":"اكتب رسالة...","send-message":"إرسال رسالة",connected:"متصل",connecting:"جاري الاتصال",reconnecting:"جاري إعادة الاتصال",reconnected:"تم إعادة الاتصال",disconnecting:"جاري قطع الاتصال",disconnected:"قطع الاتصال",error:"خطأ","persist-session":"حفظ الجلسة",settings:"إعدادات",close:"إغلاق",help:"مساعدة",chat:"محادثة",send:"إرسال",copy:"نسخ",copied:"تم النسخ","sound-effects":"التاثيرات الصوتية",language:"اللغة",select:"اختر",agent:"الوكيل",user:"المستخدم",bot:"البوت","reset-conversation-confirm":"هل أنت متأكد من أنك تريد إعادة تعيين المحادثة؟","close-widget":"إغلاق الودجة","got-any-questions":"هل لديك أي أسئلة؟ تحدث معنا!","typical-response-time":"عادة ما نرد في أقل من دقيقة واحدة","session-closed-lead":"تم حل مشكلتك!",exit:"خروج","create-new-ticket":"إنشاء تذكرة جديدة","reset-conversation":"إعادة تعيين المحادثة","welcome-title":"مرحبًا بك في دردشة الدعم الخاصة بنا","welcome-description":"نحن هنا للمساعدة! ابدأ محادثة وسنرد عليك في أقرب وقت ممكن.","your-name":"اسمك","your-email":"عنوان بريدك الإلكتروني","start-chat":"تحدث إلى الدعم","starting-chat":"جاري الاتصال...","hello-greeting":"مرحبًا! كيف يمكننا مساعدتك اليوم؟"},gt={ok:"OK",yes:"Ja",no:"Nein",agree:"Zustimmen",cancel:"Stornieren","yes-exit":"Ja, beenden","yes-reset":"Ja, zurücksetzen","no-cancel":"Nein, abbrechen","are-you-sure":"Sind Sie sicher?",recording:"Aufnahme läuft","thank-you":"Vielen Dank","sorry-try-again":"Entschuldigung, bitte versuchen Sie es erneut","error-occurred":"Ein Fehler ist aufgetreten","please-try-again":"Bitte versuchen Sie es erneut","write-a-message":"Nachricht schreiben...","send-message":"Nachricht senden",connected:"Verbunden",connecting:"Verbindung wird hergestellt",reconnecting:"Verbindung wird wiederhergestellt",reconnected:"Wieder verbunden",disconnecting:"Verbindung wird getrennt",disconnected:"Verbindung getrennt",error:"Fehler","persist-session":"Sitzung beibehalten",settings:"Einstellungen",close:"Schließen",help:"Hilfe",chat:"Chat",send:"Senden",copy:"Kopieren",copied:"Kopiert","sound-effects":"Soundeffekte",language:"Sprache",select:"Auswählen",agent:"Agent",user:"Benutzer",bot:"Bot","got-any-questions":"Haben Sie Fragen? Chatten Sie mit uns!","typical-response-time":"Üblicherweise antworten wir in weniger als 1 Minute","reset-conversation-confirm":"Möchten Sie die Konversation wirklich zurücksetzen?","close-widget":"Widget schließen","session-closed-lead":"Ihr Problem wurde gelöst!","create-new-ticket":"Neues Ticket erstellen",exit:"Beenden","reset-conversation":"Konversation zurücksetzen","welcome-title":"Willkommen in unserem Support-Chat","welcome-description":"Wir sind hier, um zu helfen! Beginnen Sie ein Gespräch und wir werden so schnell wie möglich antworten.","your-name":"Ihr Name","your-email":"Ihre E-Mail-Adresse","start-chat":"Mit dem Support sprechen","starting-chat":"Verbindung wird hergestellt...","hello-greeting":"Hallo! Wie können wir Ihnen heute helfen?"},pt={ok:"OK",yes:"Yes",no:"No",agree:"Agree",cancel:"Cancel","yes-exit":"Yes, exit","yes-reset":"Yes, reset","no-cancel":"No, cancel","are-you-sure":"Are you sure?",recording:"Recording...","thank-you":"Thank you","sorry-try-again":"Sorry, please try again","error-occurred":"An error occurred","please-try-again":"Please try again","write-a-message":"Write a message...","send-message":"Send message",connected:"Connected",connecting:"Connecting",reconnecting:"Reconnecting",reconnected:"Reconnected",disconnecting:"Disconnecting",disconnected:"Disconnected",error:"Error","persist-session":"Persist session",settings:"Settings",close:"Close",help:"Help",chat:"Chat",send:"Send",copy:"Copy",copied:"Copied","sound-effects":"Sound effects",language:"Language",select:"Select",agent:"Agent",user:"User",bot:"Bot","reset-conversation-confirm":"Are you sure you want to reset the conversation?","close-widget":"Close widget","got-any-questions":"Got any questions? Chat with us!","typical-response-time":"Typically respond in less than 1 minute","session-closed-lead":"Your issue has been resolved!","create-new-ticket":"Create new ticket",exit:"Exit","reset-conversation":"Reset conversation","welcome-title":"Welcome to our support chat","welcome-description":"We're here to help! Start a conversation and we'll get back to you as soon as possible.","your-name":"Your name","your-email":"Your email address","start-chat":"Talk to support","starting-chat":"Connecting...","hello-greeting":"Hi there!"},ht={ok:"D'accord",yes:"Oui",no:"Non",agree:"Accepter",cancel:"Annuler","yes-exit":"Oui, quitter","yes-reset":"Oui, réinitialiser","no-cancel":"Non, annuler","are-you-sure":"Êtes-vous sûr ?",recording:"Enregistrement...","thank-you":"Merci","sorry-try-again":"Désolé, veuillez réessayer","error-occurred":"Une erreur s'est produite","please-try-again":"Veuillez réessayer","write-a-message":"Écrivez un message...","send-message":"Envoyer le message",connected:"Connecté",connecting:"Connexion en cours",reconnecting:"Reconnexion en cours",reconnected:"Reconnecté",disconnecting:"Déconnexion en cours",disconnected:"Déconnecté",error:"Erreur","persist-session":"Conserver la session",settings:"Paramètres",close:"Fermer",help:"Aide",chat:"Chat",send:"Envoyer",copy:"Copier",copied:"Copié","sound-effects":"Effets sonores",language:"Langue",select:"Sélectionner",agent:"Agent",user:"Utilisateur",bot:"Bot","reset-conversation-confirm":"Êtes-vous sûr de vouloir réinitialiser la conversation ?","close-widget":"Fermer le widget","got-any-questions":"Vous avez des questions ? Chattez avec nous !","typical-response-time":"Nous répondons généralement en moins d'une minute","session-closed-lead":"Votre problème a été résolu !","create-new-ticket":"Créer un nouveau ticket",exit:"Sortie","reset-conversation":"Réinitialiser la conversation","welcome-title":"Bienvenue dans notre chat de support","welcome-description":"Nous sommes là pour vous aider ! Commencez une conversation et nous vous répondrons dès que possible.","your-name":"Votre nom","your-email":"Votre adresse e-mail","start-chat":"Parler au support","starting-chat":"Connexion...","hello-greeting":"Bonjour ! Comment pouvons-nous vous aider aujourd'hui ?"},mt={ok:"OK",yes:"Ja",no:"Nee",agree:"Akkoord",cancel:"Annuleren","yes-exit":"Ja, afsluiten","yes-reset":"Ja, resetten","no-cancel":"Nee, annuleren","are-you-sure":"Weet u het zeker?",recording:"Opname...","thank-you":"Dank u","sorry-try-again":"Sorry, probeer het opnieuw","error-occurred":"Er is een fout opgetreden","please-try-again":"Probeer het opnieuw","write-a-message":"Schrijf een bericht...","send-message":"Bericht verzenden",connected:"Verbonden",connecting:"Verbinding maken",reconnecting:"Opnieuw verbinding maken",reconnected:"Opnieuw verbonden",disconnecting:"Verbinding verbreken",disconnected:"Verbinding verbroken",error:"Fout","persist-session":"Sessie behouden",settings:"Instellingen",close:"Sluiten",help:"Help",chat:"Chat",send:"Verzenden",copy:"Kopiëren",copied:"Gekopieerd","sound-effects":"Geluidseffecten",language:"Taal",select:"Selecteren",agent:"Agent",user:"Gebruiker",bot:"Bot","reset-conversation-confirm":"Weet u zeker dat u het gesprek wilt resetten?","close-widget":"Widget sluiten","got-any-questions":"Heeft u vragen? Chat met ons!","typical-response-time":"We reageren doorgaans binnen 1 minuut","session-closed-lead":"Uw probleem is opgelost!","create-new-ticket":"Nieuw ticket aanmaken",exit:"Afsluiten","reset-conversation":"Gesprek resetten","welcome-title":"Welkom bij onze supportchat","welcome-description":"We zijn hier om te helpen! Begin een gesprek en we nemen zo snel mogelijk contact met u op.","your-name":"Uw naam","your-email":"Uw e-mailadres","start-chat":"Praat met ondersteuning","starting-chat":"Verbinding maken...","hello-greeting":"Hallo! Hoe kunnen we u vandaag helpen?"},St={ok:"OK",yes:"Sim",no:"Não",agree:"Concordo",cancel:"Cancelar","yes-exit":"Sim, sair","yes-reset":"Sim, redefinir","no-cancel":"Não, cancelar","are-you-sure":"Você tem certeza?",recording:"Gravando...","thank-you":"Obrigado","sorry-try-again":"Desculpe, tente novamente","error-occurred":"Ocorreu um erro","please-try-again":"Por favor, tente novamente","write-a-message":"Escreva uma mensagem...","send-message":"Enviar mensagem",connected:"Conectado",connecting:"Conectando",reconnecting:"Reconectando",reconnected:"Reconectado",disconnecting:"Desconectando",disconnected:"Desconectado",error:"Erro","persist-session":"Persistir sessão",settings:"Configurações",close:"Fechar",help:"Ajuda",chat:"Bate-papo",send:"Enviar",copy:"Copiar",copied:"Copiado","sound-effects":"Efeitos sonoros",language:"Idioma",select:"Selecionar",agent:"Agente",user:"Usuário",bot:"Bot","reset-conversation-confirm":"Você tem certeza de que deseja redefinir a conversa?","close-widget":"Fechar widget","got-any-questions":"Tem alguma dúvida? Converse conosco!","typical-response-time":"Geralmente respondemos em menos de 1 minuto","session-closed-lead":"Seu problema foi resolvido!","create-new-ticket":"Criar novo ticket",exit:"Sair","reset-conversation":"Redefinir conversa","welcome-title":"Bem-vindo ao nosso chat de suporte","welcome-description":"Estamos aqui para ajudar! Inicie uma conversa e responderemos o mais rápido possível.","your-name":"Seu nome","your-email":"Seu endereço de email","start-chat":"Falar com o suporte","starting-chat":"Conectando...","hello-greeting":"Olá! Como podemos ajudar você hoje?"},Et={en:pt,ar:ft,nl:mt,fr:ht,de:gt,pt:St};function vt(e,t){const n=Et[t];return n&&n[e]||""}const yt={getItem:async e=>localStorage.getItem(e),setItem:async(e,t)=>localStorage.setItem(e,t),removeItem:async e=>localStorage.removeItem(e),isAvailable:()=>!0},ae={env:{platform:"web"},storage:yt,logger:ne.createLogger({level:"debug"})},wt=pe.z.object({persistSession:pe.z.boolean().optional(),useSoundEffects:pe.z.boolean().optional()});function Ct({options:e,platform:t}){var g,b;const[n,i]=f.useState({persistSession:((g=e.settings)==null?void 0:g.persistSession)??!1,useSoundEffects:((b=e.settings)==null?void 0:b.useSoundEffects)??!1}),o=f.useMemo(()=>{var s;return{env:{platform:((s=t==null?void 0:t.env)==null?void 0:s.platform)??ae.env.platform},storage:(t==null?void 0:t.storage)??ae.storage,logger:(t==null?void 0:t.logger)??ae.logger,audio:(t==null?void 0:t.audio)??ae.audio}},[t]),a=f.useMemo(()=>ne.createConfig({...e,settings:n},o),[e,o,n]);f.useEffect(()=>{(async()=>{if(ne.isStorageAvailable(o.storage))try{const r=await o.storage.getItem(`${e.token}:settings`);if(r){const c=wt.parse(JSON.parse(r));i(l=>({...l,...c}))}}catch(r){console.error("Failed to load settings:",r)}})()},[o.storage,e.token]);const d=f.useMemo(()=>new ne.ApiCaller({config:a.getConfig()}),[a.config]),p=f.useMemo(()=>ne.createChat({api:d,config:a,platform:o}),[a,o,d]);return f.useEffect(()=>()=>{p.cleanup()},[p]),{config:a,chat:p,api:d,widgetSettings:n,setWidgetSettings:i}}const[K,_t]=lt();function bt({options:e,children:t,components:n,platform:i}){const o=Ct({options:e,platform:i}),a=f.useMemo(()=>new dt({components:n}),[n]),d=f.useMemo(()=>{const p=o.config.getConfig();return{get:(g,b)=>vt(g,p.language)+(b??""),lang:p.language}},[o.config.getConfig().language]);return ut.jsx(_t,{value:{...o,componentStore:a,version:void 0,locale:d},children:t})}function le(e){return f.useSyncExternalStore(e.subscribe,e.getState,e.getState)}function Rt(){const{chat:e}=K();return{chatState:le(e.chatState),chat:e}}function Ot(){const{chat:e}=K(),t=le(e.sessionState);return{chat:e,chatSession:t}}function Pe(){const{config:e}=K();return e}var Ce={exports:{}},he={};/**
|
|
1
|
+
"use strict";var it=Object.defineProperty;var at=(e,t,n)=>t in e?it(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qe=(e,t,n)=>at(e,typeof t!="symbol"?t+"":t,n);const f=require("react"),ct=require("uuid"),ut=require("react/jsx-runtime"),ne=require("./api-oIDR-KZx.cjs"),pe=require("zod");function lt(e){const t=f.createContext({});return[()=>{const i=f.useContext(t);if(i===void 0)throw new Error("useSafeContext must be used within a Provider");return i},t.Provider]}class dt{constructor(t){qe(this,"components",[{key:"fallback",component:t=>"fallback"},{key:"loading",component:t=>"loading"}]);const{components:n}=t;if(n&&n.forEach(i=>this.register(i)),this.components.length===0)throw new Error("No components registered");if(!this.get("fallback"))throw new Error("No fallback component registered")}register(t){const n=this.components.findIndex(i=>i.key===t.key);return n!==-1?this.components[n]=t:this.components.push(t),this}get(t){const n=this.components.find(i=>i.key.toUpperCase()===t.toUpperCase());return n||null}getOrFallback(t){return t?this.get(t)||this.get("fallback"):this.get("fallback")}getComponent(t,n){var i;return n?this.getOrFallback(t).component:(i=this.get(t))==null?void 0:i.component}}const ft={ok:"حسنا",yes:"نعم",no:"لا",agree:"موافق",cancel:"إلغاء","yes-exit":"نعم، اخرج","yes-reset":"نعم، إعادة تعيين","no-cancel":"لا، إلغاء","are-you-sure":"هل أنت متأكد؟",recording:"تسجيل","thank-you":"شكرا","sorry-try-again":"عذرا، حاول مرة أخرى","error-occurred":"حدث خطأ","please-try-again":"يرجى المحاولة مرة أخرى","write-a-message":"اكتب رسالة...","send-message":"إرسال رسالة",connected:"متصل",connecting:"جاري الاتصال",reconnecting:"جاري إعادة الاتصال",reconnected:"تم إعادة الاتصال",disconnecting:"جاري قطع الاتصال",disconnected:"قطع الاتصال",error:"خطأ","persist-session":"حفظ الجلسة",settings:"إعدادات",close:"إغلاق",help:"مساعدة",chat:"محادثة",send:"إرسال",copy:"نسخ",copied:"تم النسخ","sound-effects":"التاثيرات الصوتية",language:"اللغة",select:"اختر",agent:"الوكيل",user:"المستخدم",bot:"البوت","reset-conversation-confirm":"هل أنت متأكد من أنك تريد إعادة تعيين المحادثة؟","close-widget":"إغلاق الودجة","got-any-questions":"هل لديك أي أسئلة؟ تحدث معنا!","typical-response-time":"عادة ما نرد في أقل من دقيقة واحدة","session-closed-lead":"تم حل مشكلتك!",exit:"خروج","create-new-ticket":"إنشاء تذكرة جديدة","reset-conversation":"إعادة تعيين المحادثة","welcome-title":"مرحبًا بك في دردشة الدعم الخاصة بنا","welcome-description":"نحن هنا للمساعدة! ابدأ محادثة وسنرد عليك في أقرب وقت ممكن.","your-name":"اسمك","your-email":"عنوان بريدك الإلكتروني","start-chat":"تحدث إلى الدعم","starting-chat":"جاري الاتصال...","hello-greeting":"مرحبًا! كيف يمكننا مساعدتك اليوم؟"},gt={ok:"OK",yes:"Ja",no:"Nein",agree:"Zustimmen",cancel:"Stornieren","yes-exit":"Ja, beenden","yes-reset":"Ja, zurücksetzen","no-cancel":"Nein, abbrechen","are-you-sure":"Sind Sie sicher?",recording:"Aufnahme läuft","thank-you":"Vielen Dank","sorry-try-again":"Entschuldigung, bitte versuchen Sie es erneut","error-occurred":"Ein Fehler ist aufgetreten","please-try-again":"Bitte versuchen Sie es erneut","write-a-message":"Nachricht schreiben...","send-message":"Nachricht senden",connected:"Verbunden",connecting:"Verbindung wird hergestellt",reconnecting:"Verbindung wird wiederhergestellt",reconnected:"Wieder verbunden",disconnecting:"Verbindung wird getrennt",disconnected:"Verbindung getrennt",error:"Fehler","persist-session":"Sitzung beibehalten",settings:"Einstellungen",close:"Schließen",help:"Hilfe",chat:"Chat",send:"Senden",copy:"Kopieren",copied:"Kopiert","sound-effects":"Soundeffekte",language:"Sprache",select:"Auswählen",agent:"Agent",user:"Benutzer",bot:"Bot","got-any-questions":"Haben Sie Fragen? Chatten Sie mit uns!","typical-response-time":"Üblicherweise antworten wir in weniger als 1 Minute","reset-conversation-confirm":"Möchten Sie die Konversation wirklich zurücksetzen?","close-widget":"Widget schließen","session-closed-lead":"Ihr Problem wurde gelöst!","create-new-ticket":"Neues Ticket erstellen",exit:"Beenden","reset-conversation":"Konversation zurücksetzen","welcome-title":"Willkommen in unserem Support-Chat","welcome-description":"Wir sind hier, um zu helfen! Beginnen Sie ein Gespräch und wir werden so schnell wie möglich antworten.","your-name":"Ihr Name","your-email":"Ihre E-Mail-Adresse","start-chat":"Mit dem Support sprechen","starting-chat":"Verbindung wird hergestellt...","hello-greeting":"Hallo! Wie können wir Ihnen heute helfen?"},pt={ok:"OK",yes:"Yes",no:"No",agree:"Agree",cancel:"Cancel","yes-exit":"Yes, exit","yes-reset":"Yes, reset","no-cancel":"No, cancel","are-you-sure":"Are you sure?",recording:"Recording...","thank-you":"Thank you","sorry-try-again":"Sorry, please try again","error-occurred":"An error occurred","please-try-again":"Please try again","write-a-message":"Write a message...","send-message":"Send message",connected:"Connected",connecting:"Connecting",reconnecting:"Reconnecting",reconnected:"Reconnected",disconnecting:"Disconnecting",disconnected:"Disconnected",error:"Error","persist-session":"Persist session",settings:"Settings",close:"Close",help:"Help",chat:"Chat",send:"Send",copy:"Copy",copied:"Copied","sound-effects":"Sound effects",language:"Language",select:"Select",agent:"Agent",user:"User",bot:"Bot","reset-conversation-confirm":"Are you sure you want to reset the conversation?","close-widget":"Close widget","got-any-questions":"Got any questions? Chat with us!","typical-response-time":"Typically respond in less than 1 minute","session-closed-lead":"Your issue has been resolved!","create-new-ticket":"Create new ticket",exit:"Exit","reset-conversation":"Reset conversation","welcome-title":"Welcome to our support chat","welcome-description":"We're here to help! Start a conversation and we'll get back to you as soon as possible.","your-name":"Your name","your-email":"Your email address","start-chat":"Talk to support","starting-chat":"Connecting...","hello-greeting":"Hi there!"},ht={ok:"D'accord",yes:"Oui",no:"Non",agree:"Accepter",cancel:"Annuler","yes-exit":"Oui, quitter","yes-reset":"Oui, réinitialiser","no-cancel":"Non, annuler","are-you-sure":"Êtes-vous sûr ?",recording:"Enregistrement...","thank-you":"Merci","sorry-try-again":"Désolé, veuillez réessayer","error-occurred":"Une erreur s'est produite","please-try-again":"Veuillez réessayer","write-a-message":"Écrivez un message...","send-message":"Envoyer le message",connected:"Connecté",connecting:"Connexion en cours",reconnecting:"Reconnexion en cours",reconnected:"Reconnecté",disconnecting:"Déconnexion en cours",disconnected:"Déconnecté",error:"Erreur","persist-session":"Conserver la session",settings:"Paramètres",close:"Fermer",help:"Aide",chat:"Chat",send:"Envoyer",copy:"Copier",copied:"Copié","sound-effects":"Effets sonores",language:"Langue",select:"Sélectionner",agent:"Agent",user:"Utilisateur",bot:"Bot","reset-conversation-confirm":"Êtes-vous sûr de vouloir réinitialiser la conversation ?","close-widget":"Fermer le widget","got-any-questions":"Vous avez des questions ? Chattez avec nous !","typical-response-time":"Nous répondons généralement en moins d'une minute","session-closed-lead":"Votre problème a été résolu !","create-new-ticket":"Créer un nouveau ticket",exit:"Sortie","reset-conversation":"Réinitialiser la conversation","welcome-title":"Bienvenue dans notre chat de support","welcome-description":"Nous sommes là pour vous aider ! Commencez une conversation et nous vous répondrons dès que possible.","your-name":"Votre nom","your-email":"Votre adresse e-mail","start-chat":"Parler au support","starting-chat":"Connexion...","hello-greeting":"Bonjour ! Comment pouvons-nous vous aider aujourd'hui ?"},mt={ok:"OK",yes:"Ja",no:"Nee",agree:"Akkoord",cancel:"Annuleren","yes-exit":"Ja, afsluiten","yes-reset":"Ja, resetten","no-cancel":"Nee, annuleren","are-you-sure":"Weet u het zeker?",recording:"Opname...","thank-you":"Dank u","sorry-try-again":"Sorry, probeer het opnieuw","error-occurred":"Er is een fout opgetreden","please-try-again":"Probeer het opnieuw","write-a-message":"Schrijf een bericht...","send-message":"Bericht verzenden",connected:"Verbonden",connecting:"Verbinding maken",reconnecting:"Opnieuw verbinding maken",reconnected:"Opnieuw verbonden",disconnecting:"Verbinding verbreken",disconnected:"Verbinding verbroken",error:"Fout","persist-session":"Sessie behouden",settings:"Instellingen",close:"Sluiten",help:"Help",chat:"Chat",send:"Verzenden",copy:"Kopiëren",copied:"Gekopieerd","sound-effects":"Geluidseffecten",language:"Taal",select:"Selecteren",agent:"Agent",user:"Gebruiker",bot:"Bot","reset-conversation-confirm":"Weet u zeker dat u het gesprek wilt resetten?","close-widget":"Widget sluiten","got-any-questions":"Heeft u vragen? Chat met ons!","typical-response-time":"We reageren doorgaans binnen 1 minuut","session-closed-lead":"Uw probleem is opgelost!","create-new-ticket":"Nieuw ticket aanmaken",exit:"Afsluiten","reset-conversation":"Gesprek resetten","welcome-title":"Welkom bij onze supportchat","welcome-description":"We zijn hier om te helpen! Begin een gesprek en we nemen zo snel mogelijk contact met u op.","your-name":"Uw naam","your-email":"Uw e-mailadres","start-chat":"Praat met ondersteuning","starting-chat":"Verbinding maken...","hello-greeting":"Hallo! Hoe kunnen we u vandaag helpen?"},St={ok:"OK",yes:"Sim",no:"Não",agree:"Concordo",cancel:"Cancelar","yes-exit":"Sim, sair","yes-reset":"Sim, redefinir","no-cancel":"Não, cancelar","are-you-sure":"Você tem certeza?",recording:"Gravando...","thank-you":"Obrigado","sorry-try-again":"Desculpe, tente novamente","error-occurred":"Ocorreu um erro","please-try-again":"Por favor, tente novamente","write-a-message":"Escreva uma mensagem...","send-message":"Enviar mensagem",connected:"Conectado",connecting:"Conectando",reconnecting:"Reconectando",reconnected:"Reconectado",disconnecting:"Desconectando",disconnected:"Desconectado",error:"Erro","persist-session":"Persistir sessão",settings:"Configurações",close:"Fechar",help:"Ajuda",chat:"Bate-papo",send:"Enviar",copy:"Copiar",copied:"Copiado","sound-effects":"Efeitos sonoros",language:"Idioma",select:"Selecionar",agent:"Agente",user:"Usuário",bot:"Bot","reset-conversation-confirm":"Você tem certeza de que deseja redefinir a conversa?","close-widget":"Fechar widget","got-any-questions":"Tem alguma dúvida? Converse conosco!","typical-response-time":"Geralmente respondemos em menos de 1 minuto","session-closed-lead":"Seu problema foi resolvido!","create-new-ticket":"Criar novo ticket",exit:"Sair","reset-conversation":"Redefinir conversa","welcome-title":"Bem-vindo ao nosso chat de suporte","welcome-description":"Estamos aqui para ajudar! Inicie uma conversa e responderemos o mais rápido possível.","your-name":"Seu nome","your-email":"Seu endereço de email","start-chat":"Falar com o suporte","starting-chat":"Conectando...","hello-greeting":"Olá! Como podemos ajudar você hoje?"},Et={en:pt,ar:ft,nl:mt,fr:ht,de:gt,pt:St};function vt(e,t){const n=Et[t];return n&&n[e]||""}const yt={getItem:async e=>localStorage.getItem(e),setItem:async(e,t)=>localStorage.setItem(e,t),removeItem:async e=>localStorage.removeItem(e),isAvailable:()=>!0},ae={env:{platform:"web"},storage:yt,logger:ne.createLogger({level:"debug"})},wt=pe.z.object({persistSession:pe.z.boolean().optional(),useSoundEffects:pe.z.boolean().optional()});function Ct({options:e,platform:t}){var g,b;const[n,i]=f.useState({persistSession:((g=e.settings)==null?void 0:g.persistSession)??!1,useSoundEffects:((b=e.settings)==null?void 0:b.useSoundEffects)??!1}),o=f.useMemo(()=>{var s;return{env:{platform:((s=t==null?void 0:t.env)==null?void 0:s.platform)??ae.env.platform},storage:(t==null?void 0:t.storage)??ae.storage,logger:(t==null?void 0:t.logger)??ae.logger,audio:(t==null?void 0:t.audio)??ae.audio}},[t]),c=f.useMemo(()=>ne.createConfig({...e,settings:n},o),[e,o,n]);f.useEffect(()=>{(async()=>{if(ne.isStorageAvailable(o.storage))try{const r=await o.storage.getItem(`${e.token}:settings`);if(r){const a=wt.parse(JSON.parse(r));i(u=>({...u,...a}))}}catch(r){console.error("Failed to load settings:",r)}})()},[o.storage,e.token]);const d=f.useMemo(()=>new ne.ApiCaller({config:c.getConfig()}),[c.config]),p=f.useMemo(()=>ne.createChat({api:d,config:c,platform:o}),[c,o,d]);return f.useEffect(()=>()=>{p.cleanup()},[p]),{config:c,chat:p,api:d,widgetSettings:n,setWidgetSettings:i}}const[K,_t]=lt();function bt({options:e,children:t,components:n,platform:i}){const o=Ct({options:e,platform:i}),c=f.useMemo(()=>new dt({components:n}),[n]),d=f.useMemo(()=>{const p=o.config.getConfig();return{get:(g,b)=>vt(g,p.language)+(b??""),lang:p.language}},[o.config.getConfig().language]);return ut.jsx(_t,{value:{...o,componentStore:c,version:void 0,locale:d},children:t})}function le(e){return f.useSyncExternalStore(e.subscribe,e.getState,e.getState)}function Rt(){const{chat:e}=K();return{chatState:le(e.chatState),chat:e}}function Ot(){const{chat:e}=K(),t=le(e.sessionState);return{chat:e,chatSession:t}}function Pe(){const{config:e}=K();return e}var Ce={exports:{}},he={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ze;function Tt(){if(ze)return he;ze=1;var e=f;function t(r,
|
|
9
|
+
*/var ze;function Tt(){if(ze)return he;ze=1;var e=f;function t(r,a){return r===a&&(r!==0||1/r===1/a)||r!==r&&a!==a}var n=typeof Object.is=="function"?Object.is:t,i=e.useState,o=e.useEffect,c=e.useLayoutEffect,d=e.useDebugValue;function p(r,a){var u=a(),R=i({inst:{value:u,getSnapshot:a}}),E=R[0].inst,M=R[1];return c(function(){E.value=u,E.getSnapshot=a,g(E)&&M({inst:E})},[r,u,a]),o(function(){return g(E)&&M({inst:E}),r(function(){g(E)&&M({inst:E})})},[r]),d(u),u}function g(r){var a=r.getSnapshot;r=r.value;try{var u=a();return!n(r,u)}catch{return!0}}function b(r,a){return a()}var s=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?b:p;return he.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:s,he}var me={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* use-sync-external-store-shim.development.js
|
|
12
12
|
*
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Be;function At(){return Be||(Be=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=f,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(_){{for(var S=arguments.length,v=new Array(S>1?S-1:0),E=1;E<S;E++)v[E-1]=arguments[E];i("error",_,v)}}function i(_,S,v){{var E=t.ReactDebugCurrentFrame,x=E.getStackAddendum();x!==""&&(S+="%s",v=v.concat([x]));var y=v.map(function(T){return String(T)});y.unshift("Warning: "+S),Function.prototype.apply.call(console[_],console,y)}}function o(_,S){return _===S&&(_!==0||1/_===1/S)||_!==_&&S!==S}var a=typeof Object.is=="function"?Object.is:o,d=e.useState,p=e.useEffect,g=e.useLayoutEffect,b=e.useDebugValue,s=!1,r=!1;function c(_,S,v){s||e.startTransition!==void 0&&(s=!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."));var E=S();if(!r){var x=S();a(E,x)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),r=!0)}var y=d({inst:{value:E,getSnapshot:S}}),T=y[0].inst,L=y[1];return g(function(){T.value=E,T.getSnapshot=S,l(T)&&L({inst:T})},[_,E,S]),p(function(){l(T)&&L({inst:T});var B=function(){l(T)&&L({inst:T})};return _(B)},[_]),b(E),E}function l(_){var S=_.getSnapshot,v=_.value;try{var E=S();return!a(v,E)}catch{return!0}}function O(_,S,v){return S()}var h=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",W=!h,u=W?O:c,J=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u;me.useSyncExternalStore=J,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),me}process.env.NODE_ENV==="production"?Ce.exports=Tt():Ce.exports=At();var Dt=Ce.exports;const j=()=>{},k=j(),Se=Object,m=e=>e===k,U=e=>typeof e=="function",G=(e,t)=>({...e,...t}),Vt=e=>U(e.then),ce=new WeakMap;let Lt=0;const re=e=>{const t=typeof e,n=e&&e.constructor,i=n==Date;let o,a;if(Se(e)===e&&!i&&n!=RegExp){if(o=ce.get(e),o)return o;if(o=++Lt+"~",ce.set(e,o),n==Array){for(o="@",a=0;a<e.length;a++)o+=re(e[a])+",";ce.set(e,o)}if(n==Se){o="#";const d=Se.keys(e).sort();for(;!m(a=d.pop());)m(e[a])||(o+=a+":"+re(e[a])+",");ce.set(e,o)}}else o=i?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},z=new WeakMap,Ee={},ue={},Ae="undefined",de=typeof window!=Ae,_e=typeof document!=Ae,kt=()=>de&&typeof window.requestAnimationFrame!=Ae,Je=(e,t)=>{const n=z.get(e);return[()=>!m(t)&&e.get(t)||Ee,i=>{if(!m(t)){const o=e.get(t);t in ue||(ue[t]=o),n[5](t,G(o,i),o||Ee)}},n[6],()=>!m(t)&&t in ue?ue[t]:!m(t)&&e.get(t)||Ee]};let be=!0;const xt=()=>be,[Re,Oe]=de&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[j,j],It=()=>{const e=_e&&document.visibilityState;return m(e)||e!=="hidden"},Nt=e=>(_e&&document.addEventListener("visibilitychange",e),Re("focus",e),()=>{_e&&document.removeEventListener("visibilitychange",e),Oe("focus",e)}),Ft=e=>{const t=()=>{be=!0,e()},n=()=>{be=!1};return Re("online",t),Re("offline",n),()=>{Oe("online",t),Oe("offline",n)}},Ut={isOnline:xt,isVisible:It},Wt={initFocus:Nt,initReconnect:Ft},He=!f.useId,oe=!de||"Deno"in window,Mt=e=>kt()?window.requestAnimationFrame(e):setTimeout(e,1),ve=oe?f.useEffect:f.useLayoutEffect,ye=typeof navigator<"u"&&navigator.connection,je=!oe&&ye&&(["slow-2g","2g"].includes(ye.effectiveType)||ye.saveData),De=e=>{if(U(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?re(e):"",[e,t]};let qt=0;const Te=()=>++qt,Ye=0,$e=1,Xe=2,zt=3;var te={__proto__:null,ERROR_REVALIDATE_EVENT:zt,FOCUS_EVENT:Ye,MUTATE_EVENT:Xe,RECONNECT_EVENT:$e};async function Ze(...e){const[t,n,i,o]=e,a=G({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let d=a.populateCache;const p=a.rollbackOnError;let g=a.optimisticData;const b=c=>typeof p=="function"?p(c):p!==!1,s=a.throwOnError;if(U(n)){const c=n,l=[],O=t.keys();for(const h of O)!/^\$(inf|sub)\$/.test(h)&&c(t.get(h)._k)&&l.push(h);return Promise.all(l.map(r))}return r(n);async function r(c){const[l]=De(c);if(!l)return;const[O,h]=Je(t,l),[W,u,J,_]=z.get(t),S=()=>{const N=W[l];return(U(a.revalidate)?a.revalidate(O().data,c):a.revalidate!==!1)&&(delete J[l],delete _[l],N&&N[0])?N[0](Xe).then(()=>O().data):O().data};if(e.length<3)return S();let v=i,E;const x=Te();u[l]=[x,0];const y=!m(g),T=O(),L=T.data,B=T._c,P=m(B)?L:B;if(y&&(g=U(g)?g(P,L):g,h({data:g,_c:P})),U(v))try{v=v(P)}catch(N){E=N}if(v&&Vt(v))if(v=await v.catch(N=>{E=N}),x!==u[l][0]){if(E)throw E;return v}else E&&y&&b(E)&&(d=!0,h({data:P,_c:k}));if(d&&!E)if(U(d)){const N=d(v,P);h({data:N,error:k,_c:k})}else h({data:v,error:k,_c:k});if(u[l][1]=Te(),Promise.resolve(S()).then(()=>{h({_c:k})}),E){if(s)throw E;return}return v}}const Ge=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},Bt=(e,t)=>{if(!z.has(e)){const n=G(Wt,t),i={},o=Ze.bind(k,e);let a=j;const d={},p=(s,r)=>{const c=d[s]||[];return d[s]=c,c.push(r),()=>c.splice(c.indexOf(r),1)},g=(s,r,c)=>{e.set(s,r);const l=d[s];if(l)for(const O of l)O(r,c)},b=()=>{if(!z.has(e)&&(z.set(e,[i,{},{},{},o,g,p]),!oe)){const s=n.initFocus(setTimeout.bind(k,Ge.bind(k,i,Ye))),r=n.initReconnect(setTimeout.bind(k,Ge.bind(k,i,$e)));a=()=>{s&&s(),r&&r(),z.delete(e)}}};return b(),[e,o,b,a]}return[e,z.get(e)[4]]},Ht=(e,t,n,i,o)=>{const a=n.errorRetryCount,d=o.retryCount,p=~~((Math.random()+.5)*(1<<(d<8?d:8)))*n.errorRetryInterval;!m(a)&&d>a||setTimeout(i,p,o)},jt=(e,t)=>re(e)==re(t),[Qe,Gt]=Bt(new Map),Kt=G({onLoadingSlow:j,onSuccess:j,onError:j,onErrorRetry:Ht,onDiscarded:j,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:je?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:je?5e3:3e3,compare:jt,isPaused:()=>!1,cache:Qe,mutate:Gt,fallback:{}},Ut),Pt=(e,t)=>{const n=G(e,t);if(t){const{use:i,fallback:o}=e,{use:a,fallback:d}=t;i&&a&&(n.use=i.concat(a)),o&&d&&(n.fallback=G(o,d))}return n},Jt=f.createContext({}),Yt="$inf$",et=de&&window.__SWR_DEVTOOLS_USE__,$t=et?window.__SWR_DEVTOOLS_USE__:[],Xt=()=>{et&&(window.__SWR_DEVTOOLS_REACT__=f)},Zt=e=>U(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Qt=()=>G(Kt,f.useContext(Jt)),en=e=>(t,n,i)=>e(t,n&&((...a)=>{const[d]=De(t),[,,,p]=z.get(Qe);if(d.startsWith(Yt))return n(...a);const g=p[d];return m(g)?n(...a):(delete p[d],g)}),i),tn=$t.concat(en),nn=e=>function(...n){const i=Qt(),[o,a,d]=Zt(n),p=Pt(i,d);let g=e;const{use:b}=p,s=(b||[]).concat(tn);for(let r=s.length;r--;)g=s[r](g);return g(o,a||p.fetcher||null,p)},rn=(e,t,n)=>{const i=t[e]||(t[e]=[]);return i.push(n),()=>{const o=i.indexOf(n);o>=0&&(i[o]=i[i.length-1],i.pop())}};Xt();const Ke=f.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),we={dedupe:!0},on=(e,t,n)=>{const{cache:i,compare:o,suspense:a,fallbackData:d,revalidateOnMount:p,revalidateIfStale:g,refreshInterval:b,refreshWhenHidden:s,refreshWhenOffline:r,keepPreviousData:c}=n,[l,O,h,W]=z.get(i),[u,J]=De(e),_=f.useRef(!1),S=f.useRef(!1),v=f.useRef(u),E=f.useRef(t),x=f.useRef(n),y=()=>x.current,T=()=>y().isVisible()&&y().isOnline(),[L,B,P,N]=Je(i,u),Y=f.useRef({}).current,tt=m(d)?n.fallback[u]:d,Ve=(w,C)=>{for(const D in Y){const R=D;if(R==="data"){if(!o(w[R],C[R])&&(!m(w[R])||!o(ie,C[R])))return!1}else if(C[R]!==w[R])return!1}return!0},Le=f.useMemo(()=>{const w=!u||!t?!1:m(p)?y().isPaused()||a?!1:m(g)?!0:g:p,C=V=>{const M=G(V);return delete M._k,w?{isValidating:!0,isLoading:!0,...M}:M},D=L(),R=N(),F=C(D),Q=D===R?F:C(R);let A=F;return[()=>{const V=C(L());return Ve(V,A)?(A.data=V.data,A.isLoading=V.isLoading,A.isValidating=V.isValidating,A.error=V.error,A):(A=V,V)},()=>Q]},[i,u]),$=Dt.useSyncExternalStore(f.useCallback(w=>P(u,(C,D)=>{Ve(D,C)||w()}),[i,u]),Le[0],Le[1]),ke=!_.current,nt=l[u]&&l[u].length>0,X=$.data,Z=m(X)?tt:X,se=$.error,xe=f.useRef(Z),ie=c?m(X)?xe.current:X:Z,Ie=nt&&!m(se)?!1:ke&&!m(p)?p:y().isPaused()?!1:a?m(Z)?!1:g:m(Z)||g,Ne=!!(u&&t&&ke&&Ie),rt=m($.isValidating)?Ne:$.isValidating,ot=m($.isLoading)?Ne:$.isLoading,ee=f.useCallback(async w=>{const C=E.current;if(!u||!C||S.current||y().isPaused())return!1;let D,R,F=!0;const Q=w||{},A=!h[u]||!Q.dedupe,V=()=>He?!S.current&&u===v.current&&_.current:u===v.current,M={isValidating:!1,isLoading:!1},Ue=()=>{B(M)},We=()=>{const I=h[u];I&&I[1]===R&&delete h[u]},Me={isValidating:!0};m(L().data)&&(Me.isLoading=!0);try{if(A&&(B(Me),n.loadingTimeout&&m(L().data)&&setTimeout(()=>{F&&V()&&y().onLoadingSlow(u,n)},n.loadingTimeout),h[u]=[C(J),Te()]),[D,R]=h[u],D=await D,A&&setTimeout(We,n.dedupingInterval),!h[u]||h[u][1]!==R)return A&&V()&&y().onDiscarded(u),!1;M.error=k;const I=O[u];if(!m(I)&&(R<=I[0]||R<=I[1]||I[1]===0))return Ue(),A&&V()&&y().onDiscarded(u),!1;const q=L().data;M.data=o(q,D)?q:D,A&&V()&&y().onSuccess(D,u,n)}catch(I){We();const q=y(),{shouldRetryOnError:fe}=q;q.isPaused()||(M.error=I,A&&V()&&(q.onError(I,u,q),(fe===!0||U(fe)&&fe(I))&&(!y().revalidateOnFocus||!y().revalidateOnReconnect||T())&&q.onErrorRetry(I,u,q,st=>{const ge=l[u];ge&&ge[0]&&ge[0](te.ERROR_REVALIDATE_EVENT,st)},{retryCount:(Q.retryCount||0)+1,dedupe:!0})))}return F=!1,Ue(),!0},[u,i]),Fe=f.useCallback((...w)=>Ze(i,v.current,...w),[]);if(ve(()=>{E.current=t,x.current=n,m(X)||(xe.current=X)}),ve(()=>{if(!u)return;const w=ee.bind(k,we);let C=0;const R=rn(u,l,(F,Q={})=>{if(F==te.FOCUS_EVENT){const A=Date.now();y().revalidateOnFocus&&A>C&&T()&&(C=A+y().focusThrottleInterval,w())}else if(F==te.RECONNECT_EVENT)y().revalidateOnReconnect&&T()&&w();else{if(F==te.MUTATE_EVENT)return ee();if(F==te.ERROR_REVALIDATE_EVENT)return ee(Q)}});return S.current=!1,v.current=u,_.current=!0,B({_k:J}),Ie&&(m(Z)||oe?w():Mt(w)),()=>{S.current=!0,R()}},[u]),ve(()=>{let w;function C(){const R=U(b)?b(L().data):b;R&&w!==-1&&(w=setTimeout(D,R))}function D(){!L().error&&(s||y().isVisible())&&(r||y().isOnline())?ee(we).then(C):C()}return C(),()=>{w&&(clearTimeout(w),w=-1)}},[b,s,r,u]),f.useDebugValue(ie),a&&m(Z)&&u){if(!He&&oe)throw new Error("Fallback data is required when using suspense in SSR.");E.current=t,x.current=n,S.current=!1;const w=W[u];if(!m(w)){const C=Fe(w);Ke(C)}if(m(se)){const C=ee(we);m(ie)||(C.status="fulfilled",C.value=!0),Ke(C)}else throw se}return{mutate:Fe,get data(){return Y.data=!0,ie},get error(){return Y.error=!0,se},get isValidating(){return Y.isValidating=!0,rt},get isLoading(){return Y.isLoading=!0,ot}}},sn=nn(on);function an(){const{api:e}=K(),t=Pe();return sn([t.config.apiUrl],e.widgetPrelude)}function cn(){const{locale:e}=K();return e}const H=new Map;function un(){const[e,t]=f.useState([]),{api:n}=K();function i(s){const r=s.map(c=>({file:c,id:ct.v4(),status:"pending",progress:0}));t(c=>[...c,...r]),r.forEach(d)}function o(s,r){t(c=>c.map(l=>l.id===s?{...l,...r}:l))}function a(s){t(r=>r.filter(c=>c.id!==s))}const d=async s=>{const r=new AbortController;H.set(s.id,r),t(O=>O.map(h=>h.id===s.id?{...h,status:"uploading",progress:0}:h));const{data:c,error:l}=await n.uploadFile({file:s,abortSignal:r.signal});c?o(s.id,{status:"success",fileUrl:c.fileUrl,progress:100}):r.signal.aborted||o(s.id,{status:"error",error:l.message||"Upload failed",progress:0}),H.delete(s.id)},p=s=>{const r=H.get(s);r&&(r.abort(),H.delete(s)),a(s)},g=f.useMemo(()=>e.filter(s=>s.status==="success"&&s.fileUrl),[e]);function b(){H.forEach(s=>s.abort()),H.clear(),t([])}return f.useEffect(()=>()=>{H.forEach(s=>s.abort()),H.clear()},[]),{allFiles:e,appendFiles:i,handleCancelUpload:p,successFiles:g,emptyTheFiles:b,getFileById:s=>e.find(r=>r.id===s),getUploadProgress:s=>{var r;return((r=e.find(c=>c.id===s))==null?void 0:r.progress)??0},getUploadStatus:s=>{var r;return(r=e.find(c=>c.id===s))==null?void 0:r.status},hasErrors:e.some(s=>s.status==="error"),isUploading:e.some(s=>s.status==="uploading")}}function ln(){const{chat:e}=K();return{contactState:le(e.contactState),shouldCollectData:e.shouldCollectData}}exports.ChatProvider=bt;exports.useChat=K;exports.useChatSession=Ot;exports.useChatState=Rt;exports.useConfig=Pe;exports.useContact=ln;exports.useLocale=cn;exports.usePreludeData=an;exports.usePubsub=le;exports.useUploadFiles=un;
|
|
18
|
-
//# sourceMappingURL=index-
|
|
17
|
+
*/var Be;function At(){return Be||(Be=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=f,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(_){{for(var m=arguments.length,v=new Array(m>1?m-1:0),S=1;S<m;S++)v[S-1]=arguments[S];i("error",_,v)}}function i(_,m,v){{var S=t.ReactDebugCurrentFrame,x=S.getStackAddendum();x!==""&&(m+="%s",v=v.concat([x]));var y=v.map(function(T){return String(T)});y.unshift("Warning: "+m),Function.prototype.apply.call(console[_],console,y)}}function o(_,m){return _===m&&(_!==0||1/_===1/m)||_!==_&&m!==m}var c=typeof Object.is=="function"?Object.is:o,d=e.useState,p=e.useEffect,g=e.useLayoutEffect,b=e.useDebugValue,s=!1,r=!1;function a(_,m,v){s||e.startTransition!==void 0&&(s=!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."));var S=m();if(!r){var x=m();c(S,x)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),r=!0)}var y=d({inst:{value:S,getSnapshot:m}}),T=y[0].inst,L=y[1];return g(function(){T.value=S,T.getSnapshot=m,u(T)&&L({inst:T})},[_,S,m]),p(function(){u(T)&&L({inst:T});var B=function(){u(T)&&L({inst:T})};return _(B)},[_]),b(S),S}function u(_){var m=_.getSnapshot,v=_.value;try{var S=m();return!c(v,S)}catch{return!0}}function R(_,m,v){return m()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",M=!E,l=M?R:a,J=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:l;me.useSyncExternalStore=J,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),me}process.env.NODE_ENV==="production"?Ce.exports=Tt():Ce.exports=At();var Dt=Ce.exports;const j=()=>{},k=j(),Se=Object,h=e=>e===k,U=e=>typeof e=="function",G=(e,t)=>({...e,...t}),Vt=e=>U(e.then),ce=new WeakMap;let Lt=0;const re=e=>{const t=typeof e,n=e&&e.constructor,i=n==Date;let o,c;if(Se(e)===e&&!i&&n!=RegExp){if(o=ce.get(e),o)return o;if(o=++Lt+"~",ce.set(e,o),n==Array){for(o="@",c=0;c<e.length;c++)o+=re(e[c])+",";ce.set(e,o)}if(n==Se){o="#";const d=Se.keys(e).sort();for(;!h(c=d.pop());)h(e[c])||(o+=c+":"+re(e[c])+",");ce.set(e,o)}}else o=i?e.toJSON():t=="symbol"?e.toString():t=="string"?JSON.stringify(e):""+e;return o},z=new WeakMap,Ee={},ue={},Ae="undefined",de=typeof window!=Ae,_e=typeof document!=Ae,kt=()=>de&&typeof window.requestAnimationFrame!=Ae,Je=(e,t)=>{const n=z.get(e);return[()=>!h(t)&&e.get(t)||Ee,i=>{if(!h(t)){const o=e.get(t);t in ue||(ue[t]=o),n[5](t,G(o,i),o||Ee)}},n[6],()=>!h(t)&&t in ue?ue[t]:!h(t)&&e.get(t)||Ee]};let be=!0;const xt=()=>be,[Re,Oe]=de&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[j,j],Nt=()=>{const e=_e&&document.visibilityState;return h(e)||e!=="hidden"},It=e=>(_e&&document.addEventListener("visibilitychange",e),Re("focus",e),()=>{_e&&document.removeEventListener("visibilitychange",e),Oe("focus",e)}),Ft=e=>{const t=()=>{be=!0,e()},n=()=>{be=!1};return Re("online",t),Re("offline",n),()=>{Oe("online",t),Oe("offline",n)}},Ut={isOnline:xt,isVisible:Nt},Mt={initFocus:It,initReconnect:Ft},He=!f.useId,oe=!de||"Deno"in window,Wt=e=>kt()?window.requestAnimationFrame(e):setTimeout(e,1),ve=oe?f.useEffect:f.useLayoutEffect,ye=typeof navigator<"u"&&navigator.connection,je=!oe&&ye&&(["slow-2g","2g"].includes(ye.effectiveType)||ye.saveData),De=e=>{if(U(e))try{e=e()}catch{e=""}const t=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?re(e):"",[e,t]};let qt=0;const Te=()=>++qt,Ye=0,$e=1,Xe=2,zt=3;var te={__proto__:null,ERROR_REVALIDATE_EVENT:zt,FOCUS_EVENT:Ye,MUTATE_EVENT:Xe,RECONNECT_EVENT:$e};async function Ze(...e){const[t,n,i,o]=e,c=G({populateCache:!0,throwOnError:!0},typeof o=="boolean"?{revalidate:o}:o||{});let d=c.populateCache;const p=c.rollbackOnError;let g=c.optimisticData;const b=a=>typeof p=="function"?p(a):p!==!1,s=c.throwOnError;if(U(n)){const a=n,u=[],R=t.keys();for(const E of R)!/^\$(inf|sub)\$/.test(E)&&a(t.get(E)._k)&&u.push(E);return Promise.all(u.map(r))}return r(n);async function r(a){const[u]=De(a);if(!u)return;const[R,E]=Je(t,u),[M,l,J,_]=z.get(t),m=()=>{const I=M[u];return(U(c.revalidate)?c.revalidate(R().data,a):c.revalidate!==!1)&&(delete J[u],delete _[u],I&&I[0])?I[0](Xe).then(()=>R().data):R().data};if(e.length<3)return m();let v=i,S;const x=Te();l[u]=[x,0];const y=!h(g),T=R(),L=T.data,B=T._c,P=h(B)?L:B;if(y&&(g=U(g)?g(P,L):g,E({data:g,_c:P})),U(v))try{v=v(P)}catch(I){S=I}if(v&&Vt(v))if(v=await v.catch(I=>{S=I}),x!==l[u][0]){if(S)throw S;return v}else S&&y&&b(S)&&(d=!0,E({data:P,_c:k}));if(d&&!S)if(U(d)){const I=d(v,P);E({data:I,error:k,_c:k})}else E({data:v,error:k,_c:k});if(l[u][1]=Te(),Promise.resolve(m()).then(()=>{E({_c:k})}),S){if(s)throw S;return}return v}}const Ge=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},Bt=(e,t)=>{if(!z.has(e)){const n=G(Mt,t),i={},o=Ze.bind(k,e);let c=j;const d={},p=(s,r)=>{const a=d[s]||[];return d[s]=a,a.push(r),()=>a.splice(a.indexOf(r),1)},g=(s,r,a)=>{e.set(s,r);const u=d[s];if(u)for(const R of u)R(r,a)},b=()=>{if(!z.has(e)&&(z.set(e,[i,{},{},{},o,g,p]),!oe)){const s=n.initFocus(setTimeout.bind(k,Ge.bind(k,i,Ye))),r=n.initReconnect(setTimeout.bind(k,Ge.bind(k,i,$e)));c=()=>{s&&s(),r&&r(),z.delete(e)}}};return b(),[e,o,b,c]}return[e,z.get(e)[4]]},Ht=(e,t,n,i,o)=>{const c=n.errorRetryCount,d=o.retryCount,p=~~((Math.random()+.5)*(1<<(d<8?d:8)))*n.errorRetryInterval;!h(c)&&d>c||setTimeout(i,p,o)},jt=(e,t)=>re(e)==re(t),[Qe,Gt]=Bt(new Map),Kt=G({onLoadingSlow:j,onSuccess:j,onError:j,onErrorRetry:Ht,onDiscarded:j,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:je?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:je?5e3:3e3,compare:jt,isPaused:()=>!1,cache:Qe,mutate:Gt,fallback:{}},Ut),Pt=(e,t)=>{const n=G(e,t);if(t){const{use:i,fallback:o}=e,{use:c,fallback:d}=t;i&&c&&(n.use=i.concat(c)),o&&d&&(n.fallback=G(o,d))}return n},Jt=f.createContext({}),Yt="$inf$",et=de&&window.__SWR_DEVTOOLS_USE__,$t=et?window.__SWR_DEVTOOLS_USE__:[],Xt=()=>{et&&(window.__SWR_DEVTOOLS_REACT__=f)},Zt=e=>U(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],Qt=()=>G(Kt,f.useContext(Jt)),en=e=>(t,n,i)=>e(t,n&&((...c)=>{const[d]=De(t),[,,,p]=z.get(Qe);if(d.startsWith(Yt))return n(...c);const g=p[d];return h(g)?n(...c):(delete p[d],g)}),i),tn=$t.concat(en),nn=e=>function(...n){const i=Qt(),[o,c,d]=Zt(n),p=Pt(i,d);let g=e;const{use:b}=p,s=(b||[]).concat(tn);for(let r=s.length;r--;)g=s[r](g);return g(o,c||p.fetcher||null,p)},rn=(e,t,n)=>{const i=t[e]||(t[e]=[]);return i.push(n),()=>{const o=i.indexOf(n);o>=0&&(i[o]=i[i.length-1],i.pop())}};Xt();const Ke=f.use||(e=>{if(e.status==="pending")throw e;if(e.status==="fulfilled")return e.value;throw e.status==="rejected"?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),we={dedupe:!0},on=(e,t,n)=>{const{cache:i,compare:o,suspense:c,fallbackData:d,revalidateOnMount:p,revalidateIfStale:g,refreshInterval:b,refreshWhenHidden:s,refreshWhenOffline:r,keepPreviousData:a}=n,[u,R,E,M]=z.get(i),[l,J]=De(e),_=f.useRef(!1),m=f.useRef(!1),v=f.useRef(l),S=f.useRef(t),x=f.useRef(n),y=()=>x.current,T=()=>y().isVisible()&&y().isOnline(),[L,B,P,I]=Je(i,l),Y=f.useRef({}).current,tt=h(d)?n.fallback[l]:d,Ve=(w,C)=>{for(const D in Y){const O=D;if(O==="data"){if(!o(w[O],C[O])&&(!h(w[O])||!o(ie,C[O])))return!1}else if(C[O]!==w[O])return!1}return!0},Le=f.useMemo(()=>{const w=!l||!t?!1:h(p)?y().isPaused()||c?!1:h(g)?!0:g:p,C=V=>{const W=G(V);return delete W._k,w?{isValidating:!0,isLoading:!0,...W}:W},D=L(),O=I(),F=C(D),Q=D===O?F:C(O);let A=F;return[()=>{const V=C(L());return Ve(V,A)?(A.data=V.data,A.isLoading=V.isLoading,A.isValidating=V.isValidating,A.error=V.error,A):(A=V,V)},()=>Q]},[i,l]),$=Dt.useSyncExternalStore(f.useCallback(w=>P(l,(C,D)=>{Ve(D,C)||w()}),[i,l]),Le[0],Le[1]),ke=!_.current,nt=u[l]&&u[l].length>0,X=$.data,Z=h(X)?tt:X,se=$.error,xe=f.useRef(Z),ie=a?h(X)?xe.current:X:Z,Ne=nt&&!h(se)?!1:ke&&!h(p)?p:y().isPaused()?!1:c?h(Z)?!1:g:h(Z)||g,Ie=!!(l&&t&&ke&&Ne),rt=h($.isValidating)?Ie:$.isValidating,ot=h($.isLoading)?Ie:$.isLoading,ee=f.useCallback(async w=>{const C=S.current;if(!l||!C||m.current||y().isPaused())return!1;let D,O,F=!0;const Q=w||{},A=!E[l]||!Q.dedupe,V=()=>He?!m.current&&l===v.current&&_.current:l===v.current,W={isValidating:!1,isLoading:!1},Ue=()=>{B(W)},Me=()=>{const N=E[l];N&&N[1]===O&&delete E[l]},We={isValidating:!0};h(L().data)&&(We.isLoading=!0);try{if(A&&(B(We),n.loadingTimeout&&h(L().data)&&setTimeout(()=>{F&&V()&&y().onLoadingSlow(l,n)},n.loadingTimeout),E[l]=[C(J),Te()]),[D,O]=E[l],D=await D,A&&setTimeout(Me,n.dedupingInterval),!E[l]||E[l][1]!==O)return A&&V()&&y().onDiscarded(l),!1;W.error=k;const N=R[l];if(!h(N)&&(O<=N[0]||O<=N[1]||N[1]===0))return Ue(),A&&V()&&y().onDiscarded(l),!1;const q=L().data;W.data=o(q,D)?q:D,A&&V()&&y().onSuccess(D,l,n)}catch(N){Me();const q=y(),{shouldRetryOnError:fe}=q;q.isPaused()||(W.error=N,A&&V()&&(q.onError(N,l,q),(fe===!0||U(fe)&&fe(N))&&(!y().revalidateOnFocus||!y().revalidateOnReconnect||T())&&q.onErrorRetry(N,l,q,st=>{const ge=u[l];ge&&ge[0]&&ge[0](te.ERROR_REVALIDATE_EVENT,st)},{retryCount:(Q.retryCount||0)+1,dedupe:!0})))}return F=!1,Ue(),!0},[l,i]),Fe=f.useCallback((...w)=>Ze(i,v.current,...w),[]);if(ve(()=>{S.current=t,x.current=n,h(X)||(xe.current=X)}),ve(()=>{if(!l)return;const w=ee.bind(k,we);let C=0;const O=rn(l,u,(F,Q={})=>{if(F==te.FOCUS_EVENT){const A=Date.now();y().revalidateOnFocus&&A>C&&T()&&(C=A+y().focusThrottleInterval,w())}else if(F==te.RECONNECT_EVENT)y().revalidateOnReconnect&&T()&&w();else{if(F==te.MUTATE_EVENT)return ee();if(F==te.ERROR_REVALIDATE_EVENT)return ee(Q)}});return m.current=!1,v.current=l,_.current=!0,B({_k:J}),Ne&&(h(Z)||oe?w():Wt(w)),()=>{m.current=!0,O()}},[l]),ve(()=>{let w;function C(){const O=U(b)?b(L().data):b;O&&w!==-1&&(w=setTimeout(D,O))}function D(){!L().error&&(s||y().isVisible())&&(r||y().isOnline())?ee(we).then(C):C()}return C(),()=>{w&&(clearTimeout(w),w=-1)}},[b,s,r,l]),f.useDebugValue(ie),c&&h(Z)&&l){if(!He&&oe)throw new Error("Fallback data is required when using suspense in SSR.");S.current=t,x.current=n,m.current=!1;const w=M[l];if(!h(w)){const C=Fe(w);Ke(C)}if(h(se)){const C=ee(we);h(ie)||(C.status="fulfilled",C.value=!0),Ke(C)}else throw se}return{mutate:Fe,get data(){return Y.data=!0,ie},get error(){return Y.error=!0,se},get isValidating(){return Y.isValidating=!0,rt},get isLoading(){return Y.isLoading=!0,ot}}},sn=nn(on);function an(){const{api:e}=K(),t=Pe();return sn([t.config.apiUrl],e.widgetPrelude)}function cn(){const{locale:e}=K();return e}const H=new Map;function un(){const[e,t]=f.useState([]),{api:n}=K();function i(s){const r=s.map(a=>({file:a,id:ct.v4(),status:"pending",progress:0}));t(a=>[...a,...r]),r.forEach(d)}function o(s,r){t(a=>a.map(u=>u.id===s?{...u,...r}:u))}function c(s){t(r=>r.filter(a=>a.id!==s))}const d=async s=>{const r=new AbortController;H.set(s.id,r);try{t(u=>u.map(R=>R.id===s.id?{...R,status:"uploading",progress:0}:R));const a=await n.uploadFile(s,{signal:r.signal,onUploadProgress:u=>{if(!u.total)return;const R=Math.round(u.loaded*100/u.total);o(s.id,{progress:R})}});o(s.id,{status:"success",fileUrl:a.fileUrl,progress:100})}catch(a){r.signal.aborted||o(s.id,{status:"error",error:a instanceof Error?a.message:"Upload failed",progress:0})}finally{H.delete(s.id)}},p=s=>{const r=H.get(s);r&&(r.abort(),H.delete(s)),c(s)},g=f.useMemo(()=>e.filter(s=>s.status==="success"&&s.fileUrl),[e]);function b(){H.forEach(s=>s.abort()),H.clear(),t([])}return f.useEffect(()=>()=>{H.forEach(s=>s.abort()),H.clear()},[]),{allFiles:e,appendFiles:i,handleCancelUpload:p,successFiles:g,emptyTheFiles:b,getFileById:s=>e.find(r=>r.id===s),getUploadProgress:s=>{var r;return((r=e.find(a=>a.id===s))==null?void 0:r.progress)??0},getUploadStatus:s=>{var r;return(r=e.find(a=>a.id===s))==null?void 0:r.status},hasErrors:e.some(s=>s.status==="error"),isUploading:e.some(s=>s.status==="uploading")}}function ln(){const{chat:e}=K();return{contactState:le(e.contactState),contactManager:e.contactManager}}exports.ChatProvider=bt;exports.useChat=K;exports.useChatSession=Ot;exports.useChatState=Rt;exports.useConfig=Pe;exports.useContact=ln;exports.useLocale=cn;exports.usePreludeData=an;exports.usePubsub=le;exports.useUploadFiles=un;
|
|
18
|
+
//# sourceMappingURL=index-CSptf_Dw.cjs.map
|