@bergetai/ui 0.22.0 → 0.24.0
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/components/markdown/Markdown.cjs +9 -5
- package/dist/components/markdown/Markdown.cjs.map +1 -1
- package/dist/components/markdown/Markdown.d.cts.map +1 -1
- package/dist/components/markdown/Markdown.d.mts.map +1 -1
- package/dist/components/markdown/Markdown.mjs +9 -5
- package/dist/components/markdown/Markdown.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -94,7 +94,8 @@ const bergetComponents = {
|
|
|
94
94
|
blockquote: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.blockquote, {
|
|
95
95
|
...props,
|
|
96
96
|
className: `
|
|
97
|
-
my-3 border-berget-border ps-3 text-berget-muted-foreground
|
|
97
|
+
my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground
|
|
98
|
+
italic
|
|
98
99
|
`
|
|
99
100
|
}),
|
|
100
101
|
hr: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.hr, {
|
|
@@ -105,7 +106,7 @@ const bergetComponents = {
|
|
|
105
106
|
}),
|
|
106
107
|
img: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.img, {
|
|
107
108
|
...props,
|
|
108
|
-
className: `my-3 max-w-full rounded-berget-xs border-berget-border`
|
|
109
|
+
className: `my-3 max-w-full rounded-berget-xs border border-berget-border`
|
|
109
110
|
}),
|
|
110
111
|
a: ({ node: _node, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
111
112
|
...props,
|
|
@@ -132,7 +133,8 @@ const bergetComponents = {
|
|
|
132
133
|
},
|
|
133
134
|
table: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
134
135
|
className: `
|
|
135
|
-
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
136
|
+
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
137
|
+
border-berget-border
|
|
136
138
|
`,
|
|
137
139
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("table", {
|
|
138
140
|
...props,
|
|
@@ -145,12 +147,14 @@ const bergetComponents = {
|
|
|
145
147
|
}),
|
|
146
148
|
th: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.th, {
|
|
147
149
|
...props,
|
|
148
|
-
className: `
|
|
150
|
+
className: `
|
|
151
|
+
border-b border-b-berget-border px-3 py-1.5 text-start font-semibold
|
|
152
|
+
`
|
|
149
153
|
}),
|
|
150
154
|
td: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.td, {
|
|
151
155
|
...props,
|
|
152
156
|
className: `
|
|
153
|
-
border-b-berget-border px-3 py-1.5
|
|
157
|
+
border-b border-b-berget-border px-3 py-1.5
|
|
154
158
|
`
|
|
155
159
|
})
|
|
156
160
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.cjs","names":["defaultComponents","React","MarkdownCodeBlock","Streamdown","cn"],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) => (\n <defaultComponents.h1\n {...props}\n className={`\n mt-4 mb-2 text-lg font-semibold\n `}\n />\n ),\n h2: (props) => (\n <defaultComponents.h2\n {...props}\n className={`\n mt-4 mb-2 text-base font-semibold\n `}\n />\n ),\n h3: (props) => (\n <defaultComponents.h3\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h4: (props) => (\n <defaultComponents.h4\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h5: (props) => (\n <defaultComponents.h5\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h6: (props) => (\n <defaultComponents.h6\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n p: (props) => (\n <defaultComponents.p\n {...props}\n className={`\n my-2\n first:mt-0\n last:mb-0\n `}\n />\n ),\n ul: (props) => (\n <defaultComponents.ul\n {...props}\n className={`\n my-2 ms-5 list-disc space-y-1\n marker:text-berget-muted-foreground\n `}\n />\n ),\n ol: (props) => (\n <defaultComponents.ol\n {...props}\n className={`\n my-2 ms-5 list-decimal space-y-1\n `}\n />\n ),\n li: (props) => <defaultComponents.li {...props} className={`leading-relaxed`} />,\n del: (props) => <del {...props} className={`line-through`} />,\n em: (props) => <em {...props} className={`italic`} />,\n blockquote: (props) => (\n <defaultComponents.blockquote\n {...props}\n className={`\n my-3 border-berget-border ps-3 text-berget-muted-foreground
|
|
1
|
+
{"version":3,"file":"Markdown.cjs","names":["defaultComponents","React","MarkdownCodeBlock","Streamdown","cn"],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) => (\n <defaultComponents.h1\n {...props}\n className={`\n mt-4 mb-2 text-lg font-semibold\n `}\n />\n ),\n h2: (props) => (\n <defaultComponents.h2\n {...props}\n className={`\n mt-4 mb-2 text-base font-semibold\n `}\n />\n ),\n h3: (props) => (\n <defaultComponents.h3\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h4: (props) => (\n <defaultComponents.h4\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h5: (props) => (\n <defaultComponents.h5\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h6: (props) => (\n <defaultComponents.h6\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n p: (props) => (\n <defaultComponents.p\n {...props}\n className={`\n my-2\n first:mt-0\n last:mb-0\n `}\n />\n ),\n ul: (props) => (\n <defaultComponents.ul\n {...props}\n className={`\n my-2 ms-5 list-disc space-y-1\n marker:text-berget-muted-foreground\n `}\n />\n ),\n ol: (props) => (\n <defaultComponents.ol\n {...props}\n className={`\n my-2 ms-5 list-decimal space-y-1\n `}\n />\n ),\n li: (props) => <defaultComponents.li {...props} className={`leading-relaxed`} />,\n del: (props) => <del {...props} className={`line-through`} />,\n em: (props) => <em {...props} className={`italic`} />,\n blockquote: (props) => (\n <defaultComponents.blockquote\n {...props}\n className={`\n my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground\n italic\n `}\n />\n ),\n hr: (props) => (\n <defaultComponents.hr\n {...props}\n className={`\n my-4 border-berget-border\n `}\n />\n ),\n img: (props) => (\n <defaultComponents.img\n {...props}\n className={`my-3 max-w-full rounded-berget-xs border border-berget-border`}\n />\n ),\n // Real anchor, not Streamdown's default <button>: links must keep href\n // semantics (middle-click, new tab). Hardening attrs are added explicitly\n // since rehype-harden can only act on real anchors.\n a: ({ node: _node, ...props }) => (\n <a\n {...props}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n className={`text-berget-primary underline underline-offset-2`}\n />\n ),\n // Inline code only — fenced blocks are consumed by the `pre` override below.\n code: (props) => (\n <defaultComponents.code\n {...props}\n className={`\n rounded-berget-xs bg-muted px-1.5 py-0.5 font-mono text-[0.85em]\n `}\n />\n ),\n // Fenced / indented code: derive code + language from the child code\n // element and render with the package CodeBlock (highlighting included).\n pre: ({ children }) => {\n if (React.isValidElement(children)) {\n const { className, children: code } = children.props as {\n className?: string;\n children?: React.ReactNode;\n };\n const language = /language-([\\w+-]+)/.exec(className ?? '')?.[1] ?? 'text';\n return <MarkdownCodeBlock code={String(code ?? '')} language={language} />;\n }\n return <>{children}</>;\n },\n table: (props) => (\n <div\n className={`\n my-3 max-w-full overflow-x-auto rounded-berget-xs border\n border-berget-border\n `}\n >\n <table {...props} className={`w-full border-collapse text-sm`} />\n </div>\n ),\n thead: (props) => <defaultComponents.thead {...props} className={`bg-muted/50`} />,\n th: (props) => (\n <defaultComponents.th\n {...props}\n className={`\n border-b border-b-berget-border px-3 py-1.5 text-start font-semibold\n `}\n />\n ),\n td: (props) => (\n <defaultComponents.td\n {...props}\n className={`\n border-b border-b-berget-border px-3 py-1.5\n `}\n />\n ),\n};\n\ntype MarkdownProps = Omit<StreamdownProps, 'components' | 'plugins' | 'dir' | 'prefix'>;\nexport type { MarkdownProps };\n\nexport function Markdown({ className, ...props }: MarkdownProps) {\n return (\n <Streamdown\n {...props}\n dir=\"ltr\"\n components={bergetComponents}\n className={cn('text-caption/relaxed text-berget-foreground', className)}\n />\n );\n}\n\nMarkdown.displayName = 'Markdown';\n"],"mappings":";;;;;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EP,QAAQ,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAACF,WAAAA,kBAAkB,OAAnB;EAAyB,GAAI;EAAO,WAAW;CAAgB,CAAA;CACjF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;AAEL;AAKA,SAAgB,SAAS,EAAE,WAAW,GAAG,SAAwB;CAC/D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACG,WAAAA,YAAD;EACE,GAAI;EACJ,KAAI;EACJ,YAAY;EACZ,WAAWC,cAAAA,GAAG,+CAA+C,SAAS;CACvE,CAAA;AAEL;AAEA,SAAS,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.cts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Markdown.d.cts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;KAyLK,gBAAgB,KAAK;wBAGV,WAAW,cAAc,SAAS,4CAAa,IAAA;yBAA/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"mappings":";;KAyLK,gBAAgB,KAAK;wBAGV,WAAW,cAAc,SAAS,4CAAa,IAAA;yBAA/C"}
|
|
@@ -92,7 +92,8 @@ const bergetComponents = {
|
|
|
92
92
|
blockquote: (props) => /* @__PURE__ */ jsx(defaultComponents.blockquote, {
|
|
93
93
|
...props,
|
|
94
94
|
className: `
|
|
95
|
-
my-3 border-berget-border ps-3 text-berget-muted-foreground
|
|
95
|
+
my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground
|
|
96
|
+
italic
|
|
96
97
|
`
|
|
97
98
|
}),
|
|
98
99
|
hr: (props) => /* @__PURE__ */ jsx(defaultComponents.hr, {
|
|
@@ -103,7 +104,7 @@ const bergetComponents = {
|
|
|
103
104
|
}),
|
|
104
105
|
img: (props) => /* @__PURE__ */ jsx(defaultComponents.img, {
|
|
105
106
|
...props,
|
|
106
|
-
className: `my-3 max-w-full rounded-berget-xs border-berget-border`
|
|
107
|
+
className: `my-3 max-w-full rounded-berget-xs border border-berget-border`
|
|
107
108
|
}),
|
|
108
109
|
a: ({ node: _node, ...props }) => /* @__PURE__ */ jsx("a", {
|
|
109
110
|
...props,
|
|
@@ -130,7 +131,8 @@ const bergetComponents = {
|
|
|
130
131
|
},
|
|
131
132
|
table: (props) => /* @__PURE__ */ jsx("div", {
|
|
132
133
|
className: `
|
|
133
|
-
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
134
|
+
my-3 max-w-full overflow-x-auto rounded-berget-xs border
|
|
135
|
+
border-berget-border
|
|
134
136
|
`,
|
|
135
137
|
children: /* @__PURE__ */ jsx("table", {
|
|
136
138
|
...props,
|
|
@@ -143,12 +145,14 @@ const bergetComponents = {
|
|
|
143
145
|
}),
|
|
144
146
|
th: (props) => /* @__PURE__ */ jsx(defaultComponents.th, {
|
|
145
147
|
...props,
|
|
146
|
-
className: `
|
|
148
|
+
className: `
|
|
149
|
+
border-b border-b-berget-border px-3 py-1.5 text-start font-semibold
|
|
150
|
+
`
|
|
147
151
|
}),
|
|
148
152
|
td: (props) => /* @__PURE__ */ jsx(defaultComponents.td, {
|
|
149
153
|
...props,
|
|
150
154
|
className: `
|
|
151
|
-
border-b-berget-border px-3 py-1.5
|
|
155
|
+
border-b border-b-berget-border px-3 py-1.5
|
|
152
156
|
`
|
|
153
157
|
})
|
|
154
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.mjs","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) => (\n <defaultComponents.h1\n {...props}\n className={`\n mt-4 mb-2 text-lg font-semibold\n `}\n />\n ),\n h2: (props) => (\n <defaultComponents.h2\n {...props}\n className={`\n mt-4 mb-2 text-base font-semibold\n `}\n />\n ),\n h3: (props) => (\n <defaultComponents.h3\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h4: (props) => (\n <defaultComponents.h4\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h5: (props) => (\n <defaultComponents.h5\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h6: (props) => (\n <defaultComponents.h6\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n p: (props) => (\n <defaultComponents.p\n {...props}\n className={`\n my-2\n first:mt-0\n last:mb-0\n `}\n />\n ),\n ul: (props) => (\n <defaultComponents.ul\n {...props}\n className={`\n my-2 ms-5 list-disc space-y-1\n marker:text-berget-muted-foreground\n `}\n />\n ),\n ol: (props) => (\n <defaultComponents.ol\n {...props}\n className={`\n my-2 ms-5 list-decimal space-y-1\n `}\n />\n ),\n li: (props) => <defaultComponents.li {...props} className={`leading-relaxed`} />,\n del: (props) => <del {...props} className={`line-through`} />,\n em: (props) => <em {...props} className={`italic`} />,\n blockquote: (props) => (\n <defaultComponents.blockquote\n {...props}\n className={`\n my-3 border-berget-border ps-3 text-berget-muted-foreground
|
|
1
|
+
{"version":3,"file":"Markdown.mjs","names":[],"sources":["../../../src/components/markdown/Markdown.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Streamdown, defaultComponents, type Components, type StreamdownProps } from 'streamdown';\nimport { cn } from '../../lib/utils';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\n\n/**\n * Markdown renderer for chat/UI text, built on Streamdown (incomplete-markdown\n * repair during streaming, GFM tables, rehype-sanitize + rehype-harden).\n *\n * Streamdown ships its own Tailwind classes inside its dist files, which\n * consumers' Tailwind builds never scan — so every element is given a full\n * Berget class set here instead of relying on the defaults. Utility classes\n * used below live in this package's own dist, which the shipped `@source`\n * covers for all consumers.\n *\n * Code highlighting reuses the package CodeBlock family and the shared Shiki\n * highlighter (Berget CSS-variable theme). Mermaid/KaTeX are intentionally\n * not enabled.\n */\nconst bergetComponents: Components = {\n h1: (props) => (\n <defaultComponents.h1\n {...props}\n className={`\n mt-4 mb-2 text-lg font-semibold\n `}\n />\n ),\n h2: (props) => (\n <defaultComponents.h2\n {...props}\n className={`\n mt-4 mb-2 text-base font-semibold\n `}\n />\n ),\n h3: (props) => (\n <defaultComponents.h3\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h4: (props) => (\n <defaultComponents.h4\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h5: (props) => (\n <defaultComponents.h5\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n h6: (props) => (\n <defaultComponents.h6\n {...props}\n className={`\n mt-3 mb-1.5 text-sm font-semibold\n `}\n />\n ),\n p: (props) => (\n <defaultComponents.p\n {...props}\n className={`\n my-2\n first:mt-0\n last:mb-0\n `}\n />\n ),\n ul: (props) => (\n <defaultComponents.ul\n {...props}\n className={`\n my-2 ms-5 list-disc space-y-1\n marker:text-berget-muted-foreground\n `}\n />\n ),\n ol: (props) => (\n <defaultComponents.ol\n {...props}\n className={`\n my-2 ms-5 list-decimal space-y-1\n `}\n />\n ),\n li: (props) => <defaultComponents.li {...props} className={`leading-relaxed`} />,\n del: (props) => <del {...props} className={`line-through`} />,\n em: (props) => <em {...props} className={`italic`} />,\n blockquote: (props) => (\n <defaultComponents.blockquote\n {...props}\n className={`\n my-3 border-l-4 border-berget-border ps-3 text-berget-muted-foreground\n italic\n `}\n />\n ),\n hr: (props) => (\n <defaultComponents.hr\n {...props}\n className={`\n my-4 border-berget-border\n `}\n />\n ),\n img: (props) => (\n <defaultComponents.img\n {...props}\n className={`my-3 max-w-full rounded-berget-xs border border-berget-border`}\n />\n ),\n // Real anchor, not Streamdown's default <button>: links must keep href\n // semantics (middle-click, new tab). Hardening attrs are added explicitly\n // since rehype-harden can only act on real anchors.\n a: ({ node: _node, ...props }) => (\n <a\n {...props}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n className={`text-berget-primary underline underline-offset-2`}\n />\n ),\n // Inline code only — fenced blocks are consumed by the `pre` override below.\n code: (props) => (\n <defaultComponents.code\n {...props}\n className={`\n rounded-berget-xs bg-muted px-1.5 py-0.5 font-mono text-[0.85em]\n `}\n />\n ),\n // Fenced / indented code: derive code + language from the child code\n // element and render with the package CodeBlock (highlighting included).\n pre: ({ children }) => {\n if (React.isValidElement(children)) {\n const { className, children: code } = children.props as {\n className?: string;\n children?: React.ReactNode;\n };\n const language = /language-([\\w+-]+)/.exec(className ?? '')?.[1] ?? 'text';\n return <MarkdownCodeBlock code={String(code ?? '')} language={language} />;\n }\n return <>{children}</>;\n },\n table: (props) => (\n <div\n className={`\n my-3 max-w-full overflow-x-auto rounded-berget-xs border\n border-berget-border\n `}\n >\n <table {...props} className={`w-full border-collapse text-sm`} />\n </div>\n ),\n thead: (props) => <defaultComponents.thead {...props} className={`bg-muted/50`} />,\n th: (props) => (\n <defaultComponents.th\n {...props}\n className={`\n border-b border-b-berget-border px-3 py-1.5 text-start font-semibold\n `}\n />\n ),\n td: (props) => (\n <defaultComponents.td\n {...props}\n className={`\n border-b border-b-berget-border px-3 py-1.5\n `}\n />\n ),\n};\n\ntype MarkdownProps = Omit<StreamdownProps, 'components' | 'plugins' | 'dir' | 'prefix'>;\nexport type { MarkdownProps };\n\nexport function Markdown({ className, ...props }: MarkdownProps) {\n return (\n <Streamdown\n {...props}\n dir=\"ltr\"\n components={bergetComponents}\n className={cn('text-caption/relaxed text-berget-foreground', className)}\n />\n );\n}\n\nMarkdown.displayName = 'Markdown';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,mBAA+B;CACnC,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;CAGZ,CAAA;CAEH,IAAI,UACF,oBAAC,kBAAkB,GAAnB;EACE,GAAI;EACJ,WAAW;;;;;CAKZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;;CAIZ,CAAA;CAEH,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EACE,GAAI;EACJ,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