@kite-copilot/chat-panel 0.2.38 → 0.2.40

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.cjs CHANGED
@@ -70,7 +70,7 @@ var import_react = __toESM(require("react"), 1);
70
70
  var import_client = require("react-dom/client");
71
71
 
72
72
  // src/ChatPanel.tsx
73
- var React4 = __toESM(require("react"), 1);
73
+ var React5 = __toESM(require("react"), 1);
74
74
  var import_supabase_js = require("@supabase/supabase-js");
75
75
 
76
76
  // src/lib/utils.ts
@@ -369,6 +369,58 @@ function useGuideCursor() {
369
369
  };
370
370
  }
371
371
 
372
+ // src/hooks/useUserAuth.ts
373
+ var React4 = __toESM(require("react"), 1);
374
+ function useUserAuth({
375
+ productBackendUrl,
376
+ sessionId,
377
+ enabled = true
378
+ }) {
379
+ const [authState, setAuthState] = React4.useState({ status: "idle" });
380
+ const lastSessionIdRef = React4.useRef(null);
381
+ const fetchUser = React4.useCallback(async () => {
382
+ if (!productBackendUrl || !enabled) {
383
+ setAuthState({ status: "idle" });
384
+ return;
385
+ }
386
+ setAuthState({ status: "loading" });
387
+ try {
388
+ const response = await fetch(`${productBackendUrl}/users/me`, {
389
+ method: "GET",
390
+ credentials: "include",
391
+ // Include cookies for authentication
392
+ headers: {
393
+ "Accept": "application/json"
394
+ }
395
+ });
396
+ if (!response.ok) {
397
+ if (response.status === 401) {
398
+ throw new Error("Please log in to use the chat assistant.");
399
+ }
400
+ if (response.status === 403) {
401
+ throw new Error("You do not have permission to access this feature.");
402
+ }
403
+ throw new Error(`Authentication failed (${response.status})`);
404
+ }
405
+ const user = await response.json();
406
+ setAuthState({ status: "authenticated", user });
407
+ } catch (error) {
408
+ const message = error instanceof Error ? error.message : "Unable to verify your identity. Please try again.";
409
+ setAuthState({ status: "error", error: message });
410
+ }
411
+ }, [productBackendUrl, enabled]);
412
+ React4.useEffect(() => {
413
+ if (sessionId !== lastSessionIdRef.current) {
414
+ lastSessionIdRef.current = sessionId;
415
+ fetchUser();
416
+ }
417
+ }, [sessionId, fetchUser]);
418
+ const retry = React4.useCallback(() => {
419
+ fetchUser();
420
+ }, [fetchUser]);
421
+ return { authState, retry };
422
+ }
423
+
372
424
  // src/components/ui/card.tsx
373
425
  var import_jsx_runtime7 = require("react/jsx-runtime");
374
426
  function Card({ className, ...props }) {
@@ -969,7 +1021,7 @@ function TypingIndicator({ className = "" }) {
969
1021
 
970
1022
  // src/ChatPanel.tsx
971
1023
  var import_jsx_runtime10 = require("react/jsx-runtime");
972
- var CHAT_PANEL_VERSION = true ? "0.2.38" : "dev";
1024
+ var CHAT_PANEL_VERSION = true ? "0.2.40" : "dev";
973
1025
  var DEFAULT_AGENT_URL = "http://localhost:5002";
974
1026
  var PANEL_WIDTH = 340;
975
1027
  function unescapeJsonString(str) {
@@ -1387,6 +1439,32 @@ var guides = {
1387
1439
  }
1388
1440
  };
1389
1441
  var initialMessages = [];
1442
+ function AuthLoadingState() {
1443
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col items-center justify-center h-full p-6", children: [
1444
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Loader2, { className: "h-8 w-8 animate-spin text-gray-400 mb-3" }),
1445
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-xs text-gray-500", children: "Verifying your identity..." })
1446
+ ] });
1447
+ }
1448
+ function AuthErrorState({
1449
+ error,
1450
+ onRetry
1451
+ }) {
1452
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col items-center justify-center h-full p-6 text-center", children: [
1453
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "w-12 h-12 rounded-full bg-red-100 flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.X, { className: "h-6 w-6 text-red-600" }) }),
1454
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-sm font-semibold text-gray-900 mb-2", children: "Unable to Start Chat" }),
1455
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-xs text-gray-500 mb-4 max-w-[240px]", children: error }),
1456
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1457
+ Button,
1458
+ {
1459
+ variant: "secondary",
1460
+ size: "sm",
1461
+ onClick: onRetry,
1462
+ className: "h-8 px-4 text-xs",
1463
+ children: "Try Again"
1464
+ }
1465
+ )
1466
+ ] });
1467
+ }
1390
1468
  function ChatPanel({
1391
1469
  isOpen = true,
1392
1470
  onClose,
@@ -1404,26 +1482,62 @@ function ChatPanel({
1404
1482
  userEmail,
1405
1483
  userOrganization,
1406
1484
  supabaseUrl,
1407
- supabaseAnonKey
1485
+ supabaseAnonKey,
1486
+ productBackendUrl
1408
1487
  } = {}) {
1409
- const [messages, setMessages] = React4.useState(initialMessages);
1410
- const [input, setInput] = React4.useState("");
1411
- const [sessionId, setSessionId] = React4.useState(() => crypto.randomUUID());
1412
- const [isEscalated, setIsEscalated] = React4.useState(false);
1413
- const escalationWsRef = React4.useRef(null);
1414
- const [agentIsTyping, setAgentIsTyping] = React4.useState(false);
1415
- const supabaseRef = React4.useRef(null);
1416
- const typingChannelRef = React4.useRef(null);
1417
- const typingTimeoutRef = React4.useRef(null);
1418
- React4.useEffect(() => {
1488
+ const [messages, setMessages] = React5.useState(initialMessages);
1489
+ const [input, setInput] = React5.useState("");
1490
+ const [sessionId, setSessionId] = React5.useState(() => crypto.randomUUID());
1491
+ const { authState, retry: retryAuth } = useUserAuth({
1492
+ productBackendUrl,
1493
+ sessionId,
1494
+ enabled: !!productBackendUrl
1495
+ // Only enable if URL is provided
1496
+ });
1497
+ const effectiveUser = React5.useMemo(() => {
1498
+ if (authState.status === "authenticated") {
1499
+ return {
1500
+ userId: authState.user.id,
1501
+ userName: authState.user.name,
1502
+ userEmail: authState.user.email,
1503
+ userRole: authState.user.role,
1504
+ isInternal: authState.user.isInternal
1505
+ };
1506
+ }
1507
+ return {
1508
+ userId: userId || "anonymous",
1509
+ userName: userName || "Anonymous User",
1510
+ userEmail: userEmail || "Not provided",
1511
+ userRole: void 0,
1512
+ isInternal: false
1513
+ };
1514
+ }, [authState, userId, userName, userEmail]);
1515
+ const [isEscalated, setIsEscalated] = React5.useState(false);
1516
+ const escalationWsRef = React5.useRef(null);
1517
+ const [agentIsTyping, setAgentIsTyping] = React5.useState(false);
1518
+ const supabaseRef = React5.useRef(null);
1519
+ const typingChannelRef = React5.useRef(null);
1520
+ const typingTimeoutRef = React5.useRef(null);
1521
+ React5.useEffect(() => {
1419
1522
  console.log(`[KiteChat] Chat Panel v${CHAT_PANEL_VERSION} loaded`);
1420
1523
  }, []);
1421
- const resetSession = React4.useCallback(() => {
1524
+ const resetSession = React5.useCallback(() => {
1525
+ console.log("[KiteChat] resetSession called", { isEscalated, hasSupabase: !!supabaseRef.current, sessionId });
1422
1526
  if (isEscalated && supabaseRef.current && sessionId) {
1527
+ console.log("[KiteChat] Updating customer_status to disconnected for session:", sessionId);
1423
1528
  supabaseRef.current.from("escalations").update({
1424
1529
  customer_status: "disconnected",
1425
1530
  customer_last_seen: (/* @__PURE__ */ new Date()).toISOString()
1426
- }).eq("session_id", sessionId);
1531
+ }).eq("session_id", sessionId).then(
1532
+ (result) => {
1533
+ console.log("[KiteChat] Disconnect update result:", result);
1534
+ },
1535
+ (err) => {
1536
+ console.error("[KiteChat] Disconnect update failed:", err);
1537
+ }
1538
+ );
1539
+ } else {
1540
+ console.log("[KiteChat] Skipping disconnect update - conditions not met");
1427
1541
  }
1428
1542
  setSessionId(crypto.randomUUID());
1429
1543
  setIsEscalated(false);
@@ -1437,12 +1551,12 @@ function ChatPanel({
1437
1551
  typingChannelRef.current = null;
1438
1552
  }
1439
1553
  }, [isEscalated, sessionId]);
1440
- React4.useEffect(() => {
1554
+ React5.useEffect(() => {
1441
1555
  if (supabaseUrl && supabaseAnonKey && !supabaseRef.current) {
1442
1556
  supabaseRef.current = (0, import_supabase_js.createClient)(supabaseUrl, supabaseAnonKey);
1443
1557
  }
1444
1558
  }, [supabaseUrl, supabaseAnonKey]);
1445
- React4.useEffect(() => {
1559
+ React5.useEffect(() => {
1446
1560
  if (!isEscalated || !sessionId || !supabaseRef.current) {
1447
1561
  return;
1448
1562
  }
@@ -1479,8 +1593,8 @@ function ChatPanel({
1479
1593
  }
1480
1594
  };
1481
1595
  }, [isEscalated, sessionId]);
1482
- const heartbeatIntervalRef = React4.useRef(null);
1483
- const updateCustomerStatus = React4.useCallback(async (status) => {
1596
+ const heartbeatIntervalRef = React5.useRef(null);
1597
+ const updateCustomerStatus = React5.useCallback(async (status) => {
1484
1598
  if (!supabaseRef.current || !sessionId) return;
1485
1599
  try {
1486
1600
  await supabaseRef.current.from("escalations").update({
@@ -1491,7 +1605,7 @@ function ChatPanel({
1491
1605
  console.error("[KiteChat] Failed to update customer status:", err);
1492
1606
  }
1493
1607
  }, [sessionId]);
1494
- React4.useEffect(() => {
1608
+ React5.useEffect(() => {
1495
1609
  if (!isEscalated || !sessionId || !supabaseRef.current) {
1496
1610
  return;
1497
1611
  }
@@ -1539,7 +1653,7 @@ function ChatPanel({
1539
1653
  }
1540
1654
  };
1541
1655
  }, [isEscalated, sessionId, updateCustomerStatus]);
1542
- const sendTypingIndicator = React4.useCallback((isTyping) => {
1656
+ const sendTypingIndicator = React5.useCallback((isTyping) => {
1543
1657
  if (!typingChannelRef.current) {
1544
1658
  console.log("[KiteChat] Cannot send typing - channel not ready");
1545
1659
  return;
@@ -1555,8 +1669,8 @@ function ChatPanel({
1555
1669
  payload: { sender: "user", isTyping }
1556
1670
  });
1557
1671
  }, [isEscalated]);
1558
- const userTypingTimeoutRef = React4.useRef(null);
1559
- const handleTypingStart = React4.useCallback(() => {
1672
+ const userTypingTimeoutRef = React5.useRef(null);
1673
+ const handleTypingStart = React5.useCallback(() => {
1560
1674
  if (!isEscalated || !supabaseRef.current) return;
1561
1675
  sendTypingIndicator(true);
1562
1676
  updateCustomerStatus("active");
@@ -1567,19 +1681,19 @@ function ChatPanel({
1567
1681
  sendTypingIndicator(false);
1568
1682
  }, 1500);
1569
1683
  }, [isEscalated, sendTypingIndicator, updateCustomerStatus]);
1570
- const streamIntervals = React4.useRef({});
1684
+ const streamIntervals = React5.useRef({});
1571
1685
  const isEmpty = messages.length === 0;
1572
- const [phase, setPhase] = React4.useState("idle");
1573
- const [progressSteps, setProgressSteps] = React4.useState([]);
1574
- const phaseTimers = React4.useRef([]);
1686
+ const [phase, setPhase] = React5.useState("idle");
1687
+ const [progressSteps, setProgressSteps] = React5.useState([]);
1688
+ const phaseTimers = React5.useRef([]);
1575
1689
  const lastRole = messages.length ? messages[messages.length - 1].role : void 0;
1576
- const [panelView, setPanelView] = React4.useState(
1690
+ const [panelView, setPanelView] = React5.useState(
1577
1691
  "landing"
1578
1692
  );
1579
- const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1580
- const [startingQuestions, setStartingQuestions] = React4.useState(startingQuestionsProp || defaultStartingQuestions);
1581
- const [loadingQuestions, setLoadingQuestions] = React4.useState(false);
1582
- React4.useEffect(() => {
1693
+ const [currentFolderId, setCurrentFolderId] = React5.useState(void 0);
1694
+ const [startingQuestions, setStartingQuestions] = React5.useState(startingQuestionsProp || defaultStartingQuestions);
1695
+ const [loadingQuestions, setLoadingQuestions] = React5.useState(false);
1696
+ React5.useEffect(() => {
1583
1697
  if (startingQuestionsEndpoint && !startingQuestionsProp) {
1584
1698
  setLoadingQuestions(true);
1585
1699
  fetch(startingQuestionsEndpoint).then((res) => res.json()).then((data) => {
@@ -1591,16 +1705,16 @@ function ChatPanel({
1591
1705
  }).finally(() => setLoadingQuestions(false));
1592
1706
  }
1593
1707
  }, [startingQuestionsEndpoint, startingQuestionsProp]);
1594
- React4.useEffect(() => {
1708
+ React5.useEffect(() => {
1595
1709
  if (startingQuestionsProp) {
1596
1710
  setStartingQuestions(startingQuestionsProp);
1597
1711
  }
1598
1712
  }, [startingQuestionsProp]);
1599
- const [activeGuide, setActiveGuide] = React4.useState(void 0);
1600
- const activeGuideRef = React4.useRef(void 0);
1601
- const latestBulkSummaryNavigationRef = React4.useRef(null);
1602
- const [guideComplete, setGuideComplete] = React4.useState(false);
1603
- React4.useEffect(() => {
1713
+ const [activeGuide, setActiveGuide] = React5.useState(void 0);
1714
+ const activeGuideRef = React5.useRef(void 0);
1715
+ const latestBulkSummaryNavigationRef = React5.useRef(null);
1716
+ const [guideComplete, setGuideComplete] = React5.useState(false);
1717
+ React5.useEffect(() => {
1604
1718
  window.resetIntegrationNotification = () => {
1605
1719
  localStorage.removeItem("gmailNotificationSeen");
1606
1720
  console.log(
@@ -1634,7 +1748,7 @@ function ChatPanel({
1634
1748
  );
1635
1749
  };
1636
1750
  }, []);
1637
- React4.useEffect(() => {
1751
+ React5.useEffect(() => {
1638
1752
  if (activeGuide) {
1639
1753
  if (!activeGuideRef.current || activeGuideRef.current.id !== activeGuide.id || activeGuideRef.current.stepIndex !== activeGuide.stepIndex) {
1640
1754
  activeGuideRef.current = activeGuide;
@@ -1643,21 +1757,21 @@ function ChatPanel({
1643
1757
  activeGuideRef.current = void 0;
1644
1758
  }
1645
1759
  }, [activeGuide]);
1646
- const [pendingNavigation, setPendingNavigation] = React4.useState(null);
1647
- const [pendingAction, setPendingAction] = React4.useState(null);
1648
- const [actionFormData, setActionFormData] = React4.useState({});
1649
- const messagesEndRef = React4.useRef(null);
1650
- const messagesContainerRef = React4.useRef(null);
1651
- const currentStepRef = React4.useRef(null);
1760
+ const [pendingNavigation, setPendingNavigation] = React5.useState(null);
1761
+ const [pendingAction, setPendingAction] = React5.useState(null);
1762
+ const [actionFormData, setActionFormData] = React5.useState({});
1763
+ const messagesEndRef = React5.useRef(null);
1764
+ const messagesContainerRef = React5.useRef(null);
1765
+ const currentStepRef = React5.useRef(null);
1652
1766
  const { cursorState, moveTo, hide } = useGuideCursor();
1653
- const [pendingFile, setPendingFile] = React4.useState(null);
1654
- const [pendingBulkSession, setPendingBulkSession] = React4.useState(null);
1655
- const pendingBulkSessionRef = React4.useRef(null);
1656
- const fileInputRef = React4.useRef(null);
1657
- const [searchExpanded, setSearchExpanded] = React4.useState(false);
1658
- const [searchInput, setSearchInput] = React4.useState("");
1659
- const searchInputRef = React4.useRef(null);
1660
- React4.useEffect(() => {
1767
+ const [pendingFile, setPendingFile] = React5.useState(null);
1768
+ const [pendingBulkSession, setPendingBulkSession] = React5.useState(null);
1769
+ const pendingBulkSessionRef = React5.useRef(null);
1770
+ const fileInputRef = React5.useRef(null);
1771
+ const [searchExpanded, setSearchExpanded] = React5.useState(false);
1772
+ const [searchInput, setSearchInput] = React5.useState("");
1773
+ const searchInputRef = React5.useRef(null);
1774
+ React5.useEffect(() => {
1661
1775
  if (!activeGuide || activeGuide.id !== "add-api-key" || activeGuide.stepIndex !== 2) {
1662
1776
  return;
1663
1777
  }
@@ -1683,7 +1797,7 @@ function ChatPanel({
1683
1797
  const interval = setInterval(checkForDialogOpen, 300);
1684
1798
  return () => clearInterval(interval);
1685
1799
  }, [activeGuide, hide]);
1686
- React4.useEffect(() => {
1800
+ React5.useEffect(() => {
1687
1801
  return () => {
1688
1802
  Object.values(streamIntervals.current).forEach(
1689
1803
  (id) => window.clearInterval(id)
@@ -1693,7 +1807,7 @@ function ChatPanel({
1693
1807
  phaseTimers.current = [];
1694
1808
  };
1695
1809
  }, []);
1696
- React4.useEffect(() => {
1810
+ React5.useEffect(() => {
1697
1811
  if (activeGuide && messages.length > 0) {
1698
1812
  const lastMessage = messages[messages.length - 1];
1699
1813
  if (lastMessage.kind === "guideStep" || lastMessage.kind === "guideComplete") {
@@ -1710,7 +1824,7 @@ function ChatPanel({
1710
1824
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
1711
1825
  }
1712
1826
  }, [messages, phase, activeGuide]);
1713
- const latestBulkSummaryNavigation = React4.useMemo(() => {
1827
+ const latestBulkSummaryNavigation = React5.useMemo(() => {
1714
1828
  for (let i = messages.length - 1; i >= 0; i--) {
1715
1829
  const msg = messages[i];
1716
1830
  if (msg.kind === "bulkSummary" && msg.bulkSummary?.navigationPage && msg.bulkSummary.successes > 0) {
@@ -1719,13 +1833,13 @@ function ChatPanel({
1719
1833
  }
1720
1834
  return null;
1721
1835
  }, [messages]);
1722
- React4.useEffect(() => {
1836
+ React5.useEffect(() => {
1723
1837
  latestBulkSummaryNavigationRef.current = latestBulkSummaryNavigation;
1724
1838
  }, [latestBulkSummaryNavigation]);
1725
- React4.useEffect(() => {
1839
+ React5.useEffect(() => {
1726
1840
  pendingBulkSessionRef.current = pendingBulkSession;
1727
1841
  }, [pendingBulkSession]);
1728
- React4.useEffect(() => {
1842
+ React5.useEffect(() => {
1729
1843
  const handleKeyDown = (e) => {
1730
1844
  if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
1731
1845
  const currentBulkSession = pendingBulkSessionRef.current;
@@ -1788,7 +1902,7 @@ function ChatPanel({
1788
1902
  guideComplete,
1789
1903
  onNavigate
1790
1904
  ]);
1791
- const connectToEscalationWs = React4.useCallback((currentSessionId) => {
1905
+ const connectToEscalationWs = React5.useCallback((currentSessionId) => {
1792
1906
  if (!agentUrl) return;
1793
1907
  if (escalationWsRef.current) {
1794
1908
  escalationWsRef.current.close();
@@ -1831,7 +1945,7 @@ function ChatPanel({
1831
1945
  };
1832
1946
  escalationWsRef.current = ws;
1833
1947
  }, [agentUrl]);
1834
- const sendEscalatedMessage = React4.useCallback(async (content) => {
1948
+ const sendEscalatedMessage = React5.useCallback(async (content) => {
1835
1949
  if (!escalationWsRef.current || escalationWsRef.current.readyState !== WebSocket.OPEN) {
1836
1950
  console.error("[KiteChat] Escalation WebSocket not connected");
1837
1951
  return false;
@@ -1848,14 +1962,14 @@ function ChatPanel({
1848
1962
  return false;
1849
1963
  }
1850
1964
  }, [updateCustomerStatus]);
1851
- React4.useEffect(() => {
1965
+ React5.useEffect(() => {
1852
1966
  return () => {
1853
1967
  if (escalationWsRef.current) {
1854
1968
  escalationWsRef.current.close();
1855
1969
  }
1856
1970
  };
1857
1971
  }, []);
1858
- React4.useEffect(() => {
1972
+ React5.useEffect(() => {
1859
1973
  if (isEscalated && sessionId) {
1860
1974
  connectToEscalationWs(sessionId);
1861
1975
  }
@@ -2130,9 +2244,9 @@ function ChatPanel({
2130
2244
  session_id: sessionId,
2131
2245
  message: userText,
2132
2246
  current_page: currentPage || "dashboard",
2133
- user_id: userId,
2134
- user_name: userName,
2135
- user_email: userEmail,
2247
+ user_id: effectiveUser.userId,
2248
+ user_name: effectiveUser.userName,
2249
+ user_email: effectiveUser.userEmail,
2136
2250
  user_organization: userOrganization,
2137
2251
  org_id: orgId
2138
2252
  }),
@@ -3075,6 +3189,64 @@ ${userText}`
3075
3189
  ] })
3076
3190
  ] }) }) });
3077
3191
  }
3192
+ if (productBackendUrl) {
3193
+ if (authState.status === "loading") {
3194
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
3195
+ "section",
3196
+ {
3197
+ className: `fixed top-0 right-0 z-40 flex flex-col bg-white border-l border-gray-200 h-full overflow-hidden transition-transform duration-300 ${isOpen ? "translate-x-0" : "translate-x-full"}`,
3198
+ style: { width: `${PANEL_WIDTH}px` },
3199
+ children: [
3200
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-gradient-to-r from-gray-50 to-white shrink-0", children: [
3201
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-2.5", children: [
3202
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" }),
3203
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-sm font-semibold text-gray-800", children: "Copilot" })
3204
+ ] }),
3205
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3206
+ Button,
3207
+ {
3208
+ variant: "ghost",
3209
+ size: "sm",
3210
+ className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
3211
+ onClick: () => onClose?.(),
3212
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Minus, { className: "h-3.5 w-3.5" })
3213
+ }
3214
+ )
3215
+ ] }),
3216
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AuthLoadingState, {})
3217
+ ]
3218
+ }
3219
+ );
3220
+ }
3221
+ if (authState.status === "error") {
3222
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
3223
+ "section",
3224
+ {
3225
+ className: `fixed top-0 right-0 z-40 flex flex-col bg-white border-l border-gray-200 h-full overflow-hidden transition-transform duration-300 ${isOpen ? "translate-x-0" : "translate-x-full"}`,
3226
+ style: { width: `${PANEL_WIDTH}px` },
3227
+ children: [
3228
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-gradient-to-r from-gray-50 to-white shrink-0", children: [
3229
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-2.5", children: [
3230
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" }),
3231
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-sm font-semibold text-gray-800", children: "Copilot" })
3232
+ ] }),
3233
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3234
+ Button,
3235
+ {
3236
+ variant: "ghost",
3237
+ size: "sm",
3238
+ className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
3239
+ onClick: () => onClose?.(),
3240
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react4.Minus, { className: "h-3.5 w-3.5" })
3241
+ }
3242
+ )
3243
+ ] }),
3244
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AuthErrorState, { error: authState.error, onRetry: retryAuth })
3245
+ ]
3246
+ }
3247
+ );
3248
+ }
3249
+ }
3078
3250
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
3079
3251
  "section",
3080
3252
  {
@@ -4192,7 +4364,7 @@ ${userText}`
4192
4364
  message.id
4193
4365
  );
4194
4366
  }
4195
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
4367
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React5.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
4196
4368
  "div",
4197
4369
  {
4198
4370
  ref: isCurrentGuideStep ? currentStepRef : null,
@@ -4446,9 +4618,10 @@ function ChatPanelWithToggle({
4446
4618
  userEmail,
4447
4619
  userOrganization,
4448
4620
  supabaseUrl,
4449
- supabaseAnonKey
4621
+ supabaseAnonKey,
4622
+ productBackendUrl
4450
4623
  }) {
4451
- const [internalIsOpen, setInternalIsOpen] = React4.useState(defaultOpen);
4624
+ const [internalIsOpen, setInternalIsOpen] = React5.useState(defaultOpen);
4452
4625
  const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
4453
4626
  const setIsOpen = (open) => {
4454
4627
  if (controlledIsOpen === void 0) {
@@ -4456,7 +4629,7 @@ function ChatPanelWithToggle({
4456
4629
  }
4457
4630
  onOpenChange?.(open);
4458
4631
  };
4459
- React4.useEffect(() => {
4632
+ React5.useEffect(() => {
4460
4633
  const originalPadding = document.body.style.paddingRight;
4461
4634
  const originalTransition = document.body.style.transition;
4462
4635
  document.body.style.transition = "padding-right 0.3s ease";
@@ -4484,7 +4657,8 @@ function ChatPanelWithToggle({
4484
4657
  userEmail,
4485
4658
  userOrganization,
4486
4659
  supabaseUrl,
4487
- supabaseAnonKey
4660
+ supabaseAnonKey,
4661
+ productBackendUrl
4488
4662
  }
4489
4663
  );
4490
4664
  }
@@ -4556,7 +4730,8 @@ function KiteChatWrapper({
4556
4730
  userEmail: config.userEmail,
4557
4731
  userOrganization: config.userOrganization,
4558
4732
  supabaseUrl: config.supabaseUrl,
4559
- supabaseAnonKey: config.supabaseAnonKey
4733
+ supabaseAnonKey: config.supabaseAnonKey,
4734
+ productBackendUrl: config.productBackendUrl
4560
4735
  }
4561
4736
  );
4562
4737
  }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as ActionData, A as ActionType, C as ChatPanel, d as ChatPanelProps, b as ChatPanelWithToggle, e as ChatPanelWithToggleProps, H as HelpButton, g as HelpButtonProps, K as KiteChatConfig, a as KiteChatInstance, N as NavigationTarget, h as Page, P as PanelToggle, f as PanelToggleProps, S as SettingsTab, j as StartingQuestion, c as createKiteChat } from './createKiteChat-jmAPjuv_.cjs';
1
+ export { i as ActionData, A as ActionType, C as ChatPanel, d as ChatPanelProps, b as ChatPanelWithToggle, e as ChatPanelWithToggleProps, H as HelpButton, g as HelpButtonProps, K as KiteChatConfig, a as KiteChatInstance, N as NavigationTarget, h as Page, P as PanelToggle, f as PanelToggleProps, S as SettingsTab, j as StartingQuestion, c as createKiteChat } from './createKiteChat-o5u-5Sor.cjs';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
4
  import * as React from 'react';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as ActionData, A as ActionType, C as ChatPanel, d as ChatPanelProps, b as ChatPanelWithToggle, e as ChatPanelWithToggleProps, H as HelpButton, g as HelpButtonProps, K as KiteChatConfig, a as KiteChatInstance, N as NavigationTarget, h as Page, P as PanelToggle, f as PanelToggleProps, S as SettingsTab, j as StartingQuestion, c as createKiteChat } from './createKiteChat-jmAPjuv_.js';
1
+ export { i as ActionData, A as ActionType, C as ChatPanel, d as ChatPanelProps, b as ChatPanelWithToggle, e as ChatPanelWithToggleProps, H as HelpButton, g as HelpButtonProps, K as KiteChatConfig, a as KiteChatInstance, N as NavigationTarget, h as Page, P as PanelToggle, f as PanelToggleProps, S as SettingsTab, j as StartingQuestion, c as createKiteChat } from './createKiteChat-o5u-5Sor.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
4
4
  import * as React from 'react';
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  cn,
32
32
  createKiteChat,
33
33
  useGuideCursor
34
- } from "./chunk-QSVOPKVC.js";
34
+ } from "./chunk-XMA5S556.js";
35
35
  export {
36
36
  ApiKeyList,
37
37
  AssistantActivity,