@kite-copilot/chat-panel 0.2.16 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -958,7 +958,14 @@ function renderMarkdown(text) {
958
958
  const codeMatch = remaining.match(/^`([^`]+)`/);
959
959
  if (codeMatch) {
960
960
  parts.push(
961
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "bg-gray-100 px-1 py-0.5 rounded text-xs font-mono", children: codeMatch[1] }, keyIndex++)
961
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
962
+ "code",
963
+ {
964
+ className: "bg-gray-100 px-1 py-0.5 rounded text-xs font-mono",
965
+ children: codeMatch[1]
966
+ },
967
+ keyIndex++
968
+ )
962
969
  );
963
970
  remaining = remaining.slice(codeMatch[0].length);
964
971
  continue;
@@ -978,7 +985,17 @@ function renderMarkdown(text) {
978
985
  const linkMatch = remaining.match(/^\[([^\]]+)\]\(([^)]+)\)/);
979
986
  if (linkMatch) {
980
987
  parts.push(
981
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: linkMatch[2], className: "text-blue-600 hover:underline", target: "_blank", rel: "noopener noreferrer", children: linkMatch[1] }, keyIndex++)
988
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
989
+ "a",
990
+ {
991
+ href: linkMatch[2],
992
+ className: "text-blue-600 hover:underline",
993
+ target: "_blank",
994
+ rel: "noopener noreferrer",
995
+ children: linkMatch[1]
996
+ },
997
+ keyIndex++
998
+ )
982
999
  );
983
1000
  remaining = remaining.slice(linkMatch[0].length);
984
1001
  continue;
@@ -1001,7 +1018,14 @@ function renderMarkdown(text) {
1001
1018
  if (currentList) {
1002
1019
  const ListTag = currentList.type === "ul" ? "ul" : "ol";
1003
1020
  elements.push(
1004
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ListTag, { className: `${currentList.type === "ul" ? "list-disc" : "list-decimal"} ml-4 my-1`, children: currentList.items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "ml-2", children: item }, i)) }, elements.length)
1021
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1022
+ ListTag,
1023
+ {
1024
+ className: `${currentList.type === "ul" ? "list-disc" : "list-decimal"} ml-4 my-1`,
1025
+ children: currentList.items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "ml-2", children: item }, i))
1026
+ },
1027
+ elements.length
1028
+ )
1005
1029
  );
1006
1030
  currentList = null;
1007
1031
  }
@@ -1011,7 +1035,14 @@ function renderMarkdown(text) {
1011
1035
  if (line.startsWith("```")) {
1012
1036
  if (inCodeBlock) {
1013
1037
  elements.push(
1014
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pre", { className: "bg-gray-100 rounded p-2 my-1 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "text-xs font-mono", children: codeContent.join("\n") }) }, elements.length)
1038
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1039
+ "pre",
1040
+ {
1041
+ className: "bg-gray-100 rounded p-2 my-1 overflow-x-auto",
1042
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { className: "text-xs font-mono", children: codeContent.join("\n") })
1043
+ },
1044
+ elements.length
1045
+ )
1015
1046
  );
1016
1047
  inCodeBlock = false;
1017
1048
  codeContent = [];
@@ -1033,7 +1064,9 @@ function renderMarkdown(text) {
1033
1064
  const level = headerMatch[1].length;
1034
1065
  const content = processInlineFormatting(headerMatch[2]);
1035
1066
  const className = level === 1 ? "text-lg font-bold my-1" : level === 2 ? "text-base font-bold my-1" : "text-sm font-semibold my-1";
1036
- elements.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, children: content }, elements.length));
1067
+ elements.push(
1068
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, children: content }, elements.length)
1069
+ );
1037
1070
  continue;
1038
1071
  }
1039
1072
  const ulMatch = line.match(/^[-*]\s+(.+)/);
@@ -1061,11 +1094,15 @@ function renderMarkdown(text) {
1061
1094
  }
1062
1095
  if (line.match(/^[-*_]{3,}$/)) {
1063
1096
  flushList();
1064
- elements.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { className: "my-2 border-gray-200" }, elements.length));
1097
+ elements.push(
1098
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("hr", { className: "my-2 border-gray-200" }, elements.length)
1099
+ );
1065
1100
  continue;
1066
1101
  }
1067
1102
  flushList();
1068
- elements.push(/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: processInlineFormatting(line) }, elements.length));
1103
+ elements.push(
1104
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: processInlineFormatting(line) }, elements.length)
1105
+ );
1069
1106
  }
1070
1107
  flushList();
1071
1108
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: elements });
@@ -1095,31 +1132,59 @@ var folders = [
1095
1132
  id: "customers",
1096
1133
  title: "Customer Management",
1097
1134
  topics: [
1098
- { id: "add-customer", label: "Add a new customer", prompt: "How do I add a new customer to the system and what information is required?" },
1099
- { id: "customer-details", label: "View customer details", prompt: "Show me how to view and edit customer information and their payment history." }
1135
+ {
1136
+ id: "add-customer",
1137
+ label: "Add a new customer",
1138
+ prompt: "How do I add a new customer to the system and what information is required?"
1139
+ },
1140
+ {
1141
+ id: "customer-details",
1142
+ label: "View customer details",
1143
+ prompt: "Show me how to view and edit customer information and their payment history."
1144
+ }
1100
1145
  ]
1101
1146
  },
1102
1147
  {
1103
1148
  id: "payments",
1104
1149
  title: "Payment Processing",
1105
1150
  topics: [
1106
- { id: "process-payment", label: "Process a payment", prompt: "How do I process a one-time payment for a customer?" },
1107
- { id: "refund-payment", label: "Issue a refund", prompt: "Walk me through issuing a refund for a customer payment." }
1151
+ {
1152
+ id: "process-payment",
1153
+ label: "Process a payment",
1154
+ prompt: "How do I process a one-time payment for a customer?"
1155
+ },
1156
+ {
1157
+ id: "refund-payment",
1158
+ label: "Issue a refund",
1159
+ prompt: "Walk me through issuing a refund for a customer payment."
1160
+ }
1108
1161
  ]
1109
1162
  },
1110
1163
  {
1111
1164
  id: "subscriptions",
1112
1165
  title: "Subscription Management",
1113
1166
  topics: [
1114
- { id: "create-subscription", label: "Create a subscription", prompt: "How do I set up a new subscription plan for a customer?" },
1115
- { id: "update-subscription", label: "Update subscription tier", prompt: "How can I change a customer's subscription plan or upgrade them?" }
1167
+ {
1168
+ id: "create-subscription",
1169
+ label: "Create a subscription",
1170
+ prompt: "How do I set up a new subscription plan for a customer?"
1171
+ },
1172
+ {
1173
+ id: "update-subscription",
1174
+ label: "Update subscription tier",
1175
+ prompt: "How can I change a customer's subscription plan or upgrade them?"
1176
+ }
1116
1177
  ]
1117
1178
  },
1118
1179
  {
1119
1180
  id: "billing",
1120
1181
  title: "Billing",
1121
1182
  topics: [
1122
- { id: "payment-methods", label: "Manage payment methods", prompt: "How do customers add or update their payment methods?" }
1183
+ {
1184
+ id: "payment-methods",
1185
+ label: "Manage payment methods",
1186
+ prompt: "How do customers add or update their payment methods?"
1187
+ }
1123
1188
  ]
1124
1189
  }
1125
1190
  ];
@@ -1265,18 +1330,21 @@ function ChatPanel({
1265
1330
  } = {}) {
1266
1331
  const [messages, setMessages] = React4.useState(initialMessages);
1267
1332
  const [input, setInput] = React4.useState("");
1268
- const [sessionId] = React4.useState(() => crypto.randomUUID());
1333
+ const [sessionId, setSessionId] = React4.useState(() => crypto.randomUUID());
1334
+ const resetSession = React4.useCallback(() => {
1335
+ setSessionId(crypto.randomUUID());
1336
+ }, []);
1269
1337
  const streamIntervals = React4.useRef({});
1270
1338
  const isEmpty = messages.length === 0;
1271
1339
  const [phase, setPhase] = React4.useState("idle");
1272
1340
  const [progressSteps, setProgressSteps] = React4.useState([]);
1273
1341
  const phaseTimers = React4.useRef([]);
1274
1342
  const lastRole = messages.length ? messages[messages.length - 1].role : void 0;
1275
- const [panelView, setPanelView] = React4.useState("landing");
1276
- const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1277
- const [startingQuestions, setStartingQuestions] = React4.useState(
1278
- startingQuestionsProp || defaultStartingQuestions
1343
+ const [panelView, setPanelView] = React4.useState(
1344
+ "landing"
1279
1345
  );
1346
+ const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1347
+ const [startingQuestions, setStartingQuestions] = React4.useState(startingQuestionsProp || defaultStartingQuestions);
1280
1348
  const [loadingQuestions, setLoadingQuestions] = React4.useState(false);
1281
1349
  React4.useEffect(() => {
1282
1350
  if (startingQuestionsEndpoint && !startingQuestionsProp) {
@@ -1300,10 +1368,11 @@ function ChatPanel({
1300
1368
  const latestBulkSummaryNavigationRef = React4.useRef(null);
1301
1369
  const [guideComplete, setGuideComplete] = React4.useState(false);
1302
1370
  React4.useEffect(() => {
1303
- ;
1304
1371
  window.resetIntegrationNotification = () => {
1305
1372
  localStorage.removeItem("gmailNotificationSeen");
1306
- console.log("Integration notification reset! Click the Integrations tab to see it again.");
1373
+ console.log(
1374
+ "Integration notification reset! Click the Integrations tab to see it again."
1375
+ );
1307
1376
  };
1308
1377
  const handleIntegrationTabClick = () => {
1309
1378
  const hasSeenNotification = localStorage.getItem("gmailNotificationSeen");
@@ -1326,7 +1395,10 @@ function ChatPanel({
1326
1395
  };
1327
1396
  window.addEventListener("integrationTabClicked", handleIntegrationTabClick);
1328
1397
  return () => {
1329
- window.removeEventListener("integrationTabClicked", handleIntegrationTabClick);
1398
+ window.removeEventListener(
1399
+ "integrationTabClicked",
1400
+ handleIntegrationTabClick
1401
+ );
1330
1402
  };
1331
1403
  }, []);
1332
1404
  React4.useEffect(() => {
@@ -1361,7 +1433,12 @@ function ChatPanel({
1361
1433
  const id = Date.now() + 1;
1362
1434
  setMessages((prev) => [
1363
1435
  ...prev,
1364
- { id, role: "assistant", kind: "guideComplete", content: "Perfect! The dialog is now open. You can enter a name and create your API key." }
1436
+ {
1437
+ id,
1438
+ role: "assistant",
1439
+ kind: "guideComplete",
1440
+ content: "Perfect! The dialog is now open. You can enter a name and create your API key."
1441
+ }
1365
1442
  ]);
1366
1443
  setActiveGuide(void 0);
1367
1444
  setGuideComplete(true);
@@ -1372,7 +1449,9 @@ function ChatPanel({
1372
1449
  }, [activeGuide, hide]);
1373
1450
  React4.useEffect(() => {
1374
1451
  return () => {
1375
- Object.values(streamIntervals.current).forEach((id) => window.clearInterval(id));
1452
+ Object.values(streamIntervals.current).forEach(
1453
+ (id) => window.clearInterval(id)
1454
+ );
1376
1455
  streamIntervals.current = {};
1377
1456
  phaseTimers.current.forEach((id) => window.clearTimeout(id));
1378
1457
  phaseTimers.current = [];
@@ -1433,9 +1512,17 @@ function ChatPanel({
1433
1512
  return;
1434
1513
  }
1435
1514
  const currentBulkNav = latestBulkSummaryNavigationRef.current;
1436
- console.log("[DEBUG] Keyboard handler - latestBulkSummaryNavigation:", currentBulkNav, "onNavigate:", !!onNavigate);
1515
+ console.log(
1516
+ "[DEBUG] Keyboard handler - latestBulkSummaryNavigation:",
1517
+ currentBulkNav,
1518
+ "onNavigate:",
1519
+ !!onNavigate
1520
+ );
1437
1521
  if (currentBulkNav && onNavigate) {
1438
- console.log("[DEBUG] Navigating via keyboard to:", currentBulkNav.page);
1522
+ console.log(
1523
+ "[DEBUG] Navigating via keyboard to:",
1524
+ currentBulkNav.page
1525
+ );
1439
1526
  e.preventDefault();
1440
1527
  e.stopPropagation();
1441
1528
  onNavigate(currentBulkNav.page, currentBulkNav.subtab);
@@ -1458,21 +1545,57 @@ function ChatPanel({
1458
1545
  };
1459
1546
  window.addEventListener("keydown", handleKeyDown);
1460
1547
  return () => window.removeEventListener("keydown", handleKeyDown);
1461
- }, [pendingAction, pendingNavigation, activeGuide, guideComplete, onNavigate]);
1548
+ }, [
1549
+ pendingAction,
1550
+ pendingNavigation,
1551
+ activeGuide,
1552
+ guideComplete,
1553
+ onNavigate
1554
+ ]);
1462
1555
  function streamAssistantMessage(messageId, fullText, followups) {
1463
- const tokens = fullText.split(" ");
1556
+ let textToStream = fullText;
1557
+ let extractedFollowups = followups;
1558
+ if (fullText && fullText.startsWith("{") && fullText.includes('"response"')) {
1559
+ try {
1560
+ let depth = 0, endIdx = 0;
1561
+ for (let i2 = 0; i2 < fullText.length; i2++) {
1562
+ if (fullText[i2] === "{") depth++;
1563
+ else if (fullText[i2] === "}") {
1564
+ depth--;
1565
+ if (depth === 0) {
1566
+ endIdx = i2 + 1;
1567
+ break;
1568
+ }
1569
+ }
1570
+ }
1571
+ const firstJson = endIdx > 0 ? fullText.slice(0, endIdx) : fullText;
1572
+ const parsed = JSON.parse(firstJson);
1573
+ if (parsed.response && typeof parsed.response === "string") {
1574
+ textToStream = parsed.response;
1575
+ if (!extractedFollowups && parsed.followups) {
1576
+ extractedFollowups = parsed.followups;
1577
+ }
1578
+ }
1579
+ } catch {
1580
+ }
1581
+ }
1582
+ const tokens = textToStream.split(" ");
1464
1583
  let i = 0;
1465
1584
  const intervalId = window.setInterval(() => {
1466
1585
  i += 1;
1467
1586
  setMessages(
1468
- (prev) => prev.map((m) => m.id === messageId ? { ...m, content: tokens.slice(0, i).join(" ") } : m)
1587
+ (prev) => prev.map(
1588
+ (m) => m.id === messageId ? { ...m, content: tokens.slice(0, i).join(" ") } : m
1589
+ )
1469
1590
  );
1470
1591
  if (i >= tokens.length) {
1471
1592
  window.clearInterval(intervalId);
1472
1593
  delete streamIntervals.current[messageId];
1473
- if (followups && followups.length > 0) {
1594
+ if (extractedFollowups && extractedFollowups.length > 0) {
1474
1595
  setMessages(
1475
- (prev) => prev.map((m) => m.id === messageId ? { ...m, followups } : m)
1596
+ (prev) => prev.map(
1597
+ (m) => m.id === messageId ? { ...m, followups: extractedFollowups } : m
1598
+ )
1476
1599
  );
1477
1600
  }
1478
1601
  setPhase("idle");
@@ -1482,16 +1605,21 @@ function ChatPanel({
1482
1605
  }
1483
1606
  function handleFollowupClick(messageId, followup) {
1484
1607
  setMessages(
1485
- (prev) => prev.map((m) => m.id === messageId ? { ...m, followupSelected: true } : m)
1608
+ (prev) => prev.map(
1609
+ (m) => m.id === messageId ? { ...m, followupSelected: true } : m
1610
+ )
1486
1611
  );
1487
1612
  startChatFlow(followup.label);
1488
1613
  }
1489
1614
  function handleBack() {
1490
- Object.values(streamIntervals.current).forEach((id) => window.clearInterval(id));
1615
+ Object.values(streamIntervals.current).forEach(
1616
+ (id) => window.clearInterval(id)
1617
+ );
1491
1618
  streamIntervals.current = {};
1492
1619
  phaseTimers.current.forEach((id) => window.clearTimeout(id));
1493
1620
  phaseTimers.current = [];
1494
1621
  hide();
1622
+ resetSession();
1495
1623
  setMessages([]);
1496
1624
  setInput("");
1497
1625
  setPhase("idle");
@@ -1641,7 +1769,11 @@ function ChatPanel({
1641
1769
  const isRespondingToNotification = lastAssistantMessage?.isNotificationMessage === true;
1642
1770
  const now = Date.now();
1643
1771
  const userMessage = { id: now, role: "user", content: userText };
1644
- setMessages((prev) => [...prev, userMessage]);
1772
+ setMessages(
1773
+ (prev) => prev.map(
1774
+ (m) => m.followups && m.followups.length > 0 ? { ...m, followupSelected: true } : m
1775
+ ).concat(userMessage)
1776
+ );
1645
1777
  if (isRespondingToNotification) {
1646
1778
  const thankYouMessageId = Date.now() + 1;
1647
1779
  const thankYouMessage = {
@@ -1651,7 +1783,10 @@ function ChatPanel({
1651
1783
  content: ""
1652
1784
  };
1653
1785
  setMessages((prev) => [...prev, thankYouMessage]);
1654
- streamAssistantMessage(thankYouMessageId, "Thank you, your feedback is saved.");
1786
+ streamAssistantMessage(
1787
+ thankYouMessageId,
1788
+ "Thank you, your feedback is saved."
1789
+ );
1655
1790
  return;
1656
1791
  }
1657
1792
  setPendingNavigation(null);
@@ -1709,7 +1844,10 @@ function ChatPanel({
1709
1844
  } else if (data.status === "executing") {
1710
1845
  setPhase("executing");
1711
1846
  setProgressSteps((prev) => {
1712
- const updated = prev.map((step) => ({ ...step, completed: true }));
1847
+ const updated = prev.map((step) => ({
1848
+ ...step,
1849
+ completed: true
1850
+ }));
1713
1851
  const lastStep = updated[updated.length - 1];
1714
1852
  if (!lastStep || lastStep.message !== data.message) {
1715
1853
  updated.push({ message: data.message, completed: false });
@@ -1718,7 +1856,9 @@ function ChatPanel({
1718
1856
  });
1719
1857
  } else if (data.status === "responding") {
1720
1858
  setPhase("responding");
1721
- setProgressSteps((prev) => prev.map((step) => ({ ...step, completed: true })));
1859
+ setProgressSteps(
1860
+ (prev) => prev.map((step) => ({ ...step, completed: true }))
1861
+ );
1722
1862
  }
1723
1863
  } else if (eventType === "response") {
1724
1864
  setProgressSteps([]);
@@ -1764,7 +1904,11 @@ function ChatPanel({
1764
1904
  content: ""
1765
1905
  };
1766
1906
  setMessages((prev) => [...prev, assistantMessage]);
1767
- streamAssistantMessage(assistantMessageId, agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!", agentResponse.followups);
1907
+ streamAssistantMessage(
1908
+ assistantMessageId,
1909
+ agentResponse.response || agentResponse.message || "For bulk operations, you can upload a CSV file - just click the \u{1F4CE} button!",
1910
+ agentResponse.followups
1911
+ );
1768
1912
  streamCompleted = true;
1769
1913
  } else if (agentResponse.action === "bulk_preview") {
1770
1914
  setPendingBulkSession(agentResponse.bulk_session_id);
@@ -1796,12 +1940,18 @@ function ChatPanel({
1796
1940
  structuredData: agentResponse.structuredData || void 0
1797
1941
  };
1798
1942
  setMessages((prev) => [...prev, assistantMessage]);
1799
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1943
+ streamAssistantMessage(
1944
+ assistantMessageId,
1945
+ agentResponse.response,
1946
+ agentResponse.followups
1947
+ );
1800
1948
  streamCompleted = true;
1801
1949
  setTimeout(() => {
1802
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1803
- detail: { result: agentResponse.executionResult }
1804
- }));
1950
+ window.dispatchEvent(
1951
+ new CustomEvent("agentActionComplete", {
1952
+ detail: { result: agentResponse.executionResult }
1953
+ })
1954
+ );
1805
1955
  }, 100);
1806
1956
  } else {
1807
1957
  const assistantMessageId = now + 1;
@@ -1812,7 +1962,11 @@ function ChatPanel({
1812
1962
  content: ""
1813
1963
  };
1814
1964
  setMessages((prev) => [...prev, assistantMessage]);
1815
- streamAssistantMessage(assistantMessageId, agentResponse.response, agentResponse.followups);
1965
+ streamAssistantMessage(
1966
+ assistantMessageId,
1967
+ agentResponse.response,
1968
+ agentResponse.followups
1969
+ );
1816
1970
  streamCompleted = true;
1817
1971
  }
1818
1972
  } else if (eventType === "error") {
@@ -1827,7 +1981,10 @@ function ChatPanel({
1827
1981
  content: ""
1828
1982
  };
1829
1983
  setMessages((prev) => [...prev, errorMessage]);
1830
- streamAssistantMessage(errorMessageId, data.message || "An error occurred processing your request.");
1984
+ streamAssistantMessage(
1985
+ errorMessageId,
1986
+ data.message || "An error occurred processing your request."
1987
+ );
1831
1988
  } else if (eventType === "done") {
1832
1989
  setProgressSteps([]);
1833
1990
  setPhase("idle");
@@ -1853,7 +2010,18 @@ function ChatPanel({
1853
2010
  content: ""
1854
2011
  };
1855
2012
  setMessages((prev) => [...prev, errorMessage]);
1856
- 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.");
2013
+ let errorText = "I'm having trouble connecting to my backend.";
2014
+ if (error instanceof Error) {
2015
+ if (error.name === "AbortError") {
2016
+ errorText = "The request timed out. The server might be busy - please try again.";
2017
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
2018
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
2019
+ } else if (error.message.includes("Agent request failed:")) {
2020
+ errorText = "The server encountered an error. Please try again.";
2021
+ }
2022
+ }
2023
+ errorText += " For simple navigation requests, I can still help you locally.";
2024
+ streamAssistantMessage(errorMessageId, errorText);
1857
2025
  } finally {
1858
2026
  setProgressSteps([]);
1859
2027
  }
@@ -1937,33 +2105,41 @@ ${userText}`
1937
2105
  setMessages((prev) => [...prev, previewMessage]);
1938
2106
  } else if (eventType === "progress") {
1939
2107
  setPhase("executing");
1940
- setProgressSteps([{
1941
- message: `Processing row ${data.row} of ${data.total}...`,
1942
- completed: false
1943
- }]);
2108
+ setProgressSteps([
2109
+ {
2110
+ message: `Processing row ${data.row} of ${data.total}...`,
2111
+ completed: false
2112
+ }
2113
+ ]);
1944
2114
  setMessages((prev) => {
1945
2115
  const lastMsg = prev[prev.length - 1];
1946
2116
  if (lastMsg?.kind === "bulkProgress") {
1947
2117
  return prev.map(
1948
- (m, i) => i === prev.length - 1 ? { ...m, bulkProgress: {
1949
- processed: data.row,
1950
- total: data.total,
1951
- successes: data.successes || 0,
1952
- failures: data.failures || 0
1953
- } } : m
2118
+ (m, i) => i === prev.length - 1 ? {
2119
+ ...m,
2120
+ bulkProgress: {
2121
+ processed: data.row,
2122
+ total: data.total,
2123
+ successes: data.successes || 0,
2124
+ failures: data.failures || 0
2125
+ }
2126
+ } : m
1954
2127
  );
1955
2128
  } else {
1956
- return [...prev, {
1957
- id: Date.now(),
1958
- role: "assistant",
1959
- kind: "bulkProgress",
1960
- bulkProgress: {
1961
- processed: data.row,
1962
- total: data.total,
1963
- successes: data.successes || 0,
1964
- failures: data.failures || 0
2129
+ return [
2130
+ ...prev,
2131
+ {
2132
+ id: Date.now(),
2133
+ role: "assistant",
2134
+ kind: "bulkProgress",
2135
+ bulkProgress: {
2136
+ processed: data.row,
2137
+ total: data.total,
2138
+ successes: data.successes || 0,
2139
+ failures: data.failures || 0
2140
+ }
1965
2141
  }
1966
- }];
2142
+ ];
1967
2143
  }
1968
2144
  });
1969
2145
  } else if (eventType === "summary") {
@@ -1972,23 +2148,34 @@ ${userText}`
1972
2148
  setPendingBulkSession(null);
1973
2149
  setMessages((prev) => {
1974
2150
  const filtered = prev.filter((m) => m.kind !== "bulkProgress");
1975
- return [...filtered, {
1976
- id: Date.now(),
1977
- role: "assistant",
1978
- kind: "bulkSummary",
1979
- content: data.message,
1980
- bulkSummary: {
1981
- total: data.total,
1982
- successes: data.successes,
1983
- failures: data.failures || [],
1984
- navigationPage: data.navigationPage
2151
+ return [
2152
+ ...filtered,
2153
+ {
2154
+ id: Date.now(),
2155
+ role: "assistant",
2156
+ kind: "bulkSummary",
2157
+ content: data.message,
2158
+ bulkSummary: {
2159
+ total: data.total,
2160
+ successes: data.successes,
2161
+ failures: data.failures || [],
2162
+ navigationPage: data.navigationPage
2163
+ }
1985
2164
  }
1986
- }];
2165
+ ];
1987
2166
  });
1988
2167
  setTimeout(() => {
1989
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
1990
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
1991
- }));
2168
+ window.dispatchEvent(
2169
+ new CustomEvent("agentActionComplete", {
2170
+ detail: {
2171
+ result: {
2172
+ bulk: true,
2173
+ total: data.total,
2174
+ successes: data.successes
2175
+ }
2176
+ }
2177
+ })
2178
+ );
1992
2179
  }, 100);
1993
2180
  } else if (eventType === "error") {
1994
2181
  setPhase("idle");
@@ -2016,18 +2203,31 @@ ${userText}`
2016
2203
  console.error("Bulk upload failed:", error);
2017
2204
  setProgressSteps([]);
2018
2205
  setPhase("idle");
2206
+ let errorText = "I'm having trouble processing your CSV file.";
2207
+ if (error instanceof Error) {
2208
+ if (error.name === "AbortError") {
2209
+ errorText = "The bulk upload request timed out. The file might be too large or the server is busy - please try again.";
2210
+ } else if (error.message.includes("Failed to fetch") || error.message.includes("NetworkError")) {
2211
+ errorText = "I'm having trouble connecting to my backend. Please make sure the agent server is running on port 5002.";
2212
+ } else if (error.message.includes("Bulk upload failed:")) {
2213
+ errorText = "The server encountered an error processing your CSV file. Please try again.";
2214
+ }
2215
+ }
2216
+ errorText += " Please try again.";
2019
2217
  const errorMessage = {
2020
2218
  id: now + 1,
2021
2219
  role: "assistant",
2022
2220
  kind: "text",
2023
- content: "I'm having trouble processing your CSV file. Please make sure the agent server is running on port 5002 and try again."
2221
+ content: errorText
2024
2222
  };
2025
2223
  setMessages((prev) => [...prev, errorMessage]);
2026
2224
  }
2027
2225
  }
2028
2226
  async function confirmBulkOperation(bulkSessionId) {
2029
2227
  setPhase("executing");
2030
- setProgressSteps([{ message: "Starting bulk operation...", completed: false }]);
2228
+ setProgressSteps([
2229
+ { message: "Starting bulk operation...", completed: false }
2230
+ ]);
2031
2231
  try {
2032
2232
  const response = await fetch(`${agentUrl}/chat/bulk/confirm`, {
2033
2233
  method: "POST",
@@ -2063,43 +2263,56 @@ ${userText}`
2063
2263
  try {
2064
2264
  const data = JSON.parse(eventData);
2065
2265
  if (eventType === "progress") {
2066
- setProgressSteps([{
2067
- message: `Processing row ${data.row} of ${data.total}...`,
2068
- completed: false
2069
- }]);
2266
+ setProgressSteps([
2267
+ {
2268
+ message: `Processing row ${data.row} of ${data.total}...`,
2269
+ completed: false
2270
+ }
2271
+ ]);
2070
2272
  setMessages((prev) => {
2071
2273
  const lastMsg = prev[prev.length - 1];
2072
2274
  if (lastMsg?.kind === "bulkProgress") {
2073
2275
  return prev.map(
2074
- (m, i) => i === prev.length - 1 ? { ...m, bulkProgress: {
2075
- processed: data.row,
2076
- total: data.total,
2077
- successes: data.successes || 0,
2078
- failures: data.failures || 0
2079
- } } : m
2276
+ (m, i) => i === prev.length - 1 ? {
2277
+ ...m,
2278
+ bulkProgress: {
2279
+ processed: data.row,
2280
+ total: data.total,
2281
+ successes: data.successes || 0,
2282
+ failures: data.failures || 0
2283
+ }
2284
+ } : m
2080
2285
  );
2081
2286
  } else {
2082
- return [...prev, {
2083
- id: Date.now(),
2084
- role: "assistant",
2085
- kind: "bulkProgress",
2086
- bulkProgress: {
2087
- processed: data.row,
2088
- total: data.total,
2089
- successes: data.successes || 0,
2090
- failures: data.failures || 0
2287
+ return [
2288
+ ...prev,
2289
+ {
2290
+ id: Date.now(),
2291
+ role: "assistant",
2292
+ kind: "bulkProgress",
2293
+ bulkProgress: {
2294
+ processed: data.row,
2295
+ total: data.total,
2296
+ successes: data.successes || 0,
2297
+ failures: data.failures || 0
2298
+ }
2091
2299
  }
2092
- }];
2300
+ ];
2093
2301
  }
2094
2302
  });
2095
2303
  } else if (eventType === "summary") {
2096
2304
  console.log("[DEBUG] Received summary event - data:", data);
2097
- console.log("[DEBUG] navigationPage from backend:", data.navigationPage);
2305
+ console.log(
2306
+ "[DEBUG] navigationPage from backend:",
2307
+ data.navigationPage
2308
+ );
2098
2309
  setPhase("idle");
2099
2310
  setProgressSteps([]);
2100
2311
  setPendingBulkSession(null);
2101
2312
  setMessages((prev) => {
2102
- const filtered = prev.filter((m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview");
2313
+ const filtered = prev.filter(
2314
+ (m) => m.kind !== "bulkProgress" && m.kind !== "bulkPreview"
2315
+ );
2103
2316
  const newMsg = {
2104
2317
  id: Date.now(),
2105
2318
  role: "assistant",
@@ -2116,9 +2329,17 @@ ${userText}`
2116
2329
  return [...filtered, newMsg];
2117
2330
  });
2118
2331
  setTimeout(() => {
2119
- window.dispatchEvent(new CustomEvent("agentActionComplete", {
2120
- detail: { result: { bulk: true, total: data.total, successes: data.successes } }
2121
- }));
2332
+ window.dispatchEvent(
2333
+ new CustomEvent("agentActionComplete", {
2334
+ detail: {
2335
+ result: {
2336
+ bulk: true,
2337
+ total: data.total,
2338
+ successes: data.successes
2339
+ }
2340
+ }
2341
+ })
2342
+ );
2122
2343
  }, 100);
2123
2344
  } else if (eventType === "error") {
2124
2345
  setPhase("idle");
@@ -2160,7 +2381,10 @@ ${userText}`
2160
2381
  }
2161
2382
  function appendAssistantText(text) {
2162
2383
  const id = Date.now() + Math.floor(Math.random() * 1e3);
2163
- setMessages((prev) => [...prev, { id, role: "assistant", kind: "text", content: text }]);
2384
+ setMessages((prev) => [
2385
+ ...prev,
2386
+ { id, role: "assistant", kind: "text", content: text }
2387
+ ]);
2164
2388
  }
2165
2389
  function startGuide(guideId) {
2166
2390
  const guide = guides[guideId];
@@ -2173,7 +2397,9 @@ ${userText}`
2173
2397
  appendAssistantText(`I'll help you with ${guide.title}.`);
2174
2398
  const firstStep = guide.steps[0];
2175
2399
  const isNavigationButton = firstStep.cursorTarget?.selector.includes("[data-page=");
2176
- const isTabButton = firstStep.cursorTarget?.selector.includes("[data-settings-tab=");
2400
+ const isTabButton = firstStep.cursorTarget?.selector.includes(
2401
+ "[data-settings-tab="
2402
+ );
2177
2403
  if (firstStep.cursorTarget && (isNavigationButton || isTabButton)) {
2178
2404
  const cursorTarget = firstStep.cursorTarget;
2179
2405
  if (isTabButton && firstStep.navigation && onNavigate) {
@@ -2182,7 +2408,9 @@ ${userText}`
2182
2408
  const initialDelay = isTabButton ? 800 : 400;
2183
2409
  setTimeout(() => {
2184
2410
  const waitForElement = () => {
2185
- const element = document.querySelector(cursorTarget.selector);
2411
+ const element = document.querySelector(
2412
+ cursorTarget.selector
2413
+ );
2186
2414
  if (element && element.offsetParent !== null) {
2187
2415
  moveTo(cursorTarget);
2188
2416
  if (cursorTarget.onClick) {
@@ -2207,7 +2435,9 @@ ${userText}`
2207
2435
  const initialDelay = isDialogElement ? 700 : isSettingsTab ? 600 : 400;
2208
2436
  setTimeout(() => {
2209
2437
  const waitForElement = () => {
2210
- const element = document.querySelector(cursorTarget.selector);
2438
+ const element = document.querySelector(
2439
+ cursorTarget.selector
2440
+ );
2211
2441
  if (element && element.offsetParent !== null) {
2212
2442
  moveTo(cursorTarget);
2213
2443
  if (cursorTarget.onClick) {
@@ -2221,7 +2451,9 @@ ${userText}`
2221
2451
  moveTo(cursorTarget);
2222
2452
  if (cursorTarget.onClick) {
2223
2453
  setTimeout(() => {
2224
- const el = document.querySelector(cursorTarget.selector);
2454
+ const el = document.querySelector(
2455
+ cursorTarget.selector
2456
+ );
2225
2457
  if (el) el.click();
2226
2458
  }, 1e3);
2227
2459
  }
@@ -2258,7 +2490,12 @@ ${userText}`
2258
2490
  const id = Date.now() + 1;
2259
2491
  setMessages((prev) => [
2260
2492
  ...prev,
2261
- { id, role: "assistant", kind: "guideComplete", content: "Guide Complete" }
2493
+ {
2494
+ id,
2495
+ role: "assistant",
2496
+ kind: "guideComplete",
2497
+ content: "Guide Complete"
2498
+ }
2262
2499
  ]);
2263
2500
  setActiveGuide(void 0);
2264
2501
  setGuideComplete(true);
@@ -2277,7 +2514,9 @@ ${userText}`
2277
2514
  };
2278
2515
  setMessages((prev) => [...prev, draft]);
2279
2516
  const isNavigationButton = nextStep.cursorTarget?.selector.includes("[data-page=");
2280
- const isTabButton = nextStep.cursorTarget?.selector.includes("[data-settings-tab=");
2517
+ const isTabButton = nextStep.cursorTarget?.selector.includes(
2518
+ "[data-settings-tab="
2519
+ );
2281
2520
  if (nextStep.cursorTarget && (isNavigationButton || isTabButton)) {
2282
2521
  const cursorTarget = nextStep.cursorTarget;
2283
2522
  if (isTabButton && nextStep.navigation && onNavigate) {
@@ -2294,7 +2533,9 @@ ${userText}`
2294
2533
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2295
2534
  return;
2296
2535
  }
2297
- const element = document.querySelector(cursorTarget.selector);
2536
+ const element = document.querySelector(
2537
+ cursorTarget.selector
2538
+ );
2298
2539
  if (element && element.offsetParent !== null) {
2299
2540
  moveTo(cursorTarget);
2300
2541
  if (cursorTarget.onClick) {
@@ -2320,7 +2561,9 @@ ${userText}`
2320
2561
  const cursorTarget = nextStep.cursorTarget;
2321
2562
  const isDialogElement = cursorTarget.selector.includes("dialog") || cursorTarget.selector.includes("api-key-name-input");
2322
2563
  const isSettingsTab = cursorTarget.selector.includes("data-settings-tab");
2323
- const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(`data-settings-tab="${nextStep.navigation.subtab}"`);
2564
+ const navigationSetTab = nextStep.navigation?.subtab && isSettingsTab && cursorTarget.selector.includes(
2565
+ `data-settings-tab="${nextStep.navigation.subtab}"`
2566
+ );
2324
2567
  const shouldAutoClick = cursorTarget.onClick && !navigationSetTab;
2325
2568
  const hasNavigation = !!nextStep.navigation;
2326
2569
  const hasSubtab = !!nextStep.navigation?.subtab;
@@ -2336,7 +2579,9 @@ ${userText}`
2336
2579
  if (!currentGuide3 || currentGuide3.id !== guide.id || currentGuide3.stepIndex !== nextIndex) {
2337
2580
  return;
2338
2581
  }
2339
- const element = document.querySelector(cursorTarget.selector);
2582
+ const element = document.querySelector(
2583
+ cursorTarget.selector
2584
+ );
2340
2585
  if (element && element.offsetParent !== null) {
2341
2586
  moveTo(cursorTarget);
2342
2587
  if (shouldAutoClick) {
@@ -2358,7 +2603,9 @@ ${userText}`
2358
2603
  if (!currentGuide4 || currentGuide4.id !== guide.id || currentGuide4.stepIndex !== nextIndex) {
2359
2604
  return;
2360
2605
  }
2361
- const el = document.querySelector(cursorTarget.selector);
2606
+ const el = document.querySelector(
2607
+ cursorTarget.selector
2608
+ );
2362
2609
  if (el) el.click();
2363
2610
  }, 1e3);
2364
2611
  }
@@ -2390,10 +2637,17 @@ ${userText}`
2390
2637
  } else {
2391
2638
  hide();
2392
2639
  }
2393
- const existingMessages = messages.filter((m) => m.kind !== "guideStep" && m.kind !== "guideComplete");
2640
+ const existingMessages = messages.filter(
2641
+ (m) => m.kind !== "guideStep" && m.kind !== "guideComplete"
2642
+ );
2394
2643
  setMessages([
2395
2644
  ...existingMessages,
2396
- { id: Date.now(), role: "assistant", kind: "guideStep", content: prevStep.text }
2645
+ {
2646
+ id: Date.now(),
2647
+ role: "assistant",
2648
+ kind: "guideStep",
2649
+ content: prevStep.text
2650
+ }
2397
2651
  ]);
2398
2652
  }
2399
2653
  }
@@ -2416,6 +2670,7 @@ ${userText}`
2416
2670
  size: "sm",
2417
2671
  className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2418
2672
  onClick: () => {
2673
+ resetSession();
2419
2674
  setMessages([]);
2420
2675
  setPanelView("landing");
2421
2676
  setCurrentFolderId(void 0);
@@ -2438,919 +2693,1148 @@ ${userText}`
2438
2693
  )
2439
2694
  ] })
2440
2695
  ] }),
2441
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-full overflow-y-auto px-4", children: [
2442
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "py-3 transition-all duration-300", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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?" }) }),
2443
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "pb-4 px-4", children: [
2444
- panelView === "landing" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2445
- const iconColors = ["bg-blue-400", "bg-green-400", "bg-purple-400", "bg-orange-400", "bg-pink-400"];
2446
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2447
- Button,
2448
- {
2449
- type: "button",
2450
- size: "sm",
2451
- variant: "ghost",
2452
- className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2453
- onClick: () => sendTopic(question.prompt),
2454
- children: [
2455
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}` }),
2456
- question.label
2457
- ]
2458
- },
2459
- question.id
2460
- );
2461
- }) }) }),
2462
- panelView === "folder" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2463
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
2464
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2465
- Button,
2466
- {
2467
- type: "button",
2468
- size: "icon",
2469
- variant: "ghost",
2470
- className: "h-7 w-7 rounded-full hover:bg-gray-100",
2471
- onClick: closeFolder,
2472
- "aria-label": "Back to suggestions",
2473
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2474
- }
2475
- ),
2476
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2477
- ] }),
2478
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2479
- Button,
2480
- {
2481
- type: "button",
2482
- size: "sm",
2483
- variant: "secondary",
2484
- 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",
2485
- onClick: () => sendTopic(topic.prompt),
2486
- children: topic.label
2487
- },
2488
- topic.id
2489
- )) })
2490
- ] })
2491
- ] })
2492
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2493
- messages.map((message, index) => {
2494
- const isUser = message.role === "user";
2495
- const previousRole = index > 0 ? messages[index - 1].role : void 0;
2496
- const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2497
- const currentGuide = activeGuideRef.current || activeGuide;
2498
- let isCurrentGuideStep = false;
2499
- if (currentGuide && message.kind === "guideStep") {
2500
- if (message.guideStepIndex !== void 0) {
2501
- isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2502
- } else {
2503
- isCurrentGuideStep = index === messages.length - 1;
2504
- }
2505
- } else if (message.kind === "guideComplete") {
2506
- isCurrentGuideStep = index === messages.length - 1;
2507
- }
2508
- if (message.kind === "guideStep" && !isCurrentGuideStep) {
2509
- return null;
2510
- }
2511
- if (isUser) {
2512
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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);
2513
- }
2514
- if (message.kind === "searchSummary") {
2515
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AssistantSearchSummary, { title: message.title ?? "Search results", links: message.links ?? [] }) }, message.id);
2516
- }
2517
- if (message.kind === "guideComplete") {
2518
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2519
- "div",
2520
- {
2521
- ref: isCurrentGuideStep ? currentStepRef : null,
2522
- className: `${isRoleChange ? "mt-3" : ""}`,
2523
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("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: [
2524
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2525
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-medium text-green-800", children: message.content })
2526
- ] })
2527
- },
2528
- message.id
2529
- );
2530
- }
2531
- if (message.kind === "navigationAction") {
2532
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
2533
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2534
- message.navigationTarget && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2535
- Button,
2536
- {
2537
- type: "button",
2538
- size: "sm",
2539
- variant: "secondary",
2540
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2541
- onClick: () => message.navigationTarget && handleConfirmNavigation(message.navigationTarget),
2542
- children: [
2543
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
2544
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2545
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
2546
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
2547
- ] })
2548
- ]
2549
- }
2550
- ) })
2551
- ] }, message.id);
2552
- }
2553
- if (message.kind === "actionForm") {
2554
- const actionType = message.actionType;
2555
- const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2556
- if (message.isSubmitted) {
2557
- let successContent = "";
2558
- if (actionType === "updateCompanyInfo") {
2559
- successContent = "Company information has been updated successfully.";
2560
- } else if (actionType === "addApiKey") {
2561
- successContent = "API key has been added successfully.";
2562
- } else if (actionType === "addCustomer") {
2563
- successContent = "Customer has been added successfully.";
2564
- } else if (actionType === "enable2FA") {
2565
- successContent = "Two-factor authentication has been enabled successfully.";
2566
- } else if (actionType === "disable2FA") {
2567
- successContent = "Two-factor authentication has been disabled successfully.";
2568
- } else if (actionType === "changePassword") {
2569
- successContent = "Your password has been changed successfully.";
2570
- } else if (actionType === "revokeSession") {
2571
- successContent = "Session has been revoked successfully.";
2572
- } else if (actionType === "toggleNotification") {
2573
- successContent = "Notification preferences have been updated successfully.";
2574
- } else if (actionType === "connectIntegration") {
2575
- successContent = "Integration has been connected successfully.";
2576
- } else if (actionType === "disconnectIntegration") {
2577
- successContent = "Integration has been disconnected successfully.";
2578
- } else if (actionType === "addPaymentMethod") {
2579
- successContent = "Payment method has been added successfully.";
2580
- } else if (actionType === "removePaymentMethod") {
2581
- successContent = "Payment method has been removed successfully.";
2582
- } else if (actionType === "deleteApiKey") {
2583
- successContent = "API key has been deleted successfully.";
2584
- } else if (actionType === "addWebhook") {
2585
- successContent = "Webhook endpoint has been added successfully.";
2586
- } else if (actionType === "updateCurrency") {
2587
- successContent = "Currency preference has been updated successfully.";
2588
- } else if (actionType === "updateTimezone") {
2589
- successContent = "Timezone has been updated successfully.";
2590
- } else if (actionType === "refundPayment") {
2591
- successContent = "Refund has been processed successfully.";
2592
- } else if (actionType === "exportCertificate") {
2593
- successContent = "Certificate of Incorporation has been downloaded successfully.";
2594
- } else if (actionType === "createSubscription") {
2595
- successContent = "Subscription has been created successfully.";
2596
- } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2597
- successContent = "Block rule has been updated successfully.";
2598
- } else {
2599
- successContent = "Action completed successfully.";
2600
- }
2601
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent }) }, message.id);
2602
- }
2603
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`, children: [
2604
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2605
- actionType === "updateCompanyInfo" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2606
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2607
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2608
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2609
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2610
- Input,
2611
- {
2612
- placeholder: "Acme Corporation",
2613
- value: formData.companyName || "",
2614
- onChange: (e) => setActionFormData({ ...actionFormData, companyName: e.target.value }),
2615
- className: "h-8 text-xs border-gray-200"
2616
- }
2617
- )
2618
- ] }),
2619
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2620
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2621
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2622
- Input,
2623
- {
2624
- type: "email",
2625
- placeholder: "contact@acme.com",
2626
- value: formData.email || "",
2627
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2628
- className: "h-8 text-xs border-gray-200"
2629
- }
2630
- )
2631
- ] })
2632
- ] }),
2633
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2634
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2696
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2697
+ "div",
2698
+ {
2699
+ 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",
2700
+ children: isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "w-full overflow-y-auto px-4", children: [
2701
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "py-3 transition-all duration-300", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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?" }) }),
2702
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "pb-4 px-4", children: [
2703
+ panelView === "landing" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2704
+ const iconColors = [
2705
+ "bg-blue-400",
2706
+ "bg-green-400",
2707
+ "bg-purple-400",
2708
+ "bg-orange-400",
2709
+ "bg-pink-400"
2710
+ ];
2711
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2712
+ Button,
2713
+ {
2714
+ type: "button",
2715
+ size: "sm",
2716
+ variant: "ghost",
2717
+ className: "w-full justify-start rounded-lg px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2718
+ onClick: () => sendTopic(question.prompt),
2719
+ children: [
2720
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2721
+ "span",
2722
+ {
2723
+ className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}`
2724
+ }
2725
+ ),
2726
+ question.label
2727
+ ]
2728
+ },
2729
+ question.id
2730
+ );
2731
+ }) }) }),
2732
+ panelView === "folder" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2733
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-3 flex items-center gap-2", children: [
2635
2734
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2636
- Input,
2735
+ Button,
2637
2736
  {
2638
- placeholder: "123 Main St, San Francisco, CA",
2639
- value: formData.address || "",
2640
- onChange: (e) => setActionFormData({ ...actionFormData, address: e.target.value }),
2641
- className: "h-8 text-xs border-gray-200"
2737
+ type: "button",
2738
+ size: "icon",
2739
+ variant: "ghost",
2740
+ className: "h-7 w-7 rounded-full hover:bg-gray-100",
2741
+ onClick: closeFolder,
2742
+ "aria-label": "Back to suggestions",
2743
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2642
2744
  }
2643
- )
2745
+ ),
2746
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2644
2747
  ] }),
2645
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2646
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2647
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2649
- Input,
2650
- {
2651
- type: "tel",
2652
- placeholder: "+1 (555) 123-4567",
2653
- value: formData.phone || "",
2654
- onChange: (e) => setActionFormData({ ...actionFormData, phone: e.target.value }),
2655
- className: "h-8 text-xs border-gray-200"
2656
- }
2657
- )
2658
- ] }),
2659
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2660
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2661
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2662
- Input,
2663
- {
2664
- type: "url",
2665
- placeholder: "https://acme.com",
2666
- value: formData.website || "",
2667
- onChange: (e) => setActionFormData({ ...actionFormData, website: e.target.value }),
2668
- className: "h-8 text-xs border-gray-200"
2669
- }
2670
- )
2671
- ] })
2672
- ] })
2673
- ] }),
2674
- actionType === "addApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2675
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2676
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2677
- Input,
2748
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2749
+ Button,
2678
2750
  {
2679
- placeholder: "Production Key",
2680
- value: formData.name || "",
2681
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2682
- className: "h-8 text-xs border-gray-200"
2683
- }
2684
- )
2685
- ] }) }),
2686
- actionType === "addCustomer" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2687
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2688
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2689
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2690
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2691
- Input,
2692
- {
2693
- placeholder: "Acme Corporation",
2694
- value: formData.name || "",
2695
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2696
- className: "h-8 text-xs border-gray-200"
2697
- }
2698
- )
2699
- ] }),
2700
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2701
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2702
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2703
- Input,
2751
+ type: "button",
2752
+ size: "sm",
2753
+ variant: "secondary",
2754
+ 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",
2755
+ onClick: () => sendTopic(topic.prompt),
2756
+ children: topic.label
2757
+ },
2758
+ topic.id
2759
+ )) })
2760
+ ] })
2761
+ ] })
2762
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2763
+ messages.map((message, index) => {
2764
+ const isUser = message.role === "user";
2765
+ const previousRole = index > 0 ? messages[index - 1].role : void 0;
2766
+ const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2767
+ const currentGuide = activeGuideRef.current || activeGuide;
2768
+ let isCurrentGuideStep = false;
2769
+ if (currentGuide && message.kind === "guideStep") {
2770
+ if (message.guideStepIndex !== void 0) {
2771
+ isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2772
+ } else {
2773
+ isCurrentGuideStep = index === messages.length - 1;
2774
+ }
2775
+ } else if (message.kind === "guideComplete") {
2776
+ isCurrentGuideStep = index === messages.length - 1;
2777
+ }
2778
+ if (message.kind === "guideStep" && !isCurrentGuideStep) {
2779
+ return null;
2780
+ }
2781
+ if (isUser) {
2782
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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);
2783
+ }
2784
+ if (message.kind === "searchSummary") {
2785
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2786
+ "div",
2787
+ {
2788
+ className: `${isRoleChange ? "mt-3" : ""}`,
2789
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2790
+ AssistantSearchSummary,
2704
2791
  {
2705
- type: "email",
2706
- placeholder: "contact@acme.com",
2707
- value: formData.email || "",
2708
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2709
- className: "h-8 text-xs border-gray-200"
2792
+ title: message.title ?? "Search results",
2793
+ links: message.links ?? []
2710
2794
  }
2711
2795
  )
2712
- ] })
2713
- ] }),
2714
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2715
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2716
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2717
- Input,
2718
- {
2719
- placeholder: "San Francisco, CA",
2720
- value: formData.location || "",
2721
- onChange: (e) => setActionFormData({ ...actionFormData, location: e.target.value }),
2722
- className: "h-8 text-xs border-gray-200"
2723
- }
2724
- )
2725
- ] }),
2726
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2727
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
2728
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2729
- "select",
2730
- {
2731
- value: formData.subscription || "Starter",
2732
- onChange: (e) => setActionFormData({ ...actionFormData, subscription: e.target.value }),
2733
- 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",
2734
- children: [
2735
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter" }),
2736
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional" }),
2737
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise" })
2738
- ]
2739
- }
2740
- )
2741
- ] })
2742
- ] }),
2743
- (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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." }) }),
2744
- actionType === "changePassword" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2745
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2746
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
2747
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2748
- Input,
2749
- {
2750
- type: "password",
2751
- value: formData.currentPassword || "",
2752
- onChange: (e) => setActionFormData({ ...actionFormData, currentPassword: e.target.value }),
2753
- className: "h-8 text-xs border-gray-200"
2754
- }
2755
- )
2756
- ] }),
2757
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2758
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
2759
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2760
- Input,
2761
- {
2762
- type: "password",
2763
- value: formData.newPassword || "",
2764
- onChange: (e) => setActionFormData({ ...actionFormData, newPassword: e.target.value }),
2765
- className: "h-8 text-xs border-gray-200"
2766
- }
2767
- )
2768
- ] }),
2769
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2770
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
2771
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2772
- Input,
2773
- {
2774
- type: "password",
2775
- value: formData.confirmPassword || "",
2776
- onChange: (e) => setActionFormData({ ...actionFormData, confirmPassword: e.target.value }),
2777
- className: "h-8 text-xs border-gray-200"
2778
- }
2779
- )
2780
- ] })
2781
- ] }),
2782
- actionType === "toggleNotification" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2783
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2784
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
2785
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2786
- "select",
2787
- {
2788
- value: formData.notificationType || "paymentReceived",
2789
- onChange: (e) => setActionFormData({ ...actionFormData, notificationType: e.target.value }),
2790
- 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",
2791
- children: [
2792
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentReceived", children: "Payment Received" }),
2793
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentFailed", children: "Payment Failed" }),
2794
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "invoicePaid", children: "Invoice Paid" }),
2795
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthlySummary", children: "Monthly Summary" }),
2796
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "productUpdates", children: "Product Updates" })
2797
- ]
2798
- }
2799
- )
2800
- ] }),
2801
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
2802
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2803
- "input",
2804
- {
2805
- type: "checkbox",
2806
- checked: formData.enabled !== false,
2807
- onChange: (e) => setActionFormData({ ...actionFormData, enabled: e.target.checked }),
2808
- className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
2809
- }
2810
- ),
2811
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs text-black", children: "Enable this notification" })
2812
- ] })
2813
- ] }),
2814
- (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2815
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
2816
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2817
- "select",
2796
+ },
2797
+ message.id
2798
+ );
2799
+ }
2800
+ if (message.kind === "guideComplete") {
2801
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2802
+ "div",
2818
2803
  {
2819
- value: formData.integrationName || "Slack",
2820
- onChange: (e) => setActionFormData({ ...actionFormData, integrationName: e.target.value }),
2821
- 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",
2804
+ ref: isCurrentGuideStep ? currentStepRef : null,
2805
+ className: `${isRoleChange ? "mt-3" : ""}`,
2806
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("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: [
2807
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2808
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-medium text-green-800", children: message.content })
2809
+ ] })
2810
+ },
2811
+ message.id
2812
+ );
2813
+ }
2814
+ if (message.kind === "navigationAction") {
2815
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2816
+ "div",
2817
+ {
2818
+ className: `${isRoleChange ? "mt-3" : ""}`,
2822
2819
  children: [
2823
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Slack", children: "Slack" }),
2824
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Zapier", children: "Zapier" }),
2825
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Webhook", children: "Webhook" })
2820
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2821
+ message.navigationTarget && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2822
+ Button,
2823
+ {
2824
+ type: "button",
2825
+ size: "sm",
2826
+ variant: "secondary",
2827
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2828
+ onClick: () => message.navigationTarget && handleConfirmNavigation(
2829
+ message.navigationTarget
2830
+ ),
2831
+ children: [
2832
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
2833
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2834
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
2835
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
2836
+ ] })
2837
+ ]
2838
+ }
2839
+ ) })
2826
2840
  ]
2841
+ },
2842
+ message.id
2843
+ );
2844
+ }
2845
+ if (message.kind === "actionForm") {
2846
+ const actionType = message.actionType;
2847
+ const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2848
+ if (message.isSubmitted) {
2849
+ let successContent = "";
2850
+ if (actionType === "updateCompanyInfo") {
2851
+ successContent = "Company information has been updated successfully.";
2852
+ } else if (actionType === "addApiKey") {
2853
+ successContent = "API key has been added successfully.";
2854
+ } else if (actionType === "addCustomer") {
2855
+ successContent = "Customer has been added successfully.";
2856
+ } else if (actionType === "enable2FA") {
2857
+ successContent = "Two-factor authentication has been enabled successfully.";
2858
+ } else if (actionType === "disable2FA") {
2859
+ successContent = "Two-factor authentication has been disabled successfully.";
2860
+ } else if (actionType === "changePassword") {
2861
+ successContent = "Your password has been changed successfully.";
2862
+ } else if (actionType === "revokeSession") {
2863
+ successContent = "Session has been revoked successfully.";
2864
+ } else if (actionType === "toggleNotification") {
2865
+ successContent = "Notification preferences have been updated successfully.";
2866
+ } else if (actionType === "connectIntegration") {
2867
+ successContent = "Integration has been connected successfully.";
2868
+ } else if (actionType === "disconnectIntegration") {
2869
+ successContent = "Integration has been disconnected successfully.";
2870
+ } else if (actionType === "addPaymentMethod") {
2871
+ successContent = "Payment method has been added successfully.";
2872
+ } else if (actionType === "removePaymentMethod") {
2873
+ successContent = "Payment method has been removed successfully.";
2874
+ } else if (actionType === "deleteApiKey") {
2875
+ successContent = "API key has been deleted successfully.";
2876
+ } else if (actionType === "addWebhook") {
2877
+ successContent = "Webhook endpoint has been added successfully.";
2878
+ } else if (actionType === "updateCurrency") {
2879
+ successContent = "Currency preference has been updated successfully.";
2880
+ } else if (actionType === "updateTimezone") {
2881
+ successContent = "Timezone has been updated successfully.";
2882
+ } else if (actionType === "refundPayment") {
2883
+ successContent = "Refund has been processed successfully.";
2884
+ } else if (actionType === "exportCertificate") {
2885
+ successContent = "Certificate of Incorporation has been downloaded successfully.";
2886
+ } else if (actionType === "createSubscription") {
2887
+ successContent = "Subscription has been created successfully.";
2888
+ } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2889
+ successContent = "Block rule has been updated successfully.";
2890
+ } else {
2891
+ successContent = "Action completed successfully.";
2827
2892
  }
2828
- )
2829
- ] }) }),
2830
- actionType === "addPaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2831
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2832
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
2833
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2834
- Input,
2835
- {
2836
- placeholder: "1234 5678 9012 3456",
2837
- value: formData.cardNumber || "",
2838
- onChange: (e) => setActionFormData({ ...actionFormData, cardNumber: e.target.value }),
2839
- className: "h-8 text-xs border-gray-200"
2840
- }
2841
- )
2842
- ] }),
2843
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2844
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
2845
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2846
- Input,
2847
- {
2848
- placeholder: "MM/YY",
2849
- value: formData.expiryDate || "",
2850
- onChange: (e) => setActionFormData({ ...actionFormData, expiryDate: e.target.value }),
2851
- className: "h-8 text-xs border-gray-200"
2852
- }
2853
- )
2854
- ] })
2855
- ] }),
2856
- actionType === "removePaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
2857
- actionType === "refundPayment" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2858
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2859
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
2860
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2861
- Input,
2893
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2894
+ "div",
2862
2895
  {
2863
- placeholder: "e.g., txn_1234 or Acme Corp",
2864
- value: formData.transactionId || formData.customer || "",
2865
- onChange: (e) => {
2866
- const value = e.target.value;
2867
- if (value.startsWith("txn_") || /^\d+$/.test(value)) {
2868
- setActionFormData({ ...actionFormData, transactionId: value, customer: void 0 });
2869
- } else {
2870
- setActionFormData({ ...actionFormData, customer: value, transactionId: void 0 });
2871
- }
2872
- },
2873
- className: "h-8 text-xs border-gray-200"
2874
- }
2875
- )
2876
- ] }),
2877
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2878
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
2879
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2880
- Input,
2881
- {
2882
- placeholder: "$0.00",
2883
- value: formData.amount || "",
2884
- onChange: (e) => setActionFormData({ ...actionFormData, amount: e.target.value }),
2885
- className: "h-8 text-xs border-gray-200"
2886
- }
2887
- )
2888
- ] }),
2889
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2890
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
2891
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2892
- Input,
2893
- {
2894
- placeholder: "e.g., Customer request",
2895
- value: formData.reason || "",
2896
- onChange: (e) => setActionFormData({ ...actionFormData, reason: e.target.value }),
2897
- className: "h-8 text-xs border-gray-200"
2898
- }
2899
- )
2900
- ] })
2901
- ] }),
2902
- actionType === "deleteApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2903
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2904
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
2905
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2906
- Input,
2907
- {
2908
- placeholder: "Production Key",
2909
- value: formData.keyId || formData.name || "",
2910
- onChange: (e) => setActionFormData({ ...actionFormData, keyId: e.target.value, name: e.target.value }),
2911
- className: "h-8 text-xs border-gray-200"
2912
- }
2913
- )
2914
- ] }),
2915
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
2916
- ] }),
2917
- actionType === "addWebhook" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2918
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2919
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
2920
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2921
- Input,
2922
- {
2923
- type: "url",
2924
- placeholder: "https://example.com/webhook",
2925
- value: formData.url || "",
2926
- onChange: (e) => setActionFormData({ ...actionFormData, url: e.target.value }),
2927
- className: "h-8 text-xs border-gray-200"
2928
- }
2929
- )
2930
- ] }),
2931
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2932
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
2933
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2934
- Input,
2935
- {
2936
- placeholder: "Production Webhook",
2937
- value: formData.name || "",
2938
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2939
- className: "h-8 text-xs border-gray-200"
2940
- }
2941
- )
2942
- ] })
2943
- ] }),
2944
- actionType === "updateCurrency" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2945
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
2946
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2947
- "select",
2896
+ className: `${isRoleChange ? "mt-3" : ""}`,
2897
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent })
2898
+ },
2899
+ message.id
2900
+ );
2901
+ }
2902
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2903
+ "div",
2948
2904
  {
2949
- value: formData.currency || "USD",
2950
- onChange: (e) => setActionFormData({ ...actionFormData, currency: e.target.value }),
2951
- 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",
2905
+ className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`,
2952
2906
  children: [
2953
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "USD", children: "USD ($)" }),
2954
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "EUR", children: "EUR (\u20AC)" }),
2955
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "GBP", children: "GBP (\xA3)" }),
2956
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "JPY", children: "JPY (\xA5)" })
2907
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2908
+ actionType === "updateCompanyInfo" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2909
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2910
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2911
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2912
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2913
+ Input,
2914
+ {
2915
+ placeholder: "Acme Corporation",
2916
+ value: formData.companyName || "",
2917
+ onChange: (e) => setActionFormData({
2918
+ ...actionFormData,
2919
+ companyName: e.target.value
2920
+ }),
2921
+ className: "h-8 text-xs border-gray-200"
2922
+ }
2923
+ )
2924
+ ] }),
2925
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2926
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2927
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2928
+ Input,
2929
+ {
2930
+ type: "email",
2931
+ placeholder: "contact@acme.com",
2932
+ value: formData.email || "",
2933
+ onChange: (e) => setActionFormData({
2934
+ ...actionFormData,
2935
+ email: e.target.value
2936
+ }),
2937
+ className: "h-8 text-xs border-gray-200"
2938
+ }
2939
+ )
2940
+ ] })
2941
+ ] }),
2942
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2943
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2944
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2945
+ Input,
2946
+ {
2947
+ placeholder: "123 Main St, San Francisco, CA",
2948
+ value: formData.address || "",
2949
+ onChange: (e) => setActionFormData({
2950
+ ...actionFormData,
2951
+ address: e.target.value
2952
+ }),
2953
+ className: "h-8 text-xs border-gray-200"
2954
+ }
2955
+ )
2956
+ ] }),
2957
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
2958
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2959
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2960
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2961
+ Input,
2962
+ {
2963
+ type: "tel",
2964
+ placeholder: "+1 (555) 123-4567",
2965
+ value: formData.phone || "",
2966
+ onChange: (e) => setActionFormData({
2967
+ ...actionFormData,
2968
+ phone: e.target.value
2969
+ }),
2970
+ className: "h-8 text-xs border-gray-200"
2971
+ }
2972
+ )
2973
+ ] }),
2974
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2975
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2976
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2977
+ Input,
2978
+ {
2979
+ type: "url",
2980
+ placeholder: "https://acme.com",
2981
+ value: formData.website || "",
2982
+ onChange: (e) => setActionFormData({
2983
+ ...actionFormData,
2984
+ website: e.target.value
2985
+ }),
2986
+ className: "h-8 text-xs border-gray-200"
2987
+ }
2988
+ )
2989
+ ] })
2990
+ ] })
2991
+ ] }),
2992
+ actionType === "addApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2993
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2994
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2995
+ Input,
2996
+ {
2997
+ placeholder: "Production Key",
2998
+ value: formData.name || "",
2999
+ onChange: (e) => setActionFormData({
3000
+ ...actionFormData,
3001
+ name: e.target.value
3002
+ }),
3003
+ className: "h-8 text-xs border-gray-200"
3004
+ }
3005
+ )
3006
+ ] }) }),
3007
+ actionType === "addCustomer" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
3008
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
3009
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3010
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
3011
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3012
+ Input,
3013
+ {
3014
+ placeholder: "Acme Corporation",
3015
+ value: formData.name || "",
3016
+ onChange: (e) => setActionFormData({
3017
+ ...actionFormData,
3018
+ name: e.target.value
3019
+ }),
3020
+ className: "h-8 text-xs border-gray-200"
3021
+ }
3022
+ )
3023
+ ] }),
3024
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3025
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
3026
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3027
+ Input,
3028
+ {
3029
+ type: "email",
3030
+ placeholder: "contact@acme.com",
3031
+ value: formData.email || "",
3032
+ onChange: (e) => setActionFormData({
3033
+ ...actionFormData,
3034
+ email: e.target.value
3035
+ }),
3036
+ className: "h-8 text-xs border-gray-200"
3037
+ }
3038
+ )
3039
+ ] })
3040
+ ] }),
3041
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3042
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
3043
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3044
+ Input,
3045
+ {
3046
+ placeholder: "San Francisco, CA",
3047
+ value: formData.location || "",
3048
+ onChange: (e) => setActionFormData({
3049
+ ...actionFormData,
3050
+ location: e.target.value
3051
+ }),
3052
+ className: "h-8 text-xs border-gray-200"
3053
+ }
3054
+ )
3055
+ ] }),
3056
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3057
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
3058
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3059
+ "select",
3060
+ {
3061
+ value: formData.subscription || "Starter",
3062
+ onChange: (e) => setActionFormData({
3063
+ ...actionFormData,
3064
+ subscription: e.target.value
3065
+ }),
3066
+ 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",
3067
+ children: [
3068
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter" }),
3069
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional" }),
3070
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise" })
3071
+ ]
3072
+ }
3073
+ )
3074
+ ] })
3075
+ ] }),
3076
+ (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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." }) }),
3077
+ actionType === "changePassword" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3078
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3079
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
3080
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3081
+ Input,
3082
+ {
3083
+ type: "password",
3084
+ value: formData.currentPassword || "",
3085
+ onChange: (e) => setActionFormData({
3086
+ ...actionFormData,
3087
+ currentPassword: e.target.value
3088
+ }),
3089
+ className: "h-8 text-xs border-gray-200"
3090
+ }
3091
+ )
3092
+ ] }),
3093
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3094
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
3095
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3096
+ Input,
3097
+ {
3098
+ type: "password",
3099
+ value: formData.newPassword || "",
3100
+ onChange: (e) => setActionFormData({
3101
+ ...actionFormData,
3102
+ newPassword: e.target.value
3103
+ }),
3104
+ className: "h-8 text-xs border-gray-200"
3105
+ }
3106
+ )
3107
+ ] }),
3108
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3109
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
3110
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3111
+ Input,
3112
+ {
3113
+ type: "password",
3114
+ value: formData.confirmPassword || "",
3115
+ onChange: (e) => setActionFormData({
3116
+ ...actionFormData,
3117
+ confirmPassword: e.target.value
3118
+ }),
3119
+ className: "h-8 text-xs border-gray-200"
3120
+ }
3121
+ )
3122
+ ] })
3123
+ ] }),
3124
+ actionType === "toggleNotification" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3125
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3126
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
3127
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3128
+ "select",
3129
+ {
3130
+ value: formData.notificationType || "paymentReceived",
3131
+ onChange: (e) => setActionFormData({
3132
+ ...actionFormData,
3133
+ notificationType: e.target.value
3134
+ }),
3135
+ 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",
3136
+ children: [
3137
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentReceived", children: "Payment Received" }),
3138
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "paymentFailed", children: "Payment Failed" }),
3139
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "invoicePaid", children: "Invoice Paid" }),
3140
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthlySummary", children: "Monthly Summary" }),
3141
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "productUpdates", children: "Product Updates" })
3142
+ ]
3143
+ }
3144
+ )
3145
+ ] }),
3146
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
3147
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3148
+ "input",
3149
+ {
3150
+ type: "checkbox",
3151
+ checked: formData.enabled !== false,
3152
+ onChange: (e) => setActionFormData({
3153
+ ...actionFormData,
3154
+ enabled: e.target.checked
3155
+ }),
3156
+ className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
3157
+ }
3158
+ ),
3159
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs text-black", children: "Enable this notification" })
3160
+ ] })
3161
+ ] }),
3162
+ (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3163
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
3164
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3165
+ "select",
3166
+ {
3167
+ value: formData.integrationName || "Slack",
3168
+ onChange: (e) => setActionFormData({
3169
+ ...actionFormData,
3170
+ integrationName: e.target.value
3171
+ }),
3172
+ 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",
3173
+ children: [
3174
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Slack", children: "Slack" }),
3175
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Zapier", children: "Zapier" }),
3176
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Webhook", children: "Webhook" })
3177
+ ]
3178
+ }
3179
+ )
3180
+ ] }) }),
3181
+ actionType === "addPaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3182
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3183
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
3184
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3185
+ Input,
3186
+ {
3187
+ placeholder: "1234 5678 9012 3456",
3188
+ value: formData.cardNumber || "",
3189
+ onChange: (e) => setActionFormData({
3190
+ ...actionFormData,
3191
+ cardNumber: e.target.value
3192
+ }),
3193
+ className: "h-8 text-xs border-gray-200"
3194
+ }
3195
+ )
3196
+ ] }),
3197
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3198
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
3199
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3200
+ Input,
3201
+ {
3202
+ placeholder: "MM/YY",
3203
+ value: formData.expiryDate || "",
3204
+ onChange: (e) => setActionFormData({
3205
+ ...actionFormData,
3206
+ expiryDate: e.target.value
3207
+ }),
3208
+ className: "h-8 text-xs border-gray-200"
3209
+ }
3210
+ )
3211
+ ] })
3212
+ ] }),
3213
+ actionType === "removePaymentMethod" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
3214
+ actionType === "refundPayment" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3215
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3216
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
3217
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3218
+ Input,
3219
+ {
3220
+ placeholder: "e.g., txn_1234 or Acme Corp",
3221
+ value: formData.transactionId || formData.customer || "",
3222
+ onChange: (e) => {
3223
+ const value = e.target.value;
3224
+ if (value.startsWith("txn_") || /^\d+$/.test(value)) {
3225
+ setActionFormData({
3226
+ ...actionFormData,
3227
+ transactionId: value,
3228
+ customer: void 0
3229
+ });
3230
+ } else {
3231
+ setActionFormData({
3232
+ ...actionFormData,
3233
+ customer: value,
3234
+ transactionId: void 0
3235
+ });
3236
+ }
3237
+ },
3238
+ className: "h-8 text-xs border-gray-200"
3239
+ }
3240
+ )
3241
+ ] }),
3242
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3243
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
3244
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3245
+ Input,
3246
+ {
3247
+ placeholder: "$0.00",
3248
+ value: formData.amount || "",
3249
+ onChange: (e) => setActionFormData({
3250
+ ...actionFormData,
3251
+ amount: e.target.value
3252
+ }),
3253
+ className: "h-8 text-xs border-gray-200"
3254
+ }
3255
+ )
3256
+ ] }),
3257
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3258
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
3259
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3260
+ Input,
3261
+ {
3262
+ placeholder: "e.g., Customer request",
3263
+ value: formData.reason || "",
3264
+ onChange: (e) => setActionFormData({
3265
+ ...actionFormData,
3266
+ reason: e.target.value
3267
+ }),
3268
+ className: "h-8 text-xs border-gray-200"
3269
+ }
3270
+ )
3271
+ ] })
3272
+ ] }),
3273
+ actionType === "deleteApiKey" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3274
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3275
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
3276
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3277
+ Input,
3278
+ {
3279
+ placeholder: "Production Key",
3280
+ value: formData.keyId || formData.name || "",
3281
+ onChange: (e) => setActionFormData({
3282
+ ...actionFormData,
3283
+ keyId: e.target.value,
3284
+ name: e.target.value
3285
+ }),
3286
+ className: "h-8 text-xs border-gray-200"
3287
+ }
3288
+ )
3289
+ ] }),
3290
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
3291
+ ] }),
3292
+ actionType === "addWebhook" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3293
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3294
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
3295
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3296
+ Input,
3297
+ {
3298
+ type: "url",
3299
+ placeholder: "https://example.com/webhook",
3300
+ value: formData.url || "",
3301
+ onChange: (e) => setActionFormData({
3302
+ ...actionFormData,
3303
+ url: e.target.value
3304
+ }),
3305
+ className: "h-8 text-xs border-gray-200"
3306
+ }
3307
+ )
3308
+ ] }),
3309
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3310
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
3311
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3312
+ Input,
3313
+ {
3314
+ placeholder: "Production Webhook",
3315
+ value: formData.name || "",
3316
+ onChange: (e) => setActionFormData({
3317
+ ...actionFormData,
3318
+ name: e.target.value
3319
+ }),
3320
+ className: "h-8 text-xs border-gray-200"
3321
+ }
3322
+ )
3323
+ ] })
3324
+ ] }),
3325
+ actionType === "updateCurrency" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3326
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
3327
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3328
+ "select",
3329
+ {
3330
+ value: formData.currency || "USD",
3331
+ onChange: (e) => setActionFormData({
3332
+ ...actionFormData,
3333
+ currency: e.target.value
3334
+ }),
3335
+ 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",
3336
+ children: [
3337
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "USD", children: "USD ($)" }),
3338
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "EUR", children: "EUR (\u20AC)" }),
3339
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "GBP", children: "GBP (\xA3)" }),
3340
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "JPY", children: "JPY (\xA5)" })
3341
+ ]
3342
+ }
3343
+ )
3344
+ ] }) }),
3345
+ actionType === "updateTimezone" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3346
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
3347
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3348
+ "select",
3349
+ {
3350
+ value: formData.timezone || "America/Los_Angeles",
3351
+ onChange: (e) => setActionFormData({
3352
+ ...actionFormData,
3353
+ timezone: e.target.value
3354
+ }),
3355
+ 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",
3356
+ children: [
3357
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
3358
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
3359
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Europe/London", children: "GMT" }),
3360
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Asia/Tokyo", children: "JST" })
3361
+ ]
3362
+ }
3363
+ )
3364
+ ] }) }),
3365
+ actionType === "revokeSession" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3366
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3367
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
3368
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3369
+ Input,
3370
+ {
3371
+ placeholder: "MacBook Pro",
3372
+ value: formData.device || "",
3373
+ onChange: (e) => setActionFormData({
3374
+ ...actionFormData,
3375
+ device: e.target.value
3376
+ }),
3377
+ className: "h-8 text-xs border-gray-200"
3378
+ }
3379
+ )
3380
+ ] }),
3381
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
3382
+ ] }),
3383
+ actionType === "createSubscription" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3384
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3385
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
3386
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3387
+ Input,
3388
+ {
3389
+ type: "email",
3390
+ placeholder: "customer@example.com",
3391
+ value: formData.customerEmail || "",
3392
+ onChange: (e) => setActionFormData({
3393
+ ...actionFormData,
3394
+ customerEmail: e.target.value
3395
+ }),
3396
+ className: "h-8 text-xs border-gray-200"
3397
+ }
3398
+ )
3399
+ ] }),
3400
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3401
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
3402
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3403
+ "select",
3404
+ {
3405
+ value: formData.plan || "Starter",
3406
+ onChange: (e) => setActionFormData({
3407
+ ...actionFormData,
3408
+ plan: e.target.value
3409
+ }),
3410
+ 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",
3411
+ children: [
3412
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter ($29/mo)" }),
3413
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional ($99/mo)" }),
3414
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
3415
+ ]
3416
+ }
3417
+ )
3418
+ ] }),
3419
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3420
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
3421
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3422
+ "select",
3423
+ {
3424
+ value: formData.billingCycle || "monthly",
3425
+ onChange: (e) => setActionFormData({
3426
+ ...actionFormData,
3427
+ billingCycle: e.target.value
3428
+ }),
3429
+ 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",
3430
+ children: [
3431
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthly", children: "Monthly" }),
3432
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "yearly", children: "Yearly (Save 15%)" })
3433
+ ]
3434
+ }
3435
+ )
3436
+ ] })
3437
+ ] }),
3438
+ actionType === "exportCertificate" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3439
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
3440
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3441
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
3442
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3443
+ "select",
3444
+ {
3445
+ value: formData.format || "pdf",
3446
+ onChange: (e) => setActionFormData({
3447
+ ...actionFormData,
3448
+ format: e.target.value
3449
+ }),
3450
+ 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",
3451
+ children: [
3452
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "pdf", children: "PDF" }),
3453
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "json", children: "JSON" })
3454
+ ]
3455
+ }
3456
+ )
3457
+ ] })
3458
+ ] }),
3459
+ (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3460
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3461
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3462
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3463
+ "select",
3464
+ {
3465
+ value: formData.ruleId || "rule_1",
3466
+ onChange: (e) => setActionFormData({
3467
+ ...actionFormData,
3468
+ ruleId: e.target.value
3469
+ }),
3470
+ 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",
3471
+ children: [
3472
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3473
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3474
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3475
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3476
+ ]
3477
+ }
3478
+ )
3479
+ ] }),
3480
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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." })
3481
+ ] }),
3482
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3483
+ Button,
3484
+ {
3485
+ type: "button",
3486
+ size: "sm",
3487
+ variant: "secondary",
3488
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3489
+ onClick: handleActionSubmit,
3490
+ children: [
3491
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
3492
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3493
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3494
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3495
+ ] })
3496
+ ]
3497
+ }
3498
+ ) })
2957
3499
  ]
2958
- }
2959
- )
2960
- ] }) }),
2961
- actionType === "updateTimezone" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2962
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
2963
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2964
- "select",
3500
+ },
3501
+ message.id
3502
+ );
3503
+ }
3504
+ if (message.kind === "bulkPreview" && message.csvData) {
3505
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3506
+ "div",
2965
3507
  {
2966
- value: formData.timezone || "America/Los_Angeles",
2967
- onChange: (e) => setActionFormData({ ...actionFormData, timezone: e.target.value }),
2968
- 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",
3508
+ className: `${isRoleChange ? "mt-3" : ""}`,
2969
3509
  children: [
2970
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
2971
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
2972
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Europe/London", children: "GMT" }),
2973
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Asia/Tokyo", children: "JST" })
2974
- ]
2975
- }
2976
- )
2977
- ] }) }),
2978
- actionType === "revokeSession" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2979
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2980
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
2981
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2982
- Input,
2983
- {
2984
- placeholder: "MacBook Pro",
2985
- value: formData.device || "",
2986
- onChange: (e) => setActionFormData({ ...actionFormData, device: e.target.value }),
2987
- className: "h-8 text-xs border-gray-200"
2988
- }
2989
- )
2990
- ] }),
2991
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
2992
- ] }),
2993
- actionType === "createSubscription" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2994
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2995
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
2996
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2997
- Input,
2998
- {
2999
- type: "email",
3000
- placeholder: "customer@example.com",
3001
- value: formData.customerEmail || "",
3002
- onChange: (e) => setActionFormData({ ...actionFormData, customerEmail: e.target.value }),
3003
- className: "h-8 text-xs border-gray-200"
3004
- }
3005
- )
3006
- ] }),
3007
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3008
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
3009
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3010
- "select",
3011
- {
3012
- value: formData.plan || "Starter",
3013
- onChange: (e) => setActionFormData({ ...actionFormData, plan: e.target.value }),
3014
- 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",
3015
- children: [
3016
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Starter", children: "Starter ($29/mo)" }),
3017
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Professional", children: "Professional ($99/mo)" }),
3018
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
3019
- ]
3020
- }
3021
- )
3022
- ] }),
3023
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3024
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
3025
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3026
- "select",
3027
- {
3028
- value: formData.billingCycle || "monthly",
3029
- onChange: (e) => setActionFormData({ ...actionFormData, billingCycle: e.target.value }),
3030
- 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",
3031
- children: [
3032
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "monthly", children: "Monthly" }),
3033
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "yearly", children: "Yearly (Save 15%)" })
3034
- ]
3035
- }
3036
- )
3037
- ] })
3038
- ] }),
3039
- actionType === "exportCertificate" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3040
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
3041
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3042
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
3043
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3044
- "select",
3045
- {
3046
- value: formData.format || "pdf",
3047
- onChange: (e) => setActionFormData({ ...actionFormData, format: e.target.value }),
3048
- 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",
3049
- children: [
3050
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "pdf", children: "PDF" }),
3051
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "json", children: "JSON" })
3052
- ]
3053
- }
3054
- )
3055
- ] })
3056
- ] }),
3057
- (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3058
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
3059
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3060
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3061
- "select",
3062
- {
3063
- value: formData.ruleId || "rule_1",
3064
- onChange: (e) => setActionFormData({ ...actionFormData, ruleId: e.target.value }),
3065
- 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",
3066
- children: [
3067
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3068
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3069
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3070
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3071
- ]
3072
- }
3073
- )
3074
- ] }),
3075
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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." })
3076
- ] }),
3077
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3078
- Button,
3079
- {
3080
- type: "button",
3081
- size: "sm",
3082
- variant: "secondary",
3083
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3084
- onClick: handleActionSubmit,
3085
- children: [
3086
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "Confirm" }),
3087
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3088
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3089
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3090
- ] })
3091
- ]
3092
- }
3093
- ) })
3094
- ] }, message.id);
3095
- }
3096
- if (message.kind === "bulkPreview" && message.csvData) {
3097
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
3098
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3099
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3100
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3101
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3102
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3103
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-gray-500", children: [
3104
- "\u2022 ",
3105
- message.csvData.rowCount,
3106
- " rows"
3107
- ] })
3108
- ] }),
3109
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3110
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3111
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded", children: col }, i)) })
3112
- ] }),
3113
- message.csvData.sampleRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2", children: [
3114
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3115
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100", children: [
3116
- Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3117
- j > 0 && " \u2022 ",
3118
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3119
- key,
3120
- ":"
3510
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3511
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3512
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3513
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3514
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3515
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-gray-500", children: [
3516
+ "\u2022 ",
3517
+ message.csvData.rowCount,
3518
+ " rows"
3519
+ ] })
3520
+ ] }),
3521
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3522
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3523
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3524
+ "span",
3525
+ {
3526
+ className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded",
3527
+ children: col
3528
+ },
3529
+ i
3530
+ )) })
3531
+ ] }),
3532
+ message.csvData.sampleRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-3 py-2", children: [
3533
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3534
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3535
+ "div",
3536
+ {
3537
+ className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100",
3538
+ children: [
3539
+ Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3540
+ j > 0 && " \u2022 ",
3541
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3542
+ key,
3543
+ ":"
3544
+ ] }),
3545
+ " ",
3546
+ val
3547
+ ] }, key)),
3548
+ Object.keys(row).length > 3 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-gray-400", children: [
3549
+ " ",
3550
+ "..."
3551
+ ] })
3552
+ ]
3553
+ },
3554
+ i
3555
+ )) })
3556
+ ] }),
3557
+ message.suggestedAction && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-blue-700", children: [
3558
+ "Suggested action:",
3559
+ " ",
3560
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3561
+ ] }) })
3121
3562
  ] }),
3122
- " ",
3123
- val
3124
- ] }, key)),
3125
- Object.keys(row).length > 3 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-gray-400", children: " ..." })
3126
- ] }, i)) })
3127
- ] }),
3128
- message.suggestedAction && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-xs text-blue-700", children: [
3129
- "Suggested action: ",
3130
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3131
- ] }) })
3132
- ] }),
3133
- message.bulkSessionId && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3134
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3135
- Button,
3563
+ message.bulkSessionId && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3564
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3565
+ Button,
3566
+ {
3567
+ type: "button",
3568
+ size: "sm",
3569
+ variant: "secondary",
3570
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3571
+ onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3572
+ children: [
3573
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3574
+ "Process ",
3575
+ message.csvData.rowCount,
3576
+ " rows"
3577
+ ] }),
3578
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3579
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3580
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3581
+ ] })
3582
+ ]
3583
+ }
3584
+ ),
3585
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3586
+ Button,
3587
+ {
3588
+ type: "button",
3589
+ size: "sm",
3590
+ variant: "ghost",
3591
+ className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3592
+ onClick: cancelBulkOperation,
3593
+ children: "Cancel"
3594
+ }
3595
+ )
3596
+ ] })
3597
+ ]
3598
+ },
3599
+ message.id
3600
+ );
3601
+ }
3602
+ if (message.kind === "bulkProgress" && message.bulkProgress) {
3603
+ const { processed, total, successes, failures } = message.bulkProgress;
3604
+ const percentage = Math.round(processed / total * 100);
3605
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3606
+ "div",
3136
3607
  {
3137
- type: "button",
3138
- size: "sm",
3139
- variant: "secondary",
3140
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3141
- onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3142
- children: [
3143
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3144
- "Process ",
3145
- message.csvData.rowCount,
3146
- " rows"
3608
+ className: `${isRoleChange ? "mt-3" : ""}`,
3609
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3610
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3611
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-blue-600" }),
3612
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-700", children: [
3613
+ "Processing... ",
3614
+ processed,
3615
+ " of ",
3616
+ total
3617
+ ] })
3147
3618
  ] }),
3148
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3149
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3150
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3619
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3620
+ "div",
3621
+ {
3622
+ className: "h-full bg-blue-600 transition-all duration-300",
3623
+ style: { width: `${percentage}%` }
3624
+ }
3625
+ ) }),
3626
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3627
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
3628
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3 text-green-600" }),
3629
+ successes,
3630
+ " successful"
3631
+ ] }),
3632
+ failures > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3633
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3634
+ failures,
3635
+ " failed"
3636
+ ] })
3151
3637
  ] })
3152
- ]
3153
- }
3154
- ),
3155
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3156
- Button,
3638
+ ] })
3639
+ },
3640
+ message.id
3641
+ );
3642
+ }
3643
+ if (message.kind === "bulkSummary" && message.bulkSummary) {
3644
+ const { total, successes, failures, navigationPage } = message.bulkSummary;
3645
+ const hasFailures = failures.length > 0;
3646
+ const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3647
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3648
+ "div",
3157
3649
  {
3158
- type: "button",
3159
- size: "sm",
3160
- variant: "ghost",
3161
- className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3162
- onClick: cancelBulkOperation,
3163
- children: "Cancel"
3164
- }
3165
- )
3166
- ] })
3167
- ] }, message.id);
3168
- }
3169
- if (message.kind === "bulkProgress" && message.bulkProgress) {
3170
- const { processed, total, successes, failures } = message.bulkProgress;
3171
- const percentage = Math.round(processed / total * 100);
3172
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3173
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3174
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "h-4 w-4 animate-spin text-blue-600" }),
3175
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-sm font-medium text-gray-700", children: [
3176
- "Processing... ",
3177
- processed,
3178
- " of ",
3179
- total
3180
- ] })
3181
- ] }),
3182
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3650
+ className: `${isRoleChange ? "mt-3" : ""}`,
3651
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3652
+ "div",
3653
+ {
3654
+ className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`,
3655
+ children: [
3656
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3657
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3658
+ import_lucide_react4.CheckCircle2,
3659
+ {
3660
+ className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}`
3661
+ }
3662
+ ),
3663
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3664
+ ] }),
3665
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3666
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-4 text-xs", children: [
3667
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-green-700", children: [
3668
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3" }),
3669
+ successes,
3670
+ " successful"
3671
+ ] }),
3672
+ hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3673
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3674
+ failures.length,
3675
+ " failed"
3676
+ ] })
3677
+ ] }),
3678
+ hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3679
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3680
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3681
+ failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3682
+ "div",
3683
+ {
3684
+ className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1",
3685
+ children: [
3686
+ "Row ",
3687
+ failure.row,
3688
+ ":",
3689
+ " ",
3690
+ failure.error || "Unknown error"
3691
+ ]
3692
+ },
3693
+ i
3694
+ )),
3695
+ failures.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-amber-600", children: [
3696
+ "...and ",
3697
+ failures.length - 5,
3698
+ " more"
3699
+ ] })
3700
+ ] })
3701
+ ] }),
3702
+ navigationPage && successes > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3703
+ "button",
3704
+ {
3705
+ type: "button",
3706
+ onClick: (e) => {
3707
+ e.preventDefault();
3708
+ e.stopPropagation();
3709
+ console.log(
3710
+ "[DEBUG] Button clicked - navigationPage:",
3711
+ navigationPage,
3712
+ "onNavigate:",
3713
+ !!onNavigate
3714
+ );
3715
+ if (onNavigate && navigationPage.page) {
3716
+ console.log(
3717
+ "[DEBUG] Calling onNavigate with page:",
3718
+ navigationPage.page
3719
+ );
3720
+ onNavigate(
3721
+ navigationPage.page,
3722
+ navigationPage.subtab
3723
+ );
3724
+ } else {
3725
+ console.log(
3726
+ "[DEBUG] Condition failed - onNavigate:",
3727
+ !!onNavigate,
3728
+ "navigationPage.page:",
3729
+ navigationPage.page
3730
+ );
3731
+ }
3732
+ },
3733
+ className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3734
+ children: [
3735
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("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: [
3736
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-2.5 w-2.5" }),
3737
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "+" }),
3738
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-2.5 w-2.5" })
3739
+ ] }),
3740
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3741
+ "View ",
3742
+ pageLabel
3743
+ ] })
3744
+ ]
3745
+ }
3746
+ ) })
3747
+ ]
3748
+ }
3749
+ )
3750
+ },
3751
+ message.id
3752
+ );
3753
+ }
3754
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3183
3755
  "div",
3184
3756
  {
3185
- className: "h-full bg-blue-600 transition-all duration-300",
3186
- style: { width: `${percentage}%` }
3757
+ ref: isCurrentGuideStep ? currentStepRef : null,
3758
+ className: `${isRoleChange ? "mt-3" : ""}`,
3759
+ children: [
3760
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3761
+ const text = message.content || "";
3762
+ if (message.kind === "guideStep") {
3763
+ const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3764
+ if (m) {
3765
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3766
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: m[1] }),
3767
+ m[2]
3768
+ ] });
3769
+ }
3770
+ }
3771
+ if (message.role === "assistant" && text) {
3772
+ return renderMarkdown(text);
3773
+ }
3774
+ return text || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "opacity-70", children: "Thinking\u2026" });
3775
+ })() }),
3776
+ message.role === "assistant" && message.structuredData && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3777
+ DataRenderer,
3778
+ {
3779
+ type: message.structuredData.type,
3780
+ data: message.structuredData.data
3781
+ }
3782
+ ) }),
3783
+ message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3784
+ "button",
3785
+ {
3786
+ type: "button",
3787
+ onClick: () => handleFollowupClick(message.id, followup),
3788
+ 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",
3789
+ children: followup.label
3790
+ },
3791
+ followup.id
3792
+ )) })
3793
+ ]
3187
3794
  }
3188
- ) }),
3189
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3190
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1", children: [
3191
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3 text-green-600" }),
3192
- successes,
3193
- " successful"
3194
- ] }),
3195
- failures > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3196
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3197
- failures,
3198
- " failed"
3199
- ] })
3200
- ] })
3201
- ] }) }, message.id);
3202
- }
3203
- if (message.kind === "bulkSummary" && message.bulkSummary) {
3204
- const { total, successes, failures, navigationPage } = message.bulkSummary;
3205
- const hasFailures = failures.length > 0;
3206
- const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3207
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`, children: [
3208
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2 mb-2", children: [
3209
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}` }),
3210
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3211
- ] }),
3212
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3213
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-4 text-xs", children: [
3214
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-green-700", children: [
3215
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CheckCircle2, { className: "h-3 w-3" }),
3216
- successes,
3217
- " successful"
3218
- ] }),
3219
- hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-1 text-red-600", children: [
3220
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.X, { className: "h-3 w-3" }),
3221
- failures.length,
3222
- " failed"
3223
- ] })
3224
- ] }),
3225
- hasFailures && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3226
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3227
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3228
- failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1", children: [
3229
- "Row ",
3230
- failure.row,
3231
- ": ",
3232
- failure.error || "Unknown error"
3233
- ] }, i)),
3234
- failures.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "text-xs text-amber-600", children: [
3235
- "...and ",
3236
- failures.length - 5,
3237
- " more"
3238
- ] })
3239
- ] })
3240
- ] }),
3241
- navigationPage && successes > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3242
- "button",
3795
+ ) }, message.id);
3796
+ }),
3797
+ (activeGuide || guideComplete) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3798
+ activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3799
+ Button,
3243
3800
  {
3244
3801
  type: "button",
3245
- onClick: (e) => {
3246
- e.preventDefault();
3247
- e.stopPropagation();
3248
- console.log("[DEBUG] Button clicked - navigationPage:", navigationPage, "onNavigate:", !!onNavigate);
3249
- if (onNavigate && navigationPage.page) {
3250
- console.log("[DEBUG] Calling onNavigate with page:", navigationPage.page);
3251
- onNavigate(navigationPage.page, navigationPage.subtab);
3252
- } else {
3253
- console.log("[DEBUG] Condition failed - onNavigate:", !!onNavigate, "navigationPage.page:", navigationPage.page);
3254
- }
3255
- },
3256
- className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3802
+ size: "sm",
3803
+ variant: "secondary",
3804
+ className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3805
+ onClick: goBackGuide,
3806
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3807
+ }
3808
+ ),
3809
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3810
+ Button,
3811
+ {
3812
+ type: "button",
3813
+ size: "sm",
3814
+ variant: "secondary",
3815
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3816
+ onClick: guideComplete ? handleBack : advanceGuide,
3257
3817
  children: [
3258
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("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: [
3259
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-2.5 w-2.5" }),
3260
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "+" }),
3261
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-2.5 w-2.5" })
3262
- ] }),
3263
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
3264
- "View ",
3265
- pageLabel
3818
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: guideComplete ? "Done" : "Next" }),
3819
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3820
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3821
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3266
3822
  ] })
3267
3823
  ]
3268
3824
  }
3269
- ) })
3270
- ] }) }, message.id);
3271
- }
3272
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(React4.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3273
- "div",
3274
- {
3275
- ref: isCurrentGuideStep ? currentStepRef : null,
3276
- className: `${isRoleChange ? "mt-3" : ""}`,
3277
- children: [
3278
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3279
- const text = message.content || "";
3280
- if (message.kind === "guideStep") {
3281
- const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3282
- if (m) {
3283
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3284
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("strong", { children: m[1] }),
3285
- m[2]
3286
- ] });
3287
- }
3288
- }
3289
- if (message.role === "assistant" && text) {
3290
- return renderMarkdown(text);
3291
- }
3292
- return text || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "opacity-70", children: "Thinking\u2026" });
3293
- })() }),
3294
- message.role === "assistant" && message.structuredData && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3295
- DataRenderer,
3296
- {
3297
- type: message.structuredData.type,
3298
- data: message.structuredData.data
3299
- }
3300
- ) }),
3301
- message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3302
- "button",
3303
- {
3304
- type: "button",
3305
- onClick: () => handleFollowupClick(message.id, followup),
3306
- 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",
3307
- children: followup.label
3308
- },
3309
- followup.id
3310
- )) })
3311
- ]
3312
- }
3313
- ) }, message.id);
3314
- }),
3315
- (activeGuide || guideComplete) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
3316
- activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3317
- Button,
3318
- {
3319
- type: "button",
3320
- size: "sm",
3321
- variant: "secondary",
3322
- className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3323
- onClick: goBackGuide,
3324
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3325
- }
3326
- ),
3327
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3328
- Button,
3329
- {
3330
- type: "button",
3331
- size: "sm",
3332
- variant: "secondary",
3333
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3334
- onClick: guideComplete ? handleBack : advanceGuide,
3335
- children: [
3336
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: guideComplete ? "Done" : "Next" }),
3337
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3338
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Command, { className: "h-3 w-3" }),
3339
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CornerDownLeft, { className: "h-3 w-3" })
3340
- ] })
3341
- ]
3342
- }
3343
- )
3344
- ] }),
3345
- (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3346
- AssistantActivity,
3347
- {
3348
- phase,
3349
- progressSteps
3350
- }
3351
- ) }),
3352
- !activeGuide && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: messagesEndRef })
3353
- ] }) }) }) }) }),
3825
+ )
3826
+ ] }),
3827
+ (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3828
+ AssistantActivity,
3829
+ {
3830
+ phase,
3831
+ progressSteps
3832
+ }
3833
+ ) }),
3834
+ !activeGuide && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: messagesEndRef })
3835
+ ] }) }) }) })
3836
+ }
3837
+ ),
3354
3838
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "px-4 py-3 border-t border-gray-100 bg-gray-50/50 shrink-0", children: [
3355
3839
  pendingFile && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-2 flex items-center gap-2 rounded-xl bg-blue-50 border border-blue-200 px-3 py-2", children: [
3356
3840
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.FileSpreadsheet, { className: "h-4 w-4 text-blue-600" }),
@@ -3479,7 +3963,11 @@ ${userText}`
3479
3963
  }
3480
3964
  );
3481
3965
  }
3482
- function PanelToggle({ isOpen, onClick, className = "" }) {
3966
+ function PanelToggle({
3967
+ isOpen,
3968
+ onClick,
3969
+ className = ""
3970
+ }) {
3483
3971
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3484
3972
  "button",
3485
3973
  {
@@ -3525,13 +4013,7 @@ function ChatPanelWithToggle({
3525
4013
  };
3526
4014
  }, [isOpen]);
3527
4015
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3528
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3529
- PanelToggle,
3530
- {
3531
- isOpen,
3532
- onClick: () => setIsOpen(!isOpen)
3533
- }
3534
- ),
4016
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PanelToggle, { isOpen, onClick: () => setIsOpen(!isOpen) }),
3535
4017
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3536
4018
  ChatPanel,
3537
4019
  {