@bergetai/ui 0.24.0 → 0.25.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 +13 -27
- 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 +13 -27
- package/dist/components/markdown/Markdown.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -24,39 +24,27 @@ let streamdown = require("streamdown");
|
|
|
24
24
|
const bergetComponents = {
|
|
25
25
|
h1: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h1, {
|
|
26
26
|
...props,
|
|
27
|
-
className: `
|
|
28
|
-
mt-4 mb-2 text-lg font-semibold
|
|
29
|
-
`
|
|
27
|
+
className: `mt-4 mb-2 text-lg font-semibold`
|
|
30
28
|
}),
|
|
31
29
|
h2: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h2, {
|
|
32
30
|
...props,
|
|
33
|
-
className: `
|
|
34
|
-
mt-4 mb-2 text-base font-semibold
|
|
35
|
-
`
|
|
31
|
+
className: `mt-4 mb-2 text-base font-semibold`
|
|
36
32
|
}),
|
|
37
33
|
h3: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h3, {
|
|
38
34
|
...props,
|
|
39
|
-
className: `
|
|
40
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
41
|
-
`
|
|
35
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
42
36
|
}),
|
|
43
37
|
h4: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h4, {
|
|
44
38
|
...props,
|
|
45
|
-
className: `
|
|
46
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
47
|
-
`
|
|
39
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
48
40
|
}),
|
|
49
41
|
h5: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h5, {
|
|
50
42
|
...props,
|
|
51
|
-
className: `
|
|
52
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
53
|
-
`
|
|
43
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
54
44
|
}),
|
|
55
45
|
h6: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h6, {
|
|
56
46
|
...props,
|
|
57
|
-
className: `
|
|
58
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
59
|
-
`
|
|
47
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
60
48
|
}),
|
|
61
49
|
p: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.p, {
|
|
62
50
|
...props,
|
|
@@ -69,15 +57,17 @@ const bergetComponents = {
|
|
|
69
57
|
ul: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.ul, {
|
|
70
58
|
...props,
|
|
71
59
|
className: `
|
|
72
|
-
my-2 ms-5 list-disc
|
|
60
|
+
my-2 ms-5 list-disc
|
|
73
61
|
marker:text-berget-muted-foreground
|
|
62
|
+
[&>li+li]:mt-1
|
|
74
63
|
`
|
|
75
64
|
}),
|
|
76
65
|
ol: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.ol, {
|
|
77
66
|
...props,
|
|
78
67
|
className: `
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
my-2 ms-5 list-decimal
|
|
69
|
+
[&>li+li]:mt-1
|
|
70
|
+
`
|
|
81
71
|
}),
|
|
82
72
|
li: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.li, {
|
|
83
73
|
...props,
|
|
@@ -100,9 +90,7 @@ const bergetComponents = {
|
|
|
100
90
|
}),
|
|
101
91
|
hr: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.hr, {
|
|
102
92
|
...props,
|
|
103
|
-
className: `
|
|
104
|
-
my-4 border-berget-border
|
|
105
|
-
`
|
|
93
|
+
className: `my-4 border-berget-border`
|
|
106
94
|
}),
|
|
107
95
|
img: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.img, {
|
|
108
96
|
...props,
|
|
@@ -153,9 +141,7 @@ const bergetComponents = {
|
|
|
153
141
|
}),
|
|
154
142
|
td: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.td, {
|
|
155
143
|
...props,
|
|
156
|
-
className: `
|
|
157
|
-
border-b border-b-berget-border px-3 py-1.5
|
|
158
|
-
`
|
|
144
|
+
className: `border-b border-b-berget-border px-3 py-1.5`
|
|
159
145
|
})
|
|
160
146
|
};
|
|
161
147
|
function Markdown({ className, ...props }) {
|
|
@@ -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) =>
|
|
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) => <defaultComponents.h1 {...props} className={`mt-4 mb-2 text-lg font-semibold`} />,\n h2: (props) => (\n <defaultComponents.h2 {...props} className={`mt-4 mb-2 text-base font-semibold`} />\n ),\n h3: (props) => (\n <defaultComponents.h3 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h4: (props) => (\n <defaultComponents.h4 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h5: (props) => (\n <defaultComponents.h5 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h6: (props) => (\n <defaultComponents.h6 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\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\n marker:text-berget-muted-foreground\n [&>li+li]:mt-1\n `}\n />\n ),\n ol: (props) => (\n <defaultComponents.ol\n {...props}\n className={`\n my-2 ms-5 list-decimal\n [&>li+li]:mt-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) => <defaultComponents.hr {...props} className={`my-4 border-berget-border`} />,\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 {...props} className={`border-b border-b-berget-border px-3 py-1.5`} />\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,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAoC,CAAA;CAC/F,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,IAAI,UACF,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,GAAnB;EACE,GAAI;EACJ,WAAW;;;;;CAKZ,CAAA;CAEH,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,WAAAA,kBAAkB,IAAnB;EACE,GAAI;EACJ,WAAW;;;;;CAKZ,CAAA;CAEH,KAAK,UACH,iBAAA,GAAA,kBAAA,IAAA,CAACA,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ACA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAG,SAAW,CAAA;CACvB;CACA,QAAQ,UACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAW;;;;EAKX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;GAAO,GAAI;GAAO,WAAW;EAAmC,CAAA;CAC7D,CAAA;CAEP,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;EAAsB,GAAI;EAAO,WAAW;CAAgD,CAAA;AAEhG;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":";;KA+IK,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":";;KA+IK,gBAAgB,KAAK;wBAGV,WAAW,cAAc,SAAS,4CAAa,IAAA;yBAA/C"}
|
|
@@ -22,39 +22,27 @@ import { Streamdown, defaultComponents } from "streamdown";
|
|
|
22
22
|
const bergetComponents = {
|
|
23
23
|
h1: (props) => /* @__PURE__ */ jsx(defaultComponents.h1, {
|
|
24
24
|
...props,
|
|
25
|
-
className: `
|
|
26
|
-
mt-4 mb-2 text-lg font-semibold
|
|
27
|
-
`
|
|
25
|
+
className: `mt-4 mb-2 text-lg font-semibold`
|
|
28
26
|
}),
|
|
29
27
|
h2: (props) => /* @__PURE__ */ jsx(defaultComponents.h2, {
|
|
30
28
|
...props,
|
|
31
|
-
className: `
|
|
32
|
-
mt-4 mb-2 text-base font-semibold
|
|
33
|
-
`
|
|
29
|
+
className: `mt-4 mb-2 text-base font-semibold`
|
|
34
30
|
}),
|
|
35
31
|
h3: (props) => /* @__PURE__ */ jsx(defaultComponents.h3, {
|
|
36
32
|
...props,
|
|
37
|
-
className: `
|
|
38
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
39
|
-
`
|
|
33
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
40
34
|
}),
|
|
41
35
|
h4: (props) => /* @__PURE__ */ jsx(defaultComponents.h4, {
|
|
42
36
|
...props,
|
|
43
|
-
className: `
|
|
44
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
45
|
-
`
|
|
37
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
46
38
|
}),
|
|
47
39
|
h5: (props) => /* @__PURE__ */ jsx(defaultComponents.h5, {
|
|
48
40
|
...props,
|
|
49
|
-
className: `
|
|
50
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
51
|
-
`
|
|
41
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
52
42
|
}),
|
|
53
43
|
h6: (props) => /* @__PURE__ */ jsx(defaultComponents.h6, {
|
|
54
44
|
...props,
|
|
55
|
-
className: `
|
|
56
|
-
mt-3 mb-1.5 text-sm font-semibold
|
|
57
|
-
`
|
|
45
|
+
className: `mt-3 mb-1.5 text-sm font-semibold`
|
|
58
46
|
}),
|
|
59
47
|
p: (props) => /* @__PURE__ */ jsx(defaultComponents.p, {
|
|
60
48
|
...props,
|
|
@@ -67,15 +55,17 @@ const bergetComponents = {
|
|
|
67
55
|
ul: (props) => /* @__PURE__ */ jsx(defaultComponents.ul, {
|
|
68
56
|
...props,
|
|
69
57
|
className: `
|
|
70
|
-
my-2 ms-5 list-disc
|
|
58
|
+
my-2 ms-5 list-disc
|
|
71
59
|
marker:text-berget-muted-foreground
|
|
60
|
+
[&>li+li]:mt-1
|
|
72
61
|
`
|
|
73
62
|
}),
|
|
74
63
|
ol: (props) => /* @__PURE__ */ jsx(defaultComponents.ol, {
|
|
75
64
|
...props,
|
|
76
65
|
className: `
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
my-2 ms-5 list-decimal
|
|
67
|
+
[&>li+li]:mt-1
|
|
68
|
+
`
|
|
79
69
|
}),
|
|
80
70
|
li: (props) => /* @__PURE__ */ jsx(defaultComponents.li, {
|
|
81
71
|
...props,
|
|
@@ -98,9 +88,7 @@ const bergetComponents = {
|
|
|
98
88
|
}),
|
|
99
89
|
hr: (props) => /* @__PURE__ */ jsx(defaultComponents.hr, {
|
|
100
90
|
...props,
|
|
101
|
-
className: `
|
|
102
|
-
my-4 border-berget-border
|
|
103
|
-
`
|
|
91
|
+
className: `my-4 border-berget-border`
|
|
104
92
|
}),
|
|
105
93
|
img: (props) => /* @__PURE__ */ jsx(defaultComponents.img, {
|
|
106
94
|
...props,
|
|
@@ -151,9 +139,7 @@ const bergetComponents = {
|
|
|
151
139
|
}),
|
|
152
140
|
td: (props) => /* @__PURE__ */ jsx(defaultComponents.td, {
|
|
153
141
|
...props,
|
|
154
|
-
className: `
|
|
155
|
-
border-b border-b-berget-border px-3 py-1.5
|
|
156
|
-
`
|
|
142
|
+
className: `border-b border-b-berget-border px-3 py-1.5`
|
|
157
143
|
})
|
|
158
144
|
};
|
|
159
145
|
function Markdown({ className, ...props }) {
|
|
@@ -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) =>
|
|
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) => <defaultComponents.h1 {...props} className={`mt-4 mb-2 text-lg font-semibold`} />,\n h2: (props) => (\n <defaultComponents.h2 {...props} className={`mt-4 mb-2 text-base font-semibold`} />\n ),\n h3: (props) => (\n <defaultComponents.h3 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h4: (props) => (\n <defaultComponents.h4 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h5: (props) => (\n <defaultComponents.h5 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\n ),\n h6: (props) => (\n <defaultComponents.h6 {...props} className={`mt-3 mb-1.5 text-sm font-semibold`} />\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\n marker:text-berget-muted-foreground\n [&>li+li]:mt-1\n `}\n />\n ),\n ol: (props) => (\n <defaultComponents.ol\n {...props}\n className={`\n my-2 ms-5 list-decimal\n [&>li+li]:mt-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) => <defaultComponents.hr {...props} className={`my-4 border-berget-border`} />,\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 {...props} className={`border-b border-b-berget-border px-3 py-1.5`} />\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,UAAU,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAoC,CAAA;CAC/F,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,CAAA;CAEpF,KAAK,UACH,oBAAC,kBAAkB,IAAnB;EAAsB,GAAI;EAAO,WAAW;CAAsC,C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