@bergetai/ui 0.23.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 +31 -11
- 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 +31 -11
- package/dist/components/markdown/Markdown.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -24,27 +24,39 @@ 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: `
|
|
27
|
+
className: `
|
|
28
|
+
mt-4 mb-2 text-lg font-semibold
|
|
29
|
+
`
|
|
28
30
|
}),
|
|
29
31
|
h2: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h2, {
|
|
30
32
|
...props,
|
|
31
|
-
className: `
|
|
33
|
+
className: `
|
|
34
|
+
mt-4 mb-2 text-base font-semibold
|
|
35
|
+
`
|
|
32
36
|
}),
|
|
33
37
|
h3: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h3, {
|
|
34
38
|
...props,
|
|
35
|
-
className: `
|
|
39
|
+
className: `
|
|
40
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
41
|
+
`
|
|
36
42
|
}),
|
|
37
43
|
h4: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h4, {
|
|
38
44
|
...props,
|
|
39
|
-
className: `
|
|
45
|
+
className: `
|
|
46
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
47
|
+
`
|
|
40
48
|
}),
|
|
41
49
|
h5: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h5, {
|
|
42
50
|
...props,
|
|
43
|
-
className: `
|
|
51
|
+
className: `
|
|
52
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
53
|
+
`
|
|
44
54
|
}),
|
|
45
55
|
h6: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.h6, {
|
|
46
56
|
...props,
|
|
47
|
-
className: `
|
|
57
|
+
className: `
|
|
58
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
59
|
+
`
|
|
48
60
|
}),
|
|
49
61
|
p: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.p, {
|
|
50
62
|
...props,
|
|
@@ -63,7 +75,9 @@ const bergetComponents = {
|
|
|
63
75
|
}),
|
|
64
76
|
ol: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.ol, {
|
|
65
77
|
...props,
|
|
66
|
-
className: `
|
|
78
|
+
className: `
|
|
79
|
+
my-2 ms-5 list-decimal space-y-1
|
|
80
|
+
`
|
|
67
81
|
}),
|
|
68
82
|
li: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.li, {
|
|
69
83
|
...props,
|
|
@@ -86,11 +100,13 @@ const bergetComponents = {
|
|
|
86
100
|
}),
|
|
87
101
|
hr: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.hr, {
|
|
88
102
|
...props,
|
|
89
|
-
className: `
|
|
103
|
+
className: `
|
|
104
|
+
my-4 border-berget-border
|
|
105
|
+
`
|
|
90
106
|
}),
|
|
91
107
|
img: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.img, {
|
|
92
108
|
...props,
|
|
93
|
-
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`
|
|
94
110
|
}),
|
|
95
111
|
a: ({ node: _node, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
96
112
|
...props,
|
|
@@ -131,11 +147,15 @@ const bergetComponents = {
|
|
|
131
147
|
}),
|
|
132
148
|
th: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.th, {
|
|
133
149
|
...props,
|
|
134
|
-
className: `
|
|
150
|
+
className: `
|
|
151
|
+
border-b border-b-berget-border px-3 py-1.5 text-start font-semibold
|
|
152
|
+
`
|
|
135
153
|
}),
|
|
136
154
|
td: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.defaultComponents.td, {
|
|
137
155
|
...props,
|
|
138
|
-
className: `
|
|
156
|
+
className: `
|
|
157
|
+
border-b border-b-berget-border px-3 py-1.5
|
|
158
|
+
`
|
|
139
159
|
})
|
|
140
160
|
};
|
|
141
161
|
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) => <defaultComponents.h1
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,mBAA+B;CACnC,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;CAEH,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;CAEH,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;CAEH,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;;;;CAIZ,CAAA;CAEH,KAAK,UACH,iBAAA,G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;GAAW,CAAA;EAC3E;EACA,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;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"}
|
|
@@ -22,27 +22,39 @@ import { Streamdown, defaultComponents } from "streamdown";
|
|
|
22
22
|
const bergetComponents = {
|
|
23
23
|
h1: (props) => /* @__PURE__ */ jsx(defaultComponents.h1, {
|
|
24
24
|
...props,
|
|
25
|
-
className: `
|
|
25
|
+
className: `
|
|
26
|
+
mt-4 mb-2 text-lg font-semibold
|
|
27
|
+
`
|
|
26
28
|
}),
|
|
27
29
|
h2: (props) => /* @__PURE__ */ jsx(defaultComponents.h2, {
|
|
28
30
|
...props,
|
|
29
|
-
className: `
|
|
31
|
+
className: `
|
|
32
|
+
mt-4 mb-2 text-base font-semibold
|
|
33
|
+
`
|
|
30
34
|
}),
|
|
31
35
|
h3: (props) => /* @__PURE__ */ jsx(defaultComponents.h3, {
|
|
32
36
|
...props,
|
|
33
|
-
className: `
|
|
37
|
+
className: `
|
|
38
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
39
|
+
`
|
|
34
40
|
}),
|
|
35
41
|
h4: (props) => /* @__PURE__ */ jsx(defaultComponents.h4, {
|
|
36
42
|
...props,
|
|
37
|
-
className: `
|
|
43
|
+
className: `
|
|
44
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
45
|
+
`
|
|
38
46
|
}),
|
|
39
47
|
h5: (props) => /* @__PURE__ */ jsx(defaultComponents.h5, {
|
|
40
48
|
...props,
|
|
41
|
-
className: `
|
|
49
|
+
className: `
|
|
50
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
51
|
+
`
|
|
42
52
|
}),
|
|
43
53
|
h6: (props) => /* @__PURE__ */ jsx(defaultComponents.h6, {
|
|
44
54
|
...props,
|
|
45
|
-
className: `
|
|
55
|
+
className: `
|
|
56
|
+
mt-3 mb-1.5 text-sm font-semibold
|
|
57
|
+
`
|
|
46
58
|
}),
|
|
47
59
|
p: (props) => /* @__PURE__ */ jsx(defaultComponents.p, {
|
|
48
60
|
...props,
|
|
@@ -61,7 +73,9 @@ const bergetComponents = {
|
|
|
61
73
|
}),
|
|
62
74
|
ol: (props) => /* @__PURE__ */ jsx(defaultComponents.ol, {
|
|
63
75
|
...props,
|
|
64
|
-
className: `
|
|
76
|
+
className: `
|
|
77
|
+
my-2 ms-5 list-decimal space-y-1
|
|
78
|
+
`
|
|
65
79
|
}),
|
|
66
80
|
li: (props) => /* @__PURE__ */ jsx(defaultComponents.li, {
|
|
67
81
|
...props,
|
|
@@ -84,11 +98,13 @@ const bergetComponents = {
|
|
|
84
98
|
}),
|
|
85
99
|
hr: (props) => /* @__PURE__ */ jsx(defaultComponents.hr, {
|
|
86
100
|
...props,
|
|
87
|
-
className: `
|
|
101
|
+
className: `
|
|
102
|
+
my-4 border-berget-border
|
|
103
|
+
`
|
|
88
104
|
}),
|
|
89
105
|
img: (props) => /* @__PURE__ */ jsx(defaultComponents.img, {
|
|
90
106
|
...props,
|
|
91
|
-
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`
|
|
92
108
|
}),
|
|
93
109
|
a: ({ node: _node, ...props }) => /* @__PURE__ */ jsx("a", {
|
|
94
110
|
...props,
|
|
@@ -129,11 +145,15 @@ const bergetComponents = {
|
|
|
129
145
|
}),
|
|
130
146
|
th: (props) => /* @__PURE__ */ jsx(defaultComponents.th, {
|
|
131
147
|
...props,
|
|
132
|
-
className: `
|
|
148
|
+
className: `
|
|
149
|
+
border-b border-b-berget-border px-3 py-1.5 text-start font-semibold
|
|
150
|
+
`
|
|
133
151
|
}),
|
|
134
152
|
td: (props) => /* @__PURE__ */ jsx(defaultComponents.td, {
|
|
135
153
|
...props,
|
|
136
|
-
className: `
|
|
154
|
+
className: `
|
|
155
|
+
border-b border-b-berget-border px-3 py-1.5
|
|
156
|
+
`
|
|
137
157
|
})
|
|
138
158
|
};
|
|
139
159
|
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) => <defaultComponents.h1
|
|
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;E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