@topconsultnpm/sdkui-react 6.22.0-dev3.9 → 6.22.0-dev4.3

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.
Files changed (96) hide show
  1. package/lib/components/base/TMAlert.js +6 -8
  2. package/lib/components/base/TMAreaManager.js +53 -55
  3. package/lib/components/base/TMButton.js +4 -2
  4. package/lib/components/base/TMCustomButton.js +40 -48
  5. package/lib/components/base/TMDataGrid.js +219 -219
  6. package/lib/components/base/TMPanel.js +173 -170
  7. package/lib/components/base/TMSpinner.d.ts +2 -1
  8. package/lib/components/base/TMSpinner.js +9 -7
  9. package/lib/components/base/TMTabControl.d.ts +5 -0
  10. package/lib/components/base/TMTabControl.js +18 -7
  11. package/lib/components/base/TMTreeView.js +20 -0
  12. package/lib/components/base/TMWaitPanel.js +1 -1
  13. package/lib/components/base/waitPanel/TMWaitPanelConfirm.d.ts +12 -0
  14. package/lib/components/base/waitPanel/TMWaitPanelConfirm.js +185 -0
  15. package/lib/components/base/waitPanel/TMWaitPanelManager.d.ts +169 -0
  16. package/lib/components/base/waitPanel/TMWaitPanelManager.js +320 -0
  17. package/lib/components/base/waitPanel/TMWaitPanelView.d.ts +53 -0
  18. package/lib/components/base/waitPanel/TMWaitPanelView.js +274 -0
  19. package/lib/components/base/waitPanel/index.d.ts +1 -0
  20. package/lib/components/base/waitPanel/index.js +1 -0
  21. package/lib/components/choosers/TMPathChooser.js +17 -34
  22. package/lib/components/editors/TMTextBox.d.ts +4 -0
  23. package/lib/components/editors/TMTextBox.js +99 -11
  24. package/lib/components/features/archive/TMArchive.js +7 -2
  25. package/lib/components/features/assistant/TMHelpOnLineChat.d.ts +29 -0
  26. package/lib/components/features/assistant/TMHelpOnLineChat.js +1384 -0
  27. package/lib/components/features/assistant/TMToppyDraggableHelpCenter.js +2 -2
  28. package/lib/components/features/assistant/dataset/Designer-Suggested-Questions.json +102 -0
  29. package/lib/components/features/assistant/dataset/Login-Suggested-Questions.json +32 -0
  30. package/lib/components/features/assistant/dataset/Surfer-Suggested-Questions.json +102 -0
  31. package/lib/components/features/documents/TMBatchUpdateForm.js +3 -4
  32. package/lib/components/features/documents/TMCopyToFolderForm.js +53 -84
  33. package/lib/components/features/documents/TMDcmtForm.js +50 -61
  34. package/lib/components/features/documents/TMDcmtIcon.d.ts +1 -3
  35. package/lib/components/features/documents/TMDcmtIcon.js +3 -5
  36. package/lib/components/features/documents/TMDcmtPreview.js +5 -3
  37. package/lib/components/features/documents/TMDcmtTasks.js +2 -9
  38. package/lib/components/features/documents/TMFileUploader.js +26 -26
  39. package/lib/components/features/documents/TMMasterDetailDcmts.d.ts +2 -0
  40. package/lib/components/features/documents/TMMasterDetailDcmts.js +53 -148
  41. package/lib/components/features/documents/TMMasterInfoFields.js +3 -2
  42. package/lib/components/features/documents/TMMergeToPdfForm.js +49 -54
  43. package/lib/components/features/documents/TMMultiMasterDetailDcmtsForm.js +14 -15
  44. package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.d.ts +1 -1
  45. package/lib/components/features/documents/TMMultiMasterDetailDcmtsUtils.js +3 -3
  46. package/lib/components/features/documents/TMRelationViewer.d.ts +13 -14
  47. package/lib/components/features/documents/TMRelationViewer.js +206 -143
  48. package/lib/components/features/documents/relationTreeState.d.ts +32 -0
  49. package/lib/components/features/documents/relationTreeState.js +89 -0
  50. package/lib/components/features/search/TMSearch.js +3 -4
  51. package/lib/components/features/search/TMSearchQueryPanel.js +0 -4
  52. package/lib/components/features/search/TMSearchResult.d.ts +5 -0
  53. package/lib/components/features/search/TMSearchResult.js +39 -19
  54. package/lib/components/features/search/TMTreeSelector.js +23 -27
  55. package/lib/components/features/search/TMViewHistoryDcmt.js +14 -25
  56. package/lib/components/features/tasks/TMTasksView.js +91 -90
  57. package/lib/components/features/wg/TMWGsCopyMoveForm.js +91 -91
  58. package/lib/components/forms/TMResultDialog.js +1 -1
  59. package/lib/components/grids/TMBlogsPost.js +92 -96
  60. package/lib/components/index.d.ts +5 -1
  61. package/lib/components/index.js +4 -1
  62. package/lib/components/layout/panelManager/TMPanelManagerContainer.js +16 -15
  63. package/lib/components/layout/panelManager/TMPanelManagerContext.d.ts +1 -0
  64. package/lib/components/layout/panelManager/TMPanelManagerContext.js +5 -1
  65. package/lib/components/layout/panelManager/TMPanelManagerLoader.d.ts +6 -0
  66. package/lib/components/layout/panelManager/TMPanelManagerLoader.js +18 -0
  67. package/lib/components/layout/panelManager/TMPanelManagerToolbar.js +4 -8
  68. package/lib/components/layout/panelManager/TMPanelManagerWithPersistenceProvider.d.ts +1 -1
  69. package/lib/components/layout/panelManager/TMPanelManagerWithPersistenceProvider.js +2 -1
  70. package/lib/components/pages/TMPage.js +29 -31
  71. package/lib/components/query/TMQueryEditor.d.ts +3 -0
  72. package/lib/components/query/TMQueryEditor.js +2 -1
  73. package/lib/components/sidebar/TMHeader.d.ts +1 -0
  74. package/lib/components/sidebar/TMHeader.js +2 -2
  75. package/lib/helper/Enum_Localizator.js +1 -0
  76. package/lib/helper/SDKUI_Globals.d.ts +3 -0
  77. package/lib/helper/SDKUI_Globals.js +3 -0
  78. package/lib/helper/SDKUI_Localizator.d.ts +21 -0
  79. package/lib/helper/SDKUI_Localizator.js +210 -0
  80. package/lib/helper/ZipManager.d.ts +1 -1
  81. package/lib/helper/ZipManager.js +2 -1
  82. package/lib/helper/dcmtsHelper.d.ts +2 -0
  83. package/lib/helper/dcmtsHelper.js +3 -1
  84. package/lib/hooks/useCheckInOutOperations.d.ts +0 -6
  85. package/lib/hooks/useCheckInOutOperations.js +14 -34
  86. package/lib/hooks/useDcmtOperations.d.ts +3 -19
  87. package/lib/hooks/useDcmtOperations.js +160 -222
  88. package/lib/hooks/useDocumentOperations.d.ts +1 -0
  89. package/lib/hooks/useDocumentOperations.js +14 -25
  90. package/lib/hooks/useMultiMasterDetailDcmts.d.ts +0 -15
  91. package/lib/hooks/useMultiMasterDetailDcmts.js +65 -67
  92. package/lib/hooks/usePreventFileDrop.js +9 -0
  93. package/lib/hooks/useWorkflowApprove.js +33 -17
  94. package/lib/services/caseflow/CaseFlowService.d.ts +36 -6
  95. package/lib/services/caseflow/CaseFlowService.js +55 -14
  96. package/package.json +69 -69
@@ -0,0 +1,1384 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+ import styled, { keyframes } from 'styled-components';
4
+ import { locale as dxLocale } from 'devextreme/localization';
5
+ import { AppModules, CultureIDs, HolAskDescriptor, SDK_Globals, TopMediaServer } from '@topconsultnpm/sdk-ts';
6
+ import TMTooltip from '../../base/TMTooltip';
7
+ import { TMColors } from '../../../utils/theme';
8
+ import { SDKUI_Localizator } from '../../../helper';
9
+ import ToppyImage from '../../../assets/Toppy-help-center.png';
10
+ import LoginSuggestedQuestions from './dataset/Login-Suggested-Questions.json';
11
+ import SurferSuggestedQuestions from './dataset/Surfer-Suggested-Questions.json';
12
+ import DesignerSuggestedQuestions from './dataset/Designer-Suggested-Questions.json';
13
+ const generateGUID = () => {
14
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/g, (c) => {
15
+ const r = Math.trunc(Math.random() * 16);
16
+ const v = c === 'x' ? r : (r & 0x3 | 0x8);
17
+ return v.toString(16);
18
+ });
19
+ };
20
+ const PANEL_DEFAULT_WIDTH = 600;
21
+ const PANEL_MIN_WIDTH = 340;
22
+ const PANEL_MAX_WIDTH = 900;
23
+ const SUGGESTIONS_COUNT = 4;
24
+ const FEEDBACK_MAX_LENGTH = 200;
25
+ const NO_ANSWER_TEXT = 'Nessuna risposta ricevuta.';
26
+ const ERROR_TEXT = 'Si è verificato un errore, riprova più tardi.';
27
+ const FEEDBACK_TAGS = {
28
+ like: ['Aggiornata', 'Accurata', 'Utile', 'Pertinente', 'Fonti affidabili', 'Altro'],
29
+ dislike: ['Non aggiornata', 'Imprecisa', 'Troppo lunga', 'Troppo corta', 'Fonti non affidabili', 'Inappropriata', 'Altro'],
30
+ };
31
+ const FEEDBACK_TITLES = {
32
+ like: 'Cosa ti è piaciuto di questa risposta?',
33
+ dislike: 'Cosa non ha funzionato in questa risposta?',
34
+ };
35
+ const copyToClipboard = async (text) => {
36
+ try {
37
+ if (globalThis.isSecureContext && navigator.clipboard?.writeText) {
38
+ await navigator.clipboard.writeText(text);
39
+ return true;
40
+ }
41
+ const textarea = document.createElement('textarea');
42
+ textarea.value = text;
43
+ textarea.setAttribute('readonly', '');
44
+ textarea.style.position = 'fixed';
45
+ textarea.style.opacity = '0';
46
+ document.body.appendChild(textarea);
47
+ textarea.select();
48
+ const copied = document.execCommand('copy');
49
+ document.body.removeChild(textarea);
50
+ return copied;
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ };
56
+ const getDefaultSuggestedQuestions = (isLogged) => {
57
+ if (!isLogged)
58
+ return LoginSuggestedQuestions;
59
+ switch (SDK_Globals.appModule) {
60
+ case AppModules.SURFER: return SurferSuggestedQuestions;
61
+ case AppModules.DESIGNER: return DesignerSuggestedQuestions;
62
+ default: return [];
63
+ }
64
+ };
65
+ const pickRandom = (items, count) => {
66
+ const pool = [...items];
67
+ for (let i = pool.length - 1; i > 0; i--) {
68
+ const j = Math.floor(Math.random() * (i + 1));
69
+ [pool[i], pool[j]] = [pool[j], pool[i]];
70
+ }
71
+ return pool.slice(0, count);
72
+ };
73
+ const getSafeSession = () => {
74
+ try {
75
+ return SDK_Globals.tmSession;
76
+ }
77
+ catch {
78
+ return undefined;
79
+ }
80
+ };
81
+ const DX_LOCALE_TO_CULTURE_ID = {
82
+ de: CultureIDs.De_DE,
83
+ en: CultureIDs.En_US,
84
+ es: CultureIDs.Es_ES,
85
+ fr: CultureIDs.Fr_FR,
86
+ it: CultureIDs.It_IT,
87
+ pt: CultureIDs.Pt_PT,
88
+ };
89
+ const getCurrentCultureId = () => DX_LOCALE_TO_CULTURE_ID[dxLocale().split('-')[0]] ?? getSafeSession()?.SessionDescr?.cultureID;
90
+ let preLoginSession;
91
+ let preLoginSessionUrl;
92
+ const getPreLoginSession = (endpointUrl) => {
93
+ if (!endpointUrl) {
94
+ return undefined;
95
+ }
96
+ if (!preLoginSession || preLoginSessionUrl !== endpointUrl) {
97
+ const tmServer = new TopMediaServer(endpointUrl);
98
+ preLoginSession = tmServer.NewSession();
99
+ preLoginSessionUrl = endpointUrl;
100
+ }
101
+ return preLoginSession;
102
+ };
103
+ const TMHelpOnLineChat = ({ isOpen, showChatButton, isLogged, messages, conversationId, isThinking, endpointUrl, onClose, onToggle, onNewConversation, onAddMessage, onSetThinking, onSetConversationId, suggestedQuestions }) => {
104
+ const [width, setWidth] = useState(PANEL_DEFAULT_WIDTH);
105
+ const showFab = !isLogged && showChatButton && !isOpen;
106
+ const questions = suggestedQuestions ?? getDefaultSuggestedQuestions(isLogged);
107
+ const [submittedRatings, setSubmittedRatings] = useState({});
108
+ const onFeedbackSubmitted = useCallback((messageId, rating) => {
109
+ setSubmittedRatings(prev => ({ ...prev, [messageId]: rating }));
110
+ }, []);
111
+ return (_jsxs(_Fragment, { children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(Overlay, { onClick: onClose }), _jsx(ChatPanel, { width: width, onWidthChange: setWidth, messages: messages, conversationId: conversationId, isThinking: isThinking, endpointUrl: endpointUrl, onClose: onClose, onNewConversation: onNewConversation, onAddMessage: onAddMessage, onSetThinking: onSetThinking, onSetConversationId: onSetConversationId, suggestedQuestions: questions, isLogged: isLogged, submittedRatings: submittedRatings, onFeedbackSubmitted: onFeedbackSubmitted })] })), showFab && (_jsx(Fab, { onClick: onToggle, title: "Chiedi a Toppy", "aria-label": "Chiedi a Toppy", children: _jsx(FabAvatar, { src: ToppyImage, alt: "Toppy" }) }))] }));
112
+ };
113
+ export default TMHelpOnLineChat;
114
+ //#region Header button
115
+ export const TMToppyHeaderButton = ({ showChatButton, onToggle }) => {
116
+ if (!showChatButton)
117
+ return null;
118
+ return (_jsx(TMTooltip, { content: "Chiedi a Toppy", children: _jsxs(ToppyHeaderButton, { onClick: onToggle, title: "Chiedi a Toppy", children: [_jsx(ToppyHeaderAvatar, { src: ToppyImage, alt: "Toppy" }), _jsx(ToppyHeaderText, { children: "Chiedi a Toppy" })] }) }));
119
+ };
120
+ const ChatPanel = ({ width, onWidthChange, messages, conversationId, isThinking, endpointUrl, onClose, onNewConversation, onAddMessage, onSetThinking, onSetConversationId, suggestedQuestions, isLogged, submittedRatings, onFeedbackSubmitted }) => {
121
+ const [chatInput, setChatInput] = useState('');
122
+ const [suggestions, setSuggestions] = useState(() => pickRandom(suggestedQuestions, SUGGESTIONS_COUNT));
123
+ const [hoveredSuggestion, setHoveredSuggestion] = useState(undefined);
124
+ const prevMessagesCountRef = useRef(messages.length);
125
+ const inputRef = useRef(null);
126
+ const messagesEndRef = useRef(null);
127
+ const onCloseRef = useRef(onClose);
128
+ onCloseRef.current = onClose;
129
+ const userName = getSafeSession()?.SessionDescr?.userName ?? '';
130
+ useEffect(() => {
131
+ messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
132
+ }, [messages, isThinking]);
133
+ useEffect(() => {
134
+ inputRef.current?.focus();
135
+ }, []);
136
+ useEffect(() => {
137
+ if (messages.length === 0 && prevMessagesCountRef.current > 0) {
138
+ setSuggestions(pickRandom(suggestedQuestions, SUGGESTIONS_COUNT));
139
+ }
140
+ prevMessagesCountRef.current = messages.length;
141
+ }, [messages.length, suggestedQuestions]);
142
+ useEffect(() => {
143
+ const onKeyDown = (e) => {
144
+ if (e.key === 'Escape')
145
+ onCloseRef.current();
146
+ };
147
+ window.addEventListener('keydown', onKeyDown);
148
+ return () => window.removeEventListener('keydown', onKeyDown);
149
+ }, []);
150
+ const onResizeStart = useCallback((e) => {
151
+ e.preventDefault();
152
+ const startX = e.clientX;
153
+ const startWidth = width;
154
+ const onMove = (ev) => {
155
+ const next = startWidth + (startX - ev.clientX);
156
+ const max = Math.min(PANEL_MAX_WIDTH, globalThis.innerWidth - 40);
157
+ onWidthChange(Math.min(Math.max(next, PANEL_MIN_WIDTH), max));
158
+ };
159
+ const onUp = () => {
160
+ document.body.style.userSelect = '';
161
+ document.body.style.cursor = '';
162
+ globalThis.removeEventListener('mousemove', onMove);
163
+ globalThis.removeEventListener('mouseup', onUp);
164
+ };
165
+ document.body.style.userSelect = 'none';
166
+ document.body.style.cursor = 'col-resize';
167
+ globalThis.addEventListener('mousemove', onMove);
168
+ globalThis.addEventListener('mouseup', onUp);
169
+ }, [width, onWidthChange]);
170
+ const ask = useCallback(async (text) => {
171
+ const question = text.trim();
172
+ if (question.length < 2 || isThinking) {
173
+ return;
174
+ }
175
+ onAddMessage({ id: generateGUID(), text: question, isUser: true });
176
+ setChatInput('');
177
+ onSetThinking(true);
178
+ let convId = conversationId;
179
+ if (!convId) {
180
+ convId = generateGUID();
181
+ onSetConversationId(convId);
182
+ }
183
+ try {
184
+ const globalSession = getSafeSession();
185
+ const preSession = globalSession ? undefined : getPreLoginSession(endpointUrl);
186
+ const session = globalSession ?? preSession;
187
+ let answer = '';
188
+ if (session) {
189
+ const hol_d = new HolAskDescriptor();
190
+ hol_d.question = question;
191
+ hol_d.conversationId = convId;
192
+ const raw = await session.HelpOnLineAskAsync(hol_d);
193
+ const parsed = typeof raw === 'string' ? safeJsonParse(raw) : raw;
194
+ if (parsed && typeof parsed === 'object') {
195
+ answer = parsed.answer ?? '';
196
+ }
197
+ else if (typeof raw === 'string') {
198
+ answer = raw;
199
+ }
200
+ }
201
+ else {
202
+ console.error('[HOL] NO SESSION -> nothing called. endpointUrl =', endpointUrl);
203
+ }
204
+ onAddMessage({ id: generateGUID(), text: answer || NO_ANSWER_TEXT, isUser: false });
205
+ }
206
+ catch (error) {
207
+ onAddMessage({ id: generateGUID(), text: ERROR_TEXT, isUser: false });
208
+ console.error('[HOL]', error);
209
+ }
210
+ finally {
211
+ onSetThinking(false);
212
+ }
213
+ }, [conversationId, isThinking, endpointUrl, onAddMessage, onSetThinking, onSetConversationId]);
214
+ const askHandler = useCallback(() => ask(chatInput), [ask, chatInput]);
215
+ const onSuggestionClick = (question) => {
216
+ setHoveredSuggestion(undefined);
217
+ ask(question);
218
+ };
219
+ const onFeedbackSubmit = (index, rating, tags, feedback) => {
220
+ const answer = messages[index];
221
+ const question = messages.slice(0, index).reverse().find(m => m.isUser)?.text ?? '';
222
+ const session = getSafeSession();
223
+ console.log('[HOL] feedback', {
224
+ userName: session?.SessionDescr?.userName ?? '',
225
+ app: isLogged ? SDK_Globals.appModule : 'LOGIN',
226
+ cultureId: getCurrentCultureId(),
227
+ question,
228
+ answer: answer.text,
229
+ rating,
230
+ tags,
231
+ feedback,
232
+ conversationId,
233
+ timestamp: new Date().toISOString(),
234
+ });
235
+ onFeedbackSubmitted(answer.id, rating);
236
+ };
237
+ const showSuggestions = messages.length === 0 && !isThinking && suggestions.length > 0;
238
+ return (_jsxs(PanelContainer, { $width: width, children: [_jsx(ResizeHandle, { onMouseDown: onResizeStart }), _jsxs(ChatHeader, { children: [_jsxs(HeaderLeft, { children: [_jsx(ToppyAvatar, { src: ToppyImage, alt: "Toppy" }), _jsxs(HeaderText, { children: [_jsxs(HeaderGreeting, { children: ["Ciao ", userName] }), _jsx(HeaderQuestion, { children: "Come posso aiutarti?" })] })] }), _jsxs(HeaderRight, { children: [_jsx(TMTooltip, { content: "Nuova conversazione", children: _jsx(HeaderButton, { onClick: onNewConversation, disabled: !conversationId && messages.length === 0, title: "Nuova conversazione", children: _jsx(IconNewChat, { color: "white", fontSize: 18 }) }) }), _jsx(TMTooltip, { content: "Chiudi", children: _jsx(HeaderButton, { onClick: onClose, title: "Chiudi", children: _jsx(IconClose, { fontSize: 18 }) }) })] })] }), _jsxs(ChatBody, { children: [messages.length === 0 ? (_jsxs(WelcomeMessage, { children: [_jsx(WelcomeIcon, { children: "\uD83D\uDCA1" }), _jsxs(WelcomeText, { children: ["Ciao! Sono ", _jsx("strong", { children: "Toppy" }), ", il tuo assistente.", _jsx("br", {}), "Fai una domanda e ti aiuter\u00F2 a trovare la risposta."] })] })) : (messages.map((msg, index) => (_jsxs(MessageBubble, { $isUser: msg.isUser, children: [!msg.isUser && _jsx(BotAvatar, { src: ToppyImage, alt: "Toppy" }), msg.isUser ? (_jsxs(_Fragment, { children: [_jsx(QuestionCopy, { children: _jsx(CopyButton, { text: msg.text }) }), _jsx(MessageContent, { $isUser: true, children: msg.text })] })) : (_jsxs(BotMessageColumn, { children: [_jsx(BotMessageContent, { $isUser: false, children: _jsx(MarkdownContent, { children: renderMarkdown(msg.text) }) }), msg.text !== NO_ANSWER_TEXT && msg.text !== ERROR_TEXT && (_jsx(MessageFeedback, { answer: msg.text, submittedRating: submittedRatings[msg.id], onSubmit: (rating, tags, feedback) => onFeedbackSubmit(index, rating, tags, feedback) }))] }))] }, msg.id)))), isThinking && (_jsxs(MessageBubble, { $isUser: false, children: [_jsx(BotAvatar, { src: ToppyImage, alt: "Toppy" }), _jsx(ThinkingStatus, {}, messages.length)] })), _jsx("div", { ref: messagesEndRef })] }), _jsxs(ChatFooter, { children: [showSuggestions && (_jsxs(SuggestionsSection, { children: [_jsxs(SuggestionsTitle, { children: [_jsx(IconSparkle, { fontSize: 14 }), _jsx("span", { children: "Domande suggerite" })] }), _jsx(SuggestionsGrid, { children: suggestions.map((question, index) => (_jsxs(SuggestionCard, { type: "button", $index: index, title: question, onClick: () => onSuggestionClick(question), onMouseEnter: () => setHoveredSuggestion(question), onMouseLeave: () => setHoveredSuggestion(undefined), onFocus: () => setHoveredSuggestion(question), onBlur: () => setHoveredSuggestion(undefined), children: [_jsx(SuggestionIcon, { children: _jsx(IconQuestion, { fontSize: 16 }) }), _jsx(SuggestionText, { children: question }), _jsx(SuggestionArrow, { children: _jsx(IconArrowForward, { fontSize: 16 }) })] }, question))) })] })), _jsx(TMChatInput, { inputRef: inputRef, value: chatInput, onChange: setChatInput, onSend: askHandler, placeholder: hoveredSuggestion ?? 'Scrivi la tua domanda...', tooltip: "Invia", disabled: isThinking }), _jsx(FooterHint, { children: SDKUI_Localizator.HelpOnLineShiftEnterHint })] })] }));
239
+ };
240
+ const TMChatInput = ({ value, onChange, onSend, placeholder = 'Scrivi la tua domanda...', disabled = false, inputRef, tooltip = 'Ricerca AI' }) => {
241
+ const isDisabled = disabled || value.length < 2;
242
+ return (_jsxs(ChatInputWrapper, { children: [_jsx(ChatInputTextarea, { ref: inputRef, placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), onKeyDown: (e) => {
243
+ if (e.key !== 'Enter')
244
+ return;
245
+ e.stopPropagation();
246
+ if (!e.shiftKey && !e.nativeEvent.isComposing) {
247
+ e.preventDefault();
248
+ if (!isDisabled)
249
+ onSend();
250
+ }
251
+ } }), _jsx(TMTooltip, { content: tooltip, children: _jsx(InlineSendButton, { $disabled: isDisabled, disabled: isDisabled, onClick: onSend, title: tooltip, children: _jsx(IconSendFilled, { fontSize: 20 }) }) })] }));
252
+ };
253
+ const CopyButton = ({ text }) => {
254
+ const [copied, setCopied] = useState(false);
255
+ const copiedTimerRef = useRef();
256
+ useEffect(() => () => clearTimeout(copiedTimerRef.current), []);
257
+ const onCopyClick = async () => {
258
+ if (!(await copyToClipboard(text)))
259
+ return;
260
+ setCopied(true);
261
+ clearTimeout(copiedTimerRef.current);
262
+ copiedTimerRef.current = setTimeout(() => setCopied(false), 2000);
263
+ };
264
+ return (_jsx(TMTooltip, { content: copied ? 'Copiato' : 'Copia', children: _jsx(FeedbackActionButton, { type: "button", $active: false, $locked: false, $success: copied, "aria-label": "Copia", onClick: onCopyClick, children: copied ? _jsx(IconCheck, { fontSize: 16 }) : _jsx(IconCopy, { fontSize: 16 }) }) }));
265
+ };
266
+ const MessageFeedback = ({ answer, submittedRating, onSubmit }) => {
267
+ const [draftRating, setDraftRating] = useState(undefined);
268
+ const [selectedTags, setSelectedTags] = useState([]);
269
+ const [feedback, setFeedback] = useState('');
270
+ const panelRef = useRef(null);
271
+ useEffect(() => {
272
+ if (draftRating)
273
+ panelRef.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
274
+ }, [draftRating]);
275
+ const isSubmitted = submittedRating !== undefined;
276
+ const activeRating = submittedRating ?? draftRating;
277
+ const canSubmit = draftRating === 'like' || selectedTags.length > 0 || feedback.trim().length > 0;
278
+ const resetDraft = () => {
279
+ setDraftRating(undefined);
280
+ setSelectedTags([]);
281
+ setFeedback('');
282
+ };
283
+ const onRatingClick = (rating) => {
284
+ if (isSubmitted)
285
+ return;
286
+ if (draftRating === rating) {
287
+ resetDraft();
288
+ return;
289
+ }
290
+ setDraftRating(rating);
291
+ setSelectedTags([]);
292
+ };
293
+ const onTagClick = (tag) => {
294
+ setSelectedTags(prev => prev.includes(tag) ? prev.filter(t => t !== tag) : [...prev, tag]);
295
+ };
296
+ const onSubmitClick = () => {
297
+ if (!draftRating || !canSubmit)
298
+ return;
299
+ onSubmit(draftRating, selectedTags, feedback.trim());
300
+ resetDraft();
301
+ };
302
+ return (_jsxs(FeedbackContainer, { children: [_jsxs(FeedbackActions, { children: [_jsx(CopyButton, { text: answer }), isSubmitted && (_jsxs(SentBadge, { role: "status", children: [_jsx(IconCheck, { fontSize: 12 }), "Inviato"] }))] }), !isSubmitted && draftRating && (_jsxs(FeedbackPanel, { ref: panelRef, children: [_jsxs(FeedbackPanelHeader, { children: [_jsx(FeedbackPanelTitle, { children: FEEDBACK_TITLES[draftRating] }), _jsx(FeedbackCloseButton, { type: "button", "aria-label": "Chiudi", title: "Chiudi", onClick: resetDraft, children: _jsx(IconClose, { fontSize: 16 }) })] }), _jsx(FeedbackLabel, { children: "Era..." }), _jsx(FeedbackTags, { children: FEEDBACK_TAGS[draftRating].map(tag => (_jsx(FeedbackTag, { type: "button", $selected: selectedTags.includes(tag), "aria-pressed": selectedTags.includes(tag), onClick: () => onTagClick(tag), children: tag }, tag))) }), _jsx(FeedbackLabel, { children: "Feedback aggiuntivo" }), _jsx(FeedbackTextarea, { value: feedback, maxLength: FEEDBACK_MAX_LENGTH, placeholder: "Raccontaci di pi\u00F9", onChange: (e) => setFeedback(e.target.value.slice(0, FEEDBACK_MAX_LENGTH)), onKeyDown: (e) => { if (e.key === 'Enter')
303
+ e.stopPropagation(); } }), _jsxs(FeedbackPanelFooter, { children: [_jsxs(FeedbackCounter, { $full: feedback.length >= FEEDBACK_MAX_LENGTH, children: [feedback.length, "/", FEEDBACK_MAX_LENGTH] }), _jsx(FeedbackSubmitButton, { type: "button", disabled: !canSubmit, onClick: onSubmitClick, children: "Invia" })] })] }, draftRating))] }));
304
+ };
305
+ //#endregion
306
+ //#region Thinking status (phrases + elapsed seconds)
307
+ const getThinkingPhrases = () => [
308
+ { at: 0, text: SDKUI_Localizator.HelpOnLineThinking01 },
309
+ { at: 3, text: SDKUI_Localizator.HelpOnLineThinking02 },
310
+ { at: 7, text: SDKUI_Localizator.HelpOnLineThinking03 },
311
+ { at: 12, text: SDKUI_Localizator.HelpOnLineThinking04 },
312
+ { at: 18, text: SDKUI_Localizator.HelpOnLineThinking05 },
313
+ { at: 25, text: SDKUI_Localizator.HelpOnLineThinking06 },
314
+ { at: 33, text: SDKUI_Localizator.HelpOnLineThinking07 },
315
+ { at: 42, text: SDKUI_Localizator.HelpOnLineThinking08 },
316
+ { at: 55, text: SDKUI_Localizator.HelpOnLineThinking09 },
317
+ { at: 70, text: SDKUI_Localizator.HelpOnLineThinking10 },
318
+ ];
319
+ const COUNTER_VISIBLE_FROM = 2;
320
+ const getPhraseIndex = (seconds, phrases) => {
321
+ let index = 0;
322
+ for (let i = 1; i < phrases.length; i++) {
323
+ if (seconds < phrases[i].at)
324
+ break;
325
+ index = i;
326
+ }
327
+ return index;
328
+ };
329
+ const formatElapsed = (seconds) => seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
330
+ const ThinkingStatus = () => {
331
+ const [seconds, setSeconds] = useState(0);
332
+ useEffect(() => {
333
+ const startedAt = performance.now();
334
+ const intervalId = globalThis.setInterval(() => {
335
+ setSeconds(Math.floor((performance.now() - startedAt) / 1000));
336
+ }, 1000);
337
+ return () => globalThis.clearInterval(intervalId);
338
+ }, []);
339
+ const phrases = getThinkingPhrases();
340
+ const phraseIndex = getPhraseIndex(seconds, phrases);
341
+ return (_jsx(ThinkingIndicator, { children: _jsxs(ThinkingCaption, { children: [_jsxs(ThinkingPhrase, { role: "status", "aria-live": "polite", children: [phrases[phraseIndex].text, _jsxs(ThinkingDots, { "aria-hidden": "true", children: [_jsx(ThinkingDot, { $delay: 0, children: "." }), _jsx(ThinkingDot, { $delay: 0.2, children: "." }), _jsx(ThinkingDot, { $delay: 0.4, children: "." })] })] }, phraseIndex), _jsx(ThinkingCounter, { $visible: seconds >= COUNTER_VISIBLE_FROM, "aria-hidden": "true", children: formatElapsed(seconds) })] }) }));
342
+ };
343
+ //#endregion
344
+ //#region Markdown rendering (no third-party library)
345
+ const safeJsonParse = (value) => {
346
+ try {
347
+ return JSON.parse(value);
348
+ }
349
+ catch {
350
+ return value;
351
+ }
352
+ };
353
+ const renderInline = (text, keyPrefix) => {
354
+ const nodes = [];
355
+ const pattern = /(\*\*([^*]+)\*\*)|(~~([^~]+)~~)|(`([^`]+)`)|(\[([^\]]+)\]\(([^)]+)\))|(\*([^*\n]+)\*)|(_([^_\n]+)_)/g;
356
+ let lastIndex = 0;
357
+ let match;
358
+ let i = 0;
359
+ while ((match = pattern.exec(text)) !== null) {
360
+ if (match.index > lastIndex)
361
+ nodes.push(text.slice(lastIndex, match.index));
362
+ const key = `${keyPrefix}-${i}`;
363
+ if (match[2] !== undefined) {
364
+ nodes.push(_jsx("strong", { children: renderInline(match[2], key) }, key));
365
+ }
366
+ else if (match[4] !== undefined) {
367
+ nodes.push(_jsx("s", { children: renderInline(match[4], key) }, key));
368
+ }
369
+ else if (match[6] !== undefined) {
370
+ nodes.push(_jsx(MdCode, { children: match[6] }, key));
371
+ }
372
+ else if (match[8] !== undefined) {
373
+ nodes.push(_jsx("a", { href: match[9], target: "_blank", rel: "noopener noreferrer", children: match[8] }, key));
374
+ }
375
+ else if (match[11] !== undefined) {
376
+ nodes.push(_jsx("em", { children: match[11] }, key));
377
+ }
378
+ else if (match[13] !== undefined) {
379
+ nodes.push(_jsx("em", { children: match[13] }, key));
380
+ }
381
+ lastIndex = pattern.lastIndex;
382
+ i++;
383
+ }
384
+ if (lastIndex < text.length)
385
+ nodes.push(text.slice(lastIndex));
386
+ return nodes;
387
+ };
388
+ const splitTableCells = (row) => {
389
+ let s = row.trim();
390
+ if (s.startsWith('|'))
391
+ s = s.slice(1);
392
+ if (s.endsWith('|') && !s.endsWith('\\|'))
393
+ s = s.slice(0, -1);
394
+ const cells = [];
395
+ let cur = '';
396
+ for (let i = 0; i < s.length; i++) {
397
+ if (s[i] === '\\' && s[i + 1] === '|') {
398
+ cur += '|';
399
+ i++;
400
+ continue;
401
+ }
402
+ if (s[i] === '|') {
403
+ cells.push(cur.trim());
404
+ cur = '';
405
+ continue;
406
+ }
407
+ cur += s[i];
408
+ }
409
+ cells.push(cur.trim());
410
+ return cells;
411
+ };
412
+ const isTableSeparator = (line) => {
413
+ if (!line?.includes('-'))
414
+ return false;
415
+ const cells = splitTableCells(line);
416
+ return cells.length > 0 && cells.every(c => /^:?-+:?$/.test(c));
417
+ };
418
+ const getCellAlign = (sep) => {
419
+ const left = sep.startsWith(':');
420
+ const right = sep.endsWith(':');
421
+ if (left && right)
422
+ return 'center';
423
+ if (right)
424
+ return 'right';
425
+ if (left)
426
+ return 'left';
427
+ return undefined;
428
+ };
429
+ //#endregion
430
+ const startsBlock = (lines, idx) => {
431
+ const line = lines[idx];
432
+ if (line.trim() === '')
433
+ return true;
434
+ if (line.trim().startsWith('```'))
435
+ return true;
436
+ if (/^#{1,6}\s+/.test(line))
437
+ return true;
438
+ if (/^\s*[-*+]\s+/.test(line))
439
+ return true;
440
+ if (/^\s*\d+\.\s+/.test(line))
441
+ return true;
442
+ if (/^\s*>\s?/.test(line))
443
+ return true;
444
+ if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line))
445
+ return true;
446
+ if (line.includes('|') && isTableSeparator(lines[idx + 1]))
447
+ return true;
448
+ return false;
449
+ };
450
+ const renderMarkdown = (raw) => {
451
+ const lines = raw.replace(/\r\n/g, '\n').split('\n');
452
+ const blocks = [];
453
+ let i = 0;
454
+ let key = 0;
455
+ while (i < lines.length) {
456
+ const line = lines[i];
457
+ if (line.trim().startsWith('```')) {
458
+ const codeLines = [];
459
+ i++;
460
+ while (i < lines.length && !lines[i].trim().startsWith('```')) {
461
+ codeLines.push(lines[i]);
462
+ i++;
463
+ }
464
+ i++;
465
+ blocks.push(_jsx(MdPre, { children: codeLines.join('\n') }, `b-${key++}`));
466
+ continue;
467
+ }
468
+ if (line.includes('|') && isTableSeparator(lines[i + 1])) {
469
+ const headers = splitTableCells(line);
470
+ const aligns = splitTableCells(lines[i + 1]).map(getCellAlign);
471
+ i += 2;
472
+ const rows = [];
473
+ while (i < lines.length && lines[i].trim() !== '' && lines[i].includes('|')) {
474
+ rows.push(splitTableCells(lines[i]));
475
+ i++;
476
+ }
477
+ const tKey = key++;
478
+ blocks.push(_jsx(MdTableWrapper, { children: _jsxs(MdTable, { children: [_jsx("thead", { children: _jsx("tr", { children: headers.map((cell, ci) => (_jsx(MdTh, { $align: aligns[ci], children: renderInline(cell, `th-${tKey}-${ci}`) }, `th-${tKey}-${ci}`))) }) }), _jsx("tbody", { children: rows.map((row, ri) => (_jsx("tr", { children: headers.map((_, ci) => (_jsx(MdTd, { $align: aligns[ci], children: renderInline(row[ci] ?? '', `td-${tKey}-${ri}-${ci}`) }, `td-${tKey}-${ri}-${ci}`))) }, `tr-${tKey}-${ri}`))) })] }) }, `b-${tKey}`));
479
+ continue;
480
+ }
481
+ if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line)) {
482
+ blocks.push(_jsx(MdHr, {}, `b-${key++}`));
483
+ i++;
484
+ continue;
485
+ }
486
+ if (/^\s*>\s?/.test(line)) {
487
+ const quoteLines = [];
488
+ while (i < lines.length && /^\s*>\s?/.test(lines[i])) {
489
+ quoteLines.push(lines[i].replace(/^\s*>\s?/, ''));
490
+ i++;
491
+ }
492
+ blocks.push(_jsx(MdBlockquote, { children: renderMarkdown(quoteLines.join('\n')) }, `b-${key++}`));
493
+ continue;
494
+ }
495
+ const heading = line.match(/^(#{1,6})\s+(.*)$/);
496
+ if (heading) {
497
+ const level = heading[1].length;
498
+ blocks.push(_jsx(MdHeading, { $level: level, children: renderInline(heading[2], `h-${key}`) }, `b-${key}`));
499
+ key++;
500
+ i++;
501
+ continue;
502
+ }
503
+ if (/^\s*[-*+]\s+/.test(line)) {
504
+ const items = [];
505
+ while (i < lines.length && /^\s*[-*+]\s+/.test(lines[i])) {
506
+ const content = lines[i].replace(/^\s*[-*+]\s+/, '');
507
+ items.push(_jsx("li", { children: renderInline(content, `li-${key}-${items.length}`) }, `li-${key}-${items.length}`));
508
+ i++;
509
+ }
510
+ blocks.push(_jsx(MdUl, { children: items }, `b-${key++}`));
511
+ continue;
512
+ }
513
+ if (/^\s*\d+\.\s+/.test(line)) {
514
+ const items = [];
515
+ while (i < lines.length && /^\s*\d+\.\s+/.test(lines[i])) {
516
+ const content = lines[i].replace(/^\s*\d+\.\s+/, '');
517
+ items.push(_jsx("li", { children: renderInline(content, `oi-${key}-${items.length}`) }, `oi-${key}-${items.length}`));
518
+ i++;
519
+ }
520
+ blocks.push(_jsx(MdOl, { children: items }, `b-${key++}`));
521
+ continue;
522
+ }
523
+ if (line.trim() === '') {
524
+ i++;
525
+ continue;
526
+ }
527
+ const paraLines = [];
528
+ while (i < lines.length && !startsBlock(lines, i)) {
529
+ paraLines.push(lines[i]);
530
+ i++;
531
+ }
532
+ const paraNodes = paraLines.flatMap((pl, idx) => {
533
+ const inline = renderInline(pl, `p-${key}-${idx}`);
534
+ return idx === 0 ? inline : [_jsx("br", {}, `br-${key}-${idx}`), ...inline];
535
+ });
536
+ blocks.push(_jsx(MdParagraph, { children: paraNodes }, `b-${key++}`));
537
+ }
538
+ return blocks;
539
+ };
540
+ //#endregion
541
+ //#region Icons
542
+ function IconClose(props) {
543
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M18.3 5.71 12 12.01l-6.3-6.3-1.41 1.41 6.3 6.3-6.3 6.3 1.41 1.41 6.3-6.3 6.3 6.3 1.41-1.41-6.3-6.3 6.3-6.3z" }) }));
544
+ }
545
+ function IconSendFilled(props) {
546
+ return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", width: "1em", height: "1em", ...props, children: [_jsx("defs", { children: _jsx("path", { id: "lsiconSendFilled0", d: "M12.97 2.67a.5.5 0 0 0-.64-.64l-11 4a.5.5 0 0 0-.016.934l4.433 1.773l2.9-3.09l.707.707l-2.98 3.176l1.662 4.156a.5.5 0 0 0 .934-.015z" }) }), _jsxs("g", { fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd", children: [_jsx("use", { href: "#lsiconSendFilled0" }), _jsx("use", { href: "#lsiconSendFilled0" })] })] }));
547
+ }
548
+ function IconNewChat(props) {
549
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: props.color || "currentColor", ...props, children: _jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z" }) }));
550
+ }
551
+ function IconSparkle(props) {
552
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z" }) }));
553
+ }
554
+ function IconQuestion(props) {
555
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z" }) }));
556
+ }
557
+ function IconArrowForward(props) {
558
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z" }) }));
559
+ }
560
+ function IconThumbUp(props) {
561
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.58 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h4v12H1z" }) }));
562
+ }
563
+ function IconCopy(props) {
564
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }) }));
565
+ }
566
+ function IconCheck(props) {
567
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "currentColor", ...props, children: _jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }));
568
+ }
569
+ //#endregion
570
+ //#region Styled Components
571
+ const fadeIn = keyframes `
572
+ from { opacity: 0; }
573
+ to { opacity: 1; }
574
+ `;
575
+ const slideInRight = keyframes `
576
+ from { transform: translateX(100%); }
577
+ to { transform: translateX(0); }
578
+ `;
579
+ const phraseIn = keyframes `
580
+ from { opacity: 0; transform: translateY(4px); }
581
+ to { opacity: 1; transform: translateY(0); }
582
+ `;
583
+ const suggestionIn = keyframes `
584
+ from { opacity: 0; transform: translateY(6px); }
585
+ to { opacity: 1; transform: translateY(0); }
586
+ `;
587
+ const feedbackIn = keyframes `
588
+ from { opacity: 0; transform: translateY(-4px); }
589
+ to { opacity: 1; transform: translateY(0); }
590
+ `;
591
+ const badgeIn = keyframes `
592
+ 0% { opacity: 0; transform: scale(0.85); }
593
+ 60% { opacity: 1; transform: scale(1.05); }
594
+ 100% { opacity: 1; transform: scale(1); }
595
+ `;
596
+ const dotCycle = keyframes `
597
+ 0% { opacity: 0; }
598
+ 25%, 75% { opacity: 1; }
599
+ 100% { opacity: 0; }
600
+ `;
601
+ const ToppyHeaderButton = styled.button `
602
+ display: flex;
603
+ align-items: center;
604
+ gap: 8px;
605
+ height: 36px;
606
+ padding: 0 14px 0 5px;
607
+ border-radius: 18px;
608
+ border: 1px solid ${TMColors.primary}35;
609
+ background: ${TMColors.primary}0d;
610
+ color: ${TMColors.primary};
611
+ font-size: 13px;
612
+ font-weight: 600;
613
+ white-space: nowrap;
614
+ cursor: pointer;
615
+ flex-shrink: 0;
616
+ transition: all 0.2s ease;
617
+
618
+ &:hover {
619
+ background: ${TMColors.primary}1a;
620
+ border-color: ${TMColors.primary}66;
621
+ transform: translateY(-1px);
622
+ box-shadow: 0 4px 12px ${TMColors.primary}25;
623
+ }
624
+ &:active { transform: translateY(0); }
625
+ `;
626
+ const ToppyHeaderAvatar = styled.img `
627
+ width: 28px;
628
+ height: 28px;
629
+ border-radius: 50%;
630
+ object-fit: contain;
631
+ pointer-events: none;
632
+ `;
633
+ const ToppyHeaderText = styled.span `
634
+ line-height: 1;
635
+ `;
636
+ const Fab = styled.button `
637
+ position: fixed;
638
+ bottom: 24px;
639
+ right: 24px;
640
+ width: 60px;
641
+ height: 60px;
642
+ border-radius: 50%;
643
+ border: none;
644
+ padding: 0;
645
+ cursor: pointer;
646
+ display: flex;
647
+ align-items: center;
648
+ justify-content: center;
649
+ background: white;
650
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
651
+ z-index: 100000;
652
+ transition: transform 0.2s ease, box-shadow 0.2s ease;
653
+ animation: ${fadeIn} 0.3s ease-out;
654
+
655
+ &:hover { transform: scale(1.08); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.3); }
656
+ &:active { transform: scale(0.96); }
657
+ `;
658
+ const FabAvatar = styled.img `
659
+ width: 52px;
660
+ height: 52px;
661
+ border-radius: 50%;
662
+ object-fit: contain;
663
+ pointer-events: none;
664
+ `;
665
+ const Overlay = styled.div `
666
+ position: fixed;
667
+ inset: 0;
668
+ background: rgba(0, 0, 0, 0.45);
669
+ z-index: 100000;
670
+ animation: ${fadeIn} 0.2s ease-out;
671
+ `;
672
+ const PanelContainer = styled.div `
673
+ position: fixed;
674
+ top: 0;
675
+ right: 0;
676
+ height: 100vh;
677
+ width: ${props => props.$width}px;
678
+ max-width: 100vw;
679
+ background: white;
680
+ display: flex;
681
+ flex-direction: column;
682
+ box-shadow: -8px 0 32px rgba(0, 0, 0, 0.28);
683
+ z-index: 100001;
684
+ animation: ${slideInRight} 0.25s ease-out;
685
+ `;
686
+ const ResizeHandle = styled.div `
687
+ position: absolute;
688
+ left: 0;
689
+ top: 0;
690
+ bottom: 0;
691
+ width: 6px;
692
+ cursor: col-resize;
693
+ background: transparent;
694
+ z-index: 2;
695
+ transition: background 0.2s ease;
696
+
697
+ &:hover { background: ${TMColors.primary}55; }
698
+ `;
699
+ const ChatHeader = styled.div `
700
+ display: flex;
701
+ align-items: center;
702
+ justify-content: space-between;
703
+ padding: 16px 20px;
704
+ background: linear-gradient(135deg, ${TMColors.primary} 0%, ${TMColors.primary}dd 100%);
705
+ color: white;
706
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
707
+ `;
708
+ const HeaderLeft = styled.div `
709
+ display: flex;
710
+ align-items: center;
711
+ gap: 12px;
712
+ flex: 1;
713
+ min-width: 0;
714
+ `;
715
+ const HeaderRight = styled.div `
716
+ display: flex;
717
+ align-items: center;
718
+ gap: 8px;
719
+ margin-left: 12px;
720
+ flex-shrink: 0;
721
+ `;
722
+ const ToppyAvatar = styled.img `
723
+ width: 44px;
724
+ height: 44px;
725
+ border-radius: 50%;
726
+ background: white;
727
+ padding: 4px;
728
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
729
+ flex-shrink: 0;
730
+ object-fit: contain;
731
+ `;
732
+ const HeaderText = styled.div `
733
+ display: flex;
734
+ flex-direction: column;
735
+ gap: 2px;
736
+ min-width: 0;
737
+ `;
738
+ const HeaderGreeting = styled.h2 `
739
+ margin: 0;
740
+ font-size: 17px;
741
+ font-weight: 600;
742
+ color: white;
743
+ white-space: nowrap;
744
+ overflow: hidden;
745
+ text-overflow: ellipsis;
746
+ `;
747
+ const HeaderQuestion = styled.p `
748
+ margin: 0;
749
+ font-size: 13px;
750
+ color: rgba(255, 255, 255, 0.9);
751
+ `;
752
+ const HeaderButton = styled.button `
753
+ width: 32px;
754
+ height: 32px;
755
+ border-radius: 50%;
756
+ background: rgba(255, 255, 255, 0.2);
757
+ border: 1px solid rgba(255, 255, 255, 0.3);
758
+ color: white;
759
+ cursor: pointer;
760
+ display: flex;
761
+ align-items: center;
762
+ justify-content: center;
763
+ flex-shrink: 0;
764
+ transition: all 0.2s ease;
765
+
766
+ &:hover:not(:disabled) { background: rgba(255, 255, 255, 0.3); transform: scale(1.05); }
767
+ &:active:not(:disabled) { transform: scale(0.95); }
768
+ &:disabled { opacity: 0.45; cursor: default; }
769
+ `;
770
+ const ChatBody = styled.div `
771
+ flex: 1;
772
+ padding: 20px;
773
+ overflow-y: auto;
774
+ background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
775
+ `;
776
+ const WelcomeMessage = styled.div `
777
+ display: flex;
778
+ gap: 16px;
779
+ padding: 18px;
780
+ background: white;
781
+ border-radius: 12px;
782
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
783
+ border-left: 4px solid ${TMColors.primary};
784
+ animation: ${fadeIn} 0.5s ease-out;
785
+ `;
786
+ const WelcomeIcon = styled.div `
787
+ font-size: 30px;
788
+ flex-shrink: 0;
789
+ `;
790
+ const WelcomeText = styled.p `
791
+ margin: 0;
792
+ font-size: 14px;
793
+ line-height: 1.6;
794
+ color: #242424;
795
+
796
+ strong { color: ${TMColors.primary}; font-weight: 600; }
797
+ `;
798
+ const MessageBubble = styled.div `
799
+ display: flex;
800
+ gap: 10px;
801
+ margin-bottom: 16px;
802
+ align-items: flex-start;
803
+ justify-content: ${props => (props.$isUser ? 'flex-end' : 'flex-start')};
804
+ animation: ${fadeIn} 0.3s ease-out;
805
+ `;
806
+ const BotAvatar = styled.img `
807
+ width: 32px;
808
+ height: 32px;
809
+ border-radius: 50%;
810
+ background: white;
811
+ padding: 2px;
812
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
813
+ flex-shrink: 0;
814
+ object-fit: contain;
815
+ `;
816
+ const MessageContent = styled.div `
817
+ max-width: 80%;
818
+ padding: 10px 14px;
819
+ border-radius: 12px;
820
+ font-size: 14px;
821
+ line-height: 1.5;
822
+ background: ${props => (props.$isUser ? TMColors.primary : '#f0f2f5')};
823
+ color: ${props => (props.$isUser ? 'white' : '#242424')};
824
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
825
+ word-wrap: break-word;
826
+ overflow-wrap: anywhere;
827
+ white-space: ${props => (props.$isUser ? 'pre-wrap' : 'normal')};
828
+ border-bottom-${props => (props.$isUser ? 'right' : 'left')}-radius: 4px;
829
+ `;
830
+ const BotMessageColumn = styled.div `
831
+ display: flex;
832
+ flex-direction: column;
833
+ align-items: flex-start;
834
+ width: 80%;
835
+ min-width: 0;
836
+ `;
837
+ const BotMessageContent = styled(MessageContent) `
838
+ max-width: 100%;
839
+ `;
840
+ const QuestionCopy = styled.div `
841
+ align-self: center;
842
+ flex-shrink: 0;
843
+ opacity: 0.55;
844
+ transition: opacity 0.2s ease;
845
+
846
+ ${MessageBubble}:hover &, &:focus-within {
847
+ opacity: 1;
848
+ }
849
+ `;
850
+ const FeedbackContainer = styled.div `
851
+ width: 100%;
852
+ margin-top: 4px;
853
+ `;
854
+ const FeedbackActions = styled.div `
855
+ display: flex;
856
+ align-items: center;
857
+ gap: 2px;
858
+ `;
859
+ const FeedbackActionButton = styled.button `
860
+ display: flex;
861
+ align-items: center;
862
+ justify-content: center;
863
+ width: 28px;
864
+ height: 28px;
865
+ padding: 0;
866
+ border-radius: 8px;
867
+ border: 1px solid ${props => (props.$active ? `${TMColors.primary}55` : 'transparent')};
868
+ background: ${props => (props.$active ? `${TMColors.primary}12` : 'transparent')};
869
+ color: ${props => (props.$success ? '#2e7d32' : props.$active ? TMColors.primary : '#8a8f98')};
870
+ cursor: ${props => (props.$locked ? 'default' : 'pointer')};
871
+ transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
872
+
873
+ &:hover:not(:disabled) {
874
+ background: ${props => (props.$active ? `${TMColors.primary}12` : 'rgba(0, 0, 0, 0.05)')};
875
+ color: ${props => (props.$success ? '#2e7d32' : props.$active ? TMColors.primary : '#242424')};
876
+ }
877
+
878
+ &:focus-visible {
879
+ outline: 2px solid ${TMColors.primary}55;
880
+ outline-offset: 1px;
881
+ }
882
+
883
+ &:disabled {
884
+ opacity: 0.35;
885
+ cursor: default;
886
+ }
887
+ `;
888
+ const SentBadge = styled.span `
889
+ display: inline-flex;
890
+ align-items: center;
891
+ gap: 4px;
892
+ margin-left: 6px;
893
+ padding: 3px 9px 3px 7px;
894
+ border-radius: 999px;
895
+ background: #e8f5e9;
896
+ border: 1px solid #c8e6c9;
897
+ color: #2e7d32;
898
+ font-size: 11px;
899
+ font-weight: 600;
900
+ line-height: 1;
901
+ letter-spacing: 0.02em;
902
+ animation: ${badgeIn} 0.35s ease-out;
903
+
904
+ @media (prefers-reduced-motion: reduce) {
905
+ animation: none;
906
+ }
907
+ `;
908
+ const FeedbackPanel = styled.div `
909
+ margin-top: 6px;
910
+ padding: 14px 16px;
911
+ border: 1px solid #e5e7eb;
912
+ border-radius: 12px;
913
+ background: white;
914
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
915
+ scroll-margin: 12px;
916
+ animation: ${feedbackIn} 0.2s ease-out;
917
+ `;
918
+ const FeedbackPanelHeader = styled.div `
919
+ display: flex;
920
+ align-items: flex-start;
921
+ justify-content: space-between;
922
+ gap: 12px;
923
+ margin-bottom: 10px;
924
+ `;
925
+ const FeedbackPanelTitle = styled.div `
926
+ font-size: 14px;
927
+ font-weight: 600;
928
+ color: #242424;
929
+ line-height: 1.35;
930
+ `;
931
+ const FeedbackCloseButton = styled.button `
932
+ display: flex;
933
+ align-items: center;
934
+ justify-content: center;
935
+ width: 24px;
936
+ height: 24px;
937
+ padding: 0;
938
+ border: none;
939
+ border-radius: 6px;
940
+ background: transparent;
941
+ color: #6b7280;
942
+ cursor: pointer;
943
+ flex-shrink: 0;
944
+ transition: background 0.2s ease, color 0.2s ease;
945
+
946
+ &:hover { background: rgba(0, 0, 0, 0.06); color: #242424; }
947
+ `;
948
+ const FeedbackLabel = styled.div `
949
+ margin: 0 0 8px 0;
950
+ font-size: 12px;
951
+ font-weight: 600;
952
+ color: #6b7280;
953
+ `;
954
+ const FeedbackTags = styled.div `
955
+ display: flex;
956
+ flex-wrap: wrap;
957
+ gap: 8px;
958
+ margin-bottom: 14px;
959
+ `;
960
+ const FeedbackTag = styled.button `
961
+ padding: 6px 12px;
962
+ border-radius: 8px;
963
+ border: 1px solid ${props => (props.$selected ? TMColors.primary : '#dcdfe3')};
964
+ background: ${props => (props.$selected ? `${TMColors.primary}10` : 'white')};
965
+ color: ${props => (props.$selected ? TMColors.primary : '#242424')};
966
+ font-family: inherit;
967
+ font-size: 13px;
968
+ font-weight: ${props => (props.$selected ? 600 : 400)};
969
+ line-height: 1.2;
970
+ cursor: pointer;
971
+ transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
972
+
973
+ &:hover { border-color: ${TMColors.primary}88; }
974
+
975
+ &:focus-visible {
976
+ outline: 2px solid ${TMColors.primary}55;
977
+ outline-offset: 1px;
978
+ }
979
+ `;
980
+ const FeedbackTextarea = styled.textarea `
981
+ display: block;
982
+ width: 100%;
983
+ min-height: 70px;
984
+ padding: 9px 11px;
985
+ border: 1px solid #dcdfe3;
986
+ border-radius: 8px;
987
+ font-family: inherit;
988
+ font-size: 13px;
989
+ line-height: 1.45;
990
+ color: #242424;
991
+ background: white;
992
+ resize: none;
993
+ box-sizing: border-box;
994
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
995
+
996
+ &::placeholder { color: #9ca3af; }
997
+
998
+ &:focus {
999
+ outline: none;
1000
+ border-color: ${TMColors.primary};
1001
+ box-shadow: 0 0 0 3px ${TMColors.primary}15;
1002
+ }
1003
+ `;
1004
+ const FeedbackPanelFooter = styled.div `
1005
+ display: flex;
1006
+ align-items: center;
1007
+ justify-content: space-between;
1008
+ margin-top: 10px;
1009
+ `;
1010
+ const FeedbackCounter = styled.span `
1011
+ font-size: 11px;
1012
+ color: ${props => (props.$full ? '#c62828' : '#9ca3af')};
1013
+ font-variant-numeric: tabular-nums;
1014
+ `;
1015
+ const FeedbackSubmitButton = styled.button `
1016
+ padding: 7px 18px;
1017
+ border: none;
1018
+ border-radius: 8px;
1019
+ background: ${TMColors.primary};
1020
+ color: white;
1021
+ font-family: inherit;
1022
+ font-size: 13px;
1023
+ font-weight: 600;
1024
+ cursor: pointer;
1025
+ transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
1026
+
1027
+ &:hover:not(:disabled) {
1028
+ box-shadow: 0 4px 12px ${TMColors.primary}40;
1029
+ transform: translateY(-1px);
1030
+ }
1031
+
1032
+ &:active:not(:disabled) { transform: translateY(0); }
1033
+
1034
+ &:disabled {
1035
+ opacity: 0.4;
1036
+ cursor: default;
1037
+ }
1038
+ `;
1039
+ const MarkdownContent = styled.div `
1040
+ & > *:first-child { margin-top: 0; }
1041
+ & > *:last-child { margin-bottom: 0; }
1042
+
1043
+ a { color: ${TMColors.primary}; text-decoration: underline; }
1044
+ strong { font-weight: 600; }
1045
+ `;
1046
+ const MdParagraph = styled.p `
1047
+ margin: 0 0 8px 0;
1048
+ line-height: 1.55;
1049
+ `;
1050
+ const MdHeading = styled.div `
1051
+ margin: 12px 0 6px 0;
1052
+ font-weight: 700;
1053
+ line-height: 1.3;
1054
+ font-size: ${props => `${Math.max(14, 20 - (props.$level - 1) * 2)}px`};
1055
+ `;
1056
+ const MdUl = styled.ul `
1057
+ margin: 4px 0 8px 0;
1058
+ padding-left: 20px;
1059
+ li { margin: 2px 0; line-height: 1.5; }
1060
+ `;
1061
+ const MdOl = styled.ol `
1062
+ margin: 4px 0 8px 0;
1063
+ padding-left: 22px;
1064
+ li { margin: 2px 0; line-height: 1.5; }
1065
+ `;
1066
+ const MdCode = styled.code `
1067
+ background: rgba(0, 0, 0, 0.06);
1068
+ padding: 1px 5px;
1069
+ border-radius: 4px;
1070
+ font-family: 'Consolas', 'Monaco', monospace;
1071
+ font-size: 0.9em;
1072
+ `;
1073
+ const MdPre = styled.pre `
1074
+ background: rgba(0, 0, 0, 0.06);
1075
+ padding: 10px 12px;
1076
+ border-radius: 8px;
1077
+ overflow-x: auto;
1078
+ margin: 8px 0;
1079
+ font-family: 'Consolas', 'Monaco', monospace;
1080
+ font-size: 0.88em;
1081
+ white-space: pre;
1082
+ `;
1083
+ const MdTableWrapper = styled.div `
1084
+ margin: 8px 0;
1085
+ max-width: 100%;
1086
+ overflow-x: auto;
1087
+ border: 1px solid #dcdfe3;
1088
+ border-radius: 8px;
1089
+
1090
+ &::-webkit-scrollbar { height: 6px; }
1091
+ &::-webkit-scrollbar-track { background: transparent; }
1092
+ &::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
1093
+ &::-webkit-scrollbar-thumb:hover { background: #999; }
1094
+ `;
1095
+ const MdTable = styled.table `
1096
+ border-collapse: collapse;
1097
+ width: 100%;
1098
+ font-size: 0.92em;
1099
+ background: white;
1100
+ `;
1101
+ const MdTh = styled.th `
1102
+ padding: 7px 10px;
1103
+ background: ${TMColors.primary}14;
1104
+ color: #242424;
1105
+ font-weight: 600;
1106
+ text-align: ${props => props.$align ?? 'left'};
1107
+ border-bottom: 1px solid #dcdfe3;
1108
+ white-space: nowrap;
1109
+
1110
+ &:not(:last-child) { border-right: 1px solid #e6e8eb; }
1111
+ `;
1112
+ const MdTd = styled.td `
1113
+ padding: 7px 10px;
1114
+ text-align: ${props => props.$align ?? 'left'};
1115
+ vertical-align: top;
1116
+ border-top: 1px solid #eceef0;
1117
+
1118
+ &:not(:last-child) { border-right: 1px solid #eceef0; }
1119
+
1120
+ tr:nth-child(even) & { background: #fafbfc; }
1121
+ `;
1122
+ const MdBlockquote = styled.blockquote `
1123
+ margin: 8px 0;
1124
+ padding: 6px 12px;
1125
+ border-left: 3px solid ${TMColors.primary}66;
1126
+ background: ${TMColors.primary}0a;
1127
+ border-radius: 0 6px 6px 0;
1128
+ color: #444;
1129
+
1130
+ & > *:first-child { margin-top: 0; }
1131
+ & > *:last-child { margin-bottom: 0; }
1132
+ `;
1133
+ const MdHr = styled.hr `
1134
+ border: none;
1135
+ border-top: 1px solid #dcdfe3;
1136
+ margin: 12px 0;
1137
+ `;
1138
+ const ThinkingIndicator = styled.div `
1139
+ display: flex;
1140
+ align-items: center;
1141
+ gap: 10px;
1142
+ max-width: 80%;
1143
+ padding: 7px 12px;
1144
+ background: #f0f2f5;
1145
+ border-radius: 12px;
1146
+ border-bottom-left-radius: 4px;
1147
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
1148
+ `;
1149
+ const ThinkingCaption = styled.div `
1150
+ display: flex;
1151
+ flex-direction: column;
1152
+ align-items: flex-start;
1153
+ gap: 0;
1154
+ min-width: 0;
1155
+ `;
1156
+ const ThinkingPhrase = styled.span `
1157
+ display: inline-flex;
1158
+ align-items: center;
1159
+ min-width: 0;
1160
+ font-size: 12px;
1161
+ font-style: italic;
1162
+ line-height: 1.15;
1163
+ color: #6b7280;
1164
+ animation: ${phraseIn} 0.25s ease-out;
1165
+ `;
1166
+ const ThinkingDots = styled.span `
1167
+ display: inline-flex;
1168
+ width: 12px;
1169
+ flex-shrink: 0;
1170
+ `;
1171
+ const ThinkingDot = styled.span `
1172
+ animation: ${dotCycle} 1.2s linear infinite;
1173
+ animation-delay: ${props => props.$delay}s;
1174
+ will-change: opacity;
1175
+
1176
+ @media (prefers-reduced-motion: reduce) {
1177
+ animation: none;
1178
+ opacity: 1;
1179
+ }
1180
+ `;
1181
+ const ThinkingCounter = styled.span `
1182
+ margin-top: 2px;
1183
+ font-size: 10px;
1184
+ font-weight: 600;
1185
+ line-height: 1.1;
1186
+ letter-spacing: 0.02em;
1187
+ color: ${TMColors.primary}b3;
1188
+ font-variant-numeric: tabular-nums;
1189
+ font-feature-settings: 'tnum';
1190
+ opacity: ${props => (props.$visible ? 1 : 0)};
1191
+ transition: opacity 0.3s ease;
1192
+ `;
1193
+ const ChatFooter = styled.div `
1194
+ padding: 16px 20px;
1195
+ background: white;
1196
+ border-top: 1px solid #e1e5e9;
1197
+ box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
1198
+ `;
1199
+ const SuggestionsSection = styled.div `
1200
+ margin-bottom: 14px;
1201
+ `;
1202
+ const SuggestionsTitle = styled.div `
1203
+ display: flex;
1204
+ align-items: center;
1205
+ gap: 6px;
1206
+ margin: 0 0 8px 2px;
1207
+ font-size: 11px;
1208
+ font-weight: 600;
1209
+ letter-spacing: 0.06em;
1210
+ text-transform: uppercase;
1211
+ color: #6b7280;
1212
+
1213
+ svg { color: ${TMColors.primary}; }
1214
+ `;
1215
+ const SuggestionsGrid = styled.div `
1216
+ display: grid;
1217
+ grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
1218
+ gap: 8px;
1219
+ `;
1220
+ const SuggestionIcon = styled.span `
1221
+ display: flex;
1222
+ align-items: center;
1223
+ justify-content: center;
1224
+ width: 28px;
1225
+ height: 28px;
1226
+ border-radius: 8px;
1227
+ flex-shrink: 0;
1228
+ background: ${TMColors.primary}14;
1229
+ color: ${TMColors.primary};
1230
+ transition: background 0.2s ease, color 0.2s ease;
1231
+ `;
1232
+ const SuggestionText = styled.span `
1233
+ flex: 1;
1234
+ min-width: 0;
1235
+ display: -webkit-box;
1236
+ -webkit-line-clamp: 2;
1237
+ -webkit-box-orient: vertical;
1238
+ overflow: hidden;
1239
+ `;
1240
+ const SuggestionArrow = styled.span `
1241
+ display: flex;
1242
+ flex-shrink: 0;
1243
+ color: ${TMColors.primary};
1244
+ opacity: 0;
1245
+ transform: translateX(-4px);
1246
+ transition: opacity 0.2s ease, transform 0.2s ease;
1247
+ `;
1248
+ const SuggestionCard = styled.button `
1249
+ display: flex;
1250
+ align-items: center;
1251
+ gap: 10px;
1252
+ width: 100%;
1253
+ min-height: 52px;
1254
+ padding: 9px 12px;
1255
+ border: 1px solid ${TMColors.primary}22;
1256
+ border-radius: 12px;
1257
+ background: linear-gradient(135deg, #ffffff 0%, ${TMColors.primary}08 100%);
1258
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
1259
+ color: #242424;
1260
+ font-family: inherit;
1261
+ font-size: 13px;
1262
+ line-height: 1.35;
1263
+ text-align: left;
1264
+ cursor: pointer;
1265
+ opacity: 0;
1266
+ animation: ${suggestionIn} 0.35s ease-out forwards;
1267
+ animation-delay: ${props => props.$index * 70}ms;
1268
+ transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
1269
+
1270
+ &:hover, &:focus-visible {
1271
+ border-color: ${TMColors.primary}66;
1272
+ background: ${TMColors.primary}0d;
1273
+ box-shadow: 0 4px 14px ${TMColors.primary}1f;
1274
+ transform: translateY(-1px);
1275
+ }
1276
+
1277
+ &:hover ${SuggestionIcon}, &:focus-visible ${SuggestionIcon} {
1278
+ background: ${TMColors.primary};
1279
+ color: white;
1280
+ }
1281
+
1282
+ &:hover ${SuggestionArrow}, &:focus-visible ${SuggestionArrow} {
1283
+ opacity: 1;
1284
+ transform: translateX(0);
1285
+ }
1286
+
1287
+ &:focus-visible {
1288
+ outline: 2px solid ${TMColors.primary}55;
1289
+ outline-offset: 2px;
1290
+ }
1291
+
1292
+ &:active {
1293
+ transform: translateY(0) scale(0.99);
1294
+ }
1295
+
1296
+ @media (prefers-reduced-motion: reduce) {
1297
+ animation: none;
1298
+ opacity: 1;
1299
+ transition: none;
1300
+ }
1301
+ `;
1302
+ const FooterHint = styled.p `
1303
+ margin: 6px 0 0 0;
1304
+ font-size: 11px;
1305
+ color: #999;
1306
+ text-align: center;
1307
+ `;
1308
+ const ChatInputWrapper = styled.div `
1309
+ position: relative;
1310
+ flex: 1;
1311
+ display: flex;
1312
+ `;
1313
+ const ChatInputTextarea = styled.textarea `
1314
+ width: 100%;
1315
+ padding: 14px 60px 14px 16px;
1316
+ border: 2px solid #e1e5e9;
1317
+ border-radius: 12px;
1318
+ font-size: 15px;
1319
+ font-family: inherit;
1320
+ line-height: 1.5;
1321
+ transition: all 0.2s ease;
1322
+ background: #f8f9fa;
1323
+ resize: none;
1324
+ min-height: 100px;
1325
+ max-height: 120px;
1326
+ overflow-y: hidden;
1327
+
1328
+ &:focus {
1329
+ outline: none;
1330
+ border-color: ${TMColors.primary};
1331
+ background: white;
1332
+ box-shadow: 0 0 0 4px ${TMColors.primary}15;
1333
+ }
1334
+
1335
+ &::placeholder {
1336
+ color: #999;
1337
+ }
1338
+
1339
+ &::-webkit-scrollbar {
1340
+ width: 6px;
1341
+ }
1342
+
1343
+ &::-webkit-scrollbar-track {
1344
+ background: transparent;
1345
+ }
1346
+
1347
+ &::-webkit-scrollbar-thumb {
1348
+ background: #ccc;
1349
+ border-radius: 3px;
1350
+ }
1351
+
1352
+ &::-webkit-scrollbar-thumb:hover {
1353
+ background: #999;
1354
+ }
1355
+ `;
1356
+ const InlineSendButton = styled.button `
1357
+ position: absolute;
1358
+ bottom: 8px;
1359
+ right: 8px;
1360
+ width: 40px;
1361
+ height: 40px;
1362
+ border-radius: 10px;
1363
+ background: ${props => props.$disabled ? '#ccc' : '#4caf50'};
1364
+ border: none;
1365
+ color: white;
1366
+ cursor: ${props => props.$disabled ? 'default' : 'pointer'};
1367
+ display: flex;
1368
+ align-items: center;
1369
+ justify-content: center;
1370
+ transition: all 0.2s ease;
1371
+
1372
+ &:hover:not(:disabled) {
1373
+ background: #45a049;
1374
+ transform: scale(1.05);
1375
+ }
1376
+
1377
+ &:active:not(:disabled) {
1378
+ transform: scale(0.95);
1379
+ }
1380
+
1381
+ &:disabled {
1382
+ opacity: 0.6;
1383
+ }
1384
+ `;