@brainfish-ai/components 0.13.6 → 0.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/colors/blue.d.ts +13 -0
- package/dist/colors/customColor.d.ts +4 -0
- package/dist/colors/dark.d.ts +13 -0
- package/dist/colors/green.d.ts +13 -0
- package/dist/colors/index.d.ts +128 -0
- package/dist/colors/orange.d.ts +13 -0
- package/dist/colors/pink.d.ts +13 -0
- package/dist/colors/primary.d.ts +20 -0
- package/dist/colors/purple.d.ts +13 -0
- package/dist/colors/red.d.ts +13 -0
- package/dist/colors/yellow.d.ts +13 -0
- package/dist/components/chat-search/Answer.d.ts +29 -0
- package/dist/components/chat-search/AnswerActions.d.ts +13 -0
- package/dist/components/chat-search/AnswerBlock.d.ts +8 -0
- package/dist/components/chat-search/ChatSearch.d.ts +11 -0
- package/dist/components/chat-search/ChatSearchContext.d.ts +34 -0
- package/dist/components/chat-search/FollowUpQuestions.d.ts +7 -0
- package/dist/components/chat-search/FollowUpSearchBar.d.ts +11 -0
- package/dist/components/chat-search/Header.d.ts +9 -0
- package/dist/components/chat-search/LoadingConversation.d.ts +2 -0
- package/dist/components/chat-search/LoadingSkeleton.d.ts +6 -0
- package/dist/components/chat-search/NextBestActions.d.ts +8 -0
- package/dist/components/chat-search/PrimarySearch.d.ts +29 -0
- package/dist/components/chat-search/ScrollToBottomArrow.d.ts +6 -0
- package/dist/components/chat-search/Suggestions.d.ts +9 -0
- package/dist/components/chat-search/TimelineNavigation.d.ts +9 -0
- package/dist/components/chat-search/blocks/ActionButtons.d.ts +5 -0
- package/dist/components/chat-search/blocks/ActionInputForm.d.ts +20 -0
- package/dist/components/chat-search/blocks/MarkdownText.d.ts +8 -0
- package/dist/components/chat-search/blocks/utils.d.ts +15 -0
- package/dist/components/chat-search/helpers/excuteClientAction.d.ts +9 -0
- package/dist/components/chat-search/helpers/nextBestActions.d.ts +7 -0
- package/dist/components/chat-search/hooks/index.d.ts +7 -0
- package/dist/components/chat-search/hooks/useAccessibleColor.d.ts +1 -0
- package/dist/components/chat-search/hooks/useAnswerList.d.ts +217 -0
- package/dist/components/chat-search/hooks/useConversationId.d.ts +5 -0
- package/dist/components/chat-search/hooks/useConversationLoader.d.ts +17 -0
- package/dist/components/chat-search/hooks/useDarkMode.d.ts +1 -0
- package/dist/components/chat-search/hooks/useIsChatSearchDirty.d.ts +1 -0
- package/dist/components/chat-search/hooks/useScrollManager.d.ts +6 -0
- package/dist/components/chat-search/hooks/useSubscriptionManager.d.ts +4 -0
- package/dist/components/chat-search/hooks/useUrlManager.d.ts +8 -0
- package/dist/components/chat-search/index.d.ts +5 -0
- package/dist/components/chat-search/text-config.d.ts +3 -0
- package/dist/components/chat-search/theme.d.ts +0 -0
- package/dist/components/chat-search/types.d.ts +253 -0
- package/dist/{combobox.d.ts → components/combobox/combobox.d.ts} +14 -18
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/data-table/data-table.d.ts +17 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/{date-picker.d.ts → components/date-picker/date-picker.d.ts} +9 -12
- package/dist/components/date-picker/index.d.ts +1 -0
- package/dist/components/feedback/feedback-reason.d.ts +10 -0
- package/dist/{feedback.d.ts → components/feedback/feedback.d.ts} +17 -21
- package/dist/components/feedback/index.d.ts +1 -0
- package/dist/components/file-upload/file-upload-status.d.ts +17 -0
- package/dist/components/file-upload/file-upload.d.ts +4 -0
- package/dist/components/file-upload/index.d.ts +4 -0
- package/dist/components/file-upload/types.d.ts +18 -0
- package/dist/components/file-upload/utils.d.ts +1 -0
- package/dist/components/filter/components/CustomValueInput.d.ts +11 -0
- package/dist/components/filter/components/MultiSelectDropdown.d.ts +10 -0
- package/dist/components/filter/components/SingleSelectDropdown.d.ts +9 -0
- package/dist/components/filter/filter.d.ts +6 -0
- package/dist/components/filter/filters.d.ts +12 -0
- package/dist/components/filter/hooks.d.ts +9 -0
- package/dist/components/filter/index.d.ts +3 -0
- package/dist/{filter.d.ts → components/filter/types.d.ts} +59 -82
- package/dist/components/generating-star/generating-star.d.ts +6 -0
- package/dist/components/generating-star/index.d.ts +2 -0
- package/dist/components/markdown/CodeBlock.d.ts +7 -0
- package/dist/components/markdown/FormattedMessage.d.ts +14 -0
- package/dist/components/markdown/Frame.d.ts +10 -0
- package/dist/components/markdown/MemoizedReactMarkdown.d.ts +6 -0
- package/dist/components/markdown/MermaidDiagram.d.ts +6 -0
- package/dist/components/markdown/ZoomableImage.d.ts +7 -0
- package/dist/components/markdown/embeds/Loom.d.ts +7 -0
- package/dist/components/markdown/embeds/NativeVideo.d.ts +6 -0
- package/dist/components/markdown/embeds/Supademo.d.ts +7 -0
- package/dist/components/markdown/embeds/Typeform.d.ts +7 -0
- package/dist/components/markdown/embeds/Vimeo.d.ts +7 -0
- package/dist/components/markdown/embeds/Wistia.d.ts +7 -0
- package/dist/components/markdown/embeds/Youtube.d.ts +7 -0
- package/dist/components/markdown/embeds/index.d.ts +9 -0
- package/dist/components/markdown/index.d.ts +6 -0
- package/dist/components/markdown/utils/codeblock.d.ts +6 -0
- package/dist/components/markdown/utils/stripNewLines.d.ts +1 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/{select.d.ts → components/select/simpleSelect.d.ts} +15 -20
- package/dist/env.d.ts +5 -0
- package/dist/esm/chunks/{ChatSearch.D_zJGwAf.js → ChatSearch.JQEWTiqr.js} +77 -31
- package/dist/esm/chunks/ChatSearch.JQEWTiqr.js.map +1 -0
- package/dist/esm/chunks/{FormattedMessage.D94rlhro.js → FormattedMessage.CpTetIzd.js} +146 -14
- package/dist/esm/chunks/FormattedMessage.CpTetIzd.js.map +1 -0
- package/dist/esm/chunks/{combobox.D30-HM1I.js → combobox.B5aw7PrS.js} +2 -2
- package/dist/esm/chunks/{combobox.D30-HM1I.js.map → combobox.B5aw7PrS.js.map} +1 -1
- package/dist/esm/chunks/{data-table.CeeSYokg.js → data-table.qS51pU0z.js} +2 -2
- package/dist/esm/chunks/{data-table.CeeSYokg.js.map → data-table.qS51pU0z.js.map} +1 -1
- package/dist/esm/chunks/{date-picker.WGre3lsB.js → date-picker.DqcdwXZS.js} +2 -2
- package/dist/esm/chunks/{date-picker.WGre3lsB.js.map → date-picker.DqcdwXZS.js.map} +1 -1
- package/dist/esm/chunks/{filters.Dx9TXuJ4.js → filters.Bd9OruMH.js} +2 -2
- package/dist/esm/chunks/{filters.Dx9TXuJ4.js.map → filters.Bd9OruMH.js.map} +1 -1
- package/dist/esm/chunks/{generating-star.C6eGHpse.js → generating-star.B0RUXRff.js} +2 -2
- package/dist/esm/chunks/{generating-star.C6eGHpse.js.map → generating-star.B0RUXRff.js.map} +1 -1
- package/dist/esm/chunks/{simpleSelect.Bzw8xrbM.js → simpleSelect.BfAgKOea.js} +2 -2
- package/dist/esm/chunks/{simpleSelect.Bzw8xrbM.js.map → simpleSelect.BfAgKOea.js.map} +1 -1
- package/dist/esm/chunks/{utils.DmKr1Ojo.js → utils.DaMF_LVC.js} +2 -3
- package/dist/esm/chunks/utils.DaMF_LVC.js.map +1 -0
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/components/combobox.js +1 -1
- package/dist/esm/components/data-table.js +1 -1
- package/dist/esm/components/date-picker.js +1 -1
- package/dist/esm/components/filter.js +1 -1
- package/dist/esm/components/generating-star.js +1 -1
- package/dist/esm/components/markdown.js +1 -1
- package/dist/esm/components/select.js +1 -1
- package/dist/esm/components/ui/accordion.js +1 -1
- package/dist/esm/components/ui/accordion.js.map +1 -1
- package/dist/esm/components/ui/badge.js +1 -1
- package/dist/esm/components/ui/button.js +1 -1
- package/dist/esm/components/ui/calendar.js +1 -1
- package/dist/esm/components/ui/card.js +1 -1
- package/dist/esm/components/ui/command.js +1 -1
- package/dist/esm/components/ui/dialog.js +1 -1
- package/dist/esm/components/ui/dialog.js.map +1 -1
- package/dist/esm/components/ui/dropdown-menu.js +1 -1
- package/dist/esm/components/ui/input.js +1 -1
- package/dist/esm/components/ui/label.js +1 -1
- package/dist/esm/components/ui/popover.js +1 -1
- package/dist/esm/components/ui/progress.js +1 -1
- package/dist/esm/components/ui/scroll-area.js +1 -1
- package/dist/esm/components/ui/select.js +1 -1
- package/dist/esm/components/ui/switch.js +1 -1
- package/dist/esm/components/ui/table.js +1 -1
- package/dist/esm/components/ui/textarea.js +1 -1
- package/dist/esm/components/ui/tooltip.js +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.js +8 -8
- package/dist/index.d.ts +27 -1063
- package/dist/lib/addUtmParams.d.ts +20 -0
- package/dist/lib/api.d.ts +96 -0
- package/dist/lib/feature-flags.d.ts +9 -0
- package/dist/lib/features.d.ts +3 -0
- package/dist/lib/fetchClient.d.ts +19 -0
- package/dist/lib/getContentType.d.ts +1 -0
- package/dist/lib/hooks.d.ts +15 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/stats.html +1 -1
- package/package.json +8 -2
- package/dist/accordion.d.ts +0 -12
- package/dist/badge.d.ts +0 -14
- package/dist/button.d.ts +0 -16
- package/dist/calendar.d.ts +0 -12
- package/dist/card.d.ts +0 -17
- package/dist/chat-search.d.ts +0 -414
- package/dist/collapsible.d.ts +0 -10
- package/dist/command.d.ts +0 -90
- package/dist/components/chat-search.d.ts +0 -2
- package/dist/components/combobox.d.ts +0 -2
- package/dist/components/data-table.d.ts +0 -2
- package/dist/components/date-picker.d.ts +0 -2
- package/dist/components/feedback.d.ts +0 -2
- package/dist/components/filter.d.ts +0 -2
- package/dist/components/generating-star.d.ts +0 -6
- package/dist/components/markdown.d.ts +0 -2
- package/dist/components/select.d.ts +0 -2
- package/dist/data-table.d.ts +0 -23
- package/dist/dialog.d.ts +0 -30
- package/dist/dropdown-menu.d.ts +0 -43
- package/dist/esm/chunks/ChatSearch.D_zJGwAf.js.map +0 -1
- package/dist/esm/chunks/FormattedMessage.D94rlhro.js.map +0 -1
- package/dist/esm/chunks/utils.DmKr1Ojo.js.map +0 -1
- package/dist/generating-star.d.ts +0 -10
- package/dist/icon.d.ts +0 -26
- package/dist/input.d.ts +0 -11
- package/dist/label.d.ts +0 -8
- package/dist/markdown.d.ts +0 -54
- package/dist/popover.d.ts +0 -12
- package/dist/progress.d.ts +0 -8
- package/dist/scroll-area.d.ts +0 -8
- package/dist/switch.d.ts +0 -6
- package/dist/table.d.ts +0 -19
- package/dist/textarea.d.ts +0 -5
- package/dist/tooltip.d.ts +0 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { memo, useState, useRef, useEffect, useMemo } from 'react';
|
|
2
|
+
import React__default, { memo, useState, useRef, useEffect, useMemo, useCallback } from 'react';
|
|
3
3
|
import rehypeRaw from 'rehype-raw';
|
|
4
4
|
import remarkGfm from 'remark-gfm';
|
|
5
5
|
import { match, compile } from 'path-to-regexp';
|
|
@@ -8,7 +8,7 @@ import { Button } from '../components/ui/button.js';
|
|
|
8
8
|
import ReactMarkdown from 'react-markdown';
|
|
9
9
|
import mermaid from 'mermaid';
|
|
10
10
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
11
|
-
import { i as isAnswerUncertain } from './utils.
|
|
11
|
+
import { i as isAnswerUncertain } from './utils.DaMF_LVC.js';
|
|
12
12
|
|
|
13
13
|
function addUtmParameters(url, options) {
|
|
14
14
|
if (!url) {
|
|
@@ -39112,6 +39112,35 @@ Loom.isMatch = (href) => {
|
|
|
39112
39112
|
return loomRegex.test(href);
|
|
39113
39113
|
};
|
|
39114
39114
|
|
|
39115
|
+
const NativeVideo = ({ attrs }) => {
|
|
39116
|
+
const { href } = attrs;
|
|
39117
|
+
return (
|
|
39118
|
+
// eslint-disable-next-line jsx-a11y/media-has-caption
|
|
39119
|
+
/* @__PURE__ */ React.createElement(
|
|
39120
|
+
"video",
|
|
39121
|
+
{
|
|
39122
|
+
controls: true,
|
|
39123
|
+
width: "100%",
|
|
39124
|
+
height: "auto",
|
|
39125
|
+
src: href,
|
|
39126
|
+
title: "Native Video",
|
|
39127
|
+
style: { borderRadius: "8px", overflow: "hidden" },
|
|
39128
|
+
controlsList: "nodownload",
|
|
39129
|
+
playsInline: true
|
|
39130
|
+
},
|
|
39131
|
+
"Your browser does not support the video tag."
|
|
39132
|
+
)
|
|
39133
|
+
);
|
|
39134
|
+
};
|
|
39135
|
+
NativeVideo.isMatch = (href) => {
|
|
39136
|
+
const [url] = href.split("?");
|
|
39137
|
+
const videoExtensions = /\.(mp4|webm|ogg|mov|m4v|avi|flv|wmv|mkv)(?:\?.*|#.*)?$/i;
|
|
39138
|
+
if (url && videoExtensions.test(url)) {
|
|
39139
|
+
return true;
|
|
39140
|
+
}
|
|
39141
|
+
return false;
|
|
39142
|
+
};
|
|
39143
|
+
|
|
39115
39144
|
function Supademo(props) {
|
|
39116
39145
|
return /* @__PURE__ */ React.createElement(Frame, { ...props, src: props.attrs.href, title: "Supademo Embed" });
|
|
39117
39146
|
}
|
|
@@ -39191,7 +39220,7 @@ YouTube.isMatch = (href) => {
|
|
|
39191
39220
|
return YOUTUBE_URL_REGEX.test(href);
|
|
39192
39221
|
};
|
|
39193
39222
|
|
|
39194
|
-
const syncEmbedComponents = [Loom, Supademo, Typeform, YouTube, Wistia, Vimeo];
|
|
39223
|
+
const syncEmbedComponents = [Loom, Supademo, Typeform, YouTube, Wistia, Vimeo, NativeVideo];
|
|
39195
39224
|
const useMatchedComponent = (href, components) => {
|
|
39196
39225
|
return React.useMemo(() => {
|
|
39197
39226
|
try {
|
|
@@ -39205,7 +39234,11 @@ const useMatchedComponent = (href, components) => {
|
|
|
39205
39234
|
};
|
|
39206
39235
|
const EmbedComponent = (props) => {
|
|
39207
39236
|
const { href } = props.attrs;
|
|
39237
|
+
const { isAttachmentVideo } = props;
|
|
39208
39238
|
const matched = useMatchedComponent(href, syncEmbedComponents);
|
|
39239
|
+
if (isAttachmentVideo) {
|
|
39240
|
+
return /* @__PURE__ */ React.createElement(NativeVideo, { ...props });
|
|
39241
|
+
}
|
|
39209
39242
|
if (matched) {
|
|
39210
39243
|
const { Component } = matched;
|
|
39211
39244
|
return /* @__PURE__ */ React.createElement(Component, { ...props });
|
|
@@ -39356,8 +39389,44 @@ const ZoomableImage = ({ src, alt }) => {
|
|
|
39356
39389
|
|
|
39357
39390
|
const stripNewLines = (content) => content.replace(/^\n+|(\n+|\\)+$/g, "");
|
|
39358
39391
|
|
|
39359
|
-
|
|
39392
|
+
async function getContentType(attachmentId, apiHost, signal) {
|
|
39393
|
+
try {
|
|
39394
|
+
const host = apiHost || "https://app.brainfi.sh";
|
|
39395
|
+
const response = await fetch(`${host}/api/attachments.public.contentType?id=${attachmentId}`, {
|
|
39396
|
+
method: "GET",
|
|
39397
|
+
headers: {
|
|
39398
|
+
"Content-Type": "application/json"
|
|
39399
|
+
},
|
|
39400
|
+
signal
|
|
39401
|
+
}).then((res) => res.json());
|
|
39402
|
+
if (!response.ok) {
|
|
39403
|
+
return "unknown";
|
|
39404
|
+
}
|
|
39405
|
+
const contentType = response.contentType;
|
|
39406
|
+
if (contentType?.startsWith("image/")) {
|
|
39407
|
+
return "image";
|
|
39408
|
+
}
|
|
39409
|
+
if (contentType?.startsWith("video/")) {
|
|
39410
|
+
return "video";
|
|
39411
|
+
}
|
|
39412
|
+
if (contentType?.startsWith("audio/")) {
|
|
39413
|
+
return "audio";
|
|
39414
|
+
}
|
|
39415
|
+
if (contentType?.startsWith("application/pdf")) {
|
|
39416
|
+
return "pdf";
|
|
39417
|
+
}
|
|
39418
|
+
return "unknown";
|
|
39419
|
+
} catch (error) {
|
|
39420
|
+
console.error("Error getting content type:", error);
|
|
39421
|
+
return "unknown";
|
|
39422
|
+
}
|
|
39423
|
+
}
|
|
39424
|
+
|
|
39425
|
+
const videoContentTypePrefix = "[Content: Video]";
|
|
39426
|
+
const videoContentTypePrefixRegexp = new RegExp("^\\" + videoContentTypePrefix);
|
|
39427
|
+
const FormattedMessage = memo(({ message, isStreaming, redirectRules = [], apiUrl }) => {
|
|
39360
39428
|
const [displayContent, setDisplayContent] = useState(message.content);
|
|
39429
|
+
const [processedContent, setProcessedContent] = useState(message.content);
|
|
39361
39430
|
useEffect(() => {
|
|
39362
39431
|
const result = isAnswerUncertain(message.content);
|
|
39363
39432
|
if (result.uncertain && result.language && message.uncertaintyFallbackText?.[result.language]) {
|
|
@@ -39366,7 +39435,64 @@ const FormattedMessage = memo(({ message, isStreaming, redirectRules = [] }) =>
|
|
|
39366
39435
|
setDisplayContent(message.content);
|
|
39367
39436
|
}
|
|
39368
39437
|
}, [message.content, message.uncertaintyFallbackText, isStreaming]);
|
|
39369
|
-
const
|
|
39438
|
+
const linkRegex = useMemo(() => /(!?\[([^\]]*)\]\(([^)]+)\))/g, []);
|
|
39439
|
+
const processVideoAttachments = useCallback(
|
|
39440
|
+
async (content, signal) => {
|
|
39441
|
+
if (isStreaming) {
|
|
39442
|
+
return content;
|
|
39443
|
+
}
|
|
39444
|
+
let processedText = content;
|
|
39445
|
+
const matches = Array.from(content.matchAll(linkRegex));
|
|
39446
|
+
for (const match2 of matches) {
|
|
39447
|
+
if (signal.aborted) {
|
|
39448
|
+
throw new DOMException("Aborted", "AbortError");
|
|
39449
|
+
}
|
|
39450
|
+
const [fullMatch, , linkText, href] = match2;
|
|
39451
|
+
if (href && (href.includes("/api/attachments.public.redirect") || href.includes("/api/attachments.redirect"))) {
|
|
39452
|
+
const attachmentId = href.split("id=")[1];
|
|
39453
|
+
if (attachmentId) {
|
|
39454
|
+
try {
|
|
39455
|
+
const contentType = await getContentType(attachmentId, apiUrl, signal);
|
|
39456
|
+
if (contentType === "video") {
|
|
39457
|
+
const newLinkText = `${videoContentTypePrefix} ${linkText}`;
|
|
39458
|
+
const newMatch = fullMatch.replace(linkText, newLinkText);
|
|
39459
|
+
processedText = processedText.replace(fullMatch, newMatch);
|
|
39460
|
+
}
|
|
39461
|
+
} catch (error) {
|
|
39462
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
39463
|
+
throw error;
|
|
39464
|
+
}
|
|
39465
|
+
}
|
|
39466
|
+
}
|
|
39467
|
+
}
|
|
39468
|
+
}
|
|
39469
|
+
return processedText;
|
|
39470
|
+
},
|
|
39471
|
+
[isStreaming, linkRegex, apiUrl]
|
|
39472
|
+
);
|
|
39473
|
+
useEffect(() => {
|
|
39474
|
+
const abortController = new AbortController();
|
|
39475
|
+
const processContent = async () => {
|
|
39476
|
+
try {
|
|
39477
|
+
const processed = await processVideoAttachments(displayContent, abortController.signal);
|
|
39478
|
+
if (!abortController.signal.aborted) {
|
|
39479
|
+
setProcessedContent(processed);
|
|
39480
|
+
}
|
|
39481
|
+
} catch (error) {
|
|
39482
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
39483
|
+
return;
|
|
39484
|
+
}
|
|
39485
|
+
if (!abortController.signal.aborted) {
|
|
39486
|
+
setProcessedContent(displayContent);
|
|
39487
|
+
}
|
|
39488
|
+
}
|
|
39489
|
+
};
|
|
39490
|
+
void processContent();
|
|
39491
|
+
return () => {
|
|
39492
|
+
abortController.abort();
|
|
39493
|
+
};
|
|
39494
|
+
}, [displayContent, processVideoAttachments]);
|
|
39495
|
+
const strippedContent = stripNewLines(processedContent);
|
|
39370
39496
|
const memoizedRedirectRules = useMemo(() => redirectRules, [redirectRules]);
|
|
39371
39497
|
const rewriteUrl = useMemo(
|
|
39372
39498
|
() => (url) => {
|
|
@@ -39431,37 +39557,43 @@ const FormattedMessage = memo(({ message, isStreaming, redirectRules = [] }) =>
|
|
|
39431
39557
|
a({ children, ...props }) {
|
|
39432
39558
|
let originalHref = props.href || "";
|
|
39433
39559
|
const childrenText = typeof children === "string" ? children : "";
|
|
39434
|
-
|
|
39560
|
+
const isVideoContentType = childrenText.startsWith(videoContentTypePrefix);
|
|
39561
|
+
const parsedText = isVideoContentType ? childrenText.replace(videoContentTypePrefixRegexp, "").trim() : childrenText;
|
|
39562
|
+
if (!originalHref && parsedText) {
|
|
39435
39563
|
try {
|
|
39436
|
-
new URL(
|
|
39437
|
-
originalHref =
|
|
39564
|
+
new URL(parsedText);
|
|
39565
|
+
originalHref = parsedText;
|
|
39438
39566
|
} catch {
|
|
39439
39567
|
}
|
|
39440
39568
|
}
|
|
39441
|
-
const isTextSameAsHref =
|
|
39569
|
+
const isTextSameAsHref = parsedText === originalHref;
|
|
39442
39570
|
const rewrittenHref = originalHref ? rewriteUrl(originalHref) : originalHref;
|
|
39443
39571
|
const newProps = { ...props, href: rewrittenHref };
|
|
39444
39572
|
if (rewrittenHref && !isStreaming) {
|
|
39445
39573
|
const embedComponent = EmbedComponent({
|
|
39446
|
-
attrs: { href: rewrittenHref }
|
|
39574
|
+
attrs: { href: rewrittenHref },
|
|
39575
|
+
isAttachmentVideo: isVideoContentType
|
|
39447
39576
|
});
|
|
39448
39577
|
if (React__default.isValidElement(embedComponent)) {
|
|
39449
39578
|
return embedComponent;
|
|
39450
39579
|
}
|
|
39451
39580
|
}
|
|
39452
|
-
const displayChildren = isTextSameAsHref ? rewrittenHref : children;
|
|
39581
|
+
const displayChildren = isTextSameAsHref ? rewrittenHref : isVideoContentType ? parsedText : children;
|
|
39453
39582
|
return /* @__PURE__ */ React__default.createElement("a", { className: "link text-link", target: "_blank", rel: "noopener noreferrer", ...newProps }, displayChildren);
|
|
39454
39583
|
},
|
|
39455
39584
|
pre: ({ children }) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children),
|
|
39456
39585
|
img({ src, alt }) {
|
|
39457
39586
|
if (!src || isStreaming) return null;
|
|
39587
|
+
const isVideoContentType = alt?.startsWith(videoContentTypePrefix) || false;
|
|
39588
|
+
const parsedAlt = isVideoContentType && alt ? alt.replace(videoContentTypePrefixRegexp, "").trim() : alt;
|
|
39458
39589
|
const embedComponent = EmbedComponent({
|
|
39459
|
-
attrs: { href: src ?? "" }
|
|
39590
|
+
attrs: { href: src ?? "" },
|
|
39591
|
+
isAttachmentVideo: isVideoContentType
|
|
39460
39592
|
});
|
|
39461
39593
|
if (React__default.isValidElement(embedComponent)) {
|
|
39462
39594
|
return embedComponent;
|
|
39463
39595
|
}
|
|
39464
|
-
return /* @__PURE__ */ React__default.createElement(ZoomableImage, { src, alt, key: src });
|
|
39596
|
+
return /* @__PURE__ */ React__default.createElement(ZoomableImage, { src, alt: parsedAlt, key: src });
|
|
39465
39597
|
},
|
|
39466
39598
|
li: ({ children, ...props }) => {
|
|
39467
39599
|
return /* @__PURE__ */ React__default.createElement("li", { ...props }, children);
|
|
@@ -39501,4 +39633,4 @@ const FormattedMessage = memo(({ message, isStreaming, redirectRules = [] }) =>
|
|
|
39501
39633
|
FormattedMessage.displayName = "FormattedMessage";
|
|
39502
39634
|
|
|
39503
39635
|
export { CodeBlock as C, FormattedMessage as F, MemoizedReactMarkdown as M, ZoomableImage as Z, MermaidDiagram as a, addUtmParameters as b, addPopupWidgetUtm as c, getDefaultExportFromCjs as g };
|
|
39504
|
-
//# sourceMappingURL=FormattedMessage.
|
|
39636
|
+
//# sourceMappingURL=FormattedMessage.CpTetIzd.js.map
|