@messenger-box/tailwind-ui-inbox 10.0.3-alpha.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/LICENSE +21 -0
- package/jest.config.js +9 -0
- package/lib/cdm-locales/en/translations.json +31 -0
- package/lib/cdm-locales/es/translations.json +31 -0
- package/lib/components/AIAgent/AIAgent.d.ts +21 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -0
- package/lib/components/AIAgent/AIAgent.js +904 -0
- package/lib/components/AIAgent/AIAgent.js.map +1 -0
- package/lib/components/AIAgent/index.d.ts +2 -0
- package/lib/components/AIAgent/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts +8 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.js +35 -0
- package/lib/components/InboxMessage/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts +14 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.js +200 -0
- package/lib/components/InboxMessage/ConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/InputComponent.d.ts +12 -0
- package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/InputComponent.js +359 -0
- package/lib/components/InboxMessage/InputComponent.js.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts +20 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.js +102 -0
- package/lib/components/InboxMessage/LeftSidebar.js.map +1 -0
- package/lib/components/InboxMessage/MessageInput.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInput.d.ts.map +1 -0
- package/lib/components/InboxMessage/MessageInput.js +154 -0
- package/lib/components/InboxMessage/MessageInput.js.map +1 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.d.ts +17 -0
- package/lib/components/InboxMessage/Messages.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.js +99 -0
- package/lib/components/InboxMessage/Messages.js.map +1 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts +17 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.d.ts +3 -0
- package/lib/components/InboxMessage/Popover.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.js +31 -0
- package/lib/components/InboxMessage/Popover.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts +9 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.js +9 -0
- package/lib/components/InboxMessage/RightSidebar.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts +23 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.js +9 -0
- package/lib/components/InboxMessage/RightSidebarAi.js.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js +185 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js +182 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts +19 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js +41 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts +7 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.js +34 -0
- package/lib/components/InboxMessage/UploadImageButton.js.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts +3 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.js +60 -0
- package/lib/components/InboxMessage/UserModalContent.js.map +1 -0
- package/lib/components/InboxMessage/index.d.ts +17 -0
- package/lib/components/InboxMessage/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js +44 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js +194 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts +12 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js +37 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +18 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +1082 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js +14 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts +9 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts +14 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js +333 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts +4 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.d.ts +37 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.js +317 -0
- package/lib/components/ModelConfigPanel.js.map +1 -0
- package/lib/components/filler-components/RightSiderBar.d.ts +24 -0
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
- package/lib/components/filler-components/RightSiderBar.js +335 -0
- package/lib/components/filler-components/RightSiderBar.js.map +1 -0
- package/lib/components/inbox/FilesList.d.ts +20 -0
- package/lib/components/inbox/FilesList.d.ts.map +1 -0
- package/lib/components/inbox/FilesList.js +68 -0
- package/lib/components/inbox/FilesList.js.map +1 -0
- package/lib/components/inbox/MessageItem.d.ts +17 -0
- package/lib/components/inbox/MessageItem.d.ts.map +1 -0
- package/lib/components/inbox/MessageItem.js +50 -0
- package/lib/components/inbox/MessageItem.js.map +1 -0
- package/lib/components/inbox/ThreadItem.d.ts +11 -0
- package/lib/components/inbox/ThreadItem.d.ts.map +1 -0
- package/lib/components/inbox/ThreadItem.js +147 -0
- package/lib/components/inbox/ThreadItem.js.map +1 -0
- package/lib/components/inbox/index.d.ts +4 -0
- package/lib/components/inbox/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +7 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts +20 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js +68 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js.map +1 -0
- package/lib/components/live-code-editor/index.d.ts +4 -0
- package/lib/components/live-code-editor/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts +14 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.js +207 -0
- package/lib/components/live-code-editor/live-code-editor.js.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts +4 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.js +5 -0
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts +11 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.js +6 -0
- package/lib/components/slot-fill/chat-message-slot.js.map +1 -0
- package/lib/components/slot-fill/index.d.ts +4 -0
- package/lib/components/slot-fill/index.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts +4 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.js +13 -0
- package/lib/components/slot-fill/right-sidebar-filler.js.map +1 -0
- package/lib/components/ui/button.d.ts +9 -0
- package/lib/components/ui/button.d.ts.map +1 -0
- package/lib/compute.d.ts +8 -0
- package/lib/compute.d.ts.map +1 -0
- package/lib/compute.js +137 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.d.ts +13 -0
- package/lib/config/env-config.d.ts.map +1 -0
- package/lib/config/env-config.js +34 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/constants/breakpoints.d.ts +8 -0
- package/lib/constants/breakpoints.d.ts.map +1 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/container/AiInbox.d.ts +15 -0
- package/lib/container/AiInbox.d.ts.map +1 -0
- package/lib/container/AiInboxWithLoader.d.ts +36 -0
- package/lib/container/AiInboxWithLoader.d.ts.map +1 -0
- package/lib/container/AiLandingInput.d.ts +4 -0
- package/lib/container/AiLandingInput.d.ts.map +1 -0
- package/lib/container/AiLandingInput.js +101 -0
- package/lib/container/AiLandingInput.js.map +1 -0
- package/lib/container/Inbox.d.ts +15 -0
- package/lib/container/Inbox.d.ts.map +1 -0
- package/lib/container/Inbox.js +955 -0
- package/lib/container/Inbox.js.map +1 -0
- package/lib/container/InboxAiMessagesLoader.d.ts +15 -0
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -0
- package/lib/container/InboxAiMessagesLoader.js +30 -0
- package/lib/container/InboxAiMessagesLoader.js.map +1 -0
- package/lib/container/InboxContainer.d.ts +12 -0
- package/lib/container/InboxContainer.d.ts.map +1 -0
- package/lib/container/InboxContainer.js +31 -0
- package/lib/container/InboxContainer.js.map +1 -0
- package/lib/container/InboxTemplate1.d.ts +15 -0
- package/lib/container/InboxTemplate1.d.ts.map +1 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts +36 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts.map +1 -0
- package/lib/container/InboxTemplate2.d.ts +15 -0
- package/lib/container/InboxTemplate2.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.d.ts +15 -0
- package/lib/container/InboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.js +56 -0
- package/lib/container/InboxWithAiLoader.js.map +1 -0
- package/lib/container/InboxWithLoader.d.ts +36 -0
- package/lib/container/InboxWithLoader.d.ts.map +1 -0
- package/lib/container/InboxWithLoader.js +277 -0
- package/lib/container/InboxWithLoader.js.map +1 -0
- package/lib/container/ServiceInbox.d.ts +9 -0
- package/lib/container/ServiceInbox.d.ts.map +1 -0
- package/lib/container/ServiceInbox.js +144 -0
- package/lib/container/ServiceInbox.js.map +1 -0
- package/lib/container/ThreadMessages.d.ts +13 -0
- package/lib/container/ThreadMessages.d.ts.map +1 -0
- package/lib/container/ThreadMessages.js +314 -0
- package/lib/container/ThreadMessages.js.map +1 -0
- package/lib/container/ThreadMessagesInbox.d.ts +14 -0
- package/lib/container/ThreadMessagesInbox.d.ts.map +1 -0
- package/lib/container/ThreadMessagesInbox.js +341 -0
- package/lib/container/ThreadMessagesInbox.js.map +1 -0
- package/lib/container/Threads.d.ts +8 -0
- package/lib/container/Threads.d.ts.map +1 -0
- package/lib/container/Threads.js +231 -0
- package/lib/container/Threads.js.map +1 -0
- package/lib/container/ThreadsInbox.d.ts +21 -0
- package/lib/container/ThreadsInbox.d.ts.map +1 -0
- package/lib/container/ThreadsInbox.js +244 -0
- package/lib/container/ThreadsInbox.js.map +1 -0
- package/lib/container/apply-footer-styles.d.ts +2 -0
- package/lib/container/apply-footer-styles.d.ts.map +1 -0
- package/lib/container/apply-footer-styles.js +16 -0
- package/lib/container/apply-footer-styles.js.map +1 -0
- package/lib/container/index.d.ts +13 -0
- package/lib/container/index.d.ts.map +1 -0
- package/lib/enums/index.d.ts +2 -0
- package/lib/enums/index.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts +5 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.js +5 -0
- package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -0
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.d.ts +16 -0
- package/lib/hooks/use-file-sync.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.js +63 -0
- package/lib/hooks/use-file-sync.js.map +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts +15 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.js +46 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/interfaces/index.d.ts.map +1 -0
- package/lib/interfaces/message-widgets.interface.d.ts +21 -0
- package/lib/interfaces/message-widgets.interface.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.d.ts +3 -0
- package/lib/machines/aiAgentMachine.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.js +1083 -0
- package/lib/machines/aiAgentMachine.js.map +1 -0
- package/lib/machines/aiAgentMachine.simple.d.ts +3 -0
- package/lib/machines/aiAgentMachine.simple.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.simple.js +108 -0
- package/lib/machines/aiAgentMachine.simple.js.map +1 -0
- package/lib/machines/index.d.ts +3 -0
- package/lib/machines/index.d.ts.map +1 -0
- package/lib/machines/types.d.ts +77 -0
- package/lib/machines/types.d.ts.map +1 -0
- package/lib/module.d.ts +7 -0
- package/lib/module.d.ts.map +1 -0
- package/lib/module.js +26 -0
- package/lib/module.js.map +1 -0
- package/lib/routes.json +98 -0
- package/lib/styles/responsive.css +76 -0
- package/lib/templates/InboxWithAi.d.ts +15 -0
- package/lib/templates/InboxWithAi.d.ts.map +1 -0
- package/lib/templates/InboxWithAi.js +440 -0
- package/lib/templates/InboxWithAi.js.map +1 -0
- package/lib/templates/InboxWithAi.tsx +533 -0
- package/lib/templates/index.d.ts +2 -0
- package/lib/templates/index.d.ts.map +1 -0
- package/lib/templates/index.ts +1 -0
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +3 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +62 -0
- package/rollup.config.mjs +35 -0
- package/src/cdm-locales/en/translations.json +31 -0
- package/src/cdm-locales/es/translations.json +31 -0
- package/src/components/AIAgent/AIAgent.tsx +1103 -0
- package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
- package/src/components/AIAgent/README.md +82 -0
- package/src/components/AIAgent/index.ts +1 -0
- package/src/components/InboxMessage/CommonMessage.tsx +40 -0
- package/src/components/InboxMessage/ConversationItem.tsx +255 -0
- package/src/components/InboxMessage/InputComponent.tsx +462 -0
- package/src/components/InboxMessage/LeftSidebar.tsx +140 -0
- package/src/components/InboxMessage/MessageInput.tsx +209 -0
- package/src/components/InboxMessage/MessageInputComponent.tsx +245 -0
- package/src/components/InboxMessage/Messages.tsx +137 -0
- package/src/components/InboxMessage/MessagesBuilderUi.tsx +205 -0
- package/src/components/InboxMessage/Popover.tsx +42 -0
- package/src/components/InboxMessage/RightSidebar.tsx +22 -0
- package/src/components/InboxMessage/RightSidebarAi.tsx +37 -0
- package/src/components/InboxMessage/ServiceConversationItem.tsx +234 -0
- package/src/components/InboxMessage/ServiceInboxItem.tsx +223 -0
- package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
- package/src/components/InboxMessage/UploadImageButton.tsx +46 -0
- package/src/components/InboxMessage/UserModalContent.tsx +60 -0
- package/src/components/InboxMessage/index.ts +16 -0
- package/src/components/InboxMessage/message-widgets/CommonMessage.tsx +69 -0
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +240 -0
- package/src/components/InboxMessage/message-widgets/MessageCard.tsx +127 -0
- package/src/components/InboxMessage/message-widgets/MessageSliceRenderer.tsx +40 -0
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +1295 -0
- package/src/components/InboxMessage/message-widgets/PlainMessage.tsx +18 -0
- package/src/components/InboxMessage/message-widgets/PropertyMessageWidget.tsx +29 -0
- package/src/components/InboxMessage/message-widgets/SlackLikeMessageGroup.tsx +492 -0
- package/src/components/InboxMessage/message-widgets/index.ts +3 -0
- package/src/components/ModelConfigPanel.tsx +345 -0
- package/src/components/filler-components/RightSiderBar.tsx +408 -0
- package/src/components/inbox/FilesList.tsx +89 -0
- package/src/components/inbox/MessageItem.tsx +50 -0
- package/src/components/inbox/ThreadItem.tsx +295 -0
- package/src/components/inbox/index.ts +3 -0
- package/src/components/index.ts +22 -0
- package/src/components/live-code-editor/hybrid-live-editor.tsx +105 -0
- package/src/components/live-code-editor/index.ts +3 -0
- package/src/components/live-code-editor/live-code-editor.tsx +257 -0
- package/src/components/slot-fill/chat-message-filler.tsx +18 -0
- package/src/components/slot-fill/chat-message-slot.tsx +18 -0
- package/src/components/slot-fill/index.ts +3 -0
- package/src/components/slot-fill/right-sidebar-filler.tsx +39 -0
- package/src/components/ui/button.tsx +32 -0
- package/src/compute.ts +134 -0
- package/src/config/env-config.ts +17 -0
- package/src/config/index.ts +1 -0
- package/src/constants/breakpoints.ts +7 -0
- package/src/constants/index.ts +5 -0
- package/src/container/AiInbox.tsx +1819 -0
- package/src/container/AiInboxWithLoader.tsx +356 -0
- package/src/container/AiLandingInput.tsx +221 -0
- package/src/container/Inbox.tsx +1092 -0
- package/src/container/InboxAiMessagesLoader.tsx +44 -0
- package/src/container/InboxContainer.tsx +35 -0
- package/src/container/InboxTemplate1.tsx +1542 -0
- package/src/container/InboxTemplate1WithLoader.tsx +338 -0
- package/src/container/InboxTemplate2.tsx +1606 -0
- package/src/container/InboxWithAiLoader.tsx +76 -0
- package/src/container/InboxWithLoader.tsx +341 -0
- package/src/container/ServiceInbox.tsx +190 -0
- package/src/container/ThreadMessages.tsx +371 -0
- package/src/container/ThreadMessagesInbox.tsx +450 -0
- package/src/container/Threads.tsx +270 -0
- package/src/container/ThreadsInbox.tsx +354 -0
- package/src/container/apply-footer-styles.ts +17 -0
- package/src/container/index.ts +31 -0
- package/src/enums/index.ts +1 -0
- package/src/enums/messenger-slot-fill-name-enum.ts +4 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-file-sync.ts +91 -0
- package/src/hooks/usePersistentModelConfig.ts +63 -0
- package/src/index.ts +37 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/message-widgets.interface.ts +21 -0
- package/src/machines/aiAgentMachine.simple.ts +89 -0
- package/src/machines/aiAgentMachine.ts +1296 -0
- package/src/machines/aiAgentMachine.ts.bk +1296 -0
- package/src/machines/index.ts +2 -0
- package/src/machines/types.ts +59 -0
- package/src/module.tsx +32 -0
- package/src/styles/responsive.css +76 -0
- package/src/templates/InboxWithAi.tsx +533 -0
- package/src/templates/index.ts +1 -0
- package/src/utils/utils.ts +3 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +92 -0
|
@@ -0,0 +1,1082 @@
|
|
|
1
|
+
import React__default,{useEffect}from'react';import {format,differenceInMinutes}from'date-fns';import {FilesList}from'../../inbox/FilesList.js';import'../../inbox/MessageItem.js';import'../../inbox/ThreadItem.js';import {ErrorFixCard}from'./ErrorFixCard.js';import ReactMarkdown from'react-markdown';import remarkGfm from'remark-gfm';// Enhanced CSS styles for HTML content rendering with prettification
|
|
2
|
+
const htmlContentStyles = `
|
|
3
|
+
.html-content {
|
|
4
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
5
|
+
line-height: 1.6;
|
|
6
|
+
color: #374151;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.html-content h1, .html-content h2, .html-content h3, .html-content h4, .html-content h5, .html-content h6 {
|
|
10
|
+
margin-top: 1.5rem;
|
|
11
|
+
margin-bottom: 1rem;
|
|
12
|
+
font-weight: 600;
|
|
13
|
+
line-height: 1.25;
|
|
14
|
+
color: #111827;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.html-content h1 {
|
|
18
|
+
font-size: 1.875rem;
|
|
19
|
+
border-bottom: 2px solid #e5e7eb;
|
|
20
|
+
padding-bottom: 0.5rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.html-content h2 {
|
|
24
|
+
font-size: 1.5rem;
|
|
25
|
+
border-bottom: 1px solid #e5e7eb;
|
|
26
|
+
padding-bottom: 0.375rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.html-content h3 {
|
|
30
|
+
font-size: 1.25rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.html-content p {
|
|
34
|
+
margin-bottom: 1rem;
|
|
35
|
+
line-height: 1.7;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.html-content ul, .html-content ol {
|
|
39
|
+
margin-bottom: 1rem;
|
|
40
|
+
padding-left: 1.5rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.html-content ul {
|
|
44
|
+
list-style-type: disc;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.html-content ol {
|
|
48
|
+
list-style-type: decimal;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.html-content li {
|
|
52
|
+
margin-bottom: 0.5rem;
|
|
53
|
+
line-height: 1.6;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.html-content li > ul, .html-content li > ol {
|
|
57
|
+
margin-top: 0.5rem;
|
|
58
|
+
margin-bottom: 0.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.html-content a {
|
|
62
|
+
color: #2563eb;
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
border-bottom: 1px solid transparent;
|
|
65
|
+
transition: all 0.2s ease;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.html-content a:hover {
|
|
69
|
+
color: #1d4ed8;
|
|
70
|
+
border-bottom-color: #1d4ed8;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.html-content strong, .html-content b {
|
|
74
|
+
font-weight: 600;
|
|
75
|
+
color: #111827;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.html-content em, .html-content i {
|
|
79
|
+
font-style: italic;
|
|
80
|
+
color: #6b7280;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.html-content code {
|
|
84
|
+
background-color: #f3f4f6;
|
|
85
|
+
padding: 0.25rem 0.5rem;
|
|
86
|
+
border-radius: 0.375rem;
|
|
87
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
88
|
+
font-size: 0.875rem;
|
|
89
|
+
color: #dc2626;
|
|
90
|
+
border: 1px solid #e5e7eb;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.html-content pre {
|
|
94
|
+
background-color: #f9fafb;
|
|
95
|
+
padding: 1rem;
|
|
96
|
+
border-radius: 0.5rem;
|
|
97
|
+
overflow-x: auto;
|
|
98
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
99
|
+
font-size: 0.875rem;
|
|
100
|
+
line-height: 1.5;
|
|
101
|
+
border: 1px solid #e5e7eb;
|
|
102
|
+
margin: 1.5rem 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.html-content pre code {
|
|
106
|
+
background-color: transparent;
|
|
107
|
+
padding: 0;
|
|
108
|
+
border: none;
|
|
109
|
+
color: #374151;
|
|
110
|
+
font-size: inherit;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.html-content blockquote {
|
|
114
|
+
border-left: 4px solid #3b82f6;
|
|
115
|
+
padding-left: 1rem;
|
|
116
|
+
margin: 1.5rem 0;
|
|
117
|
+
font-style: italic;
|
|
118
|
+
color: #6b7280;
|
|
119
|
+
background-color: #f8fafc;
|
|
120
|
+
padding: 1rem;
|
|
121
|
+
border-radius: 0.375rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.html-content blockquote p {
|
|
125
|
+
margin-bottom: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.html-content table {
|
|
129
|
+
border-collapse: collapse;
|
|
130
|
+
border: 1px solid #e5e7eb;
|
|
131
|
+
width: 100%;
|
|
132
|
+
margin: 1.5rem 0;
|
|
133
|
+
border-radius: 0.5rem;
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.html-content th,
|
|
139
|
+
.html-content td {
|
|
140
|
+
border: 1px solid #e5e7eb;
|
|
141
|
+
padding: 0.75rem;
|
|
142
|
+
text-align: left;
|
|
143
|
+
vertical-align: top;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.html-content th {
|
|
147
|
+
background-color: #f9fafb;
|
|
148
|
+
font-weight: 600;
|
|
149
|
+
color: #111827;
|
|
150
|
+
border-bottom: 2px solid #e5e7eb;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.html-content tr:nth-child(even) {
|
|
154
|
+
background-color: #f9fafb;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.html-content tr:hover {
|
|
158
|
+
background-color: #f3f4f6;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.html-content hr {
|
|
162
|
+
border: none;
|
|
163
|
+
border-top: 2px solid #e5e7eb;
|
|
164
|
+
margin: 2rem 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.html-content img {
|
|
168
|
+
max-width: 100%;
|
|
169
|
+
height: auto;
|
|
170
|
+
border-radius: 0.5rem;
|
|
171
|
+
margin: 1rem 0;
|
|
172
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Enhanced message container styling */
|
|
176
|
+
.message-container {
|
|
177
|
+
background: #ffffff;
|
|
178
|
+
padding-top: 16px;
|
|
179
|
+
padding-bottom: 16px;
|
|
180
|
+
margin: 12px 0;
|
|
181
|
+
transition: all 0.2s ease-in-out;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Markdown content styling */
|
|
185
|
+
.markdown-content {
|
|
186
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
187
|
+
line-height: 1.6;
|
|
188
|
+
color: #374151;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.markdown-content h1 {
|
|
192
|
+
font-size: 1.5rem;
|
|
193
|
+
font-weight: 700;
|
|
194
|
+
margin-top: 1.5rem;
|
|
195
|
+
margin-bottom: 1rem;
|
|
196
|
+
color: #111827;
|
|
197
|
+
padding-bottom: 0.5rem;
|
|
198
|
+
border-bottom: 2px solid #e5e7eb;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.markdown-content h2 {
|
|
202
|
+
font-size: 1.25rem;
|
|
203
|
+
font-weight: 600;
|
|
204
|
+
margin-top: 1.25rem;
|
|
205
|
+
margin-bottom: 0.75rem;
|
|
206
|
+
color: #1f2937;
|
|
207
|
+
padding-bottom: 0.375rem;
|
|
208
|
+
border-bottom: 1px solid #e5e7eb;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.markdown-content h3 {
|
|
212
|
+
font-size: 1.125rem;
|
|
213
|
+
font-weight: 600;
|
|
214
|
+
margin-top: 1rem;
|
|
215
|
+
margin-bottom: 0.5rem;
|
|
216
|
+
color: #374151;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.markdown-content p {
|
|
220
|
+
margin-bottom: 0.75rem;
|
|
221
|
+
line-height: 1.6;
|
|
222
|
+
color: #4b5563;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.markdown-content ul, .markdown-content ol {
|
|
226
|
+
margin: 1rem 0;
|
|
227
|
+
padding-left: 1.5rem;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.markdown-content li {
|
|
231
|
+
margin-bottom: 0.5rem;
|
|
232
|
+
line-height: 1.6;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.markdown-content code {
|
|
236
|
+
background-color: #f3f4f6;
|
|
237
|
+
padding: 0.125rem 0.375rem;
|
|
238
|
+
border-radius: 0.25rem;
|
|
239
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
240
|
+
font-size: 0.875rem;
|
|
241
|
+
color: #dc2626;
|
|
242
|
+
border: 1px solid #e5e7eb;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.markdown-content pre {
|
|
246
|
+
color: #1f2937;
|
|
247
|
+
border-radius: 8px;
|
|
248
|
+
overflow-x: auto;
|
|
249
|
+
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
|
|
250
|
+
font-size: 0.875rem;
|
|
251
|
+
line-height: 1.5;
|
|
252
|
+
margin: 1rem 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.markdown-content pre code {
|
|
256
|
+
background-color: transparent;
|
|
257
|
+
padding: 0;
|
|
258
|
+
border: none;
|
|
259
|
+
color: #1f2937;
|
|
260
|
+
font-size: inherit;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.markdown-content blockquote {
|
|
264
|
+
border-left: 4px solid #3b82f6;
|
|
265
|
+
background-color: #f8fafc;
|
|
266
|
+
padding: 1rem;
|
|
267
|
+
margin: 1rem 0;
|
|
268
|
+
border-radius: 6px;
|
|
269
|
+
font-style: italic;
|
|
270
|
+
color: #475569;
|
|
271
|
+
border-top: 1px solid #e5e7eb;
|
|
272
|
+
border-right: 1px solid #e5e7eb;
|
|
273
|
+
border-bottom: 1px solid #e5e7eb;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.markdown-content table {
|
|
277
|
+
border-collapse: collapse;
|
|
278
|
+
border: 1px solid #e5e7eb;
|
|
279
|
+
width: 100%;
|
|
280
|
+
margin: 1rem 0;
|
|
281
|
+
border-radius: 8px;
|
|
282
|
+
overflow: hidden;
|
|
283
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.markdown-content th {
|
|
287
|
+
background-color: #f9fafb;
|
|
288
|
+
color: #374151;
|
|
289
|
+
font-weight: 600;
|
|
290
|
+
padding: 0.75rem;
|
|
291
|
+
text-align: left;
|
|
292
|
+
border-bottom: 1px solid #e5e7eb;
|
|
293
|
+
font-size: 0.875rem;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.markdown-content td {
|
|
297
|
+
border: 1px solid #e5e7eb;
|
|
298
|
+
padding: 0.75rem;
|
|
299
|
+
text-align: left;
|
|
300
|
+
vertical-align: top;
|
|
301
|
+
background-color: white;
|
|
302
|
+
font-size: 0.875rem;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.markdown-content tr:nth-child(even) td {
|
|
306
|
+
background-color: #f9fafb;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.markdown-content tr:hover td {
|
|
310
|
+
background-color: #f3f4f6;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Enhanced list styling */
|
|
314
|
+
.markdown-content ul li {
|
|
315
|
+
position: relative;
|
|
316
|
+
padding-left: 0.5rem;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.markdown-content ul li::before {
|
|
320
|
+
content: "•";
|
|
321
|
+
color: #000;
|
|
322
|
+
font-weight: bold;
|
|
323
|
+
position: absolute;
|
|
324
|
+
left: -1rem;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.markdown-content ol li {
|
|
328
|
+
position: relative;
|
|
329
|
+
padding-left: 0.5rem;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.markdown-content ol li::before {
|
|
333
|
+
content: counter(list-item) ".";
|
|
334
|
+
font-weight: 600;
|
|
335
|
+
position: absolute;
|
|
336
|
+
left: -1.5rem;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* Code block container styling */
|
|
340
|
+
.code-block-container {
|
|
341
|
+
background: #ffffff;
|
|
342
|
+
border: 1px solid #e5e7eb;
|
|
343
|
+
border-radius: 8px;
|
|
344
|
+
overflow: hidden;
|
|
345
|
+
margin: 1rem 0;
|
|
346
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.code-block-header {
|
|
350
|
+
background: #f9fafb;
|
|
351
|
+
padding: 0.5rem 1rem;
|
|
352
|
+
border-bottom: 1px solid #e5e7eb;
|
|
353
|
+
font-weight: 600;
|
|
354
|
+
color: #374151;
|
|
355
|
+
font-size: 0.875rem;
|
|
356
|
+
text-transform: uppercase;
|
|
357
|
+
letter-spacing: 0.05em;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.code-block-content {
|
|
361
|
+
padding: 1rem;
|
|
362
|
+
overflow-x: auto;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.hover\:bg-gray-100:hover {
|
|
366
|
+
background-color: transparent !important;
|
|
367
|
+
}
|
|
368
|
+
`;
|
|
369
|
+
// Hook to inject CSS styles
|
|
370
|
+
const useInjectStyles = () => {
|
|
371
|
+
useEffect(() => {
|
|
372
|
+
// Check if styles are already injected
|
|
373
|
+
if (document.getElementById('html-content-styles')) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
// Create and inject style element
|
|
377
|
+
const styleElement = document.createElement('style');
|
|
378
|
+
styleElement.id = 'html-content-styles';
|
|
379
|
+
styleElement.textContent = htmlContentStyles;
|
|
380
|
+
document.head.appendChild(styleElement);
|
|
381
|
+
// Cleanup function
|
|
382
|
+
return () => {
|
|
383
|
+
const existingStyle = document.getElementById('html-content-styles');
|
|
384
|
+
if (existingStyle) {
|
|
385
|
+
existingStyle.remove();
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}, []);
|
|
389
|
+
};
|
|
390
|
+
// Enhanced utility function to group messages by user and time
|
|
391
|
+
const groupMessagesByUserAndTime = (messages, timeThresholdMinutes = 5) => {
|
|
392
|
+
if (!messages || messages.length === 0) return [];
|
|
393
|
+
const groups = [];
|
|
394
|
+
let currentGroup = [];
|
|
395
|
+
let lastMessage = null;
|
|
396
|
+
for (const message of messages) {
|
|
397
|
+
if (typeof message === 'string') continue; // Skip date separators
|
|
398
|
+
const shouldStartNewGroup = !lastMessage || lastMessage.author?.id !== message.author?.id || differenceInMinutes(new Date(message.createdAt), new Date(lastMessage.createdAt)) > timeThresholdMinutes;
|
|
399
|
+
if (shouldStartNewGroup) {
|
|
400
|
+
if (currentGroup.length > 0) {
|
|
401
|
+
groups.push(currentGroup);
|
|
402
|
+
}
|
|
403
|
+
currentGroup = [message];
|
|
404
|
+
} else {
|
|
405
|
+
currentGroup.push(message);
|
|
406
|
+
}
|
|
407
|
+
lastMessage = message;
|
|
408
|
+
}
|
|
409
|
+
if (currentGroup.length > 0) {
|
|
410
|
+
groups.push(currentGroup);
|
|
411
|
+
}
|
|
412
|
+
return groups;
|
|
413
|
+
};
|
|
414
|
+
// Enhanced content detection that properly identifies different content types
|
|
415
|
+
const detectContentType = value => {
|
|
416
|
+
if (!value) return 'text';
|
|
417
|
+
const trimmed = value.trim();
|
|
418
|
+
// Check for code patterns first (most specific)
|
|
419
|
+
const codePatterns = [/```[\s\S]*?```/g,
|
|
420
|
+
// Fenced code blocks
|
|
421
|
+
/`[^`\n]+`/g,
|
|
422
|
+
// Inline code
|
|
423
|
+
/---\s*\w+\.\w+\s*---/g,
|
|
424
|
+
// File separators like "--- src/index.css ---"
|
|
425
|
+
/@tailwind\s+\w+/g,
|
|
426
|
+
// Tailwind directives
|
|
427
|
+
/export\s+default\s*\{/g,
|
|
428
|
+
// JS/TS exports
|
|
429
|
+
/import\s+.*\s+from\s+['"]/g,
|
|
430
|
+
// Import statements
|
|
431
|
+
/\/\*\*[\s\S]*?\*\//g,
|
|
432
|
+
// JSDoc comments
|
|
433
|
+
/\/\*[\s\S]*?\*\//g,
|
|
434
|
+
// Block comments
|
|
435
|
+
/\/\/.*$/gm // Line comments
|
|
436
|
+
];
|
|
437
|
+
const hasCodePatterns = codePatterns.some(pattern => pattern.test(trimmed));
|
|
438
|
+
if (hasCodePatterns) return 'code';
|
|
439
|
+
// Check for markdown patterns
|
|
440
|
+
const markdownPatterns = [/^#{1,6}\s+/gm,
|
|
441
|
+
// Headers
|
|
442
|
+
/\*\*.*?\*\*/g,
|
|
443
|
+
// Bold
|
|
444
|
+
/\*.*?\*/g,
|
|
445
|
+
// Italic
|
|
446
|
+
/^\s*[-*+]\s+/gm,
|
|
447
|
+
// Lists
|
|
448
|
+
/^\s*\d+\.\s+/gm,
|
|
449
|
+
// Numbered lists
|
|
450
|
+
/\[.*?\]\(.*?\)/g,
|
|
451
|
+
// Links
|
|
452
|
+
/!\[.*?\]\(.*?\)/g // Images
|
|
453
|
+
];
|
|
454
|
+
const hasMarkdownPatterns = markdownPatterns.some(pattern => pattern.test(trimmed));
|
|
455
|
+
if (hasMarkdownPatterns) return 'markdown';
|
|
456
|
+
// Check for HTML patterns
|
|
457
|
+
const htmlPatterns = [/<\/?[a-z][\s\S]*>/i,
|
|
458
|
+
// HTML tags
|
|
459
|
+
/&[a-z0-9#]+;/i,
|
|
460
|
+
// HTML entities
|
|
461
|
+
/\s+[a-z-]+\s*=\s*["'][^"']*["']/i,
|
|
462
|
+
// HTML attributes
|
|
463
|
+
/<[^>]+>[^<]*<\/[^>]+>/i // HTML structure
|
|
464
|
+
];
|
|
465
|
+
const hasHtmlPatterns = htmlPatterns.some(pattern => pattern.test(trimmed));
|
|
466
|
+
if (hasHtmlPatterns) return 'html';
|
|
467
|
+
return 'text';
|
|
468
|
+
};
|
|
469
|
+
// Enhanced sanitizer that allows most HTML tags while maintaining security
|
|
470
|
+
const sanitizeHtml = html => {
|
|
471
|
+
try {
|
|
472
|
+
if (typeof window === 'undefined' || typeof window.DOMParser === 'undefined') {
|
|
473
|
+
return html.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '').replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi, '').replace(/on\w+\s*=\s*"[^"]*"/gi, '').replace(/on\w+\s*=\s*'[^']*'/gi, '').replace(/on\w+\s*=\s*[^\s>]+/gi, '').replace(/javascript:/gi, '').replace(/data:text\/html/gi, '');
|
|
474
|
+
}
|
|
475
|
+
const parser = new window.DOMParser();
|
|
476
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
477
|
+
// Only remove the most dangerous tags
|
|
478
|
+
const dangerousTags = ['script', 'style'];
|
|
479
|
+
dangerousTags.forEach(tag => {
|
|
480
|
+
doc.querySelectorAll(tag).forEach(el => el.remove());
|
|
481
|
+
});
|
|
482
|
+
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT);
|
|
483
|
+
let node = walker.nextNode();
|
|
484
|
+
while (node) {
|
|
485
|
+
Array.from(node.attributes).forEach(attr => {
|
|
486
|
+
const name = attr.name.toLowerCase();
|
|
487
|
+
const value = (attr.value || '').toLowerCase();
|
|
488
|
+
// Remove event handlers and javascript protocols
|
|
489
|
+
if (name.startsWith('on') || value.startsWith('javascript:')) {
|
|
490
|
+
node?.removeAttribute(attr.name);
|
|
491
|
+
}
|
|
492
|
+
// Allow most attributes but validate URLs for src/href
|
|
493
|
+
if ((name === 'src' || name === 'href') && !/^https?:|^\/.*/.test(attr.value)) {
|
|
494
|
+
node?.removeAttribute(attr.name);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
node = walker.nextNode();
|
|
498
|
+
}
|
|
499
|
+
return doc.body.innerHTML;
|
|
500
|
+
} catch (e) {
|
|
501
|
+
return html.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '');
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
// Function to prettify HTML content
|
|
505
|
+
const prettifyHtmlContent = htmlContent => {
|
|
506
|
+
// Add semantic classes for better styling
|
|
507
|
+
let prettified = htmlContent;
|
|
508
|
+
// Enhance headings with better styling
|
|
509
|
+
prettified = prettified.replace(/<h([1-6])>/g, '<h$1 class="html-heading html-heading-$1">');
|
|
510
|
+
// Enhance lists with better styling
|
|
511
|
+
prettified = prettified.replace(/<ul>/g, '<ul class="html-list html-list-unordered">');
|
|
512
|
+
prettified = prettified.replace(/<ol>/g, '<ol class="html-list html-list-ordered">');
|
|
513
|
+
// Enhance paragraphs with better spacing
|
|
514
|
+
prettified = prettified.replace(/<p>/g, '<p class="html-paragraph">');
|
|
515
|
+
// Enhance code blocks
|
|
516
|
+
prettified = prettified.replace(/<code>/g, '<code class="html-inline-code">');
|
|
517
|
+
prettified = prettified.replace(/<pre>/g, '<pre class="html-code-block">');
|
|
518
|
+
// Enhance blockquotes
|
|
519
|
+
prettified = prettified.replace(/<blockquote>/g, '<blockquote class="html-blockquote">');
|
|
520
|
+
// Enhance tables
|
|
521
|
+
prettified = prettified.replace(/<table>/g, '<table class="html-table">');
|
|
522
|
+
prettified = prettified.replace(/<th>/g, '<th class="html-table-header">');
|
|
523
|
+
prettified = prettified.replace(/<td>/g, '<td class="html-table-cell">');
|
|
524
|
+
// Add info boxes for certain content patterns
|
|
525
|
+
prettified = prettified.replace(/<p>(Note|Tip|Info|Warning|Error):\s*(.*?)<\/p>/gi, '<div class="html-info-box"><strong>$1:</strong> $2</div>');
|
|
526
|
+
return prettified;
|
|
527
|
+
};
|
|
528
|
+
// Minimal Builder-like blocks renderer (text/image/button/columns)
|
|
529
|
+
const BuilderLikeRenderer = ({
|
|
530
|
+
blocks
|
|
531
|
+
}) => {
|
|
532
|
+
if (!blocks || !Array.isArray(blocks) || blocks.length === 0) return null;
|
|
533
|
+
return React__default.createElement("div", {
|
|
534
|
+
className: "space-y-3"
|
|
535
|
+
}, blocks.map((block, idx) => {
|
|
536
|
+
const type = block?.['@type'] || block?.type;
|
|
537
|
+
if (!type) return null;
|
|
538
|
+
if (/text/i.test(type)) {
|
|
539
|
+
const html = sanitizeHtml(block?.text || block?.data?.text || '');
|
|
540
|
+
return React__default.createElement("div", {
|
|
541
|
+
key: idx,
|
|
542
|
+
className: "max-w-none text-gray-800",
|
|
543
|
+
dangerouslySetInnerHTML: {
|
|
544
|
+
__html: html
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
if (/image/i.test(type)) {
|
|
549
|
+
const src = block?.src || block?.image || block?.data?.src;
|
|
550
|
+
const alt = block?.alt || block?.data?.alt || '';
|
|
551
|
+
if (!src) return null;
|
|
552
|
+
return React__default.createElement("div", {
|
|
553
|
+
key: idx,
|
|
554
|
+
className: "rounded-lg overflow-hidden border border-gray-200"
|
|
555
|
+
}, React__default.createElement("img", {
|
|
556
|
+
className: "w-full h-auto",
|
|
557
|
+
src: src,
|
|
558
|
+
alt: alt
|
|
559
|
+
}));
|
|
560
|
+
}
|
|
561
|
+
if (/button/i.test(type)) {
|
|
562
|
+
const text = block?.text || block?.data?.text || 'Button';
|
|
563
|
+
const href = block?.href || block?.link || block?.data?.href || '#';
|
|
564
|
+
return React__default.createElement("a", {
|
|
565
|
+
key: idx,
|
|
566
|
+
href: href,
|
|
567
|
+
target: "_blank",
|
|
568
|
+
rel: "noopener noreferrer",
|
|
569
|
+
className: "inline-flex items-center px-3 py-1.5 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700"
|
|
570
|
+
}, text);
|
|
571
|
+
}
|
|
572
|
+
if (/columns?/i.test(type)) {
|
|
573
|
+
const cols = block?.columns || block?.data?.columns || [];
|
|
574
|
+
return React__default.createElement("div", {
|
|
575
|
+
key: idx,
|
|
576
|
+
className: "grid grid-cols-1 sm:grid-cols-2 gap-3"
|
|
577
|
+
}, cols.map((col, colIdx) => React__default.createElement("div", {
|
|
578
|
+
key: colIdx,
|
|
579
|
+
className: "space-y-2"
|
|
580
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
581
|
+
blocks: col?.blocks || col?.children
|
|
582
|
+
}))));
|
|
583
|
+
}
|
|
584
|
+
return React__default.createElement("div", {
|
|
585
|
+
key: idx,
|
|
586
|
+
className: "message-container"
|
|
587
|
+
}, React__default.createElement("pre", {
|
|
588
|
+
className: "text-xs text-gray-600 overflow-x-auto"
|
|
589
|
+
}, JSON.stringify(block, null, 2)));
|
|
590
|
+
}));
|
|
591
|
+
};
|
|
592
|
+
// Enhanced code formatter for raw code content
|
|
593
|
+
const CodeFormatter = ({
|
|
594
|
+
content
|
|
595
|
+
}) => {
|
|
596
|
+
if (!content) return null;
|
|
597
|
+
// Split content by file separators and format each section
|
|
598
|
+
const sections = content.split(/(---\s*\w+\.\w+\s*---)/g);
|
|
599
|
+
return React__default.createElement("div", {
|
|
600
|
+
className: "message-container"
|
|
601
|
+
}, React__default.createElement("div", {
|
|
602
|
+
className: "space-y-4"
|
|
603
|
+
}, sections.map((section, index) => {
|
|
604
|
+
if (!section.trim()) return null;
|
|
605
|
+
// Check if this is a file separator
|
|
606
|
+
const fileMatch = section.match(/---\s*(\w+\.\w+)\s*---/);
|
|
607
|
+
if (fileMatch) {
|
|
608
|
+
return React__default.createElement("div", {
|
|
609
|
+
key: index,
|
|
610
|
+
className: "code-block-container"
|
|
611
|
+
}, React__default.createElement("div", {
|
|
612
|
+
className: "code-block-header"
|
|
613
|
+
}, "\uD83D\uDCC4 ", fileMatch[1]));
|
|
614
|
+
}
|
|
615
|
+
// Format the code content
|
|
616
|
+
const lines = section.trim().split('\n');
|
|
617
|
+
const isCode = lines.some(line => line.includes('@tailwind') || line.includes('export default') || line.includes('import ') || line.includes('{') || line.includes('}') || line.includes('//') || line.includes('/*'));
|
|
618
|
+
if (isCode) {
|
|
619
|
+
return React__default.createElement("div", {
|
|
620
|
+
key: index,
|
|
621
|
+
className: "code-block-container"
|
|
622
|
+
}, React__default.createElement("div", {
|
|
623
|
+
className: "code-block-content"
|
|
624
|
+
}, React__default.createElement("pre", {
|
|
625
|
+
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap"
|
|
626
|
+
}, React__default.createElement("code", null, section.trim()))));
|
|
627
|
+
}
|
|
628
|
+
// Regular text content
|
|
629
|
+
return React__default.createElement("div", {
|
|
630
|
+
key: index,
|
|
631
|
+
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
632
|
+
}, section.trim());
|
|
633
|
+
})));
|
|
634
|
+
};
|
|
635
|
+
// Enhanced markdown renderer using react-markdown with remark-gfm
|
|
636
|
+
const FormattedMessageContent = ({
|
|
637
|
+
content
|
|
638
|
+
}) => {
|
|
639
|
+
if (!content) return null;
|
|
640
|
+
// Check if content contains markdown patterns
|
|
641
|
+
const hasMarkdown = /[#*`>|]/.test(content) || content.includes('```');
|
|
642
|
+
if (hasMarkdown) {
|
|
643
|
+
return React__default.createElement("div", {
|
|
644
|
+
className: "message-container"
|
|
645
|
+
}, React__default.createElement("div", {
|
|
646
|
+
className: "markdown-content"
|
|
647
|
+
}, React__default.createElement(ReactMarkdown, {
|
|
648
|
+
remarkPlugins: [remarkGfm],
|
|
649
|
+
components: {
|
|
650
|
+
// Custom styling for code blocks
|
|
651
|
+
code: ({
|
|
652
|
+
className,
|
|
653
|
+
children,
|
|
654
|
+
...props
|
|
655
|
+
}) => {
|
|
656
|
+
const match = /language-(\w+)/.exec(className || '');
|
|
657
|
+
const isInline = !className?.includes('language-');
|
|
658
|
+
return !isInline ? React__default.createElement("div", {
|
|
659
|
+
className: "code-block-container"
|
|
660
|
+
}, React__default.createElement("div", {
|
|
661
|
+
className: "code-block-header"
|
|
662
|
+
}, match?.[1] || 'code'), React__default.createElement("div", {
|
|
663
|
+
className: "code-block-content"
|
|
664
|
+
}, React__default.createElement("pre", {
|
|
665
|
+
className: "text-sm text-gray-900 font-mono leading-relaxed whitespace-pre-wrap"
|
|
666
|
+
}, React__default.createElement("code", {
|
|
667
|
+
className: className,
|
|
668
|
+
...props
|
|
669
|
+
}, children)))) : React__default.createElement("code", {
|
|
670
|
+
className: "bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono text-gray-800 border border-gray-200",
|
|
671
|
+
...props
|
|
672
|
+
}, children);
|
|
673
|
+
},
|
|
674
|
+
// Custom styling for headings
|
|
675
|
+
h1: ({
|
|
676
|
+
children,
|
|
677
|
+
...props
|
|
678
|
+
}) => React__default.createElement("h1", {
|
|
679
|
+
className: "text-xl font-bold text-gray-900 mb-3",
|
|
680
|
+
...props
|
|
681
|
+
}, children),
|
|
682
|
+
h2: ({
|
|
683
|
+
children,
|
|
684
|
+
...props
|
|
685
|
+
}) => React__default.createElement("h2", {
|
|
686
|
+
className: "text-lg font-semibold text-gray-800 mb-2",
|
|
687
|
+
...props
|
|
688
|
+
}, children),
|
|
689
|
+
h3: ({
|
|
690
|
+
children,
|
|
691
|
+
...props
|
|
692
|
+
}) => React__default.createElement("h3", {
|
|
693
|
+
className: "text-base font-medium text-gray-700 mb-2",
|
|
694
|
+
...props
|
|
695
|
+
}, children),
|
|
696
|
+
// Custom styling for lists
|
|
697
|
+
ul: ({
|
|
698
|
+
children,
|
|
699
|
+
...props
|
|
700
|
+
}) => React__default.createElement("ul", {
|
|
701
|
+
className: "space-y-1",
|
|
702
|
+
...props
|
|
703
|
+
}, children),
|
|
704
|
+
ol: ({
|
|
705
|
+
children,
|
|
706
|
+
...props
|
|
707
|
+
}) => React__default.createElement("ol", {
|
|
708
|
+
className: "space-y-1",
|
|
709
|
+
...props
|
|
710
|
+
}, children),
|
|
711
|
+
li: ({
|
|
712
|
+
children,
|
|
713
|
+
...props
|
|
714
|
+
}) => React__default.createElement("li", {
|
|
715
|
+
className: "text-gray-700 leading-relaxed",
|
|
716
|
+
...props
|
|
717
|
+
}, children),
|
|
718
|
+
// Custom styling for blockquotes
|
|
719
|
+
blockquote: ({
|
|
720
|
+
children,
|
|
721
|
+
...props
|
|
722
|
+
}) => React__default.createElement("blockquote", {
|
|
723
|
+
className: "border-l-4 border-blue-400 pl-3 py-2 bg-blue-50 rounded-r-md my-3",
|
|
724
|
+
...props
|
|
725
|
+
}, children),
|
|
726
|
+
// Custom styling for tables
|
|
727
|
+
table: ({
|
|
728
|
+
children,
|
|
729
|
+
...props
|
|
730
|
+
}) => React__default.createElement("div", {
|
|
731
|
+
className: "overflow-x-auto my-3"
|
|
732
|
+
}, React__default.createElement("table", {
|
|
733
|
+
className: "min-w-full border border-gray-200 rounded-md overflow-hidden",
|
|
734
|
+
...props
|
|
735
|
+
}, children)),
|
|
736
|
+
th: ({
|
|
737
|
+
children,
|
|
738
|
+
...props
|
|
739
|
+
}) => React__default.createElement("th", {
|
|
740
|
+
className: "px-3 py-2 text-left font-medium text-gray-700 border border-gray-200",
|
|
741
|
+
...props
|
|
742
|
+
}, children),
|
|
743
|
+
td: ({
|
|
744
|
+
children,
|
|
745
|
+
...props
|
|
746
|
+
}) => React__default.createElement("td", {
|
|
747
|
+
className: "px-3 py-2 border border-gray-200 text-gray-700",
|
|
748
|
+
...props
|
|
749
|
+
}, children),
|
|
750
|
+
// Custom styling for task lists (from remark-gfm)
|
|
751
|
+
input: ({
|
|
752
|
+
checked,
|
|
753
|
+
...props
|
|
754
|
+
}) => React__default.createElement("input", {
|
|
755
|
+
type: "checkbox",
|
|
756
|
+
checked: checked,
|
|
757
|
+
readOnly: true,
|
|
758
|
+
className: "mr-2 mt-1 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",
|
|
759
|
+
...props
|
|
760
|
+
}),
|
|
761
|
+
// Custom styling for strikethrough (from remark-gfm)
|
|
762
|
+
del: ({
|
|
763
|
+
children,
|
|
764
|
+
...props
|
|
765
|
+
}) => React__default.createElement("del", {
|
|
766
|
+
className: "text-gray-500 line-through",
|
|
767
|
+
...props
|
|
768
|
+
}, children)
|
|
769
|
+
}
|
|
770
|
+
}, content)));
|
|
771
|
+
}
|
|
772
|
+
// For plain text content
|
|
773
|
+
return React__default.createElement("div", {
|
|
774
|
+
className: "message-container"
|
|
775
|
+
}, React__default.createElement("p", {
|
|
776
|
+
className: "text-gray-700 leading-relaxed whitespace-pre-wrap"
|
|
777
|
+
}, content));
|
|
778
|
+
};
|
|
779
|
+
// Detect predominant text direction (RTL/LTR) for international content
|
|
780
|
+
const detectTextDirection = text => {
|
|
781
|
+
if (!text) return 'ltr';
|
|
782
|
+
const rtlRanges = /[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/g; // Hebrew, Arabic, etc.
|
|
783
|
+
const ltrRanges = /[A-Za-z\u00C0-\u024F\u1E00-\u1EFF]/g;
|
|
784
|
+
const rtlCount = (text.match(rtlRanges) || []).length;
|
|
785
|
+
const ltrCount = (text.match(ltrRanges) || []).length;
|
|
786
|
+
return rtlCount > ltrCount ? 'rtl' : 'ltr';
|
|
787
|
+
};
|
|
788
|
+
// Lightweight language heuristic for lang attribute
|
|
789
|
+
const detectLanguageTag = text => {
|
|
790
|
+
if (!text) return 'en';
|
|
791
|
+
if (/\p{Script=Arabic}/u.test(text)) return 'ar';
|
|
792
|
+
if (/[\u0590-\u05FF]/.test(text)) return 'he';
|
|
793
|
+
if (/[\u0600-\u06FF]/.test(text)) return 'fa';
|
|
794
|
+
if (/[\u0900-\u097F]/.test(text)) return 'hi';
|
|
795
|
+
if (/[\u4E00-\u9FFF]/.test(text)) return 'zh';
|
|
796
|
+
if (/[\u3040-\u309F\u30A0-\u30FF]/.test(text)) return 'ja';
|
|
797
|
+
if (/[\uAC00-\uD7AF]/.test(text)) return 'ko';
|
|
798
|
+
if (/[\u0400-\u04FF]/.test(text)) return 'ru';
|
|
799
|
+
if (/[\u0E00-\u0E7F]/.test(text)) return 'th';
|
|
800
|
+
return 'en';
|
|
801
|
+
};
|
|
802
|
+
// Attempt to parse Builder.io-like JSON blocks embedded as message string
|
|
803
|
+
const tryExtractBuilderBlocks = content => {
|
|
804
|
+
if (!content || content.length < 2) return null;
|
|
805
|
+
try {
|
|
806
|
+
const trimmed = content.trim();
|
|
807
|
+
const jsonMatch = trimmed.match(/([\[{][\s\S]*[\]}])/);
|
|
808
|
+
const jsonText = jsonMatch ? jsonMatch[1] : trimmed;
|
|
809
|
+
const parsed = JSON.parse(jsonText);
|
|
810
|
+
if (Array.isArray(parsed)) {
|
|
811
|
+
if (parsed.length && (parsed[0]['@type'] || parsed[0].type)) return parsed;
|
|
812
|
+
} else if (parsed && typeof parsed === 'object') {
|
|
813
|
+
if (Array.isArray(parsed.blocks)) return parsed.blocks;
|
|
814
|
+
if (Array.isArray(parsed?.data?.blocks)) return parsed.data.blocks;
|
|
815
|
+
}
|
|
816
|
+
return null;
|
|
817
|
+
} catch {
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
const ModernMessageGroup = ({
|
|
822
|
+
author,
|
|
823
|
+
messages,
|
|
824
|
+
currentUser,
|
|
825
|
+
onOpen,
|
|
826
|
+
onMessageClick,
|
|
827
|
+
isDesktopView = false,
|
|
828
|
+
isSmallScreen = false
|
|
829
|
+
}) => {
|
|
830
|
+
// Inject CSS styles for HTML content
|
|
831
|
+
useInjectStyles();
|
|
832
|
+
const isOwnMessage = author?.id === currentUser?.id;
|
|
833
|
+
const authorName = author?.givenName && author?.familyName ? `${author.givenName} ${author.familyName}` : author?.username || 'Unknown User';
|
|
834
|
+
const firstMessage = messages[0];
|
|
835
|
+
const formatTime = timestamp => {
|
|
836
|
+
const date = new Date(timestamp);
|
|
837
|
+
return format(date, 'h:mm a');
|
|
838
|
+
};
|
|
839
|
+
// Determine if this is an AI/system message for special styling
|
|
840
|
+
const isSystemMessage = author?.username?.toLowerCase().includes('ai') || author?.username?.toLowerCase().includes('assistant') || author?.username?.toLowerCase().includes('system');
|
|
841
|
+
// For user messages, don't show group header, just individual messages with avatars
|
|
842
|
+
if (isOwnMessage) {
|
|
843
|
+
return React__default.createElement("div", {
|
|
844
|
+
className: `min-h-fit ${isDesktopView ? 'space-y-1 mb-3' : isSmallScreen ? 'space-y-0.5 mb-2' : 'space-y-0.5 mb-2'}`
|
|
845
|
+
}, messages.map((message, index) => React__default.createElement(ModernMessageBubble, {
|
|
846
|
+
key: message.id,
|
|
847
|
+
message: message,
|
|
848
|
+
isOwnMessage: isOwnMessage,
|
|
849
|
+
isSystemMessage: isSystemMessage,
|
|
850
|
+
isFirstInGroup: index === 0,
|
|
851
|
+
isLastInGroup: index === messages.length - 1,
|
|
852
|
+
onMessageClick: onMessageClick,
|
|
853
|
+
formatTime: formatTime
|
|
854
|
+
})));
|
|
855
|
+
}
|
|
856
|
+
// For other messages (non-user), show the traditional group layout
|
|
857
|
+
return React__default.createElement("div", {
|
|
858
|
+
className: `group transition-all duration-300 ease-in-out ${isDesktopView ? 'mb-4 px-4 py-3' : isSmallScreen ? 'mb-2 px-2 py-1' : 'mb-3 px-3 py-1'} ${isSystemMessage ? 'bg-white rounded-lg' : ' rounded-lg'}`
|
|
859
|
+
}, React__default.createElement("div", {
|
|
860
|
+
className: `flex items-start ${isDesktopView ? 'space-x-4' : isSmallScreen ? 'space-x-2' : 'space-x-3'}`
|
|
861
|
+
}, !isSystemMessage && React__default.createElement("div", {
|
|
862
|
+
className: "flex-shrink-0 mt-1"
|
|
863
|
+
}, React__default.createElement("div", {
|
|
864
|
+
className: "relative rounded-lg overflow-hidden"
|
|
865
|
+
}, React__default.createElement("img", {
|
|
866
|
+
className: `cursor-pointer hover:opacity-80 transition-opacity ${isDesktopView ? 'w-12 h-12' : isSmallScreen ? 'w-8 h-8' : 'w-10 h-10'} rounded-lg object-cover`,
|
|
867
|
+
src: author?.picture || '/default-avatar.svg',
|
|
868
|
+
alt: authorName,
|
|
869
|
+
onClick: () => onOpen(firstMessage),
|
|
870
|
+
onError: e => {
|
|
871
|
+
e.currentTarget.src = '/default-avatar.svg';
|
|
872
|
+
}
|
|
873
|
+
}))), React__default.createElement("div", {
|
|
874
|
+
className: "flex-1 min-w-0 overflow-hidden"
|
|
875
|
+
}, !isSystemMessage && React__default.createElement("div", {
|
|
876
|
+
className: "flex items-center space-x-3 mb-2"
|
|
877
|
+
}, React__default.createElement("span", {
|
|
878
|
+
className: "font-semibold truncate text-gray-900"
|
|
879
|
+
}, authorName)), React__default.createElement("div", {
|
|
880
|
+
className: "space-y-1"
|
|
881
|
+
}, messages.map((message, index) => React__default.createElement(ModernMessageBubble, {
|
|
882
|
+
key: message.id,
|
|
883
|
+
message: message,
|
|
884
|
+
isOwnMessage: isOwnMessage,
|
|
885
|
+
isSystemMessage: isSystemMessage,
|
|
886
|
+
isFirstInGroup: index === 0,
|
|
887
|
+
isLastInGroup: index === messages.length - 1,
|
|
888
|
+
onMessageClick: onMessageClick,
|
|
889
|
+
formatTime: formatTime
|
|
890
|
+
}))))));
|
|
891
|
+
};
|
|
892
|
+
const ModernMessageBubble = ({
|
|
893
|
+
message,
|
|
894
|
+
isOwnMessage,
|
|
895
|
+
isSystemMessage,
|
|
896
|
+
isFirstInGroup,
|
|
897
|
+
isLastInGroup,
|
|
898
|
+
onMessageClick,
|
|
899
|
+
formatTime
|
|
900
|
+
}) => {
|
|
901
|
+
const handleClick = () => {
|
|
902
|
+
onMessageClick?.(message);
|
|
903
|
+
};
|
|
904
|
+
const isAssistantRole = message?.propsConfiguration?.contents?.role === 'ASSISTANT';
|
|
905
|
+
// For user messages, create a right-aligned layout with avatar and name
|
|
906
|
+
if (isOwnMessage) {
|
|
907
|
+
const authorName = message.author?.givenName && message.author?.familyName ? `${message.author.givenName} ${message.author.familyName}` : message.author?.username || 'You';
|
|
908
|
+
return React__default.createElement("div", {
|
|
909
|
+
className: `py-1 hover:bg-gray-50 hover:bg-opacity-50 rounded px-1 sm:px-2 -mx-1 sm:-mx-2 group ${isAssistantRole ? 'border border-gray-200' : ''}`
|
|
910
|
+
}, React__default.createElement("div", {
|
|
911
|
+
className: "flex items-start justify-end gap-2"
|
|
912
|
+
}, React__default.createElement("div", {
|
|
913
|
+
className: "flex flex-col items-end "
|
|
914
|
+
}, !isAssistantRole && React__default.createElement("div", {
|
|
915
|
+
className: "flex items-end space-x-2 mb-0.5"
|
|
916
|
+
}, React__default.createElement("span", {
|
|
917
|
+
className: "text-sm font-semibold text-gray-900"
|
|
918
|
+
}, authorName)), React__default.createElement("div", {
|
|
919
|
+
className: `text-sm text-gray-900 ${isAssistantRole ? 'cursor-pointer' : ''} px-1 sm:px-2 py-1 rounded`,
|
|
920
|
+
onClick: isAssistantRole ? handleClick : undefined,
|
|
921
|
+
dir: detectTextDirection(message?.message || ''),
|
|
922
|
+
lang: detectLanguageTag(message?.message || '')
|
|
923
|
+
}, message.message && React__default.createElement("div", {
|
|
924
|
+
className: "max-w-none"
|
|
925
|
+
}, (() => {
|
|
926
|
+
const contentType = detectContentType(message.message);
|
|
927
|
+
if (contentType === 'code') {
|
|
928
|
+
return React__default.createElement(CodeFormatter, {
|
|
929
|
+
content: message.message
|
|
930
|
+
});
|
|
931
|
+
} else if (contentType === 'html') {
|
|
932
|
+
return React__default.createElement("div", {
|
|
933
|
+
className: "text-gray-800 html-content",
|
|
934
|
+
dangerouslySetInnerHTML: {
|
|
935
|
+
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
} else {
|
|
939
|
+
return React__default.createElement(FormattedMessageContent, {
|
|
940
|
+
content: message.message
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
})()), tryExtractBuilderBlocks(message?.message)?.length ? React__default.createElement("div", {
|
|
944
|
+
className: "mt-2"
|
|
945
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
946
|
+
blocks: tryExtractBuilderBlocks(message?.message)
|
|
947
|
+
})) : null, message?.props?.blocks?.length ? React__default.createElement("div", {
|
|
948
|
+
className: "mt-2"
|
|
949
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
950
|
+
blocks: message.props.blocks
|
|
951
|
+
})) : null, message.files?.totalCount > 0 && React__default.createElement("div", {
|
|
952
|
+
className: "mt-2"
|
|
953
|
+
}, React__default.createElement(FilesList, {
|
|
954
|
+
uploaded: true,
|
|
955
|
+
files: message.files.data
|
|
956
|
+
})))), !isAssistantRole && React__default.createElement("div", {
|
|
957
|
+
className: "flex-shrink-0 mt-0.5"
|
|
958
|
+
}, React__default.createElement("img", {
|
|
959
|
+
className: `w-8 h-8 sm:w-10 sm:h-10 rounded-lg ${isAssistantRole ? '' : 'cursor-pointer hover:opacity-80'} transition-opacity object-cover`,
|
|
960
|
+
src: message.author?.picture || '/default-avatar.svg',
|
|
961
|
+
alt: authorName,
|
|
962
|
+
onClick: isAssistantRole ? undefined : handleClick,
|
|
963
|
+
onError: e => {
|
|
964
|
+
e.currentTarget.src = '/default-avatar.svg';
|
|
965
|
+
}
|
|
966
|
+
}))));
|
|
967
|
+
}
|
|
968
|
+
// For other messages (left-aligned with full formatting)
|
|
969
|
+
return React__default.createElement("div", {
|
|
970
|
+
className: `group/message transition-all duration-200 hover:bg-gray-50 rounded-lg px-3 py-1 -mx-3 ${isSystemMessage || isAssistantRole ? '' : 'cursor-pointer'}`,
|
|
971
|
+
onClick: isSystemMessage || isAssistantRole ? undefined : handleClick
|
|
972
|
+
}, React__default.createElement("div", {
|
|
973
|
+
className: "flex items-start justify-between gap-3"
|
|
974
|
+
}, React__default.createElement("div", {
|
|
975
|
+
className: "flex-1 min-w-0"
|
|
976
|
+
}, message.message && React__default.createElement("div", {
|
|
977
|
+
className: `max-w-none ${isSystemMessage ? 'text-gray-800' : 'text-gray-900'}`,
|
|
978
|
+
dir: detectTextDirection(message?.message || ''),
|
|
979
|
+
lang: detectLanguageTag(message?.message || '')
|
|
980
|
+
}, (() => {
|
|
981
|
+
const contentType = detectContentType(message.message);
|
|
982
|
+
if (contentType === 'code') {
|
|
983
|
+
return React__default.createElement(CodeFormatter, {
|
|
984
|
+
content: message.message
|
|
985
|
+
});
|
|
986
|
+
} else if (contentType === 'html') {
|
|
987
|
+
return React__default.createElement("div", {
|
|
988
|
+
className: "max-w-none text-gray-800 html-content",
|
|
989
|
+
dangerouslySetInnerHTML: {
|
|
990
|
+
__html: prettifyHtmlContent(sanitizeHtml(message.message))
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
} else {
|
|
994
|
+
return React__default.createElement(FormattedMessageContent, {
|
|
995
|
+
content: message.message
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
})()), tryExtractBuilderBlocks(message?.message)?.length ? React__default.createElement("div", {
|
|
999
|
+
className: "mt-3 p-3 bg-gray-50 rounded-lg border border-gray-200"
|
|
1000
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
1001
|
+
blocks: tryExtractBuilderBlocks(message?.message)
|
|
1002
|
+
})) : null, message?.props?.blocks?.length ? React__default.createElement("div", {
|
|
1003
|
+
className: "mt-3 p-3 bg-gray-50 rounded-lg border border-gray-200"
|
|
1004
|
+
}, React__default.createElement(BuilderLikeRenderer, {
|
|
1005
|
+
blocks: message.props.blocks
|
|
1006
|
+
})) : null, message.files?.totalCount > 0 && React__default.createElement("div", {
|
|
1007
|
+
className: "mt-3 p-3 bg-gray-50 rounded-lg border border-gray-200"
|
|
1008
|
+
}, React__default.createElement(FilesList, {
|
|
1009
|
+
uploaded: true,
|
|
1010
|
+
files: message.files.data
|
|
1011
|
+
}))), !isSystemMessage && React__default.createElement("div", {
|
|
1012
|
+
className: "flex-shrink-0 mt-1"
|
|
1013
|
+
}, React__default.createElement("div", {
|
|
1014
|
+
className: "opacity-0 group-hover/message:opacity-100 transition-opacity duration-200 flex space-x-1"
|
|
1015
|
+
}, React__default.createElement("button", {
|
|
1016
|
+
className: "p-1 hover:bg-gray-200 rounded transition-colors"
|
|
1017
|
+
}, React__default.createElement("svg", {
|
|
1018
|
+
className: "w-3 h-3 text-gray-400",
|
|
1019
|
+
fill: "none",
|
|
1020
|
+
stroke: "currentColor",
|
|
1021
|
+
viewBox: "0 0 24 24"
|
|
1022
|
+
}, React__default.createElement("path", {
|
|
1023
|
+
strokeLinecap: "round",
|
|
1024
|
+
strokeLinejoin: "round",
|
|
1025
|
+
strokeWidth: 2,
|
|
1026
|
+
d: "M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.367 2.684 3 3 0 00-5.367-2.684z"
|
|
1027
|
+
}))), React__default.createElement("button", {
|
|
1028
|
+
className: "p-1 hover:bg-gray-200 rounded transition-colors"
|
|
1029
|
+
}, React__default.createElement("svg", {
|
|
1030
|
+
className: "w-3 h-3 text-gray-400",
|
|
1031
|
+
fill: "none",
|
|
1032
|
+
stroke: "currentColor",
|
|
1033
|
+
viewBox: "0 0 24 24"
|
|
1034
|
+
}, React__default.createElement("path", {
|
|
1035
|
+
strokeLinecap: "round",
|
|
1036
|
+
strokeLinejoin: "round",
|
|
1037
|
+
strokeWidth: 2,
|
|
1038
|
+
d: "M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
|
|
1039
|
+
})))))));
|
|
1040
|
+
};
|
|
1041
|
+
const ModernMessageGroupComponent = ({
|
|
1042
|
+
messages,
|
|
1043
|
+
currentUser,
|
|
1044
|
+
onOpen,
|
|
1045
|
+
onMessageClick,
|
|
1046
|
+
isDesktopView = false,
|
|
1047
|
+
isSmallScreen = false,
|
|
1048
|
+
sandboxErrors = [],
|
|
1049
|
+
currentFiles = {},
|
|
1050
|
+
onFixError,
|
|
1051
|
+
onRecreateSandbox
|
|
1052
|
+
}) => {
|
|
1053
|
+
// Inject CSS styles for HTML content
|
|
1054
|
+
useInjectStyles();
|
|
1055
|
+
// Filter out non-message items (like date strings)
|
|
1056
|
+
const actualMessages = messages.filter(msg => typeof msg !== 'string');
|
|
1057
|
+
// Group messages by user and time
|
|
1058
|
+
const messageGroups = groupMessagesByUserAndTime(actualMessages);
|
|
1059
|
+
return React__default.createElement("div", {
|
|
1060
|
+
className: `min-h-fit ${isDesktopView ? 'space-y-6' : isSmallScreen ? 'space-y-4' : 'space-y-5'}`
|
|
1061
|
+
}, messageGroups.map((group, groupIndex) => {
|
|
1062
|
+
const author = group[0]?.author;
|
|
1063
|
+
return React__default.createElement(ModernMessageGroup, {
|
|
1064
|
+
key: `group-${groupIndex}-${group[0]?.id}`,
|
|
1065
|
+
author: author,
|
|
1066
|
+
messages: group,
|
|
1067
|
+
currentUser: currentUser,
|
|
1068
|
+
onOpen: onOpen,
|
|
1069
|
+
onMessageClick: onMessageClick,
|
|
1070
|
+
isDesktopView: isDesktopView,
|
|
1071
|
+
isSmallScreen: isSmallScreen
|
|
1072
|
+
});
|
|
1073
|
+
}), sandboxErrors?.map(error => React__default.createElement("div", {
|
|
1074
|
+
key: error.id,
|
|
1075
|
+
className: "px-2"
|
|
1076
|
+
}, React__default.createElement(ErrorFixCard, {
|
|
1077
|
+
error: error,
|
|
1078
|
+
onFixError: onFixError || (() => Promise.resolve()),
|
|
1079
|
+
currentFiles: currentFiles,
|
|
1080
|
+
isFixing: false
|
|
1081
|
+
}))));
|
|
1082
|
+
};export{ModernMessageGroupComponent,groupMessagesByUserAndTime};//# sourceMappingURL=ModernMessageGroup.js.map
|