@kite-copilot/chat-panel 0.2.16 → 0.2.17

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.
@@ -883,10 +883,24 @@ function DataRenderer({ type, data }) {
883
883
 
884
884
  // src/ChatPanel.tsx
885
885
  import * as React4 from "react";
886
- import { ArrowLeft, ArrowUp, Command, CornerDownLeft, CheckCircle2 as CheckCircle23, SquarePen, Paperclip, X, FileSpreadsheet, Loader2 as Loader22, ChevronLeft, ChevronRight, Sparkles } from "lucide-react";
886
+ import {
887
+ ArrowLeft,
888
+ ArrowUp,
889
+ Command,
890
+ CornerDownLeft,
891
+ CheckCircle2 as CheckCircle23,
892
+ SquarePen,
893
+ Paperclip,
894
+ X,
895
+ FileSpreadsheet,
896
+ Loader2 as Loader22,
897
+ ChevronLeft,
898
+ ChevronRight,
899
+ Sparkles
900
+ } from "lucide-react";
887
901
  import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
888
902
  var DEFAULT_AGENT_URL = "http://localhost:5002";
889
- var PANEL_WIDTH = 340;
903
+ var PANEL_WIDTH = 400;
890
904
  function renderMarkdown(text) {
891
905
  if (!text) return null;
892
906
  const lines = text.split("\n");
@@ -903,7 +917,14 @@ function renderMarkdown(text) {
903
917
  const codeMatch = remaining.match(/^`([^`]+)`/);
904
918
  if (codeMatch) {
905
919
  parts.push(
906
- /* @__PURE__ */ jsx9("code", { className: "bg-gray-100 px-1 py-0.5 rounded text-xs font-mono", children: codeMatch[1] }, keyIndex++)
920
+ /* @__PURE__ */ jsx9(
921
+ "code",
922
+ {
923
+ className: "bg-gray-100 px-1 py-0.5 rounded text-xs font-mono",
924
+ children: codeMatch[1]
925
+ },
926
+ keyIndex++
927
+ )
907
928
  );
908
929
  remaining = remaining.slice(codeMatch[0].length);
909
930
  continue;
@@ -923,7 +944,17 @@ function renderMarkdown(text) {
923
944
  const linkMatch = remaining.match(/^\[([^\]]+)\]\(([^)]+)\)/);
924
945
  if (linkMatch) {
925
946
  parts.push(
926
- /* @__PURE__ */ jsx9("a", { href: linkMatch[2], className: "text-blue-600 hover:underline", target: "_blank", rel: "noopener noreferrer", children: linkMatch[1] }, keyIndex++)
947
+ /* @__PURE__ */ jsx9(
948
+ "a",
949
+ {
950
+ href: linkMatch[2],
951
+ className: "text-blue-600 hover:underline",
952
+ target: "_blank",
953
+ rel: "noopener noreferrer",
954
+ children: linkMatch[1]
955
+ },
956
+ keyIndex++
957
+ )
927
958
  );
928
959
  remaining = remaining.slice(linkMatch[0].length);
929
960
  continue;
@@ -946,7 +977,14 @@ function renderMarkdown(text) {
946
977
  if (currentList) {
947
978
  const ListTag = currentList.type === "ul" ? "ul" : "ol";
948
979
  elements.push(
949
- /* @__PURE__ */ jsx9(ListTag, { className: `${currentList.type === "ul" ? "list-disc" : "list-decimal"} ml-4 my-1`, children: currentList.items.map((item, i) => /* @__PURE__ */ jsx9("li", { className: "ml-2", children: item }, i)) }, elements.length)
980
+ /* @__PURE__ */ jsx9(
981
+ ListTag,
982
+ {
983
+ className: `${currentList.type === "ul" ? "list-disc" : "list-decimal"} ml-4 my-1`,
984
+ children: currentList.items.map((item, i) => /* @__PURE__ */ jsx9("li", { className: "ml-2", children: item }, i))
985
+ },
986
+ elements.length
987
+ )
950
988
  );
951
989
  currentList = null;
952
990
  }
@@ -956,7 +994,14 @@ function renderMarkdown(text) {
956
994
  if (line.startsWith("```")) {
957
995
  if (inCodeBlock) {
958
996
  elements.push(
959
- /* @__PURE__ */ jsx9("pre", { className: "bg-gray-100 rounded p-2 my-1 overflow-x-auto", children: /* @__PURE__ */ jsx9("code", { className: "text-xs font-mono", children: codeContent.join("\n") }) }, elements.length)
997
+ /* @__PURE__ */ jsx9(
998
+ "pre",
999
+ {
1000
+ className: "bg-gray-100 rounded p-2 my-1 overflow-x-auto",
1001
+ children: /* @__PURE__ */ jsx9("code", { className: "text-xs font-mono", children: codeContent.join("\n") })
1002
+ },
1003
+ elements.length
1004
+ )
960
1005
  );
961
1006
  inCodeBlock = false;
962
1007
  codeContent = [];
@@ -978,7 +1023,9 @@ function renderMarkdown(text) {
978
1023
  const level = headerMatch[1].length;
979
1024
  const content = processInlineFormatting(headerMatch[2]);
980
1025
  const className = level === 1 ? "text-lg font-bold my-1" : level === 2 ? "text-base font-bold my-1" : "text-sm font-semibold my-1";
981
- elements.push(/* @__PURE__ */ jsx9("div", { className, children: content }, elements.length));
1026
+ elements.push(
1027
+ /* @__PURE__ */ jsx9("div", { className, children: content }, elements.length)
1028
+ );
982
1029
  continue;
983
1030
  }
984
1031
  const ulMatch = line.match(/^[-*]\s+(.+)/);
@@ -1006,11 +1053,15 @@ function renderMarkdown(text) {
1006
1053
  }
1007
1054
  if (line.match(/^[-*_]{3,}$/)) {
1008
1055
  flushList();
1009
- elements.push(/* @__PURE__ */ jsx9("hr", { className: "my-2 border-gray-200" }, elements.length));
1056
+ elements.push(
1057
+ /* @__PURE__ */ jsx9("hr", { className: "my-2 border-gray-200" }, elements.length)
1058
+ );
1010
1059
  continue;
1011
1060
  }
1012
1061
  flushList();
1013
- elements.push(/* @__PURE__ */ jsx9("div", { children: processInlineFormatting(line) }, elements.length));
1062
+ elements.push(
1063
+ /* @__PURE__ */ jsx9("div", { children: processInlineFormatting(line) }, elements.length)
1064
+ );
1014
1065
  }
1015
1066
  flushList();
1016
1067
  return /* @__PURE__ */ jsx9(Fragment2, { children: elements });
@@ -1040,31 +1091,59 @@ var folders = [
1040
1091
  id: "customers",
1041
1092
  title: "Customer Management",
1042
1093
  topics: [
1043
- { id: "add-customer", label: "Add a new customer", prompt: "How do I add a new customer to the system and what information is required?" },
1044
- { id: "customer-details", label: "View customer details", prompt: "Show me how to view and edit customer information and their payment history." }
1094
+ {
1095
+ id: "add-customer",
1096
+ label: "Add a new customer",
1097
+ prompt: "How do I add a new customer to the system and what information is required?"
1098
+ },
1099
+ {
1100
+ id: "customer-details",
1101
+ label: "View customer details",
1102
+ prompt: "Show me how to view and edit customer information and their payment history."
1103
+ }
1045
1104
  ]
1046
1105
  },
1047
1106
  {
1048
1107
  id: "payments",
1049
1108
  title: "Payment Processing",
1050
1109
  topics: [
1051
- { id: "process-payment", label: "Process a payment", prompt: "How do I process a one-time payment for a customer?" },
1052
- { id: "refund-payment", label: "Issue a refund", prompt: "Walk me through issuing a refund for a customer payment." }
1110
+ {
1111
+ id: "process-payment",
1112
+ label: "Process a payment",
1113
+ prompt: "How do I process a one-time payment for a customer?"
1114
+ },
1115
+ {
1116
+ id: "refund-payment",
1117
+ label: "Issue a refund",
1118
+ prompt: "Walk me through issuing a refund for a customer payment."
1119
+ }
1053
1120
  ]
1054
1121
  },
1055
1122
  {
1056
1123
  id: "subscriptions",
1057
1124
  title: "Subscription Management",
1058
1125
  topics: [
1059
- { id: "create-subscription", label: "Create a subscription", prompt: "How do I set up a new subscription plan for a customer?" },
1060
- { id: "update-subscription", label: "Update subscription tier", prompt: "How can I change a customer's subscription plan or upgrade them?" }
1126
+ {
1127
+ id: "create-subscription",
1128
+ label: "Create a subscription",
1129
+ prompt: "How do I set up a new subscription plan for a customer?"
1130
+ },
1131
+ {
1132
+ id: "update-subscription",
1133
+ label: "Update subscription tier",
1134
+ prompt: "How can I change a customer's subscription plan or upgrade them?"
1135
+ }
1061
1136
  ]
1062
1137
  },
1063
1138
  {
1064
1139
  id: "billing",
1065
1140
  title: "Billing",
1066
1141
  topics: [
1067
- { id: "payment-methods", label: "Manage payment methods", prompt: "How do customers add or update their payment methods?" }
1142
+ {
1143
+ id: "payment-methods",
1144
+ label: "Manage payment methods",
1145
+ prompt: "How do customers add or update their payment methods?"
1146
+ }
1068
1147
  ]
1069
1148
  }
1070
1149
  ];
@@ -1210,18 +1289,21 @@ function ChatPanel({
1210
1289
  } = {}) {
1211
1290
  const [messages, setMessages] = React4.useState(initialMessages);
1212
1291
  const [input, setInput] = React4.useState("");
1213
- const [sessionId] = React4.useState(() => crypto.randomUUID());
1292
+ const [sessionId, setSessionId] = React4.useState(() => crypto.randomUUID());
1293
+ const resetSession = React4.useCallback(() => {
1294
+ setSessionId(crypto.randomUUID());
1295
+ }, []);
1214
1296
  const streamIntervals = React4.useRef({});
1215
1297
  const isEmpty = messages.length === 0;
1216
1298
  const [phase, setPhase] = React4.useState("idle");
1217
1299
  const [progressSteps, setProgressSteps] = React4.useState([]);
1218
1300
  const phaseTimers = React4.useRef([]);
1219
1301
  const lastRole = messages.length ? messages[messages.length - 1].role : void 0;
1220
- const [panelView, setPanelView] = React4.useState("landing");
1221
- const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1222
- const [startingQuestions, setStartingQuestions] = React4.useState(
1223
- startingQuestionsProp || defaultStartingQuestions
1302
+ const [panelView, setPanelView] = React4.useState(
1303
+ "landing"
1224
1304
  );
1305
+ const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1306
+ const [startingQuestions, setStartingQuestions] = React4.useState(startingQuestionsProp || defaultStartingQuestions);
1225
1307
  const [loadingQuestions, setLoadingQuestions] = React4.useState(false);
1226
1308
  React4.useEffect(() => {
1227
1309
  if (startingQuestionsEndpoint && !startingQuestionsProp) {
@@ -1245,10 +1327,11 @@ function ChatPanel({
1245
1327
  const latestBulkSummaryNavigationRef = React4.useRef(null);
1246
1328
  const [guideComplete, setGuideComplete] = React4.useState(false);
1247
1329
  React4.useEffect(() => {
1248
- ;
1249
1330
  window.resetIntegrationNotification = () => {
1250
1331
  localStorage.removeItem("gmailNotificationSeen");
1251
- console.log("Integration notification reset! Click the Integrations tab to see it again.");
1332
+ console.log(
1333
+ "Integration notification reset! Click the Integrations tab to see it again."
1334
+ );
1252
1335
  };
1253
1336
  const handleIntegrationTabClick = () => {
1254
1337
  const hasSeenNotification = localStorage.getItem("gmailNotificationSeen");
@@ -1271,7 +1354,10 @@ function ChatPanel({
1271
1354
  };
1272
1355
  window.addEventListener("integrationTabClicked", handleIntegrationTabClick);
1273
1356
  return () => {
1274
- window.removeEventListener("integrationTabClicked", handleIntegrationTabClick);
1357
+ window.removeEventListener(
1358
+ "integrationTabClicked",
1359
+ handleIntegrationTabClick
1360
+ );
1275
1361
  };
1276
1362
  }, []);
1277
1363
  React4.useEffect(() => {
@@ -1306,7 +1392,12 @@ function ChatPanel({
1306
1392
  const id = Date.now() + 1;
1307
1393
  setMessages((prev) => [
1308
1394
  ...prev,
1309
- { id, role: "assistant", kind: "guideComplete", content: "Perfect! The dialog is now open. You can enter a name and create your API key." }
1395
+ {
1396
+ id,
1397
+ role: "assistant",
1398
+ kind: "guideComplete",
1399
+ content: "Perfect! The dialog is now open. You can enter a name and create your API key."
1400
+ }
1310
1401
  ]);
1311
1402
  setActiveGuide(void 0);
1312
1403
  setGuideComplete(true);
@@ -1317,7 +1408,9 @@ function ChatPanel({
1317
1408
  }, [activeGuide, hide]);
1318
1409
  React4.useEffect(() => {
1319
1410
  return () => {
1320
- Object.values(streamIntervals.current).forEach((id) => window.clearInterval(id));
1411
+ Object.values(streamIntervals.current).forEach(
1412
+ (id) => window.clearInterval(id)
1413
+ );
1321
1414
  streamIntervals.current = {};
1322
1415
  phaseTimers.current.forEach((id) => window.clearTimeout(id));
1323
1416
  phaseTimers.current = [];
@@ -1378,9 +1471,17 @@ function ChatPanel({
1378
1471
  return;
1379
1472
  }
1380
1473
  const currentBulkNav = latestBulkSummaryNavigationRef.current;
1381
- console.log("[DEBUG] Keyboard handler - latestBulkSummaryNavigation:", currentBulkNav, "onNavigate:", !!onNavigate);
1474
+ console.log(
1475
+ "[DEBUG] Keyboard handler - latestBulkSummaryNavigation:",
1476
+ currentBulkNav,
1477
+ "onNavigate:",
1478
+ !!onNavigate
1479
+ );
1382
1480
  if (currentBulkNav && onNavigate) {
1383
- console.log("[DEBUG] Navigating via keyboard to:", currentBulkNav.page);
1481
+ console.log(
1482
+ "[DEBUG] Navigating via keyboard to:",
1483
+ currentBulkNav.page
1484
+ );
1384
1485
  e.preventDefault();
1385
1486
  e.stopPropagation();
1386
1487
  onNavigate(currentBulkNav.page, currentBulkNav.subtab);
@@ -1403,21 +1504,57 @@ function ChatPanel({
1403
1504
  };
1404
1505
  window.addEventListener("keydown", handleKeyDown);
1405
1506
  return () => window.removeEventListener("keydown", handleKeyDown);
1406
- }, [pendingAction, pendingNavigation, activeGuide, guideComplete, onNavigate]);
1507
+ }, [
1508
+ pendingAction,
1509
+ pendingNavigation,
1510
+ activeGuide,
1511
+ guideComplete,
1512
+ onNavigate
1513
+ ]);
1407
1514
  function streamAssistantMessage(messageId, fullText, followups) {
1408
- const tokens = fullText.split(" ");
1515
+ let textToStream = fullText;
1516
+ let extractedFollowups = followups;
1517
+ if (fullText && fullText.startsWith("{") && fullText.includes('"response"')) {
1518
+ try {
1519
+ let depth = 0, endIdx = 0;
1520
+ for (let i2 = 0; i2 < fullText.length; i2++) {
1521
+ if (fullText[i2] === "{") depth++;
1522
+ else if (fullText[i2] === "}") {
1523
+ depth--;
1524
+ if (depth === 0) {
1525
+ endIdx = i2 + 1;
1526
+ break;
1527
+ }
1528
+ }
1529
+ }
1530
+ const firstJson = endIdx > 0 ? fullText.slice(0, endIdx) : fullText;
1531
+ const parsed = JSON.parse(firstJson);
1532
+ if (parsed.response && typeof parsed.response === "string") {
1533
+ textToStream = parsed.response;
1534
+ if (!extractedFollowups && parsed.followups) {
1535
+ extractedFollowups = parsed.followups;
1536
+ }
1537
+ }
1538
+ } catch {
1539
+ }
1540
+ }
1541
+ const tokens = textToStream.split(" ");
1409
1542
  let i = 0;
1410
1543
  const intervalId = window.setInterval(() => {
1411
1544
  i += 1;
1412
1545
  setMessages(
1413
- (prev) => prev.map((m) => m.id === messageId ? { ...m, content: tokens.slice(0, i).join(" ") } : m)
1546
+ (prev) => prev.map(
1547
+ (m) => m.id === messageId ? { ...m, content: tokens.slice(0, i).join(" ") } : m
1548
+ )
1414
1549
  );
1415
1550
  if (i >= tokens.length) {
1416
1551
  window.clearInterval(intervalId);
1417
1552
  delete streamIntervals.current[messageId];
1418
- if (followups && followups.length > 0) {
1553
+ if (extractedFollowups && extractedFollowups.length > 0) {
1419
1554
  setMessages(
1420
- (prev) => prev.map((m) => m.id === messageId ? { ...m, followups } : m)
1555
+ (prev) => prev.map(
1556
+ (m) => m.id === messageId ? { ...m, followups: extractedFollowups } : m
1557
+ )
1421
1558
  );
1422
1559
  }
1423
1560
  setPhase("idle");
@@ -1427,16 +1564,21 @@ function ChatPanel({
1427
1564
  }
1428
1565
  function handleFollowupClick(messageId, followup) {
1429
1566
  setMessages(
1430
- (prev) => prev.map((m) => m.id === messageId ? { ...m, followupSelected: true } : m)
1567
+ (prev) => prev.map(
1568
+ (m) => m.id === messageId ? { ...m, followupSelected: true } : m
1569
+ )
1431
1570
  );
1432
1571
  startChatFlow(followup.label);
1433
1572
  }
1434
1573
  function handleBack() {
1435
- Object.values(streamIntervals.current).forEach((id) => window.clearInterval(id));
1574
+ Object.values(streamIntervals.current).forEach(
1575
+ (id) => window.clearInterval(id)
1576
+ );
1436
1577
  streamIntervals.current = {};
1437
1578
  phaseTimers.current.forEach((id) => window.clearTimeout(id));
1438
1579
  phaseTimers.current = [];
1439
1580
  hide();
1581
+ resetSession();
1440
1582
  setMessages([]);
1441
1583
  setInput("");
1442
1584
  setPhase("idle");
@@ -1596,7 +1738,10 @@ function ChatPanel({
1596
1738
  content: ""
1597
1739
  };
1598
1740
  setMessages((prev) => [...prev, thankYouMessage]);
1599
- streamAssistantMessage(thankYouMessageId, "Thank you, your feedback is saved.");
1741
+ streamAssistantMessage(
1742
+ thankYouMessageId,
1743
+ "Thank you, your feedback is saved."
1744
+ );
1600
1745
  return;
1601
1746
  }
1602
1747
  setPendingNavigation(null);
@@ -1654,7 +1799,10 @@ function ChatPanel({
1654
1799
  } else if (data.status === "executing") {
1655
1800
  setPhase("executing");
1656
1801
  setProgressSteps((prev) => {
1657
- const updated = prev.map((step) => ({ ...step, completed: true }));
1802
+ const updated = prev.map((step) => ({
1803
+ ...step,
1804
+ completed: true
1805
+ }));
1658
1806
  const lastStep = updated[updated.length - 1];
1659
1807
  if (!lastStep || lastStep.message !== data.message) {
1660
1808
  updated.push({ message: data.message, completed: false });
@@ -1663,7 +1811,9 @@ function ChatPanel({
1663
1811
  });
1664
1812
  } else if (data.status === "responding") {
1665
1813
  setPhase("responding");
1666
- setProgressSteps((prev) => prev.map((step) => ({ ...step, completed: true })));
1814
+ setProgressSteps(
1815
+ (prev) => prev.map((step) => ({ ...step, completed: true }))
1816
+ );
1667
1817
  }
1668
1818
  } else if (eventType === "response") {
1669
1819
  setProgressSteps([]);
@@ -1709,7 +1859,11 @@ function ChatPanel({
1709
1859
  content: ""
1710
1860
  };
1711
1861
  setMessages((prev) => [...prev, assistantMessage]);
1712
- streamAssistantMessage(assistantMessageId, agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!", agentResponse.followups);
1862
+ streamAssistantMessage(
1863
+ assistantMessageId,
1864
+ agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!",
1865
+ agentResponse.followups
1866
+ );
1713
1867
  streamCompleted = true;
1714
1868
  } else if (agentResponse.action === "bulk_preview") {
1715
1869
  setPendingBulkSession(agentResponse.bulk_session_id);
@@ -1741,12 +1895,18 @@ function ChatPanel({
1741
1895
  structuredData: agentResponse.structuredData || void 0
1742
1896
  };
1743
1897
  setMessages((prev) => [...prev, assistantMessage]);
1744
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1898
+ streamAssistantMessage(
1899
+ assistantMessageId,
1900
+ agentResponse.response,
1901
+ agentResponse.followups
1902
+ );
1745
1903
  streamCompleted = true;
1746
1904
  setTimeout(() => {
1747
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1748
- detail: { result: agentResponse.executionResult }
1749
- }));
1905
+ window.dispatchEvent(
1906
+ new CustomEvent("agentActionComplete", {
1907
+ detail: { result: agentResponse.executionResult }
1908
+ })
1909
+ );
1750
1910
  }, 100);
1751
1911
  } else {
1752
1912
  const assistantMessageId = now + 1;
@@ -1757,7 +1917,11 @@ function ChatPanel({
1757
1917
  content: ""
1758
1918
  };
1759
1919
  setMessages((prev) => [...prev, assistantMessage]);
1760
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1920
+ streamAssistantMessage(
1921
+ assistantMessageId,
1922
+ agentResponse.response,
1923
+ agentResponse.followups
1924
+ );
1761
1925
  streamCompleted = true;
1762
1926
  }
1763
1927
  } else if (eventType === "error") {
@@ -1772,7 +1936,10 @@ function ChatPanel({
1772
1936
  content: ""
1773
1937
  };
1774
1938
  setMessages((prev) => [...prev, errorMessage]);
1775
- streamAssistantMessage(errorMessageId, data.message || "An error occurred processing your request.");
1939
+ streamAssistantMessage(
1940
+ errorMessageId,
1941
+ data.message || "An error occurred processing your request."
1942
+ );
1776
1943
  } else if (eventType === "done") {
1777
1944
  setProgressSteps([]);
1778
1945
  setPhase("idle");
@@ -1798,7 +1965,18 @@ function ChatPanel({
1798
1965
  content: ""
1799
1966
  };
1800
1967
  setMessages((prev) => [...prev, errorMessage]);
1801
- streamAssistantMessage(errorMessageId, "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002. For simple navigation requests, I can still help you locally.");
1968
+ let errorText = "I'm having trouble connecting to my backend.";
1969
+ if (error instanceof Error) {
1970
+ if (error.name === "AbortError") {
1971
+ errorText = "The request timed out. The server might be busy - please try again.";
1972
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
1973
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
1974
+ } else if (error.message.includes("Agent request failed:")) {
1975
+ errorText = "The server encountered an error. Please try again.";
1976
+ }
1977
+ }
1978
+ errorText += " For simple navigation requests, I can still help you locally.";
1979
+ streamAssistantMessage(errorMessageId, errorText);
1802
1980
  } finally {
1803
1981
  setProgressSteps([]);
1804
1982
  }
@@ -1882,33 +2060,41 @@ ${userText}`
1882
2060
  setMessages((prev) => [...prev, previewMessage]);
1883
2061
  } else if (eventType === "progress") {
1884
2062
  setPhase("executing");
1885
- setProgressSteps([{
1886
- message: `Processing row ${data.row} of ${data.total}...`,
1887
- completed: false
1888
- }]);
2063
+ setProgressSteps([
2064
+ {
2065
+ message: `Processing row ${data.row} of ${data.total}...`,
2066
+ completed: false
2067
+ }
2068
+ ]);
1889
2069
  setMessages((prev) => {
1890
2070
  const lastMsg = prev[prev.length - 1];
1891
2071
  if (lastMsg?.kind === "bulkProgress") {
1892
2072
  return prev.map(
1893
- (m, i) => i === prev.length - 1 ? { ...m, bulkProgress: {
1894
- processed: data.row,
1895
- total: data.total,
1896
- successes: data.successes || 0,
1897
- failures: data.failures || 0
1898
- } } : m
2073
+ (m, i) => i === prev.length - 1 ? {
2074
+ ...m,
2075
+ bulkProgress: {
2076
+ processed: data.row,
2077
+ total: data.total,
2078
+ successes: data.successes || 0,
2079
+ failures: data.failures || 0
2080
+ }
2081
+ } : m
1899
2082
  );
1900
2083
  } else {
1901
- return [...prev, {
1902
- id: Date.now(),
1903
- role: "assistant",
1904
- kind: "bulkProgress",
1905
- bulkProgress: {
1906
- processed: data.row,
1907
- total: data.total,
1908
- successes: data.successes || 0,
1909
- failures: data.failures || 0
2084
+ return [
2085
+ ...prev,
2086
+ {
2087
+ id: Date.now(),
2088
+ role: "assistant",
2089
+ kind: "bulkProgress",
2090
+ bulkProgress: {
2091
+ processed: data.row,
2092
+ total: data.total,
2093
+ successes: data.successes || 0,
2094
+ failures: data.failures || 0
2095
+ }
1910
2096
  }
1911
- }];
2097
+ ];
1912
2098
  }
1913
2099
  });
1914
2100
  } else if (eventType === "summary") {
@@ -1917,23 +2103,34 @@ ${userText}`
1917
2103
  setPendingBulkSession(null);
1918
2104
  setMessages((prev) => {
1919
2105
  const filtered = prev.filter((m) => m.kind !== "bulkProgress");
1920
- return [...filtered, {
1921
- id: Date.now(),
1922
- role: "assistant",
1923
- kind: "bulkSummary",
1924
- content: data.message,
1925
- bulkSummary: {
1926
- total: data.total,
1927
- successes: data.successes,
1928
- failures: data.failures || [],
1929
- navigationPage: data.navigationPage
2106
+ return [
2107
+ ...filtered,
2108
+ {
2109
+ id: Date.now(),
2110
+ role: "assistant",
2111
+ kind: "bulkSummary",
2112
+ content: data.message,
2113
+ bulkSummary: {
2114
+ total: data.total,
2115
+ successes: data.successes,
2116
+ failures: data.failures || [],
2117
+ navigationPage: data.navigationPage
2118
+ }
1930
2119
  }
1931
- }];
2120
+ ];
1932
2121
  });
1933
2122
  setTimeout(() => {
1934
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1935
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
1936
- }));
2123
+ window.dispatchEvent(
2124
+ new CustomEvent("agentActionComplete", {
2125
+ detail: {
2126
+ result: {
2127
+ bulk: true,
2128
+ total: data.total,
2129
+ successes: data.successes
2130
+ }
2131
+ }
2132
+ })
2133
+ );
1937
2134
  }, 100);
1938
2135
  } else if (eventType === "error") {
1939
2136
  setPhase("idle");
@@ -1961,18 +2158,31 @@ ${userText}`
1961
2158
  console.error("Bulk upload failed:", error);
1962
2159
  setProgressSteps([]);
1963
2160
  setPhase("idle");
2161
+ let errorText = "I'm having trouble processing your CSV file.";
2162
+ if (error instanceof Error) {
2163
+ if (error.name === "AbortError") {
2164
+ errorText = "The bulk upload request timed out. The file might be too large or the server is busy - please try again.";
2165
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
2166
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
2167
+ } else if (error.message.includes("Bulk upload failed:")) {
2168
+ errorText = "The server encountered an error processing your CSV file. Please try again.";
2169
+ }
2170
+ }
2171
+ errorText += " Please try again.";
1964
2172
  const errorMessage = {
1965
2173
  id: now + 1,
1966
2174
  role: "assistant",
1967
2175
  kind: "text",
1968
- content: "I'm having trouble processing your CSV file. Please make sure the agent server is running on port 5002 and try again."
2176
+ content: errorText
1969
2177
  };
1970
2178
  setMessages((prev) => [...prev, errorMessage]);
1971
2179
  }
1972
2180
  }
1973
2181
  async function confirmBulkOperation(bulkSessionId) {
1974
2182
  setPhase("executing");
1975
- setProgressSteps([{ message: "Starting bulk operation...", completed: false }]);
2183
+ setProgressSteps([
2184
+ { message: "Starting bulk operation...", completed: false }
2185
+ ]);
1976
2186
  try {
1977
2187
  const response = await fetch(`${agentUrl}/chat/bulk/confirm`, {
1978
2188
  method: "POST",
@@ -2008,43 +2218,56 @@ ${userText}`
2008
2218
  try {
2009
2219
  const data = JSON.parse(eventData);
2010
2220
  if (eventType === "progress") {
2011
- setProgressSteps([{
2012
- message: `Processing row ${data.row} of ${data.total}...`,
2013
- completed: false
2014
- }]);
2221
+ setProgressSteps([
2222
+ {
2223
+ message: `Processing row ${data.row} of ${data.total}...`,
2224
+ completed: false
2225
+ }
2226
+ ]);
2015
2227
  setMessages((prev) => {
2016
2228
  const lastMsg = prev[prev.length - 1];
2017
2229
  if (lastMsg?.kind === "bulkProgress") {
2018
2230
  return prev.map(
2019
- (m, i) => i === prev.length - 1 ? { ...m, bulkProgress: {
2020
- processed: data.row,
2021
- total: data.total,
2022
- successes: data.successes || 0,
2023
- failures: data.failures || 0
2024
- } } : m
2231
+ (m, i) => i === prev.length - 1 ? {
2232
+ ...m,
2233
+ bulkProgress: {
2234
+ processed: data.row,
2235
+ total: data.total,
2236
+ successes: data.successes || 0,
2237
+ failures: data.failures || 0
2238
+ }
2239
+ } : m
2025
2240
  );
2026
2241
  } else {
2027
- return [...prev, {
2028
- id: Date.now(),
2029
- role: "assistant",
2030
- kind: "bulkProgress",
2031
- bulkProgress: {
2032
- processed: data.row,
2033
- total: data.total,
2034
- successes: data.successes || 0,
2035
- failures: data.failures || 0
2242
+ return [
2243
+ ...prev,
2244
+ {
2245
+ id: Date.now(),
2246
+ role: "assistant",
2247
+ kind: "bulkProgress",
2248
+ bulkProgress: {
2249
+ processed: data.row,
2250
+ total: data.total,
2251
+ successes: data.successes || 0,
2252
+ failures: data.failures || 0
2253
+ }
2036
2254
  }
2037
- }];
2255
+ ];
2038
2256
  }
2039
2257
  });
2040
2258
  } else if (eventType === "summary") {
2041
2259
  console.log("[DEBUG] Received summary event - data:", data);
2042
- console.log("[DEBUG] navigationPage from backend:", data.navigationPage);
2260
+ console.log(
2261
+ "[DEBUG] navigationPage from backend:",
2262
+ data.navigationPage
2263
+ );
2043
2264
  setPhase("idle");
2044
2265
  setProgressSteps([]);
2045
2266
  setPendingBulkSession(null);
2046
2267
  setMessages((prev) => {
2047
- const filtered = prev.filter((m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview");
2268
+ const filtered = prev.filter(
2269
+ (m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview"
2270
+ );
2048
2271
  const newMsg = {
2049
2272
  id: Date.now(),
2050
2273
  role: "assistant",
@@ -2061,9 +2284,17 @@ ${userText}`
2061
2284
  return [...filtered, newMsg];
2062
2285
  });
2063
2286
  setTimeout(() => {
2064
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
2065
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
2066
- }));
2287
+ window.dispatchEvent(
2288
+ new CustomEvent("agentActionComplete", {
2289
+ detail: {
2290
+ result: {
2291
+ bulk: true,
2292
+ total: data.total,
2293
+ successes: data.successes
2294
+ }
2295
+ }
2296
+ })
2297
+ );
2067
2298
  }, 100);
2068
2299
  } else if (eventType === "error") {
2069
2300
  setPhase("idle");
@@ -2105,7 +2336,10 @@ ${userText}`
2105
2336
  }
2106
2337
  function appendAssistantText(text) {
2107
2338
  const id = Date.now() + Math.floor(Math.random() * 1e3);
2108
- setMessages((prev) => [...prev, { id, role: "assistant", kind: "text", content: text }]);
2339
+ setMessages((prev) => [
2340
+ ...prev,
2341
+ { id, role: "assistant", kind: "text", content: text }
2342
+ ]);
2109
2343
  }
2110
2344
  function startGuide(guideId) {
2111
2345
  const guide = guides[guideId];
@@ -2118,7 +2352,9 @@ ${userText}`
2118
2352
  appendAssistantText(`I'll help you with ${guide.title}.`);
2119
2353
  const firstStep = guide.steps[0];
2120
2354
  const isNavigationButton = firstStep.cursorTarget?.selector.includes("[data-page=");
2121
- const isTabButton = firstStep.cursorTarget?.selector.includes("[data-settings-tab=");
2355
+ const isTabButton = firstStep.cursorTarget?.selector.includes(
2356
+ "[data-settings-tab="
2357
+ );
2122
2358
  if (firstStep.cursorTarget && (isNavigationButton || isTabButton)) {
2123
2359
  const cursorTarget = firstStep.cursorTarget;
2124
2360
  if (isTabButton && firstStep.navigation && onNavigate) {
@@ -2127,7 +2363,9 @@ ${userText}`
2127
2363
  const initialDelay = isTabButton ? 800 : 400;
2128
2364
  setTimeout(() => {
2129
2365
  const waitForElement = () => {
2130
- const element = document.querySelector(cursorTarget.selector);
2366
+ const element = document.querySelector(
2367
+ cursorTarget.selector
2368
+ );
2131
2369
  if (element && element.offsetParent !== null) {
2132
2370
  moveTo(cursorTarget);
2133
2371
  if (cursorTarget.onClick) {
@@ -2152,7 +2390,9 @@ ${userText}`
2152
2390
  const initialDelay = isDialogElement ? 700 : isSettingsTab ? 600 : 400;
2153
2391
  setTimeout(() => {
2154
2392
  const waitForElement = () => {
2155
- const element = document.querySelector(cursorTarget.selector);
2393
+ const element = document.querySelector(
2394
+ cursorTarget.selector
2395
+ );
2156
2396
  if (element && element.offsetParent !== null) {
2157
2397
  moveTo(cursorTarget);
2158
2398
  if (cursorTarget.onClick) {
@@ -2166,7 +2406,9 @@ ${userText}`
2166
2406
  moveTo(cursorTarget);
2167
2407
  if (cursorTarget.onClick) {
2168
2408
  setTimeout(() => {
2169
- const el = document.querySelector(cursorTarget.selector);
2409
+ const el = document.querySelector(
2410
+ cursorTarget.selector
2411
+ );
2170
2412
  if (el) el.click();
2171
2413
  }, 1e3);
2172
2414
  }
@@ -2203,7 +2445,12 @@ ${userText}`
2203
2445
  const id = Date.now() + 1;
2204
2446
  setMessages((prev) => [
2205
2447
  ...prev,
2206
- { id, role: "assistant", kind: "guideComplete", content: "Guide Complete" }
2448
+ {
2449
+ id,
2450
+ role: "assistant",
2451
+ kind: "guideComplete",
2452
+ content: "Guide Complete"
2453
+ }
2207
2454
  ]);
2208
2455
  setActiveGuide(void 0);
2209
2456
  setGuideComplete(true);
@@ -2222,7 +2469,9 @@ ${userText}`
2222
2469
  };
2223
2470
  setMessages((prev) => [...prev, draft]);
2224
2471
  const isNavigationButton = nextStep.cursorTarget?.selector.includes("[data-page=");
2225
- const isTabButton = nextStep.cursorTarget?.selector.includes("[data-settings-tab=");
2472
+ const isTabButton = nextStep.cursorTarget?.selector.includes(
2473
+ "[data-settings-tab="
2474
+ );
2226
2475
  if (nextStep.cursorTarget && (isNavigationButton || isTabButton)) {
2227
2476
  const cursorTarget = nextStep.cursorTarget;
2228
2477
  if (isTabButton && nextStep.navigation && onNavigate) {
@@ -2239,7 +2488,9 @@ ${userText}`
2239
2488
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2240
2489
  return;
2241
2490
  }
2242
- const element = document.querySelector(cursorTarget.selector);
2491
+ const element = document.querySelector(
2492
+ cursorTarget.selector
2493
+ );
2243
2494
  if (element && element.offsetParent !== null) {
2244
2495
  moveTo(cursorTarget);
2245
2496
  if (cursorTarget.onClick) {
@@ -2265,7 +2516,9 @@ ${userText}`
2265
2516
  const cursorTarget = nextStep.cursorTarget;
2266
2517
  const isDialogElement = cursorTarget.selector.includes("dialog") || cursorTarget.selector.includes("api-key-name-input");
2267
2518
  const isSettingsTab = cursorTarget.selector.includes("data-settings-tab");
2268
- const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(`data-settings-tab="${nextStep.navigation.subtab}"`);
2519
+ const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(
2520
+ `data-settings-tab="${nextStep.navigation.subtab}"`
2521
+ );
2269
2522
  const shouldAutoClick = cursorTarget.onClick && !navigationSetTab;
2270
2523
  const hasNavigation = !!nextStep.navigation;
2271
2524
  const hasSubtab = !!nextStep.navigation?.subtab;
@@ -2281,7 +2534,9 @@ ${userText}`
2281
2534
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2282
2535
  return;
2283
2536
  }
2284
- const element = document.querySelector(cursorTarget.selector);
2537
+ const element = document.querySelector(
2538
+ cursorTarget.selector
2539
+ );
2285
2540
  if (element && element.offsetParent !== null) {
2286
2541
  moveTo(cursorTarget);
2287
2542
  if (shouldAutoClick) {
@@ -2303,7 +2558,9 @@ ${userText}`
2303
2558
  if (!currentGuide4 || currentGuide4.id !== guide.id || currentGuide4.stepIndex !== nextIndex) {
2304
2559
  return;
2305
2560
  }
2306
- const el = document.querySelector(cursorTarget.selector);
2561
+ const el = document.querySelector(
2562
+ cursorTarget.selector
2563
+ );
2307
2564
  if (el) el.click();
2308
2565
  }, 1e3);
2309
2566
  }
@@ -2335,10 +2592,17 @@ ${userText}`
2335
2592
  } else {
2336
2593
  hide();
2337
2594
  }
2338
- const existingMessages = messages.filter((m) => m.kind !== "guideStep" && m.kind !== "guideComplete");
2595
+ const existingMessages = messages.filter(
2596
+ (m) => m.kind !== "guideStep" && m.kind !== "guideComplete"
2597
+ );
2339
2598
  setMessages([
2340
2599
  ...existingMessages,
2341
- { id: Date.now(), role: "assistant", kind: "guideStep", content: prevStep.text }
2600
+ {
2601
+ id: Date.now(),
2602
+ role: "assistant",
2603
+ kind: "guideStep",
2604
+ content: prevStep.text
2605
+ }
2342
2606
  ]);
2343
2607
  }
2344
2608
  }
@@ -2361,6 +2625,7 @@ ${userText}`
2361
2625
  size: "sm",
2362
2626
  className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2363
2627
  onClick: () => {
2628
+ resetSession();
2364
2629
  setMessages([]);
2365
2630
  setPanelView("landing");
2366
2631
  setCurrentFolderId(void 0);
@@ -2383,919 +2648,1161 @@ ${userText}`
2383
2648
  )
2384
2649
  ] })
2385
2650
  ] }),
2386
- /* @__PURE__ */ jsx9("div", { className: isEmpty ? "grid flex-1 place-items-center transition-all duration-300" : "flex flex-1 flex-col transition-all duration-300 min-h-0 overflow-hidden", children: isEmpty ? /* @__PURE__ */ jsxs5("div", { className: "w-full overflow-y-auto px-4", children: [
2387
- /* @__PURE__ */ jsx9("div", { className: "py-3 transition-all duration-300", children: /* @__PURE__ */ jsx9("h2", { className: "text-center text-2xl font-semibold text-gray-900", children: panelView === "folder" ? folders.find((f) => f.id === currentFolderId)?.title || "" : "How can I help?" }) }),
2388
- /* @__PURE__ */ jsxs5("div", { className: "pb-4 px-4", children: [
2389
- panelView === "landing" && /* @__PURE__ */ jsx9(Fragment2, { children: /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ jsx9("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2390
- const iconColors = ["bg-blue-400", "bg-green-400", "bg-purple-400", "bg-orange-400", "bg-pink-400"];
2391
- return /* @__PURE__ */ jsxs5(
2392
- Button,
2393
- {
2394
- type: "button",
2395
- size: "sm",
2396
- variant: "ghost",
2397
- className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2398
- onClick: () => sendTopic(question.prompt),
2399
- children: [
2400
- /* @__PURE__ */ jsx9("span", { className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}` }),
2401
- question.label
2402
- ]
2403
- },
2404
- question.id
2405
- );
2406
- }) }) }),
2407
- panelView === "folder" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2408
- /* @__PURE__ */ jsxs5("div", { className: "mb-3 flex items-center gap-2", children: [
2409
- /* @__PURE__ */ jsx9(
2410
- Button,
2411
- {
2412
- type: "button",
2413
- size: "icon",
2414
- variant: "ghost",
2415
- className: "h-7 w-7 rounded-full hover:bg-gray-100",
2416
- onClick: closeFolder,
2417
- "aria-label": "Back to suggestions",
2418
- children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2419
- }
2420
- ),
2421
- /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2651
+ /* @__PURE__ */ jsx9(
2652
+ "div",
2653
+ {
2654
+ className: isEmpty ? "grid flex-1 place-items-center transition-all duration-300" : "flex flex-1 flex-col transition-all duration-300 min-h-0 overflow-hidden",
2655
+ children: isEmpty ? /* @__PURE__ */ jsxs5("div", { className: "w-full overflow-y-auto px-4", children: [
2656
+ /* @__PURE__ */ jsxs5("div", { className: "py-3 transition-all duration-300", children: [
2657
+ /* @__PURE__ */ jsx9("h2", { className: "text-center text-2xl font-semibold text-gray-900", children: panelView === "folder" ? folders.find((f) => f.id === currentFolderId)?.title || "" : "What can I help with?" }),
2658
+ panelView === "landing" && /* @__PURE__ */ jsx9("p", { className: "mt-1 text-center text-xs text-gray-500", children: "Ask me anything about your account" })
2422
2659
  ] }),
2423
- /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ jsx9(
2424
- Button,
2425
- {
2426
- type: "button",
2427
- size: "sm",
2428
- variant: "secondary",
2429
- className: "justify-start rounded-xl border border-gray-200 bg-gray-50 px-3 py-2.5 text-xs text-gray-700 shadow-none transition-all hover:bg-gray-100 hover:border-gray-300 h-auto",
2430
- onClick: () => sendTopic(topic.prompt),
2431
- children: topic.label
2432
- },
2433
- topic.id
2434
- )) })
2435
- ] })
2436
- ] })
2437
- ] }) : /* @__PURE__ */ jsx9(Fragment2, { children: /* @__PURE__ */ jsx9("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx9(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2438
- messages.map((message, index) => {
2439
- const isUser = message.role === "user";
2440
- const previousRole = index > 0 ? messages[index - 1].role : void 0;
2441
- const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2442
- const currentGuide = activeGuideRef.current || activeGuide;
2443
- let isCurrentGuideStep = false;
2444
- if (currentGuide && message.kind === "guideStep") {
2445
- if (message.guideStepIndex !== void 0) {
2446
- isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2447
- } else {
2448
- isCurrentGuideStep = index === messages.length - 1;
2449
- }
2450
- } else if (message.kind === "guideComplete") {
2451
- isCurrentGuideStep = index === messages.length - 1;
2452
- }
2453
- if (message.kind === "guideStep" && !isCurrentGuideStep) {
2454
- return null;
2455
- }
2456
- if (isUser) {
2457
- return /* @__PURE__ */ jsx9("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[260px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2458
- }
2459
- if (message.kind === "searchSummary") {
2460
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(AssistantSearchSummary, { title: message.title ?? "Search results", links: message.links ?? [] }) }, message.id);
2461
- }
2462
- if (message.kind === "guideComplete") {
2463
- return /* @__PURE__ */ jsx9(
2464
- "div",
2465
- {
2466
- ref: isCurrentGuideStep ? currentStepRef : null,
2467
- className: `${isRoleChange ? "mt-3" : ""}`,
2468
- children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-sm leading-6", children: [
2469
- /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2470
- /* @__PURE__ */ jsx9("span", { className: "font-medium text-green-800", children: message.content })
2471
- ] })
2472
- },
2473
- message.id
2474
- );
2475
- }
2476
- if (message.kind === "navigationAction") {
2477
- return /* @__PURE__ */ jsxs5("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
2478
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2479
- message.navigationTarget && /* @__PURE__ */ jsx9("div", { className: "mt-2", children: /* @__PURE__ */ jsxs5(
2480
- Button,
2481
- {
2482
- type: "button",
2483
- size: "sm",
2484
- variant: "secondary",
2485
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2486
- onClick: () => message.navigationTarget && handleConfirmNavigation(message.navigationTarget),
2487
- children: [
2488
- /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
2489
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2490
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
2491
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
2492
- ] })
2493
- ]
2494
- }
2495
- ) })
2496
- ] }, message.id);
2497
- }
2498
- if (message.kind === "actionForm") {
2499
- const actionType = message.actionType;
2500
- const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2501
- if (message.isSubmitted) {
2502
- let successContent = "";
2503
- if (actionType === "updateCompanyInfo") {
2504
- successContent = "Company information has been updated successfully.";
2505
- } else if (actionType === "addApiKey") {
2506
- successContent = "API key has been added successfully.";
2507
- } else if (actionType === "addCustomer") {
2508
- successContent = "Customer has been added successfully.";
2509
- } else if (actionType === "enable2FA") {
2510
- successContent = "Two-factor authentication has been enabled successfully.";
2511
- } else if (actionType === "disable2FA") {
2512
- successContent = "Two-factor authentication has been disabled successfully.";
2513
- } else if (actionType === "changePassword") {
2514
- successContent = "Your password has been changed successfully.";
2515
- } else if (actionType === "revokeSession") {
2516
- successContent = "Session has been revoked successfully.";
2517
- } else if (actionType === "toggleNotification") {
2518
- successContent = "Notification preferences have been updated successfully.";
2519
- } else if (actionType === "connectIntegration") {
2520
- successContent = "Integration has been connected successfully.";
2521
- } else if (actionType === "disconnectIntegration") {
2522
- successContent = "Integration has been disconnected successfully.";
2523
- } else if (actionType === "addPaymentMethod") {
2524
- successContent = "Payment method has been added successfully.";
2525
- } else if (actionType === "removePaymentMethod") {
2526
- successContent = "Payment method has been removed successfully.";
2527
- } else if (actionType === "deleteApiKey") {
2528
- successContent = "API key has been deleted successfully.";
2529
- } else if (actionType === "addWebhook") {
2530
- successContent = "Webhook endpoint has been added successfully.";
2531
- } else if (actionType === "updateCurrency") {
2532
- successContent = "Currency preference has been updated successfully.";
2533
- } else if (actionType === "updateTimezone") {
2534
- successContent = "Timezone has been updated successfully.";
2535
- } else if (actionType === "refundPayment") {
2536
- successContent = "Refund has been processed successfully.";
2537
- } else if (actionType === "exportCertificate") {
2538
- successContent = "Certificate of Incorporation has been downloaded successfully.";
2539
- } else if (actionType === "createSubscription") {
2540
- successContent = "Subscription has been created successfully.";
2541
- } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2542
- successContent = "Block rule has been updated successfully.";
2543
- } else {
2544
- successContent = "Action completed successfully.";
2545
- }
2546
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent }) }, message.id);
2547
- }
2548
- return /* @__PURE__ */ jsxs5("div", { className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`, children: [
2549
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2550
- actionType === "updateCompanyInfo" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2551
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2552
- /* @__PURE__ */ jsxs5("div", { children: [
2553
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2554
- /* @__PURE__ */ jsx9(
2555
- Input,
2556
- {
2557
- placeholder: "Acme Corporation",
2558
- value: formData.companyName || "",
2559
- onChange: (e) => setActionFormData({ ...actionFormData, companyName: e.target.value }),
2560
- className: "h-8 text-xs border-gray-200"
2561
- }
2562
- )
2563
- ] }),
2564
- /* @__PURE__ */ jsxs5("div", { children: [
2565
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2566
- /* @__PURE__ */ jsx9(
2567
- Input,
2568
- {
2569
- type: "email",
2570
- placeholder: "contact@acme.com",
2571
- value: formData.email || "",
2572
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2573
- className: "h-8 text-xs border-gray-200"
2574
- }
2575
- )
2576
- ] })
2577
- ] }),
2578
- /* @__PURE__ */ jsxs5("div", { children: [
2579
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2580
- /* @__PURE__ */ jsx9(
2581
- Input,
2582
- {
2583
- placeholder: "123 Main St, San Francisco, CA",
2584
- value: formData.address || "",
2585
- onChange: (e) => setActionFormData({ ...actionFormData, address: e.target.value }),
2586
- className: "h-8 text-xs border-gray-200"
2587
- }
2588
- )
2589
- ] }),
2590
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2591
- /* @__PURE__ */ jsxs5("div", { children: [
2592
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2593
- /* @__PURE__ */ jsx9(
2594
- Input,
2595
- {
2596
- type: "tel",
2597
- placeholder: "+1 (555) 123-4567",
2598
- value: formData.phone || "",
2599
- onChange: (e) => setActionFormData({ ...actionFormData, phone: e.target.value }),
2600
- className: "h-8 text-xs border-gray-200"
2601
- }
2602
- )
2603
- ] }),
2604
- /* @__PURE__ */ jsxs5("div", { children: [
2605
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2606
- /* @__PURE__ */ jsx9(
2607
- Input,
2608
- {
2609
- type: "url",
2610
- placeholder: "https://acme.com",
2611
- value: formData.website || "",
2612
- onChange: (e) => setActionFormData({ ...actionFormData, website: e.target.value }),
2613
- className: "h-8 text-xs border-gray-200"
2614
- }
2615
- )
2616
- ] })
2617
- ] })
2618
- ] }),
2619
- actionType === "addApiKey" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2620
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2621
- /* @__PURE__ */ jsx9(
2622
- Input,
2623
- {
2624
- placeholder: "Production Key",
2625
- value: formData.name || "",
2626
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2627
- className: "h-8 text-xs border-gray-200"
2628
- }
2629
- )
2630
- ] }) }),
2631
- actionType === "addCustomer" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2632
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2633
- /* @__PURE__ */ jsxs5("div", { children: [
2634
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2635
- /* @__PURE__ */ jsx9(
2636
- Input,
2637
- {
2638
- placeholder: "Acme Corporation",
2639
- value: formData.name || "",
2640
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2641
- className: "h-8 text-xs border-gray-200"
2642
- }
2643
- )
2644
- ] }),
2645
- /* @__PURE__ */ jsxs5("div", { children: [
2646
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2647
- /* @__PURE__ */ jsx9(
2648
- Input,
2649
- {
2650
- type: "email",
2651
- placeholder: "contact@acme.com",
2652
- value: formData.email || "",
2653
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2654
- className: "h-8 text-xs border-gray-200"
2655
- }
2656
- )
2657
- ] })
2658
- ] }),
2659
- /* @__PURE__ */ jsxs5("div", { children: [
2660
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2661
- /* @__PURE__ */ jsx9(
2662
- Input,
2663
- {
2664
- placeholder: "San Francisco, CA",
2665
- value: formData.location || "",
2666
- onChange: (e) => setActionFormData({ ...actionFormData, location: e.target.value }),
2667
- className: "h-8 text-xs border-gray-200"
2668
- }
2669
- )
2670
- ] }),
2671
- /* @__PURE__ */ jsxs5("div", { children: [
2672
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
2673
- /* @__PURE__ */ jsxs5(
2674
- "select",
2660
+ /* @__PURE__ */ jsxs5("div", { className: "pb-4 px-4", children: [
2661
+ panelView === "landing" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2662
+ /* @__PURE__ */ jsx9("div", { className: "mb-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400", children: "Suggested Questions" }),
2663
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ jsx9("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2664
+ const iconColors = [
2665
+ "bg-blue-400",
2666
+ "bg-green-400",
2667
+ "bg-purple-400",
2668
+ "bg-orange-400",
2669
+ "bg-pink-400"
2670
+ ];
2671
+ return /* @__PURE__ */ jsxs5(
2672
+ Button,
2675
2673
  {
2676
- value: formData.subscription || "Starter",
2677
- onChange: (e) => setActionFormData({ ...actionFormData, subscription: e.target.value }),
2678
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2674
+ type: "button",
2675
+ size: "sm",
2676
+ variant: "ghost",
2677
+ className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2678
+ onClick: () => sendTopic(question.prompt),
2679
2679
  children: [
2680
- /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter" }),
2681
- /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional" }),
2682
- /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise" })
2680
+ /* @__PURE__ */ jsx9(
2681
+ "span",
2682
+ {
2683
+ className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}`
2684
+ }
2685
+ ),
2686
+ question.label
2683
2687
  ]
2684
- }
2685
- )
2686
- ] })
2687
- ] }),
2688
- (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enable2FA" ? "This will enable two-factor authentication for your account. You'll need to set up an authenticator app." : "This will disable two-factor authentication for your account. Your account will be less secure." }) }),
2689
- actionType === "changePassword" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2690
- /* @__PURE__ */ jsxs5("div", { children: [
2691
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
2692
- /* @__PURE__ */ jsx9(
2693
- Input,
2694
- {
2695
- type: "password",
2696
- value: formData.currentPassword || "",
2697
- onChange: (e) => setActionFormData({ ...actionFormData, currentPassword: e.target.value }),
2698
- className: "h-8 text-xs border-gray-200"
2699
- }
2700
- )
2701
- ] }),
2702
- /* @__PURE__ */ jsxs5("div", { children: [
2703
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
2704
- /* @__PURE__ */ jsx9(
2705
- Input,
2706
- {
2707
- type: "password",
2708
- value: formData.newPassword || "",
2709
- onChange: (e) => setActionFormData({ ...actionFormData, newPassword: e.target.value }),
2710
- className: "h-8 text-xs border-gray-200"
2711
- }
2712
- )
2713
- ] }),
2714
- /* @__PURE__ */ jsxs5("div", { children: [
2715
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
2716
- /* @__PURE__ */ jsx9(
2717
- Input,
2718
- {
2719
- type: "password",
2720
- value: formData.confirmPassword || "",
2721
- onChange: (e) => setActionFormData({ ...actionFormData, confirmPassword: e.target.value }),
2722
- className: "h-8 text-xs border-gray-200"
2723
- }
2724
- )
2725
- ] })
2688
+ },
2689
+ question.id
2690
+ );
2691
+ }) })
2726
2692
  ] }),
2727
- actionType === "toggleNotification" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2728
- /* @__PURE__ */ jsxs5("div", { children: [
2729
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
2730
- /* @__PURE__ */ jsxs5(
2731
- "select",
2732
- {
2733
- value: formData.notificationType || "paymentReceived",
2734
- onChange: (e) => setActionFormData({ ...actionFormData, notificationType: e.target.value }),
2735
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2736
- children: [
2737
- /* @__PURE__ */ jsx9("option", { value: "paymentReceived", children: "Payment Received" }),
2738
- /* @__PURE__ */ jsx9("option", { value: "paymentFailed", children: "Payment Failed" }),
2739
- /* @__PURE__ */ jsx9("option", { value: "invoicePaid", children: "Invoice Paid" }),
2740
- /* @__PURE__ */ jsx9("option", { value: "monthlySummary", children: "Monthly Summary" }),
2741
- /* @__PURE__ */ jsx9("option", { value: "productUpdates", children: "Product Updates" })
2742
- ]
2743
- }
2744
- )
2745
- ] }),
2746
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
2693
+ panelView === "folder" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2694
+ /* @__PURE__ */ jsxs5("div", { className: "mb-3 flex items-center gap-2", children: [
2747
2695
  /* @__PURE__ */ jsx9(
2748
- "input",
2696
+ Button,
2749
2697
  {
2750
- type: "checkbox",
2751
- checked: formData.enabled !== false,
2752
- onChange: (e) => setActionFormData({ ...actionFormData, enabled: e.target.checked }),
2753
- className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
2698
+ type: "button",
2699
+ size: "icon",
2700
+ variant: "ghost",
2701
+ className: "h-7 w-7 rounded-full hover:bg-gray-100",
2702
+ onClick: closeFolder,
2703
+ "aria-label": "Back to suggestions",
2704
+ children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2754
2705
  }
2755
2706
  ),
2756
- /* @__PURE__ */ jsx9("label", { className: "text-xs text-black", children: "Enable this notification" })
2757
- ] })
2758
- ] }),
2759
- (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2760
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
2761
- /* @__PURE__ */ jsxs5(
2762
- "select",
2763
- {
2764
- value: formData.integrationName || "Slack",
2765
- onChange: (e) => setActionFormData({ ...actionFormData, integrationName: e.target.value }),
2766
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2767
- children: [
2768
- /* @__PURE__ */ jsx9("option", { value: "Slack", children: "Slack" }),
2769
- /* @__PURE__ */ jsx9("option", { value: "Zapier", children: "Zapier" }),
2770
- /* @__PURE__ */ jsx9("option", { value: "Webhook", children: "Webhook" })
2771
- ]
2772
- }
2773
- )
2774
- ] }) }),
2775
- actionType === "addPaymentMethod" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2776
- /* @__PURE__ */ jsxs5("div", { children: [
2777
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
2778
- /* @__PURE__ */ jsx9(
2779
- Input,
2780
- {
2781
- placeholder: "1234 5678 9012 3456",
2782
- value: formData.cardNumber || "",
2783
- onChange: (e) => setActionFormData({ ...actionFormData, cardNumber: e.target.value }),
2784
- className: "h-8 text-xs border-gray-200"
2785
- }
2786
- )
2787
- ] }),
2788
- /* @__PURE__ */ jsxs5("div", { children: [
2789
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
2790
- /* @__PURE__ */ jsx9(
2791
- Input,
2792
- {
2793
- placeholder: "MM/YY",
2794
- value: formData.expiryDate || "",
2795
- onChange: (e) => setActionFormData({ ...actionFormData, expiryDate: e.target.value }),
2796
- className: "h-8 text-xs border-gray-200"
2797
- }
2798
- )
2799
- ] })
2800
- ] }),
2801
- actionType === "removePaymentMethod" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
2802
- actionType === "refundPayment" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2803
- /* @__PURE__ */ jsxs5("div", { children: [
2804
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
2805
- /* @__PURE__ */ jsx9(
2806
- Input,
2807
- {
2808
- placeholder: "e.g., txn_1234 or Acme Corp",
2809
- value: formData.transactionId || formData.customer || "",
2810
- onChange: (e) => {
2811
- const value = e.target.value;
2812
- if (value.startsWith("txn_") || /^\d+$/.test(value)) {
2813
- setActionFormData({ ...actionFormData, transactionId: value, customer: void 0 });
2814
- } else {
2815
- setActionFormData({ ...actionFormData, customer: value, transactionId: void 0 });
2816
- }
2817
- },
2818
- className: "h-8 text-xs border-gray-200"
2819
- }
2820
- )
2821
- ] }),
2822
- /* @__PURE__ */ jsxs5("div", { children: [
2823
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
2824
- /* @__PURE__ */ jsx9(
2825
- Input,
2826
- {
2827
- placeholder: "$0.00",
2828
- value: formData.amount || "",
2829
- onChange: (e) => setActionFormData({ ...actionFormData, amount: e.target.value }),
2830
- className: "h-8 text-xs border-gray-200"
2831
- }
2832
- )
2833
- ] }),
2834
- /* @__PURE__ */ jsxs5("div", { children: [
2835
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
2836
- /* @__PURE__ */ jsx9(
2837
- Input,
2838
- {
2839
- placeholder: "e.g., Customer request",
2840
- value: formData.reason || "",
2841
- onChange: (e) => setActionFormData({ ...actionFormData, reason: e.target.value }),
2842
- className: "h-8 text-xs border-gray-200"
2843
- }
2844
- )
2845
- ] })
2846
- ] }),
2847
- actionType === "deleteApiKey" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2848
- /* @__PURE__ */ jsxs5("div", { children: [
2849
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
2850
- /* @__PURE__ */ jsx9(
2851
- Input,
2852
- {
2853
- placeholder: "Production Key",
2854
- value: formData.keyId || formData.name || "",
2855
- onChange: (e) => setActionFormData({ ...actionFormData, keyId: e.target.value, name: e.target.value }),
2856
- className: "h-8 text-xs border-gray-200"
2857
- }
2858
- )
2859
- ] }),
2860
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
2861
- ] }),
2862
- actionType === "addWebhook" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2863
- /* @__PURE__ */ jsxs5("div", { children: [
2864
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
2865
- /* @__PURE__ */ jsx9(
2866
- Input,
2867
- {
2868
- type: "url",
2869
- placeholder: "https://example.com/webhook",
2870
- value: formData.url || "",
2871
- onChange: (e) => setActionFormData({ ...actionFormData, url: e.target.value }),
2872
- className: "h-8 text-xs border-gray-200"
2873
- }
2874
- )
2707
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2875
2708
  ] }),
2876
- /* @__PURE__ */ jsxs5("div", { children: [
2877
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
2878
- /* @__PURE__ */ jsx9(
2879
- Input,
2880
- {
2881
- placeholder: "Production Webhook",
2882
- value: formData.name || "",
2883
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2884
- className: "h-8 text-xs border-gray-200"
2885
- }
2886
- )
2887
- ] })
2888
- ] }),
2889
- actionType === "updateCurrency" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2890
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
2891
- /* @__PURE__ */ jsxs5(
2892
- "select",
2709
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ jsx9(
2710
+ Button,
2893
2711
  {
2894
- value: formData.currency || "USD",
2895
- onChange: (e) => setActionFormData({ ...actionFormData, currency: e.target.value }),
2896
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2897
- children: [
2898
- /* @__PURE__ */ jsx9("option", { value: "USD", children: "USD ($)" }),
2899
- /* @__PURE__ */ jsx9("option", { value: "EUR", children: "EUR (\u20AC)" }),
2900
- /* @__PURE__ */ jsx9("option", { value: "GBP", children: "GBP (\xA3)" }),
2901
- /* @__PURE__ */ jsx9("option", { value: "JPY", children: "JPY (\xA5)" })
2902
- ]
2903
- }
2904
- )
2905
- ] }) }),
2906
- actionType === "updateTimezone" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2907
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
2908
- /* @__PURE__ */ jsxs5(
2909
- "select",
2712
+ type: "button",
2713
+ size: "sm",
2714
+ variant: "secondary",
2715
+ className: "justify-start rounded-xl border border-gray-200 bg-gray-50 px-3 py-2.5 text-xs text-gray-700 shadow-none transition-all hover:bg-gray-100 hover:border-gray-300 h-auto",
2716
+ onClick: () => sendTopic(topic.prompt),
2717
+ children: topic.label
2718
+ },
2719
+ topic.id
2720
+ )) })
2721
+ ] })
2722
+ ] })
2723
+ ] }) : /* @__PURE__ */ jsx9(Fragment2, { children: /* @__PURE__ */ jsx9("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx9(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2724
+ messages.map((message, index) => {
2725
+ const isUser = message.role === "user";
2726
+ const previousRole = index > 0 ? messages[index - 1].role : void 0;
2727
+ const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2728
+ const currentGuide = activeGuideRef.current || activeGuide;
2729
+ let isCurrentGuideStep = false;
2730
+ if (currentGuide && message.kind === "guideStep") {
2731
+ if (message.guideStepIndex !== void 0) {
2732
+ isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2733
+ } else {
2734
+ isCurrentGuideStep = index === messages.length - 1;
2735
+ }
2736
+ } else if (message.kind === "guideComplete") {
2737
+ isCurrentGuideStep = index === messages.length - 1;
2738
+ }
2739
+ if (message.kind === "guideStep" && !isCurrentGuideStep) {
2740
+ return null;
2741
+ }
2742
+ if (isUser) {
2743
+ return /* @__PURE__ */ jsx9(
2744
+ "div",
2745
+ {
2746
+ className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`,
2747
+ children: /* @__PURE__ */ jsx9("div", { className: "max-w-[280px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content })
2748
+ },
2749
+ message.id
2750
+ );
2751
+ }
2752
+ if (message.kind === "searchSummary") {
2753
+ return /* @__PURE__ */ jsx9(
2754
+ "div",
2755
+ {
2756
+ className: `${isRoleChange ? "mt-3" : ""}`,
2757
+ children: /* @__PURE__ */ jsx9(
2758
+ AssistantSearchSummary,
2759
+ {
2760
+ title: message.title ?? "Search results",
2761
+ links: message.links ?? []
2762
+ }
2763
+ )
2764
+ },
2765
+ message.id
2766
+ );
2767
+ }
2768
+ if (message.kind === "guideComplete") {
2769
+ return /* @__PURE__ */ jsx9(
2770
+ "div",
2771
+ {
2772
+ ref: isCurrentGuideStep ? currentStepRef : null,
2773
+ className: `${isRoleChange ? "mt-3" : ""}`,
2774
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-sm leading-6", children: [
2775
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2776
+ /* @__PURE__ */ jsx9("span", { className: "font-medium text-green-800", children: message.content })
2777
+ ] })
2778
+ },
2779
+ message.id
2780
+ );
2781
+ }
2782
+ if (message.kind === "navigationAction") {
2783
+ return /* @__PURE__ */ jsxs5(
2784
+ "div",
2910
2785
  {
2911
- value: formData.timezone || "America/Los_Angeles",
2912
- onChange: (e) => setActionFormData({ ...actionFormData, timezone: e.target.value }),
2913
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2786
+ className: `${isRoleChange ? "mt-3" : ""}`,
2914
2787
  children: [
2915
- /* @__PURE__ */ jsx9("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
2916
- /* @__PURE__ */ jsx9("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
2917
- /* @__PURE__ */ jsx9("option", { value: "Europe/London", children: "GMT" }),
2918
- /* @__PURE__ */ jsx9("option", { value: "Asia/Tokyo", children: "JST" })
2788
+ /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2789
+ message.navigationTarget && /* @__PURE__ */ jsx9("div", { className: "mt-2", children: /* @__PURE__ */ jsxs5(
2790
+ Button,
2791
+ {
2792
+ type: "button",
2793
+ size: "sm",
2794
+ variant: "secondary",
2795
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2796
+ onClick: () => message.navigationTarget && handleConfirmNavigation(
2797
+ message.navigationTarget
2798
+ ),
2799
+ children: [
2800
+ /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
2801
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2802
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
2803
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
2804
+ ] })
2805
+ ]
2806
+ }
2807
+ ) })
2919
2808
  ]
2809
+ },
2810
+ message.id
2811
+ );
2812
+ }
2813
+ if (message.kind === "actionForm") {
2814
+ const actionType = message.actionType;
2815
+ const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2816
+ if (message.isSubmitted) {
2817
+ let successContent = "";
2818
+ if (actionType === "updateCompanyInfo") {
2819
+ successContent = "Company information has been updated successfully.";
2820
+ } else if (actionType === "addApiKey") {
2821
+ successContent = "API key has been added successfully.";
2822
+ } else if (actionType === "addCustomer") {
2823
+ successContent = "Customer has been added successfully.";
2824
+ } else if (actionType === "enable2FA") {
2825
+ successContent = "Two-factor authentication has been enabled successfully.";
2826
+ } else if (actionType === "disable2FA") {
2827
+ successContent = "Two-factor authentication has been disabled successfully.";
2828
+ } else if (actionType === "changePassword") {
2829
+ successContent = "Your password has been changed successfully.";
2830
+ } else if (actionType === "revokeSession") {
2831
+ successContent = "Session has been revoked successfully.";
2832
+ } else if (actionType === "toggleNotification") {
2833
+ successContent = "Notification preferences have been updated successfully.";
2834
+ } else if (actionType === "connectIntegration") {
2835
+ successContent = "Integration has been connected successfully.";
2836
+ } else if (actionType === "disconnectIntegration") {
2837
+ successContent = "Integration has been disconnected successfully.";
2838
+ } else if (actionType === "addPaymentMethod") {
2839
+ successContent = "Payment method has been added successfully.";
2840
+ } else if (actionType === "removePaymentMethod") {
2841
+ successContent = "Payment method has been removed successfully.";
2842
+ } else if (actionType === "deleteApiKey") {
2843
+ successContent = "API key has been deleted successfully.";
2844
+ } else if (actionType === "addWebhook") {
2845
+ successContent = "Webhook endpoint has been added successfully.";
2846
+ } else if (actionType === "updateCurrency") {
2847
+ successContent = "Currency preference has been updated successfully.";
2848
+ } else if (actionType === "updateTimezone") {
2849
+ successContent = "Timezone has been updated successfully.";
2850
+ } else if (actionType === "refundPayment") {
2851
+ successContent = "Refund has been processed successfully.";
2852
+ } else if (actionType === "exportCertificate") {
2853
+ successContent = "Certificate of Incorporation has been downloaded successfully.";
2854
+ } else if (actionType === "createSubscription") {
2855
+ successContent = "Subscription has been created successfully.";
2856
+ } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2857
+ successContent = "Block rule has been updated successfully.";
2858
+ } else {
2859
+ successContent = "Action completed successfully.";
2920
2860
  }
2921
- )
2922
- ] }) }),
2923
- actionType === "revokeSession" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2924
- /* @__PURE__ */ jsxs5("div", { children: [
2925
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
2926
- /* @__PURE__ */ jsx9(
2927
- Input,
2928
- {
2929
- placeholder: "MacBook Pro",
2930
- value: formData.device || "",
2931
- onChange: (e) => setActionFormData({ ...actionFormData, device: e.target.value }),
2932
- className: "h-8 text-xs border-gray-200"
2933
- }
2934
- )
2935
- ] }),
2936
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
2937
- ] }),
2938
- actionType === "createSubscription" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2939
- /* @__PURE__ */ jsxs5("div", { children: [
2940
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
2941
- /* @__PURE__ */ jsx9(
2942
- Input,
2943
- {
2944
- type: "email",
2945
- placeholder: "customer@example.com",
2946
- value: formData.customerEmail || "",
2947
- onChange: (e) => setActionFormData({ ...actionFormData, customerEmail: e.target.value }),
2948
- className: "h-8 text-xs border-gray-200"
2949
- }
2950
- )
2951
- ] }),
2952
- /* @__PURE__ */ jsxs5("div", { children: [
2953
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
2954
- /* @__PURE__ */ jsxs5(
2955
- "select",
2956
- {
2957
- value: formData.plan || "Starter",
2958
- onChange: (e) => setActionFormData({ ...actionFormData, plan: e.target.value }),
2959
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2960
- children: [
2961
- /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter ($29/mo)" }),
2962
- /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional ($99/mo)" }),
2963
- /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
2964
- ]
2965
- }
2966
- )
2967
- ] }),
2968
- /* @__PURE__ */ jsxs5("div", { children: [
2969
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
2970
- /* @__PURE__ */ jsxs5(
2971
- "select",
2972
- {
2973
- value: formData.billingCycle || "monthly",
2974
- onChange: (e) => setActionFormData({ ...actionFormData, billingCycle: e.target.value }),
2975
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2976
- children: [
2977
- /* @__PURE__ */ jsx9("option", { value: "monthly", children: "Monthly" }),
2978
- /* @__PURE__ */ jsx9("option", { value: "yearly", children: "Yearly (Save 15%)" })
2979
- ]
2980
- }
2981
- )
2982
- ] })
2983
- ] }),
2984
- actionType === "exportCertificate" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2985
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
2986
- /* @__PURE__ */ jsxs5("div", { children: [
2987
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
2988
- /* @__PURE__ */ jsxs5(
2989
- "select",
2990
- {
2991
- value: formData.format || "pdf",
2992
- onChange: (e) => setActionFormData({ ...actionFormData, format: e.target.value }),
2993
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
2994
- children: [
2995
- /* @__PURE__ */ jsx9("option", { value: "pdf", children: "PDF" }),
2996
- /* @__PURE__ */ jsx9("option", { value: "json", children: "JSON" })
2997
- ]
2998
- }
2999
- )
3000
- ] })
3001
- ] }),
3002
- (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3003
- /* @__PURE__ */ jsxs5("div", { children: [
3004
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3005
- /* @__PURE__ */ jsxs5(
3006
- "select",
2861
+ return /* @__PURE__ */ jsx9(
2862
+ "div",
3007
2863
  {
3008
- value: formData.ruleId || "rule_1",
3009
- onChange: (e) => setActionFormData({ ...actionFormData, ruleId: e.target.value }),
3010
- className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3011
- children: [
3012
- /* @__PURE__ */ jsx9("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3013
- /* @__PURE__ */ jsx9("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3014
- /* @__PURE__ */ jsx9("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3015
- /* @__PURE__ */ jsx9("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3016
- ]
3017
- }
3018
- )
3019
- ] }),
3020
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enableBlockRule" ? "This will enable the selected block rule to actively block matching payments." : actionType === "disableBlockRule" ? "This will disable the selected block rule. Matching payments will no longer be blocked." : "This will toggle the selected block rule's state." })
3021
- ] }),
3022
- /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsxs5(
3023
- Button,
3024
- {
3025
- type: "button",
3026
- size: "sm",
3027
- variant: "secondary",
3028
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3029
- onClick: handleActionSubmit,
3030
- children: [
3031
- /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
3032
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3033
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3034
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3035
- ] })
3036
- ]
2864
+ className: `${isRoleChange ? "mt-3" : ""}`,
2865
+ children: /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent })
2866
+ },
2867
+ message.id
2868
+ );
3037
2869
  }
3038
- ) })
3039
- ] }, message.id);
3040
- }
3041
- if (message.kind === "bulkPreview" && message.csvData) {
3042
- return /* @__PURE__ */ jsxs5("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
3043
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3044
- /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3045
- /* @__PURE__ */ jsxs5("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3046
- /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3047
- /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3048
- /* @__PURE__ */ jsxs5("span", { className: "text-xs text-gray-500", children: [
3049
- "\u2022 ",
3050
- message.csvData.rowCount,
3051
- " rows"
3052
- ] })
3053
- ] }),
3054
- /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3055
- /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3056
- /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ jsx9("span", { className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded", children: col }, i)) })
3057
- ] }),
3058
- message.csvData.sampleRows.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2", children: [
3059
- /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3060
- /* @__PURE__ */ jsx9("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ jsxs5("div", { className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100", children: [
3061
- Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ jsxs5("span", { children: [
3062
- j > 0 && " \u2022 ",
3063
- /* @__PURE__ */ jsxs5("span", { className: "text-gray-400", children: [
3064
- key,
3065
- ":"
2870
+ return /* @__PURE__ */ jsxs5(
2871
+ "div",
2872
+ {
2873
+ className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`,
2874
+ children: [
2875
+ /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2876
+ actionType === "updateCompanyInfo" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2877
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2878
+ /* @__PURE__ */ jsxs5("div", { children: [
2879
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2880
+ /* @__PURE__ */ jsx9(
2881
+ Input,
2882
+ {
2883
+ placeholder: "Acme Corporation",
2884
+ value: formData.companyName || "",
2885
+ onChange: (e) => setActionFormData({
2886
+ ...actionFormData,
2887
+ companyName: e.target.value
2888
+ }),
2889
+ className: "h-8 text-xs border-gray-200"
2890
+ }
2891
+ )
2892
+ ] }),
2893
+ /* @__PURE__ */ jsxs5("div", { children: [
2894
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2895
+ /* @__PURE__ */ jsx9(
2896
+ Input,
2897
+ {
2898
+ type: "email",
2899
+ placeholder: "contact@acme.com",
2900
+ value: formData.email || "",
2901
+ onChange: (e) => setActionFormData({
2902
+ ...actionFormData,
2903
+ email: e.target.value
2904
+ }),
2905
+ className: "h-8 text-xs border-gray-200"
2906
+ }
2907
+ )
2908
+ ] })
2909
+ ] }),
2910
+ /* @__PURE__ */ jsxs5("div", { children: [
2911
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2912
+ /* @__PURE__ */ jsx9(
2913
+ Input,
2914
+ {
2915
+ placeholder: "123 Main St, San Francisco, CA",
2916
+ value: formData.address || "",
2917
+ onChange: (e) => setActionFormData({
2918
+ ...actionFormData,
2919
+ address: e.target.value
2920
+ }),
2921
+ className: "h-8 text-xs border-gray-200"
2922
+ }
2923
+ )
2924
+ ] }),
2925
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2926
+ /* @__PURE__ */ jsxs5("div", { children: [
2927
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2928
+ /* @__PURE__ */ jsx9(
2929
+ Input,
2930
+ {
2931
+ type: "tel",
2932
+ placeholder: "+1 (555) 123-4567",
2933
+ value: formData.phone || "",
2934
+ onChange: (e) => setActionFormData({
2935
+ ...actionFormData,
2936
+ phone: e.target.value
2937
+ }),
2938
+ className: "h-8 text-xs border-gray-200"
2939
+ }
2940
+ )
2941
+ ] }),
2942
+ /* @__PURE__ */ jsxs5("div", { children: [
2943
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2944
+ /* @__PURE__ */ jsx9(
2945
+ Input,
2946
+ {
2947
+ type: "url",
2948
+ placeholder: "https://acme.com",
2949
+ value: formData.website || "",
2950
+ onChange: (e) => setActionFormData({
2951
+ ...actionFormData,
2952
+ website: e.target.value
2953
+ }),
2954
+ className: "h-8 text-xs border-gray-200"
2955
+ }
2956
+ )
2957
+ ] })
2958
+ ] })
3066
2959
  ] }),
3067
- " ",
3068
- val
3069
- ] }, key)),
3070
- Object.keys(row).length > 3 && /* @__PURE__ */ jsx9("span", { className: "text-gray-400", children: " ..." })
3071
- ] }, i)) })
3072
- ] }),
3073
- message.suggestedAction && /* @__PURE__ */ jsx9("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ jsxs5("span", { className: "text-xs text-blue-700", children: [
3074
- "Suggested action: ",
3075
- /* @__PURE__ */ jsx9("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3076
- ] }) })
3077
- ] }),
3078
- message.bulkSessionId && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3079
- /* @__PURE__ */ jsxs5(
3080
- Button,
2960
+ actionType === "addApiKey" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2961
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2962
+ /* @__PURE__ */ jsx9(
2963
+ Input,
2964
+ {
2965
+ placeholder: "Production Key",
2966
+ value: formData.name || "",
2967
+ onChange: (e) => setActionFormData({
2968
+ ...actionFormData,
2969
+ name: e.target.value
2970
+ }),
2971
+ className: "h-8 text-xs border-gray-200"
2972
+ }
2973
+ )
2974
+ ] }) }),
2975
+ actionType === "addCustomer" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2976
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2977
+ /* @__PURE__ */ jsxs5("div", { children: [
2978
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2979
+ /* @__PURE__ */ jsx9(
2980
+ Input,
2981
+ {
2982
+ placeholder: "Acme Corporation",
2983
+ value: formData.name || "",
2984
+ onChange: (e) => setActionFormData({
2985
+ ...actionFormData,
2986
+ name: e.target.value
2987
+ }),
2988
+ className: "h-8 text-xs border-gray-200"
2989
+ }
2990
+ )
2991
+ ] }),
2992
+ /* @__PURE__ */ jsxs5("div", { children: [
2993
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2994
+ /* @__PURE__ */ jsx9(
2995
+ Input,
2996
+ {
2997
+ type: "email",
2998
+ placeholder: "contact@acme.com",
2999
+ value: formData.email || "",
3000
+ onChange: (e) => setActionFormData({
3001
+ ...actionFormData,
3002
+ email: e.target.value
3003
+ }),
3004
+ className: "h-8 text-xs border-gray-200"
3005
+ }
3006
+ )
3007
+ ] })
3008
+ ] }),
3009
+ /* @__PURE__ */ jsxs5("div", { children: [
3010
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
3011
+ /* @__PURE__ */ jsx9(
3012
+ Input,
3013
+ {
3014
+ placeholder: "San Francisco, CA",
3015
+ value: formData.location || "",
3016
+ onChange: (e) => setActionFormData({
3017
+ ...actionFormData,
3018
+ location: e.target.value
3019
+ }),
3020
+ className: "h-8 text-xs border-gray-200"
3021
+ }
3022
+ )
3023
+ ] }),
3024
+ /* @__PURE__ */ jsxs5("div", { children: [
3025
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
3026
+ /* @__PURE__ */ jsxs5(
3027
+ "select",
3028
+ {
3029
+ value: formData.subscription || "Starter",
3030
+ onChange: (e) => setActionFormData({
3031
+ ...actionFormData,
3032
+ subscription: e.target.value
3033
+ }),
3034
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3035
+ children: [
3036
+ /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter" }),
3037
+ /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional" }),
3038
+ /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise" })
3039
+ ]
3040
+ }
3041
+ )
3042
+ ] })
3043
+ ] }),
3044
+ (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enable2FA" ? "This will enable two-factor authentication for your account. You'll need to set up an authenticator app." : "This will disable two-factor authentication for your account. Your account will be less secure." }) }),
3045
+ actionType === "changePassword" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3046
+ /* @__PURE__ */ jsxs5("div", { children: [
3047
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
3048
+ /* @__PURE__ */ jsx9(
3049
+ Input,
3050
+ {
3051
+ type: "password",
3052
+ value: formData.currentPassword || "",
3053
+ onChange: (e) => setActionFormData({
3054
+ ...actionFormData,
3055
+ currentPassword: e.target.value
3056
+ }),
3057
+ className: "h-8 text-xs border-gray-200"
3058
+ }
3059
+ )
3060
+ ] }),
3061
+ /* @__PURE__ */ jsxs5("div", { children: [
3062
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
3063
+ /* @__PURE__ */ jsx9(
3064
+ Input,
3065
+ {
3066
+ type: "password",
3067
+ value: formData.newPassword || "",
3068
+ onChange: (e) => setActionFormData({
3069
+ ...actionFormData,
3070
+ newPassword: e.target.value
3071
+ }),
3072
+ className: "h-8 text-xs border-gray-200"
3073
+ }
3074
+ )
3075
+ ] }),
3076
+ /* @__PURE__ */ jsxs5("div", { children: [
3077
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
3078
+ /* @__PURE__ */ jsx9(
3079
+ Input,
3080
+ {
3081
+ type: "password",
3082
+ value: formData.confirmPassword || "",
3083
+ onChange: (e) => setActionFormData({
3084
+ ...actionFormData,
3085
+ confirmPassword: e.target.value
3086
+ }),
3087
+ className: "h-8 text-xs border-gray-200"
3088
+ }
3089
+ )
3090
+ ] })
3091
+ ] }),
3092
+ actionType === "toggleNotification" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3093
+ /* @__PURE__ */ jsxs5("div", { children: [
3094
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
3095
+ /* @__PURE__ */ jsxs5(
3096
+ "select",
3097
+ {
3098
+ value: formData.notificationType || "paymentReceived",
3099
+ onChange: (e) => setActionFormData({
3100
+ ...actionFormData,
3101
+ notificationType: e.target.value
3102
+ }),
3103
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3104
+ children: [
3105
+ /* @__PURE__ */ jsx9("option", { value: "paymentReceived", children: "Payment Received" }),
3106
+ /* @__PURE__ */ jsx9("option", { value: "paymentFailed", children: "Payment Failed" }),
3107
+ /* @__PURE__ */ jsx9("option", { value: "invoicePaid", children: "Invoice Paid" }),
3108
+ /* @__PURE__ */ jsx9("option", { value: "monthlySummary", children: "Monthly Summary" }),
3109
+ /* @__PURE__ */ jsx9("option", { value: "productUpdates", children: "Product Updates" })
3110
+ ]
3111
+ }
3112
+ )
3113
+ ] }),
3114
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
3115
+ /* @__PURE__ */ jsx9(
3116
+ "input",
3117
+ {
3118
+ type: "checkbox",
3119
+ checked: formData.enabled !== false,
3120
+ onChange: (e) => setActionFormData({
3121
+ ...actionFormData,
3122
+ enabled: e.target.checked
3123
+ }),
3124
+ className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
3125
+ }
3126
+ ),
3127
+ /* @__PURE__ */ jsx9("label", { className: "text-xs text-black", children: "Enable this notification" })
3128
+ ] })
3129
+ ] }),
3130
+ (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
3131
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
3132
+ /* @__PURE__ */ jsxs5(
3133
+ "select",
3134
+ {
3135
+ value: formData.integrationName || "Slack",
3136
+ onChange: (e) => setActionFormData({
3137
+ ...actionFormData,
3138
+ integrationName: e.target.value
3139
+ }),
3140
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3141
+ children: [
3142
+ /* @__PURE__ */ jsx9("option", { value: "Slack", children: "Slack" }),
3143
+ /* @__PURE__ */ jsx9("option", { value: "Zapier", children: "Zapier" }),
3144
+ /* @__PURE__ */ jsx9("option", { value: "Webhook", children: "Webhook" })
3145
+ ]
3146
+ }
3147
+ )
3148
+ ] }) }),
3149
+ actionType === "addPaymentMethod" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3150
+ /* @__PURE__ */ jsxs5("div", { children: [
3151
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
3152
+ /* @__PURE__ */ jsx9(
3153
+ Input,
3154
+ {
3155
+ placeholder: "1234 5678 9012 3456",
3156
+ value: formData.cardNumber || "",
3157
+ onChange: (e) => setActionFormData({
3158
+ ...actionFormData,
3159
+ cardNumber: e.target.value
3160
+ }),
3161
+ className: "h-8 text-xs border-gray-200"
3162
+ }
3163
+ )
3164
+ ] }),
3165
+ /* @__PURE__ */ jsxs5("div", { children: [
3166
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
3167
+ /* @__PURE__ */ jsx9(
3168
+ Input,
3169
+ {
3170
+ placeholder: "MM/YY",
3171
+ value: formData.expiryDate || "",
3172
+ onChange: (e) => setActionFormData({
3173
+ ...actionFormData,
3174
+ expiryDate: e.target.value
3175
+ }),
3176
+ className: "h-8 text-xs border-gray-200"
3177
+ }
3178
+ )
3179
+ ] })
3180
+ ] }),
3181
+ actionType === "removePaymentMethod" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
3182
+ actionType === "refundPayment" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3183
+ /* @__PURE__ */ jsxs5("div", { children: [
3184
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
3185
+ /* @__PURE__ */ jsx9(
3186
+ Input,
3187
+ {
3188
+ placeholder: "e.g., txn_1234 or Acme Corp",
3189
+ value: formData.transactionId || formData.customer || "",
3190
+ onChange: (e) => {
3191
+ const value = e.target.value;
3192
+ if (value.startsWith("txn_") || /^\d+$/.test(value)) {
3193
+ setActionFormData({
3194
+ ...actionFormData,
3195
+ transactionId: value,
3196
+ customer: void 0
3197
+ });
3198
+ } else {
3199
+ setActionFormData({
3200
+ ...actionFormData,
3201
+ customer: value,
3202
+ transactionId: void 0
3203
+ });
3204
+ }
3205
+ },
3206
+ className: "h-8 text-xs border-gray-200"
3207
+ }
3208
+ )
3209
+ ] }),
3210
+ /* @__PURE__ */ jsxs5("div", { children: [
3211
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
3212
+ /* @__PURE__ */ jsx9(
3213
+ Input,
3214
+ {
3215
+ placeholder: "$0.00",
3216
+ value: formData.amount || "",
3217
+ onChange: (e) => setActionFormData({
3218
+ ...actionFormData,
3219
+ amount: e.target.value
3220
+ }),
3221
+ className: "h-8 text-xs border-gray-200"
3222
+ }
3223
+ )
3224
+ ] }),
3225
+ /* @__PURE__ */ jsxs5("div", { children: [
3226
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
3227
+ /* @__PURE__ */ jsx9(
3228
+ Input,
3229
+ {
3230
+ placeholder: "e.g., Customer request",
3231
+ value: formData.reason || "",
3232
+ onChange: (e) => setActionFormData({
3233
+ ...actionFormData,
3234
+ reason: e.target.value
3235
+ }),
3236
+ className: "h-8 text-xs border-gray-200"
3237
+ }
3238
+ )
3239
+ ] })
3240
+ ] }),
3241
+ actionType === "deleteApiKey" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3242
+ /* @__PURE__ */ jsxs5("div", { children: [
3243
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
3244
+ /* @__PURE__ */ jsx9(
3245
+ Input,
3246
+ {
3247
+ placeholder: "Production Key",
3248
+ value: formData.keyId || formData.name || "",
3249
+ onChange: (e) => setActionFormData({
3250
+ ...actionFormData,
3251
+ keyId: e.target.value,
3252
+ name: e.target.value
3253
+ }),
3254
+ className: "h-8 text-xs border-gray-200"
3255
+ }
3256
+ )
3257
+ ] }),
3258
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
3259
+ ] }),
3260
+ actionType === "addWebhook" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3261
+ /* @__PURE__ */ jsxs5("div", { children: [
3262
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
3263
+ /* @__PURE__ */ jsx9(
3264
+ Input,
3265
+ {
3266
+ type: "url",
3267
+ placeholder: "https://example.com/webhook",
3268
+ value: formData.url || "",
3269
+ onChange: (e) => setActionFormData({
3270
+ ...actionFormData,
3271
+ url: e.target.value
3272
+ }),
3273
+ className: "h-8 text-xs border-gray-200"
3274
+ }
3275
+ )
3276
+ ] }),
3277
+ /* @__PURE__ */ jsxs5("div", { children: [
3278
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
3279
+ /* @__PURE__ */ jsx9(
3280
+ Input,
3281
+ {
3282
+ placeholder: "Production Webhook",
3283
+ value: formData.name || "",
3284
+ onChange: (e) => setActionFormData({
3285
+ ...actionFormData,
3286
+ name: e.target.value
3287
+ }),
3288
+ className: "h-8 text-xs border-gray-200"
3289
+ }
3290
+ )
3291
+ ] })
3292
+ ] }),
3293
+ actionType === "updateCurrency" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
3294
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
3295
+ /* @__PURE__ */ jsxs5(
3296
+ "select",
3297
+ {
3298
+ value: formData.currency || "USD",
3299
+ onChange: (e) => setActionFormData({
3300
+ ...actionFormData,
3301
+ currency: e.target.value
3302
+ }),
3303
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3304
+ children: [
3305
+ /* @__PURE__ */ jsx9("option", { value: "USD", children: "USD ($)" }),
3306
+ /* @__PURE__ */ jsx9("option", { value: "EUR", children: "EUR (\u20AC)" }),
3307
+ /* @__PURE__ */ jsx9("option", { value: "GBP", children: "GBP (\xA3)" }),
3308
+ /* @__PURE__ */ jsx9("option", { value: "JPY", children: "JPY (\xA5)" })
3309
+ ]
3310
+ }
3311
+ )
3312
+ ] }) }),
3313
+ actionType === "updateTimezone" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
3314
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
3315
+ /* @__PURE__ */ jsxs5(
3316
+ "select",
3317
+ {
3318
+ value: formData.timezone || "America/Los_Angeles",
3319
+ onChange: (e) => setActionFormData({
3320
+ ...actionFormData,
3321
+ timezone: e.target.value
3322
+ }),
3323
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3324
+ children: [
3325
+ /* @__PURE__ */ jsx9("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
3326
+ /* @__PURE__ */ jsx9("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
3327
+ /* @__PURE__ */ jsx9("option", { value: "Europe/London", children: "GMT" }),
3328
+ /* @__PURE__ */ jsx9("option", { value: "Asia/Tokyo", children: "JST" })
3329
+ ]
3330
+ }
3331
+ )
3332
+ ] }) }),
3333
+ actionType === "revokeSession" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3334
+ /* @__PURE__ */ jsxs5("div", { children: [
3335
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
3336
+ /* @__PURE__ */ jsx9(
3337
+ Input,
3338
+ {
3339
+ placeholder: "MacBook Pro",
3340
+ value: formData.device || "",
3341
+ onChange: (e) => setActionFormData({
3342
+ ...actionFormData,
3343
+ device: e.target.value
3344
+ }),
3345
+ className: "h-8 text-xs border-gray-200"
3346
+ }
3347
+ )
3348
+ ] }),
3349
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
3350
+ ] }),
3351
+ actionType === "createSubscription" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3352
+ /* @__PURE__ */ jsxs5("div", { children: [
3353
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
3354
+ /* @__PURE__ */ jsx9(
3355
+ Input,
3356
+ {
3357
+ type: "email",
3358
+ placeholder: "customer@example.com",
3359
+ value: formData.customerEmail || "",
3360
+ onChange: (e) => setActionFormData({
3361
+ ...actionFormData,
3362
+ customerEmail: e.target.value
3363
+ }),
3364
+ className: "h-8 text-xs border-gray-200"
3365
+ }
3366
+ )
3367
+ ] }),
3368
+ /* @__PURE__ */ jsxs5("div", { children: [
3369
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
3370
+ /* @__PURE__ */ jsxs5(
3371
+ "select",
3372
+ {
3373
+ value: formData.plan || "Starter",
3374
+ onChange: (e) => setActionFormData({
3375
+ ...actionFormData,
3376
+ plan: e.target.value
3377
+ }),
3378
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3379
+ children: [
3380
+ /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter ($29/mo)" }),
3381
+ /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional ($99/mo)" }),
3382
+ /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
3383
+ ]
3384
+ }
3385
+ )
3386
+ ] }),
3387
+ /* @__PURE__ */ jsxs5("div", { children: [
3388
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
3389
+ /* @__PURE__ */ jsxs5(
3390
+ "select",
3391
+ {
3392
+ value: formData.billingCycle || "monthly",
3393
+ onChange: (e) => setActionFormData({
3394
+ ...actionFormData,
3395
+ billingCycle: e.target.value
3396
+ }),
3397
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3398
+ children: [
3399
+ /* @__PURE__ */ jsx9("option", { value: "monthly", children: "Monthly" }),
3400
+ /* @__PURE__ */ jsx9("option", { value: "yearly", children: "Yearly (Save 15%)" })
3401
+ ]
3402
+ }
3403
+ )
3404
+ ] })
3405
+ ] }),
3406
+ actionType === "exportCertificate" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3407
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
3408
+ /* @__PURE__ */ jsxs5("div", { children: [
3409
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
3410
+ /* @__PURE__ */ jsxs5(
3411
+ "select",
3412
+ {
3413
+ value: formData.format || "pdf",
3414
+ onChange: (e) => setActionFormData({
3415
+ ...actionFormData,
3416
+ format: e.target.value
3417
+ }),
3418
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3419
+ children: [
3420
+ /* @__PURE__ */ jsx9("option", { value: "pdf", children: "PDF" }),
3421
+ /* @__PURE__ */ jsx9("option", { value: "json", children: "JSON" })
3422
+ ]
3423
+ }
3424
+ )
3425
+ ] })
3426
+ ] }),
3427
+ (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3428
+ /* @__PURE__ */ jsxs5("div", { children: [
3429
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3430
+ /* @__PURE__ */ jsxs5(
3431
+ "select",
3432
+ {
3433
+ value: formData.ruleId || "rule_1",
3434
+ onChange: (e) => setActionFormData({
3435
+ ...actionFormData,
3436
+ ruleId: e.target.value
3437
+ }),
3438
+ className: "h-8 w-full rounded-md border border-gray-200 bg-transparent px-3 py-1 text-xs shadow-xs transition-colors focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none",
3439
+ children: [
3440
+ /* @__PURE__ */ jsx9("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3441
+ /* @__PURE__ */ jsx9("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3442
+ /* @__PURE__ */ jsx9("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3443
+ /* @__PURE__ */ jsx9("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3444
+ ]
3445
+ }
3446
+ )
3447
+ ] }),
3448
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enableBlockRule" ? "This will enable the selected block rule to actively block matching payments." : actionType === "disableBlockRule" ? "This will disable the selected block rule. Matching payments will no longer be blocked." : "This will toggle the selected block rule's state." })
3449
+ ] }),
3450
+ /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsxs5(
3451
+ Button,
3452
+ {
3453
+ type: "button",
3454
+ size: "sm",
3455
+ variant: "secondary",
3456
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3457
+ onClick: handleActionSubmit,
3458
+ children: [
3459
+ /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
3460
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3461
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3462
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3463
+ ] })
3464
+ ]
3465
+ }
3466
+ ) })
3467
+ ]
3468
+ },
3469
+ message.id
3470
+ );
3471
+ }
3472
+ if (message.kind === "bulkPreview" && message.csvData) {
3473
+ return /* @__PURE__ */ jsxs5(
3474
+ "div",
3081
3475
  {
3082
- type: "button",
3083
- size: "sm",
3084
- variant: "secondary",
3085
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3086
- onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3476
+ className: `${isRoleChange ? "mt-3" : ""}`,
3087
3477
  children: [
3088
- /* @__PURE__ */ jsxs5("span", { children: [
3089
- "Process ",
3090
- message.csvData.rowCount,
3091
- " rows"
3478
+ /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3479
+ /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3480
+ /* @__PURE__ */ jsxs5("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3481
+ /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3482
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3483
+ /* @__PURE__ */ jsxs5("span", { className: "text-xs text-gray-500", children: [
3484
+ "\u2022 ",
3485
+ message.csvData.rowCount,
3486
+ " rows"
3487
+ ] })
3488
+ ] }),
3489
+ /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3490
+ /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3491
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ jsx9(
3492
+ "span",
3493
+ {
3494
+ className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded",
3495
+ children: col
3496
+ },
3497
+ i
3498
+ )) })
3499
+ ] }),
3500
+ message.csvData.sampleRows.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2", children: [
3501
+ /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3502
+ /* @__PURE__ */ jsx9("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ jsxs5(
3503
+ "div",
3504
+ {
3505
+ className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100",
3506
+ children: [
3507
+ Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ jsxs5("span", { children: [
3508
+ j > 0 && " \u2022 ",
3509
+ /* @__PURE__ */ jsxs5("span", { className: "text-gray-400", children: [
3510
+ key,
3511
+ ":"
3512
+ ] }),
3513
+ " ",
3514
+ val
3515
+ ] }, key)),
3516
+ Object.keys(row).length > 3 && /* @__PURE__ */ jsxs5("span", { className: "text-gray-400", children: [
3517
+ " ",
3518
+ "..."
3519
+ ] })
3520
+ ]
3521
+ },
3522
+ i
3523
+ )) })
3524
+ ] }),
3525
+ message.suggestedAction && /* @__PURE__ */ jsx9("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ jsxs5("span", { className: "text-xs text-blue-700", children: [
3526
+ "Suggested action:",
3527
+ " ",
3528
+ /* @__PURE__ */ jsx9("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3529
+ ] }) })
3092
3530
  ] }),
3093
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3094
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3095
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3531
+ message.bulkSessionId && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3532
+ /* @__PURE__ */ jsxs5(
3533
+ Button,
3534
+ {
3535
+ type: "button",
3536
+ size: "sm",
3537
+ variant: "secondary",
3538
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3539
+ onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3540
+ children: [
3541
+ /* @__PURE__ */ jsxs5("span", { children: [
3542
+ "Process ",
3543
+ message.csvData.rowCount,
3544
+ " rows"
3545
+ ] }),
3546
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3547
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3548
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3549
+ ] })
3550
+ ]
3551
+ }
3552
+ ),
3553
+ /* @__PURE__ */ jsx9(
3554
+ Button,
3555
+ {
3556
+ type: "button",
3557
+ size: "sm",
3558
+ variant: "ghost",
3559
+ className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3560
+ onClick: cancelBulkOperation,
3561
+ children: "Cancel"
3562
+ }
3563
+ )
3096
3564
  ] })
3097
3565
  ]
3098
- }
3099
- ),
3100
- /* @__PURE__ */ jsx9(
3101
- Button,
3566
+ },
3567
+ message.id
3568
+ );
3569
+ }
3570
+ if (message.kind === "bulkProgress" && message.bulkProgress) {
3571
+ const { processed, total, successes, failures } = message.bulkProgress;
3572
+ const percentage = Math.round(processed / total * 100);
3573
+ return /* @__PURE__ */ jsx9(
3574
+ "div",
3102
3575
  {
3103
- type: "button",
3104
- size: "sm",
3105
- variant: "ghost",
3106
- className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3107
- onClick: cancelBulkOperation,
3108
- children: "Cancel"
3109
- }
3110
- )
3111
- ] })
3112
- ] }, message.id);
3113
- }
3114
- if (message.kind === "bulkProgress" && message.bulkProgress) {
3115
- const { processed, total, successes, failures } = message.bulkProgress;
3116
- const percentage = Math.round(processed / total * 100);
3117
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3118
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3119
- /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-blue-600" }),
3120
- /* @__PURE__ */ jsxs5("span", { className: "text-sm font-medium text-gray-700", children: [
3121
- "Processing... ",
3122
- processed,
3123
- " of ",
3124
- total
3125
- ] })
3126
- ] }),
3127
- /* @__PURE__ */ jsx9("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ jsx9(
3576
+ className: `${isRoleChange ? "mt-3" : ""}`,
3577
+ children: /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3578
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3579
+ /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-blue-600" }),
3580
+ /* @__PURE__ */ jsxs5("span", { className: "text-sm font-medium text-gray-700", children: [
3581
+ "Processing... ",
3582
+ processed,
3583
+ " of ",
3584
+ total
3585
+ ] })
3586
+ ] }),
3587
+ /* @__PURE__ */ jsx9("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ jsx9(
3588
+ "div",
3589
+ {
3590
+ className: "h-full bg-blue-600 transition-all duration-300",
3591
+ style: { width: `${percentage}%` }
3592
+ }
3593
+ ) }),
3594
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3595
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1", children: [
3596
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3 text-green-600" }),
3597
+ successes,
3598
+ " successful"
3599
+ ] }),
3600
+ failures > 0 && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3601
+ /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3602
+ failures,
3603
+ " failed"
3604
+ ] })
3605
+ ] })
3606
+ ] })
3607
+ },
3608
+ message.id
3609
+ );
3610
+ }
3611
+ if (message.kind === "bulkSummary" && message.bulkSummary) {
3612
+ const { total, successes, failures, navigationPage } = message.bulkSummary;
3613
+ const hasFailures = failures.length > 0;
3614
+ const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3615
+ return /* @__PURE__ */ jsx9(
3616
+ "div",
3617
+ {
3618
+ className: `${isRoleChange ? "mt-3" : ""}`,
3619
+ children: /* @__PURE__ */ jsxs5(
3620
+ "div",
3621
+ {
3622
+ className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`,
3623
+ children: [
3624
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3625
+ /* @__PURE__ */ jsx9(
3626
+ CheckCircle23,
3627
+ {
3628
+ className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}`
3629
+ }
3630
+ ),
3631
+ /* @__PURE__ */ jsx9("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3632
+ ] }),
3633
+ /* @__PURE__ */ jsx9("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3634
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4 text-xs", children: [
3635
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-green-700", children: [
3636
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3" }),
3637
+ successes,
3638
+ " successful"
3639
+ ] }),
3640
+ hasFailures && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3641
+ /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3642
+ failures.length,
3643
+ " failed"
3644
+ ] })
3645
+ ] }),
3646
+ hasFailures && /* @__PURE__ */ jsxs5("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3647
+ /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3648
+ /* @__PURE__ */ jsxs5("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3649
+ failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ jsxs5(
3650
+ "div",
3651
+ {
3652
+ className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1",
3653
+ children: [
3654
+ "Row ",
3655
+ failure.row,
3656
+ ":",
3657
+ " ",
3658
+ failure.error || "Unknown error"
3659
+ ]
3660
+ },
3661
+ i
3662
+ )),
3663
+ failures.length > 5 && /* @__PURE__ */ jsxs5("div", { className: "text-xs text-amber-600", children: [
3664
+ "...and ",
3665
+ failures.length - 5,
3666
+ " more"
3667
+ ] })
3668
+ ] })
3669
+ ] }),
3670
+ navigationPage && successes > 0 && /* @__PURE__ */ jsx9("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ jsxs5(
3671
+ "button",
3672
+ {
3673
+ type: "button",
3674
+ onClick: (e) => {
3675
+ e.preventDefault();
3676
+ e.stopPropagation();
3677
+ console.log(
3678
+ "[DEBUG] Button clicked - navigationPage:",
3679
+ navigationPage,
3680
+ "onNavigate:",
3681
+ !!onNavigate
3682
+ );
3683
+ if (onNavigate && navigationPage.page) {
3684
+ console.log(
3685
+ "[DEBUG] Calling onNavigate with page:",
3686
+ navigationPage.page
3687
+ );
3688
+ onNavigate(
3689
+ navigationPage.page,
3690
+ navigationPage.subtab
3691
+ );
3692
+ } else {
3693
+ console.log(
3694
+ "[DEBUG] Condition failed - onNavigate:",
3695
+ !!onNavigate,
3696
+ "navigationPage.page:",
3697
+ navigationPage.page
3698
+ );
3699
+ }
3700
+ },
3701
+ className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3702
+ children: [
3703
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 px-1.5 py-0.5 bg-gray-100 rounded text-[10px] font-medium text-gray-600 group-hover:bg-gray-200", children: [
3704
+ /* @__PURE__ */ jsx9(Command, { className: "h-2.5 w-2.5" }),
3705
+ /* @__PURE__ */ jsx9("span", { children: "+" }),
3706
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-2.5 w-2.5" })
3707
+ ] }),
3708
+ /* @__PURE__ */ jsxs5("span", { children: [
3709
+ "View ",
3710
+ pageLabel
3711
+ ] })
3712
+ ]
3713
+ }
3714
+ ) })
3715
+ ]
3716
+ }
3717
+ )
3718
+ },
3719
+ message.id
3720
+ );
3721
+ }
3722
+ return /* @__PURE__ */ jsx9(React4.Fragment, { children: /* @__PURE__ */ jsxs5(
3128
3723
  "div",
3129
3724
  {
3130
- className: "h-full bg-blue-600 transition-all duration-300",
3131
- style: { width: `${percentage}%` }
3725
+ ref: isCurrentGuideStep ? currentStepRef : null,
3726
+ className: `${isRoleChange ? "mt-3" : ""}`,
3727
+ children: [
3728
+ /* @__PURE__ */ jsx9("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3729
+ const text = message.content || "";
3730
+ if (message.kind === "guideStep") {
3731
+ const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3732
+ if (m) {
3733
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3734
+ /* @__PURE__ */ jsx9("strong", { children: m[1] }),
3735
+ m[2]
3736
+ ] });
3737
+ }
3738
+ }
3739
+ if (message.role === "assistant" && text) {
3740
+ return renderMarkdown(text);
3741
+ }
3742
+ return text || /* @__PURE__ */ jsx9("span", { className: "opacity-70", children: "Thinking\u2026" });
3743
+ })() }),
3744
+ message.role === "assistant" && message.structuredData && /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsx9(
3745
+ DataRenderer,
3746
+ {
3747
+ type: message.structuredData.type,
3748
+ data: message.structuredData.data
3749
+ }
3750
+ ) }),
3751
+ message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ jsx9("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ jsx9(
3752
+ "button",
3753
+ {
3754
+ type: "button",
3755
+ onClick: () => handleFollowupClick(message.id, followup),
3756
+ className: "inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-xl\n bg-white hover:bg-gray-50 text-gray-600 hover:text-gray-800\n border border-gray-200 hover:border-gray-300 shadow-sm\n transition-all duration-150 ease-in-out",
3757
+ children: followup.label
3758
+ },
3759
+ followup.id
3760
+ )) })
3761
+ ]
3132
3762
  }
3133
- ) }),
3134
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3135
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1", children: [
3136
- /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3 text-green-600" }),
3137
- successes,
3138
- " successful"
3139
- ] }),
3140
- failures > 0 && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3141
- /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3142
- failures,
3143
- " failed"
3144
- ] })
3145
- ] })
3146
- ] }) }, message.id);
3147
- }
3148
- if (message.kind === "bulkSummary" && message.bulkSummary) {
3149
- const { total, successes, failures, navigationPage } = message.bulkSummary;
3150
- const hasFailures = failures.length > 0;
3151
- const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3152
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`, children: [
3153
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3154
- /* @__PURE__ */ jsx9(CheckCircle23, { className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}` }),
3155
- /* @__PURE__ */ jsx9("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3156
- ] }),
3157
- /* @__PURE__ */ jsx9("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3158
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4 text-xs", children: [
3159
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-green-700", children: [
3160
- /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3" }),
3161
- successes,
3162
- " successful"
3163
- ] }),
3164
- hasFailures && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3165
- /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3166
- failures.length,
3167
- " failed"
3168
- ] })
3169
- ] }),
3170
- hasFailures && /* @__PURE__ */ jsxs5("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3171
- /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3172
- /* @__PURE__ */ jsxs5("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3173
- failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ jsxs5("div", { className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1", children: [
3174
- "Row ",
3175
- failure.row,
3176
- ": ",
3177
- failure.error || "Unknown error"
3178
- ] }, i)),
3179
- failures.length > 5 && /* @__PURE__ */ jsxs5("div", { className: "text-xs text-amber-600", children: [
3180
- "...and ",
3181
- failures.length - 5,
3182
- " more"
3183
- ] })
3184
- ] })
3185
- ] }),
3186
- navigationPage && successes > 0 && /* @__PURE__ */ jsx9("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ jsxs5(
3187
- "button",
3763
+ ) }, message.id);
3764
+ }),
3765
+ (activeGuide || guideComplete) && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3766
+ activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ jsx9(
3767
+ Button,
3188
3768
  {
3189
3769
  type: "button",
3190
- onClick: (e) => {
3191
- e.preventDefault();
3192
- e.stopPropagation();
3193
- console.log("[DEBUG] Button clicked - navigationPage:", navigationPage, "onNavigate:", !!onNavigate);
3194
- if (onNavigate && navigationPage.page) {
3195
- console.log("[DEBUG] Calling onNavigate with page:", navigationPage.page);
3196
- onNavigate(navigationPage.page, navigationPage.subtab);
3197
- } else {
3198
- console.log("[DEBUG] Condition failed - onNavigate:", !!onNavigate, "navigationPage.page:", navigationPage.page);
3199
- }
3200
- },
3201
- className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3770
+ size: "sm",
3771
+ variant: "secondary",
3772
+ className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3773
+ onClick: goBackGuide,
3774
+ children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3775
+ }
3776
+ ),
3777
+ /* @__PURE__ */ jsxs5(
3778
+ Button,
3779
+ {
3780
+ type: "button",
3781
+ size: "sm",
3782
+ variant: "secondary",
3783
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3784
+ onClick: guideComplete ? handleBack : advanceGuide,
3202
3785
  children: [
3203
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 px-1.5 py-0.5 bg-gray-100 rounded text-[10px] font-medium text-gray-600 group-hover:bg-gray-200", children: [
3204
- /* @__PURE__ */ jsx9(Command, { className: "h-2.5 w-2.5" }),
3205
- /* @__PURE__ */ jsx9("span", { children: "+" }),
3206
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-2.5 w-2.5" })
3207
- ] }),
3208
- /* @__PURE__ */ jsxs5("span", { children: [
3209
- "View ",
3210
- pageLabel
3786
+ /* @__PURE__ */ jsx9("span", { children: guideComplete ? "Done" : "Next" }),
3787
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3788
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3789
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3211
3790
  ] })
3212
3791
  ]
3213
3792
  }
3214
- ) })
3215
- ] }) }, message.id);
3216
- }
3217
- return /* @__PURE__ */ jsx9(React4.Fragment, { children: /* @__PURE__ */ jsxs5(
3218
- "div",
3219
- {
3220
- ref: isCurrentGuideStep ? currentStepRef : null,
3221
- className: `${isRoleChange ? "mt-3" : ""}`,
3222
- children: [
3223
- /* @__PURE__ */ jsx9("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3224
- const text = message.content || "";
3225
- if (message.kind === "guideStep") {
3226
- const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3227
- if (m) {
3228
- return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3229
- /* @__PURE__ */ jsx9("strong", { children: m[1] }),
3230
- m[2]
3231
- ] });
3232
- }
3233
- }
3234
- if (message.role === "assistant" && text) {
3235
- return renderMarkdown(text);
3236
- }
3237
- return text || /* @__PURE__ */ jsx9("span", { className: "opacity-70", children: "Thinking\u2026" });
3238
- })() }),
3239
- message.role === "assistant" && message.structuredData && /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsx9(
3240
- DataRenderer,
3241
- {
3242
- type: message.structuredData.type,
3243
- data: message.structuredData.data
3244
- }
3245
- ) }),
3246
- message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ jsx9("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ jsx9(
3247
- "button",
3248
- {
3249
- type: "button",
3250
- onClick: () => handleFollowupClick(message.id, followup),
3251
- className: "inline-flex items-center px-3 py-1.5 text-xs font-medium rounded-xl\n bg-white hover:bg-gray-50 text-gray-600 hover:text-gray-800\n border border-gray-200 hover:border-gray-300 shadow-sm\n transition-all duration-150 ease-in-out",
3252
- children: followup.label
3253
- },
3254
- followup.id
3255
- )) })
3256
- ]
3257
- }
3258
- ) }, message.id);
3259
- }),
3260
- (activeGuide || guideComplete) && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3261
- activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ jsx9(
3262
- Button,
3263
- {
3264
- type: "button",
3265
- size: "sm",
3266
- variant: "secondary",
3267
- className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3268
- onClick: goBackGuide,
3269
- children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3270
- }
3271
- ),
3272
- /* @__PURE__ */ jsxs5(
3273
- Button,
3274
- {
3275
- type: "button",
3276
- size: "sm",
3277
- variant: "secondary",
3278
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3279
- onClick: guideComplete ? handleBack : advanceGuide,
3280
- children: [
3281
- /* @__PURE__ */ jsx9("span", { children: guideComplete ? "Done" : "Next" }),
3282
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3283
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3284
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3285
- ] })
3286
- ]
3287
- }
3288
- )
3289
- ] }),
3290
- (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ jsx9("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(
3291
- AssistantActivity,
3292
- {
3293
- phase,
3294
- progressSteps
3295
- }
3296
- ) }),
3297
- !activeGuide && /* @__PURE__ */ jsx9("div", { ref: messagesEndRef })
3298
- ] }) }) }) }) }),
3793
+ )
3794
+ ] }),
3795
+ (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ jsx9("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(
3796
+ AssistantActivity,
3797
+ {
3798
+ phase,
3799
+ progressSteps
3800
+ }
3801
+ ) }),
3802
+ !activeGuide && /* @__PURE__ */ jsx9("div", { ref: messagesEndRef })
3803
+ ] }) }) }) })
3804
+ }
3805
+ ),
3299
3806
  /* @__PURE__ */ jsxs5("div", { className: "px-4 py-3 border-t border-gray-100 bg-gray-50/50 shrink-0", children: [
3300
3807
  pendingFile && /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center gap-2 rounded-xl bg-blue-50 border border-blue-200 px-3 py-2", children: [
3301
3808
  /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-blue-600" }),
@@ -3347,14 +3854,10 @@ ${userText}`
3347
3854
  {
3348
3855
  placeholder: pendingFile ? "Describe what to do with this CSV..." : "Ask anything...",
3349
3856
  value: input,
3350
- onChange: (e) => setInput(e.target.value),
3351
- rows: 1,
3352
- className: "flex-1 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 text-sm placeholder:text-gray-400 resize-none overflow-hidden outline-none",
3353
- style: { minHeight: "20px", maxHeight: "120px" },
3354
- onInput: (e) => {
3355
- const target = e.target;
3356
- target.style.height = "auto";
3357
- target.style.height = Math.min(target.scrollHeight, 120) + "px";
3857
+ onChange: (e) => {
3858
+ setInput(e.target.value);
3859
+ e.target.style.height = "24px";
3860
+ e.target.style.height = `${Math.min(120, e.target.scrollHeight)}px`;
3358
3861
  },
3359
3862
  onKeyDown: (e) => {
3360
3863
  if (e.key === "Enter" && !e.shiftKey && !e.metaKey && !e.ctrlKey) {
@@ -3424,7 +3927,11 @@ ${userText}`
3424
3927
  }
3425
3928
  );
3426
3929
  }
3427
- function PanelToggle({ isOpen, onClick, className = "" }) {
3930
+ function PanelToggle({
3931
+ isOpen,
3932
+ onClick,
3933
+ className = ""
3934
+ }) {
3428
3935
  return /* @__PURE__ */ jsx9(
3429
3936
  "button",
3430
3937
  {
@@ -3470,13 +3977,7 @@ function ChatPanelWithToggle({
3470
3977
  };
3471
3978
  }, [isOpen]);
3472
3979
  return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3473
- /* @__PURE__ */ jsx9(
3474
- PanelToggle,
3475
- {
3476
- isOpen,
3477
- onClick: () => setIsOpen(!isOpen)
3478
- }
3479
- ),
3980
+ /* @__PURE__ */ jsx9(PanelToggle, { isOpen, onClick: () => setIsOpen(!isOpen) }),
3480
3981
  /* @__PURE__ */ jsx9(
3481
3982
  ChatPanel,
3482
3983
  {