@elqnt/chat 1.0.2 → 1.0.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/index.js CHANGED
@@ -1,192 +1,238 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
- var _chunkE2FJX52Rjs = require('./chunk-E2FJX52R.js');
177
-
178
-
179
- var _chunk3PXNBY7Jjs = require('./chunk-3PXNBY7J.js');
180
-
181
-
182
- var _chunkDTFTLFSYjs = require('./chunk-DTFTLFSY.js');
1
+ "use client";
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // index.tsx
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ AdminChatHeader: () => AdminChatHeader,
35
+ AdminChatInput: () => AdminChatInput,
36
+ AdminChatList: () => AdminChatList,
37
+ AdminChatListItem: () => AdminChatListItem,
38
+ AgentStatusAway: () => AgentStatusAway,
39
+ AgentStatusBusy: () => AgentStatusBusy,
40
+ AgentStatusOffline: () => AgentStatusOffline,
41
+ AgentStatusOnline: () => AgentStatusOnline,
42
+ AssignChatToAgentSubject: () => AssignChatToAgentSubject,
43
+ AttachmentTypeActions: () => AttachmentTypeActions,
44
+ AttachmentTypeArticles: () => AttachmentTypeArticles,
45
+ AttachmentTypeAudio: () => AttachmentTypeAudio,
46
+ AttachmentTypeBullets: () => AttachmentTypeBullets,
47
+ AttachmentTypeData: () => AttachmentTypeData,
48
+ AttachmentTypeDocument: () => AttachmentTypeDocument,
49
+ AttachmentTypeDocumentAnalysis: () => AttachmentTypeDocumentAnalysis,
50
+ AttachmentTypeDocumentSources: () => AttachmentTypeDocumentSources,
51
+ AttachmentTypeImage: () => AttachmentTypeImage,
52
+ AttachmentTypeKGNodes: () => AttachmentTypeKGNodes,
53
+ AttachmentTypeLocation: () => AttachmentTypeLocation,
54
+ AttachmentTypeRecords: () => AttachmentTypeRecords,
55
+ AttachmentTypeReferences: () => AttachmentTypeReferences,
56
+ AttachmentTypeSticker: () => AttachmentTypeSticker,
57
+ AttachmentTypeSubsections: () => AttachmentTypeSubsections,
58
+ AttachmentTypeVideo: () => AttachmentTypeVideo,
59
+ ChatArchiveSubjectPattern: () => ChatArchiveSubjectPattern,
60
+ ChatEventTypeAgentActivityPing: () => ChatEventTypeAgentActivityPing,
61
+ ChatEventTypeAgentChatAssigned: () => ChatEventTypeAgentChatAssigned,
62
+ ChatEventTypeAgentChatCompleted: () => ChatEventTypeAgentChatCompleted,
63
+ ChatEventTypeAgentContextUpdate: () => ChatEventTypeAgentContextUpdate,
64
+ ChatEventTypeAgentExecutionEnded: () => ChatEventTypeAgentExecutionEnded,
65
+ ChatEventTypeAgentExecutionStarted: () => ChatEventTypeAgentExecutionStarted,
66
+ ChatEventTypeAgentSessionEnd: () => ChatEventTypeAgentSessionEnd,
67
+ ChatEventTypeAgentSessionStart: () => ChatEventTypeAgentSessionStart,
68
+ ChatEventTypeAgentStatusChange: () => ChatEventTypeAgentStatusChange,
69
+ ChatEventTypeBlockUser: () => ChatEventTypeBlockUser,
70
+ ChatEventTypeCSATRequest: () => ChatEventTypeCSATRequest,
71
+ ChatEventTypeCSATResponse: () => ChatEventTypeCSATResponse,
72
+ ChatEventTypeCSATSurvey: () => ChatEventTypeCSATSurvey,
73
+ ChatEventTypeChatEnded: () => ChatEventTypeChatEnded,
74
+ ChatEventTypeChatRemoved: () => ChatEventTypeChatRemoved,
75
+ ChatEventTypeChatUpdated: () => ChatEventTypeChatUpdated,
76
+ ChatEventTypeClientAction: () => ChatEventTypeClientAction,
77
+ ChatEventTypeClientActionCallback: () => ChatEventTypeClientActionCallback,
78
+ ChatEventTypeCreateRoom: () => ChatEventTypeCreateRoom,
79
+ ChatEventTypeDeleteRoom: () => ChatEventTypeDeleteRoom,
80
+ ChatEventTypeDelivered: () => ChatEventTypeDelivered,
81
+ ChatEventTypeEndChat: () => ChatEventTypeEndChat,
82
+ ChatEventTypeError: () => ChatEventTypeError,
83
+ ChatEventTypeGetAgents: () => ChatEventTypeGetAgents,
84
+ ChatEventTypeGetAgentsResponse: () => ChatEventTypeGetAgentsResponse,
85
+ ChatEventTypeGetOnlineUsers: () => ChatEventTypeGetOnlineUsers,
86
+ ChatEventTypeHumanAgentJoined: () => ChatEventTypeHumanAgentJoined,
87
+ ChatEventTypeHumanAgentLeft: () => ChatEventTypeHumanAgentLeft,
88
+ ChatEventTypeInviteUser: () => ChatEventTypeInviteUser,
89
+ ChatEventTypeJoinRoom: () => ChatEventTypeJoinRoom,
90
+ ChatEventTypeLeaveRoom: () => ChatEventTypeLeaveRoom,
91
+ ChatEventTypeListChats: () => ChatEventTypeListChats,
92
+ ChatEventTypeListRooms: () => ChatEventTypeListRooms,
93
+ ChatEventTypeLoadAgentContext: () => ChatEventTypeLoadAgentContext,
94
+ ChatEventTypeLoadAgentContextResponse: () => ChatEventTypeLoadAgentContextResponse,
95
+ ChatEventTypeLoadChat: () => ChatEventTypeLoadChat,
96
+ ChatEventTypeLoadChatResponse: () => ChatEventTypeLoadChatResponse,
97
+ ChatEventTypeMentionUser: () => ChatEventTypeMentionUser,
98
+ ChatEventTypeMessage: () => ChatEventTypeMessage,
99
+ ChatEventTypeMessageDeleted: () => ChatEventTypeMessageDeleted,
100
+ ChatEventTypeMessageDeletedResponse: () => ChatEventTypeMessageDeletedResponse,
101
+ ChatEventTypeMessageEdited: () => ChatEventTypeMessageEdited,
102
+ ChatEventTypeMessageEditedResponse: () => ChatEventTypeMessageEditedResponse,
103
+ ChatEventTypeMessageReaction: () => ChatEventTypeMessageReaction,
104
+ ChatEventTypeMessageReactionResponse: () => ChatEventTypeMessageReactionResponse,
105
+ ChatEventTypeMessageReply: () => ChatEventTypeMessageReply,
106
+ ChatEventTypeMessageStatusUpdate: () => ChatEventTypeMessageStatusUpdate,
107
+ ChatEventTypeNewChat: () => ChatEventTypeNewChat,
108
+ ChatEventTypeNewChatCreated: () => ChatEventTypeNewChatCreated,
109
+ ChatEventTypeObserverJoined: () => ChatEventTypeObserverJoined,
110
+ ChatEventTypeObserverLeft: () => ChatEventTypeObserverLeft,
111
+ ChatEventTypeOnlineUsersResponse: () => ChatEventTypeOnlineUsersResponse,
112
+ ChatEventTypePing: () => ChatEventTypePing,
113
+ ChatEventTypePlanApproved: () => ChatEventTypePlanApproved,
114
+ ChatEventTypePlanCompleted: () => ChatEventTypePlanCompleted,
115
+ ChatEventTypePlanPendingApproval: () => ChatEventTypePlanPendingApproval,
116
+ ChatEventTypePlanRejected: () => ChatEventTypePlanRejected,
117
+ ChatEventTypePong: () => ChatEventTypePong,
118
+ ChatEventTypeRead: () => ChatEventTypeRead,
119
+ ChatEventTypeReconnected: () => ChatEventTypeReconnected,
120
+ ChatEventTypeRoomCreated: () => ChatEventTypeRoomCreated,
121
+ ChatEventTypeRoomDeleted: () => ChatEventTypeRoomDeleted,
122
+ ChatEventTypeRoomUpdated: () => ChatEventTypeRoomUpdated,
123
+ ChatEventTypeRoomUserJoined: () => ChatEventTypeRoomUserJoined,
124
+ ChatEventTypeRoomUserLeft: () => ChatEventTypeRoomUserLeft,
125
+ ChatEventTypeRoomsResponse: () => ChatEventTypeRoomsResponse,
126
+ ChatEventTypeStepCompleted: () => ChatEventTypeStepCompleted,
127
+ ChatEventTypeStepFailed: () => ChatEventTypeStepFailed,
128
+ ChatEventTypeStepStarted: () => ChatEventTypeStepStarted,
129
+ ChatEventTypeStoppedTyping: () => ChatEventTypeStoppedTyping,
130
+ ChatEventTypeSummaryUpdate: () => ChatEventTypeSummaryUpdate,
131
+ ChatEventTypeSyncMetadata: () => ChatEventTypeSyncMetadata,
132
+ ChatEventTypeSyncMetadataResponse: () => ChatEventTypeSyncMetadataResponse,
133
+ ChatEventTypeSyncUserSession: () => ChatEventTypeSyncUserSession,
134
+ ChatEventTypeSyncUserSessionResponse: () => ChatEventTypeSyncUserSessionResponse,
135
+ ChatEventTypeTyping: () => ChatEventTypeTyping,
136
+ ChatEventTypeUpdateRoom: () => ChatEventTypeUpdateRoom,
137
+ ChatEventTypeUserActivity: () => ChatEventTypeUserActivity,
138
+ ChatEventTypeUserActivityUpdate: () => ChatEventTypeUserActivityUpdate,
139
+ ChatEventTypeUserInvited: () => ChatEventTypeUserInvited,
140
+ ChatEventTypeUserJoined: () => ChatEventTypeUserJoined,
141
+ ChatEventTypeUserLeft: () => ChatEventTypeUserLeft,
142
+ ChatEventTypeUserPresenceChanged: () => ChatEventTypeUserPresenceChanged,
143
+ ChatEventTypeUserPresenceEnd: () => ChatEventTypeUserPresenceEnd,
144
+ ChatEventTypeUserPresenceStart: () => ChatEventTypeUserPresenceStart,
145
+ ChatEventTypeUserRemoved: () => ChatEventTypeUserRemoved,
146
+ ChatEventTypeUserStatusChange: () => ChatEventTypeUserStatusChange,
147
+ ChatEventTypeUserSuggestedActionSelected: () => ChatEventTypeUserSuggestedActionSelected,
148
+ ChatEventTypeUserSuggestedActions: () => ChatEventTypeUserSuggestedActions,
149
+ ChatEventTypeWaiting: () => ChatEventTypeWaiting,
150
+ ChatEventTypeWaitingForAgent: () => ChatEventTypeWaitingForAgent,
151
+ ChatHeader: () => ChatHeader,
152
+ ChatHumanAgentActions: () => ChatHumanAgentActions,
153
+ ChatInput: () => ChatInput,
154
+ ChatMessages: () => ChatMessages,
155
+ ChatRoleAI: () => ChatRoleAI,
156
+ ChatRoleDataQuery: () => ChatRoleDataQuery,
157
+ ChatRoleEvent: () => ChatRoleEvent,
158
+ ChatRoleHumanAgent: () => ChatRoleHumanAgent,
159
+ ChatRoleObserver: () => ChatRoleObserver,
160
+ ChatRoleSystem: () => ChatRoleSystem,
161
+ ChatRoleTool: () => ChatRoleTool,
162
+ ChatRoleUser: () => ChatRoleUser,
163
+ ChatSessionStatusActive: () => ChatSessionStatusActive,
164
+ ChatSessionStatusExpired: () => ChatSessionStatusExpired,
165
+ ChatSessionStatusIdle: () => ChatSessionStatusIdle,
166
+ ChatStatusAbandoned: () => ChatStatusAbandoned,
167
+ ChatStatusActive: () => ChatStatusActive,
168
+ ChatStatusArchived: () => ChatStatusArchived,
169
+ ChatStatusClosed: () => ChatStatusClosed,
170
+ ChatStatusCustomerUI: () => ChatStatusCustomerUI,
171
+ ChatStatusDisconnected: () => ChatStatusDisconnected,
172
+ ChatTypeCustomerSupport: () => ChatTypeCustomerSupport,
173
+ ChatTypeDirect: () => ChatTypeDirect,
174
+ ChatTypeGroup: () => ChatTypeGroup,
175
+ ChatTypePrivateRoom: () => ChatTypePrivateRoom,
176
+ ChatTypePublicRoom: () => ChatTypePublicRoom,
177
+ ChatTypingIndicator: () => ChatTypingIndicator,
178
+ CompleteChatByAgentSubject: () => CompleteChatByAgentSubject,
179
+ CreateAgentQueueSubject: () => CreateAgentQueueSubject,
180
+ DeleteAgentQueueSubject: () => DeleteAgentQueueSubject,
181
+ EndAgentSessionSubject: () => EndAgentSessionSubject,
182
+ GenericChatWidget: () => GenericChatWidget,
183
+ GetActiveChatCountSubject: () => GetActiveChatCountSubject,
184
+ GetActiveChatsSubject: () => GetActiveChatsSubject,
185
+ GetAgentQueuesSubject: () => GetAgentQueuesSubject,
186
+ GetAgentSessionSubject: () => GetAgentSessionSubject,
187
+ GetChatSubject: () => GetChatSubject,
188
+ GetDailyChatCountSubject: () => GetDailyChatCountSubject,
189
+ GetOnlineAgentCountSubject: () => GetOnlineAgentCountSubject,
190
+ GetOnlineAgentsSubject: () => GetOnlineAgentsSubject,
191
+ GetOnlineUsersSubject: () => GetOnlineUsersSubject,
192
+ GetQueueChatCountSubject: () => GetQueueChatCountSubject,
193
+ GetQueueChatsSubject: () => GetQueueChatsSubject,
194
+ GetUserChatsSubject: () => GetUserChatsSubject,
195
+ GetWaitingForAgentChatCountSubject: () => GetWaitingForAgentChatCountSubject,
196
+ GetWaitingForAgentChatsSubject: () => GetWaitingForAgentChatsSubject,
197
+ MessageStatusDelivered: () => MessageStatusDelivered,
198
+ MessageStatusFailed: () => MessageStatusFailed,
199
+ MessageStatusRead: () => MessageStatusRead,
200
+ MessageStatusSending: () => MessageStatusSending,
201
+ MessageStatusSent: () => MessageStatusSent,
202
+ QueueTypeComplexity: () => QueueTypeComplexity,
203
+ QueueTypeDepartment: () => QueueTypeDepartment,
204
+ QueueTypePriority: () => QueueTypePriority,
205
+ QueueTypeSkill: () => QueueTypeSkill,
206
+ QueueTypes: () => QueueTypes,
207
+ SetupOrgSubject: () => SetupOrgSubject,
208
+ StartAgentSessionSubject: () => StartAgentSessionSubject,
209
+ TriggerAnalyticsScanSubject: () => TriggerAnalyticsScanSubject,
210
+ UpdateAgentLastActivitySubject: () => UpdateAgentLastActivitySubject,
211
+ UpdateAgentQueueSubject: () => UpdateAgentQueueSubject,
212
+ UpdateAgentStatusSubject: () => UpdateAgentStatusSubject,
213
+ UpdateUserStatusSubject: () => UpdateUserStatusSubject,
214
+ UserStatusAway: () => UserStatusAway,
215
+ UserStatusBusy: () => UserStatusBusy,
216
+ UserStatusOffline: () => UserStatusOffline,
217
+ UserStatusOnline: () => UserStatusOnline,
218
+ WebSocketChatAdminContext: () => WebSocketChatAdminContext,
219
+ WebSocketChatAdminProvider: () => WebSocketChatAdminProvider,
220
+ WebSocketChatCustomerContext: () => WebSocketChatCustomerContext,
221
+ WebSocketChatCustomerProvider: () => WebSocketChatCustomerProvider,
222
+ useWebSocketChatAdmin: () => useWebSocketChatAdmin,
223
+ useWebSocketChatAdminContext: () => useWebSocketChatAdminContext,
224
+ useWebSocketChatBase: () => useWebSocketChatBase,
225
+ useWebSocketChatCustomer: () => useWebSocketChatCustomer,
226
+ useWebSocketChatCustomerContext: () => useWebSocketChatCustomerContext
227
+ });
228
+ module.exports = __toCommonJS(index_exports);
183
229
 
184
230
  // components/admin/admin-chat-input.tsx
185
- var _auth = require('@elqnt/auth');
186
- var _ksuid = require('ksuid'); var _ksuid2 = _interopRequireDefault(_ksuid);
231
+ var import_auth = require("@elqnt/auth");
232
+ var import_ksuid = __toESM(require("ksuid"));
187
233
 
188
234
  // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
189
- var _react = require('react');
235
+ var import_react2 = require("react");
190
236
 
191
237
  // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
192
238
  var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
@@ -195,7 +241,7 @@ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
195
241
  }).join(" ").trim();
196
242
 
197
243
  // ../../node_modules/lucide-react/dist/esm/Icon.js
198
-
244
+ var import_react = require("react");
199
245
 
200
246
  // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
201
247
  var defaultAttributes = {
@@ -211,7 +257,7 @@ var defaultAttributes = {
211
257
  };
212
258
 
213
259
  // ../../node_modules/lucide-react/dist/esm/Icon.js
214
- var Icon = _react.forwardRef.call(void 0,
260
+ var Icon = (0, import_react.forwardRef)(
215
261
  ({
216
262
  color = "currentColor",
217
263
  size = 24,
@@ -222,7 +268,7 @@ var Icon = _react.forwardRef.call(void 0,
222
268
  iconNode,
223
269
  ...rest
224
270
  }, ref) => {
225
- return _react.createElement.call(void 0,
271
+ return (0, import_react.createElement)(
226
272
  "svg",
227
273
  {
228
274
  ref,
@@ -235,7 +281,7 @@ var Icon = _react.forwardRef.call(void 0,
235
281
  ...rest
236
282
  },
237
283
  [
238
- ...iconNode.map(([tag, attrs]) => _react.createElement.call(void 0, tag, attrs)),
284
+ ...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
239
285
  ...Array.isArray(children) ? children : [children]
240
286
  ]
241
287
  );
@@ -244,8 +290,8 @@ var Icon = _react.forwardRef.call(void 0,
244
290
 
245
291
  // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
246
292
  var createLucideIcon = (iconName, iconNode) => {
247
- const Component = _react.forwardRef.call(void 0,
248
- ({ className, ...props }, ref) => _react.createElement.call(void 0, Icon, {
293
+ const Component = (0, import_react2.forwardRef)(
294
+ ({ className, ...props }, ref) => (0, import_react2.createElement)(Icon, {
249
295
  ref,
250
296
  iconNode,
251
297
  className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
@@ -383,23 +429,1071 @@ var __iconNode14 = [
383
429
  var User = createLucideIcon("User", __iconNode14);
384
430
 
385
431
  // components/admin/admin-chat-input.tsx
432
+ var import_react7 = require("react");
433
+
434
+ // context/websocket-chat-admin-context.tsx
435
+ var import_react6 = require("react");
436
+
437
+ // hooks/use-websocket-chat-admin.ts
438
+ var import_react4 = require("react");
439
+
440
+ // models/chat-models.ts
441
+ var ChatStatusActive = "active";
442
+ var ChatStatusDisconnected = "disconnected";
443
+ var ChatStatusAbandoned = "abandoned";
444
+ var ChatStatusClosed = "closed";
445
+ var ChatStatusArchived = "archived";
446
+ var ChatTypeCustomerSupport = "customer_support";
447
+ var ChatTypePublicRoom = "public_room";
448
+ var ChatTypePrivateRoom = "private_room";
449
+ var ChatTypeDirect = "direct";
450
+ var ChatTypeGroup = "group";
451
+ var ChatRoleUser = "user";
452
+ var ChatRoleAI = "ai";
453
+ var ChatRoleEvent = "event";
454
+ var ChatRoleHumanAgent = "humanAgent";
455
+ var ChatRoleObserver = "observer";
456
+ var ChatRoleDataQuery = "dataQuery";
457
+ var ChatRoleSystem = "system";
458
+ var ChatRoleTool = "tool";
459
+ var AgentStatusOnline = "online";
460
+ var AgentStatusAway = "away";
461
+ var AgentStatusBusy = "busy";
462
+ var AgentStatusOffline = "offline";
463
+ var ChatEventTypeUserJoined = "user_joined";
464
+ var ChatEventTypeUserLeft = "user_left";
465
+ var ChatEventTypeTyping = "typing";
466
+ var ChatEventTypeStoppedTyping = "stopped_typing";
467
+ var ChatEventTypeRead = "read";
468
+ var ChatEventTypeDelivered = "delivered";
469
+ var ChatEventTypeReconnected = "reconnected";
470
+ var ChatEventTypeError = "error";
471
+ var ChatEventTypeWaiting = "waiting";
472
+ var ChatEventTypeLoadChat = "load_chat";
473
+ var ChatEventTypeLoadChatResponse = "load_chat_response";
474
+ var ChatEventTypeMessage = "message";
475
+ var ChatEventTypeWaitingForAgent = "waiting_for_agent";
476
+ var ChatEventTypeMessageStatusUpdate = "message_status_update";
477
+ var ChatEventTypeHumanAgentJoined = "human_agent_joined";
478
+ var ChatEventTypeHumanAgentLeft = "human_agent_left";
479
+ var ChatEventTypeObserverJoined = "observer_joined";
480
+ var ChatEventTypeObserverLeft = "observer_left";
481
+ var ChatEventTypeListChats = "list_chats";
482
+ var ChatEventTypeChatUpdated = "chat_updated";
483
+ var ChatEventTypeChatRemoved = "chat_removed";
484
+ var ChatEventTypeSyncMetadata = "sync_metadata";
485
+ var ChatEventTypeSyncMetadataResponse = "sync_metadata_response";
486
+ var ChatEventTypeSyncUserSession = "sync_user_session";
487
+ var ChatEventTypeSyncUserSessionResponse = "sync_user_session_response";
488
+ var ChatEventTypeClientAction = "client_action";
489
+ var ChatEventTypeClientActionCallback = "client_action_callback";
490
+ var ChatEventTypeBlockUser = "block_user";
491
+ var ChatEventTypeCreateRoom = "create_room";
492
+ var ChatEventTypeRoomCreated = "room_created";
493
+ var ChatEventTypeJoinRoom = "join_room";
494
+ var ChatEventTypeLeaveRoom = "leave_room";
495
+ var ChatEventTypeDeleteRoom = "delete_room";
496
+ var ChatEventTypeRoomDeleted = "room_deleted";
497
+ var ChatEventTypeUpdateRoom = "update_room";
498
+ var ChatEventTypeRoomUpdated = "room_updated";
499
+ var ChatEventTypeInviteUser = "invite_user";
500
+ var ChatEventTypeUserInvited = "user_invited";
501
+ var ChatEventTypeRoomUserJoined = "room_user_joined";
502
+ var ChatEventTypeRoomUserLeft = "room_user_left";
503
+ var ChatEventTypeUserRemoved = "user_removed";
504
+ var ChatEventTypeListRooms = "list_rooms";
505
+ var ChatEventTypeRoomsResponse = "rooms_response";
506
+ var ChatEventTypeMessageEdited = "message_edited";
507
+ var ChatEventTypeMessageDeleted = "message_deleted";
508
+ var ChatEventTypeMessageReaction = "message_reaction";
509
+ var ChatEventTypeMessageReply = "message_reply";
510
+ var ChatEventTypeMentionUser = "mention_user";
511
+ var ChatEventTypeMessageEditedResponse = "message_edited_response";
512
+ var ChatEventTypeMessageDeletedResponse = "message_deleted_response";
513
+ var ChatEventTypeMessageReactionResponse = "message_reaction_response";
514
+ var ChatEventTypeUserPresenceStart = "user_presence_start";
515
+ var ChatEventTypeUserPresenceEnd = "user_presence_end";
516
+ var ChatEventTypeUserStatusChange = "user_status_change";
517
+ var ChatEventTypeUserActivity = "user_activity";
518
+ var ChatEventTypeUserPresenceChanged = "user_presence_changed";
519
+ var ChatEventTypeUserActivityUpdate = "user_activity_update";
520
+ var ChatEventTypeGetOnlineUsers = "get_online_users";
521
+ var ChatEventTypeOnlineUsersResponse = "online_users";
522
+ var ChatEventTypeEndChat = "end_chat";
523
+ var ChatEventTypeChatEnded = "chat_ended";
524
+ var ChatEventTypeAgentSessionStart = "agent_session_start";
525
+ var ChatEventTypeAgentSessionEnd = "agent_session_end";
526
+ var ChatEventTypeAgentStatusChange = "agent_status_change";
527
+ var ChatEventTypeAgentActivityPing = "agent_activity_ping";
528
+ var ChatEventTypeAgentChatAssigned = "agent_chat_assigned";
529
+ var ChatEventTypeAgentChatCompleted = "agent_chat_completed";
530
+ var ChatEventTypeGetAgents = "get_agents";
531
+ var ChatEventTypeGetAgentsResponse = "get_agents_response";
532
+ var ChatEventTypeCSATRequest = "csat_request";
533
+ var ChatEventTypeCSATSurvey = "show_csat_survey";
534
+ var ChatEventTypeCSATResponse = "csat_response";
535
+ var ChatEventTypeUserSuggestedActions = "user_suggested_actions";
536
+ var ChatEventTypeUserSuggestedActionSelected = "user_suggested_action_selected";
537
+ var ChatEventTypeSummaryUpdate = "summary_update";
538
+ var ChatEventTypeAgentContextUpdate = "agent_context_update";
539
+ var ChatEventTypeAgentExecutionStarted = "agent_execution_started";
540
+ var ChatEventTypeAgentExecutionEnded = "agent_execution_ended";
541
+ var ChatEventTypeLoadAgentContext = "load_agent_context";
542
+ var ChatEventTypeLoadAgentContextResponse = "load_agent_context_response";
543
+ var ChatEventTypePlanPendingApproval = "plan_pending_approval";
544
+ var ChatEventTypePlanApproved = "plan_approved";
545
+ var ChatEventTypePlanRejected = "plan_rejected";
546
+ var ChatEventTypePlanCompleted = "plan_completed";
547
+ var ChatEventTypeStepStarted = "step_started";
548
+ var ChatEventTypeStepCompleted = "step_completed";
549
+ var ChatEventTypeStepFailed = "step_failed";
550
+ var ChatEventTypeNewChat = "new_chat";
551
+ var ChatEventTypeNewChatCreated = "new_chat_created";
552
+ var ChatEventTypePing = "ping";
553
+ var ChatEventTypePong = "pong";
554
+ var MessageStatusSending = "sending";
555
+ var MessageStatusSent = "sent";
556
+ var MessageStatusDelivered = "delivered";
557
+ var MessageStatusRead = "read";
558
+ var MessageStatusFailed = "failed";
559
+ var AttachmentTypeDocument = "document";
560
+ var AttachmentTypeDocumentAnalysis = "document_analysis";
561
+ var AttachmentTypeImage = "image";
562
+ var AttachmentTypeAudio = "audio";
563
+ var AttachmentTypeVideo = "video";
564
+ var AttachmentTypeLocation = "location";
565
+ var AttachmentTypeReferences = "references";
566
+ var AttachmentTypeSubsections = "subsections";
567
+ var AttachmentTypeArticles = "articles";
568
+ var AttachmentTypeRecords = "records";
569
+ var AttachmentTypeActions = "actions";
570
+ var AttachmentTypeBullets = "bullets";
571
+ var AttachmentTypeSticker = "sticker";
572
+ var AttachmentTypeData = "data";
573
+ var AttachmentTypeKGNodes = "kgNodes";
574
+ var AttachmentTypeDocumentSources = "document_sources";
575
+ var ChatSessionStatusActive = "active";
576
+ var ChatSessionStatusIdle = "idle";
577
+ var ChatSessionStatusExpired = "expired";
578
+ var UserStatusOnline = "online";
579
+ var UserStatusAway = "away";
580
+ var UserStatusBusy = "busy";
581
+ var UserStatusOffline = "offline";
582
+ var QueueTypes = {
583
+ skill: { value: "skill", label: "Skill-based", description: "Route by agent expertise and skills" },
584
+ priority: { value: "priority", label: "Priority-based", description: "Route by customer tier and urgency level" },
585
+ department: { value: "department", label: "Department-based", description: "Route by business function alignment" },
586
+ complexity: { value: "complexity", label: "Complexity-based", description: "Route by issue difficulty assessment" }
587
+ };
588
+ var QueueTypeSkill = "skill";
589
+ var QueueTypePriority = "priority";
590
+ var QueueTypeDepartment = "department";
591
+ var QueueTypeComplexity = "complexity";
592
+ var GetWaitingForAgentChatCountSubject = "chat.get_waiting_for_agent_chat_count";
593
+ var GetActiveChatCountSubject = "chat.get_active_chat_count";
594
+ var GetWaitingForAgentChatsSubject = "chat.get_waiting_for_agent_chats";
595
+ var GetActiveChatsSubject = "chat.get_active_chats";
596
+ var GetUserChatsSubject = "chat.get_user_chats";
597
+ var GetChatSubject = "chat.get_chat";
598
+ var ChatArchiveSubjectPattern = "chat.archive.%s.server";
599
+ var StartAgentSessionSubject = "chat.agent_session.start";
600
+ var EndAgentSessionSubject = "chat.agent_session.end";
601
+ var UpdateAgentStatusSubject = "chat.agent_session.update_status";
602
+ var UpdateAgentLastActivitySubject = "chat.agent_session.update_last_activity";
603
+ var AssignChatToAgentSubject = "chat.agent_session.assign_chat";
604
+ var CompleteChatByAgentSubject = "chat.agent_session.complete_chat";
605
+ var GetAgentSessionSubject = "chat.agent_session.get";
606
+ var GetOnlineAgentsSubject = "chat.agent_session.get_online_agents";
607
+ var GetOnlineAgentCountSubject = "chat.agent_session.get_online_agent_count";
608
+ var CreateAgentQueueSubject = "chat.agent_queue.create";
609
+ var GetAgentQueuesSubject = "chat.agent_queue.get";
610
+ var UpdateAgentQueueSubject = "chat.agent_queue.update";
611
+ var DeleteAgentQueueSubject = "chat.agent_queue.delete";
612
+ var GetQueueChatsSubject = "chat.queue.get_chats";
613
+ var GetQueueChatCountSubject = "chat.queue.get_chat_count";
614
+ var GetDailyChatCountSubject = "chat.get_daily_chat_count";
615
+ var UpdateUserStatusSubject = "chat.user.status.update";
616
+ var GetOnlineUsersSubject = "chat.users.online.get";
617
+ var TriggerAnalyticsScanSubject = "chat.analytics.trigger-scan";
618
+ var SetupOrgSubject = "chat.org.setup";
619
+
620
+ // hooks/use-websocket-chat-base.ts
621
+ var import_react3 = require("react");
622
+ var createDefaultLogger = (debug) => ({
623
+ debug: debug ? console.log : () => {
624
+ },
625
+ info: console.info,
626
+ warn: console.warn,
627
+ error: console.error
628
+ });
629
+ var DEFAULT_RETRY_CONFIG = {
630
+ maxRetries: 10,
631
+ intervals: [1e3, 2e3, 5e3],
632
+ backoffMultiplier: 1.5,
633
+ maxBackoffTime: 3e4
634
+ };
635
+ var DEFAULT_QUEUE_CONFIG = {
636
+ maxSize: 100,
637
+ dropStrategy: "oldest"
638
+ };
639
+ var DEFAULT_HEARTBEAT_INTERVAL = 3e4;
640
+ var DEFAULT_HEARTBEAT_TIMEOUT = 5e3;
641
+ function isChatEvent(data) {
642
+ return data && typeof data === "object" && (typeof data.type === "string" || data.message);
643
+ }
644
+ var useWebSocketChatBase = ({
645
+ serverBaseUrl,
646
+ orgId,
647
+ clientType,
648
+ product,
649
+ onMessage,
650
+ retryConfig = DEFAULT_RETRY_CONFIG,
651
+ queueConfig = DEFAULT_QUEUE_CONFIG,
652
+ debug = false,
653
+ logger = createDefaultLogger(debug),
654
+ heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL,
655
+ heartbeatTimeout = DEFAULT_HEARTBEAT_TIMEOUT
656
+ }) => {
657
+ const [connectionState, setConnectionState] = (0, import_react3.useState)("disconnected");
658
+ const [error, setError] = (0, import_react3.useState)(void 0);
659
+ const [startTime, setStartTime] = (0, import_react3.useState)(void 0);
660
+ const [metrics, setMetrics] = (0, import_react3.useState)({
661
+ latency: 0,
662
+ messagesSent: 0,
663
+ messagesReceived: 0,
664
+ messagesQueued: 0,
665
+ reconnectCount: 0
666
+ });
667
+ const wsRef = (0, import_react3.useRef)(void 0);
668
+ const reconnectTimeoutRef = (0, import_react3.useRef)(void 0);
669
+ const retryCountRef = (0, import_react3.useRef)(0);
670
+ const messageQueueRef = (0, import_react3.useRef)([]);
671
+ const mountedRef = (0, import_react3.useRef)(false);
672
+ const currentChatKeyRef = (0, import_react3.useRef)(void 0);
673
+ const currentUserIdRef = (0, import_react3.useRef)(void 0);
674
+ const intentionalDisconnectRef = (0, import_react3.useRef)(false);
675
+ const eventHandlersRef = (0, import_react3.useRef)(
676
+ /* @__PURE__ */ new Map()
677
+ );
678
+ const onMessageRef = (0, import_react3.useRef)(onMessage);
679
+ const pendingMessagesRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
680
+ const heartbeatIntervalRef = (0, import_react3.useRef)(void 0);
681
+ const heartbeatTimeoutRef = (0, import_react3.useRef)(void 0);
682
+ const lastPongRef = (0, import_react3.useRef)(Date.now());
683
+ const chatCreationPromiseRef = (0, import_react3.useRef)(null);
684
+ const loadChatRetryMapRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
685
+ (0, import_react3.useEffect)(() => {
686
+ onMessageRef.current = onMessage;
687
+ }, [onMessage]);
688
+ const isConnected = connectionState === "connected";
689
+ const on = (0, import_react3.useCallback)((eventType, handler) => {
690
+ if (!eventHandlersRef.current.has(eventType)) {
691
+ eventHandlersRef.current.set(eventType, /* @__PURE__ */ new Set());
692
+ }
693
+ eventHandlersRef.current.get(eventType).add(handler);
694
+ return () => off(eventType, handler);
695
+ }, []);
696
+ const off = (0, import_react3.useCallback)((eventType, handler) => {
697
+ const handlers = eventHandlersRef.current.get(eventType);
698
+ if (handlers) {
699
+ handlers.delete(handler);
700
+ if (handlers.size === 0) {
701
+ eventHandlersRef.current.delete(eventType);
702
+ }
703
+ }
704
+ }, []);
705
+ const emit = (0, import_react3.useCallback)(
706
+ (eventType, data) => {
707
+ const handlers = eventHandlersRef.current.get(eventType);
708
+ if (handlers) {
709
+ handlers.forEach((handler) => {
710
+ try {
711
+ handler(data);
712
+ } catch (error2) {
713
+ logger.error(`Error in event handler for ${eventType}:`, error2);
714
+ }
715
+ });
716
+ }
717
+ },
718
+ [logger]
719
+ );
720
+ const updateMetrics = (0, import_react3.useCallback)((updates) => {
721
+ setMetrics((prev) => ({ ...prev, ...updates }));
722
+ }, []);
723
+ const addToQueue = (0, import_react3.useCallback)(
724
+ (event) => {
725
+ const currentQueueSize = messageQueueRef.current.length;
726
+ const maxSize = queueConfig.maxSize || DEFAULT_QUEUE_CONFIG.maxSize;
727
+ if (currentQueueSize >= maxSize) {
728
+ if (queueConfig.dropStrategy === "newest") {
729
+ logger.warn("Message queue full, dropping new message");
730
+ return false;
731
+ } else {
732
+ const dropped = messageQueueRef.current.shift();
733
+ logger.warn("Message queue full, dropped oldest message", dropped);
734
+ }
735
+ }
736
+ messageQueueRef.current.push(event);
737
+ updateMetrics({ messagesQueued: messageQueueRef.current.length });
738
+ return true;
739
+ },
740
+ [queueConfig, logger, updateMetrics]
741
+ );
742
+ const calculateRetryInterval = (0, import_react3.useCallback)(
743
+ (retryCount) => {
744
+ const config = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };
745
+ const {
746
+ intervals = [],
747
+ backoffMultiplier = 1.5,
748
+ maxBackoffTime = 3e4
749
+ } = config;
750
+ if (retryCount < intervals.length) {
751
+ return intervals[retryCount];
752
+ }
753
+ const baseInterval = intervals[intervals.length - 1] || 5e3;
754
+ const backoffTime = baseInterval * Math.pow(backoffMultiplier, retryCount - intervals.length + 1);
755
+ return Math.min(backoffTime, maxBackoffTime);
756
+ },
757
+ [retryConfig]
758
+ );
759
+ const startHeartbeat = (0, import_react3.useCallback)(() => {
760
+ if (!heartbeatInterval || heartbeatInterval <= 0) return;
761
+ const sendPing = () => {
762
+ if (wsRef.current?.readyState === WebSocket.OPEN) {
763
+ const pingTime = Date.now();
764
+ wsRef.current.send(
765
+ JSON.stringify({ type: "ping", timestamp: pingTime })
766
+ );
767
+ heartbeatTimeoutRef.current = setTimeout(() => {
768
+ logger.warn("Heartbeat timeout - no pong received");
769
+ if (wsRef.current) {
770
+ wsRef.current.close(4e3, "Heartbeat timeout");
771
+ }
772
+ }, heartbeatTimeout);
773
+ }
774
+ };
775
+ if (heartbeatIntervalRef.current) {
776
+ clearInterval(heartbeatIntervalRef.current);
777
+ }
778
+ heartbeatIntervalRef.current = setInterval(sendPing, heartbeatInterval);
779
+ logger.debug("Heartbeat started");
780
+ }, [heartbeatInterval, heartbeatTimeout, logger]);
781
+ const stopHeartbeat = (0, import_react3.useCallback)(() => {
782
+ if (heartbeatIntervalRef.current) {
783
+ clearInterval(heartbeatIntervalRef.current);
784
+ heartbeatIntervalRef.current = void 0;
785
+ }
786
+ if (heartbeatTimeoutRef.current) {
787
+ clearTimeout(heartbeatTimeoutRef.current);
788
+ heartbeatTimeoutRef.current = void 0;
789
+ }
790
+ logger.debug("Heartbeat stopped");
791
+ }, [logger]);
792
+ const cleanup = (0, import_react3.useCallback)(() => {
793
+ if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
794
+ wsRef.current.close(1e3, "Cleanup");
795
+ }
796
+ wsRef.current = void 0;
797
+ if (reconnectTimeoutRef.current) {
798
+ clearTimeout(reconnectTimeoutRef.current);
799
+ reconnectTimeoutRef.current = void 0;
800
+ }
801
+ stopHeartbeat();
802
+ pendingMessagesRef.current.forEach(({ reject, timeout }) => {
803
+ clearTimeout(timeout);
804
+ reject(new Error("Connection closed"));
805
+ });
806
+ pendingMessagesRef.current.clear();
807
+ loadChatRetryMapRef.current.forEach((retryState) => {
808
+ if (retryState.timeoutId) {
809
+ clearTimeout(retryState.timeoutId);
810
+ }
811
+ });
812
+ loadChatRetryMapRef.current.clear();
813
+ }, [stopHeartbeat]);
814
+ const connect = (0, import_react3.useCallback)(
815
+ async (userId) => {
816
+ if (!mountedRef.current) {
817
+ mountedRef.current = true;
818
+ }
819
+ if (!orgId) {
820
+ const error2 = {
821
+ code: "CONNECTION_FAILED",
822
+ message: "Cannot connect: orgId is undefined",
823
+ retryable: false,
824
+ timestamp: Date.now()
825
+ };
826
+ logger.error("Cannot connect: orgId is undefined");
827
+ setError(error2);
828
+ return Promise.reject(error2);
829
+ }
830
+ if (wsRef.current?.readyState === WebSocket.OPEN) {
831
+ logger.debug("Already connected");
832
+ return Promise.resolve();
833
+ }
834
+ if (connectionState === "connecting" || connectionState === "reconnecting") {
835
+ logger.debug("Connection already in progress");
836
+ return Promise.resolve();
837
+ }
838
+ const maxRetries = retryConfig.maxRetries ?? DEFAULT_RETRY_CONFIG.maxRetries;
839
+ if (retryCountRef.current >= maxRetries && !intentionalDisconnectRef.current) {
840
+ const error2 = {
841
+ code: "CONNECTION_FAILED",
842
+ message: `Max retries (${maxRetries}) exceeded`,
843
+ retryable: false,
844
+ timestamp: Date.now()
845
+ };
846
+ setError(error2);
847
+ updateMetrics({ lastError: error2 });
848
+ return Promise.reject(error2);
849
+ }
850
+ cleanup();
851
+ setConnectionState(
852
+ retryCountRef.current > 0 ? "reconnecting" : "connecting"
853
+ );
854
+ intentionalDisconnectRef.current = false;
855
+ return new Promise((resolve, reject) => {
856
+ try {
857
+ const wsUrl = `${serverBaseUrl}?orgId=${orgId}&userId=${userId}&clientType=${clientType}&product=${product}`;
858
+ const connectionStartTime = Date.now();
859
+ logger.debug("Connecting to WebSocket:", wsUrl);
860
+ console.log(`\u23F3 Initiating WebSocket connection to ${serverBaseUrl}...`);
861
+ const ws = new WebSocket(wsUrl);
862
+ ws.onopen = () => {
863
+ if (!mountedRef.current) {
864
+ ws.close(1e3, "Component unmounted");
865
+ reject(new Error("Component unmounted"));
866
+ return;
867
+ }
868
+ const connectionTimeMs = Date.now() - connectionStartTime;
869
+ const connectionTimeSec = (connectionTimeMs / 1e3).toFixed(2);
870
+ logger.info("\u2705 WebSocket connected", {
871
+ userId,
872
+ retryCount: retryCountRef.current,
873
+ connectionTime: `${connectionTimeSec}s (${connectionTimeMs}ms)`
874
+ });
875
+ console.log(`\u{1F50C} WebSocket connection established in ${connectionTimeSec} seconds`);
876
+ setConnectionState("connected");
877
+ setError(void 0);
878
+ const wasReconnecting = retryCountRef.current > 0;
879
+ retryCountRef.current = 0;
880
+ updateMetrics({
881
+ connectedAt: Date.now(),
882
+ latency: connectionTimeMs,
883
+ reconnectCount: wasReconnecting ? metrics.reconnectCount + 1 : metrics.reconnectCount
884
+ });
885
+ while (messageQueueRef.current.length > 0 && ws.readyState === WebSocket.OPEN) {
886
+ const event = messageQueueRef.current.shift();
887
+ if (event) {
888
+ ws.send(JSON.stringify({ ...event, timestamp: Date.now() }));
889
+ updateMetrics({
890
+ messagesSent: metrics.messagesSent + 1,
891
+ messagesQueued: messageQueueRef.current.length
892
+ });
893
+ }
894
+ }
895
+ currentUserIdRef.current = userId;
896
+ if (currentChatKeyRef.current) {
897
+ if (!orgId) {
898
+ logger.error("Cannot resubscribe to chat: orgId is undefined");
899
+ } else {
900
+ logger.info(
901
+ "Resubscribing to chat after reconnection:",
902
+ currentChatKeyRef.current
903
+ );
904
+ const resubscribeEvent = {
905
+ type: "load_chat",
906
+ orgId,
907
+ chatKey: currentChatKeyRef.current,
908
+ userId,
909
+ timestamp: Date.now(),
910
+ data: {}
911
+ };
912
+ ws.send(JSON.stringify(resubscribeEvent));
913
+ }
914
+ }
915
+ startHeartbeat();
916
+ emit("connected", { userId, wasReconnecting });
917
+ resolve();
918
+ };
919
+ ws.onmessage = (event) => {
920
+ if (!mountedRef.current) return;
921
+ try {
922
+ const data = JSON.parse(event.data);
923
+ if (!isChatEvent(data)) {
924
+ logger.warn("Received invalid message format:", data);
925
+ return;
926
+ }
927
+ const chatEvent = data;
928
+ logger.debug("Message received:", chatEvent.type);
929
+ updateMetrics({
930
+ messagesReceived: metrics.messagesReceived + 1,
931
+ lastMessageAt: Date.now()
932
+ });
933
+ if (chatEvent.type === "pong") {
934
+ if (heartbeatTimeoutRef.current) {
935
+ clearTimeout(heartbeatTimeoutRef.current);
936
+ heartbeatTimeoutRef.current = void 0;
937
+ }
938
+ const latency = Date.now() - (chatEvent.timestamp || Date.now());
939
+ lastPongRef.current = Date.now();
940
+ updateMetrics({ latency });
941
+ return;
942
+ }
943
+ switch (chatEvent.type) {
944
+ case "new_chat_created":
945
+ const newChatKey = chatEvent.data?.chatKey;
946
+ if (newChatKey) {
947
+ logger.info("New chat created with key:", newChatKey);
948
+ currentChatKeyRef.current = newChatKey;
949
+ if (chatCreationPromiseRef.current) {
950
+ chatCreationPromiseRef.current.resolve(newChatKey);
951
+ chatCreationPromiseRef.current = null;
952
+ }
953
+ if (!orgId) {
954
+ logger.error("Cannot send load_chat: orgId is undefined");
955
+ return;
956
+ }
957
+ const loadChatEvent = {
958
+ type: "load_chat",
959
+ orgId,
960
+ chatKey: newChatKey,
961
+ userId: currentUserIdRef.current || userId,
962
+ timestamp: Date.now(),
963
+ data: {}
964
+ };
965
+ ws.send(JSON.stringify(loadChatEvent));
966
+ }
967
+ break;
968
+ case "load_chat_response":
969
+ const chat = chatEvent.data?.chat;
970
+ if (chat && chat.key) {
971
+ logger.info("Chat loaded with key:", chat.key);
972
+ currentChatKeyRef.current = chat.key;
973
+ const retryState = loadChatRetryMapRef.current.get(chat.key);
974
+ if (retryState) {
975
+ if (retryState.timeoutId) {
976
+ clearTimeout(retryState.timeoutId);
977
+ }
978
+ loadChatRetryMapRef.current.delete(chat.key);
979
+ }
980
+ } else if (!chat) {
981
+ logger.warn("Chat load failed, clearing key");
982
+ currentChatKeyRef.current = void 0;
983
+ }
984
+ break;
985
+ case "chat_ended":
986
+ logger.info("Chat ended, clearing key");
987
+ currentChatKeyRef.current = void 0;
988
+ break;
989
+ case "error":
990
+ const errorMessage = chatEvent.data?.message || "Unknown error";
991
+ logger.error("Received error from server:", errorMessage);
992
+ if (errorMessage.includes("nats: key not found") || errorMessage.includes("Failed to load chat")) {
993
+ const chatKeyFromError = currentChatKeyRef.current;
994
+ if (chatKeyFromError) {
995
+ const maxRetries2 = 5;
996
+ let retryState = loadChatRetryMapRef.current.get(chatKeyFromError);
997
+ if (!retryState) {
998
+ retryState = { retryCount: 0, timeoutId: null };
999
+ loadChatRetryMapRef.current.set(chatKeyFromError, retryState);
1000
+ }
1001
+ if (retryState.retryCount < maxRetries2) {
1002
+ const delay = 200 * Math.pow(2, retryState.retryCount);
1003
+ retryState.retryCount++;
1004
+ logger.info(
1005
+ `Chat load failed, retrying (${retryState.retryCount}/${maxRetries2}) in ${delay}ms...`,
1006
+ chatKeyFromError
1007
+ );
1008
+ retryState.timeoutId = setTimeout(() => {
1009
+ if (!wsRef.current || !mountedRef.current) return;
1010
+ if (!orgId) {
1011
+ logger.error("Cannot retry load_chat: orgId is undefined", chatKeyFromError);
1012
+ loadChatRetryMapRef.current.delete(chatKeyFromError);
1013
+ return;
1014
+ }
1015
+ logger.debug("Retrying load_chat:", chatKeyFromError);
1016
+ const retryLoadEvent = {
1017
+ type: "load_chat",
1018
+ orgId,
1019
+ chatKey: chatKeyFromError,
1020
+ userId: currentUserIdRef.current || "",
1021
+ timestamp: Date.now(),
1022
+ data: {}
1023
+ };
1024
+ ws.send(JSON.stringify(retryLoadEvent));
1025
+ }, delay);
1026
+ } else {
1027
+ logger.error("Max retries reached for loading chat:", chatKeyFromError);
1028
+ loadChatRetryMapRef.current.delete(chatKeyFromError);
1029
+ }
1030
+ }
1031
+ }
1032
+ const wsError = {
1033
+ code: "NETWORK_ERROR",
1034
+ message: errorMessage,
1035
+ retryable: true,
1036
+ timestamp: Date.now()
1037
+ };
1038
+ setError(wsError);
1039
+ updateMetrics({ lastError: wsError });
1040
+ break;
1041
+ }
1042
+ emit(chatEvent.type || "message", chatEvent);
1043
+ if (onMessageRef.current) {
1044
+ onMessageRef.current(chatEvent);
1045
+ }
1046
+ } catch (error2) {
1047
+ logger.error("Failed to parse WebSocket message:", error2);
1048
+ const parseError = {
1049
+ code: "PARSE_ERROR",
1050
+ message: "Failed to parse message",
1051
+ retryable: false,
1052
+ timestamp: Date.now()
1053
+ };
1054
+ setError(parseError);
1055
+ updateMetrics({ lastError: parseError });
1056
+ }
1057
+ };
1058
+ ws.onclose = (event) => {
1059
+ if (!mountedRef.current) return;
1060
+ logger.info("WebSocket closed", {
1061
+ code: event.code,
1062
+ reason: event.reason
1063
+ });
1064
+ setConnectionState("disconnected");
1065
+ wsRef.current = void 0;
1066
+ stopHeartbeat();
1067
+ emit("disconnected", { code: event.code, reason: event.reason });
1068
+ if (event.code !== 1e3 && !intentionalDisconnectRef.current && mountedRef.current) {
1069
+ const retryInterval = calculateRetryInterval(
1070
+ retryCountRef.current
1071
+ );
1072
+ retryCountRef.current++;
1073
+ logger.info(
1074
+ `Reconnecting in ${retryInterval}ms (attempt ${retryCountRef.current})`
1075
+ );
1076
+ if (reconnectTimeoutRef.current) {
1077
+ clearTimeout(reconnectTimeoutRef.current);
1078
+ }
1079
+ reconnectTimeoutRef.current = setTimeout(() => {
1080
+ connect(userId);
1081
+ }, retryInterval);
1082
+ }
1083
+ };
1084
+ ws.onerror = (error2) => {
1085
+ logger.error("WebSocket error:", error2);
1086
+ if (!mountedRef.current) return;
1087
+ const wsError = {
1088
+ code: "CONNECTION_FAILED",
1089
+ message: "WebSocket connection failed",
1090
+ retryable: true,
1091
+ timestamp: Date.now()
1092
+ };
1093
+ setError(wsError);
1094
+ updateMetrics({ lastError: wsError });
1095
+ reject(wsError);
1096
+ };
1097
+ wsRef.current = ws;
1098
+ } catch (error2) {
1099
+ logger.error("Failed to create WebSocket:", error2);
1100
+ const wsError = {
1101
+ code: "CONNECTION_FAILED",
1102
+ message: error2 instanceof Error ? error2.message : "Failed to create connection",
1103
+ retryable: true,
1104
+ timestamp: Date.now()
1105
+ };
1106
+ setError(wsError);
1107
+ updateMetrics({ lastError: wsError });
1108
+ reject(wsError);
1109
+ }
1110
+ });
1111
+ },
1112
+ [
1113
+ serverBaseUrl,
1114
+ orgId,
1115
+ clientType,
1116
+ product,
1117
+ connectionState,
1118
+ logger,
1119
+ retryConfig,
1120
+ metrics,
1121
+ updateMetrics,
1122
+ cleanup,
1123
+ calculateRetryInterval,
1124
+ startHeartbeat,
1125
+ emit
1126
+ ]
1127
+ );
1128
+ const sendMessage = (0, import_react3.useCallback)(
1129
+ (event, overrideUserId) => {
1130
+ return new Promise((resolve, reject) => {
1131
+ if (!mountedRef.current) {
1132
+ reject(new Error("Component not mounted"));
1133
+ return;
1134
+ }
1135
+ const fullEvent = {
1136
+ ...event,
1137
+ timestamp: Date.now()
1138
+ };
1139
+ const messageId = `${fullEvent.type}_${fullEvent.timestamp}_${Math.random()}`;
1140
+ logger.debug("Sending message:", fullEvent.type);
1141
+ if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
1142
+ if (addToQueue(fullEvent)) {
1143
+ logger.debug("Message queued, attempting to connect");
1144
+ if (connectionState === "disconnected" && overrideUserId) {
1145
+ connect(overrideUserId).then(() => resolve()).catch(reject);
1146
+ } else {
1147
+ resolve();
1148
+ }
1149
+ } else {
1150
+ reject(new Error("Message queue full"));
1151
+ }
1152
+ return;
1153
+ }
1154
+ try {
1155
+ wsRef.current.send(JSON.stringify(fullEvent));
1156
+ updateMetrics({ messagesSent: metrics.messagesSent + 1 });
1157
+ logger.debug("Message sent successfully");
1158
+ resolve();
1159
+ } catch (error2) {
1160
+ logger.error("Failed to send message:", error2);
1161
+ if (addToQueue(fullEvent)) {
1162
+ resolve();
1163
+ } else {
1164
+ const sendError = {
1165
+ code: "SEND_FAILED",
1166
+ message: error2 instanceof Error ? error2.message : "Failed to send message",
1167
+ retryable: true,
1168
+ timestamp: Date.now()
1169
+ };
1170
+ setError(sendError);
1171
+ updateMetrics({ lastError: sendError });
1172
+ reject(sendError);
1173
+ }
1174
+ }
1175
+ });
1176
+ },
1177
+ [connectionState, connect, addToQueue, logger, metrics, updateMetrics]
1178
+ );
1179
+ const startNewChat = (0, import_react3.useCallback)(
1180
+ (userId, data) => {
1181
+ return new Promise((resolve, reject) => {
1182
+ if (!userId) {
1183
+ reject(new Error("User ID is required"));
1184
+ return;
1185
+ }
1186
+ logger.info("Requesting new chat from server with userId:", userId);
1187
+ setStartTime(/* @__PURE__ */ new Date());
1188
+ chatCreationPromiseRef.current = { resolve, reject };
1189
+ sendMessage(
1190
+ {
1191
+ type: "new_chat",
1192
+ orgId,
1193
+ chatKey: "",
1194
+ // Server will generate
1195
+ userId,
1196
+ data: data ?? {}
1197
+ },
1198
+ userId
1199
+ ).catch((error2) => {
1200
+ chatCreationPromiseRef.current = null;
1201
+ reject(error2);
1202
+ });
1203
+ setTimeout(() => {
1204
+ if (chatCreationPromiseRef.current) {
1205
+ chatCreationPromiseRef.current = null;
1206
+ reject(new Error("Chat creation timed out"));
1207
+ }
1208
+ }, 3e4);
1209
+ });
1210
+ },
1211
+ [sendMessage, orgId, logger]
1212
+ );
1213
+ const disconnect = (0, import_react3.useCallback)(
1214
+ (intentional = true) => {
1215
+ logger.info("Disconnecting WebSocket", { intentional });
1216
+ intentionalDisconnectRef.current = intentional;
1217
+ cleanup();
1218
+ setConnectionState("disconnected");
1219
+ messageQueueRef.current = [];
1220
+ retryCountRef.current = 0;
1221
+ mountedRef.current = false;
1222
+ currentChatKeyRef.current = void 0;
1223
+ currentUserIdRef.current = void 0;
1224
+ },
1225
+ [cleanup, logger]
1226
+ );
1227
+ const clearError = (0, import_react3.useCallback)(() => {
1228
+ setError(void 0);
1229
+ }, []);
1230
+ (0, import_react3.useEffect)(() => {
1231
+ mountedRef.current = true;
1232
+ return () => {
1233
+ mountedRef.current = false;
1234
+ disconnect(true);
1235
+ };
1236
+ }, []);
1237
+ return {
1238
+ connectionState,
1239
+ isConnected,
1240
+ sendMessage,
1241
+ error,
1242
+ connect,
1243
+ startNewChat,
1244
+ startTime,
1245
+ disconnect,
1246
+ metrics,
1247
+ on,
1248
+ off,
1249
+ clearError
1250
+ };
1251
+ };
1252
+
1253
+ // hooks/use-websocket-chat-admin.ts
1254
+ var useWebSocketChatAdmin = ({
1255
+ serverBaseUrl,
1256
+ orgId,
1257
+ product
1258
+ }) => {
1259
+ const [chats, setChats] = (0, import_react4.useState)(/* @__PURE__ */ new Map());
1260
+ const [selectedChat, setSelectedChat] = (0, import_react4.useState)(void 0);
1261
+ const handleMessage = (0, import_react4.useCallback)(
1262
+ (chatEvent) => {
1263
+ switch (chatEvent.type) {
1264
+ case "message":
1265
+ if (!selectedChat || !chatEvent.message) return;
1266
+ setChats((prev) => {
1267
+ const newMap = new Map(prev);
1268
+ newMap.set(selectedChat.key, {
1269
+ ...selectedChat,
1270
+ messages: [...selectedChat.messages, chatEvent.message]
1271
+ });
1272
+ return newMap;
1273
+ });
1274
+ setSelectedChat((prev) => {
1275
+ if (!prev) return prev;
1276
+ return {
1277
+ ...prev,
1278
+ messages: [...prev.messages, chatEvent.message]
1279
+ };
1280
+ });
1281
+ break;
1282
+ case "list_chats":
1283
+ const chatList = chatEvent.data?.chats;
1284
+ if (!chatList) return;
1285
+ setChats(new Map(chatList.map((chat) => [chat.key, chat])));
1286
+ break;
1287
+ case "chat_updated":
1288
+ const updatedChat = chatEvent.data?.chat?.value;
1289
+ if (updatedChat) {
1290
+ setChats((prev) => new Map(prev).set(updatedChat.key, updatedChat));
1291
+ }
1292
+ break;
1293
+ case "chat_removed":
1294
+ const chatKey = chatEvent.data?.chatKey?.value;
1295
+ if (chatKey) {
1296
+ setChats((prev) => {
1297
+ const newMap = new Map(prev);
1298
+ newMap.delete(chatKey);
1299
+ return newMap;
1300
+ });
1301
+ }
1302
+ break;
1303
+ case "load_chat":
1304
+ const history = chatEvent.data?.chat?.value;
1305
+ if (history) {
1306
+ setChats((prev) => {
1307
+ const existingChat = prev.get(history.key);
1308
+ if (!existingChat) return prev;
1309
+ return new Map(prev).set(history.key, {
1310
+ ...existingChat,
1311
+ messages: history.messages
1312
+ });
1313
+ });
1314
+ }
1315
+ break;
1316
+ }
1317
+ },
1318
+ [selectedChat]
1319
+ );
1320
+ const base = useWebSocketChatBase({
1321
+ serverBaseUrl,
1322
+ orgId,
1323
+ clientType: "humanAgent",
1324
+ onMessage: handleMessage,
1325
+ product
1326
+ });
1327
+ const selectChat = (0, import_react4.useCallback)(
1328
+ (chatKey) => {
1329
+ const chat = chats.get(chatKey);
1330
+ if (!chat) {
1331
+ console.error("Unable to select chat", chatKey);
1332
+ return;
1333
+ }
1334
+ setSelectedChat(chat);
1335
+ },
1336
+ [chats, orgId, base.sendMessage]
1337
+ );
1338
+ const addUserToChat = (0, import_react4.useCallback)(
1339
+ (orgId2, chatKey, user) => {
1340
+ base.sendMessage({
1341
+ type: "human_agent_joined",
1342
+ orgId: orgId2,
1343
+ chatKey,
1344
+ userId: user.email,
1345
+ data: { user }
1346
+ });
1347
+ setChats((prev) => {
1348
+ const newMap = new Map(prev);
1349
+ const chat = newMap.get(chatKey);
1350
+ if (!chat) return prev;
1351
+ newMap.set(chatKey, {
1352
+ ...chat,
1353
+ humanAgentEngaged: user.role === ChatRoleHumanAgent,
1354
+ users: [...chat?.users ?? [], user]
1355
+ });
1356
+ return newMap;
1357
+ });
1358
+ setSelectedChat((prev) => {
1359
+ if (!prev) return prev;
1360
+ return {
1361
+ ...prev,
1362
+ humanAgentEngaged: user.role === ChatRoleHumanAgent,
1363
+ users: [...prev.users ?? [], user]
1364
+ };
1365
+ });
1366
+ },
1367
+ [base.sendMessage]
1368
+ );
1369
+ const removeUserFromChat = (0, import_react4.useCallback)(
1370
+ (orgId2, chatKey, userId) => {
1371
+ const chat = chats.get(chatKey);
1372
+ if (!chat) return;
1373
+ const user = chat.users?.find((u) => u.id === userId);
1374
+ if (!user) return;
1375
+ base.sendMessage({
1376
+ type: "human_agent_left",
1377
+ orgId: orgId2,
1378
+ chatKey,
1379
+ userId,
1380
+ data: { user }
1381
+ });
1382
+ setChats((prev) => {
1383
+ const newMap = new Map(prev);
1384
+ const chat2 = newMap.get(chatKey);
1385
+ if (!chat2) return prev;
1386
+ newMap.set(chatKey, {
1387
+ ...chat2,
1388
+ humanAgentEngaged: false,
1389
+ users: chat2.users?.filter((u) => u.id !== userId)
1390
+ });
1391
+ return newMap;
1392
+ });
1393
+ },
1394
+ [chats, base.sendMessage]
1395
+ );
1396
+ const blockUser = (0, import_react4.useCallback)(
1397
+ (orgId2, chatKey, userId) => {
1398
+ base.sendMessage({
1399
+ type: "block_user",
1400
+ orgId: orgId2,
1401
+ chatKey,
1402
+ userId
1403
+ });
1404
+ },
1405
+ [base.sendMessage]
1406
+ );
1407
+ return {
1408
+ ...base,
1409
+ chats,
1410
+ selectedChat,
1411
+ selectChat,
1412
+ addUserToChat,
1413
+ removeUserFromChat,
1414
+ blockUser
1415
+ };
1416
+ };
386
1417
 
1418
+ // hooks/use-websocket-chat-customer.ts
1419
+ var import_react5 = require("react");
1420
+ var useWebSocketChatCustomer = ({
1421
+ serverBaseUrl,
1422
+ orgId,
1423
+ chatKey,
1424
+ product
1425
+ }) => {
1426
+ const [currentChat, setCurrentChat] = (0, import_react5.useState)(void 0);
1427
+ const handleMessage = (0, import_react5.useCallback)((chatEvent) => {
1428
+ console.log("Received event:", chatEvent.type);
1429
+ switch (chatEvent.type) {
1430
+ case "message":
1431
+ if (!chatEvent.message) return;
1432
+ console.log(
1433
+ "got message:",
1434
+ chatEvent.message.role,
1435
+ ":",
1436
+ chatEvent.message.content
1437
+ );
1438
+ setCurrentChat((prev) => {
1439
+ if (!prev) return prev;
1440
+ return {
1441
+ ...prev,
1442
+ messages: [...prev.messages, chatEvent.message]
1443
+ };
1444
+ });
1445
+ break;
1446
+ case "chat_updated":
1447
+ const chat = chatEvent.data?.chat?.value;
1448
+ if (chat) {
1449
+ setCurrentChat(chat);
1450
+ }
1451
+ break;
1452
+ case "load_chat":
1453
+ const history = chatEvent.data?.chat;
1454
+ if (!history) return;
1455
+ setCurrentChat(history);
1456
+ break;
1457
+ default:
1458
+ break;
1459
+ }
1460
+ }, []);
1461
+ const base = useWebSocketChatBase({
1462
+ serverBaseUrl,
1463
+ orgId,
1464
+ clientType: "customer",
1465
+ onMessage: handleMessage,
1466
+ product
1467
+ });
1468
+ return {
1469
+ ...base,
1470
+ chatKey,
1471
+ title: currentChat?.title,
1472
+ messages: currentChat?.messages ?? [],
1473
+ users: currentChat?.users ?? [],
1474
+ isWaiting: currentChat?.isWaiting ?? false,
1475
+ isWaitingForAgent: currentChat?.isWaitingForAgent ?? false,
1476
+ aiEngaged: currentChat?.aiEngaged ?? false,
1477
+ humanAgentEngaged: currentChat?.humanAgentEngaged ?? false,
1478
+ metadata: currentChat?.metadata ?? {},
1479
+ status: currentChat?.status
1480
+ };
1481
+ };
387
1482
 
388
1483
  // context/websocket-chat-admin-context.tsx
389
-
390
- var _jsxruntime = require('react/jsx-runtime');
391
- var WebSocketChatAdminContext = _react.createContext.call(void 0, void 0);
1484
+ var import_jsx_runtime = require("react/jsx-runtime");
1485
+ var WebSocketChatAdminContext = (0, import_react6.createContext)(void 0);
392
1486
  function WebSocketChatAdminProvider(props) {
393
1487
  const { children, serverBaseUrl, orgId, userId, product } = props;
394
- const webSocket = _chunkE2FJX52Rjs.useWebSocketChatAdmin.call(void 0, {
1488
+ const webSocket = useWebSocketChatAdmin({
395
1489
  serverBaseUrl,
396
1490
  orgId,
397
1491
  product
398
1492
  });
399
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WebSocketChatAdminContext.Provider, { value: webSocket, children });
1493
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WebSocketChatAdminContext.Provider, { value: webSocket, children });
400
1494
  }
401
1495
  var useWebSocketChatAdminContext = () => {
402
- const context = _react.useContext.call(void 0, WebSocketChatAdminContext);
1496
+ const context = (0, import_react6.useContext)(WebSocketChatAdminContext);
403
1497
  if (context === void 0) {
404
1498
  throw new Error(
405
1499
  "useWebSocketChatAdminContext must be used within a WebSocketChatAdminProvider"
@@ -409,21 +1503,21 @@ var useWebSocketChatAdminContext = () => {
409
1503
  };
410
1504
 
411
1505
  // components/admin/admin-chat-input.tsx
412
-
1506
+ var import_jsx_runtime2 = require("react/jsx-runtime");
413
1507
  var AdminChatInput = ({
414
1508
  onFileUpload,
415
1509
  chatKey
416
1510
  }) => {
417
1511
  const { sendMessage } = useWebSocketChatAdminContext();
418
- const { user, selectedOrgId } = _auth.useUserContext.call(void 0, );
419
- const [input, setInput] = _react.useState.call(void 0, "");
420
- const [isUploading, setIsUploading] = _react.useState.call(void 0, false);
421
- const [isSending, setIsSending] = _react.useState.call(void 0, false);
422
- const fileInputRef = _react.useRef.call(void 0, null);
1512
+ const { user, selectedOrgId } = (0, import_auth.useUserContext)();
1513
+ const [input, setInput] = (0, import_react7.useState)("");
1514
+ const [isUploading, setIsUploading] = (0, import_react7.useState)(false);
1515
+ const [isSending, setIsSending] = (0, import_react7.useState)(false);
1516
+ const fileInputRef = (0, import_react7.useRef)(null);
423
1517
  const MAX_FILE_SIZE = 5 * 1024 * 1024;
424
1518
  const handleSend = async () => {
425
1519
  if (!input.trim() && !isUploading || isSending) return;
426
- if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _ => _.id])) {
1520
+ if (!chatKey || !selectedOrgId || !user?.id) {
427
1521
  console.error("chatKey, orgId, or userId is not defined");
428
1522
  return;
429
1523
  }
@@ -433,12 +1527,12 @@ var AdminChatInput = ({
433
1527
  type: "message",
434
1528
  chatKey,
435
1529
  orgId: selectedOrgId,
436
- userId: _optionalChain([user, 'optionalAccess', _2 => _2.id]),
1530
+ userId: user?.id,
437
1531
  message: {
438
- id: _ksuid2.default.randomSync().string,
1532
+ id: import_ksuid.default.randomSync().string,
439
1533
  content: input,
440
1534
  role: "user",
441
- senderId: _optionalChain([user, 'optionalAccess', _3 => _3.id]),
1535
+ senderId: user?.id,
442
1536
  time: Date.now(),
443
1537
  status: "sending",
444
1538
  createdAt: Date.now()
@@ -474,7 +1568,7 @@ var AdminChatInput = ({
474
1568
  url: file.url,
475
1569
  title: file.name
476
1570
  }));
477
- if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _4 => _4.id])) {
1571
+ if (!chatKey || !selectedOrgId || !user?.id) {
478
1572
  console.error("chatKey, orgId, or userId is not defined");
479
1573
  return;
480
1574
  }
@@ -485,9 +1579,9 @@ var AdminChatInput = ({
485
1579
  }
486
1580
  }
487
1581
  };
488
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border-t bg-white rounded-b-lg", children: [
489
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
490
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1582
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-4 border-t bg-white rounded-b-lg", children: [
1583
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center space-x-2", children: [
1584
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
491
1585
  "input",
492
1586
  {
493
1587
  type: "file",
@@ -498,17 +1592,17 @@ var AdminChatInput = ({
498
1592
  accept: "image/*,.pdf,.doc,.docx,.txt"
499
1593
  }
500
1594
  ),
501
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1595
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
502
1596
  "button",
503
1597
  {
504
- onClick: () => _optionalChain([fileInputRef, 'access', _5 => _5.current, 'optionalAccess', _6 => _6.click, 'call', _7 => _7()]),
1598
+ onClick: () => fileInputRef.current?.click(),
505
1599
  className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
506
1600
  disabled: isUploading,
507
1601
  "aria-label": "Attach file",
508
- children: isUploading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paperclip, { className: "w-5 h-5" })
1602
+ children: isUploading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Paperclip, { className: "w-5 h-5" })
509
1603
  }
510
1604
  ),
511
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 relative", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1605
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex-1 relative", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
512
1606
  "textarea",
513
1607
  {
514
1608
  value: input,
@@ -528,40 +1622,40 @@ var AdminChatInput = ({
528
1622
  }
529
1623
  }
530
1624
  ) }),
531
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1625
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
532
1626
  "button",
533
1627
  {
534
1628
  onClick: handleSend,
535
1629
  disabled: !input.trim() && !isUploading || isSending,
536
1630
  className: `p-2 rounded-full transition-colors ${!input.trim() && !isUploading || isSending ? "text-gray-400 bg-gray-100" : "text-white bg-blue-500 hover:bg-blue-600"}`,
537
1631
  "aria-label": "Send message",
538
- children: isSending ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Send, { className: "w-5 h-5" })
1632
+ children: isSending ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Send, { className: "w-5 h-5" })
539
1633
  }
540
1634
  )
541
1635
  ] }),
542
- isUploading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full bg-gray-200 rounded-full h-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-blue-500 h-1 rounded-full animate-pulse" }) }) })
1636
+ isUploading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "w-full bg-gray-200 rounded-full h-1", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "bg-blue-500 h-1 rounded-full animate-pulse" }) }) })
543
1637
  ] });
544
1638
  };
545
1639
 
546
1640
  // components/admin/chat-human-agent-actions.tsx
547
-
1641
+ var import_auth2 = require("@elqnt/auth");
548
1642
 
549
1643
  // context/websocket-chat-customer-context.tsx
550
-
551
-
552
- var WebSocketChatCustomerContext = _react.createContext.call(void 0, void 0);
1644
+ var import_react8 = require("react");
1645
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1646
+ var WebSocketChatCustomerContext = (0, import_react8.createContext)(void 0);
553
1647
  function WebSocketChatCustomerProvider(props) {
554
1648
  const { children, serverBaseUrl, orgId, userId, chatKey, product } = props;
555
- const webSocket = _chunk3PXNBY7Jjs.useWebSocketChatCustomer.call(void 0, {
1649
+ const webSocket = useWebSocketChatCustomer({
556
1650
  serverBaseUrl,
557
1651
  orgId,
558
1652
  chatKey,
559
1653
  product
560
1654
  });
561
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WebSocketChatCustomerContext.Provider, { value: webSocket, children });
1655
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WebSocketChatCustomerContext.Provider, { value: webSocket, children });
562
1656
  }
563
1657
  var useWebSocketChatCustomerContext = () => {
564
- const context = _react.useContext.call(void 0, WebSocketChatCustomerContext);
1658
+ const context = (0, import_react8.useContext)(WebSocketChatCustomerContext);
565
1659
  if (context === void 0) {
566
1660
  throw new Error(
567
1661
  "useWebSocketChatCustomerContext must be used within a WebSocketChatCustomerProvider"
@@ -571,9 +1665,9 @@ var useWebSocketChatCustomerContext = () => {
571
1665
  };
572
1666
 
573
1667
  // components/admin/chat-human-agent-actions.tsx
574
-
1668
+ var import_jsx_runtime4 = require("react/jsx-runtime");
575
1669
  var ChatHumanAgentActions = ({}) => {
576
- const { user, selectedOrgId } = _auth.useUserContext.call(void 0, );
1670
+ const { user, selectedOrgId } = (0, import_auth2.useUserContext)();
577
1671
  const { selectedChat, addUserToChat, removeUserFromChat, blockUser } = useWebSocketChatAdminContext();
578
1672
  const handleJoinChat = () => {
579
1673
  if (!selectedChat || !user || !selectedOrgId) return;
@@ -604,78 +1698,78 @@ var ChatHumanAgentActions = ({}) => {
604
1698
  blockUser(selectedOrgId, selectedChat.key, user.id);
605
1699
  };
606
1700
  if (!selectedChat) return null;
607
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border-b bg-white flex items-center justify-between", children: [
608
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-4", children: [
609
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "font-semibold text-lg", children: selectedChat.title || `Chat ${selectedChat.key}` }),
610
- selectedChat.humanAgentEngaged && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-green-100 px-2.5 py-0.5 text-sm font-medium text-green-800", children: [
611
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, User, { className: "mr-1 h-4 w-4" }),
1701
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "p-4 border-b bg-white flex items-center justify-between", children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center space-x-4", children: [
1703
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "font-semibold text-lg", children: selectedChat.title || `Chat ${selectedChat.key}` }),
1704
+ selectedChat.humanAgentEngaged && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "inline-flex items-center rounded-full bg-green-100 px-2.5 py-0.5 text-sm font-medium text-green-800", children: [
1705
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(User, { className: "mr-1 h-4 w-4" }),
612
1706
  "Agent Engaged"
613
1707
  ] })
614
1708
  ] }),
615
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
616
- !selectedChat.humanAgentEngaged ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1709
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center space-x-2", children: [
1710
+ !selectedChat.humanAgentEngaged ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
617
1711
  "button",
618
1712
  {
619
1713
  onClick: handleJoinChat,
620
1714
  className: "bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
621
1715
  children: [
622
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, User, { className: "h-4 w-4" }),
623
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Join Chat" })
1716
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(User, { className: "h-4 w-4" }),
1717
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Join Chat" })
624
1718
  ]
625
1719
  }
626
- ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1720
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
627
1721
  "button",
628
1722
  {
629
1723
  onClick: handleLeaveChat,
630
1724
  className: "bg-orange-500 hover:bg-orange-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
631
1725
  children: [
632
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LogOut, { className: "h-4 w-4" }),
633
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Leave Chat" })
1726
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LogOut, { className: "h-4 w-4" }),
1727
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Leave Chat" })
634
1728
  ]
635
1729
  }
636
1730
  ),
637
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1731
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
638
1732
  "button",
639
1733
  {
640
1734
  onClick: handleEndChat,
641
1735
  className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
642
1736
  children: [
643
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleX, { className: "h-4 w-4" }),
644
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "End Chat" })
1737
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CircleX, { className: "h-4 w-4" }),
1738
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "End Chat" })
645
1739
  ]
646
1740
  }
647
1741
  ),
648
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1742
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
649
1743
  "button",
650
1744
  {
651
1745
  onClick: handleBlockUser,
652
1746
  className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
653
1747
  children: [
654
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleX, { className: "h-4 w-4" }),
655
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Block User" })
1748
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CircleX, { className: "h-4 w-4" }),
1749
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Block User" })
656
1750
  ]
657
1751
  }
658
1752
  ),
659
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1753
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
660
1754
  "button",
661
1755
  {
662
1756
  onClick: handleStartCall,
663
1757
  disabled: !selectedChat.humanAgentEngaged,
664
1758
  className: "bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
665
1759
  children: [
666
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Phone, { className: "h-4 w-4" }),
667
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Start Call" })
1760
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Phone, { className: "h-4 w-4" }),
1761
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Start Call" })
668
1762
  ]
669
1763
  }
670
1764
  ),
671
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1765
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
672
1766
  "button",
673
1767
  {
674
1768
  onClick: handleCreateCase,
675
1769
  className: "bg-purple-500 hover:bg-purple-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
676
1770
  children: [
677
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Plus, { className: "h-4 w-4" }),
678
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Create Case" })
1771
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Plus, { className: "h-4 w-4" }),
1772
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Create Case" })
679
1773
  ]
680
1774
  }
681
1775
  )
@@ -684,20 +1778,20 @@ var ChatHumanAgentActions = ({}) => {
684
1778
  };
685
1779
 
686
1780
  // components/admin/admin-chat-list.tsx
687
- var _react3 = require('@elqnt/react');
688
-
1781
+ var import_react9 = require("@elqnt/react");
1782
+ var import_jsx_runtime5 = require("react/jsx-runtime");
689
1783
  var AdminChatList = ({ className }) => {
690
1784
  const { chats, selectedChat, selectChat } = useWebSocketChatAdminContext();
691
1785
  const sortedChats = Array.from(chats.values()).sort(
692
1786
  (a, b) => b.lastUpdated - a.lastUpdated
693
1787
  );
694
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
695
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border-b", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "font-semibold text-lg", children: "Active Chats" }) }),
696
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 overflow-y-auto", children: sortedChats.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 text-center text-gray-500", children: "No active chats" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "divide-y", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.ScrollArea, { className: "h-[calc(100vh-15rem)]", children: sortedChats.map((chat, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1788
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-full", children: [
1789
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-4 border-b", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: "font-semibold text-lg", children: "Active Chats" }) }),
1790
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-y-auto", children: sortedChats.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-4 text-center text-gray-500", children: "No active chats" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "divide-y", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react9.ScrollArea, { className: "h-[calc(100vh-15rem)]", children: sortedChats.map((chat, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
697
1791
  AdminChatListItem,
698
1792
  {
699
1793
  chat,
700
- isSelected: chat.key === _optionalChain([selectedChat, 'optionalAccess', _8 => _8.key]),
1794
+ isSelected: chat.key === selectedChat?.key,
701
1795
  onSelect: () => selectChat(chat.key)
702
1796
  },
703
1797
  index
@@ -710,31 +1804,31 @@ var AdminChatListItem = ({
710
1804
  onSelect
711
1805
  }) => {
712
1806
  const lastMessage = chat.messages[chat.messages.length - 1];
713
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1807
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
714
1808
  "button",
715
1809
  {
716
1810
  onClick: onSelect,
717
1811
  className: `w-full p-4 text-left hover:bg-gray-50 focus:outline-none focus:bg-gray-50 ${isSelected ? "bg-blue-50" : ""}`,
718
- children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start space-x-3", children: [
719
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "shrink-0", children: [
720
- chat.aiEngaged && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Bot, { className: "w-6 h-6 text-blue-500" }),
721
- chat.isWaitingForAgent && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoaderCircle, { className: "w-6 h-6 text-blue-500 animate-spin text-orange-500" }),
722
- chat.humanAgentEngaged && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserCheck, { className: "w-6 h-6 text-blue-500 text-green-500" })
1812
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-start space-x-3", children: [
1813
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "shrink-0", children: [
1814
+ chat.aiEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Bot, { className: "w-6 h-6 text-blue-500" }),
1815
+ chat.isWaitingForAgent && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LoaderCircle, { className: "w-6 h-6 text-blue-500 animate-spin text-orange-500" }),
1816
+ chat.humanAgentEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UserCheck, { className: "w-6 h-6 text-blue-500 text-green-500" })
723
1817
  ] }),
724
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1 min-w-0", children: [
725
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-between", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-medium text-gray-900 truncate", children: chat.title || `Chat ${chat.key}` }) }),
726
- lastMessage && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mt-1 text-sm text-gray-500 truncate", children: lastMessage.content }),
727
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-1 flex items-center space-x-2", children: [
728
- chat.isWaiting && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-yellow-100 px-2 py-0.5 text-xs font-medium text-yellow-800", children: [
729
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleAlert, { className: "mr-1 h-3 w-3" }),
1818
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex-1 min-w-0", children: [
1819
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm font-medium text-gray-900 truncate", children: chat.title || `Chat ${chat.key}` }) }),
1820
+ lastMessage && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mt-1 text-sm text-gray-500 truncate", children: lastMessage.content }),
1821
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center space-x-2", children: [
1822
+ chat.isWaiting && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "inline-flex items-center rounded-full bg-yellow-100 px-2 py-0.5 text-xs font-medium text-yellow-800", children: [
1823
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CircleAlert, { className: "mr-1 h-3 w-3" }),
730
1824
  "Waiting"
731
1825
  ] }),
732
- chat.humanAgentEngaged && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800", children: [
1826
+ chat.humanAgentEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800", children: [
733
1827
  "Agent Engaged:",
734
1828
  " ",
735
- _optionalChain([chat, 'access', _9 => _9.users, 'optionalAccess', _10 => _10.find, 'call', _11 => _11((u) => u.role === _chunkE2FJX52Rjs.ChatRoleHumanAgent), 'optionalAccess', _12 => _12.name])
1829
+ chat.users?.find((u) => u.role === ChatRoleHumanAgent)?.name
736
1830
  ] }),
737
- chat.isWaitingForAgent && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "inline-flex items-center rounded-full bg-orange-100 px-2 py-0.5 text-xs font-medium text-orange-800", children: "Waiting For Agent" })
1831
+ chat.isWaitingForAgent && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex items-center rounded-full bg-orange-100 px-2 py-0.5 text-xs font-medium text-orange-800", children: "Waiting For Agent" })
738
1832
  ] })
739
1833
  ] })
740
1834
  ] })
@@ -743,27 +1837,27 @@ var AdminChatListItem = ({
743
1837
  };
744
1838
 
745
1839
  // components/admin/admin-chat-header.tsx
746
-
1840
+ var import_jsx_runtime6 = require("react/jsx-runtime");
747
1841
  var AdminChatHeader = ({
748
1842
  className
749
1843
  }) => {
750
1844
  const { isConnected, chats } = useWebSocketChatAdminContext();
751
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border-b", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
752
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1845
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "p-4 border-b", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center space-x-2", children: [
1846
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
753
1847
  "div",
754
1848
  {
755
1849
  className: `w-2 h-2 rounded-full ${isConnected ? "bg-green-500" : "bg-red-500"}`
756
1850
  }
757
1851
  ),
758
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-sm text-gray-600", children: [
1852
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "text-sm text-gray-600", children: [
759
1853
  "Active Chats: ",
760
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-bold", children: chats.size })
1854
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "font-bold", children: chats.size })
761
1855
  ] }),
762
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-gray-500", children: "|" }),
763
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "text-sm text-gray-600", children: [
1856
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-sm text-gray-500", children: "|" }),
1857
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "text-sm text-gray-600", children: [
764
1858
  "Waiting For Agent:",
765
1859
  " ",
766
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-bold", children: Array.from(chats.values()).filter(
1860
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "font-bold", children: Array.from(chats.values()).filter(
767
1861
  (chat) => chat.isWaitingForAgent
768
1862
  ).length })
769
1863
  ] })
@@ -771,10 +1865,10 @@ var AdminChatHeader = ({
771
1865
  };
772
1866
 
773
1867
  // components/customer/chat-status-customer-ui.tsx
774
-
1868
+ var import_jsx_runtime7 = require("react/jsx-runtime");
775
1869
  var ChatStatusCustomerUI = ({ isConnected }) => {
776
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
777
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1870
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center space-x-2", children: [
1871
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
778
1872
  "span",
779
1873
  {
780
1874
  className: `w-3 h-3 rounded-full ${isConnected ? "bg-green-500" : "bg-red-500"}`,
@@ -782,36 +1876,36 @@ var ChatStatusCustomerUI = ({ isConnected }) => {
782
1876
  "aria-label": isConnected ? "Connected" : "Disconnected"
783
1877
  }
784
1878
  ),
785
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm text-gray-500", children: isConnected ? "Connected" : "Reconnecting..." })
1879
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-sm text-gray-500", children: isConnected ? "Connected" : "Reconnecting..." })
786
1880
  ] });
787
1881
  };
788
1882
 
789
1883
  // components/customer/chat-header.tsx
790
-
1884
+ var import_jsx_runtime8 = require("react/jsx-runtime");
791
1885
  var ChatHeader = () => {
792
1886
  const { isConnected, title } = useWebSocketChatCustomerContext();
793
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "p-4 border-b bg-white rounded-t-lg", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between", children: [
794
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "font-bold text-lg", children: title || "Chat" }),
795
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatStatusCustomerUI, { isConnected })
1887
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "p-4 border-b bg-white rounded-t-lg", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between", children: [
1888
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: "font-bold text-lg", children: title || "Chat" }),
1889
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChatStatusCustomerUI, { isConnected })
796
1890
  ] }) });
797
1891
  };
798
1892
 
799
1893
  // components/customer/chat-input.tsx
800
-
801
-
802
-
803
-
1894
+ var import_auth3 = require("@elqnt/auth");
1895
+ var import_ksuid2 = __toESM(require("ksuid"));
1896
+ var import_react10 = require("react");
1897
+ var import_jsx_runtime9 = require("react/jsx-runtime");
804
1898
  var ChatInput = ({ onFileUpload }) => {
805
1899
  const { sendMessage, chatKey } = useWebSocketChatCustomerContext();
806
- const { user, selectedOrgId } = _auth.useUserContext.call(void 0, );
807
- const [input, setInput] = _react.useState.call(void 0, "");
808
- const [isUploading, setIsUploading] = _react.useState.call(void 0, false);
809
- const [isSending, setIsSending] = _react.useState.call(void 0, false);
810
- const fileInputRef = _react.useRef.call(void 0, null);
1900
+ const { user, selectedOrgId } = (0, import_auth3.useUserContext)();
1901
+ const [input, setInput] = (0, import_react10.useState)("");
1902
+ const [isUploading, setIsUploading] = (0, import_react10.useState)(false);
1903
+ const [isSending, setIsSending] = (0, import_react10.useState)(false);
1904
+ const fileInputRef = (0, import_react10.useRef)(null);
811
1905
  const MAX_FILE_SIZE = 5 * 1024 * 1024;
812
1906
  const handleSend = async () => {
813
1907
  if (!input.trim() && !isUploading || isSending) return;
814
- if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _13 => _13.id])) {
1908
+ if (!chatKey || !selectedOrgId || !user?.id) {
815
1909
  console.error("chatKey, orgId, or userId is not defined");
816
1910
  return;
817
1911
  }
@@ -821,12 +1915,12 @@ var ChatInput = ({ onFileUpload }) => {
821
1915
  type: "message",
822
1916
  chatKey,
823
1917
  orgId: selectedOrgId,
824
- userId: _optionalChain([user, 'optionalAccess', _14 => _14.id]),
1918
+ userId: user?.id,
825
1919
  message: {
826
- id: _ksuid2.default.randomSync().string,
1920
+ id: import_ksuid2.default.randomSync().string,
827
1921
  content: input,
828
1922
  role: "user",
829
- senderId: _optionalChain([user, 'optionalAccess', _15 => _15.id]),
1923
+ senderId: user?.id,
830
1924
  time: Date.now(),
831
1925
  status: "sending",
832
1926
  createdAt: Date.now()
@@ -862,7 +1956,7 @@ var ChatInput = ({ onFileUpload }) => {
862
1956
  url: file.url,
863
1957
  title: file.name
864
1958
  }));
865
- if (!chatKey || !selectedOrgId || !_optionalChain([user, 'optionalAccess', _16 => _16.id])) {
1959
+ if (!chatKey || !selectedOrgId || !user?.id) {
866
1960
  console.error("chatKey, orgId, or userId is not defined");
867
1961
  return;
868
1962
  }
@@ -873,9 +1967,9 @@ var ChatInput = ({ onFileUpload }) => {
873
1967
  }
874
1968
  }
875
1969
  };
876
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4 border-t bg-white rounded-b-lg", children: [
877
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center space-x-2", children: [
878
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1970
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "p-4 border-t bg-white rounded-b-lg", children: [
1971
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center space-x-2", children: [
1972
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
879
1973
  "input",
880
1974
  {
881
1975
  type: "file",
@@ -886,17 +1980,17 @@ var ChatInput = ({ onFileUpload }) => {
886
1980
  accept: "image/*,.pdf,.doc,.docx,.txt"
887
1981
  }
888
1982
  ),
889
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1983
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
890
1984
  "button",
891
1985
  {
892
- onClick: () => _optionalChain([fileInputRef, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.click, 'call', _19 => _19()]),
1986
+ onClick: () => fileInputRef.current?.click(),
893
1987
  className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
894
1988
  disabled: isUploading,
895
1989
  "aria-label": "Attach file",
896
- children: isUploading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paperclip, { className: "w-5 h-5" })
1990
+ children: isUploading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Paperclip, { className: "w-5 h-5" })
897
1991
  }
898
1992
  ),
899
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 relative", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1993
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 relative", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
900
1994
  "textarea",
901
1995
  {
902
1996
  value: input,
@@ -916,23 +2010,23 @@ var ChatInput = ({ onFileUpload }) => {
916
2010
  }
917
2011
  }
918
2012
  ) }),
919
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2013
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
920
2014
  "button",
921
2015
  {
922
2016
  onClick: handleSend,
923
2017
  disabled: !input.trim() && !isUploading || isSending,
924
2018
  className: `p-2 rounded-full transition-colors ${!input.trim() && !isUploading || isSending ? "text-gray-400 bg-gray-100" : "text-white bg-blue-500 hover:bg-blue-600"}`,
925
2019
  "aria-label": "Send message",
926
- children: isSending ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Send, { className: "w-5 h-5" })
2020
+ children: isSending ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-5 h-5 animate-spin rounded-full border-2 border-gray-300 border-t-white" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Send, { className: "w-5 h-5" })
927
2021
  }
928
2022
  )
929
2023
  ] }),
930
- isUploading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full bg-gray-200 rounded-full h-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "bg-blue-500 h-1 rounded-full animate-pulse" }) }) })
2024
+ isUploading && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-full bg-gray-200 rounded-full h-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "bg-blue-500 h-1 rounded-full animate-pulse" }) }) })
931
2025
  ] });
932
2026
  };
933
2027
 
934
2028
  // components/customer/chat-messages.tsx
935
-
2029
+ var import_react11 = require("react");
936
2030
 
937
2031
  // ../../node_modules/date-fns/constants.js
938
2032
  var daysInYear = 365.2425;
@@ -971,8 +2065,8 @@ function getDefaultOptions() {
971
2065
  // ../../node_modules/date-fns/startOfWeek.js
972
2066
  function startOfWeek(date, options) {
973
2067
  const defaultOptions2 = getDefaultOptions();
974
- const weekStartsOn = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.weekStartsOn]), () => ( _optionalChain([options, 'optionalAccess', _21 => _21.locale, 'optionalAccess', _22 => _22.options, 'optionalAccess', _23 => _23.weekStartsOn]))), () => ( defaultOptions2.weekStartsOn)), () => ( _optionalChain([defaultOptions2, 'access', _24 => _24.locale, 'optionalAccess', _25 => _25.options, 'optionalAccess', _26 => _26.weekStartsOn]))), () => ( 0));
975
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _27 => _27.in]));
2068
+ const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
2069
+ const _date = toDate(date, options?.in);
976
2070
  const day = _date.getDay();
977
2071
  const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
978
2072
  _date.setDate(_date.getDate() - diff);
@@ -987,7 +2081,7 @@ function startOfISOWeek(date, options) {
987
2081
 
988
2082
  // ../../node_modules/date-fns/getISOWeekYear.js
989
2083
  function getISOWeekYear(date, options) {
990
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _28 => _28.in]));
2084
+ const _date = toDate(date, options?.in);
991
2085
  const year = _date.getFullYear();
992
2086
  const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
993
2087
  fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
@@ -1035,7 +2129,7 @@ function normalizeDates(context, ...dates) {
1035
2129
 
1036
2130
  // ../../node_modules/date-fns/startOfDay.js
1037
2131
  function startOfDay(date, options) {
1038
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _29 => _29.in]));
2132
+ const _date = toDate(date, options?.in);
1039
2133
  _date.setHours(0, 0, 0, 0);
1040
2134
  return _date;
1041
2135
  }
@@ -1043,7 +2137,7 @@ function startOfDay(date, options) {
1043
2137
  // ../../node_modules/date-fns/differenceInCalendarDays.js
1044
2138
  function differenceInCalendarDays(laterDate, earlierDate, options) {
1045
2139
  const [laterDate_, earlierDate_] = normalizeDates(
1046
- _optionalChain([options, 'optionalAccess', _30 => _30.in]),
2140
+ options?.in,
1047
2141
  laterDate,
1048
2142
  earlierDate
1049
2143
  );
@@ -1057,7 +2151,7 @@ function differenceInCalendarDays(laterDate, earlierDate, options) {
1057
2151
  // ../../node_modules/date-fns/startOfISOWeekYear.js
1058
2152
  function startOfISOWeekYear(date, options) {
1059
2153
  const year = getISOWeekYear(date, options);
1060
- const fourthOfJanuary = constructFrom(_optionalChain([options, 'optionalAccess', _31 => _31.in]) || date, 0);
2154
+ const fourthOfJanuary = constructFrom(options?.in || date, 0);
1061
2155
  fourthOfJanuary.setFullYear(year, 0, 4);
1062
2156
  fourthOfJanuary.setHours(0, 0, 0, 0);
1063
2157
  return startOfISOWeek(fourthOfJanuary);
@@ -1075,7 +2169,7 @@ function isValid(date) {
1075
2169
 
1076
2170
  // ../../node_modules/date-fns/startOfYear.js
1077
2171
  function startOfYear(date, options) {
1078
- const date_ = toDate(date, _optionalChain([options, 'optionalAccess', _32 => _32.in]));
2172
+ const date_ = toDate(date, options?.in);
1079
2173
  date_.setFullYear(date_.getFullYear(), 0, 1);
1080
2174
  date_.setHours(0, 0, 0, 0);
1081
2175
  return date_;
@@ -1155,7 +2249,7 @@ var formatDistance = (token, count, options) => {
1155
2249
  } else {
1156
2250
  result = tokenValue.other.replace("{{count}}", count.toString());
1157
2251
  }
1158
- if (_optionalChain([options, 'optionalAccess', _33 => _33.addSuffix])) {
2252
+ if (options?.addSuffix) {
1159
2253
  if (options.comparison && options.comparison > 0) {
1160
2254
  return "in " + result;
1161
2255
  } else {
@@ -1222,15 +2316,15 @@ var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale
1222
2316
  // ../../node_modules/date-fns/locale/_lib/buildLocalizeFn.js
1223
2317
  function buildLocalizeFn(args) {
1224
2318
  return (value, options) => {
1225
- const context = _optionalChain([options, 'optionalAccess', _34 => _34.context]) ? String(options.context) : "standalone";
2319
+ const context = options?.context ? String(options.context) : "standalone";
1226
2320
  let valuesArray;
1227
2321
  if (context === "formatting" && args.formattingValues) {
1228
2322
  const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1229
- const width = _optionalChain([options, 'optionalAccess', _35 => _35.width]) ? String(options.width) : defaultWidth;
2323
+ const width = options?.width ? String(options.width) : defaultWidth;
1230
2324
  valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1231
2325
  } else {
1232
2326
  const defaultWidth = args.defaultWidth;
1233
- const width = _optionalChain([options, 'optionalAccess', _36 => _36.width]) ? String(options.width) : args.defaultWidth;
2327
+ const width = options?.width ? String(options.width) : args.defaultWidth;
1234
2328
  valuesArray = args.values[width] || args.values[defaultWidth];
1235
2329
  }
1236
2330
  const index = args.argumentCallback ? args.argumentCallback(value) : value;
@@ -1592,7 +2686,7 @@ var enUS = {
1592
2686
 
1593
2687
  // ../../node_modules/date-fns/getDayOfYear.js
1594
2688
  function getDayOfYear(date, options) {
1595
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _37 => _37.in]));
2689
+ const _date = toDate(date, options?.in);
1596
2690
  const diff = differenceInCalendarDays(_date, startOfYear(_date));
1597
2691
  const dayOfYear = diff + 1;
1598
2692
  return dayOfYear;
@@ -1600,22 +2694,22 @@ function getDayOfYear(date, options) {
1600
2694
 
1601
2695
  // ../../node_modules/date-fns/getISOWeek.js
1602
2696
  function getISOWeek(date, options) {
1603
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _38 => _38.in]));
2697
+ const _date = toDate(date, options?.in);
1604
2698
  const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
1605
2699
  return Math.round(diff / millisecondsInWeek) + 1;
1606
2700
  }
1607
2701
 
1608
2702
  // ../../node_modules/date-fns/getWeekYear.js
1609
2703
  function getWeekYear(date, options) {
1610
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _39 => _39.in]));
2704
+ const _date = toDate(date, options?.in);
1611
2705
  const year = _date.getFullYear();
1612
2706
  const defaultOptions2 = getDefaultOptions();
1613
- const firstWeekContainsDate = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.firstWeekContainsDate]), () => ( _optionalChain([options, 'optionalAccess', _41 => _41.locale, 'optionalAccess', _42 => _42.options, 'optionalAccess', _43 => _43.firstWeekContainsDate]))), () => ( defaultOptions2.firstWeekContainsDate)), () => ( _optionalChain([defaultOptions2, 'access', _44 => _44.locale, 'optionalAccess', _45 => _45.options, 'optionalAccess', _46 => _46.firstWeekContainsDate]))), () => ( 1));
1614
- const firstWeekOfNextYear = constructFrom(_optionalChain([options, 'optionalAccess', _47 => _47.in]) || date, 0);
2707
+ const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
2708
+ const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
1615
2709
  firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
1616
2710
  firstWeekOfNextYear.setHours(0, 0, 0, 0);
1617
2711
  const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
1618
- const firstWeekOfThisYear = constructFrom(_optionalChain([options, 'optionalAccess', _48 => _48.in]) || date, 0);
2712
+ const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
1619
2713
  firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
1620
2714
  firstWeekOfThisYear.setHours(0, 0, 0, 0);
1621
2715
  const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
@@ -1631,9 +2725,9 @@ function getWeekYear(date, options) {
1631
2725
  // ../../node_modules/date-fns/startOfWeekYear.js
1632
2726
  function startOfWeekYear(date, options) {
1633
2727
  const defaultOptions2 = getDefaultOptions();
1634
- const firstWeekContainsDate = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.firstWeekContainsDate]), () => ( _optionalChain([options, 'optionalAccess', _50 => _50.locale, 'optionalAccess', _51 => _51.options, 'optionalAccess', _52 => _52.firstWeekContainsDate]))), () => ( defaultOptions2.firstWeekContainsDate)), () => ( _optionalChain([defaultOptions2, 'access', _53 => _53.locale, 'optionalAccess', _54 => _54.options, 'optionalAccess', _55 => _55.firstWeekContainsDate]))), () => ( 1));
2728
+ const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
1635
2729
  const year = getWeekYear(date, options);
1636
- const firstWeek = constructFrom(_optionalChain([options, 'optionalAccess', _56 => _56.in]) || date, 0);
2730
+ const firstWeek = constructFrom(options?.in || date, 0);
1637
2731
  firstWeek.setFullYear(year, 0, firstWeekContainsDate);
1638
2732
  firstWeek.setHours(0, 0, 0, 0);
1639
2733
  const _date = startOfWeek(firstWeek, options);
@@ -1642,7 +2736,7 @@ function startOfWeekYear(date, options) {
1642
2736
 
1643
2737
  // ../../node_modules/date-fns/getWeek.js
1644
2738
  function getWeek(date, options) {
1645
- const _date = toDate(date, _optionalChain([options, 'optionalAccess', _57 => _57.in]));
2739
+ const _date = toDate(date, options?.in);
1646
2740
  const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
1647
2741
  return Math.round(diff / millisecondsInWeek) + 1;
1648
2742
  }
@@ -2445,10 +3539,10 @@ var doubleQuoteRegExp = /''/g;
2445
3539
  var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2446
3540
  function format(date, formatStr, options) {
2447
3541
  const defaultOptions2 = getDefaultOptions();
2448
- const locale = _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _58 => _58.locale]), () => ( defaultOptions2.locale)), () => ( enUS));
2449
- const firstWeekContainsDate = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _59 => _59.firstWeekContainsDate]), () => ( _optionalChain([options, 'optionalAccess', _60 => _60.locale, 'optionalAccess', _61 => _61.options, 'optionalAccess', _62 => _62.firstWeekContainsDate]))), () => ( defaultOptions2.firstWeekContainsDate)), () => ( _optionalChain([defaultOptions2, 'access', _63 => _63.locale, 'optionalAccess', _64 => _64.options, 'optionalAccess', _65 => _65.firstWeekContainsDate]))), () => ( 1));
2450
- const weekStartsOn = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _66 => _66.weekStartsOn]), () => ( _optionalChain([options, 'optionalAccess', _67 => _67.locale, 'optionalAccess', _68 => _68.options, 'optionalAccess', _69 => _69.weekStartsOn]))), () => ( defaultOptions2.weekStartsOn)), () => ( _optionalChain([defaultOptions2, 'access', _70 => _70.locale, 'optionalAccess', _71 => _71.options, 'optionalAccess', _72 => _72.weekStartsOn]))), () => ( 0));
2451
- const originalDate = toDate(date, _optionalChain([options, 'optionalAccess', _73 => _73.in]));
3542
+ const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
3543
+ const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
3544
+ const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
3545
+ const originalDate = toDate(date, options?.in);
2452
3546
  if (!isValid(originalDate)) {
2453
3547
  throw new RangeError("Invalid time value");
2454
3548
  }
@@ -2488,7 +3582,7 @@ function format(date, formatStr, options) {
2488
3582
  return parts.map((part) => {
2489
3583
  if (!part.isToken) return part.value;
2490
3584
  const token = part.value;
2491
- if (!_optionalChain([options, 'optionalAccess', _74 => _74.useAdditionalWeekYearTokens]) && isProtectedWeekYearToken(token) || !_optionalChain([options, 'optionalAccess', _75 => _75.useAdditionalDayOfYearTokens]) && isProtectedDayOfYearToken(token)) {
3585
+ if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
2492
3586
  warnOrThrowProtectedError(token, formatStr, String(date));
2493
3587
  }
2494
3588
  const formatter = formatters[token[0]];
@@ -2504,16 +3598,16 @@ function cleanEscapedString(input) {
2504
3598
  }
2505
3599
 
2506
3600
  // components/markdown-renderer.tsx
2507
- var _reactmarkdown = require('react-markdown'); var _reactmarkdown2 = _interopRequireDefault(_reactmarkdown);
2508
- var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
2509
-
3601
+ var import_react_markdown = __toESM(require("react-markdown"));
3602
+ var import_remark_gfm = __toESM(require("remark-gfm"));
3603
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2510
3604
  function MarkdownRenderer({ content }) {
2511
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2512
- _reactmarkdown2.default,
3605
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3606
+ import_react_markdown.default,
2513
3607
  {
2514
- remarkPlugins: [_remarkgfm2.default],
3608
+ remarkPlugins: [import_remark_gfm.default],
2515
3609
  components: {
2516
- a: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3610
+ a: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2517
3611
  "a",
2518
3612
  {
2519
3613
  target: "_blank",
@@ -2522,20 +3616,20 @@ function MarkdownRenderer({ content }) {
2522
3616
  ...props
2523
3617
  }
2524
3618
  ),
2525
- h1: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h1", { className: "text-2xl font-bold mt-6 mb-4", ...props }),
2526
- h2: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "text-xl font-semibold mt-5 mb-3", ...props }),
2527
- h3: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-lg font-semibold mt-4 mb-2", ...props }),
2528
- code: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3619
+ h1: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { className: "text-2xl font-bold mt-6 mb-4", ...props }),
3620
+ h2: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: "text-xl font-semibold mt-5 mb-3", ...props }),
3621
+ h3: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-lg font-semibold mt-4 mb-2", ...props }),
3622
+ code: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2529
3623
  "code",
2530
3624
  {
2531
3625
  className: "block bg-gray-100 p-3 rounded font-mono",
2532
3626
  ...props
2533
3627
  }
2534
3628
  ),
2535
- ul: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "list-disc pl-6 my-4", ...props }),
2536
- ol: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "list-decimal pl-6 my-4", ...props }),
2537
- p: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "my-4", ...props }),
2538
- blockquote: ({ node, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3629
+ ul: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "list-disc pl-6 my-4", ...props }),
3630
+ ol: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ol", { className: "list-decimal pl-6 my-4", ...props }),
3631
+ p: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "my-4", ...props }),
3632
+ blockquote: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2539
3633
  "blockquote",
2540
3634
  {
2541
3635
  className: "border-l-4 border-gray-200 pl-4 my-4 italic",
@@ -2549,13 +3643,13 @@ function MarkdownRenderer({ content }) {
2549
3643
  }
2550
3644
 
2551
3645
  // components/customer/chat-message.tsx
2552
-
3646
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2553
3647
  var Message = ({
2554
3648
  message: message2,
2555
3649
  isConsecutive,
2556
3650
  onRetry
2557
3651
  }) => {
2558
- const renderAttachment = (attachment, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mt-2", children: attachment.type === "image" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3652
+ const renderAttachment = (attachment, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mt-2", children: attachment.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2559
3653
  "img",
2560
3654
  {
2561
3655
  src: attachment.url,
@@ -2563,7 +3657,7 @@ var Message = ({
2563
3657
  className: "max-w-full rounded",
2564
3658
  loading: "lazy"
2565
3659
  }
2566
- ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3660
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2567
3661
  "a",
2568
3662
  {
2569
3663
  href: attachment.url,
@@ -2571,12 +3665,12 @@ var Message = ({
2571
3665
  target: "_blank",
2572
3666
  rel: "noopener noreferrer",
2573
3667
  children: [
2574
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Paperclip, { className: "w-4 h-4" }),
2575
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: attachment.title })
3668
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Paperclip, { className: "w-4 h-4" }),
3669
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: attachment.title })
2576
3670
  ]
2577
3671
  }
2578
3672
  ) }, index);
2579
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3673
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2580
3674
  "div",
2581
3675
  {
2582
3676
  className: "flex justify-start gap-2",
@@ -2584,33 +3678,33 @@ var Message = ({
2584
3678
  role: "article",
2585
3679
  "aria-label": `Message from ${message2.senderId}`,
2586
3680
  children: [
2587
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex pt-10 w-10", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "w-8 h-8 rounded-full flex justify-center", children: [
2588
- message2.role === "user" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, User, {}),
2589
- message2.role === "ai" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Bot, {}),
2590
- message2.role === "humanAgent" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserCog, {})
3681
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex pt-10 w-10", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "w-8 h-8 rounded-full flex justify-center", children: [
3682
+ message2.role === "user" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(User, {}),
3683
+ message2.role === "ai" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Bot, {}),
3684
+ message2.role === "humanAgent" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(UserCog, {})
2591
3685
  ] }) }),
2592
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3686
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2593
3687
  "div",
2594
3688
  {
2595
3689
  className: `p-3 rounded-lg max-w-[80%] bg-gray-100 text-primary-900 ${isConsecutive ? "mt-1" : "mt-4"}`,
2596
3690
  children: [
2597
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "break-words", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MarkdownRenderer, { content: message2.content }) }),
2598
- _optionalChain([message2, 'access', _76 => _76.attachments, 'optionalAccess', _77 => _77.map, 'call', _78 => _78(
3691
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "break-words", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MarkdownRenderer, { content: message2.content }) }),
3692
+ message2.attachments?.map(
2599
3693
  (attachment, i) => renderAttachment(attachment, i)
2600
- )]),
2601
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-end space-x-1 mt-1", children: [
2602
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs opacity-70", children: format(message2.time, "HH:mm") }),
2603
- message2.role === "user" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
2604
- message2.status === "sending" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "w-4 h-4 animate-spin rounded-full border-2 border-gray-300 border-t-white" }),
2605
- message2.status === "sent" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Check, { className: "w-4 h-4" }),
2606
- message2.status === "delivered" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckCheck, { className: "w-4 h-4" }),
2607
- message2.status === "failed" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3694
+ ),
3695
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-end space-x-1 mt-1", children: [
3696
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-xs opacity-70", children: format(message2.time, "HH:mm") }),
3697
+ message2.role === "user" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
3698
+ message2.status === "sending" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "w-4 h-4 animate-spin rounded-full border-2 border-gray-300 border-t-white" }),
3699
+ message2.status === "sent" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Check, { className: "w-4 h-4" }),
3700
+ message2.status === "delivered" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckCheck, { className: "w-4 h-4" }),
3701
+ message2.status === "failed" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2608
3702
  "button",
2609
3703
  {
2610
3704
  onClick: () => onRetry(message2.id),
2611
3705
  className: "text-red-300 hover:text-red-400",
2612
3706
  "aria-label": "Retry sending message",
2613
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleAlert, { className: "w-4 h-4" })
3707
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CircleAlert, { className: "w-4 h-4" })
2614
3708
  }
2615
3709
  )
2616
3710
  ] })
@@ -2624,19 +3718,19 @@ var Message = ({
2624
3718
  };
2625
3719
 
2626
3720
  // components/customer/chat-messages.tsx
2627
-
3721
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2628
3722
  var ChatMessages = ({
2629
3723
  onRetry,
2630
3724
  messages
2631
3725
  }) => {
2632
- const messageEndRef = _react.useRef.call(void 0, null);
3726
+ const messageEndRef = (0, import_react11.useRef)(null);
2633
3727
  const scrollToBottom = () => {
2634
- _optionalChain([messageEndRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.scrollIntoView, 'call', _81 => _81({ behavior: "smooth" })]);
3728
+ messageEndRef.current?.scrollIntoView({ behavior: "smooth" });
2635
3729
  };
2636
- _react.useEffect.call(void 0, () => {
3730
+ (0, import_react11.useEffect)(() => {
2637
3731
  scrollToBottom();
2638
3732
  }, [messages]);
2639
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3733
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2640
3734
  "div",
2641
3735
  {
2642
3736
  className: "flex-1 overflow-y-auto p-4 space-y-4 bg-white min-h-[calc(100vh-290px)]",
@@ -2644,10 +3738,10 @@ var ChatMessages = ({
2644
3738
  "aria-label": "Chat messages",
2645
3739
  children: [
2646
3740
  messages.filter(
2647
- (msg) => (!_optionalChain([msg, 'access', _82 => _82.toolCalls, 'optionalAccess', _83 => _83.length]) || msg.toolCalls.length === 0) && !msg.toolCallId
3741
+ (msg) => (!msg.toolCalls?.length || msg.toolCalls.length === 0) && !msg.toolCallId
2648
3742
  ).map((msg, index) => {
2649
3743
  const isConsecutive = index > 0 && messages[index - 1].senderId === msg.senderId && msg.time - messages[index - 1].time < 3e5;
2650
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3744
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2651
3745
  Message,
2652
3746
  {
2653
3747
  message: msg,
@@ -2657,246 +3751,247 @@ var ChatMessages = ({
2657
3751
  msg.id
2658
3752
  );
2659
3753
  }),
2660
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: messageEndRef })
3754
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: messageEndRef })
2661
3755
  ]
2662
3756
  }
2663
3757
  );
2664
3758
  };
2665
3759
 
2666
3760
  // components/customer/chat-typing-indicator.tsx
2667
-
3761
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2668
3762
  var ChatTypingIndicator = ({
2669
3763
  typingUsers
2670
3764
  }) => {
2671
3765
  if (typingUsers.size === 0) return null;
2672
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "px-4 py-2 text-sm text-gray-500 italic", role: "status", children: [
3766
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "px-4 py-2 text-sm text-gray-500 italic", role: "status", children: [
2673
3767
  Array.from(typingUsers).join(", "),
2674
3768
  " typing..."
2675
3769
  ] });
2676
3770
  };
2677
3771
 
2678
3772
  // components/customer/generic-chat-widget.tsx
2679
-
2680
-
2681
-
3773
+ var import_react12 = require("@elqnt/react");
3774
+ var import_react13 = require("react");
3775
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2682
3776
  var GenericChatWidget = ({
2683
3777
  onFileUpload
2684
3778
  }) => {
2685
- const [typingUsers] = _react.useState.call(void 0, /* @__PURE__ */ new Set());
3779
+ const [typingUsers] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
2686
3780
  const { error, messages } = useWebSocketChatCustomerContext();
2687
3781
  const handleRetry = (messageId) => {
2688
3782
  };
2689
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3783
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2690
3784
  "div",
2691
3785
  {
2692
3786
  className: "flex flex-col w-full max-w-lg border rounded-lg shadow-lg",
2693
3787
  role: "region",
2694
3788
  "aria-label": "Chat interface",
2695
3789
  children: [
2696
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatHeader, {}),
2697
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react3.Alert, { title: "Error", description: error.message }),
2698
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatMessages, { onRetry: handleRetry, messages }),
2699
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatTypingIndicator, { typingUsers }),
2700
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChatInput, { onFileUpload })
3790
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatHeader, {}),
3791
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react12.Alert, { title: "Error", description: error.message }),
3792
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatMessages, { onRetry: handleRetry, messages }),
3793
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatTypingIndicator, { typingUsers }),
3794
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatInput, { onFileUpload })
2701
3795
  ]
2702
3796
  }
2703
3797
  );
2704
3798
  };
2705
-
2706
-
2707
-
2708
-
2709
-
2710
-
2711
-
2712
-
2713
-
2714
-
2715
-
2716
-
2717
-
2718
-
2719
-
2720
-
2721
-
2722
-
2723
-
2724
-
2725
-
2726
-
2727
-
2728
-
2729
-
2730
-
2731
-
2732
-
2733
-
2734
-
2735
-
2736
-
2737
-
2738
-
2739
-
2740
-
2741
-
2742
-
2743
-
2744
-
2745
-
2746
-
2747
-
2748
-
2749
-
2750
-
2751
-
2752
-
2753
-
2754
-
2755
-
2756
-
2757
-
2758
-
2759
-
2760
-
2761
-
2762
-
2763
-
2764
-
2765
-
2766
-
2767
-
2768
-
2769
-
2770
-
2771
-
2772
-
2773
-
2774
-
2775
-
2776
-
2777
-
2778
-
2779
-
2780
-
2781
-
2782
-
2783
-
2784
-
2785
-
2786
-
2787
-
2788
-
2789
-
2790
-
2791
-
2792
-
2793
-
2794
-
2795
-
2796
-
2797
-
2798
-
2799
-
2800
-
2801
-
2802
-
2803
-
2804
-
2805
-
2806
-
2807
-
2808
-
2809
-
2810
-
2811
-
2812
-
2813
-
2814
-
2815
-
2816
-
2817
-
2818
-
2819
-
2820
-
2821
-
2822
-
2823
-
2824
-
2825
-
2826
-
2827
-
2828
-
2829
-
2830
-
2831
-
2832
-
2833
-
2834
-
2835
-
2836
-
2837
-
2838
-
2839
-
2840
-
2841
-
2842
-
2843
-
2844
-
2845
-
2846
-
2847
-
2848
-
2849
-
2850
-
2851
-
2852
-
2853
-
2854
-
2855
-
2856
-
2857
-
2858
-
2859
-
2860
-
2861
-
2862
-
2863
-
2864
-
2865
-
2866
-
2867
-
2868
-
2869
-
2870
-
2871
-
2872
-
2873
-
2874
-
2875
-
2876
-
2877
-
2878
-
2879
-
2880
-
2881
-
2882
-
2883
-
2884
-
2885
-
2886
-
2887
-
2888
-
2889
-
2890
-
2891
-
2892
-
2893
-
2894
-
2895
-
2896
-
2897
-
2898
-
2899
- exports.AdminChatHeader = AdminChatHeader; exports.AdminChatInput = AdminChatInput; exports.AdminChatList = AdminChatList; exports.AdminChatListItem = AdminChatListItem; exports.AgentStatusAway = _chunkE2FJX52Rjs.AgentStatusAway; exports.AgentStatusBusy = _chunkE2FJX52Rjs.AgentStatusBusy; exports.AgentStatusOffline = _chunkE2FJX52Rjs.AgentStatusOffline; exports.AgentStatusOnline = _chunkE2FJX52Rjs.AgentStatusOnline; exports.AssignChatToAgentSubject = _chunkE2FJX52Rjs.AssignChatToAgentSubject; exports.AttachmentTypeActions = _chunkE2FJX52Rjs.AttachmentTypeActions; exports.AttachmentTypeArticles = _chunkE2FJX52Rjs.AttachmentTypeArticles; exports.AttachmentTypeAudio = _chunkE2FJX52Rjs.AttachmentTypeAudio; exports.AttachmentTypeBullets = _chunkE2FJX52Rjs.AttachmentTypeBullets; exports.AttachmentTypeData = _chunkE2FJX52Rjs.AttachmentTypeData; exports.AttachmentTypeDocument = _chunkE2FJX52Rjs.AttachmentTypeDocument; exports.AttachmentTypeDocumentAnalysis = _chunkE2FJX52Rjs.AttachmentTypeDocumentAnalysis; exports.AttachmentTypeDocumentSources = _chunkE2FJX52Rjs.AttachmentTypeDocumentSources; exports.AttachmentTypeImage = _chunkE2FJX52Rjs.AttachmentTypeImage; exports.AttachmentTypeKGNodes = _chunkE2FJX52Rjs.AttachmentTypeKGNodes; exports.AttachmentTypeLocation = _chunkE2FJX52Rjs.AttachmentTypeLocation; exports.AttachmentTypeRecords = _chunkE2FJX52Rjs.AttachmentTypeRecords; exports.AttachmentTypeReferences = _chunkE2FJX52Rjs.AttachmentTypeReferences; exports.AttachmentTypeSticker = _chunkE2FJX52Rjs.AttachmentTypeSticker; exports.AttachmentTypeSubsections = _chunkE2FJX52Rjs.AttachmentTypeSubsections; exports.AttachmentTypeVideo = _chunkE2FJX52Rjs.AttachmentTypeVideo; exports.ChatArchiveSubjectPattern = _chunkE2FJX52Rjs.ChatArchiveSubjectPattern; exports.ChatEventTypeAgentActivityPing = _chunkE2FJX52Rjs.ChatEventTypeAgentActivityPing; exports.ChatEventTypeAgentChatAssigned = _chunkE2FJX52Rjs.ChatEventTypeAgentChatAssigned; exports.ChatEventTypeAgentChatCompleted = _chunkE2FJX52Rjs.ChatEventTypeAgentChatCompleted; exports.ChatEventTypeAgentContextUpdate = _chunkE2FJX52Rjs.ChatEventTypeAgentContextUpdate; exports.ChatEventTypeAgentExecutionEnded = _chunkE2FJX52Rjs.ChatEventTypeAgentExecutionEnded; exports.ChatEventTypeAgentExecutionStarted = _chunkE2FJX52Rjs.ChatEventTypeAgentExecutionStarted; exports.ChatEventTypeAgentSessionEnd = _chunkE2FJX52Rjs.ChatEventTypeAgentSessionEnd; exports.ChatEventTypeAgentSessionStart = _chunkE2FJX52Rjs.ChatEventTypeAgentSessionStart; exports.ChatEventTypeAgentStatusChange = _chunkE2FJX52Rjs.ChatEventTypeAgentStatusChange; exports.ChatEventTypeBlockUser = _chunkE2FJX52Rjs.ChatEventTypeBlockUser; exports.ChatEventTypeCSATRequest = _chunkE2FJX52Rjs.ChatEventTypeCSATRequest; exports.ChatEventTypeCSATResponse = _chunkE2FJX52Rjs.ChatEventTypeCSATResponse; exports.ChatEventTypeCSATSurvey = _chunkE2FJX52Rjs.ChatEventTypeCSATSurvey; exports.ChatEventTypeChatEnded = _chunkE2FJX52Rjs.ChatEventTypeChatEnded; exports.ChatEventTypeChatRemoved = _chunkE2FJX52Rjs.ChatEventTypeChatRemoved; exports.ChatEventTypeChatUpdated = _chunkE2FJX52Rjs.ChatEventTypeChatUpdated; exports.ChatEventTypeClientAction = _chunkE2FJX52Rjs.ChatEventTypeClientAction; exports.ChatEventTypeClientActionCallback = _chunkE2FJX52Rjs.ChatEventTypeClientActionCallback; exports.ChatEventTypeCreateRoom = _chunkE2FJX52Rjs.ChatEventTypeCreateRoom; exports.ChatEventTypeDeleteRoom = _chunkE2FJX52Rjs.ChatEventTypeDeleteRoom; exports.ChatEventTypeDelivered = _chunkE2FJX52Rjs.ChatEventTypeDelivered; exports.ChatEventTypeEndChat = _chunkE2FJX52Rjs.ChatEventTypeEndChat; exports.ChatEventTypeError = _chunkE2FJX52Rjs.ChatEventTypeError; exports.ChatEventTypeGetAgents = _chunkE2FJX52Rjs.ChatEventTypeGetAgents; exports.ChatEventTypeGetAgentsResponse = _chunkE2FJX52Rjs.ChatEventTypeGetAgentsResponse; exports.ChatEventTypeGetOnlineUsers = _chunkE2FJX52Rjs.ChatEventTypeGetOnlineUsers; exports.ChatEventTypeHumanAgentJoined = _chunkE2FJX52Rjs.ChatEventTypeHumanAgentJoined; exports.ChatEventTypeHumanAgentLeft = _chunkE2FJX52Rjs.ChatEventTypeHumanAgentLeft; exports.ChatEventTypeInviteUser = _chunkE2FJX52Rjs.ChatEventTypeInviteUser; exports.ChatEventTypeJoinRoom = _chunkE2FJX52Rjs.ChatEventTypeJoinRoom; exports.ChatEventTypeLeaveRoom = _chunkE2FJX52Rjs.ChatEventTypeLeaveRoom; exports.ChatEventTypeListChats = _chunkE2FJX52Rjs.ChatEventTypeListChats; exports.ChatEventTypeListRooms = _chunkE2FJX52Rjs.ChatEventTypeListRooms; exports.ChatEventTypeLoadAgentContext = _chunkE2FJX52Rjs.ChatEventTypeLoadAgentContext; exports.ChatEventTypeLoadAgentContextResponse = _chunkE2FJX52Rjs.ChatEventTypeLoadAgentContextResponse; exports.ChatEventTypeLoadChat = _chunkE2FJX52Rjs.ChatEventTypeLoadChat; exports.ChatEventTypeLoadChatResponse = _chunkE2FJX52Rjs.ChatEventTypeLoadChatResponse; exports.ChatEventTypeMentionUser = _chunkE2FJX52Rjs.ChatEventTypeMentionUser; exports.ChatEventTypeMessage = _chunkE2FJX52Rjs.ChatEventTypeMessage; exports.ChatEventTypeMessageDeleted = _chunkE2FJX52Rjs.ChatEventTypeMessageDeleted; exports.ChatEventTypeMessageDeletedResponse = _chunkE2FJX52Rjs.ChatEventTypeMessageDeletedResponse; exports.ChatEventTypeMessageEdited = _chunkE2FJX52Rjs.ChatEventTypeMessageEdited; exports.ChatEventTypeMessageEditedResponse = _chunkE2FJX52Rjs.ChatEventTypeMessageEditedResponse; exports.ChatEventTypeMessageReaction = _chunkE2FJX52Rjs.ChatEventTypeMessageReaction; exports.ChatEventTypeMessageReactionResponse = _chunkE2FJX52Rjs.ChatEventTypeMessageReactionResponse; exports.ChatEventTypeMessageReply = _chunkE2FJX52Rjs.ChatEventTypeMessageReply; exports.ChatEventTypeMessageStatusUpdate = _chunkE2FJX52Rjs.ChatEventTypeMessageStatusUpdate; exports.ChatEventTypeNewChat = _chunkE2FJX52Rjs.ChatEventTypeNewChat; exports.ChatEventTypeNewChatCreated = _chunkE2FJX52Rjs.ChatEventTypeNewChatCreated; exports.ChatEventTypeObserverJoined = _chunkE2FJX52Rjs.ChatEventTypeObserverJoined; exports.ChatEventTypeObserverLeft = _chunkE2FJX52Rjs.ChatEventTypeObserverLeft; exports.ChatEventTypeOnlineUsersResponse = _chunkE2FJX52Rjs.ChatEventTypeOnlineUsersResponse; exports.ChatEventTypePing = _chunkE2FJX52Rjs.ChatEventTypePing; exports.ChatEventTypePlanApproved = _chunkE2FJX52Rjs.ChatEventTypePlanApproved; exports.ChatEventTypePlanCompleted = _chunkE2FJX52Rjs.ChatEventTypePlanCompleted; exports.ChatEventTypePlanPendingApproval = _chunkE2FJX52Rjs.ChatEventTypePlanPendingApproval; exports.ChatEventTypePlanRejected = _chunkE2FJX52Rjs.ChatEventTypePlanRejected; exports.ChatEventTypePong = _chunkE2FJX52Rjs.ChatEventTypePong; exports.ChatEventTypeRead = _chunkE2FJX52Rjs.ChatEventTypeRead; exports.ChatEventTypeReconnected = _chunkE2FJX52Rjs.ChatEventTypeReconnected; exports.ChatEventTypeRoomCreated = _chunkE2FJX52Rjs.ChatEventTypeRoomCreated; exports.ChatEventTypeRoomDeleted = _chunkE2FJX52Rjs.ChatEventTypeRoomDeleted; exports.ChatEventTypeRoomUpdated = _chunkE2FJX52Rjs.ChatEventTypeRoomUpdated; exports.ChatEventTypeRoomUserJoined = _chunkE2FJX52Rjs.ChatEventTypeRoomUserJoined; exports.ChatEventTypeRoomUserLeft = _chunkE2FJX52Rjs.ChatEventTypeRoomUserLeft; exports.ChatEventTypeRoomsResponse = _chunkE2FJX52Rjs.ChatEventTypeRoomsResponse; exports.ChatEventTypeStepCompleted = _chunkE2FJX52Rjs.ChatEventTypeStepCompleted; exports.ChatEventTypeStepFailed = _chunkE2FJX52Rjs.ChatEventTypeStepFailed; exports.ChatEventTypeStepStarted = _chunkE2FJX52Rjs.ChatEventTypeStepStarted; exports.ChatEventTypeStoppedTyping = _chunkE2FJX52Rjs.ChatEventTypeStoppedTyping; exports.ChatEventTypeSummaryUpdate = _chunkE2FJX52Rjs.ChatEventTypeSummaryUpdate; exports.ChatEventTypeSyncMetadata = _chunkE2FJX52Rjs.ChatEventTypeSyncMetadata; exports.ChatEventTypeSyncMetadataResponse = _chunkE2FJX52Rjs.ChatEventTypeSyncMetadataResponse; exports.ChatEventTypeSyncUserSession = _chunkE2FJX52Rjs.ChatEventTypeSyncUserSession; exports.ChatEventTypeSyncUserSessionResponse = _chunkE2FJX52Rjs.ChatEventTypeSyncUserSessionResponse; exports.ChatEventTypeTyping = _chunkE2FJX52Rjs.ChatEventTypeTyping; exports.ChatEventTypeUpdateRoom = _chunkE2FJX52Rjs.ChatEventTypeUpdateRoom; exports.ChatEventTypeUserActivity = _chunkE2FJX52Rjs.ChatEventTypeUserActivity; exports.ChatEventTypeUserActivityUpdate = _chunkE2FJX52Rjs.ChatEventTypeUserActivityUpdate; exports.ChatEventTypeUserInvited = _chunkE2FJX52Rjs.ChatEventTypeUserInvited; exports.ChatEventTypeUserJoined = _chunkE2FJX52Rjs.ChatEventTypeUserJoined; exports.ChatEventTypeUserLeft = _chunkE2FJX52Rjs.ChatEventTypeUserLeft; exports.ChatEventTypeUserPresenceChanged = _chunkE2FJX52Rjs.ChatEventTypeUserPresenceChanged; exports.ChatEventTypeUserPresenceEnd = _chunkE2FJX52Rjs.ChatEventTypeUserPresenceEnd; exports.ChatEventTypeUserPresenceStart = _chunkE2FJX52Rjs.ChatEventTypeUserPresenceStart; exports.ChatEventTypeUserRemoved = _chunkE2FJX52Rjs.ChatEventTypeUserRemoved; exports.ChatEventTypeUserStatusChange = _chunkE2FJX52Rjs.ChatEventTypeUserStatusChange; exports.ChatEventTypeUserSuggestedActionSelected = _chunkE2FJX52Rjs.ChatEventTypeUserSuggestedActionSelected; exports.ChatEventTypeUserSuggestedActions = _chunkE2FJX52Rjs.ChatEventTypeUserSuggestedActions; exports.ChatEventTypeWaiting = _chunkE2FJX52Rjs.ChatEventTypeWaiting; exports.ChatEventTypeWaitingForAgent = _chunkE2FJX52Rjs.ChatEventTypeWaitingForAgent; exports.ChatHeader = ChatHeader; exports.ChatHumanAgentActions = ChatHumanAgentActions; exports.ChatInput = ChatInput; exports.ChatMessages = ChatMessages; exports.ChatRoleAI = _chunkE2FJX52Rjs.ChatRoleAI; exports.ChatRoleDataQuery = _chunkE2FJX52Rjs.ChatRoleDataQuery; exports.ChatRoleEvent = _chunkE2FJX52Rjs.ChatRoleEvent; exports.ChatRoleHumanAgent = _chunkE2FJX52Rjs.ChatRoleHumanAgent; exports.ChatRoleObserver = _chunkE2FJX52Rjs.ChatRoleObserver; exports.ChatRoleSystem = _chunkE2FJX52Rjs.ChatRoleSystem; exports.ChatRoleTool = _chunkE2FJX52Rjs.ChatRoleTool; exports.ChatRoleUser = _chunkE2FJX52Rjs.ChatRoleUser; exports.ChatSessionStatusActive = _chunkE2FJX52Rjs.ChatSessionStatusActive; exports.ChatSessionStatusExpired = _chunkE2FJX52Rjs.ChatSessionStatusExpired; exports.ChatSessionStatusIdle = _chunkE2FJX52Rjs.ChatSessionStatusIdle; exports.ChatStatusAbandoned = _chunkE2FJX52Rjs.ChatStatusAbandoned; exports.ChatStatusActive = _chunkE2FJX52Rjs.ChatStatusActive; exports.ChatStatusArchived = _chunkE2FJX52Rjs.ChatStatusArchived; exports.ChatStatusClosed = _chunkE2FJX52Rjs.ChatStatusClosed; exports.ChatStatusCustomerUI = ChatStatusCustomerUI; exports.ChatStatusDisconnected = _chunkE2FJX52Rjs.ChatStatusDisconnected; exports.ChatTypeCustomerSupport = _chunkE2FJX52Rjs.ChatTypeCustomerSupport; exports.ChatTypeDirect = _chunkE2FJX52Rjs.ChatTypeDirect; exports.ChatTypeGroup = _chunkE2FJX52Rjs.ChatTypeGroup; exports.ChatTypePrivateRoom = _chunkE2FJX52Rjs.ChatTypePrivateRoom; exports.ChatTypePublicRoom = _chunkE2FJX52Rjs.ChatTypePublicRoom; exports.ChatTypingIndicator = ChatTypingIndicator; exports.CompleteChatByAgentSubject = _chunkE2FJX52Rjs.CompleteChatByAgentSubject; exports.CreateAgentQueueSubject = _chunkE2FJX52Rjs.CreateAgentQueueSubject; exports.DeleteAgentQueueSubject = _chunkE2FJX52Rjs.DeleteAgentQueueSubject; exports.EndAgentSessionSubject = _chunkE2FJX52Rjs.EndAgentSessionSubject; exports.GenericChatWidget = GenericChatWidget; exports.GetActiveChatCountSubject = _chunkE2FJX52Rjs.GetActiveChatCountSubject; exports.GetActiveChatsSubject = _chunkE2FJX52Rjs.GetActiveChatsSubject; exports.GetAgentQueuesSubject = _chunkE2FJX52Rjs.GetAgentQueuesSubject; exports.GetAgentSessionSubject = _chunkE2FJX52Rjs.GetAgentSessionSubject; exports.GetChatSubject = _chunkE2FJX52Rjs.GetChatSubject; exports.GetDailyChatCountSubject = _chunkE2FJX52Rjs.GetDailyChatCountSubject; exports.GetOnlineAgentCountSubject = _chunkE2FJX52Rjs.GetOnlineAgentCountSubject; exports.GetOnlineAgentsSubject = _chunkE2FJX52Rjs.GetOnlineAgentsSubject; exports.GetOnlineUsersSubject = _chunkE2FJX52Rjs.GetOnlineUsersSubject; exports.GetQueueChatCountSubject = _chunkE2FJX52Rjs.GetQueueChatCountSubject; exports.GetQueueChatsSubject = _chunkE2FJX52Rjs.GetQueueChatsSubject; exports.GetUserChatsSubject = _chunkE2FJX52Rjs.GetUserChatsSubject; exports.GetWaitingForAgentChatCountSubject = _chunkE2FJX52Rjs.GetWaitingForAgentChatCountSubject; exports.GetWaitingForAgentChatsSubject = _chunkE2FJX52Rjs.GetWaitingForAgentChatsSubject; exports.MessageStatusDelivered = _chunkE2FJX52Rjs.MessageStatusDelivered; exports.MessageStatusFailed = _chunkE2FJX52Rjs.MessageStatusFailed; exports.MessageStatusRead = _chunkE2FJX52Rjs.MessageStatusRead; exports.MessageStatusSending = _chunkE2FJX52Rjs.MessageStatusSending; exports.MessageStatusSent = _chunkE2FJX52Rjs.MessageStatusSent; exports.QueueTypeComplexity = _chunkE2FJX52Rjs.QueueTypeComplexity; exports.QueueTypeDepartment = _chunkE2FJX52Rjs.QueueTypeDepartment; exports.QueueTypePriority = _chunkE2FJX52Rjs.QueueTypePriority; exports.QueueTypeSkill = _chunkE2FJX52Rjs.QueueTypeSkill; exports.QueueTypes = _chunkE2FJX52Rjs.QueueTypes; exports.SetupOrgSubject = _chunkE2FJX52Rjs.SetupOrgSubject; exports.StartAgentSessionSubject = _chunkE2FJX52Rjs.StartAgentSessionSubject; exports.TriggerAnalyticsScanSubject = _chunkE2FJX52Rjs.TriggerAnalyticsScanSubject; exports.UpdateAgentLastActivitySubject = _chunkE2FJX52Rjs.UpdateAgentLastActivitySubject; exports.UpdateAgentQueueSubject = _chunkE2FJX52Rjs.UpdateAgentQueueSubject; exports.UpdateAgentStatusSubject = _chunkE2FJX52Rjs.UpdateAgentStatusSubject; exports.UpdateUserStatusSubject = _chunkE2FJX52Rjs.UpdateUserStatusSubject; exports.UserStatusAway = _chunkE2FJX52Rjs.UserStatusAway; exports.UserStatusBusy = _chunkE2FJX52Rjs.UserStatusBusy; exports.UserStatusOffline = _chunkE2FJX52Rjs.UserStatusOffline; exports.UserStatusOnline = _chunkE2FJX52Rjs.UserStatusOnline; exports.WebSocketChatAdminContext = WebSocketChatAdminContext; exports.WebSocketChatAdminProvider = WebSocketChatAdminProvider; exports.WebSocketChatCustomerContext = WebSocketChatCustomerContext; exports.WebSocketChatCustomerProvider = WebSocketChatCustomerProvider; exports.useWebSocketChatAdmin = _chunkE2FJX52Rjs.useWebSocketChatAdmin; exports.useWebSocketChatAdminContext = useWebSocketChatAdminContext; exports.useWebSocketChatBase = _chunkDTFTLFSYjs.useWebSocketChatBase; exports.useWebSocketChatCustomer = _chunk3PXNBY7Jjs.useWebSocketChatCustomer; exports.useWebSocketChatCustomerContext = useWebSocketChatCustomerContext;
3799
+ // Annotate the CommonJS export names for ESM import in node:
3800
+ 0 && (module.exports = {
3801
+ AdminChatHeader,
3802
+ AdminChatInput,
3803
+ AdminChatList,
3804
+ AdminChatListItem,
3805
+ AgentStatusAway,
3806
+ AgentStatusBusy,
3807
+ AgentStatusOffline,
3808
+ AgentStatusOnline,
3809
+ AssignChatToAgentSubject,
3810
+ AttachmentTypeActions,
3811
+ AttachmentTypeArticles,
3812
+ AttachmentTypeAudio,
3813
+ AttachmentTypeBullets,
3814
+ AttachmentTypeData,
3815
+ AttachmentTypeDocument,
3816
+ AttachmentTypeDocumentAnalysis,
3817
+ AttachmentTypeDocumentSources,
3818
+ AttachmentTypeImage,
3819
+ AttachmentTypeKGNodes,
3820
+ AttachmentTypeLocation,
3821
+ AttachmentTypeRecords,
3822
+ AttachmentTypeReferences,
3823
+ AttachmentTypeSticker,
3824
+ AttachmentTypeSubsections,
3825
+ AttachmentTypeVideo,
3826
+ ChatArchiveSubjectPattern,
3827
+ ChatEventTypeAgentActivityPing,
3828
+ ChatEventTypeAgentChatAssigned,
3829
+ ChatEventTypeAgentChatCompleted,
3830
+ ChatEventTypeAgentContextUpdate,
3831
+ ChatEventTypeAgentExecutionEnded,
3832
+ ChatEventTypeAgentExecutionStarted,
3833
+ ChatEventTypeAgentSessionEnd,
3834
+ ChatEventTypeAgentSessionStart,
3835
+ ChatEventTypeAgentStatusChange,
3836
+ ChatEventTypeBlockUser,
3837
+ ChatEventTypeCSATRequest,
3838
+ ChatEventTypeCSATResponse,
3839
+ ChatEventTypeCSATSurvey,
3840
+ ChatEventTypeChatEnded,
3841
+ ChatEventTypeChatRemoved,
3842
+ ChatEventTypeChatUpdated,
3843
+ ChatEventTypeClientAction,
3844
+ ChatEventTypeClientActionCallback,
3845
+ ChatEventTypeCreateRoom,
3846
+ ChatEventTypeDeleteRoom,
3847
+ ChatEventTypeDelivered,
3848
+ ChatEventTypeEndChat,
3849
+ ChatEventTypeError,
3850
+ ChatEventTypeGetAgents,
3851
+ ChatEventTypeGetAgentsResponse,
3852
+ ChatEventTypeGetOnlineUsers,
3853
+ ChatEventTypeHumanAgentJoined,
3854
+ ChatEventTypeHumanAgentLeft,
3855
+ ChatEventTypeInviteUser,
3856
+ ChatEventTypeJoinRoom,
3857
+ ChatEventTypeLeaveRoom,
3858
+ ChatEventTypeListChats,
3859
+ ChatEventTypeListRooms,
3860
+ ChatEventTypeLoadAgentContext,
3861
+ ChatEventTypeLoadAgentContextResponse,
3862
+ ChatEventTypeLoadChat,
3863
+ ChatEventTypeLoadChatResponse,
3864
+ ChatEventTypeMentionUser,
3865
+ ChatEventTypeMessage,
3866
+ ChatEventTypeMessageDeleted,
3867
+ ChatEventTypeMessageDeletedResponse,
3868
+ ChatEventTypeMessageEdited,
3869
+ ChatEventTypeMessageEditedResponse,
3870
+ ChatEventTypeMessageReaction,
3871
+ ChatEventTypeMessageReactionResponse,
3872
+ ChatEventTypeMessageReply,
3873
+ ChatEventTypeMessageStatusUpdate,
3874
+ ChatEventTypeNewChat,
3875
+ ChatEventTypeNewChatCreated,
3876
+ ChatEventTypeObserverJoined,
3877
+ ChatEventTypeObserverLeft,
3878
+ ChatEventTypeOnlineUsersResponse,
3879
+ ChatEventTypePing,
3880
+ ChatEventTypePlanApproved,
3881
+ ChatEventTypePlanCompleted,
3882
+ ChatEventTypePlanPendingApproval,
3883
+ ChatEventTypePlanRejected,
3884
+ ChatEventTypePong,
3885
+ ChatEventTypeRead,
3886
+ ChatEventTypeReconnected,
3887
+ ChatEventTypeRoomCreated,
3888
+ ChatEventTypeRoomDeleted,
3889
+ ChatEventTypeRoomUpdated,
3890
+ ChatEventTypeRoomUserJoined,
3891
+ ChatEventTypeRoomUserLeft,
3892
+ ChatEventTypeRoomsResponse,
3893
+ ChatEventTypeStepCompleted,
3894
+ ChatEventTypeStepFailed,
3895
+ ChatEventTypeStepStarted,
3896
+ ChatEventTypeStoppedTyping,
3897
+ ChatEventTypeSummaryUpdate,
3898
+ ChatEventTypeSyncMetadata,
3899
+ ChatEventTypeSyncMetadataResponse,
3900
+ ChatEventTypeSyncUserSession,
3901
+ ChatEventTypeSyncUserSessionResponse,
3902
+ ChatEventTypeTyping,
3903
+ ChatEventTypeUpdateRoom,
3904
+ ChatEventTypeUserActivity,
3905
+ ChatEventTypeUserActivityUpdate,
3906
+ ChatEventTypeUserInvited,
3907
+ ChatEventTypeUserJoined,
3908
+ ChatEventTypeUserLeft,
3909
+ ChatEventTypeUserPresenceChanged,
3910
+ ChatEventTypeUserPresenceEnd,
3911
+ ChatEventTypeUserPresenceStart,
3912
+ ChatEventTypeUserRemoved,
3913
+ ChatEventTypeUserStatusChange,
3914
+ ChatEventTypeUserSuggestedActionSelected,
3915
+ ChatEventTypeUserSuggestedActions,
3916
+ ChatEventTypeWaiting,
3917
+ ChatEventTypeWaitingForAgent,
3918
+ ChatHeader,
3919
+ ChatHumanAgentActions,
3920
+ ChatInput,
3921
+ ChatMessages,
3922
+ ChatRoleAI,
3923
+ ChatRoleDataQuery,
3924
+ ChatRoleEvent,
3925
+ ChatRoleHumanAgent,
3926
+ ChatRoleObserver,
3927
+ ChatRoleSystem,
3928
+ ChatRoleTool,
3929
+ ChatRoleUser,
3930
+ ChatSessionStatusActive,
3931
+ ChatSessionStatusExpired,
3932
+ ChatSessionStatusIdle,
3933
+ ChatStatusAbandoned,
3934
+ ChatStatusActive,
3935
+ ChatStatusArchived,
3936
+ ChatStatusClosed,
3937
+ ChatStatusCustomerUI,
3938
+ ChatStatusDisconnected,
3939
+ ChatTypeCustomerSupport,
3940
+ ChatTypeDirect,
3941
+ ChatTypeGroup,
3942
+ ChatTypePrivateRoom,
3943
+ ChatTypePublicRoom,
3944
+ ChatTypingIndicator,
3945
+ CompleteChatByAgentSubject,
3946
+ CreateAgentQueueSubject,
3947
+ DeleteAgentQueueSubject,
3948
+ EndAgentSessionSubject,
3949
+ GenericChatWidget,
3950
+ GetActiveChatCountSubject,
3951
+ GetActiveChatsSubject,
3952
+ GetAgentQueuesSubject,
3953
+ GetAgentSessionSubject,
3954
+ GetChatSubject,
3955
+ GetDailyChatCountSubject,
3956
+ GetOnlineAgentCountSubject,
3957
+ GetOnlineAgentsSubject,
3958
+ GetOnlineUsersSubject,
3959
+ GetQueueChatCountSubject,
3960
+ GetQueueChatsSubject,
3961
+ GetUserChatsSubject,
3962
+ GetWaitingForAgentChatCountSubject,
3963
+ GetWaitingForAgentChatsSubject,
3964
+ MessageStatusDelivered,
3965
+ MessageStatusFailed,
3966
+ MessageStatusRead,
3967
+ MessageStatusSending,
3968
+ MessageStatusSent,
3969
+ QueueTypeComplexity,
3970
+ QueueTypeDepartment,
3971
+ QueueTypePriority,
3972
+ QueueTypeSkill,
3973
+ QueueTypes,
3974
+ SetupOrgSubject,
3975
+ StartAgentSessionSubject,
3976
+ TriggerAnalyticsScanSubject,
3977
+ UpdateAgentLastActivitySubject,
3978
+ UpdateAgentQueueSubject,
3979
+ UpdateAgentStatusSubject,
3980
+ UpdateUserStatusSubject,
3981
+ UserStatusAway,
3982
+ UserStatusBusy,
3983
+ UserStatusOffline,
3984
+ UserStatusOnline,
3985
+ WebSocketChatAdminContext,
3986
+ WebSocketChatAdminProvider,
3987
+ WebSocketChatCustomerContext,
3988
+ WebSocketChatCustomerProvider,
3989
+ useWebSocketChatAdmin,
3990
+ useWebSocketChatAdminContext,
3991
+ useWebSocketChatBase,
3992
+ useWebSocketChatCustomer,
3993
+ useWebSocketChatCustomerContext
3994
+ });
2900
3995
  /*! Bundled license information:
2901
3996
 
2902
3997
  lucide-react/dist/esm/shared/src/utils.js: