xertica-ui 2.1.2 → 2.1.4

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 (181) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +1 -1
  3. package/bin/cli.ts +1 -1
  4. package/bin/generate-tokens.ts +13 -7
  5. package/components/assistant/xertica-assistant/index.ts +2 -0
  6. package/components/assistant/xertica-assistant/parts/AssistantCollapsedView.tsx +97 -0
  7. package/components/assistant/xertica-assistant/parts/AssistantConversationList.tsx +104 -0
  8. package/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.tsx +81 -0
  9. package/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.tsx +86 -0
  10. package/components/assistant/xertica-assistant/parts/AssistantHeader.tsx +77 -0
  11. package/components/assistant/xertica-assistant/parts/AssistantMessageBubble.tsx +573 -0
  12. package/components/assistant/xertica-assistant/parts/AssistantTabBar.tsx +65 -0
  13. package/components/assistant/xertica-assistant/parts/AssistantTypingIndicator.tsx +41 -0
  14. package/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.tsx +98 -0
  15. package/components/assistant/xertica-assistant/parts/index.ts +16 -0
  16. package/components/assistant/xertica-assistant/types.ts +139 -0
  17. package/components/assistant/xertica-assistant/use-assistant.ts +559 -0
  18. package/components/assistant/xertica-assistant/xertica-assistant.stories.tsx +200 -0
  19. package/components/assistant/xertica-assistant/xertica-assistant.tsx +198 -1460
  20. package/components/brand/theme-toggle/ThemeToggle.tsx +8 -27
  21. package/components/hooks/index.ts +3 -0
  22. package/components/hooks/use-layout-shortcuts.ts +46 -0
  23. package/components/layout/sidebar/index.ts +2 -0
  24. package/components/layout/sidebar/sidebar.stories.tsx +160 -8
  25. package/components/layout/sidebar/sidebar.tsx +606 -497
  26. package/components/layout/sidebar/use-sidebar.ts +104 -0
  27. package/components/media/audio-player/AudioPlayer.tsx +131 -206
  28. package/components/media/audio-player/use-audio-player.ts +298 -0
  29. package/components/pages/home-page/HomePage.tsx +1 -1
  30. package/components/pages/template-content/TemplateContent.tsx +5 -5
  31. package/components/pages/template-page/TemplatePage.tsx +5 -5
  32. package/components/shared/CustomTooltipContent.tsx +52 -0
  33. package/components/shared/layout-constants.ts +1 -1
  34. package/components/ui/chart/chart.stories.tsx +966 -7
  35. package/components/ui/chart/chart.tsx +918 -45
  36. package/components/ui/file-upload/file-upload.stories.tsx +100 -0
  37. package/components/ui/file-upload/file-upload.tsx +14 -74
  38. package/components/ui/file-upload/index.ts +1 -0
  39. package/components/ui/file-upload/use-file-upload.ts +181 -0
  40. package/components/ui/pagination/index.ts +2 -0
  41. package/components/ui/pagination/pagination.stories.tsx +94 -0
  42. package/components/ui/pagination/use-pagination.ts +194 -0
  43. package/components/ui/rich-text-editor/index.ts +2 -0
  44. package/components/ui/rich-text-editor/rich-text-editor.stories.tsx +129 -1
  45. package/components/ui/rich-text-editor/rich-text-editor.tsx +86 -305
  46. package/components/ui/rich-text-editor/use-rich-text-editor.ts +439 -0
  47. package/components/ui/stepper/index.ts +3 -1
  48. package/components/ui/stepper/stepper.stories.tsx +116 -0
  49. package/components/ui/stepper/stepper.tsx +4 -4
  50. package/components/ui/stepper/use-stepper.ts +137 -0
  51. package/components/ui/tree-view/index.ts +4 -1
  52. package/components/ui/tree-view/tree-view.stories.tsx +110 -4
  53. package/components/ui/tree-view/tree-view.tsx +17 -125
  54. package/components/ui/tree-view/use-tree-view.ts +229 -0
  55. package/contexts/AssistenteContext.tsx +17 -54
  56. package/contexts/BrandColorsContext.tsx +6 -17
  57. package/contexts/LayoutContext.tsx +5 -31
  58. package/dist/AssistantChart-BAudAfne.cjs +3591 -0
  59. package/dist/AssistantChart-BP8upjMk.js +3565 -0
  60. package/dist/AudioPlayer-1ypwE2Wh.cjs +936 -0
  61. package/dist/AudioPlayer-DuKXrCfy.js +937 -0
  62. package/dist/CustomTooltipContent-DHjkY0ww.js +40 -0
  63. package/dist/CustomTooltipContent-c_K-DWRr.cjs +56 -0
  64. package/dist/LanguageContext-BwhwC3G2.js +657 -0
  65. package/dist/LanguageContext-DvUt5jBg.cjs +656 -0
  66. package/dist/LayoutContext-BDmcZfMH.cjs +84 -0
  67. package/dist/LayoutContext-dbQvdC4O.js +85 -0
  68. package/dist/ThemeContext-RTy1m2Uq.js +82 -0
  69. package/dist/ThemeContext-bSzuOit2.cjs +81 -0
  70. package/dist/VerifyEmailPage-C_ihbcth.js +2828 -0
  71. package/dist/VerifyEmailPage-Dt7zgA4w.cjs +2827 -0
  72. package/dist/XerticaProvider-CW9hpCdF.cjs +39 -0
  73. package/dist/XerticaProvider-siSt9uG2.js +40 -0
  74. package/dist/XerticaXLogo-D8jf0SNv.cjs +214 -0
  75. package/dist/XerticaXLogo-fAJMy3H4.js +215 -0
  76. package/dist/assistant.cjs.js +2 -1
  77. package/dist/assistant.es.js +3 -2
  78. package/dist/brand.cjs.js +2 -2
  79. package/dist/brand.es.js +2 -2
  80. package/dist/cli.js +14 -8
  81. package/dist/components/assistant/xertica-assistant/index.d.ts +2 -0
  82. package/dist/components/assistant/xertica-assistant/parts/AssistantCollapsedView.d.ts +13 -0
  83. package/dist/components/assistant/xertica-assistant/parts/AssistantConversationList.d.ts +16 -0
  84. package/dist/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.d.ts +17 -0
  85. package/dist/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.d.ts +19 -0
  86. package/dist/components/assistant/xertica-assistant/parts/AssistantHeader.d.ts +11 -0
  87. package/dist/components/assistant/xertica-assistant/parts/AssistantMessageBubble.d.ts +29 -0
  88. package/dist/components/assistant/xertica-assistant/parts/AssistantTabBar.d.ts +13 -0
  89. package/dist/components/assistant/xertica-assistant/parts/AssistantTypingIndicator.d.ts +4 -0
  90. package/dist/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.d.ts +17 -0
  91. package/dist/components/assistant/xertica-assistant/parts/index.d.ts +16 -0
  92. package/dist/components/assistant/xertica-assistant/types.d.ts +106 -0
  93. package/dist/components/assistant/xertica-assistant/use-assistant.d.ts +125 -0
  94. package/dist/components/assistant/xertica-assistant/xertica-assistant.d.ts +8 -97
  95. package/dist/components/hooks/index.d.ts +3 -0
  96. package/dist/components/hooks/use-layout-shortcuts.d.ts +22 -0
  97. package/dist/components/layout/sidebar/index.d.ts +2 -0
  98. package/dist/components/layout/sidebar/sidebar.d.ts +80 -0
  99. package/dist/components/layout/sidebar/use-sidebar.d.ts +22 -0
  100. package/dist/components/media/audio-player/AudioPlayer.d.ts +4 -1
  101. package/dist/components/media/audio-player/use-audio-player.d.ts +72 -0
  102. package/dist/components/shared/CustomTooltipContent.d.ts +20 -0
  103. package/dist/components/shared/layout-constants.d.ts +1 -1
  104. package/dist/components/ui/alert/alert.d.ts +1 -1
  105. package/dist/components/ui/badge/badge.d.ts +1 -1
  106. package/dist/components/ui/button/button.d.ts +2 -2
  107. package/dist/components/ui/chart/chart.d.ts +162 -5
  108. package/dist/components/ui/file-upload/file-upload.d.ts +2 -0
  109. package/dist/components/ui/file-upload/index.d.ts +1 -0
  110. package/dist/components/ui/file-upload/use-file-upload.d.ts +49 -0
  111. package/dist/components/ui/pagination/index.d.ts +2 -0
  112. package/dist/components/ui/pagination/use-pagination.d.ts +78 -0
  113. package/dist/components/ui/rich-text-editor/index.d.ts +2 -0
  114. package/dist/components/ui/rich-text-editor/use-rich-text-editor.d.ts +107 -0
  115. package/dist/components/ui/stepper/index.d.ts +3 -1
  116. package/dist/components/ui/stepper/stepper.d.ts +2 -2
  117. package/dist/components/ui/stepper/use-stepper.d.ts +60 -0
  118. package/dist/components/ui/tree-view/index.d.ts +4 -1
  119. package/dist/components/ui/tree-view/tree-view.d.ts +4 -6
  120. package/dist/components/ui/tree-view/use-tree-view.d.ts +60 -0
  121. package/dist/contexts/AssistenteContext.d.ts +10 -49
  122. package/dist/hooks.cjs.js +30 -10
  123. package/dist/hooks.es.js +25 -4
  124. package/dist/index.cjs.js +20 -9
  125. package/dist/index.es.js +38 -27
  126. package/dist/layout.cjs.js +82 -1
  127. package/dist/layout.es.js +83 -2
  128. package/dist/media.cjs.js +1 -1
  129. package/dist/media.es.js +1 -1
  130. package/dist/pages.cjs.js +1 -1
  131. package/dist/pages.es.js +1 -1
  132. package/dist/rich-text-editor-BmsjY03B.js +2949 -0
  133. package/dist/rich-text-editor-GS2kpTAK.cjs +2966 -0
  134. package/dist/sidebar-CVUGHOS_.cjs +756 -0
  135. package/dist/sidebar-CmvwjnVb.js +757 -0
  136. package/dist/ui.cjs.js +12 -2
  137. package/dist/ui.es.js +24 -14
  138. package/dist/use-audio-player-Bkh23vQ3.js +177 -0
  139. package/dist/use-audio-player-Dn1NR9xN.cjs +176 -0
  140. package/dist/utils/color-utils.d.ts +51 -0
  141. package/dist/xertica-assistant-BMqdyRVi.js +2082 -0
  142. package/dist/xertica-assistant-Bj3vBCq_.cjs +2081 -0
  143. package/dist/xertica-ui.css +1 -1
  144. package/docs/ai-usage.md +28 -10
  145. package/docs/architecture-improvements.md +463 -0
  146. package/docs/architecture.md +77 -1
  147. package/docs/components/assistant-chart.md +1 -1
  148. package/docs/components/assistant.md +159 -0
  149. package/docs/components/audio-player.md +46 -0
  150. package/docs/components/branding.md +251 -0
  151. package/docs/components/chart.md +354 -39
  152. package/docs/components/code-block.md +108 -0
  153. package/docs/components/file-upload.md +119 -2
  154. package/docs/components/formatted-document.md +113 -0
  155. package/docs/components/hooks.md +430 -0
  156. package/docs/components/image-with-fallback.md +106 -0
  157. package/docs/components/map-layers.md +140 -0
  158. package/docs/components/modern-chat-input.md +163 -0
  159. package/docs/components/pages.md +351 -0
  160. package/docs/components/pagination.md +187 -0
  161. package/docs/components/rich-text-editor.md +164 -0
  162. package/docs/components/sidebar.md +153 -4
  163. package/docs/components/stepper.md +157 -12
  164. package/docs/components/tree-view.md +164 -6
  165. package/docs/doc-audit.md +223 -0
  166. package/docs/getting-started.md +155 -1
  167. package/docs/guidelines.md +14 -8
  168. package/docs/layout.md +2 -2
  169. package/docs/llms.md +29 -9
  170. package/docs/patterns/detail-page.md +276 -0
  171. package/docs/patterns/settings.md +346 -0
  172. package/docs/patterns/wizard.md +217 -0
  173. package/guidelines/Guidelines.md +5 -3
  174. package/llms.txt +1 -1
  175. package/package.json +10 -10
  176. package/styles/xertica/tokens.css +41 -12
  177. package/templates/CLAUDE.md +16 -6
  178. package/templates/guidelines/Guidelines.md +16 -4
  179. package/templates/package.json +3 -3
  180. package/templates/src/styles/xertica/tokens.css +39 -10
  181. package/utils/color-utils.ts +72 -0
@@ -0,0 +1,2081 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const React = require("react");
4
+ const sonner = require("sonner");
5
+ const lucideReact = require("lucide-react");
6
+ const useMobile = require("./use-mobile-Dlf74ufz.cjs");
7
+ const framerMotion = require("framer-motion");
8
+ const input = require("./input-CPl84zAx.cjs");
9
+ const button = require("./button-0CXwCRTm.cjs");
10
+ const XerticaOrbe = require("./XerticaOrbe-FWGjBj0U.cjs");
11
+ const tooltip = require("./tooltip-CNtsL5cB.cjs");
12
+ const CustomTooltipContent = require("./CustomTooltipContent-c_K-DWRr.cjs");
13
+ const RechartsPrimitive = require("recharts");
14
+ const richTextEditor = require("./rich-text-editor-GS2kpTAK.cjs");
15
+ const dropdownMenu = require("./dropdown-menu-Ze1YZFyc.cjs");
16
+ [
17
+ { id: "rich-1", text: "Ver exemplo de Gráfico", icon: React.createElement(lucideReact.BarChart3, { className: "w-4 h-4 mr-2" }) },
18
+ { id: "rich-2", text: "Ver exemplo de Imagem", icon: React.createElement(lucideReact.ImageIcon, { className: "w-4 h-4 mr-2" }) },
19
+ { id: "rich-3", text: "Ver exemplo de Tabela", icon: React.createElement(lucideReact.Table, { className: "w-4 h-4 mr-2" }) },
20
+ { id: "rich-4", text: "Ver exemplo de Documento", icon: React.createElement(lucideReact.FileText, { className: "w-4 h-4 mr-2" }) }
21
+ ];
22
+ const gerarResposta = (mensagemUsuario, customResponses) => {
23
+ const mensagemLower = mensagemUsuario.toLowerCase();
24
+ if (customResponses && customResponses.length > 0) {
25
+ for (const mock of customResponses) {
26
+ const trigger = mock.trigger;
27
+ let match = false;
28
+ if (trigger instanceof RegExp) {
29
+ match = trigger.test(mensagemUsuario);
30
+ } else {
31
+ match = mensagemLower.includes(trigger.toLowerCase());
32
+ }
33
+ if (match) {
34
+ return mock.response;
35
+ }
36
+ }
37
+ }
38
+ const mensagemOriginal = mensagemUsuario;
39
+ if (mensagemLower.includes("o que") && (mensagemLower.includes("fazer") || mensagemLower.includes("pedir"))) {
40
+ return "Posso ajudar você com diversas tarefas! Posso:\n\n• Analisar dados e métricas dos seus projetos\n• Responder perguntas sobre performance e resultados\n• Sugerir otimizações e melhorias\n• Gerar relatórios e documentação\n• Ajudar no planejamento de sprints\n• E muito mais!\n\nQual tarefa você gostaria de realizar primeiro?";
41
+ }
42
+ if (mensagemLower.includes("o que você faz") || mensagemLower.includes("quem é você")) {
43
+ return "Olá! Sou o Assistente Xertica, uma IA desenvolvida para ajudar você a gerenciar projetos, analisar dados e otimizar processos. Estou aqui 24/7 para responder suas perguntas e auxiliar nas suas tarefas diárias.\n\nPosso processar documentos, analisar áudios e imagens, além de fornecer insights baseados nos dados da plataforma.";
44
+ }
45
+ if (mensagemLower.includes("projeto") && (mensagemLower.includes("preocupar") || mensagemLower.includes("atenção"))) {
46
+ return "Com base na análise dos seus projetos ativos, recomendo focar nos seguintes:\n\n1. **Projeto Alpha** - 15% acima do prazo, requer atenção imediata\n2. **Sistema Beta** - Performance crítica, necessita otimização\n3. **Mobile Gamma** - Aguardando aprovações há 5 dias\n\nGostaria de mais detalhes sobre algum deles?";
47
+ }
48
+ if (mensagemLower.includes("próximo projeto") || mensagemLower.includes("próxima tarefa")) {
49
+ return "Seu próximo projeto prioritário é o **Sistema de Analytics V2**.\n\n📅 Início previsto: Próxima segunda-feira\n👥 Time: 5 desenvolvedores\n⏱️ Duração estimada: 3 sprints\n\nJá preparei um roadmap inicial. Gostaria de revisar?";
50
+ }
51
+ if (mensagemLower.includes("desempenho") || mensagemLower.includes("performance") || mensagemLower.includes("melhor")) {
52
+ return "Analisando os dados de performance dos últimos 30 dias:\n\n🏆 **Melhor Performance:**\n• Projeto Dashboard 2.0: +35% eficiência\n• Sistema CRM: -40% tempo de resposta\n• App Mobile: 4.8★ rating (+0.5)\n\n📊 Todos estão acima das metas estabelecidas. Parabéns!\n\nQuer ver métricas detalhadas?";
53
+ }
54
+ if (mensagemLower.includes("olá") || mensagemLower.includes("oi") || mensagemLower.includes("bom dia") || mensagemLower.includes("boa tarde") || mensagemLower.includes("boa noite")) {
55
+ return "Olá! 👋 Como posso ajudar você hoje? Estou pronto para auxiliar com análises, relatórios ou responder suas dúvidas sobre os projetos.";
56
+ }
57
+ if (mensagemLower.includes("obrigado") || mensagemLower.includes("obrigada")) {
58
+ return "Por nada! Estou aqui sempre que precisar. 😊 Se tiver mais alguma dúvida ou precisar de ajuda, é só chamar!";
59
+ }
60
+ if (mensagemLower.includes("criar documento")) {
61
+ const tema = mensagemOriginal.replace(/📄 \[Criar documento\]/gi, "").trim() || "Novo Documento";
62
+ return {
63
+ content: `📝 Documento criado com sucesso!
64
+
65
+ Gerei um documento completo sobre "${tema}". O documento está pronto para revisão e pode ser editado conforme necessário.`,
66
+ attachmentType: "document",
67
+ attachmentName: `Documento - ${tema}.md`,
68
+ documentTitle: tema,
69
+ documentContent: `# ${tema}
70
+
71
+ ## Introdução
72
+ Este é um documento gerado automaticamente sobre ${tema}.
73
+
74
+ ## Detalhes
75
+ - Item 1
76
+ - Item 2
77
+
78
+ ## Conclusão
79
+ Documento finalizado.`
80
+ };
81
+ }
82
+ if (mensagemLower.includes("gráfico") || mensagemLower.includes("chart")) {
83
+ return {
84
+ content: "Aqui está a análise de performance solicitada:",
85
+ chartData: [
86
+ { month: "Jan", desktop: 186, mobile: 80 },
87
+ { month: "Fev", desktop: 305, mobile: 200 },
88
+ { month: "Mar", desktop: 237, mobile: 120 },
89
+ { month: "Abr", desktop: 73, mobile: 190 },
90
+ { month: "Mai", desktop: 209, mobile: 130 },
91
+ { month: "Jun", desktop: 214, mobile: 140 }
92
+ ],
93
+ chartConfig: {
94
+ desktop: { label: "Desktop", color: "hsl(var(--primary))" },
95
+ mobile: { label: "Mobile", color: "hsl(var(--destructive))" }
96
+ }
97
+ };
98
+ }
99
+ if (mensagemLower.includes("tabela") || mensagemLower.includes("table")) {
100
+ return {
101
+ content: "Aqui estão os dados estruturados conforme solicitado:",
102
+ tableData: {
103
+ caption: "Lista de Projetos Ativos",
104
+ headers: ["Projeto", "Status", "Prazo"],
105
+ rows: [
106
+ ["Alpha", "Em andamento", "15/05"],
107
+ ["Beta", "Concluido", "02/04"],
108
+ ["Gamma", "Atrasado", "10/01"]
109
+ ]
110
+ }
111
+ };
112
+ }
113
+ if (mensagemLower.includes("exemplo de documento")) {
114
+ return {
115
+ content: "Com certeza! Aqui está um exemplo de documento profissional que acabei de gerar:",
116
+ attachmentType: "document",
117
+ attachmentName: "Proposta_Comercial_Xertica.md",
118
+ documentTitle: "Proposta Comercial Xertica",
119
+ documentContent: "# Proposta Comercial\n\n## 1. Visão Geral\nNossa solução oferece o melhor desempenho para sua empresa.\n\n## 2. Investimento\nO valor total é de R$ 50.000,00."
120
+ };
121
+ }
122
+ if (mensagemLower.includes("arquivo") || mensagemLower.includes("documento")) {
123
+ return "Entendi que você deseja trabalhar com arquivos. Posso analisar diversos tipos de documentos:\n\n📄 Documentos de texto (PDF, DOCX)\n📊 Planilhas (XLSX, CSV)\n📈 Relatórios e apresentações\n\nBasta enviá-los usando o botão de anexo (📎) e terei prazer em analisá-los para você!";
124
+ }
125
+ const respostasGenericas = [
126
+ "Entendo sua questão. Com base nos dados disponíveis na plataforma Xertica, posso fornecer análises detalhadas sobre esse tema. Poderia me dar mais contexto para que eu possa ajudá-lo melhor?",
127
+ "Interessante! Deixe-me processar isso... Com base no seu histórico e nos dados do sistema, recomendo que possamos explorar essa questão em mais detalhes. O que especificamente você gostaria de saber?",
128
+ "Ótima pergunta! Para te dar a melhor resposta possível, preciso entender melhor o contexto. Você pode me fornecer mais informações sobre o que está buscando?",
129
+ "Estou analisando sua solicitação. Baseado nos dados do sistema Xertica, posso te ajudar com isso. Você gostaria de uma análise rápida ou um relatório completo?"
130
+ ];
131
+ return respostasGenericas[Math.floor(Math.random() * respostasGenericas.length)];
132
+ };
133
+ const DEFAULT_SUGGESTIONS = [
134
+ { id: "1", text: "Me ajude a criar um documento profissional" },
135
+ { id: "2", text: 'Buscar nos meus arquivos por "relatório"' },
136
+ { id: "3", text: "Resuma as conversas importantes desta semana" },
137
+ { id: "4", text: "Crie um podcast sobre o último projeto" }
138
+ ];
139
+ function useAssistant({
140
+ mode = "expanded",
141
+ isExpanded: controlledIsExpanded,
142
+ onToggle,
143
+ defaultTab = "chat",
144
+ demoMode = true,
145
+ customResponses = [],
146
+ initialMessages = [],
147
+ savedConversations = [],
148
+ suggestions: propSuggestions,
149
+ onSendMessage,
150
+ isProcessing = false,
151
+ responseGenerator,
152
+ richSuggestions = [],
153
+ onRichAction,
154
+ onEvaluation
155
+ } = {}) {
156
+ const isFullPage = mode === "fullPage";
157
+ const [internalIsExpanded, setInternalIsExpanded] = React.useState(controlledIsExpanded ?? true);
158
+ const isExpanded = controlledIsExpanded ?? internalIsExpanded;
159
+ const isMobile = useMobile.useIsMobile();
160
+ const [abaSelecionada, setAbaSelecionada] = React.useState(defaultTab);
161
+ const [mensagens, setMensagens] = React.useState(initialMessages);
162
+ const [mensagem, setMensagem] = React.useState("");
163
+ const [conversas, setConversas] = React.useState(savedConversations);
164
+ const [conversaAtual, setConversaAtual] = React.useState(null);
165
+ const [copiedId, setCopiedId] = React.useState(null);
166
+ const [generatingPodcastId, setGeneratingPodcastId] = React.useState(null);
167
+ const [executingCommand, setExecutingCommand] = React.useState(null);
168
+ const [savedSearches, setSavedSearches] = React.useState([]);
169
+ const [editingDocument, setEditingDocument] = React.useState(null);
170
+ const [showMoreSuggestions, setShowMoreSuggestions] = React.useState(false);
171
+ const [evaluationState, setEvaluationState] = React.useState({
172
+ isOpen: false,
173
+ messageId: null,
174
+ type: null,
175
+ category: null,
176
+ reason: ""
177
+ });
178
+ const messagesEndRef = React.useRef(null);
179
+ const fileInputRef = React.useRef(null);
180
+ const audioInputRef = React.useRef(null);
181
+ const sugestoes = propSuggestions ?? DEFAULT_SUGGESTIONS;
182
+ React.useEffect(() => {
183
+ if (messagesEndRef.current && abaSelecionada === "chat") {
184
+ messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
185
+ }
186
+ }, [mensagens, abaSelecionada]);
187
+ React.useEffect(() => {
188
+ if (initialMessages && initialMessages.length > 0) {
189
+ setMensagens(initialMessages);
190
+ }
191
+ }, [initialMessages]);
192
+ const conversasFiltradas = conversas.filter((conversa) => {
193
+ if (abaSelecionada === "favoritos") return conversa.isFavorite;
194
+ return true;
195
+ });
196
+ const handleToggle = React.useCallback(() => {
197
+ if (onToggle) {
198
+ onToggle();
199
+ } else {
200
+ setInternalIsExpanded((prev) => !prev);
201
+ }
202
+ }, [onToggle]);
203
+ const handleExpandWithTab = React.useCallback((tab) => {
204
+ setAbaSelecionada(tab);
205
+ if (onToggle) {
206
+ onToggle();
207
+ } else {
208
+ setInternalIsExpanded(true);
209
+ }
210
+ }, [onToggle]);
211
+ const handleEnviarMensagem = React.useCallback(async (arg) => {
212
+ let msgToSend = mensagem;
213
+ if (typeof arg === "string" && !["document", "podcast", "search"].includes(arg)) {
214
+ msgToSend = arg;
215
+ }
216
+ if (!msgToSend.trim() || isProcessing) return;
217
+ const novaMensagem = {
218
+ id: `msg-${Date.now()}`,
219
+ type: "user",
220
+ content: msgToSend,
221
+ timestamp: /* @__PURE__ */ new Date(),
222
+ isFavorite: false
223
+ };
224
+ setMensagens((prev) => [...prev, novaMensagem]);
225
+ if (onSendMessage) {
226
+ onSendMessage(msgToSend);
227
+ }
228
+ if (demoMode || responseGenerator) {
229
+ const mensagemAtual = msgToSend;
230
+ setTimeout(async () => {
231
+ let resposta;
232
+ if (responseGenerator) {
233
+ resposta = await responseGenerator(mensagemAtual);
234
+ } else {
235
+ resposta = gerarResposta(mensagemAtual, customResponses);
236
+ }
237
+ let novaMensagemIA = {
238
+ id: `msg-${Date.now()}-ia`,
239
+ type: "assistant",
240
+ content: "",
241
+ timestamp: /* @__PURE__ */ new Date(),
242
+ isFavorite: false
243
+ };
244
+ if (typeof resposta === "string") {
245
+ novaMensagemIA.content = resposta;
246
+ } else {
247
+ novaMensagemIA = { ...novaMensagemIA, ...resposta };
248
+ }
249
+ setMensagens((prev) => [...prev, novaMensagemIA]);
250
+ }, 1e3 + Math.random() * 1e3);
251
+ }
252
+ setMensagem("");
253
+ }, [mensagem, isProcessing, onSendMessage, demoMode, responseGenerator, customResponses]);
254
+ const handleToggleFavorite = React.useCallback((messageId) => {
255
+ setMensagens(
256
+ (prev) => prev.map(
257
+ (msg) => msg.id === messageId ? { ...msg, isFavorite: !msg.isFavorite } : msg
258
+ )
259
+ );
260
+ }, []);
261
+ const handleCopyMessage = React.useCallback(async (content, messageId) => {
262
+ try {
263
+ if (navigator.clipboard && navigator.clipboard.writeText) {
264
+ try {
265
+ await navigator.clipboard.writeText(content);
266
+ setCopiedId(messageId);
267
+ setTimeout(() => setCopiedId(null), 2e3);
268
+ } catch (clipboardError) {
269
+ if (clipboardError.name === "NotAllowedError" || clipboardError.message.includes("permissions policy")) {
270
+ throw new Error("Clipboard permission denied, falling back");
271
+ }
272
+ throw clipboardError;
273
+ }
274
+ } else {
275
+ throw new Error("Clipboard API not available");
276
+ }
277
+ } catch {
278
+ try {
279
+ const textArea = document.createElement("textarea");
280
+ textArea.value = content;
281
+ textArea.style.position = "fixed";
282
+ textArea.style.left = "-999999px";
283
+ textArea.style.top = "-999999px";
284
+ document.body.appendChild(textArea);
285
+ textArea.focus();
286
+ textArea.select();
287
+ const successful = document.execCommand("copy");
288
+ document.body.removeChild(textArea);
289
+ if (successful) {
290
+ setCopiedId(messageId);
291
+ setTimeout(() => setCopiedId(null), 2e3);
292
+ }
293
+ } catch (fallbackErr) {
294
+ console.error("Falha ao copiar:", fallbackErr);
295
+ }
296
+ }
297
+ }, []);
298
+ const handleGeneratePodcast = React.useCallback(async (messageId, content) => {
299
+ setGeneratingPodcastId(messageId);
300
+ setTimeout(() => {
301
+ setMensagens(
302
+ (prev) => prev.map(
303
+ (msg) => msg.id === messageId ? {
304
+ ...msg,
305
+ attachmentType: "podcast",
306
+ attachmentName: "Podcast - " + content.substring(0, 30) + "...",
307
+ audioUrl: "data:audio/mpeg;base64,//uQx..."
308
+ } : msg
309
+ )
310
+ );
311
+ setGeneratingPodcastId(null);
312
+ }, 2e3);
313
+ }, []);
314
+ const handleDownloadDocument = React.useCallback((content, fileName) => {
315
+ const blob = new Blob([content], { type: "text/markdown" });
316
+ const url = URL.createObjectURL(blob);
317
+ const a = document.createElement("a");
318
+ a.href = url;
319
+ a.download = fileName.endsWith(".md") ? fileName : fileName + ".md";
320
+ document.body.appendChild(a);
321
+ a.click();
322
+ document.body.removeChild(a);
323
+ URL.revokeObjectURL(url);
324
+ }, []);
325
+ const handleDownloadPodcast = React.useCallback((audioUrl, fileName) => {
326
+ const a = document.createElement("a");
327
+ a.href = audioUrl;
328
+ a.download = fileName.endsWith(".mp3") ? fileName : fileName + ".mp3";
329
+ document.body.appendChild(a);
330
+ a.click();
331
+ document.body.removeChild(a);
332
+ }, []);
333
+ const handleEditDocument = React.useCallback((content, title) => {
334
+ setEditingDocument({ content, title });
335
+ }, []);
336
+ const handleNovaConversa = React.useCallback(() => {
337
+ setMensagens([]);
338
+ setConversaAtual(null);
339
+ setAbaSelecionada("chat");
340
+ }, []);
341
+ const handleSelecionarConversa = React.useCallback((conversaId) => {
342
+ const conversa = conversas.find((c) => c.id === conversaId);
343
+ if (conversa) {
344
+ setMensagens(conversa.messages);
345
+ setConversaAtual(conversaId);
346
+ setAbaSelecionada("chat");
347
+ }
348
+ }, [conversas]);
349
+ const handleToggleFavoritaConversa = React.useCallback((conversaId) => {
350
+ setConversas(
351
+ (prev) => prev.map(
352
+ (conv) => conv.id === conversaId ? { ...conv, isFavorite: !conv.isFavorite } : conv
353
+ )
354
+ );
355
+ }, []);
356
+ const handleOpenSearchResult = React.useCallback((result) => {
357
+ console.log("Abrir resultado:", result);
358
+ }, []);
359
+ const handleExecuteSearchCommand = React.useCallback(async (commandId, searchTerm, results, messageId) => {
360
+ setExecutingCommand(commandId);
361
+ setTimeout(() => {
362
+ if (commandId === "5") {
363
+ setSavedSearches((prev) => [...prev, messageId]);
364
+ }
365
+ setExecutingCommand(null);
366
+ }, 1500);
367
+ }, []);
368
+ const handleRichSuggestionClick = React.useCallback((suggestion) => {
369
+ if (onRichAction) {
370
+ onRichAction(suggestion.id, suggestion.text);
371
+ } else {
372
+ handleEnviarMensagem(suggestion.text);
373
+ }
374
+ setShowMoreSuggestions(false);
375
+ }, [onRichAction, handleEnviarMensagem]);
376
+ const handleEvaluationClick = React.useCallback((messageId, type) => {
377
+ if (type === "like") {
378
+ if (onEvaluation) onEvaluation(messageId, "like");
379
+ setMensagens((prev) => prev.map((m) => m.id === messageId ? { ...m, evaluation: "like" } : m));
380
+ sonner.toast.success("Obrigado por avaliar positivamente!");
381
+ }
382
+ }, [onEvaluation]);
383
+ const openFeedbackDialog = React.useCallback((messageId, category) => {
384
+ setEvaluationState({
385
+ isOpen: true,
386
+ messageId,
387
+ type: "dislike",
388
+ category,
389
+ reason: ""
390
+ });
391
+ }, []);
392
+ const handleSubmitDislike = React.useCallback(() => {
393
+ if (evaluationState.messageId) {
394
+ const finalReason = evaluationState.category ? evaluationState.reason ? `${evaluationState.category}: ${evaluationState.reason}` : evaluationState.category : evaluationState.reason;
395
+ if (onEvaluation) {
396
+ onEvaluation(evaluationState.messageId, "dislike", finalReason);
397
+ }
398
+ setMensagens(
399
+ (prev) => prev.map(
400
+ (m) => m.id === evaluationState.messageId ? { ...m, evaluation: "dislike", evaluationReason: finalReason } : m
401
+ )
402
+ );
403
+ sonner.toast.success("Obrigado pelo seu feedback. Vamos melhorar.");
404
+ }
405
+ setEvaluationState({ isOpen: false, messageId: null, type: null, category: null, reason: "" });
406
+ }, [evaluationState, onEvaluation]);
407
+ return {
408
+ // Layout
409
+ isFullPage,
410
+ isExpanded,
411
+ isMobile,
412
+ abaSelecionada,
413
+ setAbaSelecionada,
414
+ // Messages
415
+ mensagens,
416
+ setMensagens,
417
+ mensagem,
418
+ setMensagem,
419
+ // Conversations
420
+ conversas,
421
+ conversaAtual,
422
+ conversasFiltradas,
423
+ // UI
424
+ copiedId,
425
+ generatingPodcastId,
426
+ executingCommand,
427
+ savedSearches,
428
+ editingDocument,
429
+ setEditingDocument,
430
+ showMoreSuggestions,
431
+ setShowMoreSuggestions,
432
+ evaluationState,
433
+ setEvaluationState,
434
+ // Suggestions
435
+ sugestoes,
436
+ // Refs
437
+ messagesEndRef,
438
+ fileInputRef,
439
+ audioInputRef,
440
+ // Handlers
441
+ handleToggle,
442
+ handleExpandWithTab,
443
+ handleEnviarMensagem,
444
+ handleToggleFavorite,
445
+ handleCopyMessage,
446
+ handleGeneratePodcast,
447
+ handleDownloadDocument,
448
+ handleDownloadPodcast,
449
+ handleEditDocument,
450
+ handleNovaConversa,
451
+ handleSelecionarConversa,
452
+ handleToggleFavoritaConversa,
453
+ handleOpenSearchResult,
454
+ handleExecuteSearchCommand,
455
+ handleRichSuggestionClick,
456
+ handleEvaluationClick,
457
+ openFeedbackDialog,
458
+ handleSubmitDislike
459
+ };
460
+ }
461
+ function ModernChatInput({
462
+ value,
463
+ onChange,
464
+ onSubmit,
465
+ placeholder = "Mande uma mensagem para o Xertica",
466
+ disabled = false,
467
+ onFileUpload,
468
+ onAudioUpload,
469
+ onVoiceRecording,
470
+ isFullPage = false,
471
+ enableAudioInput = true,
472
+ enableFileAttachment = true,
473
+ enableDocumentCreation = true,
474
+ enablePodcastGeneration = true,
475
+ enableSearch = true
476
+ }) {
477
+ const textareaRef = React.useRef(null);
478
+ const [isFocused, setIsFocused] = React.useState(false);
479
+ const [textareaHeight, setTextareaHeight] = React.useState(20);
480
+ const [selectedAction, setSelectedAction] = React.useState(null);
481
+ const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
482
+ const [isRecording, setIsRecording] = React.useState(false);
483
+ const [recordingTime, setRecordingTime] = React.useState(0);
484
+ const recordingIntervalRef = React.useRef(null);
485
+ const adjustHeight = () => {
486
+ const textarea = textareaRef.current;
487
+ if (textarea) {
488
+ textarea.style.height = "20px";
489
+ const scrollHeight = textarea.scrollHeight;
490
+ const newHeight = Math.min(Math.max(scrollHeight, 20), 100);
491
+ setTextareaHeight(newHeight);
492
+ textarea.style.height = newHeight + "px";
493
+ }
494
+ };
495
+ React.useEffect(() => {
496
+ const textarea = textareaRef.current;
497
+ if (textarea) {
498
+ textarea.style.height = "20px";
499
+ setTextareaHeight(20);
500
+ if (value) {
501
+ setTimeout(adjustHeight, 0);
502
+ }
503
+ }
504
+ }, []);
505
+ React.useEffect(() => {
506
+ if (value === "") {
507
+ const textarea = textareaRef.current;
508
+ if (textarea) {
509
+ textarea.style.height = "20px";
510
+ setTextareaHeight(20);
511
+ }
512
+ } else {
513
+ const timeoutId = setTimeout(adjustHeight, 0);
514
+ return () => clearTimeout(timeoutId);
515
+ }
516
+ }, [value]);
517
+ const handleKeyDown = (e) => {
518
+ if (e.key === "Enter" && !e.shiftKey) {
519
+ e.preventDefault();
520
+ if (value.trim() && !disabled) {
521
+ onSubmit(selectedAction);
522
+ setSelectedAction(null);
523
+ }
524
+ }
525
+ };
526
+ const handleActionSelect = (action) => {
527
+ setSelectedAction(action);
528
+ setIsPopoverOpen(false);
529
+ };
530
+ const handleRemoveAction = () => {
531
+ setSelectedAction(null);
532
+ };
533
+ const handleVoiceRecording = () => {
534
+ if (isRecording) {
535
+ if (recordingIntervalRef.current) {
536
+ clearInterval(recordingIntervalRef.current);
537
+ recordingIntervalRef.current = null;
538
+ }
539
+ const transcricoes = [
540
+ "Como posso analisar os dados de vendas do último trimestre?",
541
+ "Me ajude a criar um relatório de performance do time",
542
+ "Quais são as principais tendências do mercado atual?",
543
+ "Preciso de insights sobre a satisfação dos clientes",
544
+ "Como posso melhorar a produtividade da minha equipe?",
545
+ "Me mostre um resumo das métricas mais importantes",
546
+ "Crie um documento sobre técnicas de marketing digital",
547
+ "Analise os dados de engajamento das redes sociais"
548
+ ];
549
+ const transcricaoAleatoria = transcricoes[Math.floor(Math.random() * transcricoes.length)];
550
+ if (onVoiceRecording) {
551
+ onVoiceRecording(transcricaoAleatoria);
552
+ }
553
+ setIsRecording(false);
554
+ setRecordingTime(0);
555
+ } else {
556
+ setIsRecording(true);
557
+ setRecordingTime(0);
558
+ sonner.toast.info("Gravação iniciada", {
559
+ description: "Fale sua dúvida ou comando. A gravação parará automaticamente em 60s.",
560
+ duration: 3e3
561
+ });
562
+ recordingIntervalRef.current = setInterval(() => {
563
+ setRecordingTime((prev) => prev + 1);
564
+ }, 1e3);
565
+ }
566
+ };
567
+ React.useEffect(() => {
568
+ if (recordingTime >= 60 && isRecording) {
569
+ handleVoiceRecording();
570
+ }
571
+ }, [recordingTime, isRecording]);
572
+ React.useEffect(() => {
573
+ return () => {
574
+ if (recordingIntervalRef.current) {
575
+ clearInterval(recordingIntervalRef.current);
576
+ }
577
+ };
578
+ }, []);
579
+ const getActionInfo = (action) => {
580
+ switch (action) {
581
+ case "document":
582
+ return { label: "Criar documento", icon: lucideReact.FileText, color: "bg-[var(--chart-4)]" };
583
+ case "podcast":
584
+ return { label: "Gerar podcast", icon: lucideReact.Radio, color: "bg-[var(--chart-1)]" };
585
+ case "search":
586
+ return { label: "Pesquisar", icon: lucideReact.Search, color: "bg-[var(--chart-2)]" };
587
+ default:
588
+ return null;
589
+ }
590
+ };
591
+ const handleFocus = () => setIsFocused(true);
592
+ const handleBlur = () => setIsFocused(false);
593
+ const hasContent = value.trim().length > 0;
594
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `p-4 ${isFullPage ? "mx-auto w-full max-w-6xl" : ""}`, children: [
595
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isRecording && /* @__PURE__ */ jsxRuntime.jsx(
596
+ framerMotion.motion.div,
597
+ {
598
+ initial: { opacity: 0, y: 10 },
599
+ animate: { opacity: 1, y: 0 },
600
+ exit: { opacity: 0, y: 10 },
601
+ className: "mb-3 p-4 bg-destructive/10 border border-destructive/30 rounded-[var(--radius-card)]",
602
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
603
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
604
+ /* @__PURE__ */ jsxRuntime.jsx(
605
+ framerMotion.motion.div,
606
+ {
607
+ animate: {
608
+ scale: [1, 1.2, 1],
609
+ opacity: [1, 0.7, 1]
610
+ },
611
+ transition: {
612
+ duration: 1.5,
613
+ repeat: Infinity,
614
+ ease: "easeInOut"
615
+ },
616
+ className: "w-3 h-3 bg-destructive rounded-full"
617
+ }
618
+ ),
619
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1", children: [0, 1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxRuntime.jsx(
620
+ framerMotion.motion.div,
621
+ {
622
+ animate: {
623
+ height: ["8px", "20px", "8px"]
624
+ },
625
+ transition: {
626
+ duration: 0.8,
627
+ repeat: Infinity,
628
+ ease: "easeInOut",
629
+ delay: i * 0.1
630
+ },
631
+ className: "w-1 bg-destructive rounded-full h-2"
632
+ },
633
+ i
634
+ )) }),
635
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-destructive", children: "Gravando áudio" })
636
+ ] }),
637
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
638
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-destructive font-mono tabular-nums", children: [
639
+ Math.floor(recordingTime / 60),
640
+ ":",
641
+ (recordingTime % 60).toString().padStart(2, "0")
642
+ ] }),
643
+ /* @__PURE__ */ jsxRuntime.jsx(
644
+ button.Button,
645
+ {
646
+ onClick: handleVoiceRecording,
647
+ size: "sm",
648
+ variant: "outline",
649
+ className: "h-7 px-3 text-xs border-destructive/30 text-destructive hover:bg-destructive/10 rounded-[var(--radius-button)]",
650
+ children: "Parar gravação"
651
+ }
652
+ )
653
+ ] })
654
+ ] })
655
+ }
656
+ ) }),
657
+ /* @__PURE__ */ jsxRuntime.jsxs(
658
+ framerMotion.motion.div,
659
+ {
660
+ className: `relative bg-card rounded-[var(--radius)] border shadow-sm transition-all duration-300 ${isFocused || hasContent ? "border-primary shadow-lg shadow-primary/10" : "border-border"}`,
661
+ initial: false,
662
+ animate: {
663
+ scale: isFocused ? 1.01 : 1
664
+ },
665
+ transition: { duration: 0.2, ease: "easeOut" },
666
+ children: [
667
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-2 pt-[14px] pr-[10px] pb-[8px] pl-[10px] rounded-[var(--radius)]", children: [
668
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: selectedAction && /* @__PURE__ */ jsxRuntime.jsx(
669
+ framerMotion.motion.div,
670
+ {
671
+ initial: { opacity: 0, y: -10, height: 0 },
672
+ animate: { opacity: 1, y: 0, height: "auto" },
673
+ exit: { opacity: 0, y: -10, height: 0 },
674
+ transition: { duration: 0.2 },
675
+ className: "mb-2",
676
+ children: (() => {
677
+ const actionInfo = getActionInfo(selectedAction);
678
+ if (!actionInfo) return null;
679
+ const Icon = actionInfo.icon;
680
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex items-center gap-2 px-3 py-1.5 rounded-full ${actionInfo.color} text-white text-xs font-medium shadow-sm`, children: [
681
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "w-3.5 h-3.5" }),
682
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: actionInfo.label }),
683
+ /* @__PURE__ */ jsxRuntime.jsx(
684
+ "button",
685
+ {
686
+ onClick: handleRemoveAction,
687
+ className: "ml-1 hover:bg-white/20 rounded-full p-0.5 transition-colors",
688
+ "aria-label": "Remover ação",
689
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3 h-3" })
690
+ }
691
+ )
692
+ ] });
693
+ })()
694
+ }
695
+ ) }),
696
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsxRuntime.jsx(
697
+ "textarea",
698
+ {
699
+ ref: textareaRef,
700
+ value,
701
+ onChange: (e) => onChange(e.target.value),
702
+ onKeyDown: handleKeyDown,
703
+ onFocus: handleFocus,
704
+ onBlur: handleBlur,
705
+ placeholder,
706
+ "aria-label": placeholder || "Mensagem para o Xertica",
707
+ disabled,
708
+ className: "w-full bg-transparent border-0 outline-none resize-none text-foreground placeholder-muted-foreground text-sm leading-5 min-h-[20px] max-h-[100px] overflow-y-auto scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",
709
+ style: {
710
+ height: `${textareaHeight}px`,
711
+ minHeight: "20px",
712
+ maxHeight: "100px"
713
+ },
714
+ rows: 1
715
+ }
716
+ ) }),
717
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
718
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
719
+ (enableDocumentCreation || enablePodcastGeneration || enableSearch) && /* @__PURE__ */ jsxRuntime.jsxs(input.Popover, { open: isPopoverOpen, onOpenChange: setIsPopoverOpen, children: [
720
+ /* @__PURE__ */ jsxRuntime.jsx(input.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
721
+ button.Button,
722
+ {
723
+ variant: "ghost",
724
+ size: "sm",
725
+ className: "h-8 w-8 p-0 rounded-full text-muted-foreground hover:bg-accent hover:text-foreground transition-all duration-200",
726
+ "aria-label": "Ver ações",
727
+ children: /* @__PURE__ */ jsxRuntime.jsx(
728
+ framerMotion.motion.div,
729
+ {
730
+ whileHover: { scale: 1.05 },
731
+ whileTap: { scale: 0.95 },
732
+ className: "flex items-center justify-center w-full h-full",
733
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-4 h-4" })
734
+ }
735
+ )
736
+ }
737
+ ) }),
738
+ /* @__PURE__ */ jsxRuntime.jsx(
739
+ input.PopoverContent,
740
+ {
741
+ className: "w-56 p-2",
742
+ align: "start",
743
+ side: "top",
744
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
745
+ enableDocumentCreation && /* @__PURE__ */ jsxRuntime.jsxs(
746
+ "button",
747
+ {
748
+ onClick: () => handleActionSelect("document"),
749
+ className: "w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent transition-colors text-left group",
750
+ children: [
751
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-8 rounded-full bg-[var(--chart-4)]/20 flex items-center justify-center group-hover:bg-[var(--chart-4)] transition-colors", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "w-4 h-4 text-[var(--chart-4)] group-hover:text-white" }) }),
752
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
753
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Criar documento" }),
754
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground", children: "Gere um documento completo" })
755
+ ] })
756
+ ]
757
+ }
758
+ ),
759
+ enablePodcastGeneration && /* @__PURE__ */ jsxRuntime.jsxs(
760
+ "button",
761
+ {
762
+ onClick: () => handleActionSelect("podcast"),
763
+ className: "w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent transition-colors text-left group",
764
+ children: [
765
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-8 rounded-full bg-[var(--chart-1)]/20 flex items-center justify-center group-hover:bg-[var(--chart-1)] transition-colors", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Radio, { className: "w-4 h-4 text-[var(--chart-1)] group-hover:text-white" }) }),
766
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
767
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Gerar podcast" }),
768
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground", children: "Crie um podcast de áudio" })
769
+ ] })
770
+ ]
771
+ }
772
+ ),
773
+ enableSearch && /* @__PURE__ */ jsxRuntime.jsxs(
774
+ "button",
775
+ {
776
+ onClick: () => handleActionSelect("search"),
777
+ className: "w-full flex items-center gap-3 px-3 py-2.5 rounded-lg hover:bg-accent transition-colors text-left group",
778
+ children: [
779
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-8 rounded-full bg-[var(--chart-2)]/20 flex items-center justify-center group-hover:bg-[var(--chart-2)] transition-colors", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-4 h-4 text-[var(--chart-2)] group-hover:text-white" }) }),
780
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
781
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Pesquisar" }),
782
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground", children: "Busque por informações relevantes" })
783
+ ] })
784
+ ]
785
+ }
786
+ )
787
+ ] })
788
+ }
789
+ )
790
+ ] }),
791
+ enableFileAttachment && /* @__PURE__ */ jsxRuntime.jsx(
792
+ framerMotion.motion.div,
793
+ {
794
+ whileHover: { scale: 1.05 },
795
+ whileTap: { scale: 0.95 },
796
+ children: /* @__PURE__ */ jsxRuntime.jsx(
797
+ button.Button,
798
+ {
799
+ variant: "ghost",
800
+ size: "sm",
801
+ onClick: onFileUpload,
802
+ className: "h-8 w-8 p-0 rounded-full text-muted-foreground hover:bg-accent hover:text-foreground transition-all duration-200",
803
+ "aria-label": "Anexar arquivo",
804
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Paperclip, { className: "w-4 h-4" })
805
+ }
806
+ )
807
+ }
808
+ )
809
+ ] }),
810
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
811
+ enableAudioInput && /* @__PURE__ */ jsxRuntime.jsx(
812
+ framerMotion.motion.div,
813
+ {
814
+ whileHover: { scale: 1.05 },
815
+ whileTap: { scale: 0.95 },
816
+ children: /* @__PURE__ */ jsxRuntime.jsx(
817
+ button.Button,
818
+ {
819
+ variant: "ghost",
820
+ size: "sm",
821
+ onClick: handleVoiceRecording,
822
+ className: `h-8 w-8 p-0 rounded-full transition-all duration-200 ${isRecording ? "bg-destructive hover:bg-destructive/90 text-white animate-pulse" : "text-muted-foreground hover:bg-accent hover:text-foreground"}`,
823
+ "aria-label": isRecording ? "Parar gravação" : "Sugerir com voz",
824
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "w-4 h-4" })
825
+ }
826
+ )
827
+ }
828
+ ),
829
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsxRuntime.jsx(
830
+ framerMotion.motion.div,
831
+ {
832
+ initial: { scale: 0.8, opacity: 0 },
833
+ animate: { scale: 1, opacity: 1 },
834
+ exit: { scale: 0.8, opacity: 0 },
835
+ transition: { duration: 0.2, ease: "easeInOut" },
836
+ whileHover: hasContent ? { scale: 1.05 } : {},
837
+ whileTap: hasContent ? { scale: 0.95 } : {},
838
+ children: /* @__PURE__ */ jsxRuntime.jsx(
839
+ button.Button,
840
+ {
841
+ onClick: () => {
842
+ onSubmit(selectedAction);
843
+ setSelectedAction(null);
844
+ },
845
+ size: "sm",
846
+ disabled: !hasContent || disabled,
847
+ className: `h-8 w-8 p-0 rounded-full transition-all duration-300 ${hasContent && !disabled ? "bg-primary hover:bg-primary/90 text-primary-foreground shadow-lg shadow-primary/30 hover:shadow-primary/40" : "bg-muted text-muted-foreground cursor-not-allowed"}`,
848
+ "aria-label": "Enviar mensagem",
849
+ children: /* @__PURE__ */ jsxRuntime.jsx(
850
+ framerMotion.motion.div,
851
+ {
852
+ animate: {
853
+ rotate: hasContent ? 0 : -45
854
+ },
855
+ transition: { duration: 0.2 },
856
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "w-4 h-4" })
857
+ }
858
+ )
859
+ }
860
+ )
861
+ },
862
+ hasContent ? "active" : "inactive"
863
+ ) })
864
+ ] })
865
+ ] })
866
+ ] }),
867
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isFocused && /* @__PURE__ */ jsxRuntime.jsx(
868
+ framerMotion.motion.div,
869
+ {
870
+ className: "absolute inset-0 rounded-[var(--radius)] bg-gradient-to-r from-primary/5 via-transparent to-primary/5 pointer-events-none",
871
+ initial: { opacity: 0 },
872
+ animate: { opacity: 1 },
873
+ exit: { opacity: 0 },
874
+ transition: { duration: 0.3 }
875
+ }
876
+ ) })
877
+ ]
878
+ }
879
+ ),
880
+ /* @__PURE__ */ jsxRuntime.jsx(
881
+ framerMotion.motion.div,
882
+ {
883
+ className: "mt-2 text-center",
884
+ initial: { opacity: 0, y: 5 },
885
+ animate: { opacity: 1, y: 0 },
886
+ transition: { delay: 0.1 },
887
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "O assistente Xertica pode cometer erros. Considere verificar informações importantes." })
888
+ }
889
+ )
890
+ ] });
891
+ }
892
+ function AssistantCollapsedView({
893
+ showHistory,
894
+ showFavorites,
895
+ onToggle,
896
+ onExpandWithTab
897
+ }) {
898
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center p-4 space-y-4", children: [
899
+ /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
900
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
901
+ "button",
902
+ {
903
+ onClick: onToggle,
904
+ className: "w-10 h-10 rounded-full flex items-center justify-center hover:bg-accent/50 transition-colors duration-200 cursor-pointer mx-auto",
905
+ "aria-label": "Abrir assistente",
906
+ children: /* @__PURE__ */ jsxRuntime.jsx(XerticaOrbe.XerticaOrbe, { size: 32 })
907
+ }
908
+ ) }),
909
+ /* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "left", sideOffset: 8, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Assistente Xertica" }) })
910
+ ] }),
911
+ /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
912
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
913
+ button.Button,
914
+ {
915
+ variant: "ghost",
916
+ size: "sm",
917
+ onClick: () => onExpandWithTab("chat"),
918
+ className: "w-8 h-8 p-0 text-muted-foreground",
919
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "w-4 h-4" })
920
+ }
921
+ ) }),
922
+ /* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "left", sideOffset: 8, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Chat" }) })
923
+ ] }),
924
+ showFavorites && /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
925
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
926
+ button.Button,
927
+ {
928
+ variant: "ghost",
929
+ size: "sm",
930
+ onClick: () => onExpandWithTab("favoritos"),
931
+ className: "w-8 h-8 p-0 text-muted-foreground",
932
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heart, { className: "w-4 h-4" })
933
+ }
934
+ ) }),
935
+ /* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "left", sideOffset: 8, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Favoritos" }) })
936
+ ] }),
937
+ showHistory && /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
938
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
939
+ button.Button,
940
+ {
941
+ variant: "ghost",
942
+ size: "sm",
943
+ onClick: () => onExpandWithTab("historico"),
944
+ className: "w-8 h-8 p-0 text-muted-foreground",
945
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "w-4 h-4" })
946
+ }
947
+ ) }),
948
+ /* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "left", sideOffset: 8, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Histórico" }) })
949
+ ] })
950
+ ] });
951
+ }
952
+ function AssistantHeader({
953
+ isExpanded,
954
+ onToggle,
955
+ onNavigateFullPage
956
+ }) {
957
+ return /* @__PURE__ */ jsxRuntime.jsxs(
958
+ "div",
959
+ {
960
+ className: button.cn(
961
+ "border-b border-border flex items-center h-[64px]",
962
+ isExpanded ? "justify-between px-4" : "justify-center px-0"
963
+ ),
964
+ children: [
965
+ isExpanded && /* @__PURE__ */ jsxRuntime.jsxs(
966
+ framerMotion.motion.div,
967
+ {
968
+ initial: { opacity: 0, x: -10 },
969
+ animate: { opacity: 1, x: 0 },
970
+ exit: { opacity: 0, x: -10 },
971
+ className: "flex items-center gap-2 overflow-hidden",
972
+ children: [
973
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(XerticaOrbe.XerticaOrbe, { size: 32 }) }),
974
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium truncate", children: "Assistente Xertica" })
975
+ ]
976
+ }
977
+ ),
978
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
979
+ isExpanded && onNavigateFullPage && /* @__PURE__ */ jsxRuntime.jsx(
980
+ button.Button,
981
+ {
982
+ variant: "ghost",
983
+ size: "sm",
984
+ onClick: onNavigateFullPage,
985
+ className: "h-8 w-8 p-0 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-full",
986
+ title: "Expandir assistente",
987
+ "aria-label": "Expandir assistente",
988
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "w-4 h-4" })
989
+ }
990
+ ),
991
+ /* @__PURE__ */ jsxRuntime.jsx(
992
+ button.Button,
993
+ {
994
+ variant: "ghost",
995
+ size: "sm",
996
+ onClick: onToggle,
997
+ className: button.cn(
998
+ "h-8 w-8 p-0 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-full",
999
+ !isExpanded && "w-10 h-10"
1000
+ ),
1001
+ "aria-label": isExpanded ? "Recolher assistente" : "Expandir assistente",
1002
+ children: isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "w-4 h-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelRight, { className: "w-4 h-4" })
1003
+ }
1004
+ )
1005
+ ] })
1006
+ ]
1007
+ }
1008
+ );
1009
+ }
1010
+ function AssistantTabBar({
1011
+ activeTab,
1012
+ showHistory,
1013
+ showFavorites,
1014
+ onTabChange
1015
+ }) {
1016
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 py-2 border-b border-border", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
1017
+ /* @__PURE__ */ jsxRuntime.jsxs(
1018
+ button.Button,
1019
+ {
1020
+ variant: activeTab === "chat" ? "default" : "ghost",
1021
+ size: "sm",
1022
+ onClick: () => onTabChange("chat"),
1023
+ className: "flex-1 h-8",
1024
+ "aria-label": "Ver chat",
1025
+ children: [
1026
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "w-3 h-3 mr-1" }),
1027
+ "Chat"
1028
+ ]
1029
+ }
1030
+ ),
1031
+ showHistory && /* @__PURE__ */ jsxRuntime.jsxs(
1032
+ button.Button,
1033
+ {
1034
+ variant: activeTab === "historico" ? "default" : "ghost",
1035
+ size: "sm",
1036
+ onClick: () => onTabChange("historico"),
1037
+ className: "flex-1 h-8",
1038
+ "aria-label": "Ver histórico de conversas",
1039
+ children: [
1040
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "w-3 h-3 mr-1" }),
1041
+ "Histórico"
1042
+ ]
1043
+ }
1044
+ ),
1045
+ showFavorites && /* @__PURE__ */ jsxRuntime.jsxs(
1046
+ button.Button,
1047
+ {
1048
+ variant: activeTab === "favoritos" ? "default" : "ghost",
1049
+ size: "sm",
1050
+ onClick: () => onTabChange("favoritos"),
1051
+ className: "flex-1 h-8",
1052
+ "aria-label": "Ver mensagens favoritas",
1053
+ children: [
1054
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heart, { className: "w-3 h-3 mr-1" }),
1055
+ "Favoritos"
1056
+ ]
1057
+ }
1058
+ )
1059
+ ] }) });
1060
+ }
1061
+ function AssistantWelcomeScreen({
1062
+ userName,
1063
+ welcomeMessage,
1064
+ suggestions,
1065
+ richSuggestions,
1066
+ showMoreSuggestions,
1067
+ onSetShowMoreSuggestions,
1068
+ onSendSuggestion,
1069
+ onRichSuggestionClick
1070
+ }) {
1071
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 overflow-y-auto min-h-0", children: [
1072
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 text-center", children: [
1073
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto mb-4 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(XerticaOrbe.XerticaOrbe, { size: 64 }) }),
1074
+ /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "mb-2 text-foreground", children: [
1075
+ "Olá, ",
1076
+ userName
1077
+ ] }),
1078
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: welcomeMessage })
1079
+ ] }),
1080
+ (suggestions.length > 0 || richSuggestions.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 pb-4 space-y-2", children: [
1081
+ suggestions.map((sugestao) => /* @__PURE__ */ jsxRuntime.jsx(
1082
+ "button",
1083
+ {
1084
+ onClick: () => onSendSuggestion(sugestao.text),
1085
+ className: "w-full p-3 text-left rounded-[var(--radius-card)] bg-muted text-foreground transition-colors duration-200 hover:bg-muted/80",
1086
+ children: sugestao.text
1087
+ },
1088
+ sugestao.id
1089
+ )),
1090
+ richSuggestions.length > 0 && (!showMoreSuggestions ? /* @__PURE__ */ jsxRuntime.jsxs(
1091
+ button.Button,
1092
+ {
1093
+ variant: "ghost",
1094
+ size: "sm",
1095
+ onClick: () => onSetShowMoreSuggestions(true),
1096
+ className: "w-full justify-start text-muted-foreground",
1097
+ children: [
1098
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "w-4 h-4 mr-2" }),
1099
+ "Mais sugestões"
1100
+ ]
1101
+ }
1102
+ ) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 pt-2 border-t border-border mt-2 animate-in slide-in-from-top-2", children: [
1103
+ richSuggestions.map((sugestao) => /* @__PURE__ */ jsxRuntime.jsx(
1104
+ "button",
1105
+ {
1106
+ onClick: () => onRichSuggestionClick(sugestao),
1107
+ className: "w-full p-3 text-left rounded-[var(--radius-card)] bg-muted/50 border border-border text-foreground transition-all duration-200 hover:bg-primary/5 hover:border-primary/50 group",
1108
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1109
+ sugestao.id.includes("chart") && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.BarChart3, { className: "w-4 h-4 text-primary" }),
1110
+ sugestao.id.includes("table") && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table, { className: "w-4 h-4 text-primary" }),
1111
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: sugestao.text })
1112
+ ] })
1113
+ },
1114
+ sugestao.id
1115
+ )),
1116
+ /* @__PURE__ */ jsxRuntime.jsxs(
1117
+ button.Button,
1118
+ {
1119
+ variant: "ghost",
1120
+ size: "sm",
1121
+ onClick: () => onSetShowMoreSuggestions(false),
1122
+ className: "w-full justify-center text-muted-foreground mt-2",
1123
+ children: [
1124
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "w-4 h-4 mr-2" }),
1125
+ "Voltar"
1126
+ ]
1127
+ }
1128
+ )
1129
+ ] }))
1130
+ ] })
1131
+ ] });
1132
+ }
1133
+ function MarkdownMessage({ content, className = "" }) {
1134
+ const convertMarkdownToHtml = (markdown) => {
1135
+ let html = markdown;
1136
+ html = html.replace(/</g, "<").replace(/>/g, ">");
1137
+ html = html.replace(/^### (.*$)/gim, '<h3 class="font-medium text-sm mt-2 mb-1 break-words">$1</h3>');
1138
+ html = html.replace(/^## (.*$)/gim, '<h2 class="font-medium text-base mt-3 mb-1.5 break-words">$1</h2>');
1139
+ html = html.replace(/^# (.*$)/gim, '<h1 class="font-medium text-lg mt-3 mb-2 break-words">$1</h1>');
1140
+ html = html.replace(/\*\*(.*?)\*\*/g, '<strong class="font-medium">$1</strong>');
1141
+ html = html.replace(/\*(.*?)\*/g, '<em class="italic">$1</em>');
1142
+ html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" class="text-[var(--chart-4)] hover:underline break-all" target="_blank" rel="noopener noreferrer">$1</a>');
1143
+ html = html.replace(/`([^`]+)`/g, '<code class="px-1.5 py-0.5 rounded bg-muted text-xs font-mono break-all inline-block max-w-full">$1</code>');
1144
+ html = html.replace(/((?:^[•\-] .*$(?:\n|$))+)/gim, (match) => {
1145
+ const items = match.trim().split("\n").map(
1146
+ (item) => `<li class="ml-4 mb-1 list-disc break-words">${item.replace(/^[•\-]\s+/, "")}</li>`
1147
+ ).join("");
1148
+ return `<ul class="list-disc my-2">${items}</ul>`;
1149
+ });
1150
+ html = html.replace(/((?:^\d+\. .*$(?:\n|$))+)/gim, (match) => {
1151
+ const items = match.trim().split("\n").map(
1152
+ (item) => `<li class="ml-4 mb-1 list-decimal break-words">${item.replace(/^\d+\.\s+/, "")}</li>`
1153
+ ).join("");
1154
+ return `<ol class="list-decimal my-2">${items}</ol>`;
1155
+ });
1156
+ html = html.replace(/((?:^\|.+\|[ \t]*(?:\r?\n|$))+)/gm, (match) => {
1157
+ const rows = match.trim().split(/\r?\n/).filter((line) => line.trim());
1158
+ if (rows.length < 2) return match;
1159
+ const isSeparatorRow = /^\|[\s\-:|]+\|$/.test(rows[1].trim());
1160
+ if (!isSeparatorRow) return match;
1161
+ const parseCells = (row) => row.split("|").slice(1, -1).map((cell) => cell.trim());
1162
+ const headerCells = parseCells(rows[0]).map((cell) => `<th class="px-3 py-2 text-left font-medium text-xs uppercase tracking-wide border-b border-border">${cell}</th>`).join("");
1163
+ const bodyRows = rows.slice(2).map(
1164
+ (row) => `<tr class="border-b border-border last:border-0 hover:bg-muted/50">${parseCells(row).map((cell) => `<td class="px-3 py-2 text-sm">${cell}</td>`).join("")}</tr>`
1165
+ ).join("");
1166
+ return `<div class="overflow-x-auto my-3 rounded-[var(--radius)] border border-border"><table class="w-full text-sm"><thead class="bg-muted/50"><tr>${headerCells}</tr></thead><tbody>${bodyRows}</tbody></table></div>`;
1167
+ });
1168
+ html = html.replace(/\n\n/g, '</p><p class="mb-2 break-words">');
1169
+ html = html.replace(/\n/g, "<br/>");
1170
+ html = '<p class="mb-2 break-words">' + html + "</p>";
1171
+ html = html.replace(/<p[^>]*>\s*<\/p>/g, "");
1172
+ return html;
1173
+ };
1174
+ const htmlContent = convertMarkdownToHtml(content);
1175
+ return /* @__PURE__ */ jsxRuntime.jsx(
1176
+ "div",
1177
+ {
1178
+ className: `text-sm leading-relaxed break-words overflow-wrap-anywhere max-w-full ${className}`,
1179
+ dangerouslySetInnerHTML: { __html: htmlContent }
1180
+ }
1181
+ );
1182
+ }
1183
+ function FormattedDocument({ content, maxPreviewLength = 500, className = "" }) {
1184
+ const [isExpanded, setIsExpanded] = React.useState(false);
1185
+ const convertMarkdownToHtml = (markdown) => {
1186
+ let html = markdown;
1187
+ html = html.replace(/^### (.*$)/gim, '<h3 class="text-base font-medium mt-2 mb-1 text-foreground">$1</h3>');
1188
+ html = html.replace(/^## (.*$)/gim, '<h2 class="text-lg font-medium mt-2 mb-1 text-foreground">$1</h2>');
1189
+ html = html.replace(/^# (.*$)/gim, '<h1 class="text-xl font-medium mt-3 mb-2 text-foreground">$1</h1>');
1190
+ html = html.replace(/\*\*(.*?)\*\*/g, '<strong class="font-medium text-foreground">$1</strong>');
1191
+ html = html.replace(/\*(.*?)\*/g, '<em class="italic">$1</em>');
1192
+ html = html.replace(/^[-*+] \[ \] (.*$)/gim, '<div class="flex items-center gap-2 ml-4 my-0.5"><input type="checkbox" disabled class="rounded w-3.5 h-3.5 accent-primary" aria-label="$1" /> <span class="text-sm">$1</span></div>');
1193
+ html = html.replace(/^[-*+] \[x\] (.*$)/gim, '<div class="flex items-center gap-2 ml-4 my-0.5"><input type="checkbox" checked disabled class="rounded w-3.5 h-3.5 accent-primary" aria-label="$1" /> <span class="text-sm">$1</span></div>');
1194
+ html = html.replace(/((?:^[-*+] .*$(?:\n|$))+)/gim, (match) => {
1195
+ const items = match.trim().split("\n").map(
1196
+ (item) => `<li class="ml-6 my-0.5 list-disc">${item.replace(/^[-*+] /i, "")}</li>`
1197
+ ).join("");
1198
+ return `<ul class="list-disc my-2">${items}</ul>`;
1199
+ });
1200
+ html = html.replace(/((?:^\d+\. .*$(?:\n|$))+)/gim, (match) => {
1201
+ const items = match.trim().split("\n").map(
1202
+ (item) => `<li class="ml-6 my-0.5 list-decimal">${item.replace(/^\d+\. /i, "")}</li>`
1203
+ ).join("");
1204
+ return `<ol class="list-decimal my-2">${items}</ol>`;
1205
+ });
1206
+ html = html.replace(/^---$/gim, '<hr class="my-2 border-border" />');
1207
+ html = html.replace(/\n\n+/g, '</p><p class="my-0.5">');
1208
+ html = html.replace(/\n/g, " ");
1209
+ html = '<p class="my-0.5">' + html + "</p>";
1210
+ return html;
1211
+ };
1212
+ const htmlContent = convertMarkdownToHtml(content);
1213
+ const isLong = content.length > maxPreviewLength;
1214
+ const displayContent = !isLong || isExpanded ? htmlContent : convertMarkdownToHtml(content.substring(0, maxPreviewLength) + "...");
1215
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
1216
+ /* @__PURE__ */ jsxRuntime.jsx(
1217
+ "div",
1218
+ {
1219
+ className: "max-w-none text-sm text-foreground leading-relaxed break-words overflow-hidden",
1220
+ dangerouslySetInnerHTML: { __html: displayContent }
1221
+ }
1222
+ ),
1223
+ isLong && /* @__PURE__ */ jsxRuntime.jsx(
1224
+ button.Button,
1225
+ {
1226
+ variant: "ghost",
1227
+ size: "sm",
1228
+ onClick: () => setIsExpanded(!isExpanded),
1229
+ className: "mt-2 w-full text-xs hover:bg-accent text-muted-foreground",
1230
+ children: isExpanded ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1231
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "w-3 h-3 mr-1" }),
1232
+ "See less"
1233
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1234
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "w-3 h-3 mr-1" }),
1235
+ "See more"
1236
+ ] })
1237
+ }
1238
+ )
1239
+ ] });
1240
+ }
1241
+ function AssistantMessageBubble({
1242
+ msg,
1243
+ copiedId,
1244
+ generatingPodcastId,
1245
+ executingCommand,
1246
+ savedSearches,
1247
+ enablePodcastGeneration,
1248
+ feedbackOptions,
1249
+ onCopyMessage,
1250
+ onToggleFavorite,
1251
+ onGeneratePodcast,
1252
+ onDownloadDocument,
1253
+ onDownloadPodcast,
1254
+ onEditDocument,
1255
+ onOpenSearchResult,
1256
+ onExecuteSearchCommand,
1257
+ onEvaluationClick,
1258
+ onOpenFeedbackDialog
1259
+ }) {
1260
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1261
+ framerMotion.motion.div,
1262
+ {
1263
+ initial: { opacity: 0, y: 10 },
1264
+ animate: { opacity: 1, y: 0 },
1265
+ className: `flex gap-2 w-full min-w-0 ${msg.type === "user" ? "justify-end" : "justify-start"}`,
1266
+ children: [
1267
+ msg.type === "assistant" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(XerticaOrbe.XerticaOrbe, { size: 32 }) }),
1268
+ /* @__PURE__ */ jsxRuntime.jsxs(
1269
+ "div",
1270
+ {
1271
+ className: button.cn(
1272
+ "flex flex-col min-w-0 transition-all duration-300",
1273
+ msg.type === "user" ? "max-w-[85%] md:max-w-[70%] items-end w-fit" : button.cn(
1274
+ "items-start",
1275
+ msg.tableData || msg.chartData || msg.searchResults || msg.attachmentType === "document" ? "w-full max-w-full" : "w-fit max-w-[95%] md:max-w-[90%]"
1276
+ )
1277
+ ),
1278
+ children: [
1279
+ /* @__PURE__ */ jsxRuntime.jsxs(
1280
+ "div",
1281
+ {
1282
+ className: button.cn(
1283
+ "px-4 py-2 break-words overflow-hidden overflow-x-hidden w-full min-w-0 rounded-2xl",
1284
+ msg.type === "user" ? "bg-primary text-primary-foreground shadow-sm" : "bg-muted text-foreground"
1285
+ ),
1286
+ children: [
1287
+ msg.attachmentType === "document" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2 pb-2 border-b border-border min-w-0 overflow-hidden", children: [
1288
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 min-w-0 flex-1 overflow-hidden", children: [
1289
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "w-4 h-4 flex-shrink-0" }),
1290
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium break-words", children: msg.attachmentName })
1291
+ ] }),
1292
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
1293
+ /* @__PURE__ */ jsxRuntime.jsx(
1294
+ button.Button,
1295
+ {
1296
+ variant: "ghost",
1297
+ size: "sm",
1298
+ onClick: () => msg.documentContent && msg.attachmentName && onDownloadDocument(msg.documentContent, msg.attachmentName),
1299
+ className: "h-6 px-2",
1300
+ title: "Baixar",
1301
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "w-3 h-3" })
1302
+ }
1303
+ ),
1304
+ /* @__PURE__ */ jsxRuntime.jsxs(
1305
+ button.Button,
1306
+ {
1307
+ variant: "ghost",
1308
+ size: "sm",
1309
+ onClick: () => msg.documentContent && msg.documentTitle && onEditDocument(msg.documentContent, msg.documentTitle),
1310
+ className: "h-6 px-2",
1311
+ children: [
1312
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { className: "w-3 h-3 mr-1" }),
1313
+ "Editar"
1314
+ ]
1315
+ }
1316
+ )
1317
+ ] })
1318
+ ] }),
1319
+ msg.attachmentType && msg.attachmentType !== "podcast" && msg.attachmentType !== "document" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-2 pb-2 border-b border-border min-w-0 overflow-hidden", children: [
1320
+ msg.attachmentType === "file" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "w-4 h-4 flex-shrink-0" }),
1321
+ msg.attachmentType === "audio" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Music, { className: "w-4 h-4 flex-shrink-0" }),
1322
+ msg.attachmentType === "image" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Image, { className: "w-4 h-4 flex-shrink-0" }),
1323
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-small break-words", children: msg.attachmentName })
1324
+ ] }),
1325
+ msg.type === "user" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap break-words", children: msg.content }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1326
+ (msg.content.includes("🔐") || msg.content.includes("❌")) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3 p-3 border rounded-[var(--radius)] overflow-hidden bg-[var(--toast-error-bg)]/20 border-[var(--toast-error-border)]/30", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2 min-w-0", children: [
1327
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 flex-shrink-0 mt-0.5 text-[var(--toast-error-icon)]" }),
1328
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(MarkdownMessage, { content: msg.content, className: "text-foreground" }) })
1329
+ ] }) }),
1330
+ !(msg.content.includes("🔐") || msg.content.includes("❌")) && /* @__PURE__ */ jsxRuntime.jsx(MarkdownMessage, { content: msg.content, className: "text-foreground" })
1331
+ ] }),
1332
+ msg.chartData && msg.chartConfig && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 w-full h-[300px] min-w-[300px]", children: /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.ChartContainer, { config: msg.chartConfig, className: "h-full w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(RechartsPrimitive.BarChart, { accessibilityLayer: true, data: msg.chartData, children: [
1333
+ /* @__PURE__ */ jsxRuntime.jsx(RechartsPrimitive.CartesianGrid, { vertical: false }),
1334
+ /* @__PURE__ */ jsxRuntime.jsx(
1335
+ RechartsPrimitive.XAxis,
1336
+ {
1337
+ dataKey: "month",
1338
+ tickLine: false,
1339
+ tickMargin: 10,
1340
+ axisLine: false,
1341
+ tickFormatter: (value) => value.slice(0, 3)
1342
+ }
1343
+ ),
1344
+ /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.ChartTooltip, { content: /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.ChartTooltipContent, {}) }),
1345
+ /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.ChartLegend, { content: /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.ChartLegendContent, {}) }),
1346
+ Object.keys(msg.chartConfig).map((key) => /* @__PURE__ */ jsxRuntime.jsx(RechartsPrimitive.Bar, { dataKey: key, fill: `var(--color-${key})`, radius: 4 }, key))
1347
+ ] }) }) }),
1348
+ msg.tableData && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 w-full max-w-full border rounded-[var(--radius)] overflow-x-auto custom-scrollbar relative", children: /* @__PURE__ */ jsxRuntime.jsxs(richTextEditor.Table, { children: [
1349
+ msg.tableData.caption && /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableCaption, { children: msg.tableData.caption }),
1350
+ /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableRow, { children: msg.tableData.headers.map((header, i) => /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableHead, { children: header }, i)) }) }),
1351
+ /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableBody, { children: msg.tableData.rows.map((row, i) => /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableRow, { children: row.map((cell, j) => /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.TableCell, { children: cell }, j)) }, i)) })
1352
+ ] }) }),
1353
+ msg.attachmentType === "document" && msg.documentContent && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 pt-3 border-t border-border overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(FormattedDocument, { content: msg.documentContent, maxPreviewLength: 250 }) }),
1354
+ msg.attachmentType === "podcast" && msg.audioUrl && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 pt-3 border-t border-border overflow-hidden", children: [
1355
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-3 min-w-0 overflow-hidden", children: [
1356
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 min-w-0 flex-1 overflow-hidden", children: [
1357
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-6 h-6 flex items-center justify-center flex-shrink-0 rounded-[var(--radius-button)] bg-gradient-to-br from-[var(--chart-1)] via-[var(--chart-4)] to-[var(--chart-1)]", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Radio, { className: "w-3 h-3 text-white" }) }),
1358
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium break-words", children: msg.attachmentName })
1359
+ ] }),
1360
+ /* @__PURE__ */ jsxRuntime.jsx(
1361
+ button.Button,
1362
+ {
1363
+ variant: "ghost",
1364
+ size: "sm",
1365
+ onClick: () => msg.audioUrl && msg.attachmentName && onDownloadPodcast(msg.audioUrl, msg.attachmentName),
1366
+ className: "h-6 px-2 flex-shrink-0",
1367
+ title: "Baixar",
1368
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "w-3 h-3" })
1369
+ }
1370
+ )
1371
+ ] }),
1372
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-[var(--radius)] p-2 overflow-hidden bg-gradient-to-r from-[var(--chart-1)]/10 to-[var(--chart-4)]/10", children: /* @__PURE__ */ jsxRuntime.jsxs("audio", { controls: true, className: "w-full max-w-full h-10 outline-none", children: [
1373
+ /* @__PURE__ */ jsxRuntime.jsx("source", { src: msg.audioUrl, type: "audio/mpeg" }),
1374
+ "Seu navegador não suporta o elemento de áudio."
1375
+ ] }) })
1376
+ ] }),
1377
+ msg.attachmentType === "search" && msg.searchResults && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 pt-3 border-t border-border space-y-4 overflow-hidden", children: [
1378
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden", children: [
1379
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-3", children: [
1380
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-4 h-4 text-[var(--chart-4)]" }),
1381
+ /* @__PURE__ */ jsxRuntime.jsxs("h4", { className: "text-foreground", children: [
1382
+ "Resultados Encontrados (",
1383
+ msg.searchResults.length,
1384
+ ")"
1385
+ ] })
1386
+ ] }),
1387
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2 overflow-hidden", children: msg.searchResults.map((result) => /* @__PURE__ */ jsxRuntime.jsx(
1388
+ "div",
1389
+ {
1390
+ onClick: () => onOpenSearchResult(result),
1391
+ className: "p-3 rounded-[var(--radius)] border border-border transition-all cursor-pointer group overflow-hidden hover:bg-muted/50",
1392
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-2 min-w-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2 flex-1 min-w-0 overflow-hidden", children: [
1393
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-0.5 flex-shrink-0", children: [
1394
+ result.type === "document" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "w-4 h-4 text-[var(--chart-4)]" }),
1395
+ result.type === "project" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FolderOpen, { className: "w-4 h-4 text-[var(--chart-1)]" }),
1396
+ result.type === "conversation" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "w-4 h-4 text-[var(--chart-2)]" }),
1397
+ result.type === "file" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Folder, { className: "w-4 h-4 text-[var(--chart-3)]" }),
1398
+ result.type === "contact" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Users, { className: "w-4 h-4 text-[var(--chart-5)]" })
1399
+ ] }),
1400
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0 overflow-hidden", children: [
1401
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2 min-w-0", children: [
1402
+ /* @__PURE__ */ jsxRuntime.jsx("h5", { className: "text-sm font-medium break-words flex-1 min-w-0 text-foreground", children: result.title }),
1403
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "px-1.5 py-0.5 rounded-sm flex-shrink-0 self-start bg-[var(--chart-4)]/10 text-[var(--chart-4)]", children: [
1404
+ result.relevance,
1405
+ "%"
1406
+ ] })
1407
+ ] }),
1408
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mt-1 line-clamp-2 break-words", children: result.description }),
1409
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mt-2 flex-wrap min-w-0", children: [
1410
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground flex items-center gap-1 min-w-0 max-w-full", children: [
1411
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "w-3 h-3 flex-shrink-0" }),
1412
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: result.path })
1413
+ ] }),
1414
+ result.lastModified && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground flex items-center gap-1 flex-shrink-0", children: [
1415
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "w-3 h-3" }),
1416
+ result.lastModified
1417
+ ] })
1418
+ ] })
1419
+ ] })
1420
+ ] }) })
1421
+ },
1422
+ result.id
1423
+ )) })
1424
+ ] }),
1425
+ msg.searchSources && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1426
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "mb-2 text-foreground", children: "Fontes Consultadas" }),
1427
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 overflow-hidden", children: msg.searchSources.map((source, index) => /* @__PURE__ */ jsxRuntime.jsxs(
1428
+ "div",
1429
+ {
1430
+ className: "px-3 py-1.5 border max-w-full rounded-[var(--radius-button)] bg-muted border-border",
1431
+ children: [
1432
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-foreground break-words", children: source.name }),
1433
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-muted-foreground ml-1 whitespace-nowrap", children: [
1434
+ "(",
1435
+ source.count,
1436
+ ")"
1437
+ ] })
1438
+ ]
1439
+ },
1440
+ index
1441
+ )) })
1442
+ ] }),
1443
+ msg.searchCommands && msg.searchResults && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1444
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "mb-2 text-foreground", children: "O que você pode fazer com estes resultados" }),
1445
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2", children: msg.searchCommands.map((command) => /* @__PURE__ */ jsxRuntime.jsxs(
1446
+ "button",
1447
+ {
1448
+ onClick: () => onExecuteSearchCommand(
1449
+ command.id,
1450
+ msg.content.replace("🔍 Pesquisa realizada com sucesso!", "").split('"')[1] || "pesquisa",
1451
+ msg.searchResults,
1452
+ msg.id
1453
+ ),
1454
+ disabled: executingCommand === command.id,
1455
+ className: button.cn(
1456
+ "flex items-start gap-2 p-2 rounded-[var(--radius)] border transition-all text-left disabled:opacity-50 disabled:cursor-not-allowed",
1457
+ savedSearches.includes(msg.id) && command.id === "5" ? "border-[var(--toast-warning-border)] bg-[var(--toast-warning-bg)]/20" : "border-border bg-transparent hover:bg-muted/50"
1458
+ ),
1459
+ children: [
1460
+ executingCommand === command.id ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-5 h-5 animate-spin flex-shrink-0 text-primary" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: command.icon }),
1461
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0 overflow-hidden", children: [
1462
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-foreground break-words", children: command.id === "5" && savedSearches.includes(msg.id) ? "⭐ Pesquisa salva" : command.label }),
1463
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground break-words", children: executingCommand === command.id ? "Processando..." : command.description })
1464
+ ] })
1465
+ ]
1466
+ },
1467
+ command.id
1468
+ )) })
1469
+ ] })
1470
+ ] })
1471
+ ]
1472
+ }
1473
+ ),
1474
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mt-1 px-2", children: [
1475
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: msg.timestamp.toLocaleTimeString("pt-BR", {
1476
+ hour: "2-digit",
1477
+ minute: "2-digit"
1478
+ }) }),
1479
+ enablePodcastGeneration && msg.type === "assistant" && msg.attachmentType !== "podcast" && /* @__PURE__ */ jsxRuntime.jsx(
1480
+ button.Button,
1481
+ {
1482
+ variant: "ghost",
1483
+ size: "sm",
1484
+ onClick: () => onGeneratePodcast(msg.id, msg.content),
1485
+ disabled: generatingPodcastId === msg.id,
1486
+ className: "h-6 w-6 p-0 disabled:opacity-50 text-muted-foreground",
1487
+ title: "Gerar Podcast",
1488
+ "aria-label": "Gerar Podcast",
1489
+ children: generatingPodcastId === msg.id ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-3 h-3 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Radio, { className: "w-3 h-3" })
1490
+ }
1491
+ ),
1492
+ msg.type === "assistant" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 border-l border-border pl-2 ml-1", children: [
1493
+ /* @__PURE__ */ jsxRuntime.jsx(
1494
+ button.Button,
1495
+ {
1496
+ variant: "ghost",
1497
+ size: "icon",
1498
+ className: button.cn(
1499
+ "h-6 w-6 rounded-full hover:bg-green-100 dark:hover:bg-green-900/20 hover:text-green-600",
1500
+ msg.evaluation === "like" && "text-green-600 bg-green-100 dark:bg-green-900/20"
1501
+ ),
1502
+ onClick: () => onEvaluationClick(msg.id, "like"),
1503
+ title: "Gostei",
1504
+ "aria-label": "Gostei",
1505
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsUp, { className: "h-3.5 w-3.5" })
1506
+ }
1507
+ ),
1508
+ /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [
1509
+ /* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1510
+ button.Button,
1511
+ {
1512
+ variant: "ghost",
1513
+ size: "icon",
1514
+ className: button.cn(
1515
+ "h-6 w-6 rounded-full hover:bg-red-100 dark:hover:bg-red-900/20 hover:text-red-600",
1516
+ msg.evaluation === "dislike" && "text-red-600 bg-red-100 dark:bg-red-900/20"
1517
+ ),
1518
+ title: "Não gostei",
1519
+ "aria-label": "Não gostei",
1520
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsDown, { className: "h-3.5 w-3.5" })
1521
+ }
1522
+ ) }),
1523
+ /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuContent, { align: "start", children: [
1524
+ feedbackOptions && feedbackOptions.length > 0 ? feedbackOptions.map((option, idx) => /* @__PURE__ */ jsxRuntime.jsx(
1525
+ dropdownMenu.DropdownMenuItem,
1526
+ {
1527
+ onClick: () => onOpenFeedbackDialog(msg.id, option),
1528
+ children: option
1529
+ },
1530
+ idx
1531
+ )) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1532
+ /* @__PURE__ */ jsxRuntime.jsx(
1533
+ dropdownMenu.DropdownMenuItem,
1534
+ {
1535
+ onClick: () => onOpenFeedbackDialog(msg.id, "Não era o que eu procurava"),
1536
+ children: "Não era o que eu procurava"
1537
+ }
1538
+ ),
1539
+ /* @__PURE__ */ jsxRuntime.jsx(
1540
+ dropdownMenu.DropdownMenuItem,
1541
+ {
1542
+ onClick: () => onOpenFeedbackDialog(msg.id, "Informação incorreta"),
1543
+ children: "Informação incorreta"
1544
+ }
1545
+ ),
1546
+ /* @__PURE__ */ jsxRuntime.jsx(
1547
+ dropdownMenu.DropdownMenuItem,
1548
+ {
1549
+ onClick: () => onOpenFeedbackDialog(msg.id, "Resposta incompleta"),
1550
+ children: "Resposta incompleta"
1551
+ }
1552
+ )
1553
+ ] }),
1554
+ /* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuItem, { onClick: () => onOpenFeedbackDialog(msg.id, null), children: "Outros..." })
1555
+ ] })
1556
+ ] })
1557
+ ] }),
1558
+ /* @__PURE__ */ jsxRuntime.jsx(
1559
+ button.Button,
1560
+ {
1561
+ variant: "ghost",
1562
+ size: "sm",
1563
+ onClick: () => onCopyMessage(msg.content, msg.id),
1564
+ className: `h-6 w-6 p-0 ${copiedId === msg.id ? "text-[var(--toast-success-icon)]" : "text-muted-foreground"}`,
1565
+ "aria-label": copiedId === msg.id ? "Copiado" : "Copiar mensagem",
1566
+ children: copiedId === msg.id ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "w-3 h-3" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "w-3 h-3" })
1567
+ }
1568
+ )
1569
+ ] })
1570
+ ]
1571
+ }
1572
+ )
1573
+ ]
1574
+ },
1575
+ msg.id
1576
+ );
1577
+ }
1578
+ function AssistantTypingIndicator() {
1579
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1580
+ framerMotion.motion.div,
1581
+ {
1582
+ initial: { opacity: 0, y: 10 },
1583
+ animate: { opacity: 1, y: 0 },
1584
+ className: "flex gap-2 justify-start",
1585
+ children: [
1586
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(XerticaOrbe.XerticaOrbe, { size: 32 }) }),
1587
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 py-3 bg-muted rounded-2xl", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
1588
+ /* @__PURE__ */ jsxRuntime.jsx(
1589
+ framerMotion.motion.div,
1590
+ {
1591
+ className: "w-2 h-2 rounded-full bg-muted-foreground",
1592
+ animate: { y: [0, -8, 0] },
1593
+ transition: { repeat: Infinity, duration: 0.6, delay: 0 }
1594
+ }
1595
+ ),
1596
+ /* @__PURE__ */ jsxRuntime.jsx(
1597
+ framerMotion.motion.div,
1598
+ {
1599
+ className: "w-2 h-2 rounded-full bg-muted-foreground",
1600
+ animate: { y: [0, -8, 0] },
1601
+ transition: { repeat: Infinity, duration: 0.6, delay: 0.2 }
1602
+ }
1603
+ ),
1604
+ /* @__PURE__ */ jsxRuntime.jsx(
1605
+ framerMotion.motion.div,
1606
+ {
1607
+ className: "w-2 h-2 rounded-full bg-muted-foreground",
1608
+ animate: { y: [0, -8, 0] },
1609
+ transition: { repeat: Infinity, duration: 0.6, delay: 0.4 }
1610
+ }
1611
+ )
1612
+ ] }) })
1613
+ ]
1614
+ }
1615
+ );
1616
+ }
1617
+ function AssistantConversationList({
1618
+ conversations,
1619
+ currentConversationId,
1620
+ activeTab,
1621
+ isFullPage,
1622
+ onNewConversation,
1623
+ onSelectConversation,
1624
+ onToggleFavorite
1625
+ }) {
1626
+ return /* @__PURE__ */ jsxRuntime.jsx(input.ScrollArea, { className: "flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `p-4 ${isFullPage ? "mx-auto w-full max-w-6xl" : ""}`, children: [
1627
+ /* @__PURE__ */ jsxRuntime.jsxs(
1628
+ button.Button,
1629
+ {
1630
+ variant: "outline",
1631
+ size: "sm",
1632
+ onClick: onNewConversation,
1633
+ className: "w-full mb-4 justify-start",
1634
+ children: [
1635
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-4 h-4 mr-2" }),
1636
+ "Nova Conversa"
1637
+ ]
1638
+ }
1639
+ ),
1640
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: conversations.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8", children: [
1641
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heart, { className: "w-12 h-12 mx-auto text-muted-foreground/50 mb-2" }),
1642
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: activeTab === "favoritos" ? "Nenhuma conversa favorita ainda" : "Nenhuma conversa no histórico" })
1643
+ ] }) : conversations.map((conversa) => /* @__PURE__ */ jsxRuntime.jsxs(
1644
+ "div",
1645
+ {
1646
+ onClick: () => onSelectConversation(conversa.id),
1647
+ className: button.cn(
1648
+ "p-3 rounded-[var(--radius)] cursor-pointer transition-colors duration-200 border",
1649
+ conversa.id === currentConversationId ? "border-primary bg-primary/10" : "border-border hover:bg-muted"
1650
+ ),
1651
+ children: [
1652
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between mb-1", children: [
1653
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-medium text-foreground truncate flex-1", children: conversa.title }),
1654
+ /* @__PURE__ */ jsxRuntime.jsx(
1655
+ button.Button,
1656
+ {
1657
+ variant: "ghost",
1658
+ size: "sm",
1659
+ onClick: (e) => {
1660
+ e.stopPropagation();
1661
+ onToggleFavorite(conversa.id);
1662
+ },
1663
+ className: "h-6 w-6 p-0 flex-shrink-0 ml-1",
1664
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1665
+ lucideReact.Heart,
1666
+ {
1667
+ className: button.cn(
1668
+ "w-3 h-3",
1669
+ conversa.isFavorite ? "text-destructive fill-current" : "text-muted-foreground"
1670
+ )
1671
+ }
1672
+ )
1673
+ }
1674
+ )
1675
+ ] }),
1676
+ conversa.lastMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground truncate mb-1", children: conversa.lastMessage }),
1677
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: conversa.timestamp })
1678
+ ]
1679
+ },
1680
+ conversa.id
1681
+ )) })
1682
+ ] }) });
1683
+ }
1684
+ function AssistantFeedbackDialog({
1685
+ state,
1686
+ onReasonChange,
1687
+ onClose,
1688
+ onSubmit
1689
+ }) {
1690
+ return /* @__PURE__ */ jsxRuntime.jsx(
1691
+ richTextEditor.Dialog,
1692
+ {
1693
+ open: state.isOpen,
1694
+ onOpenChange: (open) => !open && onClose(),
1695
+ children: /* @__PURE__ */ jsxRuntime.jsxs(richTextEditor.DialogContent, { className: "sm:max-w-[600px]", children: [
1696
+ /* @__PURE__ */ jsxRuntime.jsxs(richTextEditor.DialogHeader, { children: [
1697
+ /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.DialogTitle, { className: "pr-8", children: state.category ? `Enviar feedback: ${state.category}` : "Enviar feedback" }),
1698
+ /* @__PURE__ */ jsxRuntime.jsx(richTextEditor.DialogDescription, { children: state.category ? "Gostaria de adicionar algum comentário? (Opcional)" : "Conte-nos por que essa resposta não foi útil para que possamos melhorar." })
1699
+ ] }),
1700
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4 py-4 px-6", children: /* @__PURE__ */ jsxRuntime.jsx(
1701
+ richTextEditor.Textarea,
1702
+ {
1703
+ className: "min-h-[100px]",
1704
+ placeholder: state.category ? "Comentário adicional..." : "Descreva o motivo...",
1705
+ "aria-label": state.category ? "Comentário adicional" : "Descreva o motivo",
1706
+ value: state.reason,
1707
+ onChange: (e) => onReasonChange(e.target.value),
1708
+ rows: 4
1709
+ }
1710
+ ) }),
1711
+ /* @__PURE__ */ jsxRuntime.jsxs(richTextEditor.DialogFooter, { children: [
1712
+ /* @__PURE__ */ jsxRuntime.jsx(button.Button, { variant: "outline", onClick: onClose, children: "Cancelar" }),
1713
+ /* @__PURE__ */ jsxRuntime.jsx(
1714
+ button.Button,
1715
+ {
1716
+ onClick: onSubmit,
1717
+ disabled: !state.category && !state.reason.trim(),
1718
+ children: state.category ? "Confirmar e Enviar" : "Enviar Feedback"
1719
+ }
1720
+ )
1721
+ ] })
1722
+ ] })
1723
+ }
1724
+ );
1725
+ }
1726
+ function AssistantDocumentEditor({
1727
+ document: document2,
1728
+ isMobile,
1729
+ containerWidth,
1730
+ onClose,
1731
+ onChange
1732
+ }) {
1733
+ return /* @__PURE__ */ jsxRuntime.jsx(
1734
+ "div",
1735
+ {
1736
+ className: button.cn(
1737
+ "flex flex-col border-border bg-background overflow-hidden transition-all duration-300",
1738
+ isMobile ? "fixed inset-0 z-[110] w-full h-[100dvh]" : "absolute top-0 bottom-0 right-full w-[800px] border-l border-r border-border shadow-[-25px_0_50px_-15px_rgba(0,0,0,0.15)] z-[90]"
1739
+ ),
1740
+ style: { maxWidth: isMobile ? "none" : `calc(100vw - ${containerWidth})` },
1741
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full flex flex-col", children: [
1742
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 h-[64px] border-b border-border bg-card flex items-center justify-between", children: [
1743
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1744
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2 bg-primary/10 rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "w-4 h-4 text-primary" }) }),
1745
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-card-foreground text-sm", children: document2.title })
1746
+ ] }),
1747
+ /* @__PURE__ */ jsxRuntime.jsx(
1748
+ button.Button,
1749
+ {
1750
+ variant: "ghost",
1751
+ size: "icon",
1752
+ className: "h-8 w-8 rounded-full",
1753
+ onClick: onClose,
1754
+ "aria-label": "Fechar editor de documento",
1755
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-4 h-4" })
1756
+ }
1757
+ )
1758
+ ] }),
1759
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 bg-muted/20 p-0 sm:p-6 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
1760
+ richTextEditor.RichTextEditor,
1761
+ {
1762
+ value: document2.content || "",
1763
+ onChange: (newVal) => onChange({ ...document2, content: newVal }),
1764
+ placeholder: "Comece a digitar o conteúdo do seu documento aqui...",
1765
+ className: "max-w-4xl mx-auto h-full",
1766
+ actionButton: /* @__PURE__ */ jsxRuntime.jsxs(button.Button, { size: "sm", className: "gap-2 h-8", children: [
1767
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "w-3.5 h-3.5" }),
1768
+ "Salvar"
1769
+ ] })
1770
+ }
1771
+ ) })
1772
+ ] })
1773
+ }
1774
+ );
1775
+ }
1776
+ function XerticaAssistant({
1777
+ mode = "expanded",
1778
+ isExpanded: controlledIsExpanded,
1779
+ onToggle,
1780
+ defaultTab = "chat",
1781
+ demoMode = true,
1782
+ onNavigateSettings,
1783
+ onNavigateFullPage,
1784
+ userName = "Usuário",
1785
+ initialMessages = [],
1786
+ savedConversations = [],
1787
+ suggestions: propSuggestions,
1788
+ onSendMessage,
1789
+ onFileAttach,
1790
+ isProcessing = false,
1791
+ width,
1792
+ height,
1793
+ className = "",
1794
+ mobileFloating = false,
1795
+ customResponses = [],
1796
+ responseGenerator,
1797
+ richSuggestions = [],
1798
+ welcomeMessage = "Como posso ajudar?",
1799
+ onRichAction,
1800
+ onEvaluation,
1801
+ feedbackOptions,
1802
+ // Feature flags — all default to true for backward compatibility
1803
+ showHistory = true,
1804
+ showFavorites = true,
1805
+ enableAudioInput = true,
1806
+ enableFileAttachment = true,
1807
+ enableDocumentCreation = true,
1808
+ enablePodcastGeneration = true,
1809
+ enableSearch = true
1810
+ }) {
1811
+ const {
1812
+ isFullPage,
1813
+ isExpanded,
1814
+ isMobile,
1815
+ abaSelecionada,
1816
+ setAbaSelecionada,
1817
+ mensagens,
1818
+ mensagem,
1819
+ setMensagem,
1820
+ conversaAtual,
1821
+ conversasFiltradas,
1822
+ copiedId,
1823
+ generatingPodcastId,
1824
+ executingCommand,
1825
+ savedSearches,
1826
+ editingDocument,
1827
+ setEditingDocument,
1828
+ showMoreSuggestions,
1829
+ setShowMoreSuggestions,
1830
+ evaluationState,
1831
+ setEvaluationState,
1832
+ sugestoes,
1833
+ messagesEndRef,
1834
+ fileInputRef,
1835
+ audioInputRef,
1836
+ handleToggle,
1837
+ handleExpandWithTab,
1838
+ handleEnviarMensagem,
1839
+ handleToggleFavorite,
1840
+ handleCopyMessage,
1841
+ handleGeneratePodcast,
1842
+ handleDownloadDocument,
1843
+ handleDownloadPodcast,
1844
+ handleEditDocument,
1845
+ handleNovaConversa,
1846
+ handleSelecionarConversa,
1847
+ handleToggleFavoritaConversa,
1848
+ handleOpenSearchResult,
1849
+ handleExecuteSearchCommand,
1850
+ handleRichSuggestionClick,
1851
+ handleEvaluationClick,
1852
+ openFeedbackDialog,
1853
+ handleSubmitDislike
1854
+ } = useAssistant({
1855
+ mode,
1856
+ isExpanded: controlledIsExpanded,
1857
+ onToggle,
1858
+ defaultTab,
1859
+ demoMode,
1860
+ customResponses,
1861
+ initialMessages,
1862
+ savedConversations,
1863
+ suggestions: propSuggestions,
1864
+ onSendMessage,
1865
+ isProcessing,
1866
+ responseGenerator,
1867
+ richSuggestions,
1868
+ onRichAction,
1869
+ onEvaluation
1870
+ });
1871
+ const containerWidth = width ?? (isFullPage ? "100%" : isExpanded ? "420px" : "80px");
1872
+ const containerHeight = height ?? "h-full";
1873
+ if (isMobile && !isExpanded) {
1874
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1875
+ button.Button,
1876
+ {
1877
+ onClick: handleToggle,
1878
+ className: button.cn(
1879
+ "fixed bottom-4 right-4 h-14 rounded-full shadow-lg pl-3 pr-5 gap-3 bg-white text-zinc-900 hover:bg-zinc-50 border border-zinc-200 z-50 transition-all duration-300",
1880
+ className
1881
+ ),
1882
+ children: [
1883
+ /* @__PURE__ */ jsxRuntime.jsx(XerticaOrbe.XerticaOrbe, { size: 32 }),
1884
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-base tracking-wide", children: "Assistente" })
1885
+ ]
1886
+ }
1887
+ );
1888
+ }
1889
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1890
+ /* @__PURE__ */ jsxRuntime.jsx(
1891
+ "input",
1892
+ {
1893
+ ref: fileInputRef,
1894
+ type: "file",
1895
+ accept: ".pdf,.doc,.docx,.txt,.md",
1896
+ className: "hidden",
1897
+ onChange: (e) => {
1898
+ var _a;
1899
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
1900
+ if (file && onFileAttach) {
1901
+ onFileAttach(file);
1902
+ }
1903
+ },
1904
+ "aria-label": "Upload de documento"
1905
+ }
1906
+ ),
1907
+ /* @__PURE__ */ jsxRuntime.jsx(
1908
+ "input",
1909
+ {
1910
+ ref: audioInputRef,
1911
+ type: "file",
1912
+ accept: "audio/*",
1913
+ className: "hidden",
1914
+ onChange: (e) => {
1915
+ var _a;
1916
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
1917
+ if (file && onFileAttach) {
1918
+ onFileAttach(file);
1919
+ }
1920
+ },
1921
+ "aria-label": "Upload de áudio"
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ jsxRuntime.jsxs(
1925
+ "div",
1926
+ {
1927
+ className: button.cn(
1928
+ `${containerHeight} flex flex-col bg-background relative`,
1929
+ !isFullPage && "border-l border-border shadow-sm",
1930
+ isMobile && isExpanded && "fixed inset-0 z-[100] h-[100dvh] w-full border-l-0 shadow-2xl",
1931
+ className
1932
+ ),
1933
+ style: !(isMobile && isExpanded) ? {
1934
+ width: isFullPage ? "100%" : containerWidth
1935
+ } : void 0,
1936
+ children: [
1937
+ editingDocument && !isFullPage && /* @__PURE__ */ jsxRuntime.jsx(
1938
+ AssistantDocumentEditor,
1939
+ {
1940
+ document: editingDocument,
1941
+ isMobile,
1942
+ containerWidth,
1943
+ onClose: () => setEditingDocument(null),
1944
+ onChange: (doc) => setEditingDocument(doc)
1945
+ }
1946
+ ),
1947
+ !isFullPage && /* @__PURE__ */ jsxRuntime.jsx(
1948
+ AssistantHeader,
1949
+ {
1950
+ isExpanded,
1951
+ onToggle: handleToggle,
1952
+ onNavigateFullPage
1953
+ }
1954
+ ),
1955
+ !isExpanded && !isFullPage && /* @__PURE__ */ jsxRuntime.jsx(
1956
+ AssistantCollapsedView,
1957
+ {
1958
+ showHistory,
1959
+ showFavorites,
1960
+ onToggle: handleToggle,
1961
+ onExpandWithTab: handleExpandWithTab
1962
+ }
1963
+ ),
1964
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: (isExpanded || isFullPage) && /* @__PURE__ */ jsxRuntime.jsxs(
1965
+ framerMotion.motion.div,
1966
+ {
1967
+ initial: isFullPage ? false : { opacity: 0, x: 50 },
1968
+ animate: { opacity: 1, x: 0 },
1969
+ exit: isFullPage ? void 0 : { opacity: 0, x: 50 },
1970
+ transition: { duration: 0.2 },
1971
+ className: "flex-1 flex flex-col overflow-hidden",
1972
+ children: [
1973
+ !isFullPage && (showHistory || showFavorites) && /* @__PURE__ */ jsxRuntime.jsx(
1974
+ AssistantTabBar,
1975
+ {
1976
+ activeTab: abaSelecionada,
1977
+ showHistory,
1978
+ showFavorites,
1979
+ onTabChange: setAbaSelecionada
1980
+ }
1981
+ ),
1982
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 overflow-hidden flex flex-col", children: [
1983
+ abaSelecionada === "chat" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex-1 flex flex-col min-h-0 ${isFullPage ? "mx-auto w-full max-w-6xl" : ""}`, children: mensagens.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1984
+ AssistantWelcomeScreen,
1985
+ {
1986
+ userName,
1987
+ welcomeMessage,
1988
+ suggestions: sugestoes,
1989
+ richSuggestions,
1990
+ showMoreSuggestions,
1991
+ onSetShowMoreSuggestions: setShowMoreSuggestions,
1992
+ onSendSuggestion: handleEnviarMensagem,
1993
+ onRichSuggestionClick: handleRichSuggestionClick
1994
+ }
1995
+ ) : /* @__PURE__ */ jsxRuntime.jsx(input.ScrollArea, { className: "flex-1 min-h-0 overflow-x-hidden [&_[data-radix-scroll-area-viewport]>div]:!block", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 px-4 py-4 max-w-6xl mx-auto !block !w-full", children: [
1996
+ mensagens.map((msg) => /* @__PURE__ */ jsxRuntime.jsx(
1997
+ AssistantMessageBubble,
1998
+ {
1999
+ msg,
2000
+ copiedId,
2001
+ generatingPodcastId,
2002
+ executingCommand,
2003
+ savedSearches,
2004
+ enablePodcastGeneration,
2005
+ feedbackOptions,
2006
+ onCopyMessage: handleCopyMessage,
2007
+ onToggleFavorite: handleToggleFavorite,
2008
+ onGeneratePodcast: handleGeneratePodcast,
2009
+ onDownloadDocument: handleDownloadDocument,
2010
+ onDownloadPodcast: handleDownloadPodcast,
2011
+ onEditDocument: handleEditDocument,
2012
+ onOpenSearchResult: handleOpenSearchResult,
2013
+ onExecuteSearchCommand: handleExecuteSearchCommand,
2014
+ onEvaluationClick: handleEvaluationClick,
2015
+ onOpenFeedbackDialog: openFeedbackDialog
2016
+ },
2017
+ msg.id
2018
+ )),
2019
+ isProcessing && /* @__PURE__ */ jsxRuntime.jsx(AssistantTypingIndicator, {}),
2020
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
2021
+ ] }) }) }),
2022
+ (abaSelecionada === "historico" && showHistory || abaSelecionada === "favoritos" && showFavorites) && /* @__PURE__ */ jsxRuntime.jsx(
2023
+ AssistantConversationList,
2024
+ {
2025
+ conversations: conversasFiltradas,
2026
+ currentConversationId: conversaAtual,
2027
+ activeTab: abaSelecionada,
2028
+ isFullPage,
2029
+ onNewConversation: handleNovaConversa,
2030
+ onSelectConversation: handleSelecionarConversa,
2031
+ onToggleFavorite: handleToggleFavoritaConversa
2032
+ }
2033
+ )
2034
+ ] }),
2035
+ abaSelecionada === "chat" && /* @__PURE__ */ jsxRuntime.jsx(
2036
+ ModernChatInput,
2037
+ {
2038
+ value: mensagem,
2039
+ onChange: setMensagem,
2040
+ onSubmit: handleEnviarMensagem,
2041
+ onFileUpload: enableFileAttachment ? () => {
2042
+ var _a;
2043
+ return (_a = fileInputRef.current) == null ? void 0 : _a.click();
2044
+ } : void 0,
2045
+ onAudioUpload: enableAudioInput ? () => {
2046
+ var _a;
2047
+ return (_a = audioInputRef.current) == null ? void 0 : _a.click();
2048
+ } : void 0,
2049
+ placeholder: "Envie uma mensagem",
2050
+ disabled: isProcessing,
2051
+ isFullPage,
2052
+ enableAudioInput,
2053
+ enableFileAttachment,
2054
+ enableDocumentCreation,
2055
+ enablePodcastGeneration,
2056
+ enableSearch
2057
+ }
2058
+ )
2059
+ ]
2060
+ }
2061
+ ) })
2062
+ ]
2063
+ }
2064
+ ),
2065
+ /* @__PURE__ */ jsxRuntime.jsx(
2066
+ AssistantFeedbackDialog,
2067
+ {
2068
+ state: evaluationState,
2069
+ onReasonChange: (reason) => setEvaluationState((prev) => ({ ...prev, reason })),
2070
+ onClose: () => setEvaluationState((prev) => ({ ...prev, isOpen: false })),
2071
+ onSubmit: handleSubmitDislike
2072
+ }
2073
+ )
2074
+ ] });
2075
+ }
2076
+ exports.FormattedDocument = FormattedDocument;
2077
+ exports.MarkdownMessage = MarkdownMessage;
2078
+ exports.ModernChatInput = ModernChatInput;
2079
+ exports.XerticaAssistant = XerticaAssistant;
2080
+ exports.gerarResposta = gerarResposta;
2081
+ exports.useAssistant = useAssistant;