open-ask-ai 0.3.5 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.cjs.js → cjs/index.js} +100 -110
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/styles.css +975 -0
- package/dist/esm/ask-ai.js +158 -0
- package/dist/esm/ask-ai.js.map +1 -0
- package/dist/esm/index.js +555 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/styles.css +975 -0
- package/dist/types/components/widget/Trigger.d.ts +2 -1
- package/package.json +10 -5
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -722
- package/dist/index.esm.js.map +0 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
6
5
|
var lucideReact = require('lucide-react');
|
|
7
6
|
var reactSlot = require('@radix-ui/react-slot');
|
|
7
|
+
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
8
8
|
var ReactMarkdown = require('react-markdown');
|
|
9
9
|
var remarkGfm = require('remark-gfm');
|
|
10
10
|
var rehypeHighlight = require('rehype-highlight');
|
|
@@ -441,43 +441,14 @@ function useChat({ apiClient, texts }) {
|
|
|
441
441
|
};
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
|
|
445
|
-
if ( ref === void 0 ) ref = {};
|
|
446
|
-
var insertAt = ref.insertAt;
|
|
447
|
-
|
|
448
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
449
|
-
|
|
450
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
451
|
-
var style = document.createElement('style');
|
|
452
|
-
style.type = 'text/css';
|
|
453
|
-
|
|
454
|
-
if (insertAt === 'top') {
|
|
455
|
-
if (head.firstChild) {
|
|
456
|
-
head.insertBefore(style, head.firstChild);
|
|
457
|
-
} else {
|
|
458
|
-
head.appendChild(style);
|
|
459
|
-
}
|
|
460
|
-
} else {
|
|
461
|
-
head.appendChild(style);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
if (style.styleSheet) {
|
|
465
|
-
style.styleSheet.cssText = css;
|
|
466
|
-
} else {
|
|
467
|
-
style.appendChild(document.createTextNode(css));
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
var css_248z$5 = "/* Button 组件样式 */\n\n.button_hpHiE {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border-radius: var(--ask-ai-radius-md);\n font-size: 14px;\n font-weight: 500;\n transition: all var(--ask-ai-transition);\n border: none;\n cursor: pointer;\n}\n\n.button_hpHiE:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--ask-ai-background), 0 0 0 4px var(--ask-ai-primary);\n}\n\n.button_hpHiE:disabled {\n pointer-events: none;\n opacity: 0.5;\n}\n\n/* Variants */\n.variant-default_kUb7W {\n background-color: var(--ask-ai-primary);\n color: #ffffff;\n}\n\n.variant-default_kUb7W:hover:not(:disabled) {\n background-color: var(--ask-ai-primary-hover);\n}\n\n.variant-outline_B-jpO {\n border: 1px solid var(--ask-ai-border);\n background-color: var(--ask-ai-background);\n color: var(--ask-ai-foreground);\n}\n\n.variant-outline_B-jpO:hover:not(:disabled) {\n background-color: var(--ask-ai-button-bg);\n}\n\n.variant-ghost_Rfses {\n background-color: transparent;\n color: var(--ask-ai-foreground);\n}\n\n.variant-ghost_Rfses:hover:not(:disabled) {\n background-color: var(--ask-ai-button-bg);\n}\n\n.variant-icon_eyYEu {\n background-color: transparent;\n color: var(--ask-ai-foreground);\n}\n\n.variant-icon_eyYEu:hover:not(:disabled) {\n background-color: var(--ask-ai-button-bg);\n}\n\n/* Sizes */\n.size-default_-O-7z {\n height: 40px;\n padding: 8px 16px;\n}\n\n.size-sm_3B2YW {\n height: 36px;\n padding: 6px 12px;\n}\n\n.size-lg_pg-gK {\n height: 44px;\n padding: 10px 32px;\n}\n\n.size-icon_JKSSE {\n height: 36px;\n width: 36px;\n padding: 0;\n}\n";
|
|
472
|
-
var styles$3 = {"button":"button_hpHiE","variant-default":"variant-default_kUb7W","variant-outline":"variant-outline_B-jpO","variant-ghost":"variant-ghost_Rfses","variant-icon":"variant-icon_eyYEu","size-default":"size-default_-O-7z","size-sm":"size-sm_3B2YW","size-lg":"size-lg_pg-gK","size-icon":"size-icon_JKSSE"};
|
|
473
|
-
styleInject(css_248z$5);
|
|
444
|
+
var styles$4 = {"button":"button_hpHiE","variant-default":"variant-default_kUb7W","variant-outline":"variant-outline_B-jpO","variant-ghost":"variant-ghost_Rfses","variant-icon":"variant-icon_eyYEu","size-default":"size-default_-O-7z","size-sm":"size-sm_3B2YW","size-lg":"size-lg_pg-gK","size-icon":"size-icon_JKSSE"};
|
|
474
445
|
|
|
475
446
|
const Button = React__namespace.forwardRef(({ className, variant = 'default', size = 'default', asChild = false, ...props }, ref) => {
|
|
476
447
|
const Comp = asChild ? reactSlot.Slot : 'button';
|
|
477
448
|
const classNames = [
|
|
478
|
-
styles$
|
|
479
|
-
styles$
|
|
480
|
-
styles$
|
|
449
|
+
styles$4.button,
|
|
450
|
+
styles$4[`variant-${variant}`],
|
|
451
|
+
styles$4[`size-${size}`],
|
|
481
452
|
className,
|
|
482
453
|
]
|
|
483
454
|
.filter(Boolean)
|
|
@@ -486,9 +457,14 @@ const Button = React__namespace.forwardRef(({ className, variant = 'default', si
|
|
|
486
457
|
});
|
|
487
458
|
Button.displayName = 'Button';
|
|
488
459
|
|
|
489
|
-
var
|
|
460
|
+
var styles$3 = {"trigger":"trigger_whnWp","icon":"icon_KBJUj"};
|
|
461
|
+
|
|
462
|
+
function Trigger({ onClick, text = 'Ask AI', ariaLabel = 'Open AI assistant', className, isLoading = false, }) {
|
|
463
|
+
const classNames = [styles$3.trigger, className].filter(Boolean).join(' ');
|
|
464
|
+
return (jsxRuntime.jsxs(Button, { onClick: onClick, variant: "outline", "aria-label": ariaLabel, className: classNames, disabled: isLoading, children: [isLoading ? (jsxRuntime.jsx(lucideReact.Loader2, { className: `${styles$3.icon} ${styles$3.spinning}` })) : (jsxRuntime.jsx(lucideReact.Sparkles, { className: styles$3.icon })), text && jsxRuntime.jsx("span", { children: text })] }));
|
|
465
|
+
}
|
|
466
|
+
|
|
490
467
|
var styles$2 = {"overlay":"overlay_M4Ctc","fadeIn":"fadeIn_ofwCi","fadeOut":"fadeOut_gGY8D","content":"content_CFbqn","position-right":"position-right_jfDyQ","slideInFromRight":"slideInFromRight_1XcEG","slideOutToRight":"slideOutToRight_R3Q0I","position-left":"position-left_GhNmP","slideInFromLeft":"slideInFromLeft_g-jJq","slideOutToLeft":"slideOutToLeft_K488H","header":"header_m6xZ6","headerActions":"headerActions_p1WQU","title":"title_jiPst","icon":"icon_VOWAV","closeButton":"closeButton_HTzsf","newSessionButton":"newSessionButton_-WoCc","expandButton":"expandButton_nNGBy","expandIcon":"expandIcon_dDnlT","closeIcon":"closeIcon_QvQtm","newSessionIcon":"newSessionIcon_edUZ8","body":"body_EPX-M"};
|
|
491
|
-
styleInject(css_248z$4);
|
|
492
468
|
|
|
493
469
|
function Drawer({ isOpen, onClose, onNewSession, hasMessages, position = 'right', width = 600, expandedWidth = 920, title = 'Ask AI', closeAriaLabel = 'Close', newSessionAriaLabel = 'New session', children, theme = 'light', }) {
|
|
494
470
|
const [isExpanded, setIsExpanded] = React__namespace.useState(false);
|
|
@@ -514,18 +490,93 @@ function Drawer({ isOpen, onClose, onNewSession, hasMessages, position = 'right'
|
|
|
514
490
|
return (jsxRuntime.jsx(DialogPrimitive__namespace.Root, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: jsxRuntime.jsxs(DialogPrimitive__namespace.Portal, { container: portalContainer, children: [jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, { className: styles$2.overlay }), jsxRuntime.jsxs(DialogPrimitive__namespace.Content, { className: contentClasses, style: { maxWidth }, children: [jsxRuntime.jsxs("div", { className: styles$2.header, children: [jsxRuntime.jsxs(DialogPrimitive__namespace.Title, { className: styles$2.title, children: [jsxRuntime.jsx(lucideReact.Sparkles, { className: styles$2.icon }), title] }), jsxRuntime.jsxs("div", { className: styles$2.headerActions, children: [onNewSession && hasMessages && (jsxRuntime.jsx(Button, { variant: "ghost", size: "icon", "aria-label": newSessionAriaLabel, className: styles$2.newSessionButton, onClick: onNewSession, children: jsxRuntime.jsx(lucideReact.EraserIcon, { className: styles$2.newSessionIcon }) })), jsxRuntime.jsx(Button, { variant: "ghost", size: "icon", "aria-label": isExpanded ? 'Shrink' : 'Expand', className: styles$2.expandButton, onClick: () => setIsExpanded(!isExpanded), children: isExpanded ? (jsxRuntime.jsx(lucideReact.Minimize2, { className: styles$2.expandIcon })) : (jsxRuntime.jsx(lucideReact.Maximize2, { className: styles$2.expandIcon })) }), jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: jsxRuntime.jsx(Button, { variant: "ghost", size: "icon", "aria-label": closeAriaLabel, className: styles$2.closeButton, children: jsxRuntime.jsx(lucideReact.X, { className: styles$2.closeIcon }) }) })] })] }), jsxRuntime.jsx("div", { className: styles$2.body, children: children })] })] }) }));
|
|
515
491
|
}
|
|
516
492
|
|
|
517
|
-
var
|
|
518
|
-
var styles$1 = {"trigger":"trigger_whnWp","icon":"icon_KBJUj"};
|
|
519
|
-
styleInject(css_248z$3);
|
|
493
|
+
var styles$1 = {"spinning":"spinning_VD3F3"};
|
|
520
494
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
495
|
+
// Lazy load heavy components
|
|
496
|
+
const ChatContainer$2 = React__namespace.lazy(() => Promise.resolve().then(function () { return ChatContainer$1; }).then(m => ({ default: m.ChatContainer })));
|
|
497
|
+
function Widget(props) {
|
|
498
|
+
const { apiUrl, projectId, drawerPosition = 'right', drawerWidth = 600, drawerExpandedWidth = 920, theme = 'light', texts, exampleQuestions, hotkey, enableHotkey = true, onOpen, onClose, onMessage, onError, className, style, children, } = props;
|
|
499
|
+
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
500
|
+
const [isLoading, setIsLoading] = React__namespace.useState(false);
|
|
501
|
+
const [componentsLoaded, setComponentsLoaded] = React__namespace.useState(false);
|
|
502
|
+
const [apiClient] = React__namespace.useState(() => new APIClient(apiUrl, projectId));
|
|
503
|
+
// Lift chat state to Widget level to persist across drawer open/close
|
|
504
|
+
const { messages, isStreaming, error, sendMessage, resetChat } = useChat({ apiClient, texts });
|
|
505
|
+
// Input state also needs to persist
|
|
506
|
+
const [input, setInput] = React__namespace.useState('');
|
|
507
|
+
// Preload components
|
|
508
|
+
const preloadComponents = React__namespace.useCallback(async () => {
|
|
509
|
+
if (componentsLoaded)
|
|
510
|
+
return;
|
|
511
|
+
setIsLoading(true);
|
|
512
|
+
try {
|
|
513
|
+
// Trigger lazy loading by importing the modules
|
|
514
|
+
await Promise.resolve().then(function () { return ChatContainer$1; });
|
|
515
|
+
setComponentsLoaded(true);
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
console.error('Failed to preload components:', error);
|
|
519
|
+
}
|
|
520
|
+
finally {
|
|
521
|
+
setIsLoading(false);
|
|
522
|
+
}
|
|
523
|
+
}, [componentsLoaded]);
|
|
524
|
+
// Handle drawer open
|
|
525
|
+
const handleOpen = React__namespace.useCallback(async () => {
|
|
526
|
+
if (!componentsLoaded && !isLoading) {
|
|
527
|
+
await preloadComponents();
|
|
528
|
+
}
|
|
529
|
+
setIsOpen(true);
|
|
530
|
+
onOpen?.();
|
|
531
|
+
}, [componentsLoaded, isLoading, preloadComponents, onOpen]);
|
|
532
|
+
// Handle drawer close
|
|
533
|
+
const handleClose = React__namespace.useCallback(() => {
|
|
534
|
+
setIsOpen(false);
|
|
535
|
+
onClose?.();
|
|
536
|
+
}, [onClose]);
|
|
537
|
+
// Handle new session
|
|
538
|
+
const handleNewSession = React__namespace.useCallback(async () => {
|
|
539
|
+
setInput('');
|
|
540
|
+
await resetChat();
|
|
541
|
+
}, [resetChat]);
|
|
542
|
+
// Handle keyboard shortcut
|
|
543
|
+
React__namespace.useEffect(() => {
|
|
544
|
+
if (!enableHotkey || !hotkey)
|
|
545
|
+
return;
|
|
546
|
+
const handleKeyDown = (e) => {
|
|
547
|
+
const keys = hotkey.toLowerCase().split('+');
|
|
548
|
+
const ctrl = keys.includes('ctrl') || keys.includes('control');
|
|
549
|
+
const cmd = keys.includes('cmd') || keys.includes('command') || keys.includes('meta');
|
|
550
|
+
const shift = keys.includes('shift');
|
|
551
|
+
const alt = keys.includes('alt');
|
|
552
|
+
const key = keys[keys.length - 1];
|
|
553
|
+
const ctrlPressed = ctrl && (e.ctrlKey || e.metaKey);
|
|
554
|
+
const cmdPressed = cmd && (e.metaKey || e.ctrlKey);
|
|
555
|
+
const shiftPressed = !shift || e.shiftKey;
|
|
556
|
+
const altPressed = !alt || e.altKey;
|
|
557
|
+
if ((ctrlPressed || cmdPressed) && shiftPressed && altPressed && e.key.toLowerCase() === key) {
|
|
558
|
+
e.preventDefault();
|
|
559
|
+
setIsOpen((prev) => !prev);
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
563
|
+
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
564
|
+
}, [enableHotkey, hotkey]);
|
|
565
|
+
return (jsxRuntime.jsxs("div", { className: `ask-ai ${className || ''} ${theme === 'dark' ? 'dark' : ''}`, style: style, children: [children && React__namespace.isValidElement(children) ? (React__namespace.cloneElement(children, {
|
|
566
|
+
...children.props,
|
|
567
|
+
onClick: (e) => {
|
|
568
|
+
// Call existing onClick if present
|
|
569
|
+
const existingOnClick = children.props?.onClick;
|
|
570
|
+
if (existingOnClick) {
|
|
571
|
+
existingOnClick(e);
|
|
572
|
+
}
|
|
573
|
+
// Then call our handleOpen
|
|
574
|
+
handleOpen();
|
|
575
|
+
},
|
|
576
|
+
})) : (jsxRuntime.jsx(Trigger, { onClick: handleOpen, text: texts?.triggerButtonText, ariaLabel: texts?.triggerButtonAriaLabel })), jsxRuntime.jsx(Drawer, { isOpen: isOpen, onClose: handleClose, onNewSession: handleNewSession, hasMessages: messages.length > 0, position: drawerPosition, width: drawerWidth, expandedWidth: drawerExpandedWidth, title: texts?.drawerTitle, closeAriaLabel: texts?.drawerCloseAriaLabel, newSessionAriaLabel: texts?.drawerNewSessionAriaLabel, theme: theme, children: (isOpen || componentsLoaded) && (jsxRuntime.jsx(React__namespace.Suspense, { fallback: jsxRuntime.jsx(lucideReact.Loader2, { className: styles$1.spinning }), children: jsxRuntime.jsx(ChatContainer$2, { texts: texts, exampleQuestions: exampleQuestions, onMessage: onMessage, onError: onError, messages: messages, isStreaming: isStreaming, error: error, sendMessage: sendMessage, input: input, setInput: setInput }) })) })] }));
|
|
524
577
|
}
|
|
525
578
|
|
|
526
|
-
var css_248z$2 = "/* ChatContainer 组件样式 */\n\n.container_FRFCj {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n}\n\n.messagesArea_Hi-49 {\n flex: 1;\n overflow-y: auto;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n/* Welcome Screen */\n.welcomeScreen_fJ8-E {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n text-align: center;\n}\n\n.welcomeMessage_unMIK {\n font-size: 18px;\n color: var(--ask-ai-foreground);\n margin-bottom: 16px;\n}\n\n.exampleQuestionsContainer_RBWq6 {\n margin-top: 24px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.exampleQuestionsTitle_Vurj8 {\n font-size: 14px;\n color: var(--ask-ai-muted);\n margin-bottom: 8px;\n}\n\n.exampleButton_6sOzR {\n display: block;\n width: 100%;\n text-align: left;\n padding: 8px 16px;\n font-size: 14px;\n color: var(--ask-ai-foreground);\n background-color: var(--ask-ai-button-bg);\n border: none;\n border-radius: var(--ask-ai-radius-md);\n cursor: pointer;\n transition: background-color var(--ask-ai-transition);\n}\n\n.exampleButton_6sOzR:hover {\n background-color: var(--ask-ai-border);\n}\n\n/* Messages */\n.messageWrapper_nsQr8 {\n display: flex;\n}\n\n.messageWrapper_nsQr8.user_s1Gzu {\n justify-content: flex-end;\n}\n\n.messageWrapper_nsQr8.assistant_xU0-H {\n justify-content: flex-start;\n}\n\n.message_jxpo4 {\n border-radius: var(--ask-ai-radius-lg);\n padding: 8px 16px;\n}\n\n.message_jxpo4.user_s1Gzu {\n max-width: 85%;\n background-color: var(--ask-ai-user-message-bg);\n color: var(--ask-ai-user-message-text);\n}\n\n.message_jxpo4.assistant_xU0-H {\n width: 100%;\n background-color: var(--ask-ai-ai-message-bg);\n color: var(--ask-ai-ai-message-text);\n padding: 8px 0;\n}\n\n.messageText_neW3m {\n font-size: 14px;\n white-space: pre-wrap;\n}\n\n/* Markdown Styles */\n.markdown_mNC3q {\n font-size: 14px;\n line-height: 1.7142857;\n}\n\n.markdown_mNC3q > *:first-child {\n margin-top: 0;\n}\n\n.markdown_mNC3q > *:last-child {\n margin-bottom: 0;\n}\n\n/* Tool Calls */\n.toolCallsContainer_1nUsV {\n display: flex;\n flex-direction: column;\n align-items: start;\n gap: 8px;\n margin-bottom: 8px;\n}\n\n.toolCall_gEKn0 {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 12px;\n font-size: 12px;\n background-color: var(--ask-ai-border);\n border-radius: 12px;\n white-space: nowrap;\n}\n\n.toolCall_gEKn0.tool-completed_5Utl8 {\n opacity: 0.7;\n}\n\n.toolCall_gEKn0.tool-pending_hifHC,\n.toolCall_gEKn0.tool-running_D0dCg {\n animation: pulse_STM-e 1.5s ease-in-out infinite;\n}\n\n.toolCall_gEKn0.tool-error_eqjRM {\n color: var(--ask-ai-error);\n}\n\n@keyframes pulse_STM-e {\n 0%, 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.6;\n }\n}\n\n/* 段落 */\n.markdown_mNC3q p {\n display: block;\n margin: 0.5em 0;\n}\n\n/* 标题 */\n.markdown_mNC3q h1,\n.markdown_mNC3q h2,\n.markdown_mNC3q h3,\n.markdown_mNC3q h4,\n.markdown_mNC3q h5,\n.markdown_mNC3q h6 {\n display: block;\n margin: 1em 0 0.5em;\n font-weight: 600;\n line-height: 1.3;\n}\n\n.markdown_mNC3q h1 {\n font-size: 1.5em;\n}\n\n.markdown_mNC3q h2 {\n font-size: 1.3em;\n}\n\n.markdown_mNC3q h3 {\n font-size: 1.1em;\n}\n\n/* 无序列表 */\n.markdown_mNC3q ul {\n display: block;\n margin: 0.5em 0;\n padding-left: 1.5em;\n list-style-type: disc;\n list-style-position: outside;\n}\n\n/* 有序列表 */\n.markdown_mNC3q ol {\n display: block;\n margin: 0.5em 0;\n padding-left: 1.5em;\n list-style-type: decimal;\n list-style-position: outside;\n}\n\n/* 嵌套列表 */\n.markdown_mNC3q ul ul {\n list-style-type: circle;\n}\n\n.markdown_mNC3q ul ul ul {\n list-style-type: square;\n}\n\n.markdown_mNC3q ol ol {\n list-style-type: lower-alpha;\n}\n\n.markdown_mNC3q ol ol ol {\n list-style-type: lower-roman;\n}\n\n/* 列表项 */\n.markdown_mNC3q li {\n display: list-item;\n margin: 0.25em 0;\n}\n\n/* 文本样式 */\n.markdown_mNC3q strong,\n.markdown_mNC3q b {\n font-weight: bold;\n}\n\n.markdown_mNC3q em,\n.markdown_mNC3q i {\n font-style: italic;\n}\n\n.markdown_mNC3q u {\n text-decoration: underline;\n}\n\n.markdown_mNC3q s,\n.markdown_mNC3q del {\n text-decoration: line-through;\n}\n\n.markdown_mNC3q code {\n font-family: var(--ask-ai-monospace-font-family);\n font-size: 0.9em;\n padding: 0.15em 0.4em;\n background-color: var(--ask-ai-border);\n border-radius: 4px;\n}\n\n/* 代码块容器 */\n.markdown_mNC3q pre {\n margin: 0.75em 0;\n padding: 0;\n background-color: var(--ask-ai-code-bg);\n border-radius: var(--ask-ai-radius-md);\n overflow-x: auto;\n line-height: 1.5;\n position: relative;\n}\n\n/* 代码块包装器 - 用于定位复制按钮 */\n.codeBlockWrapper_rOz7- {\n position: relative;\n}\n\n/* 复制按钮 */\n.copyButton_Ry43q {\n position: absolute;\n top: 8px;\n right: 8px;\n padding: 6px;\n backdrop-filter: blur(8px);\n background: rgba(0, 0, 0, 0);\n border: none;\n color: var(--ask-ai-code-text);\n opacity: 0.6;\n cursor: pointer;\n border-radius: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: opacity var(--ask-ai-transition), background-color var(--ask-ai-transition);\n}\n\n.copyButton_Ry43q:hover {\n opacity: 1;\n background-color: rgba(255, 255, 255, 0.1);\n}\n\n.markdown_mNC3q pre code {\n display: block;\n padding: 0.75em 1em;\n overflow: auto;\n background-color: transparent;\n border-radius: 0;\n font-size: 0.8571429em;\n line-height: 1.25rem;\n color: var(--ask-ai-code-text);\n font-family: var(--ask-ai-monospace-font-family);\n}\n\n/* Highlight.js 语法高亮样式 */\n.markdown_mNC3q .hljs-keyword,\n.markdown_mNC3q .hljs-selector-tag,\n.markdown_mNC3q .hljs-literal,\n.markdown_mNC3q .hljs-section,\n.markdown_mNC3q .hljs-link {\n color: var(--ask-ai-code-keyword);\n font-weight: bold;\n}\n\n.markdown_mNC3q .hljs-string,\n.markdown_mNC3q .hljs-regexp,\n.markdown_mNC3q .hljs-addition,\n.markdown_mNC3q .hljs-attribute,\n.markdown_mNC3q .hljs-meta-string {\n color: var(--ask-ai-code-string);\n}\n\n.markdown_mNC3q .hljs-number,\n.markdown_mNC3q .hljs-meta .hljs-keyword {\n color: var(--ask-ai-code-number);\n}\n\n.markdown_mNC3q .hljs-comment,\n.markdown_mNC3q .hljs-quote {\n color: var(--ask-ai-code-comment);\n font-style: italic;\n}\n\n.markdown_mNC3q .hljs-function,\n.markdown_mNC3q .hljs-title {\n color: var(--ask-ai-code-function);\n}\n\n.markdown_mNC3q .hljs-operator,\n.markdown_mNC3q .hljs-punctuation {\n color: var(--ask-ai-code-operator);\n}\n\n.markdown_mNC3q .hljs-variable,\n.markdown_mNC3q .hljs-property,\n.markdown_mNC3q .hljs-params {\n color: var(--ask-ai-code-variable);\n}\n\n.markdown_mNC3q .hljs-type,\n.markdown_mNC3q .hljs-class,\n.markdown_mNC3q .hljs-built_in {\n color: var(--ask-ai-code-type);\n}\n\n.markdown_mNC3q .hljs-builtin,\n.markdown_mNC3q .hljs-name {\n color: var(--ask-ai-code-builtin);\n}\n\n.markdown_mNC3q .hljs-tag {\n color: var(--ask-ai-code-tag);\n}\n\n.markdown_mNC3q .hljs-attr {\n color: var(--ask-ai-code-attr);\n}\n\n.markdown_mNC3q .hljs-deletion {\n color: var(--ask-ai-error);\n}\n\n.markdown_mNC3q .hljs-emphasis {\n font-style: italic;\n}\n\n.markdown_mNC3q .hljs-strong {\n font-weight: bold;\n}\n\n.markdown_mNC3q blockquote {\n margin: 0.5em 0;\n padding: 0.5em 1em;\n border-left: 3px solid var(--ask-ai-primary);\n background-color: var(--ask-ai-border);\n border-radius: 0 var(--ask-ai-radius-sm) var(--ask-ai-radius-sm) 0;\n}\n\n.markdown_mNC3q blockquote p {\n margin: 0;\n}\n\n.markdown_mNC3q a {\n color: var(--ask-ai-primary);\n text-decoration: none;\n}\n\n.markdown_mNC3q a:hover {\n text-decoration: underline;\n}\n\n.markdown_mNC3q table {\n width: 100%;\n margin: 0.75em 0;\n border-collapse: collapse;\n font-size: 0.9em;\n}\n\n.markdown_mNC3q th,\n.markdown_mNC3q td {\n padding: 0.5em 0.75em;\n border: 1px solid var(--ask-ai-border);\n text-align: left;\n}\n\n.markdown_mNC3q th {\n background-color: var(--ask-ai-border);\n font-weight: 600;\n}\n\n.markdown_mNC3q hr {\n margin: 1em 0;\n border: none;\n border-top: 1px solid var(--ask-ai-border);\n}\n\n.markdown_mNC3q img {\n max-width: 100%;\n height: auto;\n border-radius: var(--ask-ai-radius-md);\n}\n\n.cursor_9Dhwg {\n display: inline-block;\n width: 6px;\n height: 16px;\n background-color: currentColor;\n animation: blink_-4y-x 1s step-end infinite;\n}\n\n@keyframes blink_-4y-x {\n 0%, 50% {\n opacity: 0.75;\n }\n 50.01%, 100% {\n opacity: 0;\n }\n}\n\n/* Error */\n.error_uFX9a {\n padding: 16px;\n background-color: rgba(220, 38, 38, 0.1);\n color: var(--ask-ai-error);\n border-radius: var(--ask-ai-radius-md);\n font-size: 14px;\n}\n\n/* Input Area */\n.inputForm_nC0l- {\n border-top: 1px solid var(--ask-ai-border);\n padding: 16px;\n margin: 0;\n}\n\n.inputWrapper_zGeKy {\n display: flex;\n gap: 8px;\n align-items: flex-end;\n}\n\n.input_7lMOc {\n flex: 1;\n padding: 8px 16px;\n font-size: 14px;\n background-color: var(--ask-ai-background);\n border: 1px solid var(--ask-ai-border);\n border-radius: var(--ask-ai-radius-md);\n color: var(--ask-ai-foreground);\n font-family: inherit;\n resize: none;\n min-height: 40px;\n max-height: 200px;\n line-height: 1.5;\n overflow-y: auto;\n}\n\n.input_7lMOc:focus {\n outline: none;\n box-shadow: 0 0 0 2px var(--ask-ai-primary);\n}\n\n.input_7lMOc:disabled {\n opacity: 0.5;\n}\n\n.submitButton_2XrPY {\n height: 40px;\n padding: 8px;\n font-size: 14px;\n background-color: var(--ask-ai-primary);\n color: #ffffff;\n border: none;\n border-radius: var(--ask-ai-radius-md);\n cursor: pointer;\n transition: all var(--ask-ai-transition);\n}\n\n.submitButton_2XrPY:hover:not(:disabled) {\n background-color: var(--ask-ai-primary-hover);\n}\n\n.submitButton_2XrPY:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n";
|
|
527
579
|
var styles = {"container":"container_FRFCj","messagesArea":"messagesArea_Hi-49","welcomeScreen":"welcomeScreen_fJ8-E","welcomeMessage":"welcomeMessage_unMIK","exampleQuestionsContainer":"exampleQuestionsContainer_RBWq6","exampleQuestionsTitle":"exampleQuestionsTitle_Vurj8","exampleButton":"exampleButton_6sOzR","messageWrapper":"messageWrapper_nsQr8","user":"user_s1Gzu","assistant":"assistant_xU0-H","message":"message_jxpo4","messageText":"messageText_neW3m","markdown":"markdown_mNC3q","toolCallsContainer":"toolCallsContainer_1nUsV","toolCall":"toolCall_gEKn0","tool-completed":"tool-completed_5Utl8","tool-pending":"tool-pending_hifHC","tool-running":"tool-running_D0dCg","pulse":"pulse_STM-e","tool-error":"tool-error_eqjRM","codeBlockWrapper":"codeBlockWrapper_rOz7-","copyButton":"copyButton_Ry43q","cursor":"cursor_9Dhwg","blink":"blink_-4y-x","error":"error_uFX9a","inputForm":"inputForm_nC0l-","inputWrapper":"inputWrapper_zGeKy","input":"input_7lMOc","submitButton":"submitButton_2XrPY"};
|
|
528
|
-
styleInject(css_248z$2);
|
|
529
580
|
|
|
530
581
|
function ChatContainer({ texts, exampleQuestions, onMessage, onError, messages, isStreaming, error, sendMessage, input, setInput, }) {
|
|
531
582
|
const textareaRef = React__namespace.useRef(null);
|
|
@@ -673,75 +724,14 @@ function ChatContainer({ texts, exampleQuestions, onMessage, onError, messages,
|
|
|
673
724
|
}, children: message.content }), message.isStreaming && (jsxRuntime.jsx("span", { className: styles.cursor }))] })) : (jsxRuntime.jsx("div", { className: styles.messageText, children: message.content })) }) }, message.id))) })), error && (jsxRuntime.jsx("div", { className: styles.error, children: error.message }))] }), jsxRuntime.jsx("form", { onSubmit: handleSubmit, className: styles.inputForm, children: jsxRuntime.jsxs("div", { className: styles.inputWrapper, children: [jsxRuntime.jsx("textarea", { ref: textareaRef, value: input, onChange: handleInputChange, onKeyDown: handleKeyDown, placeholder: inputPlaceholder, className: styles.input, rows: 1 }), jsxRuntime.jsx("button", { type: "submit", disabled: !input.trim() || isStreaming, className: styles.submitButton, children: jsxRuntime.jsx(lucideReact.ArrowUp, {}) })] }) })] }));
|
|
674
725
|
}
|
|
675
726
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
// Lift chat state to Widget level to persist across drawer open/close
|
|
681
|
-
const { messages, isStreaming, error, sendMessage, resetChat } = useChat({ apiClient, texts });
|
|
682
|
-
// Input state also needs to persist
|
|
683
|
-
const [input, setInput] = React__namespace.useState('');
|
|
684
|
-
// Handle drawer open
|
|
685
|
-
const handleOpen = React__namespace.useCallback(() => {
|
|
686
|
-
setIsOpen(true);
|
|
687
|
-
onOpen?.();
|
|
688
|
-
}, [onOpen]);
|
|
689
|
-
// Handle drawer close
|
|
690
|
-
const handleClose = React__namespace.useCallback(() => {
|
|
691
|
-
setIsOpen(false);
|
|
692
|
-
onClose?.();
|
|
693
|
-
}, [onClose]);
|
|
694
|
-
// Handle new session
|
|
695
|
-
const handleNewSession = React__namespace.useCallback(async () => {
|
|
696
|
-
setInput('');
|
|
697
|
-
await resetChat();
|
|
698
|
-
}, [resetChat]);
|
|
699
|
-
// Handle keyboard shortcut
|
|
700
|
-
React__namespace.useEffect(() => {
|
|
701
|
-
if (!enableHotkey || !hotkey)
|
|
702
|
-
return;
|
|
703
|
-
const handleKeyDown = (e) => {
|
|
704
|
-
const keys = hotkey.toLowerCase().split('+');
|
|
705
|
-
const ctrl = keys.includes('ctrl') || keys.includes('control');
|
|
706
|
-
const cmd = keys.includes('cmd') || keys.includes('command') || keys.includes('meta');
|
|
707
|
-
const shift = keys.includes('shift');
|
|
708
|
-
const alt = keys.includes('alt');
|
|
709
|
-
const key = keys[keys.length - 1];
|
|
710
|
-
const ctrlPressed = ctrl && (e.ctrlKey || e.metaKey);
|
|
711
|
-
const cmdPressed = cmd && (e.metaKey || e.ctrlKey);
|
|
712
|
-
const shiftPressed = !shift || e.shiftKey;
|
|
713
|
-
const altPressed = !alt || e.altKey;
|
|
714
|
-
if ((ctrlPressed || cmdPressed) && shiftPressed && altPressed && e.key.toLowerCase() === key) {
|
|
715
|
-
e.preventDefault();
|
|
716
|
-
setIsOpen((prev) => !prev);
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
720
|
-
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
721
|
-
}, [enableHotkey, hotkey]);
|
|
722
|
-
return (jsxRuntime.jsxs("div", { className: `ask-ai ${className || ''} ${theme === 'dark' ? 'dark' : ''}`, style: style, children: [children && React__namespace.isValidElement(children) ? (React__namespace.cloneElement(children, {
|
|
723
|
-
...children.props,
|
|
724
|
-
onClick: (e) => {
|
|
725
|
-
// Call existing onClick if present
|
|
726
|
-
const existingOnClick = children.props?.onClick;
|
|
727
|
-
if (existingOnClick) {
|
|
728
|
-
existingOnClick(e);
|
|
729
|
-
}
|
|
730
|
-
// Then call our handleOpen
|
|
731
|
-
handleOpen();
|
|
732
|
-
},
|
|
733
|
-
})) : (jsxRuntime.jsx(Trigger, { onClick: handleOpen, text: texts?.triggerButtonText, ariaLabel: texts?.triggerButtonAriaLabel })), jsxRuntime.jsx(Drawer, { isOpen: isOpen, onClose: handleClose, onNewSession: handleNewSession, hasMessages: messages.length > 0, position: drawerPosition, width: drawerWidth, expandedWidth: drawerExpandedWidth, title: texts?.drawerTitle, closeAriaLabel: texts?.drawerCloseAriaLabel, newSessionAriaLabel: texts?.drawerNewSessionAriaLabel, theme: theme, children: jsxRuntime.jsx(ChatContainer, { texts: texts, exampleQuestions: exampleQuestions, onMessage: onMessage, onError: onError, messages: messages, isStreaming: isStreaming, error: error, sendMessage: sendMessage, input: input, setInput: setInput }) })] }));
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
var css_248z$1 = "/* CSS 变量定义 - 亮色主题(默认) */\n.ask-ai {\n /* 颜色 */\n --ask-ai-primary: #2563eb;\n --ask-ai-primary-hover: #1d4ed8;\n --ask-ai-background: #ffffff;\n --ask-ai-foreground: #0f172a;\n --ask-ai-muted: #64748b;\n --ask-ai-border: #e2e8f0;\n --ask-ai-error: #dc2626;\n --ask-ai-button-bg: #f1f5f9;\n\n /* 用户消息 */\n --ask-ai-user-message-bg: var(--ask-ai-button-bg);\n --ask-ai-user-message-text: var(--ask-ai-foreground);\n\n /* AI 消息 */\n --ask-ai-ai-message-bg: none;\n --ask-ai-ai-message-text: var(--ask-ai-foreground);\n\n /* 字体 */\n --ask-ai-font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n --ask-ai-monospace-font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n --ask-ai-font-size-base: 14px;\n --ask-ai-line-height: 1.5;\n\n /* 间距 */\n --ask-ai-spacing-xs: 4px;\n --ask-ai-spacing-sm: 8px;\n --ask-ai-spacing-md: 16px;\n --ask-ai-spacing-lg: 24px;\n\n /* 圆角 */\n --ask-ai-radius-sm: 4px;\n --ask-ai-radius-md: 8px;\n --ask-ai-radius-lg: 12px;\n\n /* 阴影 */\n --ask-ai-shadow: none;\n\n /* 动画 */\n --ask-ai-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);\n\n /* 抽屉层级 */\n --ask-ai-overlay-z-index: 400;\n\n /* 语法高亮 - 亮色主题 (VS Code Light+) */\n --ask-ai-code-bg: #f8f8f8;\n --ask-ai-code-text: #000000;\n --ask-ai-code-keyword: #0000ff; /* 关键字:蓝色 */\n --ask-ai-code-string: #a31515; /* 字符串:红色 */\n --ask-ai-code-number: #098658; /* 数字:绿色 */\n --ask-ai-code-comment: #008000; /* 注释:绿色 */\n --ask-ai-code-function: #795e26; /* 函数:棕色 */\n --ask-ai-code-operator: #000000; /* 操作符:黑色 */\n --ask-ai-code-variable: #001080; /* 变量:深蓝 */\n --ask-ai-code-type: #267f99; /* 类型:青蓝 */\n --ask-ai-code-builtin: #0000ff; /* 内置:蓝色 */\n --ask-ai-code-tag: #800000; /* 标签:深红 */\n --ask-ai-code-attr: #ff0000; /* 属性:红色 */\n}\n\n/* 明确指定暗色主题 */\n.ask-ai.dark {\n --ask-ai-primary: #3b82f6;\n --ask-ai-primary-hover: #2563eb;\n --ask-ai-background: #0f172a;\n --ask-ai-foreground: #f1f5f9;\n --ask-ai-muted: #94a3b8;\n --ask-ai-border: #334155;\n --ask-ai-error: #ef4444;\n --ask-ai-button-bg: #1e293b;\n\n /* 语法高亮 - 暗色主题 (VS Code Dark+) */\n --ask-ai-code-bg: #1e1e1e;\n --ask-ai-code-text: #d4d4d4;\n --ask-ai-code-keyword: #569cd6; /* 关键字:蓝色 */\n --ask-ai-code-string: #ce9178; /* 字符串:米色 */\n --ask-ai-code-number: #b5cea8; /* 数字:浅绿 */\n --ask-ai-code-comment: #6a9955; /* 注释:绿色 */\n --ask-ai-code-function: #dcdcaa; /* 函数:黄色 */\n --ask-ai-code-operator: #d4d4d4; /* 操作符:浅灰 */\n --ask-ai-code-variable: #9cdcfe; /* 变量:青色 */\n --ask-ai-code-type: #4ec9b0; /* 类型:青绿 */\n --ask-ai-code-builtin: #4fc1ff; /* 内置:亮蓝 */\n --ask-ai-code-tag: #569cd6; /* 标签:蓝色 */\n --ask-ai-code-attr: #9cdcfe; /* 属性:青色 */\n}\n";
|
|
737
|
-
styleInject(css_248z$1);
|
|
738
|
-
|
|
739
|
-
var css_248z = "/* 全局样式 - 所有样式都在 .ask-ai 命名空间下 */\n\n/* 基础样式重置 */\n.ask-ai *,\n.ask-ai *::before,\n.ask-ai *::after {\n box-sizing: border-box;\n}\n\n.ask-ai {\n font-family: var(--ask-ai-font-family);\n font-size: var(--ask-ai-font-size-base);\n line-height: var(--ask-ai-line-height);\n color: var(--ask-ai-foreground);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n/* 确保组件不受外部样式影响 */\n.ask-ai button {\n font-family: inherit;\n}\n\n.ask-ai input,\n.ask-ai textarea {\n font-family: inherit;\n font-size: inherit;\n}\n\n/* 滚动条样式 */\n.ask-ai ::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.ask-ai ::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.ask-ai ::-webkit-scrollbar-thumb {\n background: var(--ask-ai-border);\n border-radius: var(--ask-ai-radius-sm);\n}\n\n.ask-ai ::-webkit-scrollbar-thumb:hover {\n background: var(--ask-ai-muted);\n}\n";
|
|
740
|
-
styleInject(css_248z);
|
|
727
|
+
var ChatContainer$1 = /*#__PURE__*/Object.freeze({
|
|
728
|
+
__proto__: null,
|
|
729
|
+
ChatContainer: ChatContainer
|
|
730
|
+
});
|
|
741
731
|
|
|
742
732
|
exports.APIClient = APIClient;
|
|
743
733
|
exports.AskAIWidget = Widget;
|
|
744
734
|
exports.useChat = useChat;
|
|
745
735
|
exports.useSSE = useSSE;
|
|
746
736
|
exports.useSession = useSession;
|
|
747
|
-
//# sourceMappingURL=index.
|
|
737
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/core/api/client.ts","../../src/core/hooks/useSession.ts","../../src/core/hooks/useSSE.ts","../../src/core/hooks/useChat.ts","../../src/components/ui/Button.tsx","../../src/components/widget/Trigger.tsx","../../src/components/widget/Drawer.tsx","../../src/components/widget/Widget.tsx","../../src/components/chat/ChatContainer.tsx"],"sourcesContent":["import type { SessionResponse } from '../types/index.js';\n\n/**\n * API client for Ask AI widget\n * Supports dynamic API URL configuration and optional project-scoped API\n */\nexport class APIClient {\n private baseUrl: string;\n private projectId?: string;\n\n constructor(baseUrl: string, projectId?: string) {\n this.baseUrl = baseUrl.replace(/\\/$/, ''); // Remove trailing slash\n this.projectId = projectId;\n }\n\n /**\n * Create a new session\n */\n async createSession(): Promise<SessionResponse> {\n const url = this.projectId\n ? `${this.baseUrl}/api/projects/${this.projectId}/session`\n : `${this.baseUrl}/api/session`;\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create session: ${response.statusText}`);\n }\n\n return response.json();\n }\n\n /**\n * Delete a session\n */\n async deleteSession(sessionId: string): Promise<void> {\n const url = this.projectId\n ? `${this.baseUrl}/api/projects/${this.projectId}/session/${sessionId}`\n : `${this.baseUrl}/api/session/${sessionId}`;\n\n const response = await fetch(url, {\n method: 'DELETE',\n });\n\n if (!response.ok) {\n throw new Error(`Failed to delete session: ${response.statusText}`);\n }\n }\n\n /**\n * Ask a question and return the SSE stream response\n */\n async askQuestion(\n sessionId: string,\n question: string,\n signal?: AbortSignal\n ): Promise<Response> {\n const url = this.projectId\n ? `${this.baseUrl}/api/projects/${this.projectId}/ask`\n : `${this.baseUrl}/api/ask`;\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n sessionId,\n question,\n }),\n signal,\n });\n\n if (!response.ok) {\n throw new Error(`Failed to ask question: ${response.statusText}`);\n }\n\n return response;\n }\n}\n","import { useState, useEffect, useCallback } from 'react';\nimport type { APIClient } from '../api/client.js';\n\ninterface UseSessionOptions {\n apiClient: APIClient;\n}\n\ninterface UseSessionReturn {\n sessionId: string | null;\n isCreating: boolean;\n error: Error | null;\n initializeSession: () => Promise<string>;\n clearSession: () => Promise<void>;\n}\n\nexport function useSession({ apiClient }: UseSessionOptions): UseSessionReturn {\n const [sessionId, setSessionId] = useState<string | null>(null);\n const [isCreating, setIsCreating] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const initializeSession = useCallback(async () => {\n setIsCreating(true);\n setError(null);\n\n try {\n const { sessionId: newSessionId } = await apiClient.createSession();\n setSessionId(newSessionId);\n return newSessionId;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Failed to create session');\n setError(error);\n console.error('Failed to create session:', error);\n throw error;\n } finally {\n setIsCreating(false);\n }\n }, [apiClient]);\n\n const clearSession = useCallback(async () => {\n setSessionId(null);\n setIsCreating(false);\n setError(null);\n }, [sessionId, apiClient, initializeSession]);\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n if (sessionId) {\n apiClient.deleteSession(sessionId).catch((err) => {\n console.error('Failed to cleanup session on unmount:', err);\n });\n }\n };\n }, [sessionId, apiClient]);\n\n return {\n sessionId,\n isCreating,\n error,\n initializeSession,\n clearSession,\n };\n}\n","import { useCallback } from 'react';\nimport type { SSEData } from '../types/index.js';\n\ninterface UseSSEOptions {\n onConnected?: () => void;\n onMessage?: (data: SSEData) => void;\n onDone?: () => void;\n onError?: (error: Error) => void;\n}\n\ninterface UseSSEReturn {\n handleSSEStream: (response: Response) => Promise<void>;\n}\n\n/**\n * Parse SSE chunk format: \"event: type\\ndata: json\\n\\n\"\n */\nfunction parseSSEChunk(chunk: string): Array<{ event: string; data: any }> {\n const events: Array<{ event: string; data: any }> = [];\n const lines = chunk.split('\\n');\n let currentEvent = '';\n let currentData = '';\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7).trim();\n } else if (line.startsWith('data: ')) {\n currentData = line.slice(6).trim();\n } else if (line === '') {\n // Empty line marks end of event\n if (currentEvent && currentData) {\n try {\n const parsedData = JSON.parse(currentData);\n events.push({\n event: currentEvent,\n data: parsedData,\n });\n } catch (err) {\n console.error('Failed to parse SSE data:', currentData, err);\n }\n currentEvent = '';\n currentData = '';\n }\n }\n }\n\n return events;\n}\n\nexport function useSSE(options: UseSSEOptions = {}): UseSSEReturn {\n const { onConnected, onMessage, onDone, onError } = options;\n\n const handleSSEStream = useCallback(\n async (response: Response) => {\n const reader = response.body?.getReader();\n const decoder = new TextDecoder();\n\n if (!reader) {\n onError?.(new Error('No response body'));\n return;\n }\n\n let buffer = '';\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n\n // Process complete events\n const events = parseSSEChunk(buffer);\n\n for (const { event, data } of events) {\n if (event === 'connected') {\n onConnected?.();\n onMessage?.(data);\n } else if (event === 'answer' || event === 'tool') {\n onMessage?.(data);\n } else if (event === 'done') {\n onDone?.();\n onMessage?.(data);\n } else if (event === 'error') {\n onError?.(new Error(data.error || 'Unknown error'));\n onMessage?.(data);\n }\n }\n\n // Clear processed events from buffer (keep incomplete data)\n const lastEventEnd = buffer.lastIndexOf('\\n\\n');\n if (lastEventEnd !== -1) {\n buffer = buffer.slice(lastEventEnd + 2);\n }\n }\n } catch (err) {\n // Don't report AbortError as it's an intentional cancellation\n if (err instanceof Error && err.name === 'AbortError') {\n return;\n }\n const error = err instanceof Error ? err : new Error('SSE stream error');\n onError?.(error);\n } finally {\n reader.releaseLock();\n }\n },\n [onConnected, onMessage, onDone, onError]\n );\n\n return {\n handleSSEStream,\n };\n}\n","import { useState, useCallback, useRef } from 'react';\nimport { useSession } from './useSession.js';\nimport { useSSE } from './useSSE.js';\nimport type { Message, WidgetTexts } from '../types/index.js';\nimport type { APIClient } from '../api/client.js';\n\ninterface UseChatOptions {\n apiClient: APIClient;\n texts?: WidgetTexts;\n}\n\ninterface UseChatReturn {\n messages: Message[];\n isStreaming: boolean;\n error: Error | null;\n sessionError: Error | null;\n isCreatingSession: boolean;\n sendMessage: (text: string) => Promise<void>;\n resetChat: () => Promise<void>;\n}\n\nlet idCounter = 0;\n\nfunction getMessageId() {\n idCounter += 1;\n return `msg-${idCounter}`; \n}\n\nexport function useChat({ apiClient, texts }: UseChatOptions): UseChatReturn {\n const [messages, setMessages] = useState<Message[]>([]);\n const [isStreaming, setIsStreaming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const { sessionId, isCreating: isCreatingSession, error: sessionError, initializeSession, clearSession } = useSession({ apiClient });\n\n const { handleSSEStream } = useSSE({\n onConnected: () => {\n console.log('SSE connected');\n },\n onMessage: (data) => {\n if (data.type === 'answer' && data.text) {\n // Accumulate the answer text\n setMessages((prev) => {\n const lastMessage = prev[prev.length - 1];\n if (lastMessage && lastMessage.role === 'assistant' && lastMessage.isStreaming) {\n // Update the last assistant message\n return prev.slice(0, -1).concat({\n ...lastMessage,\n content: lastMessage.content + data.text,\n });\n }\n return prev;\n });\n } else if (data.type === 'tool') {\n // Handle tool updates\n setMessages((prev) => {\n const lastMessage = prev[prev.length - 1];\n if (lastMessage && lastMessage.role === 'assistant' && lastMessage.isStreaming) {\n // Get existing tool calls or create new array\n const existingToolCalls = lastMessage.toolCalls || [];\n\n // Find the tool call with this callID\n const toolIndex = existingToolCalls.findIndex(tc => tc.callID === data.callID);\n\n let updatedToolCalls;\n if (toolIndex >= 0) {\n // Update existing tool call\n updatedToolCalls = [...existingToolCalls];\n updatedToolCalls[toolIndex] = {\n callID: data.callID,\n tool: data.tool,\n status: data.status,\n };\n } else {\n // Add new tool call\n updatedToolCalls = [...existingToolCalls, {\n callID: data.callID,\n tool: data.tool,\n status: data.status,\n }];\n }\n\n return prev.slice(0, -1).concat({\n ...lastMessage,\n toolCalls: updatedToolCalls,\n });\n }\n return prev;\n });\n }\n },\n onDone: () => {\n // Mark streaming complete\n setMessages((prev) => {\n const lastMessage = prev[prev.length - 1];\n if (lastMessage && lastMessage.role === 'assistant') {\n // If AI didn't send any content, show a fallback message\n const emptyResponseText = texts?.emptyResponseText || 'Something went wrong. Please try again later.';\n const content = lastMessage.content.trim() || emptyResponseText;\n return prev.slice(0, -1).concat({\n ...lastMessage,\n content,\n isStreaming: false,\n });\n }\n return prev;\n });\n setIsStreaming(false);\n },\n onError: (err) => {\n setError(err);\n setIsStreaming(false);\n // Remove the failed assistant message\n setMessages((prev) => {\n const lastMessage = prev[prev.length - 1];\n if (lastMessage && lastMessage.role === 'assistant' && lastMessage.isStreaming) {\n return prev.slice(0, -1);\n }\n return prev;\n });\n },\n });\n\n const sendMessage = useCallback(\n async (text: string) => {\n if (!text.trim()) {\n return;\n }\n\n // Abort any ongoing request\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController for this request\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setError(null);\n\n setIsStreaming(true);\n\n // Add user message immediately (optimistic UI)\n const userMessage: Message = {\n id: getMessageId(),\n role: 'user',\n content: text,\n timestamp: Date.now(),\n };\n setMessages((prev) => [...prev, userMessage]);\n\n // Add placeholder for assistant response\n const assistantMessage: Message = {\n id: getMessageId(),\n role: 'assistant',\n content: '',\n timestamp: Date.now(),\n isStreaming: true,\n };\n setMessages((prev) => [...prev, assistantMessage]);\n\n // Create session if it doesn't exist yet\n let currentSessionId = sessionId;\n if (!currentSessionId && !isCreatingSession) {\n try {\n currentSessionId = await initializeSession();\n } catch (err) {\n setError(new Error('Failed to create session'));\n setIsStreaming(false);\n return;\n }\n }\n\n // Wait for session to be created if it's currently being created\n if (isCreatingSession) {\n setError(new Error('Session is being created, please try again'));\n return;\n }\n\n if (!currentSessionId) {\n setError(new Error('No active session'));\n return;\n }\n\n try {\n const response = await apiClient.askQuestion(\n currentSessionId,\n text,\n abortController.signal\n );\n await handleSSEStream(response);\n } catch (err) {\n // Don't treat aborted requests as errors\n if (err instanceof Error && err.name === 'AbortError') {\n return;\n }\n\n const error = err instanceof Error ? err : new Error('Failed to send message');\n setError(error);\n setIsStreaming(false);\n\n // Remove the failed messages\n setMessages((prev) => prev.slice(0, -2));\n } finally {\n // Clear the abort controller reference if this was the current one\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n }\n },\n [sessionId, isCreatingSession, initializeSession, apiClient, handleSSEStream]\n );\n\n const resetChat = useCallback(async () => {\n // Abort any ongoing request\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n abortControllerRef.current = null;\n }\n\n setMessages([]);\n setError(null);\n setIsStreaming(false);\n await clearSession();\n }, [clearSession]);\n\n return {\n messages,\n isStreaming,\n error,\n sessionError,\n isCreatingSession,\n sendMessage,\n resetChat,\n };\n}\n","import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\nimport styles from './Button.module.css';\n\ntype ButtonVariant = 'default' | 'outline' | 'ghost' | 'icon';\ntype ButtonSize = 'default' | 'sm' | 'lg' | 'icon';\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n asChild?: boolean;\n variant?: ButtonVariant;\n size?: ButtonSize;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant = 'default', size = 'default', asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : 'button';\n\n const classNames = [\n styles.button,\n styles[`variant-${variant}`],\n styles[`size-${size}`],\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <Comp\n className={classNames}\n ref={ref}\n {...props}\n />\n );\n }\n);\n\nButton.displayName = 'Button';\n\nexport { Button };\n","import { Sparkles, Loader2 } from 'lucide-react';\nimport { Button } from '../ui/Button.js';\nimport styles from './Trigger.module.css';\n\ninterface TriggerProps {\n onClick: () => void;\n text?: string;\n ariaLabel?: string;\n className?: string;\n isLoading?: boolean;\n}\n\nexport function Trigger({\n onClick,\n text = 'Ask AI',\n ariaLabel = 'Open AI assistant',\n className,\n isLoading = false,\n}: TriggerProps) {\n const classNames = [styles.trigger, className].filter(Boolean).join(' ');\n\n return (\n <Button\n onClick={onClick}\n variant=\"outline\"\n aria-label={ariaLabel}\n className={classNames}\n disabled={isLoading}\n >\n {isLoading ? (\n <Loader2 className={`${styles.icon} ${styles.spinning}`} />\n ) : (\n <Sparkles className={styles.icon} />\n )}\n {text && <span>{text}</span>}\n </Button>\n );\n}\n","import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { Sparkles, X, EraserIcon, Maximize2, Minimize2 } from 'lucide-react';\nimport { Button } from '../ui/Button.js';\nimport styles from './Drawer.module.css';\n\ninterface DrawerProps {\n isOpen: boolean;\n onClose: () => void;\n onNewSession?: () => void;\n hasMessages?: boolean;\n position?: 'right' | 'left';\n width?: number | string;\n expandedWidth?: number | string;\n title?: string;\n closeAriaLabel?: string;\n newSessionAriaLabel?: string;\n children?: React.ReactNode;\n theme?: 'light' | 'dark';\n}\n\nexport function Drawer({\n isOpen,\n onClose,\n onNewSession,\n hasMessages,\n position = 'right',\n width = 600,\n expandedWidth = 920,\n title = 'Ask AI',\n closeAriaLabel = 'Close',\n newSessionAriaLabel = 'New session',\n children,\n theme = 'light',\n}: DrawerProps) {\n const [isExpanded, setIsExpanded] = React.useState(false);\n\n const maxWidth = isExpanded ? expandedWidth : width;\n\n const contentClasses = [\n styles.content,\n styles[`position-${position}`],\n ].join(' ');\n\n // Create a portal container that inherits theme from the nearest .ask-ai ancestor\n const [portalContainer, setPortalContainer] = React.useState<HTMLElement | null>(null);\n\n React.useEffect(() => {\n if (typeof document === 'undefined') return;\n\n // Create a portal container with ask-ai class\n const container = document.createElement('div');\n container.className = `ask-ai${theme === 'dark' ? ' dark' : ''}`;\n document.body.appendChild(container);\n setPortalContainer(container);\n\n return () => {\n document.body.removeChild(container);\n };\n }, [theme]);\n\n return (\n <DialogPrimitive.Root open={isOpen} onOpenChange={(open) => !open && onClose()}>\n <DialogPrimitive.Portal container={portalContainer}>\n {/* Overlay */}\n <DialogPrimitive.Overlay className={styles.overlay} />\n\n {/* Drawer Content */}\n <DialogPrimitive.Content\n className={contentClasses}\n style={{ maxWidth }}\n >\n {/* Header */}\n <div className={styles.header}>\n <DialogPrimitive.Title className={styles.title}>\n <Sparkles className={styles.icon} />\n {title}\n </DialogPrimitive.Title>\n <div className={styles.headerActions}>\n {onNewSession && hasMessages && (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={newSessionAriaLabel}\n className={styles.newSessionButton}\n onClick={onNewSession}\n >\n <EraserIcon className={styles.newSessionIcon} />\n </Button>\n )}\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={isExpanded ? 'Shrink' : 'Expand'}\n className={styles.expandButton}\n onClick={() => setIsExpanded(!isExpanded)}\n >\n {isExpanded ? (\n <Minimize2 className={styles.expandIcon} />\n ) : (\n <Maximize2 className={styles.expandIcon} />\n )}\n </Button>\n <DialogPrimitive.Close asChild>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n aria-label={closeAriaLabel}\n className={styles.closeButton}\n >\n <X className={styles.closeIcon} />\n </Button>\n </DialogPrimitive.Close>\n </div>\n </div>\n\n {/* Content */}\n <div className={styles.body}>\n {children}\n </div>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n}\n","import * as React from 'react';\nimport { Loader2 } from 'lucide-react';\nimport { APIClient } from '../../core/api/client.js';\nimport { useChat } from '../../core/hooks/useChat.js';\nimport type { WidgetProps } from '../../core/types/index.js';\nimport { Trigger } from './Trigger.js';\nimport { Drawer } from './Drawer.js';\nimport styles from './Widget.module.css';\n\n// Lazy load heavy components\nconst ChatContainer = React.lazy(() => import('../chat/ChatContainer.js').then(m => ({ default: m.ChatContainer })));\n\nexport function Widget(props: WidgetProps) {\n const {\n apiUrl,\n projectId,\n drawerPosition = 'right',\n drawerWidth = 600,\n drawerExpandedWidth = 920,\n theme = 'light',\n texts,\n exampleQuestions,\n hotkey,\n enableHotkey = true,\n onOpen,\n onClose,\n onMessage,\n onError,\n className,\n style,\n children,\n } = props;\n\n const [isOpen, setIsOpen] = React.useState(false);\n const [isLoading, setIsLoading] = React.useState(false);\n const [componentsLoaded, setComponentsLoaded] = React.useState(false);\n const [apiClient] = React.useState(() => new APIClient(apiUrl, projectId));\n\n // Lift chat state to Widget level to persist across drawer open/close\n const { messages, isStreaming, error, sendMessage, resetChat } = useChat({ apiClient, texts });\n\n // Input state also needs to persist\n const [input, setInput] = React.useState('');\n\n // Preload components\n const preloadComponents = React.useCallback(async () => {\n if (componentsLoaded) return;\n\n setIsLoading(true);\n try {\n // Trigger lazy loading by importing the modules\n await import('../chat/ChatContainer.js');\n setComponentsLoaded(true);\n } catch (error) {\n console.error('Failed to preload components:', error);\n } finally {\n setIsLoading(false);\n }\n }, [componentsLoaded]);\n\n // Handle drawer open\n const handleOpen = React.useCallback(async () => {\n if (!componentsLoaded && !isLoading) {\n await preloadComponents();\n }\n setIsOpen(true);\n onOpen?.();\n }, [componentsLoaded, isLoading, preloadComponents, onOpen]);\n\n // Handle drawer close\n const handleClose = React.useCallback(() => {\n setIsOpen(false);\n onClose?.();\n }, [onClose]);\n\n // Handle new session\n const handleNewSession = React.useCallback(async () => {\n setInput('');\n await resetChat();\n }, [resetChat]);\n\n // Handle keyboard shortcut\n React.useEffect(() => {\n if (!enableHotkey || !hotkey) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n const keys = hotkey.toLowerCase().split('+');\n const ctrl = keys.includes('ctrl') || keys.includes('control');\n const cmd = keys.includes('cmd') || keys.includes('command') || keys.includes('meta');\n const shift = keys.includes('shift');\n const alt = keys.includes('alt');\n const key = keys[keys.length - 1];\n\n const ctrlPressed = ctrl && (e.ctrlKey || e.metaKey);\n const cmdPressed = cmd && (e.metaKey || e.ctrlKey);\n const shiftPressed = !shift || e.shiftKey;\n const altPressed = !alt || e.altKey;\n\n if ((ctrlPressed || cmdPressed) && shiftPressed && altPressed && e.key.toLowerCase() === key) {\n e.preventDefault();\n setIsOpen((prev) => !prev);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [enableHotkey, hotkey]);\n\n return (\n <div className={`ask-ai ${className || ''} ${theme === 'dark' ? 'dark' : ''}`} style={style}>\n {/* Trigger Button - Custom or Default */}\n {children && React.isValidElement(children) ? (\n React.cloneElement(children, {\n ...children.props,\n onClick: (e: React.MouseEvent) => {\n // Call existing onClick if present\n const existingOnClick = children.props?.onClick;\n if (existingOnClick) {\n existingOnClick(e);\n }\n // Then call our handleOpen\n handleOpen();\n },\n })\n ) : (\n <Trigger\n onClick={handleOpen}\n text={texts?.triggerButtonText}\n ariaLabel={texts?.triggerButtonAriaLabel}\n />\n )}\n\n {/* Drawer with Chat */}\n <Drawer\n isOpen={isOpen}\n onClose={handleClose}\n onNewSession={handleNewSession}\n hasMessages={messages.length > 0}\n position={drawerPosition}\n width={drawerWidth}\n expandedWidth={drawerExpandedWidth}\n title={texts?.drawerTitle}\n closeAriaLabel={texts?.drawerCloseAriaLabel}\n newSessionAriaLabel={texts?.drawerNewSessionAriaLabel}\n theme={theme}\n >\n {/* Chat - Lazy loaded with Suspense */}\n {(isOpen || componentsLoaded) && (\n <React.Suspense fallback={\n <Loader2 className={styles.spinning} />\n }>\n <ChatContainer\n texts={texts}\n exampleQuestions={exampleQuestions}\n onMessage={onMessage}\n onError={onError}\n messages={messages}\n isStreaming={isStreaming}\n error={error}\n sendMessage={sendMessage}\n input={input}\n setInput={setInput}\n />\n </React.Suspense>\n )}\n </Drawer>\n </div>\n );\n}\n","import * as React from 'react';\nimport ReactMarkdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport rehypeHighlight from 'rehype-highlight';\nimport { common } from 'lowlight';\nimport type { WidgetTexts, Message } from '../../core/types/index.js';\nimport styles from './ChatContainer.module.css';\nimport { ArrowUp, Copy, Check } from 'lucide-react';\n\ninterface ChatContainerProps {\n texts?: WidgetTexts;\n exampleQuestions?: string[];\n onMessage?: (message: any) => void;\n onError?: (error: Error) => void;\n // Lifted state from parent\n messages: Message[];\n isStreaming: boolean;\n error: Error | null;\n sendMessage: (text: string) => Promise<void>;\n input: string;\n setInput: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport function ChatContainer({\n texts,\n exampleQuestions,\n onMessage,\n onError,\n messages,\n isStreaming,\n error,\n sendMessage,\n input,\n setInput,\n}: ChatContainerProps) {\n const textareaRef = React.useRef<HTMLTextAreaElement>(null);\n const messagesAreaRef = React.useRef<HTMLDivElement>(null);\n const shouldAutoScrollRef = React.useRef(true); // Track if auto-scroll is enabled\n\n // Check if user is at the bottom of the messages area\n const isAtBottom = React.useCallback(() => {\n const messagesArea = messagesAreaRef.current;\n if (!messagesArea) return true;\n\n const threshold = 50; // pixels from bottom to consider \"at bottom\"\n const scrollBottom = messagesArea.scrollHeight - messagesArea.scrollTop - messagesArea.clientHeight;\n return scrollBottom < threshold;\n }, []);\n\n // Scroll to bottom of messages area\n const scrollToBottom = React.useCallback(() => {\n const messagesArea = messagesAreaRef.current;\n if (messagesArea) {\n messagesArea.scrollTop = messagesArea.scrollHeight;\n }\n }, []);\n\n // Handle user scroll events\n const handleScroll = React.useCallback(() => {\n const atBottom = isAtBottom();\n shouldAutoScrollRef.current = atBottom;\n }, [isAtBottom]);\n\n // Auto-scroll when messages change (if enabled)\n React.useEffect(() => {\n if (shouldAutoScrollRef.current) {\n scrollToBottom();\n }\n }, [messages, scrollToBottom]);\n\n // Auto-resize textarea based on content\n const adjustTextareaHeight = React.useCallback(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n textarea.style.height = 'auto';\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, []);\n\n // Call onError callback when error occurs\n React.useEffect(() => {\n if (error && onError) {\n onError(error);\n }\n }, [error, onError]);\n\n // Call onMessage callback when new message arrives\n React.useEffect(() => {\n if (messages.length > 0 && onMessage) {\n onMessage(messages[messages.length - 1]);\n }\n }, [messages, onMessage]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n const inputValue = input.trim();\n if (!inputValue || isStreaming) return;\n\n // Enable auto-scroll for new user message\n shouldAutoScrollRef.current = true;\n\n setInput('');\n await sendMessage(inputValue);\n // Reset textarea height after submission\n setTimeout(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n }\n }, 0);\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInput(e.target.value);\n adjustTextareaHeight();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n // Submit on Enter (without Shift)\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n if (input.trim() && !isStreaming) {\n handleSubmit(e as any);\n }\n }\n // Allow Shift+Enter for new line (default textarea behavior)\n };\n\n const handleExampleClick = async (question: string) => {\n if (isStreaming) return;\n // Enable auto-scroll for new user message\n shouldAutoScrollRef.current = true;\n await sendMessage(question);\n };\n\n const inputPlaceholder = texts?.inputPlaceholder || 'Ask a question...';\n const welcomeMessage = texts?.welcomeMessage || 'Hi! How can I help you today?';\n const exampleQuestionsTitle = texts?.exampleQuestionsTitle || 'Example questions:';\n\n // Custom code block component with copy button\n const CodeBlock = ({ children, className, ...props }: any) => {\n const [copied, setCopied] = React.useState(false);\n const match = /language-(\\w+)/.exec(className || '');\n const isCodeBlock = match;\n\n const handleCopy = async () => {\n // Recursively extract text content from React elements\n const getTextContent = (node: any): string => {\n if (typeof node === 'string') return node;\n if (typeof node === 'number') return String(node);\n if (Array.isArray(node)) return node.map(getTextContent).join('');\n if (node?.props?.children) return getTextContent(node.props.children);\n return '';\n };\n\n const code = getTextContent(children).replace(/\\n$/, '');\n try {\n await navigator.clipboard.writeText(code);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (err) {\n console.error('Failed to copy:', err);\n }\n };\n\n if (isCodeBlock) {\n return (\n <div className={styles.codeBlockWrapper}>\n <button\n onClick={handleCopy}\n className={styles.copyButton}\n aria-label=\"Copy code\"\n >\n {copied ? <Check size={14} /> : <Copy size={14} />}\n </button>\n <code className={className} {...props}>\n {children}\n </code>\n </div>\n );\n }\n\n return <code className={className} {...props}>{children}</code>;\n };\n\n // Helper function to format tool name\n const getToolDisplayName = (toolName: string) => {\n if (toolName.toLowerCase() === 'read') {\n return 'Reading docs';\n }\n if (toolName.toLowerCase() === 'task') {\n return 'Exploring docs';\n }\n return 'Searching docs';\n };\n\n return (\n <div className={styles.container}>\n {/* Messages Area */}\n <div\n ref={messagesAreaRef}\n onScroll={handleScroll}\n className={styles.messagesArea}\n >\n {messages.length === 0 ? (\n // Welcome Screen\n <div className={styles.welcomeScreen}>\n <p className={styles.welcomeMessage}>\n {welcomeMessage}\n </p>\n\n {exampleQuestions && exampleQuestions.length > 0 && (\n <div className={styles.exampleQuestionsContainer}>\n <p className={styles.exampleQuestionsTitle}>\n {exampleQuestionsTitle}\n </p>\n {exampleQuestions.map((question, index) => (\n <button\n key={index}\n onClick={() => handleExampleClick(question)}\n className={styles.exampleButton}\n >\n {question}\n </button>\n ))}\n </div>\n )}\n </div>\n ) : (\n // Messages\n <>\n {messages.map((message) => (\n <div\n key={message.id}\n className={`${styles.messageWrapper} ${styles[message.role]}`}\n >\n <div className={`${styles.message} ${styles[message.role]}`}>\n {message.role === 'assistant' ? (\n <div className={styles.markdown}>\n {/* Display tool calls if present */}\n {message.toolCalls && message.toolCalls.length > 0 && (\n <div className={styles.toolCallsContainer}>\n {message.toolCalls.map((toolCall) => (\n <span\n key={toolCall.callID}\n className={`${styles.toolCall} ${styles[`tool-${toolCall.status}`]}`}\n >\n {getToolDisplayName(toolCall.tool)}\n {(toolCall.status === 'completed' || toolCall.status === 'error') ? '' : '...'}\n </span>\n ))}\n </div>\n )}\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[[rehypeHighlight, {\n languages: common,\n prefix: 'hljs-'\n }]]}\n components={{\n code: CodeBlock\n }}\n >\n {message.content}\n </ReactMarkdown>\n {message.isStreaming && (\n <span className={styles.cursor} />\n )}\n </div>\n ) : (\n <div className={styles.messageText}>\n {message.content}\n </div>\n )}\n </div>\n </div>\n ))}\n </>\n )}\n\n {error && (\n <div className={styles.error}>\n {error.message}\n </div>\n )}\n </div>\n\n {/* Input Area */}\n <form onSubmit={handleSubmit} className={styles.inputForm}>\n <div className={styles.inputWrapper}>\n <textarea\n ref={textareaRef}\n value={input}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n placeholder={inputPlaceholder}\n className={styles.input}\n rows={1}\n />\n <button\n type=\"submit\"\n disabled={!input.trim() || isStreaming}\n className={styles.submitButton}\n >\n <ArrowUp />\n </button>\n </div>\n </form>\n </div>\n );\n}\n"],"names":["useState","useCallback","useEffect","useRef","React","Slot","styles","_jsx","_jsxs","Loader2","Sparkles","DialogPrimitive","EraserIcon","Minimize2","Maximize2","X","ChatContainer","Check","Copy","_Fragment","common","ArrowUp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;AAGG;MACU,SAAS,CAAA;IAIpB,WAAA,CAAY,OAAe,EAAE,SAAkB,EAAA;AAHvC,QAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,SAAA,EAAA;;;;;AAAgB,SAAA,CAAA;AAChB,QAAA,MAAA,CAAA,cAAA,CAAA,IAAA,EAAA,WAAA,EAAA;;;;;AAAmB,SAAA,CAAA;AAGzB,QAAA,IAAI,CAAC,OAAO,GAAG,OAA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