@elqnt/chat 1.0.21 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -231,214 +231,15 @@ __export(index_exports, {
231
231
  module.exports = __toCommonJS(index_exports);
232
232
 
233
233
  // components/admin/admin-chat-input.tsx
234
- var import_auth = require("@elqnt/auth");
235
234
  var import_ksuid = __toESM(require("ksuid"));
236
-
237
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
238
- var import_react2 = require("react");
239
-
240
- // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
241
- var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
242
- var mergeClasses = (...classes) => classes.filter((className, index, array) => {
243
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
244
- }).join(" ").trim();
245
-
246
- // ../../node_modules/lucide-react/dist/esm/Icon.js
247
- var import_react = require("react");
248
-
249
- // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
250
- var defaultAttributes = {
251
- xmlns: "http://www.w3.org/2000/svg",
252
- width: 24,
253
- height: 24,
254
- viewBox: "0 0 24 24",
255
- fill: "none",
256
- stroke: "currentColor",
257
- strokeWidth: 2,
258
- strokeLinecap: "round",
259
- strokeLinejoin: "round"
260
- };
261
-
262
- // ../../node_modules/lucide-react/dist/esm/Icon.js
263
- var Icon = (0, import_react.forwardRef)(
264
- ({
265
- color = "currentColor",
266
- size = 24,
267
- strokeWidth = 2,
268
- absoluteStrokeWidth,
269
- className = "",
270
- children,
271
- iconNode,
272
- ...rest
273
- }, ref) => {
274
- return (0, import_react.createElement)(
275
- "svg",
276
- {
277
- ref,
278
- ...defaultAttributes,
279
- width: size,
280
- height: size,
281
- stroke: color,
282
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
283
- className: mergeClasses("lucide", className),
284
- ...rest
285
- },
286
- [
287
- ...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
288
- ...Array.isArray(children) ? children : [children]
289
- ]
290
- );
291
- }
292
- );
293
-
294
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
295
- var createLucideIcon = (iconName, iconNode) => {
296
- const Component = (0, import_react2.forwardRef)(
297
- ({ className, ...props }, ref) => (0, import_react2.createElement)(Icon, {
298
- ref,
299
- iconNode,
300
- className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
301
- ...props
302
- })
303
- );
304
- Component.displayName = `${iconName}`;
305
- return Component;
306
- };
307
-
308
- // ../../node_modules/lucide-react/dist/esm/icons/bot.js
309
- var __iconNode = [
310
- ["path", { d: "M12 8V4H8", key: "hb8ula" }],
311
- ["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2", key: "enze0r" }],
312
- ["path", { d: "M2 14h2", key: "vft8re" }],
313
- ["path", { d: "M20 14h2", key: "4cs60a" }],
314
- ["path", { d: "M15 13v2", key: "1xurst" }],
315
- ["path", { d: "M9 13v2", key: "rq6x2g" }]
316
- ];
317
- var Bot = createLucideIcon("Bot", __iconNode);
318
-
319
- // ../../node_modules/lucide-react/dist/esm/icons/check-check.js
320
- var __iconNode2 = [
321
- ["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
322
- ["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
323
- ];
324
- var CheckCheck = createLucideIcon("CheckCheck", __iconNode2);
325
-
326
- // ../../node_modules/lucide-react/dist/esm/icons/check.js
327
- var __iconNode3 = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
328
- var Check = createLucideIcon("Check", __iconNode3);
329
-
330
- // ../../node_modules/lucide-react/dist/esm/icons/circle-alert.js
331
- var __iconNode4 = [
332
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
333
- ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
334
- ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
335
- ];
336
- var CircleAlert = createLucideIcon("CircleAlert", __iconNode4);
337
-
338
- // ../../node_modules/lucide-react/dist/esm/icons/circle-x.js
339
- var __iconNode5 = [
340
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
341
- ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
342
- ["path", { d: "m9 9 6 6", key: "z0biqf" }]
343
- ];
344
- var CircleX = createLucideIcon("CircleX", __iconNode5);
345
-
346
- // ../../node_modules/lucide-react/dist/esm/icons/loader-circle.js
347
- var __iconNode6 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
348
- var LoaderCircle = createLucideIcon("LoaderCircle", __iconNode6);
349
-
350
- // ../../node_modules/lucide-react/dist/esm/icons/log-out.js
351
- var __iconNode7 = [
352
- ["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", key: "1uf3rs" }],
353
- ["polyline", { points: "16 17 21 12 16 7", key: "1gabdz" }],
354
- ["line", { x1: "21", x2: "9", y1: "12", y2: "12", key: "1uyos4" }]
355
- ];
356
- var LogOut = createLucideIcon("LogOut", __iconNode7);
357
-
358
- // ../../node_modules/lucide-react/dist/esm/icons/paperclip.js
359
- var __iconNode8 = [
360
- ["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
361
- [
362
- "path",
363
- {
364
- d: "m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",
365
- key: "1pkts6"
366
- }
367
- ]
368
- ];
369
- var Paperclip = createLucideIcon("Paperclip", __iconNode8);
370
-
371
- // ../../node_modules/lucide-react/dist/esm/icons/phone.js
372
- var __iconNode9 = [
373
- [
374
- "path",
375
- {
376
- d: "M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",
377
- key: "foiqr5"
378
- }
379
- ]
380
- ];
381
- var Phone = createLucideIcon("Phone", __iconNode9);
382
-
383
- // ../../node_modules/lucide-react/dist/esm/icons/plus.js
384
- var __iconNode10 = [
385
- ["path", { d: "M5 12h14", key: "1ays0h" }],
386
- ["path", { d: "M12 5v14", key: "s699le" }]
387
- ];
388
- var Plus = createLucideIcon("Plus", __iconNode10);
389
-
390
- // ../../node_modules/lucide-react/dist/esm/icons/send.js
391
- var __iconNode11 = [
392
- [
393
- "path",
394
- {
395
- d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
396
- key: "1ffxy3"
397
- }
398
- ],
399
- ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
400
- ];
401
- var Send = createLucideIcon("Send", __iconNode11);
402
-
403
- // ../../node_modules/lucide-react/dist/esm/icons/user-check.js
404
- var __iconNode12 = [
405
- ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
406
- ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
407
- ["polyline", { points: "16 11 18 13 22 9", key: "1pwet4" }]
408
- ];
409
- var UserCheck = createLucideIcon("UserCheck", __iconNode12);
410
-
411
- // ../../node_modules/lucide-react/dist/esm/icons/user-cog.js
412
- var __iconNode13 = [
413
- ["circle", { cx: "18", cy: "15", r: "3", key: "gjjjvw" }],
414
- ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
415
- ["path", { d: "M10 15H6a4 4 0 0 0-4 4v2", key: "1nfge6" }],
416
- ["path", { d: "m21.7 16.4-.9-.3", key: "12j9ji" }],
417
- ["path", { d: "m15.2 13.9-.9-.3", key: "1fdjdi" }],
418
- ["path", { d: "m16.6 18.7.3-.9", key: "heedtr" }],
419
- ["path", { d: "m19.1 12.2.3-.9", key: "1af3ki" }],
420
- ["path", { d: "m19.6 18.7-.4-1", key: "1x9vze" }],
421
- ["path", { d: "m16.8 12.3-.4-1", key: "vqeiwj" }],
422
- ["path", { d: "m14.3 16.6 1-.4", key: "1qlj63" }],
423
- ["path", { d: "m20.7 13.8 1-.4", key: "1v5t8k" }]
424
- ];
425
- var UserCog = createLucideIcon("UserCog", __iconNode13);
426
-
427
- // ../../node_modules/lucide-react/dist/esm/icons/user.js
428
- var __iconNode14 = [
429
- ["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
430
- ["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
431
- ];
432
- var User = createLucideIcon("User", __iconNode14);
433
-
434
- // components/admin/admin-chat-input.tsx
435
- var import_react7 = require("react");
235
+ var import_lucide_react = require("lucide-react");
236
+ var import_react5 = require("react");
436
237
 
437
238
  // context/websocket-chat-admin-context.tsx
438
- var import_react6 = require("react");
239
+ var import_react4 = require("react");
439
240
 
440
241
  // hooks/use-websocket-chat-admin.ts
441
- var import_react4 = require("react");
242
+ var import_react2 = require("react");
442
243
 
443
244
  // models/chat-models.ts
444
245
  var ChatStatusActive = "active";
@@ -624,7 +425,7 @@ var TriggerAnalyticsScanSubject = "chat.analytics.trigger-scan";
624
425
  var SetupOrgSubject = "chat.org.setup";
625
426
 
626
427
  // hooks/use-websocket-chat-base.ts
627
- var import_react3 = require("react");
428
+ var import_react = require("react");
628
429
  var createDefaultLogger = (debug) => ({
629
430
  debug: debug ? console.log : () => {
630
431
  },
@@ -662,10 +463,10 @@ var useWebSocketChatBase = ({
662
463
  heartbeatTimeout = DEFAULT_HEARTBEAT_TIMEOUT,
663
464
  transport = DEFAULT_TRANSPORT
664
465
  }) => {
665
- const [connectionState, setConnectionState] = (0, import_react3.useState)("disconnected");
666
- const [error, setError] = (0, import_react3.useState)(void 0);
667
- const [startTime, setStartTime] = (0, import_react3.useState)(void 0);
668
- const [metrics, setMetrics] = (0, import_react3.useState)({
466
+ const [connectionState, setConnectionState] = (0, import_react.useState)("disconnected");
467
+ const [error, setError] = (0, import_react.useState)(void 0);
468
+ const [startTime, setStartTime] = (0, import_react.useState)(void 0);
469
+ const [metrics, setMetrics] = (0, import_react.useState)({
669
470
  latency: 0,
670
471
  messagesSent: 0,
671
472
  messagesReceived: 0,
@@ -673,41 +474,41 @@ var useWebSocketChatBase = ({
673
474
  reconnectCount: 0,
674
475
  transportType: transport
675
476
  });
676
- const wsRef = (0, import_react3.useRef)(void 0);
677
- const sseRef = (0, import_react3.useRef)(void 0);
678
- const transportRef = (0, import_react3.useRef)(transport);
679
- (0, import_react3.useEffect)(() => {
477
+ const wsRef = (0, import_react.useRef)(void 0);
478
+ const sseRef = (0, import_react.useRef)(void 0);
479
+ const transportRef = (0, import_react.useRef)(transport);
480
+ (0, import_react.useEffect)(() => {
680
481
  transportRef.current = transport;
681
482
  }, [transport]);
682
- const reconnectTimeoutRef = (0, import_react3.useRef)(void 0);
683
- const retryCountRef = (0, import_react3.useRef)(0);
684
- const messageQueueRef = (0, import_react3.useRef)([]);
685
- const mountedRef = (0, import_react3.useRef)(false);
686
- const currentChatKeyRef = (0, import_react3.useRef)(void 0);
687
- const currentUserIdRef = (0, import_react3.useRef)(void 0);
688
- const intentionalDisconnectRef = (0, import_react3.useRef)(false);
689
- const eventHandlersRef = (0, import_react3.useRef)(
483
+ const reconnectTimeoutRef = (0, import_react.useRef)(void 0);
484
+ const retryCountRef = (0, import_react.useRef)(0);
485
+ const messageQueueRef = (0, import_react.useRef)([]);
486
+ const mountedRef = (0, import_react.useRef)(false);
487
+ const currentChatKeyRef = (0, import_react.useRef)(void 0);
488
+ const currentUserIdRef = (0, import_react.useRef)(void 0);
489
+ const intentionalDisconnectRef = (0, import_react.useRef)(false);
490
+ const eventHandlersRef = (0, import_react.useRef)(
690
491
  /* @__PURE__ */ new Map()
691
492
  );
692
- const onMessageRef = (0, import_react3.useRef)(onMessage);
693
- const pendingMessagesRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
694
- const heartbeatIntervalRef = (0, import_react3.useRef)(void 0);
695
- const heartbeatTimeoutRef = (0, import_react3.useRef)(void 0);
696
- const lastPongRef = (0, import_react3.useRef)(Date.now());
697
- const chatCreationPromiseRef = (0, import_react3.useRef)(null);
698
- const loadChatRetryMapRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
699
- (0, import_react3.useEffect)(() => {
493
+ const onMessageRef = (0, import_react.useRef)(onMessage);
494
+ const pendingMessagesRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
495
+ const heartbeatIntervalRef = (0, import_react.useRef)(void 0);
496
+ const heartbeatTimeoutRef = (0, import_react.useRef)(void 0);
497
+ const lastPongRef = (0, import_react.useRef)(Date.now());
498
+ const chatCreationPromiseRef = (0, import_react.useRef)(null);
499
+ const loadChatRetryMapRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
500
+ (0, import_react.useEffect)(() => {
700
501
  onMessageRef.current = onMessage;
701
502
  }, [onMessage]);
702
503
  const isConnected = connectionState === "connected";
703
- const on = (0, import_react3.useCallback)((eventType, handler) => {
504
+ const on = (0, import_react.useCallback)((eventType, handler) => {
704
505
  if (!eventHandlersRef.current.has(eventType)) {
705
506
  eventHandlersRef.current.set(eventType, /* @__PURE__ */ new Set());
706
507
  }
707
508
  eventHandlersRef.current.get(eventType).add(handler);
708
509
  return () => off(eventType, handler);
709
510
  }, []);
710
- const off = (0, import_react3.useCallback)((eventType, handler) => {
511
+ const off = (0, import_react.useCallback)((eventType, handler) => {
711
512
  const handlers = eventHandlersRef.current.get(eventType);
712
513
  if (handlers) {
713
514
  handlers.delete(handler);
@@ -716,7 +517,7 @@ var useWebSocketChatBase = ({
716
517
  }
717
518
  }
718
519
  }, []);
719
- const emit = (0, import_react3.useCallback)(
520
+ const emit = (0, import_react.useCallback)(
720
521
  (eventType, data) => {
721
522
  const handlers = eventHandlersRef.current.get(eventType);
722
523
  if (handlers) {
@@ -731,10 +532,10 @@ var useWebSocketChatBase = ({
731
532
  },
732
533
  [logger]
733
534
  );
734
- const updateMetrics = (0, import_react3.useCallback)((updates) => {
535
+ const updateMetrics = (0, import_react.useCallback)((updates) => {
735
536
  setMetrics((prev) => ({ ...prev, ...updates }));
736
537
  }, []);
737
- const addToQueue = (0, import_react3.useCallback)(
538
+ const addToQueue = (0, import_react.useCallback)(
738
539
  (event) => {
739
540
  const currentQueueSize = messageQueueRef.current.length;
740
541
  const maxSize = queueConfig.maxSize || DEFAULT_QUEUE_CONFIG.maxSize;
@@ -753,7 +554,7 @@ var useWebSocketChatBase = ({
753
554
  },
754
555
  [queueConfig, logger, updateMetrics]
755
556
  );
756
- const calculateRetryInterval = (0, import_react3.useCallback)(
557
+ const calculateRetryInterval = (0, import_react.useCallback)(
757
558
  (retryCount) => {
758
559
  const config = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };
759
560
  const {
@@ -770,7 +571,7 @@ var useWebSocketChatBase = ({
770
571
  },
771
572
  [retryConfig]
772
573
  );
773
- const startHeartbeat = (0, import_react3.useCallback)(() => {
574
+ const startHeartbeat = (0, import_react.useCallback)(() => {
774
575
  if (!heartbeatInterval || heartbeatInterval <= 0) return;
775
576
  const sendPing = () => {
776
577
  if (wsRef.current?.readyState === WebSocket.OPEN) {
@@ -792,7 +593,7 @@ var useWebSocketChatBase = ({
792
593
  heartbeatIntervalRef.current = setInterval(sendPing, heartbeatInterval);
793
594
  logger.debug("Heartbeat started");
794
595
  }, [heartbeatInterval, heartbeatTimeout, logger]);
795
- const stopHeartbeat = (0, import_react3.useCallback)(() => {
596
+ const stopHeartbeat = (0, import_react.useCallback)(() => {
796
597
  if (heartbeatIntervalRef.current) {
797
598
  clearInterval(heartbeatIntervalRef.current);
798
599
  heartbeatIntervalRef.current = void 0;
@@ -803,7 +604,7 @@ var useWebSocketChatBase = ({
803
604
  }
804
605
  logger.debug("Heartbeat stopped");
805
606
  }, [logger]);
806
- const cleanup = (0, import_react3.useCallback)(() => {
607
+ const cleanup = (0, import_react.useCallback)(() => {
807
608
  if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
808
609
  wsRef.current.close(1e3, "Cleanup");
809
610
  }
@@ -829,10 +630,10 @@ var useWebSocketChatBase = ({
829
630
  });
830
631
  loadChatRetryMapRef.current.clear();
831
632
  }, [stopHeartbeat]);
832
- const getRestApiUrl = (0, import_react3.useCallback)((endpoint) => {
633
+ const getRestApiUrl = (0, import_react.useCallback)((endpoint) => {
833
634
  return `${serverBaseUrl}/${endpoint}`;
834
635
  }, [serverBaseUrl]);
835
- const sendRestMessage = (0, import_react3.useCallback)(
636
+ const sendRestMessage = (0, import_react.useCallback)(
836
637
  async (endpoint, body) => {
837
638
  const url = getRestApiUrl(endpoint);
838
639
  logger.debug(`SSE REST API call: POST ${endpoint}`, body);
@@ -857,7 +658,7 @@ var useWebSocketChatBase = ({
857
658
  },
858
659
  [getRestApiUrl, logger]
859
660
  );
860
- const connect = (0, import_react3.useCallback)(
661
+ const connect = (0, import_react.useCallback)(
861
662
  async (userId) => {
862
663
  if (!mountedRef.current) {
863
664
  mountedRef.current = true;
@@ -1338,7 +1139,7 @@ var useWebSocketChatBase = ({
1338
1139
  emit
1339
1140
  ]
1340
1141
  );
1341
- const sendMessage = (0, import_react3.useCallback)(
1142
+ const sendMessage = (0, import_react.useCallback)(
1342
1143
  (event, overrideUserId) => {
1343
1144
  return new Promise(async (resolve, reject) => {
1344
1145
  if (!mountedRef.current) {
@@ -1544,7 +1345,7 @@ var useWebSocketChatBase = ({
1544
1345
  },
1545
1346
  [connectionState, connect, addToQueue, logger, metrics, updateMetrics, sendRestMessage, emit, orgId]
1546
1347
  );
1547
- const startNewChat = (0, import_react3.useCallback)(
1348
+ const startNewChat = (0, import_react.useCallback)(
1548
1349
  (userId, data) => {
1549
1350
  return new Promise((resolve, reject) => {
1550
1351
  if (!userId) {
@@ -1578,7 +1379,7 @@ var useWebSocketChatBase = ({
1578
1379
  },
1579
1380
  [sendMessage, orgId, logger]
1580
1381
  );
1581
- const disconnect = (0, import_react3.useCallback)(
1382
+ const disconnect = (0, import_react.useCallback)(
1582
1383
  (intentional = true) => {
1583
1384
  logger.info("Disconnecting", { intentional, transport: transportRef.current });
1584
1385
  intentionalDisconnectRef.current = intentional;
@@ -1592,10 +1393,10 @@ var useWebSocketChatBase = ({
1592
1393
  },
1593
1394
  [cleanup, logger]
1594
1395
  );
1595
- const clearError = (0, import_react3.useCallback)(() => {
1396
+ const clearError = (0, import_react.useCallback)(() => {
1596
1397
  setError(void 0);
1597
1398
  }, []);
1598
- (0, import_react3.useEffect)(() => {
1399
+ (0, import_react.useEffect)(() => {
1599
1400
  mountedRef.current = true;
1600
1401
  return () => {
1601
1402
  mountedRef.current = false;
@@ -1624,9 +1425,9 @@ var useWebSocketChatAdmin = ({
1624
1425
  orgId,
1625
1426
  product
1626
1427
  }) => {
1627
- const [chats, setChats] = (0, import_react4.useState)(/* @__PURE__ */ new Map());
1628
- const [selectedChat, setSelectedChat] = (0, import_react4.useState)(void 0);
1629
- const handleMessage = (0, import_react4.useCallback)(
1428
+ const [chats, setChats] = (0, import_react2.useState)(/* @__PURE__ */ new Map());
1429
+ const [selectedChat, setSelectedChat] = (0, import_react2.useState)(void 0);
1430
+ const handleMessage = (0, import_react2.useCallback)(
1630
1431
  (chatEvent) => {
1631
1432
  switch (chatEvent.type) {
1632
1433
  case "message":
@@ -1692,7 +1493,7 @@ var useWebSocketChatAdmin = ({
1692
1493
  onMessage: handleMessage,
1693
1494
  product
1694
1495
  });
1695
- const selectChat = (0, import_react4.useCallback)(
1496
+ const selectChat = (0, import_react2.useCallback)(
1696
1497
  (chatKey) => {
1697
1498
  const chat = chats.get(chatKey);
1698
1499
  if (!chat) {
@@ -1703,7 +1504,7 @@ var useWebSocketChatAdmin = ({
1703
1504
  },
1704
1505
  [chats, orgId, base.sendMessage]
1705
1506
  );
1706
- const addUserToChat = (0, import_react4.useCallback)(
1507
+ const addUserToChat = (0, import_react2.useCallback)(
1707
1508
  (orgId2, chatKey, user) => {
1708
1509
  base.sendMessage({
1709
1510
  type: "human_agent_joined",
@@ -1734,7 +1535,7 @@ var useWebSocketChatAdmin = ({
1734
1535
  },
1735
1536
  [base.sendMessage]
1736
1537
  );
1737
- const removeUserFromChat = (0, import_react4.useCallback)(
1538
+ const removeUserFromChat = (0, import_react2.useCallback)(
1738
1539
  (orgId2, chatKey, userId) => {
1739
1540
  const chat = chats.get(chatKey);
1740
1541
  if (!chat) return;
@@ -1761,7 +1562,7 @@ var useWebSocketChatAdmin = ({
1761
1562
  },
1762
1563
  [chats, base.sendMessage]
1763
1564
  );
1764
- const blockUser = (0, import_react4.useCallback)(
1565
+ const blockUser = (0, import_react2.useCallback)(
1765
1566
  (orgId2, chatKey, userId) => {
1766
1567
  base.sendMessage({
1767
1568
  type: "block_user",
@@ -1784,15 +1585,15 @@ var useWebSocketChatAdmin = ({
1784
1585
  };
1785
1586
 
1786
1587
  // hooks/use-websocket-chat-customer.ts
1787
- var import_react5 = require("react");
1588
+ var import_react3 = require("react");
1788
1589
  var useWebSocketChatCustomer = ({
1789
1590
  serverBaseUrl,
1790
1591
  orgId,
1791
1592
  chatKey,
1792
1593
  product
1793
1594
  }) => {
1794
- const [currentChat, setCurrentChat] = (0, import_react5.useState)(void 0);
1795
- const handleMessage = (0, import_react5.useCallback)((chatEvent) => {
1595
+ const [currentChat, setCurrentChat] = (0, import_react3.useState)(void 0);
1596
+ const handleMessage = (0, import_react3.useCallback)((chatEvent) => {
1796
1597
  console.log("Received event:", chatEvent.type);
1797
1598
  switch (chatEvent.type) {
1798
1599
  case "message":
@@ -1850,7 +1651,7 @@ var useWebSocketChatCustomer = ({
1850
1651
 
1851
1652
  // context/websocket-chat-admin-context.tsx
1852
1653
  var import_jsx_runtime = require("react/jsx-runtime");
1853
- var WebSocketChatAdminContext = (0, import_react6.createContext)(void 0);
1654
+ var WebSocketChatAdminContext = (0, import_react4.createContext)(void 0);
1854
1655
  function WebSocketChatAdminProvider(props) {
1855
1656
  const { children, serverBaseUrl, orgId, userId, product } = props;
1856
1657
  const webSocket = useWebSocketChatAdmin({
@@ -1861,7 +1662,7 @@ function WebSocketChatAdminProvider(props) {
1861
1662
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WebSocketChatAdminContext.Provider, { value: webSocket, children });
1862
1663
  }
1863
1664
  var useWebSocketChatAdminContext = () => {
1864
- const context = (0, import_react6.useContext)(WebSocketChatAdminContext);
1665
+ const context = (0, import_react4.useContext)(WebSocketChatAdminContext);
1865
1666
  if (context === void 0) {
1866
1667
  throw new Error(
1867
1668
  "useWebSocketChatAdminContext must be used within a WebSocketChatAdminProvider"
@@ -1873,19 +1674,20 @@ var useWebSocketChatAdminContext = () => {
1873
1674
  // components/admin/admin-chat-input.tsx
1874
1675
  var import_jsx_runtime2 = require("react/jsx-runtime");
1875
1676
  var AdminChatInput = ({
1677
+ userId,
1678
+ orgId,
1876
1679
  onFileUpload,
1877
1680
  chatKey
1878
1681
  }) => {
1879
1682
  const { sendMessage } = useWebSocketChatAdminContext();
1880
- const { user, selectedOrgId } = (0, import_auth.useUserContext)();
1881
- const [input, setInput] = (0, import_react7.useState)("");
1882
- const [isUploading, setIsUploading] = (0, import_react7.useState)(false);
1883
- const [isSending, setIsSending] = (0, import_react7.useState)(false);
1884
- const fileInputRef = (0, import_react7.useRef)(null);
1683
+ const [input, setInput] = (0, import_react5.useState)("");
1684
+ const [isUploading, setIsUploading] = (0, import_react5.useState)(false);
1685
+ const [isSending, setIsSending] = (0, import_react5.useState)(false);
1686
+ const fileInputRef = (0, import_react5.useRef)(null);
1885
1687
  const MAX_FILE_SIZE = 5 * 1024 * 1024;
1886
1688
  const handleSend = async () => {
1887
1689
  if (!input.trim() && !isUploading || isSending) return;
1888
- if (!chatKey || !selectedOrgId || !user?.id) {
1690
+ if (!chatKey || !orgId || !userId) {
1889
1691
  console.error("chatKey, orgId, or userId is not defined");
1890
1692
  return;
1891
1693
  }
@@ -1894,13 +1696,13 @@ var AdminChatInput = ({
1894
1696
  sendMessage({
1895
1697
  type: "message",
1896
1698
  chatKey,
1897
- orgId: selectedOrgId,
1898
- userId: user?.id,
1699
+ orgId,
1700
+ userId,
1899
1701
  message: {
1900
1702
  id: import_ksuid.default.randomSync().string,
1901
1703
  content: input,
1902
1704
  role: "user",
1903
- senderId: user?.id,
1705
+ senderId: userId,
1904
1706
  time: Date.now(),
1905
1707
  status: "sending",
1906
1708
  createdAt: Date.now()
@@ -1936,7 +1738,7 @@ var AdminChatInput = ({
1936
1738
  url: file.url,
1937
1739
  title: file.name
1938
1740
  }));
1939
- if (!chatKey || !selectedOrgId || !user?.id) {
1741
+ if (!chatKey || !orgId || !userId) {
1940
1742
  console.error("chatKey, orgId, or userId is not defined");
1941
1743
  return;
1942
1744
  }
@@ -1967,7 +1769,7 @@ var AdminChatInput = ({
1967
1769
  className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
1968
1770
  disabled: isUploading,
1969
1771
  "aria-label": "Attach file",
1970
- 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" })
1772
+ 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)(import_lucide_react.Paperclip, { className: "w-5 h-5" })
1971
1773
  }
1972
1774
  ),
1973
1775
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex-1 relative", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -1997,7 +1799,7 @@ var AdminChatInput = ({
1997
1799
  disabled: !input.trim() && !isUploading || isSending,
1998
1800
  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"}`,
1999
1801
  "aria-label": "Send message",
2000
- 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" })
1802
+ 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)(import_lucide_react.Send, { className: "w-5 h-5" })
2001
1803
  }
2002
1804
  )
2003
1805
  ] }),
@@ -2006,12 +1808,12 @@ var AdminChatInput = ({
2006
1808
  };
2007
1809
 
2008
1810
  // components/admin/chat-human-agent-actions.tsx
2009
- var import_auth2 = require("@elqnt/auth");
1811
+ var import_lucide_react2 = require("lucide-react");
2010
1812
 
2011
1813
  // context/websocket-chat-customer-context.tsx
2012
- var import_react8 = require("react");
1814
+ var import_react6 = require("react");
2013
1815
  var import_jsx_runtime3 = require("react/jsx-runtime");
2014
- var WebSocketChatCustomerContext = (0, import_react8.createContext)(void 0);
1816
+ var WebSocketChatCustomerContext = (0, import_react6.createContext)(void 0);
2015
1817
  function WebSocketChatCustomerProvider(props) {
2016
1818
  const { children, serverBaseUrl, orgId, userId, chatKey, product } = props;
2017
1819
  const webSocket = useWebSocketChatCustomer({
@@ -2023,7 +1825,7 @@ function WebSocketChatCustomerProvider(props) {
2023
1825
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WebSocketChatCustomerContext.Provider, { value: webSocket, children });
2024
1826
  }
2025
1827
  var useWebSocketChatCustomerContext = () => {
2026
- const context = (0, import_react8.useContext)(WebSocketChatCustomerContext);
1828
+ const context = (0, import_react6.useContext)(WebSocketChatCustomerContext);
2027
1829
  if (context === void 0) {
2028
1830
  throw new Error(
2029
1831
  "useWebSocketChatCustomerContext must be used within a WebSocketChatCustomerProvider"
@@ -2034,43 +1836,42 @@ var useWebSocketChatCustomerContext = () => {
2034
1836
 
2035
1837
  // components/admin/chat-human-agent-actions.tsx
2036
1838
  var import_jsx_runtime4 = require("react/jsx-runtime");
2037
- var ChatHumanAgentActions = ({}) => {
2038
- const { user, selectedOrgId } = (0, import_auth2.useUserContext)();
1839
+ var ChatHumanAgentActions = ({ user, orgId }) => {
2039
1840
  const { selectedChat, addUserToChat, removeUserFromChat, blockUser } = useWebSocketChatAdminContext();
2040
1841
  const handleJoinChat = () => {
2041
- if (!selectedChat || !user || !selectedOrgId) return;
2042
- addUserToChat(selectedOrgId, selectedChat.key, {
1842
+ if (!selectedChat || !user || !orgId) return;
1843
+ addUserToChat(orgId, selectedChat.key, {
2043
1844
  id: user.id,
2044
1845
  role: "humanAgent",
2045
- name: user.firstName + " " + user.lastName,
1846
+ name: [user.firstName, user.lastName].filter(Boolean).join(" ") || user.email,
2046
1847
  email: user.email,
2047
1848
  authProvider: "tbd",
2048
1849
  authToken: "tbd"
2049
1850
  });
2050
1851
  };
2051
1852
  const handleLeaveChat = () => {
2052
- if (!selectedChat || !user || !selectedOrgId) return;
2053
- removeUserFromChat(selectedOrgId, selectedChat.key, user.id);
1853
+ if (!selectedChat || !user || !orgId) return;
1854
+ removeUserFromChat(orgId, selectedChat.key, user.id);
2054
1855
  };
2055
1856
  const handleEndChat = () => {
2056
- if (!selectedChat || !user || !selectedOrgId) return;
1857
+ if (!selectedChat || !user || !orgId) return;
2057
1858
  };
2058
1859
  const handleStartCall = () => {
2059
- if (!selectedChat || !user || !selectedOrgId) return;
1860
+ if (!selectedChat || !user || !orgId) return;
2060
1861
  };
2061
1862
  const handleCreateCase = () => {
2062
- if (!selectedChat || !user || !selectedOrgId) return;
1863
+ if (!selectedChat || !user || !orgId) return;
2063
1864
  };
2064
1865
  const handleBlockUser = () => {
2065
- if (!selectedChat || !user || !selectedOrgId) return;
2066
- blockUser(selectedOrgId, selectedChat.key, user.id);
1866
+ if (!selectedChat || !user || !orgId) return;
1867
+ blockUser(orgId, selectedChat.key, user.id);
2067
1868
  };
2068
1869
  if (!selectedChat) return null;
2069
1870
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "p-4 border-b bg-white flex items-center justify-between", children: [
2070
1871
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center space-x-4", children: [
2071
1872
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "font-semibold text-lg", children: selectedChat.title || `Chat ${selectedChat.key}` }),
2072
1873
  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: [
2073
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(User, { className: "mr-1 h-4 w-4" }),
1874
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.User, { className: "mr-1 h-4 w-4" }),
2074
1875
  "Agent Engaged"
2075
1876
  ] })
2076
1877
  ] }),
@@ -2081,7 +1882,7 @@ var ChatHumanAgentActions = ({}) => {
2081
1882
  onClick: handleJoinChat,
2082
1883
  className: "bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
2083
1884
  children: [
2084
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(User, { className: "h-4 w-4" }),
1885
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.User, { className: "h-4 w-4" }),
2085
1886
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Join Chat" })
2086
1887
  ]
2087
1888
  }
@@ -2091,7 +1892,7 @@ var ChatHumanAgentActions = ({}) => {
2091
1892
  onClick: handleLeaveChat,
2092
1893
  className: "bg-orange-500 hover:bg-orange-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
2093
1894
  children: [
2094
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LogOut, { className: "h-4 w-4" }),
1895
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.LogOut, { className: "h-4 w-4" }),
2095
1896
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Leave Chat" })
2096
1897
  ]
2097
1898
  }
@@ -2102,7 +1903,7 @@ var ChatHumanAgentActions = ({}) => {
2102
1903
  onClick: handleEndChat,
2103
1904
  className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
2104
1905
  children: [
2105
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CircleX, { className: "h-4 w-4" }),
1906
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.XCircle, { className: "h-4 w-4" }),
2106
1907
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "End Chat" })
2107
1908
  ]
2108
1909
  }
@@ -2113,7 +1914,7 @@ var ChatHumanAgentActions = ({}) => {
2113
1914
  onClick: handleBlockUser,
2114
1915
  className: "bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
2115
1916
  children: [
2116
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CircleX, { className: "h-4 w-4" }),
1917
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.XCircle, { className: "h-4 w-4" }),
2117
1918
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Block User" })
2118
1919
  ]
2119
1920
  }
@@ -2125,7 +1926,7 @@ var ChatHumanAgentActions = ({}) => {
2125
1926
  disabled: !selectedChat.humanAgentEngaged,
2126
1927
  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",
2127
1928
  children: [
2128
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Phone, { className: "h-4 w-4" }),
1929
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.Phone, { className: "h-4 w-4" }),
2129
1930
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Start Call" })
2130
1931
  ]
2131
1932
  }
@@ -2136,7 +1937,7 @@ var ChatHumanAgentActions = ({}) => {
2136
1937
  onClick: handleCreateCase,
2137
1938
  className: "bg-purple-500 hover:bg-purple-600 text-white px-4 py-2 rounded-lg flex items-center space-x-2 transition-colors",
2138
1939
  children: [
2139
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Plus, { className: "h-4 w-4" }),
1940
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
2140
1941
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Create Case" })
2141
1942
  ]
2142
1943
  }
@@ -2146,8 +1947,9 @@ var ChatHumanAgentActions = ({}) => {
2146
1947
  };
2147
1948
 
2148
1949
  // components/admin/admin-chat-list.tsx
2149
- var import_react9 = require("@elqnt/react");
1950
+ var import_lucide_react3 = require("lucide-react");
2150
1951
  var import_jsx_runtime5 = require("react/jsx-runtime");
1952
+ var ScrollArea = ({ className, children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `overflow-auto ${className || ""}`, children });
2151
1953
  var AdminChatList = ({ className }) => {
2152
1954
  const { chats, selectedChat, selectChat } = useWebSocketChatAdminContext();
2153
1955
  const sortedChats = Array.from(chats.values()).sort(
@@ -2155,7 +1957,7 @@ var AdminChatList = ({ className }) => {
2155
1957
  );
2156
1958
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-full", children: [
2157
1959
  /* @__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" }) }),
2158
- /* @__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)(
1960
+ /* @__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)(ScrollArea, { className: "h-[calc(100vh-15rem)]", children: sortedChats.map((chat, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2159
1961
  AdminChatListItem,
2160
1962
  {
2161
1963
  chat,
@@ -2179,16 +1981,16 @@ var AdminChatListItem = ({
2179
1981
  className: `w-full p-4 text-left hover:bg-gray-50 focus:outline-none focus:bg-gray-50 ${isSelected ? "bg-blue-50" : ""}`,
2180
1982
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-start space-x-3", children: [
2181
1983
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "shrink-0", children: [
2182
- chat.aiEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Bot, { className: "w-6 h-6 text-blue-500" }),
2183
- chat.isWaitingForAgent && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LoaderCircle, { className: "w-6 h-6 text-blue-500 animate-spin text-orange-500" }),
2184
- chat.humanAgentEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UserCheck, { className: "w-6 h-6 text-blue-500 text-green-500" })
1984
+ chat.aiEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.Bot, { className: "w-6 h-6 text-blue-500" }),
1985
+ chat.isWaitingForAgent && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.Loader2, { className: "w-6 h-6 text-blue-500 animate-spin text-orange-500" }),
1986
+ chat.humanAgentEngaged && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.UserCheck, { className: "w-6 h-6 text-blue-500 text-green-500" })
2185
1987
  ] }),
2186
1988
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex-1 min-w-0", children: [
2187
1989
  /* @__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}` }) }),
2188
1990
  lastMessage && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mt-1 text-sm text-gray-500 truncate", children: lastMessage.content }),
2189
1991
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center space-x-2", children: [
2190
1992
  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: [
2191
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CircleAlert, { className: "mr-1 h-3 w-3" }),
1993
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.AlertCircle, { className: "mr-1 h-3 w-3" }),
2192
1994
  "Waiting"
2193
1995
  ] }),
2194
1996
  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: [
@@ -2259,21 +2061,20 @@ var ChatHeader = () => {
2259
2061
  };
2260
2062
 
2261
2063
  // components/customer/chat-input.tsx
2262
- var import_auth3 = require("@elqnt/auth");
2263
2064
  var import_ksuid2 = __toESM(require("ksuid"));
2264
- var import_react10 = require("react");
2065
+ var import_lucide_react4 = require("lucide-react");
2066
+ var import_react7 = require("react");
2265
2067
  var import_jsx_runtime9 = require("react/jsx-runtime");
2266
- var ChatInput = ({ onFileUpload }) => {
2068
+ var ChatInput = ({ userId, orgId, onFileUpload }) => {
2267
2069
  const { sendMessage, chatKey } = useWebSocketChatCustomerContext();
2268
- const { user, selectedOrgId } = (0, import_auth3.useUserContext)();
2269
- const [input, setInput] = (0, import_react10.useState)("");
2270
- const [isUploading, setIsUploading] = (0, import_react10.useState)(false);
2271
- const [isSending, setIsSending] = (0, import_react10.useState)(false);
2272
- const fileInputRef = (0, import_react10.useRef)(null);
2070
+ const [input, setInput] = (0, import_react7.useState)("");
2071
+ const [isUploading, setIsUploading] = (0, import_react7.useState)(false);
2072
+ const [isSending, setIsSending] = (0, import_react7.useState)(false);
2073
+ const fileInputRef = (0, import_react7.useRef)(null);
2273
2074
  const MAX_FILE_SIZE = 5 * 1024 * 1024;
2274
2075
  const handleSend = async () => {
2275
2076
  if (!input.trim() && !isUploading || isSending) return;
2276
- if (!chatKey || !selectedOrgId || !user?.id) {
2077
+ if (!chatKey || !orgId || !userId) {
2277
2078
  console.error("chatKey, orgId, or userId is not defined");
2278
2079
  return;
2279
2080
  }
@@ -2282,13 +2083,13 @@ var ChatInput = ({ onFileUpload }) => {
2282
2083
  sendMessage({
2283
2084
  type: "message",
2284
2085
  chatKey,
2285
- orgId: selectedOrgId,
2286
- userId: user?.id,
2086
+ orgId,
2087
+ userId,
2287
2088
  message: {
2288
2089
  id: import_ksuid2.default.randomSync().string,
2289
2090
  content: input,
2290
2091
  role: "user",
2291
- senderId: user?.id,
2092
+ senderId: userId,
2292
2093
  time: Date.now(),
2293
2094
  status: "sending",
2294
2095
  createdAt: Date.now()
@@ -2324,7 +2125,7 @@ var ChatInput = ({ onFileUpload }) => {
2324
2125
  url: file.url,
2325
2126
  title: file.name
2326
2127
  }));
2327
- if (!chatKey || !selectedOrgId || !user?.id) {
2128
+ if (!chatKey || !orgId || !userId) {
2328
2129
  console.error("chatKey, orgId, or userId is not defined");
2329
2130
  return;
2330
2131
  }
@@ -2355,7 +2156,7 @@ var ChatInput = ({ onFileUpload }) => {
2355
2156
  className: "p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100 transition-colors",
2356
2157
  disabled: isUploading,
2357
2158
  "aria-label": "Attach file",
2358
- 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" })
2159
+ 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)(import_lucide_react4.Paperclip, { className: "w-5 h-5" })
2359
2160
  }
2360
2161
  ),
2361
2162
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 relative", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -2385,7 +2186,7 @@ var ChatInput = ({ onFileUpload }) => {
2385
2186
  disabled: !input.trim() && !isUploading || isSending,
2386
2187
  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"}`,
2387
2188
  "aria-label": "Send message",
2388
- 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" })
2189
+ 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)(import_lucide_react4.Send, { className: "w-5 h-5" })
2389
2190
  }
2390
2191
  )
2391
2192
  ] }),
@@ -2394,7 +2195,7 @@ var ChatInput = ({ onFileUpload }) => {
2394
2195
  };
2395
2196
 
2396
2197
  // components/customer/chat-messages.tsx
2397
- var import_react11 = require("react");
2198
+ var import_react8 = require("react");
2398
2199
 
2399
2200
  // ../../node_modules/date-fns/constants.js
2400
2201
  var daysInYear = 365.2425;
@@ -3965,6 +3766,9 @@ function cleanEscapedString(input) {
3965
3766
  return matched[1].replace(doubleQuoteRegExp, "'");
3966
3767
  }
3967
3768
 
3769
+ // components/customer/chat-message.tsx
3770
+ var import_lucide_react5 = require("lucide-react");
3771
+
3968
3772
  // components/markdown-renderer.tsx
3969
3773
  var import_react_markdown = __toESM(require("react-markdown"));
3970
3774
  var import_remark_gfm = __toESM(require("remark-gfm"));
@@ -4033,7 +3837,7 @@ var Message = ({
4033
3837
  target: "_blank",
4034
3838
  rel: "noopener noreferrer",
4035
3839
  children: [
4036
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Paperclip, { className: "w-4 h-4" }),
3840
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.Paperclip, { className: "w-4 h-4" }),
4037
3841
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: attachment.title })
4038
3842
  ]
4039
3843
  }
@@ -4047,9 +3851,9 @@ var Message = ({
4047
3851
  "aria-label": `Message from ${message2.senderId}`,
4048
3852
  children: [
4049
3853
  /* @__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: [
4050
- message2.role === "user" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(User, {}),
4051
- message2.role === "ai" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Bot, {}),
4052
- message2.role === "humanAgent" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(UserCog, {})
3854
+ message2.role === "user" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.User, {}),
3855
+ message2.role === "ai" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.Bot, {}),
3856
+ message2.role === "humanAgent" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.UserCog, {})
4053
3857
  ] }) }),
4054
3858
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
4055
3859
  "div",
@@ -4064,15 +3868,15 @@ var Message = ({
4064
3868
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-xs opacity-70", children: format(message2.time, "HH:mm") }),
4065
3869
  message2.role === "user" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
4066
3870
  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" }),
4067
- message2.status === "sent" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Check, { className: "w-4 h-4" }),
4068
- message2.status === "delivered" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CheckCheck, { className: "w-4 h-4" }),
3871
+ message2.status === "sent" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.Check, { className: "w-4 h-4" }),
3872
+ message2.status === "delivered" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.CheckCheck, { className: "w-4 h-4" }),
4069
3873
  message2.status === "failed" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
4070
3874
  "button",
4071
3875
  {
4072
3876
  onClick: () => onRetry(message2.id),
4073
3877
  className: "text-red-300 hover:text-red-400",
4074
3878
  "aria-label": "Retry sending message",
4075
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CircleAlert, { className: "w-4 h-4" })
3879
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.AlertCircle, { className: "w-4 h-4" })
4076
3880
  }
4077
3881
  )
4078
3882
  ] })
@@ -4091,11 +3895,11 @@ var ChatMessages = ({
4091
3895
  onRetry,
4092
3896
  messages
4093
3897
  }) => {
4094
- const messageEndRef = (0, import_react11.useRef)(null);
3898
+ const messageEndRef = (0, import_react8.useRef)(null);
4095
3899
  const scrollToBottom = () => {
4096
3900
  messageEndRef.current?.scrollIntoView({ behavior: "smooth" });
4097
3901
  };
4098
- (0, import_react11.useEffect)(() => {
3902
+ (0, import_react8.useEffect)(() => {
4099
3903
  scrollToBottom();
4100
3904
  }, [messages]);
4101
3905
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
@@ -4138,13 +3942,16 @@ var ChatTypingIndicator = ({
4138
3942
  };
4139
3943
 
4140
3944
  // components/customer/generic-chat-widget.tsx
4141
- var import_react12 = require("@elqnt/react");
4142
- var import_react13 = require("react");
3945
+ var import_react9 = require("react");
4143
3946
  var import_jsx_runtime14 = require("react/jsx-runtime");
3947
+ var Alert = ({ title, description }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "p-4 bg-red-50 border border-red-200 rounded-lg", role: "alert", children: [
3948
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "font-medium text-red-800", children: title }),
3949
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-sm text-red-600", children: description })
3950
+ ] });
4144
3951
  var GenericChatWidget = ({
4145
3952
  onFileUpload
4146
3953
  }) => {
4147
- const [typingUsers] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
3954
+ const [typingUsers] = (0, import_react9.useState)(/* @__PURE__ */ new Set());
4148
3955
  const { error, messages } = useWebSocketChatCustomerContext();
4149
3956
  const handleRetry = (messageId) => {
4150
3957
  };
@@ -4156,7 +3963,7 @@ var GenericChatWidget = ({
4156
3963
  "aria-label": "Chat interface",
4157
3964
  children: [
4158
3965
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatHeader, {}),
4159
- error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react12.Alert, { title: "Error", description: error.message }),
3966
+ error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Alert, { title: "Error", description: error.message }),
4160
3967
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatMessages, { onRetry: handleRetry, messages }),
4161
3968
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatTypingIndicator, { typingUsers }),
4162
3969
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatInput, { onFileUpload })
@@ -4363,32 +4170,4 @@ var GenericChatWidget = ({
4363
4170
  useWebSocketChatCustomer,
4364
4171
  useWebSocketChatCustomerContext
4365
4172
  });
4366
- /*! Bundled license information:
4367
-
4368
- lucide-react/dist/esm/shared/src/utils.js:
4369
- lucide-react/dist/esm/defaultAttributes.js:
4370
- lucide-react/dist/esm/Icon.js:
4371
- lucide-react/dist/esm/createLucideIcon.js:
4372
- lucide-react/dist/esm/icons/bot.js:
4373
- lucide-react/dist/esm/icons/check-check.js:
4374
- lucide-react/dist/esm/icons/check.js:
4375
- lucide-react/dist/esm/icons/circle-alert.js:
4376
- lucide-react/dist/esm/icons/circle-x.js:
4377
- lucide-react/dist/esm/icons/loader-circle.js:
4378
- lucide-react/dist/esm/icons/log-out.js:
4379
- lucide-react/dist/esm/icons/paperclip.js:
4380
- lucide-react/dist/esm/icons/phone.js:
4381
- lucide-react/dist/esm/icons/plus.js:
4382
- lucide-react/dist/esm/icons/send.js:
4383
- lucide-react/dist/esm/icons/user-check.js:
4384
- lucide-react/dist/esm/icons/user-cog.js:
4385
- lucide-react/dist/esm/icons/user.js:
4386
- lucide-react/dist/esm/lucide-react.js:
4387
- (**
4388
- * @license lucide-react v0.483.0 - ISC
4389
- *
4390
- * This source code is licensed under the ISC license.
4391
- * See the LICENSE file in the root directory of this source tree.
4392
- *)
4393
- */
4394
4173
  //# sourceMappingURL=index.js.map