@kite-copilot/chat-panel 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -883,9 +883,10 @@ function DataRenderer({ type, data }) {
883
883
 
884
884
  // src/ChatPanel.tsx
885
885
  import * as React4 from "react";
886
- import { ArrowLeft, ArrowUp, Play, Command, CornerDownLeft, CheckCircle2 as CheckCircle23, SquarePen, Paperclip, X, FileSpreadsheet, Loader2 as Loader22, ChevronDown as ChevronDown2, ChevronUp } from "lucide-react";
886
+ import { ArrowLeft, ArrowUp, Play, Command, CornerDownLeft, CheckCircle2 as CheckCircle23, SquarePen, Paperclip, X, FileSpreadsheet, Loader2 as Loader22, ChevronLeft, ChevronRight } from "lucide-react";
887
887
  import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
888
888
  var DEFAULT_AGENT_URL = "http://localhost:5002";
889
+ var PANEL_WIDTH = 400;
889
890
  function renderMarkdown(text) {
890
891
  if (!text) return null;
891
892
  const lines = text.split("\n");
@@ -1014,6 +1015,26 @@ function renderMarkdown(text) {
1014
1015
  flushList();
1015
1016
  return /* @__PURE__ */ jsx9(Fragment2, { children: elements });
1016
1017
  }
1018
+ var defaultStartingQuestions = [
1019
+ {
1020
+ id: "changing-layouts",
1021
+ label: "Changing layouts",
1022
+ prompt: "How can I customize and change the layout of my dashboard?",
1023
+ icon: "layout"
1024
+ },
1025
+ {
1026
+ id: "bulk-uploads",
1027
+ label: "Bulk uploads",
1028
+ prompt: "How do I perform bulk uploads of data using CSV files?",
1029
+ icon: "upload"
1030
+ },
1031
+ {
1032
+ id: "example-setups",
1033
+ label: "Example setups",
1034
+ prompt: "Can you show me some example configurations and setups?",
1035
+ icon: "setup"
1036
+ }
1037
+ ];
1017
1038
  var folders = [
1018
1039
  {
1019
1040
  id: "customers",
@@ -1177,11 +1198,15 @@ var guides = {
1177
1198
  };
1178
1199
  var initialMessages = [];
1179
1200
  function ChatPanel({
1201
+ isOpen = true,
1202
+ onClose,
1180
1203
  onBack,
1181
1204
  onNavigate,
1182
1205
  onActionComplete,
1183
1206
  currentPage,
1184
- agentUrl = DEFAULT_AGENT_URL
1207
+ agentUrl = DEFAULT_AGENT_URL,
1208
+ startingQuestions: startingQuestionsProp,
1209
+ startingQuestionsEndpoint
1185
1210
  } = {}) {
1186
1211
  const [messages, setMessages] = React4.useState(initialMessages);
1187
1212
  const [input, setInput] = React4.useState("");
@@ -1194,6 +1219,27 @@ function ChatPanel({
1194
1219
  const lastRole = messages.length ? messages[messages.length - 1].role : void 0;
1195
1220
  const [panelView, setPanelView] = React4.useState("landing");
1196
1221
  const [currentFolderId, setCurrentFolderId] = React4.useState(void 0);
1222
+ const [startingQuestions, setStartingQuestions] = React4.useState(
1223
+ startingQuestionsProp || defaultStartingQuestions
1224
+ );
1225
+ const [loadingQuestions, setLoadingQuestions] = React4.useState(false);
1226
+ React4.useEffect(() => {
1227
+ if (startingQuestionsEndpoint && !startingQuestionsProp) {
1228
+ setLoadingQuestions(true);
1229
+ fetch(startingQuestionsEndpoint).then((res) => res.json()).then((data) => {
1230
+ if (Array.isArray(data) && data.length > 0) {
1231
+ setStartingQuestions(data);
1232
+ }
1233
+ }).catch((err) => {
1234
+ console.warn("[KiteChat] Failed to fetch starting questions:", err);
1235
+ }).finally(() => setLoadingQuestions(false));
1236
+ }
1237
+ }, [startingQuestionsEndpoint, startingQuestionsProp]);
1238
+ React4.useEffect(() => {
1239
+ if (startingQuestionsProp) {
1240
+ setStartingQuestions(startingQuestionsProp);
1241
+ }
1242
+ }, [startingQuestionsProp]);
1197
1243
  const [activeGuide, setActiveGuide] = React4.useState(void 0);
1198
1244
  const activeGuideRef = React4.useRef(void 0);
1199
1245
  const latestBulkSummaryNavigationRef = React4.useRef(null);
@@ -1246,7 +1292,6 @@ function ChatPanel({
1246
1292
  const { cursorState, moveTo, hide } = useGuideCursor();
1247
1293
  const [pendingFile, setPendingFile] = React4.useState(null);
1248
1294
  const [pendingBulkSession, setPendingBulkSession] = React4.useState(null);
1249
- const [isCollapsed, setIsCollapsed] = React4.useState(false);
1250
1295
  const pendingBulkSessionRef = React4.useRef(null);
1251
1296
  const fileInputRef = React4.useRef(null);
1252
1297
  React4.useEffect(() => {
@@ -2297,1119 +2342,1157 @@ ${userText}`
2297
2342
  ]);
2298
2343
  }
2299
2344
  }
2300
- return /* @__PURE__ */ jsxs5("section", { className: `fixed bottom-6 right-6 z-50 flex flex-col bg-white rounded-2xl shadow-2xl border border-gray-200/80 w-[400px] overflow-hidden transition-all duration-300 ${isCollapsed ? "h-12" : "h-[calc(100vh-48px)]"}`, children: [
2301
- /* @__PURE__ */ jsxs5(
2302
- "div",
2303
- {
2304
- className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-gradient-to-r from-gray-50 to-white cursor-pointer shrink-0",
2305
- onClick: () => setIsCollapsed(!isCollapsed),
2306
- children: [
2307
- /* @__PURE__ */ jsx9("h3", { className: "text-sm font-semibold text-gray-800", children: "Copilot" }),
2308
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1", children: [
2309
- !isCollapsed && /* @__PURE__ */ jsx9(
2310
- Button,
2311
- {
2312
- variant: "ghost",
2313
- size: "sm",
2314
- className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2315
- onClick: (e) => {
2316
- e.stopPropagation();
2317
- setMessages([]);
2318
- setPanelView("landing");
2319
- setCurrentFolderId(void 0);
2320
- setActiveGuide(void 0);
2321
- activeGuideRef.current = void 0;
2322
- setGuideComplete(false);
2323
- },
2324
- children: /* @__PURE__ */ jsx9(SquarePen, { className: "h-3.5 w-3.5" })
2325
- }
2326
- ),
2327
- /* @__PURE__ */ jsx9(
2328
- Button,
2329
- {
2330
- variant: "ghost",
2331
- size: "sm",
2332
- className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2333
- onClick: (e) => {
2334
- e.stopPropagation();
2335
- setIsCollapsed(!isCollapsed);
2336
- },
2337
- children: isCollapsed ? /* @__PURE__ */ jsx9(ChevronUp, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx9(ChevronDown2, { className: "h-4 w-4" })
2338
- }
2339
- )
2340
- ] })
2341
- ]
2342
- }
2343
- ),
2344
- !isCollapsed && /* @__PURE__ */ jsx9("div", { className: isEmpty ? "grid flex-1 place-items-center transition-all duration-300" : "flex flex-1 flex-col transition-all duration-300 min-h-0 overflow-hidden", children: isEmpty ? /* @__PURE__ */ jsxs5("div", { className: "w-full overflow-y-auto px-4", children: [
2345
- /* @__PURE__ */ jsxs5("div", { className: "py-4 transition-all duration-300", children: [
2346
- /* @__PURE__ */ jsx9("h2", { className: "text-center text-2xl font-semibold text-gray-900", children: panelView === "folder" ? folders.find((f) => f.id === currentFolderId)?.title || "" : "What can I help with?" }),
2347
- panelView === "landing" && /* @__PURE__ */ jsx9("p", { className: "mt-1 text-center text-xs text-gray-500", children: "Ask me anything about your account" })
2348
- ] }),
2349
- /* @__PURE__ */ jsxs5("div", { className: "pb-4", children: [
2350
- panelView === "landing" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2351
- /* @__PURE__ */ jsx9("div", { className: "mb-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400", children: "Quick Start" }),
2352
- /* @__PURE__ */ jsxs5(
2345
+ return /* @__PURE__ */ jsxs5(
2346
+ "section",
2347
+ {
2348
+ className: `fixed top-0 right-0 z-40 flex flex-col bg-white border-l border-gray-200 h-full overflow-hidden transition-transform duration-300 ${isOpen ? "translate-x-0" : "translate-x-full"}`,
2349
+ style: { width: `${PANEL_WIDTH}px` },
2350
+ children: [
2351
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-gradient-to-r from-gray-50 to-white shrink-0", children: [
2352
+ /* @__PURE__ */ jsx9("h3", { className: "text-sm font-semibold text-gray-800", children: "Help" }),
2353
+ /* @__PURE__ */ jsx9("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsx9(
2353
2354
  Button,
2354
2355
  {
2355
- type: "button",
2356
+ variant: "ghost",
2356
2357
  size: "sm",
2357
- variant: "secondary",
2358
- className: "w-full justify-start rounded-xl border border-primary/20 bg-primary/5 px-3 py-2.5 text-xs font-medium text-primary shadow-none transition-all hover:bg-primary/10 hover:border-primary/30 h-auto mb-4",
2359
- onClick: () => startGuide("getting-started"),
2360
- children: [
2361
- /* @__PURE__ */ jsx9(Play, { className: "mr-2 h-3.5 w-3.5" }),
2362
- "Getting started"
2363
- ]
2358
+ className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
2359
+ onClick: () => {
2360
+ setMessages([]);
2361
+ setPanelView("landing");
2362
+ setCurrentFolderId(void 0);
2363
+ setActiveGuide(void 0);
2364
+ activeGuideRef.current = void 0;
2365
+ setGuideComplete(false);
2366
+ },
2367
+ children: /* @__PURE__ */ jsx9(SquarePen, { className: "h-3.5 w-3.5" })
2364
2368
  }
2365
- ),
2366
- /* @__PURE__ */ jsx9("div", { className: "mb-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400", children: "Topics" }),
2367
- /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1", children: [
2368
- /* @__PURE__ */ jsxs5(
2369
- Button,
2370
- {
2371
- type: "button",
2372
- size: "sm",
2373
- variant: "ghost",
2374
- className: "w-full justify-start rounded-lg px-3 py-2 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2375
- onClick: () => openFolder("customers"),
2376
- children: [
2377
- /* @__PURE__ */ jsx9("span", { className: "mr-2 inline-block h-1.5 w-1.5 rounded-full bg-blue-400" }),
2378
- "Customer Management"
2379
- ]
2380
- }
2381
- ),
2382
- /* @__PURE__ */ jsxs5(
2383
- Button,
2384
- {
2385
- type: "button",
2386
- size: "sm",
2387
- variant: "ghost",
2388
- className: "w-full justify-start rounded-lg px-3 py-2 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2389
- onClick: () => openFolder("payments"),
2390
- children: [
2391
- /* @__PURE__ */ jsx9("span", { className: "mr-2 inline-block h-1.5 w-1.5 rounded-full bg-green-400" }),
2392
- "Payment Processing"
2393
- ]
2394
- }
2395
- ),
2396
- /* @__PURE__ */ jsxs5(
2397
- Button,
2398
- {
2399
- type: "button",
2400
- size: "sm",
2401
- variant: "ghost",
2402
- className: "w-full justify-start rounded-lg px-3 py-2 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2403
- onClick: () => openFolder("billing"),
2404
- children: [
2405
- /* @__PURE__ */ jsx9("span", { className: "mr-2 inline-block h-1.5 w-1.5 rounded-full bg-purple-400" }),
2406
- "Billing"
2407
- ]
2408
- }
2409
- )
2410
- ] })
2369
+ ) })
2411
2370
  ] }),
2412
- panelView === "folder" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2413
- /* @__PURE__ */ jsxs5("div", { className: "mb-3 flex items-center gap-2", children: [
2414
- /* @__PURE__ */ jsx9(
2415
- Button,
2416
- {
2417
- type: "button",
2418
- size: "icon",
2419
- variant: "ghost",
2420
- className: "h-7 w-7 rounded-full hover:bg-gray-100",
2421
- onClick: closeFolder,
2422
- "aria-label": "Back to suggestions",
2423
- children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2424
- }
2425
- ),
2426
- /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2371
+ /* @__PURE__ */ jsx9("div", { className: isEmpty ? "grid flex-1 place-items-center transition-all duration-300" : "flex flex-1 flex-col transition-all duration-300 min-h-0 overflow-hidden", children: isEmpty ? /* @__PURE__ */ jsxs5("div", { className: "w-full overflow-y-auto px-4", children: [
2372
+ /* @__PURE__ */ jsxs5("div", { className: "py-4 transition-all duration-300", children: [
2373
+ /* @__PURE__ */ jsx9("h2", { className: "text-center text-2xl font-semibold text-gray-900", children: panelView === "folder" ? folders.find((f) => f.id === currentFolderId)?.title || "" : "What can I help with?" }),
2374
+ panelView === "landing" && /* @__PURE__ */ jsx9("p", { className: "mt-1 text-center text-xs text-gray-500", children: "Ask me anything about your account" })
2427
2375
  ] }),
2428
- /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ jsx9(
2429
- Button,
2430
- {
2431
- type: "button",
2432
- size: "sm",
2433
- variant: "secondary",
2434
- 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",
2435
- onClick: () => sendTopic(topic.prompt),
2436
- children: topic.label
2437
- },
2438
- topic.id
2439
- )) })
2440
- ] })
2441
- ] })
2442
- ] }) : /* @__PURE__ */ jsx9(Fragment2, { children: /* @__PURE__ */ jsx9("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx9(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2443
- messages.map((message, index) => {
2444
- const isUser = message.role === "user";
2445
- const previousRole = index > 0 ? messages[index - 1].role : void 0;
2446
- const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2447
- const currentGuide = activeGuideRef.current || activeGuide;
2448
- let isCurrentGuideStep = false;
2449
- if (currentGuide && message.kind === "guideStep") {
2450
- if (message.guideStepIndex !== void 0) {
2451
- isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2452
- } else {
2453
- isCurrentGuideStep = index === messages.length - 1;
2454
- }
2455
- } else if (message.kind === "guideComplete") {
2456
- isCurrentGuideStep = index === messages.length - 1;
2457
- }
2458
- if (message.kind === "guideStep" && !isCurrentGuideStep) {
2459
- return null;
2460
- }
2461
- if (isUser) {
2462
- return /* @__PURE__ */ jsx9("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[280px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2463
- }
2464
- if (message.kind === "searchSummary") {
2465
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(AssistantSearchSummary, { title: message.title ?? "Search results", links: message.links ?? [] }) }, message.id);
2466
- }
2467
- if (message.kind === "guideComplete") {
2468
- return /* @__PURE__ */ jsx9(
2469
- "div",
2470
- {
2471
- ref: isCurrentGuideStep ? currentStepRef : null,
2472
- className: `${isRoleChange ? "mt-3" : ""}`,
2473
- children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-sm leading-6", children: [
2474
- /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2475
- /* @__PURE__ */ jsx9("span", { className: "font-medium text-green-800", children: message.content })
2476
- ] })
2477
- },
2478
- message.id
2479
- );
2480
- }
2481
- if (message.kind === "navigationAction") {
2482
- return /* @__PURE__ */ jsxs5("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
2483
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2484
- message.navigationTarget && /* @__PURE__ */ jsx9("div", { className: "mt-2", children: /* @__PURE__ */ jsxs5(
2485
- Button,
2486
- {
2487
- type: "button",
2488
- size: "sm",
2489
- variant: "secondary",
2490
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2491
- onClick: () => message.navigationTarget && handleConfirmNavigation(message.navigationTarget),
2492
- children: [
2493
- /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
2494
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2495
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
2496
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
2497
- ] })
2498
- ]
2376
+ /* @__PURE__ */ jsxs5("div", { className: "pb-4", children: [
2377
+ panelView === "landing" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2378
+ /* @__PURE__ */ jsx9("div", { className: "mb-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400", children: "Quick Start" }),
2379
+ /* @__PURE__ */ jsxs5(
2380
+ Button,
2381
+ {
2382
+ type: "button",
2383
+ size: "sm",
2384
+ variant: "secondary",
2385
+ className: "w-full justify-start rounded-xl border border-primary/20 bg-primary/5 px-3 py-2.5 text-xs font-medium text-primary shadow-none transition-all hover:bg-primary/10 hover:border-primary/30 h-auto mb-4",
2386
+ onClick: () => startGuide("getting-started"),
2387
+ children: [
2388
+ /* @__PURE__ */ jsx9(Play, { className: "mr-2 h-3.5 w-3.5" }),
2389
+ "Getting started"
2390
+ ]
2391
+ }
2392
+ ),
2393
+ /* @__PURE__ */ jsx9("div", { className: "mb-2 text-[10px] font-semibold uppercase tracking-wider text-gray-400", children: "Suggested Questions" }),
2394
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1", children: loadingQuestions ? /* @__PURE__ */ jsx9("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-gray-400" }) }) : startingQuestions.map((question, index) => {
2395
+ const iconColors = ["bg-blue-400", "bg-green-400", "bg-purple-400", "bg-orange-400", "bg-pink-400"];
2396
+ return /* @__PURE__ */ jsxs5(
2397
+ Button,
2398
+ {
2399
+ type: "button",
2400
+ size: "sm",
2401
+ variant: "ghost",
2402
+ className: "w-full justify-start rounded-lg px-3 py-2 text-xs text-gray-700 hover:bg-gray-100 h-auto",
2403
+ onClick: () => sendTopic(question.prompt),
2404
+ children: [
2405
+ /* @__PURE__ */ jsx9("span", { className: `mr-2 inline-block h-1.5 w-1.5 rounded-full ${iconColors[index % iconColors.length]}` }),
2406
+ question.label
2407
+ ]
2408
+ },
2409
+ question.id
2410
+ );
2411
+ }) })
2412
+ ] }),
2413
+ panelView === "folder" && /* @__PURE__ */ jsxs5(Fragment2, { children: [
2414
+ /* @__PURE__ */ jsxs5("div", { className: "mb-3 flex items-center gap-2", children: [
2415
+ /* @__PURE__ */ jsx9(
2416
+ Button,
2417
+ {
2418
+ type: "button",
2419
+ size: "icon",
2420
+ variant: "ghost",
2421
+ className: "h-7 w-7 rounded-full hover:bg-gray-100",
2422
+ onClick: closeFolder,
2423
+ "aria-label": "Back to suggestions",
2424
+ children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-4 w-4 text-gray-500" })
2425
+ }
2426
+ ),
2427
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-wide text-gray-400", children: "Topics" })
2428
+ ] }),
2429
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-col gap-1.5", children: folders.find((f) => f.id === currentFolderId)?.topics.map((topic) => /* @__PURE__ */ jsx9(
2430
+ Button,
2431
+ {
2432
+ type: "button",
2433
+ size: "sm",
2434
+ variant: "secondary",
2435
+ 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",
2436
+ onClick: () => sendTopic(topic.prompt),
2437
+ children: topic.label
2438
+ },
2439
+ topic.id
2440
+ )) })
2441
+ ] })
2442
+ ] })
2443
+ ] }) : /* @__PURE__ */ jsx9(Fragment2, { children: /* @__PURE__ */ jsx9("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx9(ScrollArea, { ref: messagesContainerRef, className: "h-full", children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-2 px-4 py-3", children: [
2444
+ messages.map((message, index) => {
2445
+ const isUser = message.role === "user";
2446
+ const previousRole = index > 0 ? messages[index - 1].role : void 0;
2447
+ const isRoleChange = previousRole !== void 0 && previousRole !== message.role;
2448
+ const currentGuide = activeGuideRef.current || activeGuide;
2449
+ let isCurrentGuideStep = false;
2450
+ if (currentGuide && message.kind === "guideStep") {
2451
+ if (message.guideStepIndex !== void 0) {
2452
+ isCurrentGuideStep = message.guideStepIndex === currentGuide.stepIndex;
2453
+ } else {
2454
+ isCurrentGuideStep = index === messages.length - 1;
2499
2455
  }
2500
- ) })
2501
- ] }, message.id);
2502
- }
2503
- if (message.kind === "actionForm") {
2504
- const actionType = message.actionType;
2505
- const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2506
- if (message.isSubmitted) {
2507
- let successContent = "";
2508
- if (actionType === "updateCompanyInfo") {
2509
- successContent = "Company information has been updated successfully.";
2510
- } else if (actionType === "addApiKey") {
2511
- successContent = "API key has been added successfully.";
2512
- } else if (actionType === "addCustomer") {
2513
- successContent = "Customer has been added successfully.";
2514
- } else if (actionType === "enable2FA") {
2515
- successContent = "Two-factor authentication has been enabled successfully.";
2516
- } else if (actionType === "disable2FA") {
2517
- successContent = "Two-factor authentication has been disabled successfully.";
2518
- } else if (actionType === "changePassword") {
2519
- successContent = "Your password has been changed successfully.";
2520
- } else if (actionType === "revokeSession") {
2521
- successContent = "Session has been revoked successfully.";
2522
- } else if (actionType === "toggleNotification") {
2523
- successContent = "Notification preferences have been updated successfully.";
2524
- } else if (actionType === "connectIntegration") {
2525
- successContent = "Integration has been connected successfully.";
2526
- } else if (actionType === "disconnectIntegration") {
2527
- successContent = "Integration has been disconnected successfully.";
2528
- } else if (actionType === "addPaymentMethod") {
2529
- successContent = "Payment method has been added successfully.";
2530
- } else if (actionType === "removePaymentMethod") {
2531
- successContent = "Payment method has been removed successfully.";
2532
- } else if (actionType === "deleteApiKey") {
2533
- successContent = "API key has been deleted successfully.";
2534
- } else if (actionType === "addWebhook") {
2535
- successContent = "Webhook endpoint has been added successfully.";
2536
- } else if (actionType === "updateCurrency") {
2537
- successContent = "Currency preference has been updated successfully.";
2538
- } else if (actionType === "updateTimezone") {
2539
- successContent = "Timezone has been updated successfully.";
2540
- } else if (actionType === "refundPayment") {
2541
- successContent = "Refund has been processed successfully.";
2542
- } else if (actionType === "exportCertificate") {
2543
- successContent = "Certificate of Incorporation has been downloaded successfully.";
2544
- } else if (actionType === "createSubscription") {
2545
- successContent = "Subscription has been created successfully.";
2546
- } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2547
- successContent = "Block rule has been updated successfully.";
2548
- } else {
2549
- successContent = "Action completed successfully.";
2456
+ } else if (message.kind === "guideComplete") {
2457
+ isCurrentGuideStep = index === messages.length - 1;
2550
2458
  }
2551
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent }) }, message.id);
2552
- }
2553
- return /* @__PURE__ */ jsxs5("div", { className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`, children: [
2554
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2555
- actionType === "updateCompanyInfo" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2556
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2557
- /* @__PURE__ */ jsxs5("div", { children: [
2558
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2559
- /* @__PURE__ */ jsx9(
2560
- Input,
2561
- {
2562
- placeholder: "Acme Corporation",
2563
- value: formData.companyName || "",
2564
- onChange: (e) => setActionFormData({ ...actionFormData, companyName: e.target.value }),
2565
- className: "h-8 text-xs border-gray-200"
2566
- }
2567
- )
2459
+ if (message.kind === "guideStep" && !isCurrentGuideStep) {
2460
+ return null;
2461
+ }
2462
+ if (isUser) {
2463
+ return /* @__PURE__ */ jsx9("div", { className: `flex justify-end ${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "max-w-[280px] rounded-2xl rounded-br-md bg-gray-900 px-3.5 py-2.5 text-sm text-white shadow-sm", children: message.content }) }, message.id);
2464
+ }
2465
+ if (message.kind === "searchSummary") {
2466
+ return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(AssistantSearchSummary, { title: message.title ?? "Search results", links: message.links ?? [] }) }, message.id);
2467
+ }
2468
+ if (message.kind === "guideComplete") {
2469
+ return /* @__PURE__ */ jsx9(
2470
+ "div",
2471
+ {
2472
+ ref: isCurrentGuideStep ? currentStepRef : null,
2473
+ className: `${isRoleChange ? "mt-3" : ""}`,
2474
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 rounded-xl bg-green-50 border border-green-200 px-3 py-2.5 text-sm leading-6", children: [
2475
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-5 w-5 text-green-600 flex-shrink-0" }),
2476
+ /* @__PURE__ */ jsx9("span", { className: "font-medium text-green-800", children: message.content })
2477
+ ] })
2478
+ },
2479
+ message.id
2480
+ );
2481
+ }
2482
+ if (message.kind === "navigationAction") {
2483
+ return /* @__PURE__ */ jsxs5("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
2484
+ /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-2 text-gray-700", children: message.content || "" }),
2485
+ message.navigationTarget && /* @__PURE__ */ jsx9("div", { className: "mt-2", children: /* @__PURE__ */ jsxs5(
2486
+ Button,
2487
+ {
2488
+ type: "button",
2489
+ size: "sm",
2490
+ variant: "secondary",
2491
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
2492
+ onClick: () => message.navigationTarget && handleConfirmNavigation(message.navigationTarget),
2493
+ children: [
2494
+ /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
2495
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
2496
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
2497
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
2498
+ ] })
2499
+ ]
2500
+ }
2501
+ ) })
2502
+ ] }, message.id);
2503
+ }
2504
+ if (message.kind === "actionForm") {
2505
+ const actionType = message.actionType;
2506
+ const formData = Object.keys(actionFormData).length > 0 ? actionFormData : message.actionData || {};
2507
+ if (message.isSubmitted) {
2508
+ let successContent = "";
2509
+ if (actionType === "updateCompanyInfo") {
2510
+ successContent = "Company information has been updated successfully.";
2511
+ } else if (actionType === "addApiKey") {
2512
+ successContent = "API key has been added successfully.";
2513
+ } else if (actionType === "addCustomer") {
2514
+ successContent = "Customer has been added successfully.";
2515
+ } else if (actionType === "enable2FA") {
2516
+ successContent = "Two-factor authentication has been enabled successfully.";
2517
+ } else if (actionType === "disable2FA") {
2518
+ successContent = "Two-factor authentication has been disabled successfully.";
2519
+ } else if (actionType === "changePassword") {
2520
+ successContent = "Your password has been changed successfully.";
2521
+ } else if (actionType === "revokeSession") {
2522
+ successContent = "Session has been revoked successfully.";
2523
+ } else if (actionType === "toggleNotification") {
2524
+ successContent = "Notification preferences have been updated successfully.";
2525
+ } else if (actionType === "connectIntegration") {
2526
+ successContent = "Integration has been connected successfully.";
2527
+ } else if (actionType === "disconnectIntegration") {
2528
+ successContent = "Integration has been disconnected successfully.";
2529
+ } else if (actionType === "addPaymentMethod") {
2530
+ successContent = "Payment method has been added successfully.";
2531
+ } else if (actionType === "removePaymentMethod") {
2532
+ successContent = "Payment method has been removed successfully.";
2533
+ } else if (actionType === "deleteApiKey") {
2534
+ successContent = "API key has been deleted successfully.";
2535
+ } else if (actionType === "addWebhook") {
2536
+ successContent = "Webhook endpoint has been added successfully.";
2537
+ } else if (actionType === "updateCurrency") {
2538
+ successContent = "Currency preference has been updated successfully.";
2539
+ } else if (actionType === "updateTimezone") {
2540
+ successContent = "Timezone has been updated successfully.";
2541
+ } else if (actionType === "refundPayment") {
2542
+ successContent = "Refund has been processed successfully.";
2543
+ } else if (actionType === "exportCertificate") {
2544
+ successContent = "Certificate of Incorporation has been downloaded successfully.";
2545
+ } else if (actionType === "createSubscription") {
2546
+ successContent = "Subscription has been created successfully.";
2547
+ } else if (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") {
2548
+ successContent = "Block rule has been updated successfully.";
2549
+ } else {
2550
+ successContent = "Action completed successfully.";
2551
+ }
2552
+ return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 text-gray-700", children: successContent }) }, message.id);
2553
+ }
2554
+ return /* @__PURE__ */ jsxs5("div", { className: `min-w-0 ${isRoleChange ? "mt-3" : ""}`, children: [
2555
+ /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
2556
+ actionType === "updateCompanyInfo" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2557
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2558
+ /* @__PURE__ */ jsxs5("div", { children: [
2559
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2560
+ /* @__PURE__ */ jsx9(
2561
+ Input,
2562
+ {
2563
+ placeholder: "Acme Corporation",
2564
+ value: formData.companyName || "",
2565
+ onChange: (e) => setActionFormData({ ...actionFormData, companyName: e.target.value }),
2566
+ className: "h-8 text-xs border-gray-200"
2567
+ }
2568
+ )
2569
+ ] }),
2570
+ /* @__PURE__ */ jsxs5("div", { children: [
2571
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2572
+ /* @__PURE__ */ jsx9(
2573
+ Input,
2574
+ {
2575
+ type: "email",
2576
+ placeholder: "contact@acme.com",
2577
+ value: formData.email || "",
2578
+ onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2579
+ className: "h-8 text-xs border-gray-200"
2580
+ }
2581
+ )
2582
+ ] })
2583
+ ] }),
2584
+ /* @__PURE__ */ jsxs5("div", { children: [
2585
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2586
+ /* @__PURE__ */ jsx9(
2587
+ Input,
2588
+ {
2589
+ placeholder: "123 Main St, San Francisco, CA",
2590
+ value: formData.address || "",
2591
+ onChange: (e) => setActionFormData({ ...actionFormData, address: e.target.value }),
2592
+ className: "h-8 text-xs border-gray-200"
2593
+ }
2594
+ )
2595
+ ] }),
2596
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2597
+ /* @__PURE__ */ jsxs5("div", { children: [
2598
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2599
+ /* @__PURE__ */ jsx9(
2600
+ Input,
2601
+ {
2602
+ type: "tel",
2603
+ placeholder: "+1 (555) 123-4567",
2604
+ value: formData.phone || "",
2605
+ onChange: (e) => setActionFormData({ ...actionFormData, phone: e.target.value }),
2606
+ className: "h-8 text-xs border-gray-200"
2607
+ }
2608
+ )
2609
+ ] }),
2610
+ /* @__PURE__ */ jsxs5("div", { children: [
2611
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2612
+ /* @__PURE__ */ jsx9(
2613
+ Input,
2614
+ {
2615
+ type: "url",
2616
+ placeholder: "https://acme.com",
2617
+ value: formData.website || "",
2618
+ onChange: (e) => setActionFormData({ ...actionFormData, website: e.target.value }),
2619
+ className: "h-8 text-xs border-gray-200"
2620
+ }
2621
+ )
2622
+ ] })
2623
+ ] })
2568
2624
  ] }),
2569
- /* @__PURE__ */ jsxs5("div", { children: [
2570
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2625
+ actionType === "addApiKey" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2626
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2571
2627
  /* @__PURE__ */ jsx9(
2572
2628
  Input,
2573
2629
  {
2574
- type: "email",
2575
- placeholder: "contact@acme.com",
2576
- value: formData.email || "",
2577
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2630
+ placeholder: "Production Key",
2631
+ value: formData.name || "",
2632
+ onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2578
2633
  className: "h-8 text-xs border-gray-200"
2579
2634
  }
2580
2635
  )
2581
- ] })
2582
- ] }),
2583
- /* @__PURE__ */ jsxs5("div", { children: [
2584
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Address" }),
2585
- /* @__PURE__ */ jsx9(
2586
- Input,
2587
- {
2588
- placeholder: "123 Main St, San Francisco, CA",
2589
- value: formData.address || "",
2590
- onChange: (e) => setActionFormData({ ...actionFormData, address: e.target.value }),
2591
- className: "h-8 text-xs border-gray-200"
2592
- }
2593
- )
2594
- ] }),
2595
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2596
- /* @__PURE__ */ jsxs5("div", { children: [
2597
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Phone" }),
2598
- /* @__PURE__ */ jsx9(
2599
- Input,
2636
+ ] }) }),
2637
+ actionType === "addCustomer" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2638
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2639
+ /* @__PURE__ */ jsxs5("div", { children: [
2640
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2641
+ /* @__PURE__ */ jsx9(
2642
+ Input,
2643
+ {
2644
+ placeholder: "Acme Corporation",
2645
+ value: formData.name || "",
2646
+ onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2647
+ className: "h-8 text-xs border-gray-200"
2648
+ }
2649
+ )
2650
+ ] }),
2651
+ /* @__PURE__ */ jsxs5("div", { children: [
2652
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
2653
+ /* @__PURE__ */ jsx9(
2654
+ Input,
2655
+ {
2656
+ type: "email",
2657
+ placeholder: "contact@acme.com",
2658
+ value: formData.email || "",
2659
+ onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2660
+ className: "h-8 text-xs border-gray-200"
2661
+ }
2662
+ )
2663
+ ] })
2664
+ ] }),
2665
+ /* @__PURE__ */ jsxs5("div", { children: [
2666
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2667
+ /* @__PURE__ */ jsx9(
2668
+ Input,
2669
+ {
2670
+ placeholder: "San Francisco, CA",
2671
+ value: formData.location || "",
2672
+ onChange: (e) => setActionFormData({ ...actionFormData, location: e.target.value }),
2673
+ className: "h-8 text-xs border-gray-200"
2674
+ }
2675
+ )
2676
+ ] }),
2677
+ /* @__PURE__ */ jsxs5("div", { children: [
2678
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
2679
+ /* @__PURE__ */ jsxs5(
2680
+ "select",
2681
+ {
2682
+ value: formData.subscription || "Starter",
2683
+ onChange: (e) => setActionFormData({ ...actionFormData, subscription: e.target.value }),
2684
+ 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",
2685
+ children: [
2686
+ /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter" }),
2687
+ /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional" }),
2688
+ /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise" })
2689
+ ]
2690
+ }
2691
+ )
2692
+ ] })
2693
+ ] }),
2694
+ (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enable2FA" ? "This will enable two-factor authentication for your account. You'll need to set up an authenticator app." : "This will disable two-factor authentication for your account. Your account will be less secure." }) }),
2695
+ actionType === "changePassword" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2696
+ /* @__PURE__ */ jsxs5("div", { children: [
2697
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
2698
+ /* @__PURE__ */ jsx9(
2699
+ Input,
2700
+ {
2701
+ type: "password",
2702
+ value: formData.currentPassword || "",
2703
+ onChange: (e) => setActionFormData({ ...actionFormData, currentPassword: e.target.value }),
2704
+ className: "h-8 text-xs border-gray-200"
2705
+ }
2706
+ )
2707
+ ] }),
2708
+ /* @__PURE__ */ jsxs5("div", { children: [
2709
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
2710
+ /* @__PURE__ */ jsx9(
2711
+ Input,
2712
+ {
2713
+ type: "password",
2714
+ value: formData.newPassword || "",
2715
+ onChange: (e) => setActionFormData({ ...actionFormData, newPassword: e.target.value }),
2716
+ className: "h-8 text-xs border-gray-200"
2717
+ }
2718
+ )
2719
+ ] }),
2720
+ /* @__PURE__ */ jsxs5("div", { children: [
2721
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
2722
+ /* @__PURE__ */ jsx9(
2723
+ Input,
2724
+ {
2725
+ type: "password",
2726
+ value: formData.confirmPassword || "",
2727
+ onChange: (e) => setActionFormData({ ...actionFormData, confirmPassword: e.target.value }),
2728
+ className: "h-8 text-xs border-gray-200"
2729
+ }
2730
+ )
2731
+ ] })
2732
+ ] }),
2733
+ actionType === "toggleNotification" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2734
+ /* @__PURE__ */ jsxs5("div", { children: [
2735
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
2736
+ /* @__PURE__ */ jsxs5(
2737
+ "select",
2738
+ {
2739
+ value: formData.notificationType || "paymentReceived",
2740
+ onChange: (e) => setActionFormData({ ...actionFormData, notificationType: e.target.value }),
2741
+ 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",
2742
+ children: [
2743
+ /* @__PURE__ */ jsx9("option", { value: "paymentReceived", children: "Payment Received" }),
2744
+ /* @__PURE__ */ jsx9("option", { value: "paymentFailed", children: "Payment Failed" }),
2745
+ /* @__PURE__ */ jsx9("option", { value: "invoicePaid", children: "Invoice Paid" }),
2746
+ /* @__PURE__ */ jsx9("option", { value: "monthlySummary", children: "Monthly Summary" }),
2747
+ /* @__PURE__ */ jsx9("option", { value: "productUpdates", children: "Product Updates" })
2748
+ ]
2749
+ }
2750
+ )
2751
+ ] }),
2752
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
2753
+ /* @__PURE__ */ jsx9(
2754
+ "input",
2755
+ {
2756
+ type: "checkbox",
2757
+ checked: formData.enabled !== false,
2758
+ onChange: (e) => setActionFormData({ ...actionFormData, enabled: e.target.checked }),
2759
+ className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
2760
+ }
2761
+ ),
2762
+ /* @__PURE__ */ jsx9("label", { className: "text-xs text-black", children: "Enable this notification" })
2763
+ ] })
2764
+ ] }),
2765
+ (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2766
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
2767
+ /* @__PURE__ */ jsxs5(
2768
+ "select",
2600
2769
  {
2601
- type: "tel",
2602
- placeholder: "+1 (555) 123-4567",
2603
- value: formData.phone || "",
2604
- onChange: (e) => setActionFormData({ ...actionFormData, phone: e.target.value }),
2605
- className: "h-8 text-xs border-gray-200"
2770
+ value: formData.integrationName || "Slack",
2771
+ onChange: (e) => setActionFormData({ ...actionFormData, integrationName: e.target.value }),
2772
+ 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",
2773
+ children: [
2774
+ /* @__PURE__ */ jsx9("option", { value: "Slack", children: "Slack" }),
2775
+ /* @__PURE__ */ jsx9("option", { value: "Zapier", children: "Zapier" }),
2776
+ /* @__PURE__ */ jsx9("option", { value: "Webhook", children: "Webhook" })
2777
+ ]
2606
2778
  }
2607
2779
  )
2780
+ ] }) }),
2781
+ actionType === "addPaymentMethod" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2782
+ /* @__PURE__ */ jsxs5("div", { children: [
2783
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
2784
+ /* @__PURE__ */ jsx9(
2785
+ Input,
2786
+ {
2787
+ placeholder: "1234 5678 9012 3456",
2788
+ value: formData.cardNumber || "",
2789
+ onChange: (e) => setActionFormData({ ...actionFormData, cardNumber: e.target.value }),
2790
+ className: "h-8 text-xs border-gray-200"
2791
+ }
2792
+ )
2793
+ ] }),
2794
+ /* @__PURE__ */ jsxs5("div", { children: [
2795
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
2796
+ /* @__PURE__ */ jsx9(
2797
+ Input,
2798
+ {
2799
+ placeholder: "MM/YY",
2800
+ value: formData.expiryDate || "",
2801
+ onChange: (e) => setActionFormData({ ...actionFormData, expiryDate: e.target.value }),
2802
+ className: "h-8 text-xs border-gray-200"
2803
+ }
2804
+ )
2805
+ ] })
2608
2806
  ] }),
2609
- /* @__PURE__ */ jsxs5("div", { children: [
2610
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Website" }),
2611
- /* @__PURE__ */ jsx9(
2612
- Input,
2807
+ actionType === "removePaymentMethod" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
2808
+ actionType === "refundPayment" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2809
+ /* @__PURE__ */ jsxs5("div", { children: [
2810
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
2811
+ /* @__PURE__ */ jsx9(
2812
+ Input,
2813
+ {
2814
+ placeholder: "e.g., txn_1234 or Acme Corp",
2815
+ value: formData.transactionId || formData.customer || "",
2816
+ onChange: (e) => {
2817
+ const value = e.target.value;
2818
+ if (value.startsWith("txn_") || /^\d+$/.test(value)) {
2819
+ setActionFormData({ ...actionFormData, transactionId: value, customer: void 0 });
2820
+ } else {
2821
+ setActionFormData({ ...actionFormData, customer: value, transactionId: void 0 });
2822
+ }
2823
+ },
2824
+ className: "h-8 text-xs border-gray-200"
2825
+ }
2826
+ )
2827
+ ] }),
2828
+ /* @__PURE__ */ jsxs5("div", { children: [
2829
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
2830
+ /* @__PURE__ */ jsx9(
2831
+ Input,
2832
+ {
2833
+ placeholder: "$0.00",
2834
+ value: formData.amount || "",
2835
+ onChange: (e) => setActionFormData({ ...actionFormData, amount: e.target.value }),
2836
+ className: "h-8 text-xs border-gray-200"
2837
+ }
2838
+ )
2839
+ ] }),
2840
+ /* @__PURE__ */ jsxs5("div", { children: [
2841
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
2842
+ /* @__PURE__ */ jsx9(
2843
+ Input,
2844
+ {
2845
+ placeholder: "e.g., Customer request",
2846
+ value: formData.reason || "",
2847
+ onChange: (e) => setActionFormData({ ...actionFormData, reason: e.target.value }),
2848
+ className: "h-8 text-xs border-gray-200"
2849
+ }
2850
+ )
2851
+ ] })
2852
+ ] }),
2853
+ actionType === "deleteApiKey" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2854
+ /* @__PURE__ */ jsxs5("div", { children: [
2855
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
2856
+ /* @__PURE__ */ jsx9(
2857
+ Input,
2858
+ {
2859
+ placeholder: "Production Key",
2860
+ value: formData.keyId || formData.name || "",
2861
+ onChange: (e) => setActionFormData({ ...actionFormData, keyId: e.target.value, name: e.target.value }),
2862
+ className: "h-8 text-xs border-gray-200"
2863
+ }
2864
+ )
2865
+ ] }),
2866
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
2867
+ ] }),
2868
+ actionType === "addWebhook" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2869
+ /* @__PURE__ */ jsxs5("div", { children: [
2870
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
2871
+ /* @__PURE__ */ jsx9(
2872
+ Input,
2873
+ {
2874
+ type: "url",
2875
+ placeholder: "https://example.com/webhook",
2876
+ value: formData.url || "",
2877
+ onChange: (e) => setActionFormData({ ...actionFormData, url: e.target.value }),
2878
+ className: "h-8 text-xs border-gray-200"
2879
+ }
2880
+ )
2881
+ ] }),
2882
+ /* @__PURE__ */ jsxs5("div", { children: [
2883
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
2884
+ /* @__PURE__ */ jsx9(
2885
+ Input,
2886
+ {
2887
+ placeholder: "Production Webhook",
2888
+ value: formData.name || "",
2889
+ onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2890
+ className: "h-8 text-xs border-gray-200"
2891
+ }
2892
+ )
2893
+ ] })
2894
+ ] }),
2895
+ actionType === "updateCurrency" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2896
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
2897
+ /* @__PURE__ */ jsxs5(
2898
+ "select",
2613
2899
  {
2614
- type: "url",
2615
- placeholder: "https://acme.com",
2616
- value: formData.website || "",
2617
- onChange: (e) => setActionFormData({ ...actionFormData, website: e.target.value }),
2618
- className: "h-8 text-xs border-gray-200"
2900
+ value: formData.currency || "USD",
2901
+ onChange: (e) => setActionFormData({ ...actionFormData, currency: e.target.value }),
2902
+ 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",
2903
+ children: [
2904
+ /* @__PURE__ */ jsx9("option", { value: "USD", children: "USD ($)" }),
2905
+ /* @__PURE__ */ jsx9("option", { value: "EUR", children: "EUR (\u20AC)" }),
2906
+ /* @__PURE__ */ jsx9("option", { value: "GBP", children: "GBP (\xA3)" }),
2907
+ /* @__PURE__ */ jsx9("option", { value: "JPY", children: "JPY (\xA5)" })
2908
+ ]
2619
2909
  }
2620
2910
  )
2621
- ] })
2622
- ] })
2623
- ] }),
2624
- actionType === "addApiKey" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2625
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name" }),
2626
- /* @__PURE__ */ jsx9(
2627
- Input,
2628
- {
2629
- placeholder: "Production Key",
2630
- value: formData.name || "",
2631
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2632
- className: "h-8 text-xs border-gray-200"
2633
- }
2634
- )
2635
- ] }) }),
2636
- actionType === "addCustomer" && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 bg-gray-50 rounded-lg p-2 border border-gray-200 overflow-hidden", children: [
2637
- /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-2 gap-2", children: [
2638
- /* @__PURE__ */ jsxs5("div", { children: [
2639
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Company Name" }),
2640
- /* @__PURE__ */ jsx9(
2641
- Input,
2911
+ ] }) }),
2912
+ actionType === "updateTimezone" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2913
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
2914
+ /* @__PURE__ */ jsxs5(
2915
+ "select",
2642
2916
  {
2643
- placeholder: "Acme Corporation",
2644
- value: formData.name || "",
2645
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2646
- className: "h-8 text-xs border-gray-200"
2917
+ value: formData.timezone || "America/Los_Angeles",
2918
+ onChange: (e) => setActionFormData({ ...actionFormData, timezone: e.target.value }),
2919
+ 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",
2920
+ children: [
2921
+ /* @__PURE__ */ jsx9("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
2922
+ /* @__PURE__ */ jsx9("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
2923
+ /* @__PURE__ */ jsx9("option", { value: "Europe/London", children: "GMT" }),
2924
+ /* @__PURE__ */ jsx9("option", { value: "Asia/Tokyo", children: "JST" })
2925
+ ]
2647
2926
  }
2648
2927
  )
2928
+ ] }) }),
2929
+ actionType === "revokeSession" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2930
+ /* @__PURE__ */ jsxs5("div", { children: [
2931
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
2932
+ /* @__PURE__ */ jsx9(
2933
+ Input,
2934
+ {
2935
+ placeholder: "MacBook Pro",
2936
+ value: formData.device || "",
2937
+ onChange: (e) => setActionFormData({ ...actionFormData, device: e.target.value }),
2938
+ className: "h-8 text-xs border-gray-200"
2939
+ }
2940
+ )
2941
+ ] }),
2942
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
2943
+ ] }),
2944
+ actionType === "createSubscription" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2945
+ /* @__PURE__ */ jsxs5("div", { children: [
2946
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
2947
+ /* @__PURE__ */ jsx9(
2948
+ Input,
2949
+ {
2950
+ type: "email",
2951
+ placeholder: "customer@example.com",
2952
+ value: formData.customerEmail || "",
2953
+ onChange: (e) => setActionFormData({ ...actionFormData, customerEmail: e.target.value }),
2954
+ className: "h-8 text-xs border-gray-200"
2955
+ }
2956
+ )
2957
+ ] }),
2958
+ /* @__PURE__ */ jsxs5("div", { children: [
2959
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
2960
+ /* @__PURE__ */ jsxs5(
2961
+ "select",
2962
+ {
2963
+ value: formData.plan || "Starter",
2964
+ onChange: (e) => setActionFormData({ ...actionFormData, plan: e.target.value }),
2965
+ 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",
2966
+ children: [
2967
+ /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter ($29/mo)" }),
2968
+ /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional ($99/mo)" }),
2969
+ /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
2970
+ ]
2971
+ }
2972
+ )
2973
+ ] }),
2974
+ /* @__PURE__ */ jsxs5("div", { children: [
2975
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
2976
+ /* @__PURE__ */ jsxs5(
2977
+ "select",
2978
+ {
2979
+ value: formData.billingCycle || "monthly",
2980
+ onChange: (e) => setActionFormData({ ...actionFormData, billingCycle: e.target.value }),
2981
+ 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",
2982
+ children: [
2983
+ /* @__PURE__ */ jsx9("option", { value: "monthly", children: "Monthly" }),
2984
+ /* @__PURE__ */ jsx9("option", { value: "yearly", children: "Yearly (Save 15%)" })
2985
+ ]
2986
+ }
2987
+ )
2988
+ ] })
2989
+ ] }),
2990
+ actionType === "exportCertificate" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2991
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
2992
+ /* @__PURE__ */ jsxs5("div", { children: [
2993
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
2994
+ /* @__PURE__ */ jsxs5(
2995
+ "select",
2996
+ {
2997
+ value: formData.format || "pdf",
2998
+ onChange: (e) => setActionFormData({ ...actionFormData, format: e.target.value }),
2999
+ 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",
3000
+ children: [
3001
+ /* @__PURE__ */ jsx9("option", { value: "pdf", children: "PDF" }),
3002
+ /* @__PURE__ */ jsx9("option", { value: "json", children: "JSON" })
3003
+ ]
3004
+ }
3005
+ )
3006
+ ] })
3007
+ ] }),
3008
+ (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3009
+ /* @__PURE__ */ jsxs5("div", { children: [
3010
+ /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3011
+ /* @__PURE__ */ jsxs5(
3012
+ "select",
3013
+ {
3014
+ value: formData.ruleId || "rule_1",
3015
+ onChange: (e) => setActionFormData({ ...actionFormData, ruleId: e.target.value }),
3016
+ 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",
3017
+ children: [
3018
+ /* @__PURE__ */ jsx9("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3019
+ /* @__PURE__ */ jsx9("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3020
+ /* @__PURE__ */ jsx9("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3021
+ /* @__PURE__ */ jsx9("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3022
+ ]
3023
+ }
3024
+ )
3025
+ ] }),
3026
+ /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enableBlockRule" ? "This will enable the selected block rule to actively block matching payments." : actionType === "disableBlockRule" ? "This will disable the selected block rule. Matching payments will no longer be blocked." : "This will toggle the selected block rule's state." })
2649
3027
  ] }),
2650
- /* @__PURE__ */ jsxs5("div", { children: [
2651
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Email" }),
3028
+ /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsxs5(
3029
+ Button,
3030
+ {
3031
+ type: "button",
3032
+ size: "sm",
3033
+ variant: "secondary",
3034
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3035
+ onClick: handleActionSubmit,
3036
+ children: [
3037
+ /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
3038
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3039
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3040
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3041
+ ] })
3042
+ ]
3043
+ }
3044
+ ) })
3045
+ ] }, message.id);
3046
+ }
3047
+ if (message.kind === "bulkPreview" && message.csvData) {
3048
+ return /* @__PURE__ */ jsxs5("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
3049
+ /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3050
+ /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3051
+ /* @__PURE__ */ jsxs5("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3052
+ /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3053
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3054
+ /* @__PURE__ */ jsxs5("span", { className: "text-xs text-gray-500", children: [
3055
+ "\u2022 ",
3056
+ message.csvData.rowCount,
3057
+ " rows"
3058
+ ] })
3059
+ ] }),
3060
+ /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3061
+ /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3062
+ /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ jsx9("span", { className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded", children: col }, i)) })
3063
+ ] }),
3064
+ message.csvData.sampleRows.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2", children: [
3065
+ /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3066
+ /* @__PURE__ */ jsx9("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ jsxs5("div", { className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100", children: [
3067
+ Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ jsxs5("span", { children: [
3068
+ j > 0 && " \u2022 ",
3069
+ /* @__PURE__ */ jsxs5("span", { className: "text-gray-400", children: [
3070
+ key,
3071
+ ":"
3072
+ ] }),
3073
+ " ",
3074
+ val
3075
+ ] }, key)),
3076
+ Object.keys(row).length > 3 && /* @__PURE__ */ jsx9("span", { className: "text-gray-400", children: " ..." })
3077
+ ] }, i)) })
3078
+ ] }),
3079
+ message.suggestedAction && /* @__PURE__ */ jsx9("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ jsxs5("span", { className: "text-xs text-blue-700", children: [
3080
+ "Suggested action: ",
3081
+ /* @__PURE__ */ jsx9("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3082
+ ] }) })
3083
+ ] }),
3084
+ message.bulkSessionId && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3085
+ /* @__PURE__ */ jsxs5(
3086
+ Button,
3087
+ {
3088
+ type: "button",
3089
+ size: "sm",
3090
+ variant: "secondary",
3091
+ className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3092
+ onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3093
+ children: [
3094
+ /* @__PURE__ */ jsxs5("span", { children: [
3095
+ "Process ",
3096
+ message.csvData.rowCount,
3097
+ " rows"
3098
+ ] }),
3099
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3100
+ /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3101
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3102
+ ] })
3103
+ ]
3104
+ }
3105
+ ),
2652
3106
  /* @__PURE__ */ jsx9(
2653
- Input,
3107
+ Button,
2654
3108
  {
2655
- type: "email",
2656
- placeholder: "contact@acme.com",
2657
- value: formData.email || "",
2658
- onChange: (e) => setActionFormData({ ...actionFormData, email: e.target.value }),
2659
- className: "h-8 text-xs border-gray-200"
3109
+ type: "button",
3110
+ size: "sm",
3111
+ variant: "ghost",
3112
+ className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3113
+ onClick: cancelBulkOperation,
3114
+ children: "Cancel"
2660
3115
  }
2661
3116
  )
2662
3117
  ] })
2663
- ] }),
2664
- /* @__PURE__ */ jsxs5("div", { children: [
2665
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Location" }),
2666
- /* @__PURE__ */ jsx9(
2667
- Input,
2668
- {
2669
- placeholder: "San Francisco, CA",
2670
- value: formData.location || "",
2671
- onChange: (e) => setActionFormData({ ...actionFormData, location: e.target.value }),
2672
- className: "h-8 text-xs border-gray-200"
2673
- }
2674
- )
2675
- ] }),
2676
- /* @__PURE__ */ jsxs5("div", { children: [
2677
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Subscription Tier" }),
2678
- /* @__PURE__ */ jsxs5(
2679
- "select",
2680
- {
2681
- value: formData.subscription || "Starter",
2682
- onChange: (e) => setActionFormData({ ...actionFormData, subscription: e.target.value }),
2683
- 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",
2684
- children: [
2685
- /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter" }),
2686
- /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional" }),
2687
- /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise" })
2688
- ]
2689
- }
2690
- )
2691
- ] })
2692
- ] }),
2693
- (actionType === "enable2FA" || actionType === "disable2FA") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enable2FA" ? "This will enable two-factor authentication for your account. You'll need to set up an authenticator app." : "This will disable two-factor authentication for your account. Your account will be less secure." }) }),
2694
- actionType === "changePassword" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2695
- /* @__PURE__ */ jsxs5("div", { children: [
2696
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Current Password" }),
2697
- /* @__PURE__ */ jsx9(
2698
- Input,
2699
- {
2700
- type: "password",
2701
- value: formData.currentPassword || "",
2702
- onChange: (e) => setActionFormData({ ...actionFormData, currentPassword: e.target.value }),
2703
- className: "h-8 text-xs border-gray-200"
2704
- }
2705
- )
2706
- ] }),
2707
- /* @__PURE__ */ jsxs5("div", { children: [
2708
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "New Password" }),
2709
- /* @__PURE__ */ jsx9(
2710
- Input,
2711
- {
2712
- type: "password",
2713
- value: formData.newPassword || "",
2714
- onChange: (e) => setActionFormData({ ...actionFormData, newPassword: e.target.value }),
2715
- className: "h-8 text-xs border-gray-200"
2716
- }
2717
- )
2718
- ] }),
2719
- /* @__PURE__ */ jsxs5("div", { children: [
2720
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Confirm New Password" }),
2721
- /* @__PURE__ */ jsx9(
2722
- Input,
2723
- {
2724
- type: "password",
2725
- value: formData.confirmPassword || "",
2726
- onChange: (e) => setActionFormData({ ...actionFormData, confirmPassword: e.target.value }),
2727
- className: "h-8 text-xs border-gray-200"
2728
- }
2729
- )
2730
- ] })
2731
- ] }),
2732
- actionType === "toggleNotification" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2733
- /* @__PURE__ */ jsxs5("div", { children: [
2734
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Notification Type" }),
2735
- /* @__PURE__ */ jsxs5(
2736
- "select",
2737
- {
2738
- value: formData.notificationType || "paymentReceived",
2739
- onChange: (e) => setActionFormData({ ...actionFormData, notificationType: e.target.value }),
2740
- 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",
2741
- children: [
2742
- /* @__PURE__ */ jsx9("option", { value: "paymentReceived", children: "Payment Received" }),
2743
- /* @__PURE__ */ jsx9("option", { value: "paymentFailed", children: "Payment Failed" }),
2744
- /* @__PURE__ */ jsx9("option", { value: "invoicePaid", children: "Invoice Paid" }),
2745
- /* @__PURE__ */ jsx9("option", { value: "monthlySummary", children: "Monthly Summary" }),
2746
- /* @__PURE__ */ jsx9("option", { value: "productUpdates", children: "Product Updates" })
2747
- ]
2748
- }
2749
- )
2750
- ] }),
2751
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
2752
- /* @__PURE__ */ jsx9(
2753
- "input",
2754
- {
2755
- type: "checkbox",
2756
- checked: formData.enabled !== false,
2757
- onChange: (e) => setActionFormData({ ...actionFormData, enabled: e.target.checked }),
2758
- className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"
2759
- }
2760
- ),
2761
- /* @__PURE__ */ jsx9("label", { className: "text-xs text-black", children: "Enable this notification" })
2762
- ] })
2763
- ] }),
2764
- (actionType === "connectIntegration" || actionType === "disconnectIntegration") && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2765
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Integration" }),
2766
- /* @__PURE__ */ jsxs5(
2767
- "select",
2768
- {
2769
- value: formData.integrationName || "Slack",
2770
- onChange: (e) => setActionFormData({ ...actionFormData, integrationName: e.target.value }),
2771
- 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",
2772
- children: [
2773
- /* @__PURE__ */ jsx9("option", { value: "Slack", children: "Slack" }),
2774
- /* @__PURE__ */ jsx9("option", { value: "Zapier", children: "Zapier" }),
2775
- /* @__PURE__ */ jsx9("option", { value: "Webhook", children: "Webhook" })
2776
- ]
2777
- }
2778
- )
2779
- ] }) }),
2780
- actionType === "addPaymentMethod" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2781
- /* @__PURE__ */ jsxs5("div", { children: [
2782
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Card Number" }),
2783
- /* @__PURE__ */ jsx9(
2784
- Input,
2785
- {
2786
- placeholder: "1234 5678 9012 3456",
2787
- value: formData.cardNumber || "",
2788
- onChange: (e) => setActionFormData({ ...actionFormData, cardNumber: e.target.value }),
2789
- className: "h-8 text-xs border-gray-200"
2790
- }
2791
- )
2792
- ] }),
2793
- /* @__PURE__ */ jsxs5("div", { children: [
2794
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Expiry Date" }),
2795
- /* @__PURE__ */ jsx9(
2796
- Input,
3118
+ ] }, message.id);
3119
+ }
3120
+ if (message.kind === "bulkProgress" && message.bulkProgress) {
3121
+ const { processed, total, successes, failures } = message.bulkProgress;
3122
+ const percentage = Math.round(processed / total * 100);
3123
+ return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3124
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3125
+ /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-blue-600" }),
3126
+ /* @__PURE__ */ jsxs5("span", { className: "text-sm font-medium text-gray-700", children: [
3127
+ "Processing... ",
3128
+ processed,
3129
+ " of ",
3130
+ total
3131
+ ] })
3132
+ ] }),
3133
+ /* @__PURE__ */ jsx9("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ jsx9(
3134
+ "div",
2797
3135
  {
2798
- placeholder: "MM/YY",
2799
- value: formData.expiryDate || "",
2800
- onChange: (e) => setActionFormData({ ...actionFormData, expiryDate: e.target.value }),
2801
- className: "h-8 text-xs border-gray-200"
3136
+ className: "h-full bg-blue-600 transition-all duration-300",
3137
+ style: { width: `${percentage}%` }
2802
3138
  }
2803
- )
2804
- ] })
2805
- ] }),
2806
- actionType === "removePaymentMethod" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will remove the default payment method from your account." }) }),
2807
- actionType === "refundPayment" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2808
- /* @__PURE__ */ jsxs5("div", { children: [
2809
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Transaction ID or Customer Name" }),
2810
- /* @__PURE__ */ jsx9(
2811
- Input,
3139
+ ) }),
3140
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3141
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1", children: [
3142
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3 text-green-600" }),
3143
+ successes,
3144
+ " successful"
3145
+ ] }),
3146
+ failures > 0 && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3147
+ /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3148
+ failures,
3149
+ " failed"
3150
+ ] })
3151
+ ] })
3152
+ ] }) }, message.id);
3153
+ }
3154
+ if (message.kind === "bulkSummary" && message.bulkSummary) {
3155
+ const { total, successes, failures, navigationPage } = message.bulkSummary;
3156
+ const hasFailures = failures.length > 0;
3157
+ const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3158
+ return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`, children: [
3159
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3160
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}` }),
3161
+ /* @__PURE__ */ jsx9("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3162
+ ] }),
3163
+ /* @__PURE__ */ jsx9("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3164
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4 text-xs", children: [
3165
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-green-700", children: [
3166
+ /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3" }),
3167
+ successes,
3168
+ " successful"
3169
+ ] }),
3170
+ hasFailures && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3171
+ /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3172
+ failures.length,
3173
+ " failed"
3174
+ ] })
3175
+ ] }),
3176
+ hasFailures && /* @__PURE__ */ jsxs5("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3177
+ /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3178
+ /* @__PURE__ */ jsxs5("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3179
+ failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ jsxs5("div", { className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1", children: [
3180
+ "Row ",
3181
+ failure.row,
3182
+ ": ",
3183
+ failure.error || "Unknown error"
3184
+ ] }, i)),
3185
+ failures.length > 5 && /* @__PURE__ */ jsxs5("div", { className: "text-xs text-amber-600", children: [
3186
+ "...and ",
3187
+ failures.length - 5,
3188
+ " more"
3189
+ ] })
3190
+ ] })
3191
+ ] }),
3192
+ navigationPage && successes > 0 && /* @__PURE__ */ jsx9("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ jsxs5(
3193
+ "button",
2812
3194
  {
2813
- placeholder: "e.g., txn_1234 or Acme Corp",
2814
- value: formData.transactionId || formData.customer || "",
2815
- onChange: (e) => {
2816
- const value = e.target.value;
2817
- if (value.startsWith("txn_") || /^\d+$/.test(value)) {
2818
- setActionFormData({ ...actionFormData, transactionId: value, customer: void 0 });
3195
+ type: "button",
3196
+ onClick: (e) => {
3197
+ e.preventDefault();
3198
+ e.stopPropagation();
3199
+ console.log("[DEBUG] Button clicked - navigationPage:", navigationPage, "onNavigate:", !!onNavigate);
3200
+ if (onNavigate && navigationPage.page) {
3201
+ console.log("[DEBUG] Calling onNavigate with page:", navigationPage.page);
3202
+ onNavigate(navigationPage.page, navigationPage.subtab);
2819
3203
  } else {
2820
- setActionFormData({ ...actionFormData, customer: value, transactionId: void 0 });
3204
+ console.log("[DEBUG] Condition failed - onNavigate:", !!onNavigate, "navigationPage.page:", navigationPage.page);
2821
3205
  }
2822
3206
  },
2823
- className: "h-8 text-xs border-gray-200"
2824
- }
2825
- )
2826
- ] }),
2827
- /* @__PURE__ */ jsxs5("div", { children: [
2828
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Amount (optional)" }),
2829
- /* @__PURE__ */ jsx9(
2830
- Input,
2831
- {
2832
- placeholder: "$0.00",
2833
- value: formData.amount || "",
2834
- onChange: (e) => setActionFormData({ ...actionFormData, amount: e.target.value }),
2835
- className: "h-8 text-xs border-gray-200"
2836
- }
2837
- )
2838
- ] }),
2839
- /* @__PURE__ */ jsxs5("div", { children: [
2840
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Reason (optional)" }),
2841
- /* @__PURE__ */ jsx9(
2842
- Input,
2843
- {
2844
- placeholder: "e.g., Customer request",
2845
- value: formData.reason || "",
2846
- onChange: (e) => setActionFormData({ ...actionFormData, reason: e.target.value }),
2847
- className: "h-8 text-xs border-gray-200"
2848
- }
2849
- )
2850
- ] })
2851
- ] }),
2852
- actionType === "deleteApiKey" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2853
- /* @__PURE__ */ jsxs5("div", { children: [
2854
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "API Key Name or ID" }),
2855
- /* @__PURE__ */ jsx9(
2856
- Input,
2857
- {
2858
- placeholder: "Production Key",
2859
- value: formData.keyId || formData.name || "",
2860
- onChange: (e) => setActionFormData({ ...actionFormData, keyId: e.target.value, name: e.target.value }),
2861
- className: "h-8 text-xs border-gray-200"
2862
- }
2863
- )
2864
- ] }),
2865
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-red-600", children: "Warning: This action cannot be undone. The API key will be permanently deleted." })
2866
- ] }),
2867
- actionType === "addWebhook" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2868
- /* @__PURE__ */ jsxs5("div", { children: [
2869
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Webhook URL" }),
2870
- /* @__PURE__ */ jsx9(
2871
- Input,
2872
- {
2873
- type: "url",
2874
- placeholder: "https://example.com/webhook",
2875
- value: formData.url || "",
2876
- onChange: (e) => setActionFormData({ ...actionFormData, url: e.target.value }),
2877
- className: "h-8 text-xs border-gray-200"
2878
- }
2879
- )
2880
- ] }),
2881
- /* @__PURE__ */ jsxs5("div", { children: [
2882
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Name (optional)" }),
2883
- /* @__PURE__ */ jsx9(
2884
- Input,
2885
- {
2886
- placeholder: "Production Webhook",
2887
- value: formData.name || "",
2888
- onChange: (e) => setActionFormData({ ...actionFormData, name: e.target.value }),
2889
- className: "h-8 text-xs border-gray-200"
2890
- }
2891
- )
2892
- ] })
2893
- ] }),
2894
- actionType === "updateCurrency" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2895
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Currency" }),
2896
- /* @__PURE__ */ jsxs5(
2897
- "select",
2898
- {
2899
- value: formData.currency || "USD",
2900
- onChange: (e) => setActionFormData({ ...actionFormData, currency: e.target.value }),
2901
- 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",
2902
- children: [
2903
- /* @__PURE__ */ jsx9("option", { value: "USD", children: "USD ($)" }),
2904
- /* @__PURE__ */ jsx9("option", { value: "EUR", children: "EUR (\u20AC)" }),
2905
- /* @__PURE__ */ jsx9("option", { value: "GBP", children: "GBP (\xA3)" }),
2906
- /* @__PURE__ */ jsx9("option", { value: "JPY", children: "JPY (\xA5)" })
2907
- ]
2908
- }
2909
- )
2910
- ] }) }),
2911
- actionType === "updateTimezone" && /* @__PURE__ */ jsx9("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: /* @__PURE__ */ jsxs5("div", { children: [
2912
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Timezone" }),
2913
- /* @__PURE__ */ jsxs5(
2914
- "select",
2915
- {
2916
- value: formData.timezone || "America/Los_Angeles",
2917
- onChange: (e) => setActionFormData({ ...actionFormData, timezone: e.target.value }),
2918
- 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",
2919
- children: [
2920
- /* @__PURE__ */ jsx9("option", { value: "America/Los_Angeles", children: "Pacific Time (PT)" }),
2921
- /* @__PURE__ */ jsx9("option", { value: "America/New_York", children: "Eastern Time (ET)" }),
2922
- /* @__PURE__ */ jsx9("option", { value: "Europe/London", children: "GMT" }),
2923
- /* @__PURE__ */ jsx9("option", { value: "Asia/Tokyo", children: "JST" })
2924
- ]
2925
- }
2926
- )
2927
- ] }) }),
2928
- actionType === "revokeSession" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2929
- /* @__PURE__ */ jsxs5("div", { children: [
2930
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Device/Session" }),
2931
- /* @__PURE__ */ jsx9(
2932
- Input,
2933
- {
2934
- placeholder: "MacBook Pro",
2935
- value: formData.device || "",
2936
- onChange: (e) => setActionFormData({ ...actionFormData, device: e.target.value }),
2937
- className: "h-8 text-xs border-gray-200"
2938
- }
2939
- )
2940
- ] }),
2941
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will sign out the device and invalidate its session." })
2942
- ] }),
2943
- actionType === "createSubscription" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2944
- /* @__PURE__ */ jsxs5("div", { children: [
2945
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Customer Email" }),
2946
- /* @__PURE__ */ jsx9(
2947
- Input,
2948
- {
2949
- type: "email",
2950
- placeholder: "customer@example.com",
2951
- value: formData.customerEmail || "",
2952
- onChange: (e) => setActionFormData({ ...actionFormData, customerEmail: e.target.value }),
2953
- className: "h-8 text-xs border-gray-200"
2954
- }
2955
- )
2956
- ] }),
2957
- /* @__PURE__ */ jsxs5("div", { children: [
2958
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Plan" }),
2959
- /* @__PURE__ */ jsxs5(
2960
- "select",
2961
- {
2962
- value: formData.plan || "Starter",
2963
- onChange: (e) => setActionFormData({ ...actionFormData, plan: e.target.value }),
2964
- 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",
2965
- children: [
2966
- /* @__PURE__ */ jsx9("option", { value: "Starter", children: "Starter ($29/mo)" }),
2967
- /* @__PURE__ */ jsx9("option", { value: "Professional", children: "Professional ($99/mo)" }),
2968
- /* @__PURE__ */ jsx9("option", { value: "Enterprise", children: "Enterprise ($299/mo)" })
2969
- ]
2970
- }
2971
- )
2972
- ] }),
2973
- /* @__PURE__ */ jsxs5("div", { children: [
2974
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Billing Cycle" }),
2975
- /* @__PURE__ */ jsxs5(
2976
- "select",
2977
- {
2978
- value: formData.billingCycle || "monthly",
2979
- onChange: (e) => setActionFormData({ ...actionFormData, billingCycle: e.target.value }),
2980
- 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",
3207
+ className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
2981
3208
  children: [
2982
- /* @__PURE__ */ jsx9("option", { value: "monthly", children: "Monthly" }),
2983
- /* @__PURE__ */ jsx9("option", { value: "yearly", children: "Yearly (Save 15%)" })
3209
+ /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 px-1.5 py-0.5 bg-gray-100 rounded text-[10px] font-medium text-gray-600 group-hover:bg-gray-200", children: [
3210
+ /* @__PURE__ */ jsx9(Command, { className: "h-2.5 w-2.5" }),
3211
+ /* @__PURE__ */ jsx9("span", { children: "+" }),
3212
+ /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-2.5 w-2.5" })
3213
+ ] }),
3214
+ /* @__PURE__ */ jsxs5("span", { children: [
3215
+ "View ",
3216
+ pageLabel
3217
+ ] })
2984
3218
  ]
2985
3219
  }
2986
- )
2987
- ] })
2988
- ] }),
2989
- actionType === "exportCertificate" && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2990
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: "This will export your certificate of incorporation document." }),
2991
- /* @__PURE__ */ jsxs5("div", { children: [
2992
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Format" }),
2993
- /* @__PURE__ */ jsxs5(
2994
- "select",
2995
- {
2996
- value: formData.format || "pdf",
2997
- onChange: (e) => setActionFormData({ ...actionFormData, format: e.target.value }),
2998
- 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",
2999
- children: [
3000
- /* @__PURE__ */ jsx9("option", { value: "pdf", children: "PDF" }),
3001
- /* @__PURE__ */ jsx9("option", { value: "json", children: "JSON" })
3002
- ]
3003
- }
3004
- )
3005
- ] })
3006
- ] }),
3007
- (actionType === "toggleBlockRule" || actionType === "enableBlockRule" || actionType === "disableBlockRule") && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3008
- /* @__PURE__ */ jsxs5("div", { children: [
3009
- /* @__PURE__ */ jsx9("label", { className: "text-xs font-medium text-black mb-1.5 block", children: "Block Rule" }),
3010
- /* @__PURE__ */ jsxs5(
3011
- "select",
3012
- {
3013
- value: formData.ruleId || "rule_1",
3014
- onChange: (e) => setActionFormData({ ...actionFormData, ruleId: e.target.value }),
3015
- 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",
3016
- children: [
3017
- /* @__PURE__ */ jsx9("option", { value: "rule_1", children: "Block if risk level = 'highest'" }),
3018
- /* @__PURE__ */ jsx9("option", { value: "rule_2", children: "Block if matches Stripe block lists" }),
3019
- /* @__PURE__ */ jsx9("option", { value: "rule_3", children: "Block if CVC verification fails" }),
3020
- /* @__PURE__ */ jsx9("option", { value: "rule_4", children: "Block if Postal code verification fails" })
3021
- ]
3022
- }
3023
- )
3024
- ] }),
3025
- /* @__PURE__ */ jsx9("p", { className: "text-xs text-black", children: actionType === "enableBlockRule" ? "This will enable the selected block rule to actively block matching payments." : actionType === "disableBlockRule" ? "This will disable the selected block rule. Matching payments will no longer be blocked." : "This will toggle the selected block rule's state." })
3026
- ] }),
3027
- /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsxs5(
3220
+ ) })
3221
+ ] }) }, message.id);
3222
+ }
3223
+ return /* @__PURE__ */ jsx9(React4.Fragment, { children: /* @__PURE__ */ jsxs5(
3224
+ "div",
3225
+ {
3226
+ ref: isCurrentGuideStep ? currentStepRef : null,
3227
+ className: `${isRoleChange ? "mt-3" : ""}`,
3228
+ children: [
3229
+ /* @__PURE__ */ jsx9("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3230
+ const text = message.content || "";
3231
+ if (message.kind === "guideStep") {
3232
+ const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3233
+ if (m) {
3234
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3235
+ /* @__PURE__ */ jsx9("strong", { children: m[1] }),
3236
+ m[2]
3237
+ ] });
3238
+ }
3239
+ }
3240
+ if (message.role === "assistant" && text) {
3241
+ return renderMarkdown(text);
3242
+ }
3243
+ return text || /* @__PURE__ */ jsx9("span", { className: "opacity-70", children: "Thinking\u2026" });
3244
+ })() }),
3245
+ message.role === "assistant" && message.structuredData && /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsx9(
3246
+ DataRenderer,
3247
+ {
3248
+ type: message.structuredData.type,
3249
+ data: message.structuredData.data
3250
+ }
3251
+ ) }),
3252
+ message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ jsx9("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ jsx9(
3253
+ "button",
3254
+ {
3255
+ type: "button",
3256
+ onClick: () => handleFollowupClick(message.id, followup),
3257
+ 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",
3258
+ children: followup.label
3259
+ },
3260
+ followup.id
3261
+ )) })
3262
+ ]
3263
+ }
3264
+ ) }, message.id);
3265
+ }),
3266
+ (activeGuide || guideComplete) && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3267
+ activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ jsx9(
3268
+ Button,
3269
+ {
3270
+ type: "button",
3271
+ size: "sm",
3272
+ variant: "secondary",
3273
+ className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3274
+ onClick: goBackGuide,
3275
+ children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3276
+ }
3277
+ ),
3278
+ /* @__PURE__ */ jsxs5(
3028
3279
  Button,
3029
3280
  {
3030
3281
  type: "button",
3031
3282
  size: "sm",
3032
3283
  variant: "secondary",
3033
3284
  className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3034
- onClick: handleActionSubmit,
3285
+ onClick: guideComplete ? handleBack : advanceGuide,
3035
3286
  children: [
3036
- /* @__PURE__ */ jsx9("span", { children: "Confirm" }),
3287
+ /* @__PURE__ */ jsx9("span", { children: guideComplete ? "Done" : "Next" }),
3037
3288
  /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3038
3289
  /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3039
3290
  /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3040
3291
  ] })
3041
3292
  ]
3042
3293
  }
3043
- ) })
3044
- ] }, message.id);
3045
- }
3046
- if (message.kind === "bulkPreview" && message.csvData) {
3047
- return /* @__PURE__ */ jsxs5("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: [
3048
- /* @__PURE__ */ jsx9("div", { className: "whitespace-pre-wrap text-sm leading-6 mb-3 text-gray-700", children: message.content || "" }),
3049
- /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 overflow-hidden", children: [
3050
- /* @__PURE__ */ jsxs5("div", { className: "bg-gray-100 px-3 py-2 border-b border-gray-200 flex items-center gap-2", children: [
3051
- /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-gray-600" }),
3052
- /* @__PURE__ */ jsx9("span", { className: "text-xs font-medium text-gray-700", children: message.csvData.fileName }),
3053
- /* @__PURE__ */ jsxs5("span", { className: "text-xs text-gray-500", children: [
3054
- "\u2022 ",
3055
- message.csvData.rowCount,
3056
- " rows"
3057
- ] })
3058
- ] }),
3059
- /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2 border-b border-gray-100", children: [
3060
- /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Columns" }),
3061
- /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", children: message.csvData.columns.map((col, i) => /* @__PURE__ */ jsx9("span", { className: "text-xs bg-blue-100 text-blue-700 px-1.5 py-0.5 rounded", children: col }, i)) })
3062
- ] }),
3063
- message.csvData.sampleRows.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "px-3 py-2", children: [
3064
- /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-gray-500 mb-1", children: "Sample Data" }),
3065
- /* @__PURE__ */ jsx9("div", { className: "space-y-1", children: message.csvData.sampleRows.slice(0, 3).map((row, i) => /* @__PURE__ */ jsxs5("div", { className: "text-xs text-gray-600 bg-white rounded px-2 py-1 border border-gray-100", children: [
3066
- Object.entries(row).slice(0, 3).map(([key, val], j) => /* @__PURE__ */ jsxs5("span", { children: [
3067
- j > 0 && " \u2022 ",
3068
- /* @__PURE__ */ jsxs5("span", { className: "text-gray-400", children: [
3069
- key,
3070
- ":"
3071
- ] }),
3072
- " ",
3073
- val
3074
- ] }, key)),
3075
- Object.keys(row).length > 3 && /* @__PURE__ */ jsx9("span", { className: "text-gray-400", children: " ..." })
3076
- ] }, i)) })
3077
- ] }),
3078
- message.suggestedAction && /* @__PURE__ */ jsx9("div", { className: "px-3 py-2 bg-blue-50 border-t border-blue-100", children: /* @__PURE__ */ jsxs5("span", { className: "text-xs text-blue-700", children: [
3079
- "Suggested action: ",
3080
- /* @__PURE__ */ jsx9("strong", { children: message.suggestedAction.replace(/_/g, " ") })
3081
- ] }) })
3082
- ] }),
3083
- message.bulkSessionId && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3084
- /* @__PURE__ */ jsxs5(
3085
- Button,
3086
- {
3087
- type: "button",
3088
- size: "sm",
3089
- variant: "secondary",
3090
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3091
- onClick: () => message.bulkSessionId && confirmBulkOperation(message.bulkSessionId),
3092
- children: [
3093
- /* @__PURE__ */ jsxs5("span", { children: [
3094
- "Process ",
3095
- message.csvData.rowCount,
3096
- " rows"
3097
- ] }),
3098
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3099
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3100
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3101
- ] })
3102
- ]
3103
- }
3104
- ),
3105
- /* @__PURE__ */ jsx9(
3106
- Button,
3107
- {
3108
- type: "button",
3109
- size: "sm",
3110
- variant: "ghost",
3111
- className: "h-8 rounded-xl px-3 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-100",
3112
- onClick: cancelBulkOperation,
3113
- children: "Cancel"
3114
- }
3115
- )
3116
- ] })
3117
- ] }, message.id);
3118
- }
3119
- if (message.kind === "bulkProgress" && message.bulkProgress) {
3120
- const { processed, total, successes, failures } = message.bulkProgress;
3121
- const percentage = Math.round(processed / total * 100);
3122
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-3", children: [
3123
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3124
- /* @__PURE__ */ jsx9(Loader22, { className: "h-4 w-4 animate-spin text-blue-600" }),
3125
- /* @__PURE__ */ jsxs5("span", { className: "text-sm font-medium text-gray-700", children: [
3126
- "Processing... ",
3127
- processed,
3128
- " of ",
3129
- total
3130
- ] })
3131
- ] }),
3132
- /* @__PURE__ */ jsx9("div", { className: "h-2 bg-gray-200 rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ jsx9(
3133
- "div",
3134
- {
3135
- className: "h-full bg-blue-600 transition-all duration-300",
3136
- style: { width: `${percentage}%` }
3137
- }
3138
- ) }),
3139
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 text-xs text-gray-600", children: [
3140
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1", children: [
3141
- /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3 text-green-600" }),
3142
- successes,
3143
- " successful"
3144
- ] }),
3145
- failures > 0 && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3146
- /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3147
- failures,
3148
- " failed"
3149
- ] })
3150
- ] })
3151
- ] }) }, message.id);
3152
- }
3153
- if (message.kind === "bulkSummary" && message.bulkSummary) {
3154
- const { total, successes, failures, navigationPage } = message.bulkSummary;
3155
- const hasFailures = failures.length > 0;
3156
- const pageLabel = navigationPage?.page === "customers" ? "Customers" : navigationPage?.page === "dashboard" ? "Dashboard" : navigationPage?.page === "settings" ? "Settings" : "Results";
3157
- return /* @__PURE__ */ jsx9("div", { className: `${isRoleChange ? "mt-3" : ""}`, children: /* @__PURE__ */ jsxs5("div", { className: `rounded-lg border p-3 ${hasFailures ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`, children: [
3158
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 mb-2", children: [
3159
- /* @__PURE__ */ jsx9(CheckCircle23, { className: `h-5 w-5 ${hasFailures ? "text-amber-600" : "text-green-600"}` }),
3160
- /* @__PURE__ */ jsx9("span", { className: "text-sm font-medium text-gray-800", children: "Bulk operation complete" })
3161
- ] }),
3162
- /* @__PURE__ */ jsx9("div", { className: "text-sm text-gray-600 mb-2", children: message.content || `Processed ${total} rows: ${successes} successful${hasFailures ? `, ${failures.length} failed` : ""}.` }),
3163
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-4 text-xs", children: [
3164
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-green-700", children: [
3165
- /* @__PURE__ */ jsx9(CheckCircle23, { className: "h-3 w-3" }),
3166
- successes,
3167
- " successful"
3168
- ] }),
3169
- hasFailures && /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 text-red-600", children: [
3170
- /* @__PURE__ */ jsx9(X, { className: "h-3 w-3" }),
3171
- failures.length,
3172
- " failed"
3173
- ] })
3174
- ] }),
3175
- hasFailures && /* @__PURE__ */ jsxs5("div", { className: "mt-3 pt-2 border-t border-amber-200", children: [
3176
- /* @__PURE__ */ jsx9("div", { className: "text-[10px] uppercase tracking-wider text-amber-700 mb-1", children: "Failed Rows" }),
3177
- /* @__PURE__ */ jsxs5("div", { className: "space-y-1 max-h-32 overflow-y-auto", children: [
3178
- failures.slice(0, 5).map((failure, i) => /* @__PURE__ */ jsxs5("div", { className: "text-xs text-red-700 bg-red-50 rounded px-2 py-1", children: [
3179
- "Row ",
3180
- failure.row,
3181
- ": ",
3182
- failure.error || "Unknown error"
3183
- ] }, i)),
3184
- failures.length > 5 && /* @__PURE__ */ jsxs5("div", { className: "text-xs text-amber-600", children: [
3185
- "...and ",
3186
- failures.length - 5,
3187
- " more"
3188
- ] })
3189
- ] })
3190
- ] }),
3191
- navigationPage && successes > 0 && /* @__PURE__ */ jsx9("div", { className: "mt-3 pt-2 border-t border-gray-200", children: /* @__PURE__ */ jsxs5(
3294
+ )
3295
+ ] }),
3296
+ (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ jsx9("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(
3297
+ AssistantActivity,
3298
+ {
3299
+ phase,
3300
+ progressSteps
3301
+ }
3302
+ ) }),
3303
+ !activeGuide && /* @__PURE__ */ jsx9("div", { ref: messagesEndRef })
3304
+ ] }) }) }) }) }),
3305
+ /* @__PURE__ */ jsxs5("div", { className: "px-4 py-3 border-t border-gray-100 bg-gray-50/50 shrink-0", children: [
3306
+ pendingFile && /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center gap-2 rounded-xl bg-blue-50 border border-blue-200 px-3 py-2", children: [
3307
+ /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-blue-600" }),
3308
+ /* @__PURE__ */ jsx9("span", { className: "text-xs text-blue-700 flex-1 truncate", children: pendingFile.name }),
3309
+ /* @__PURE__ */ jsx9(
3192
3310
  "button",
3193
3311
  {
3194
3312
  type: "button",
3195
- onClick: (e) => {
3196
- e.preventDefault();
3197
- e.stopPropagation();
3198
- console.log("[DEBUG] Button clicked - navigationPage:", navigationPage, "onNavigate:", !!onNavigate);
3199
- if (onNavigate && navigationPage.page) {
3200
- console.log("[DEBUG] Calling onNavigate with page:", navigationPage.page);
3201
- onNavigate(navigationPage.page, navigationPage.subtab);
3202
- } else {
3203
- console.log("[DEBUG] Condition failed - onNavigate:", !!onNavigate, "navigationPage.page:", navigationPage.page);
3204
- }
3313
+ onClick: () => {
3314
+ setPendingFile(null);
3315
+ if (fileInputRef.current) fileInputRef.current.value = "";
3205
3316
  },
3206
- className: "flex items-center gap-2 text-xs text-gray-500 hover:text-gray-700 transition-colors group cursor-pointer",
3207
- children: [
3208
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-1 px-1.5 py-0.5 bg-gray-100 rounded text-[10px] font-medium text-gray-600 group-hover:bg-gray-200", children: [
3209
- /* @__PURE__ */ jsx9(Command, { className: "h-2.5 w-2.5" }),
3210
- /* @__PURE__ */ jsx9("span", { children: "+" }),
3211
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-2.5 w-2.5" })
3212
- ] }),
3213
- /* @__PURE__ */ jsxs5("span", { children: [
3214
- "View ",
3215
- pageLabel
3216
- ] })
3217
- ]
3317
+ className: "text-blue-600 hover:text-blue-800",
3318
+ children: /* @__PURE__ */ jsx9(X, { className: "h-4 w-4" })
3218
3319
  }
3219
- ) })
3220
- ] }) }, message.id);
3221
- }
3222
- return /* @__PURE__ */ jsx9(React4.Fragment, { children: /* @__PURE__ */ jsxs5(
3223
- "div",
3224
- {
3225
- ref: isCurrentGuideStep ? currentStepRef : null,
3226
- className: `${isRoleChange ? "mt-3" : ""}`,
3227
- children: [
3228
- /* @__PURE__ */ jsx9("div", { className: "text-sm leading-6 text-gray-700", children: (() => {
3229
- const text = message.content || "";
3230
- if (message.kind === "guideStep") {
3231
- const m = text.match(/^(Step\s+\d+:)([\s\S]*)/);
3232
- if (m) {
3233
- return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3234
- /* @__PURE__ */ jsx9("strong", { children: m[1] }),
3235
- m[2]
3236
- ] });
3320
+ )
3321
+ ] }),
3322
+ /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className: "w-full", children: [
3323
+ /* @__PURE__ */ jsx9(
3324
+ "input",
3325
+ {
3326
+ ref: fileInputRef,
3327
+ type: "file",
3328
+ accept: ".csv",
3329
+ className: "hidden",
3330
+ onChange: (e) => {
3331
+ const file = e.target.files?.[0];
3332
+ if (file) {
3333
+ setPendingFile(file);
3237
3334
  }
3238
3335
  }
3239
- if (message.role === "assistant" && text) {
3240
- return renderMarkdown(text);
3336
+ }
3337
+ ),
3338
+ /* @__PURE__ */ jsxs5("div", { className: "flex w-full items-center gap-2 rounded-2xl border border-gray-200 bg-white px-3 py-2 shadow-sm", children: [
3339
+ /* @__PURE__ */ jsx9(
3340
+ Button,
3341
+ {
3342
+ type: "button",
3343
+ size: "icon",
3344
+ variant: "ghost",
3345
+ onClick: () => fileInputRef.current?.click(),
3346
+ className: "h-8 w-8 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100",
3347
+ title: "Upload CSV for bulk operations",
3348
+ children: /* @__PURE__ */ jsx9(Paperclip, { className: "h-4 w-4" })
3241
3349
  }
3242
- return text || /* @__PURE__ */ jsx9("span", { className: "opacity-70", children: "Thinking\u2026" });
3243
- })() }),
3244
- message.role === "assistant" && message.structuredData && /* @__PURE__ */ jsx9("div", { className: "mt-3", children: /* @__PURE__ */ jsx9(
3245
- DataRenderer,
3350
+ ),
3351
+ /* @__PURE__ */ jsx9(
3352
+ Input,
3246
3353
  {
3247
- type: message.structuredData.type,
3248
- data: message.structuredData.data
3354
+ placeholder: pendingFile ? "Describe what to do with this CSV..." : "Ask anything...",
3355
+ value: input,
3356
+ onChange: (e) => setInput(e.target.value),
3357
+ onKeyDown: (e) => {
3358
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
3359
+ const currentBulkSession = pendingBulkSessionRef.current;
3360
+ if (currentBulkSession) {
3361
+ e.preventDefault();
3362
+ e.stopPropagation();
3363
+ confirmBulkOperation(currentBulkSession);
3364
+ return;
3365
+ }
3366
+ if (pendingAction) {
3367
+ e.preventDefault();
3368
+ e.stopPropagation();
3369
+ handleActionSubmit();
3370
+ return;
3371
+ }
3372
+ if (pendingNavigation) {
3373
+ e.preventDefault();
3374
+ e.stopPropagation();
3375
+ handleConfirmNavigation(pendingNavigation);
3376
+ return;
3377
+ }
3378
+ const currentGuide = activeGuideRef.current;
3379
+ if (currentGuide) {
3380
+ e.preventDefault();
3381
+ e.stopPropagation();
3382
+ advanceGuide();
3383
+ return;
3384
+ }
3385
+ }
3386
+ },
3387
+ className: "flex-1 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 text-sm placeholder:text-gray-400"
3249
3388
  }
3250
- ) }),
3251
- message.role === "assistant" && message.followups && message.followups.length > 0 && !message.followupSelected && /* @__PURE__ */ jsx9("div", { className: "mt-3 flex flex-wrap gap-1.5", children: message.followups.map((followup) => /* @__PURE__ */ jsx9(
3252
- "button",
3389
+ ),
3390
+ /* @__PURE__ */ jsx9(
3391
+ Button,
3253
3392
  {
3254
- type: "button",
3255
- onClick: () => handleFollowupClick(message.id, followup),
3256
- 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",
3257
- children: followup.label
3258
- },
3259
- followup.id
3260
- )) })
3261
- ]
3262
- }
3263
- ) }, message.id);
3264
- }),
3265
- (activeGuide || guideComplete) && /* @__PURE__ */ jsxs5("div", { className: "mt-3 flex items-center gap-2", children: [
3266
- activeGuide && activeGuide.stepIndex > 0 && /* @__PURE__ */ jsx9(
3267
- Button,
3268
- {
3269
- type: "button",
3270
- size: "sm",
3271
- variant: "secondary",
3272
- className: "h-7 w-7 rounded-full p-0 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3273
- onClick: goBackGuide,
3274
- children: /* @__PURE__ */ jsx9(ArrowLeft, { className: "h-3.5 w-3.5 text-gray-600" })
3275
- }
3276
- ),
3277
- /* @__PURE__ */ jsxs5(
3278
- Button,
3279
- {
3280
- type: "button",
3281
- size: "sm",
3282
- variant: "secondary",
3283
- className: "h-8 rounded-xl px-3 text-xs gap-1.5 bg-gray-100 hover:bg-gray-200 border border-gray-200",
3284
- onClick: guideComplete ? handleBack : advanceGuide,
3285
- children: [
3286
- /* @__PURE__ */ jsx9("span", { children: guideComplete ? "Done" : "Next" }),
3287
- /* @__PURE__ */ jsxs5("span", { className: "flex items-center gap-0.5 text-gray-400", children: [
3288
- /* @__PURE__ */ jsx9(Command, { className: "h-3 w-3" }),
3289
- /* @__PURE__ */ jsx9(CornerDownLeft, { className: "h-3 w-3" })
3290
- ] })
3291
- ]
3292
- }
3293
- )
3294
- ] }),
3295
- (phase === "thinking" || phase === "searching" || phase === "executing" || phase === "responding") && /* @__PURE__ */ jsx9("div", { className: `${lastRole === "user" ? "mt-3" : ""}`, children: /* @__PURE__ */ jsx9(
3296
- AssistantActivity,
3297
- {
3298
- phase,
3299
- progressSteps
3300
- }
3301
- ) }),
3302
- !activeGuide && /* @__PURE__ */ jsx9("div", { ref: messagesEndRef })
3303
- ] }) }) }) }) }),
3304
- !isCollapsed && /* @__PURE__ */ jsxs5("div", { className: "px-4 py-3 border-t border-gray-100 bg-gray-50/50 shrink-0", children: [
3305
- pendingFile && /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center gap-2 rounded-xl bg-blue-50 border border-blue-200 px-3 py-2", children: [
3306
- /* @__PURE__ */ jsx9(FileSpreadsheet, { className: "h-4 w-4 text-blue-600" }),
3307
- /* @__PURE__ */ jsx9("span", { className: "text-xs text-blue-700 flex-1 truncate", children: pendingFile.name }),
3393
+ type: "submit",
3394
+ size: "icon",
3395
+ disabled: !input.trim() && !pendingFile,
3396
+ className: "h-8 w-8 rounded-full bg-gray-900 hover:bg-gray-800 disabled:bg-gray-300",
3397
+ children: /* @__PURE__ */ jsx9(ArrowUp, { className: "h-4 w-4" })
3398
+ }
3399
+ )
3400
+ ] })
3401
+ ] })
3402
+ ] }),
3308
3403
  /* @__PURE__ */ jsx9(
3309
- "button",
3404
+ GuideCursor,
3310
3405
  {
3311
- type: "button",
3312
- onClick: () => {
3313
- setPendingFile(null);
3314
- if (fileInputRef.current) fileInputRef.current.value = "";
3315
- },
3316
- className: "text-blue-600 hover:text-blue-800",
3317
- children: /* @__PURE__ */ jsx9(X, { className: "h-4 w-4" })
3406
+ x: cursorState.x,
3407
+ y: cursorState.y,
3408
+ visible: cursorState.visible,
3409
+ onClick: cursorState.onClick
3318
3410
  }
3319
3411
  )
3320
- ] }),
3321
- /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className: "w-full", children: [
3322
- /* @__PURE__ */ jsx9(
3323
- "input",
3324
- {
3325
- ref: fileInputRef,
3326
- type: "file",
3327
- accept: ".csv",
3328
- className: "hidden",
3329
- onChange: (e) => {
3330
- const file = e.target.files?.[0];
3331
- if (file) {
3332
- setPendingFile(file);
3333
- }
3334
- }
3335
- }
3336
- ),
3337
- /* @__PURE__ */ jsxs5("div", { className: "flex w-full items-center gap-2 rounded-2xl border border-gray-200 bg-white px-3 py-2 shadow-sm", children: [
3338
- /* @__PURE__ */ jsx9(
3339
- Button,
3340
- {
3341
- type: "button",
3342
- size: "icon",
3343
- variant: "ghost",
3344
- onClick: () => fileInputRef.current?.click(),
3345
- className: "h-8 w-8 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100",
3346
- title: "Upload CSV for bulk operations",
3347
- children: /* @__PURE__ */ jsx9(Paperclip, { className: "h-4 w-4" })
3348
- }
3349
- ),
3350
- /* @__PURE__ */ jsx9(
3351
- Input,
3352
- {
3353
- placeholder: pendingFile ? "Describe what to do with this CSV..." : "Ask anything...",
3354
- value: input,
3355
- onChange: (e) => setInput(e.target.value),
3356
- onKeyDown: (e) => {
3357
- if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
3358
- const currentBulkSession = pendingBulkSessionRef.current;
3359
- if (currentBulkSession) {
3360
- e.preventDefault();
3361
- e.stopPropagation();
3362
- confirmBulkOperation(currentBulkSession);
3363
- return;
3364
- }
3365
- if (pendingAction) {
3366
- e.preventDefault();
3367
- e.stopPropagation();
3368
- handleActionSubmit();
3369
- return;
3370
- }
3371
- if (pendingNavigation) {
3372
- e.preventDefault();
3373
- e.stopPropagation();
3374
- handleConfirmNavigation(pendingNavigation);
3375
- return;
3376
- }
3377
- const currentGuide = activeGuideRef.current;
3378
- if (currentGuide) {
3379
- e.preventDefault();
3380
- e.stopPropagation();
3381
- advanceGuide();
3382
- return;
3383
- }
3384
- }
3385
- },
3386
- className: "flex-1 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 text-sm placeholder:text-gray-400"
3387
- }
3388
- ),
3389
- /* @__PURE__ */ jsx9(
3390
- Button,
3391
- {
3392
- type: "submit",
3393
- size: "icon",
3394
- disabled: !input.trim() && !pendingFile,
3395
- className: "h-8 w-8 rounded-full bg-gray-900 hover:bg-gray-800 disabled:bg-gray-300",
3396
- children: /* @__PURE__ */ jsx9(ArrowUp, { className: "h-4 w-4" })
3397
- }
3398
- )
3399
- ] })
3400
- ] })
3401
- ] }),
3412
+ ]
3413
+ }
3414
+ );
3415
+ }
3416
+ function PanelToggle({ isOpen, onClick, className = "" }) {
3417
+ return /* @__PURE__ */ jsx9(
3418
+ "button",
3419
+ {
3420
+ type: "button",
3421
+ onClick,
3422
+ className: `fixed top-1/2 z-50 flex items-center justify-center w-6 h-16 bg-gray-100 hover:bg-gray-200 border border-gray-200 border-r-0 rounded-l-lg text-gray-600 hover:text-gray-800 shadow-md transition-all duration-300 ${className}`,
3423
+ "aria-label": isOpen ? "Close help panel" : "Open help panel",
3424
+ style: {
3425
+ right: isOpen ? `${PANEL_WIDTH}px` : "0px",
3426
+ transform: "translateY(-50%)"
3427
+ },
3428
+ children: isOpen ? /* @__PURE__ */ jsx9(ChevronRight, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx9(ChevronLeft, { className: "h-4 w-4" })
3429
+ }
3430
+ );
3431
+ }
3432
+ function ChatPanelWithToggle({
3433
+ onNavigate,
3434
+ onActionComplete,
3435
+ currentPage,
3436
+ agentUrl,
3437
+ startingQuestions,
3438
+ startingQuestionsEndpoint,
3439
+ defaultOpen = false,
3440
+ isOpen: controlledIsOpen,
3441
+ onOpenChange
3442
+ }) {
3443
+ const [internalIsOpen, setInternalIsOpen] = React4.useState(defaultOpen);
3444
+ const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
3445
+ const setIsOpen = (open) => {
3446
+ if (controlledIsOpen === void 0) {
3447
+ setInternalIsOpen(open);
3448
+ }
3449
+ onOpenChange?.(open);
3450
+ };
3451
+ React4.useEffect(() => {
3452
+ const originalPadding = document.body.style.paddingRight;
3453
+ const originalTransition = document.body.style.transition;
3454
+ document.body.style.transition = "padding-right 0.3s ease";
3455
+ document.body.style.paddingRight = isOpen ? `${PANEL_WIDTH}px` : "0px";
3456
+ return () => {
3457
+ document.body.style.paddingRight = originalPadding;
3458
+ document.body.style.transition = originalTransition;
3459
+ };
3460
+ }, [isOpen]);
3461
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3462
+ /* @__PURE__ */ jsx9(
3463
+ PanelToggle,
3464
+ {
3465
+ isOpen,
3466
+ onClick: () => setIsOpen(!isOpen)
3467
+ }
3468
+ ),
3402
3469
  /* @__PURE__ */ jsx9(
3403
- GuideCursor,
3470
+ ChatPanel,
3404
3471
  {
3405
- x: cursorState.x,
3406
- y: cursorState.y,
3407
- visible: cursorState.visible,
3408
- onClick: cursorState.onClick
3472
+ isOpen,
3473
+ onClose: () => setIsOpen(false),
3474
+ onNavigate,
3475
+ onActionComplete,
3476
+ currentPage,
3477
+ agentUrl,
3478
+ startingQuestions,
3479
+ startingQuestionsEndpoint
3409
3480
  }
3410
3481
  )
3411
3482
  ] });
3412
3483
  }
3484
+ function HelpButton({ onClick, className = "" }) {
3485
+ return /* @__PURE__ */ jsx9(
3486
+ "button",
3487
+ {
3488
+ type: "button",
3489
+ onClick,
3490
+ className: `flex items-center justify-center w-6 h-16 bg-gray-100 hover:bg-gray-200 border border-gray-200 border-r-0 rounded-l-lg text-gray-600 hover:text-gray-800 transition-all duration-200 shadow-sm ${className}`,
3491
+ "aria-label": "Open help",
3492
+ children: /* @__PURE__ */ jsx9(ChevronLeft, { className: "h-4 w-4" })
3493
+ }
3494
+ );
3495
+ }
3413
3496
 
3414
3497
  // src/createKiteChat.tsx
3415
3498
  import React5 from "react";
@@ -3417,10 +3500,16 @@ import { createRoot } from "react-dom/client";
3417
3500
  import { jsx as jsx10 } from "react/jsx-runtime";
3418
3501
  function KiteChatWrapper({
3419
3502
  initialConfig,
3420
- onConfigUpdate
3503
+ onConfigUpdate,
3504
+ onStateUpdate
3421
3505
  }) {
3422
3506
  const [config, setConfig] = React5.useState(initialConfig);
3423
3507
  const [currentPage, setCurrentPage] = React5.useState(initialConfig.currentPage || "dashboard");
3508
+ const [isOpen, setIsOpen] = React5.useState(false);
3509
+ const isOpenRef = React5.useRef(false);
3510
+ React5.useEffect(() => {
3511
+ isOpenRef.current = isOpen;
3512
+ }, [isOpen]);
3424
3513
  React5.useEffect(() => {
3425
3514
  onConfigUpdate((newConfig) => {
3426
3515
  if (newConfig.currentPage !== void 0) {
@@ -3428,7 +3517,11 @@ function KiteChatWrapper({
3428
3517
  }
3429
3518
  setConfig((prev) => ({ ...prev, ...newConfig }));
3430
3519
  });
3431
- }, [onConfigUpdate]);
3520
+ onStateUpdate({
3521
+ setIsOpen: (open) => setIsOpen(open),
3522
+ getIsOpen: () => isOpenRef.current
3523
+ });
3524
+ }, [onConfigUpdate, onStateUpdate]);
3432
3525
  React5.useEffect(() => {
3433
3526
  const container = document.getElementById("kite-chat-root");
3434
3527
  if (!container) return;
@@ -3442,12 +3535,16 @@ function KiteChatWrapper({
3442
3535
  }
3443
3536
  }, [config.theme]);
3444
3537
  return /* @__PURE__ */ jsx10(
3445
- ChatPanel,
3538
+ ChatPanelWithToggle,
3446
3539
  {
3540
+ isOpen,
3541
+ onOpenChange: setIsOpen,
3447
3542
  currentPage,
3448
3543
  agentUrl: config.agentUrl,
3449
3544
  onNavigate: (page, subtab) => config.onNavigate?.(page, subtab),
3450
- onActionComplete: config.onActionComplete
3545
+ onActionComplete: config.onActionComplete,
3546
+ startingQuestions: config.startingQuestions,
3547
+ startingQuestionsEndpoint: config.startingQuestionsEndpoint
3451
3548
  }
3452
3549
  );
3453
3550
  }
@@ -3455,6 +3552,7 @@ function createKiteChat(config) {
3455
3552
  let root = null;
3456
3553
  let containerElement = null;
3457
3554
  let configUpdater = null;
3555
+ let stateUpdaters = null;
3458
3556
  let currentConfig = { ...config };
3459
3557
  const instance = {
3460
3558
  mount(container) {
@@ -3482,6 +3580,9 @@ function createKiteChat(config) {
3482
3580
  initialConfig: currentConfig,
3483
3581
  onConfigUpdate: (updater) => {
3484
3582
  configUpdater = updater;
3583
+ },
3584
+ onStateUpdate: (updaters) => {
3585
+ stateUpdaters = updaters;
3485
3586
  }
3486
3587
  }
3487
3588
  )
@@ -3497,8 +3598,22 @@ function createKiteChat(config) {
3497
3598
  root = null;
3498
3599
  containerElement = null;
3499
3600
  configUpdater = null;
3601
+ stateUpdaters = null;
3500
3602
  console.log("[KiteChat] Unmounted");
3501
3603
  },
3604
+ open() {
3605
+ stateUpdaters?.setIsOpen(true);
3606
+ },
3607
+ close() {
3608
+ stateUpdaters?.setIsOpen(false);
3609
+ },
3610
+ toggle() {
3611
+ const isCurrentlyOpen = stateUpdaters?.getIsOpen() ?? false;
3612
+ stateUpdaters?.setIsOpen(!isCurrentlyOpen);
3613
+ },
3614
+ isOpen() {
3615
+ return stateUpdaters?.getIsOpen() ?? false;
3616
+ },
3502
3617
  setCurrentPage(page) {
3503
3618
  currentConfig.currentPage = page;
3504
3619
  configUpdater?.({ currentPage: page });
@@ -3543,5 +3658,8 @@ export {
3543
3658
  TopCustomersList,
3544
3659
  DataRenderer,
3545
3660
  ChatPanel,
3661
+ PanelToggle,
3662
+ ChatPanelWithToggle,
3663
+ HelpButton,
3546
3664
  createKiteChat
3547
3665
  };