fumadocs-core 16.4.0 → 16.4.2

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.
Files changed (278) hide show
  1. package/dist/advanced-BRT5Ij43.js +80 -0
  2. package/dist/advanced-BRT5Ij43.js.map +1 -0
  3. package/dist/algolia-CBBN8R6-.d.ts +68 -0
  4. package/dist/algolia-CBBN8R6-.d.ts.map +1 -0
  5. package/dist/algolia-CQPXCnjV.js +49 -0
  6. package/dist/algolia-CQPXCnjV.js.map +1 -0
  7. package/dist/breadcrumb.d.ts +29 -27
  8. package/dist/breadcrumb.d.ts.map +1 -0
  9. package/dist/breadcrumb.js +55 -72
  10. package/dist/breadcrumb.js.map +1 -0
  11. package/dist/chunk-B-ezknvj.js +42 -0
  12. package/dist/codeblock-utils-lld8UiQo.d.ts +37 -0
  13. package/dist/codeblock-utils-lld8UiQo.d.ts.map +1 -0
  14. package/dist/content/github.d.ts +43 -32
  15. package/dist/content/github.d.ts.map +1 -0
  16. package/dist/content/github.js +29 -43
  17. package/dist/content/github.js.map +1 -0
  18. package/dist/content/index.d.ts +20 -13
  19. package/dist/content/index.d.ts.map +1 -0
  20. package/dist/content/index.js +17 -23
  21. package/dist/content/index.js.map +1 -0
  22. package/dist/content/mdx/preset-bundler.d.ts +22 -24
  23. package/dist/content/mdx/preset-bundler.d.ts.map +1 -0
  24. package/dist/content/mdx/preset-bundler.js +38 -69
  25. package/dist/content/mdx/preset-bundler.js.map +1 -0
  26. package/dist/content/mdx/preset-runtime.d.ts +22 -24
  27. package/dist/content/mdx/preset-runtime.d.ts.map +1 -0
  28. package/dist/content/mdx/preset-runtime.js +36 -68
  29. package/dist/content/mdx/preset-runtime.js.map +1 -0
  30. package/dist/content/toc.d.ts +7 -6
  31. package/dist/content/toc.d.ts.map +1 -0
  32. package/dist/content/toc.js +15 -19
  33. package/dist/content/toc.js.map +1 -0
  34. package/dist/definitions-DuxDer_c.d.ts +62 -0
  35. package/dist/definitions-DuxDer_c.d.ts.map +1 -0
  36. package/dist/dynamic-link.d.ts +7 -5
  37. package/dist/dynamic-link.d.ts.map +1 -0
  38. package/dist/dynamic-link.js +29 -27
  39. package/dist/dynamic-link.js.map +1 -0
  40. package/dist/fetch-B5e9CFfN.js +20 -0
  41. package/dist/fetch-B5e9CFfN.js.map +1 -0
  42. package/dist/framework/index.d.ts +38 -29
  43. package/dist/framework/index.d.ts.map +1 -0
  44. package/dist/framework/index.js +68 -17
  45. package/dist/framework/index.js.map +1 -0
  46. package/dist/framework/next.d.ts +15 -10
  47. package/dist/framework/next.d.ts.map +1 -0
  48. package/dist/framework/next.js +18 -26
  49. package/dist/framework/next.js.map +1 -0
  50. package/dist/framework/react-router.d.ts +15 -10
  51. package/dist/framework/react-router.d.ts.map +1 -0
  52. package/dist/framework/react-router.js +42 -55
  53. package/dist/framework/react-router.js.map +1 -0
  54. package/dist/framework/tanstack.d.ts +15 -10
  55. package/dist/framework/tanstack.d.ts.map +1 -0
  56. package/dist/framework/tanstack.js +54 -69
  57. package/dist/framework/tanstack.js.map +1 -0
  58. package/dist/framework/waku.d.ts +15 -10
  59. package/dist/framework/waku.d.ts.map +1 -0
  60. package/dist/framework/waku.js +47 -58
  61. package/dist/framework/waku.js.map +1 -0
  62. package/dist/highlight/client.d.ts +6 -7
  63. package/dist/highlight/client.d.ts.map +1 -0
  64. package/dist/highlight/client.js +22 -14
  65. package/dist/highlight/client.js.map +1 -0
  66. package/dist/highlight/index.d.ts +2 -30
  67. package/dist/highlight/index.js +3 -13
  68. package/dist/i18n/index.d.ts +2 -39
  69. package/dist/i18n/index.js +6 -7
  70. package/dist/i18n/index.js.map +1 -0
  71. package/dist/i18n/middleware.d.ts +36 -28
  72. package/dist/i18n/middleware.d.ts.map +1 -0
  73. package/dist/i18n/middleware.js +55 -73
  74. package/dist/i18n/middleware.js.map +1 -0
  75. package/dist/icon-Dt7IObrc.js +19 -0
  76. package/dist/icon-Dt7IObrc.js.map +1 -0
  77. package/dist/index-2U6Tl4--.d.ts +379 -0
  78. package/dist/index-2U6Tl4--.d.ts.map +1 -0
  79. package/dist/index-Bw-DCOra.d.ts +41 -0
  80. package/dist/index-Bw-DCOra.d.ts.map +1 -0
  81. package/dist/link.d.ts +17 -15
  82. package/dist/link.d.ts.map +1 -0
  83. package/dist/link.js +29 -9
  84. package/dist/link.js.map +1 -0
  85. package/dist/mdast-utils-mc9-X-PK.js +40 -0
  86. package/dist/mdast-utils-mc9-X-PK.js.map +1 -0
  87. package/dist/mdx-plugins/codeblock-utils.d.ts +2 -29
  88. package/dist/mdx-plugins/codeblock-utils.js +71 -9
  89. package/dist/mdx-plugins/codeblock-utils.js.map +1 -0
  90. package/dist/mdx-plugins/index.d.ts +15 -20
  91. package/dist/mdx-plugins/index.js +18 -73
  92. package/dist/mdx-plugins/rehype-code.d.ts +2 -55
  93. package/dist/mdx-plugins/rehype-code.js +5 -15
  94. package/dist/mdx-plugins/rehype-toc.d.ts +2 -14
  95. package/dist/mdx-plugins/rehype-toc.js +3 -7
  96. package/dist/mdx-plugins/remark-admonition.d.ts +2 -20
  97. package/dist/mdx-plugins/remark-admonition.js +74 -8
  98. package/dist/mdx-plugins/remark-admonition.js.map +1 -0
  99. package/dist/mdx-plugins/remark-code-tab.d.ts +2 -30
  100. package/dist/mdx-plugins/remark-code-tab.js +183 -7
  101. package/dist/mdx-plugins/remark-code-tab.js.map +1 -0
  102. package/dist/mdx-plugins/remark-directive-admonition.d.ts +2 -27
  103. package/dist/mdx-plugins/remark-directive-admonition.js +60 -7
  104. package/dist/mdx-plugins/remark-directive-admonition.js.map +1 -0
  105. package/dist/mdx-plugins/remark-gfm.d.ts +2 -1
  106. package/dist/mdx-plugins/remark-gfm.js +3 -7
  107. package/dist/mdx-plugins/remark-heading.d.ts +2 -31
  108. package/dist/mdx-plugins/remark-heading.js +45 -8
  109. package/dist/mdx-plugins/remark-heading.js.map +1 -0
  110. package/dist/mdx-plugins/remark-image.d.ts +2 -57
  111. package/dist/mdx-plugins/remark-image.js +192 -7
  112. package/dist/mdx-plugins/remark-image.js.map +1 -0
  113. package/dist/mdx-plugins/remark-mdx-files.d.ts +2 -40
  114. package/dist/mdx-plugins/remark-mdx-files.js +187 -7
  115. package/dist/mdx-plugins/remark-mdx-files.js.map +1 -0
  116. package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +2 -15
  117. package/dist/mdx-plugins/remark-mdx-mermaid.js +31 -7
  118. package/dist/mdx-plugins/remark-mdx-mermaid.js.map +1 -0
  119. package/dist/mdx-plugins/remark-npm.d.ts +2 -31
  120. package/dist/mdx-plugins/remark-npm.js +68 -8
  121. package/dist/mdx-plugins/remark-npm.js.map +1 -0
  122. package/dist/mdx-plugins/remark-steps.d.ts +2 -23
  123. package/dist/mdx-plugins/remark-steps.js +77 -7
  124. package/dist/mdx-plugins/remark-steps.js.map +1 -0
  125. package/dist/mdx-plugins/remark-structure.d.ts +2 -71
  126. package/dist/mdx-plugins/remark-structure.js +105 -11
  127. package/dist/mdx-plugins/remark-structure.js.map +1 -0
  128. package/dist/mixedbread-DlByNYSd.js +88 -0
  129. package/dist/mixedbread-DlByNYSd.js.map +1 -0
  130. package/dist/negotiation/index.d.ts +6 -4
  131. package/dist/negotiation/index.d.ts.map +1 -0
  132. package/dist/negotiation/index.js +41 -11
  133. package/dist/negotiation/index.js.map +1 -0
  134. package/dist/normalize-url-DP9-1I-S.js +16 -0
  135. package/dist/normalize-url-DP9-1I-S.js.map +1 -0
  136. package/dist/orama-cloud-DH3g37zc.js +84 -0
  137. package/dist/orama-cloud-DH3g37zc.js.map +1 -0
  138. package/dist/page-tree/index.d.ts +23 -11
  139. package/dist/page-tree/index.d.ts.map +1 -0
  140. package/dist/page-tree/index.js +3 -17
  141. package/dist/path-DHIjrDBP.js +60 -0
  142. package/dist/path-DHIjrDBP.js.map +1 -0
  143. package/dist/rehype-code-CdiZ1Y6P.js +241 -0
  144. package/dist/rehype-code-CdiZ1Y6P.js.map +1 -0
  145. package/dist/rehype-code-vVWG4-ej.d.ts +58 -0
  146. package/dist/rehype-code-vVWG4-ej.d.ts.map +1 -0
  147. package/dist/rehype-toc-DJvSyE0o.d.ts +18 -0
  148. package/dist/rehype-toc-DJvSyE0o.d.ts.map +1 -0
  149. package/dist/rehype-toc-DVwJcwvA.js +143 -0
  150. package/dist/rehype-toc-DVwJcwvA.js.map +1 -0
  151. package/dist/remark-admonition-DOwBWzsH.d.ts +22 -0
  152. package/dist/remark-admonition-DOwBWzsH.d.ts.map +1 -0
  153. package/dist/remark-code-tab-CXsYlims.d.ts +32 -0
  154. package/dist/remark-code-tab-CXsYlims.d.ts.map +1 -0
  155. package/dist/remark-directive-admonition-BCm_yiU9.d.ts +36 -0
  156. package/dist/remark-directive-admonition-BCm_yiU9.d.ts.map +1 -0
  157. package/dist/remark-gfm-CeWpMwyk.d.ts +2 -0
  158. package/dist/remark-heading-CXvCY0go.d.ts +37 -0
  159. package/dist/remark-heading-CXvCY0go.d.ts.map +1 -0
  160. package/dist/remark-image-CvUis4R1.d.ts +65 -0
  161. package/dist/remark-image-CvUis4R1.d.ts.map +1 -0
  162. package/dist/remark-mdx-files-B31xFFG4.d.ts +56 -0
  163. package/dist/remark-mdx-files-B31xFFG4.d.ts.map +1 -0
  164. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts +17 -0
  165. package/dist/remark-mdx-mermaid-BdSUUiCG.d.ts.map +1 -0
  166. package/dist/remark-npm-BIvIEKT2.d.ts +36 -0
  167. package/dist/remark-npm-BIvIEKT2.d.ts.map +1 -0
  168. package/dist/remark-steps-CHJN-rtm.d.ts +28 -0
  169. package/dist/remark-steps-CHJN-rtm.d.ts.map +1 -0
  170. package/dist/remark-structure-RZD2gGKp.d.ts +77 -0
  171. package/dist/remark-structure-RZD2gGKp.d.ts.map +1 -0
  172. package/dist/remove-undefined-Cfs4o_mM.js +19 -0
  173. package/dist/remove-undefined-Cfs4o_mM.js.map +1 -0
  174. package/dist/search/algolia.d.ts +3 -69
  175. package/dist/search/algolia.js +69 -63
  176. package/dist/search/algolia.js.map +1 -0
  177. package/dist/search/client.d.ts +120 -114
  178. package/dist/search/client.d.ts.map +1 -0
  179. package/dist/search/client.js +92 -91
  180. package/dist/search/client.js.map +1 -0
  181. package/dist/search/index.d.ts +20 -18
  182. package/dist/search/index.d.ts.map +1 -0
  183. package/dist/search/index.js +3 -7
  184. package/dist/search/orama-cloud.d.ts +70 -68
  185. package/dist/search/orama-cloud.d.ts.map +1 -0
  186. package/dist/search/orama-cloud.js +46 -54
  187. package/dist/search/orama-cloud.js.map +1 -0
  188. package/dist/search/server.d.ts +6 -136
  189. package/dist/search/server.js +292 -369
  190. package/dist/search/server.js.map +1 -0
  191. package/dist/search-D6ChCLhY.js +44 -0
  192. package/dist/search-D6ChCLhY.js.map +1 -0
  193. package/dist/server-CPR_fgkH.d.ts +133 -0
  194. package/dist/server-CPR_fgkH.d.ts.map +1 -0
  195. package/dist/shiki-4oMYwHED.js +80 -0
  196. package/dist/shiki-4oMYwHED.js.map +1 -0
  197. package/dist/shiki-CIBQys54.d.ts +33 -0
  198. package/dist/shiki-CIBQys54.d.ts.map +1 -0
  199. package/dist/source/client/index.d.ts +7 -5
  200. package/dist/source/client/index.d.ts.map +1 -0
  201. package/dist/source/client/index.js +24 -35
  202. package/dist/source/client/index.js.map +1 -0
  203. package/dist/source/index.d.ts +3 -42
  204. package/dist/source/index.js +599 -752
  205. package/dist/source/index.js.map +1 -0
  206. package/dist/source/plugins/lucide-icons.d.ts +7 -7
  207. package/dist/source/plugins/lucide-icons.d.ts.map +1 -0
  208. package/dist/source/plugins/lucide-icons.js +21 -20
  209. package/dist/source/plugins/lucide-icons.js.map +1 -0
  210. package/dist/source/plugins/slugs.d.ts +3 -0
  211. package/dist/source/plugins/slugs.js +65 -0
  212. package/dist/source/plugins/slugs.js.map +1 -0
  213. package/dist/source/schema.d.ts +17 -14
  214. package/dist/source/schema.d.ts.map +1 -0
  215. package/dist/source/schema.js +26 -22
  216. package/dist/source/schema.js.map +1 -0
  217. package/dist/static-Dq8pA8Ay.js +51 -0
  218. package/dist/static-Dq8pA8Ay.js.map +1 -0
  219. package/dist/toc.d.ts +38 -25
  220. package/dist/toc.d.ts.map +1 -0
  221. package/dist/toc.js +123 -136
  222. package/dist/toc.js.map +1 -0
  223. package/dist/util-CK2ykiif.d.ts +8 -0
  224. package/dist/util-CK2ykiif.d.ts.map +1 -0
  225. package/dist/util-s9piKHsk.js +10 -0
  226. package/dist/util-s9piKHsk.js.map +1 -0
  227. package/dist/utils/use-effect-event.d.ts +3 -1
  228. package/dist/utils/use-effect-event.d.ts.map +1 -0
  229. package/dist/utils/use-effect-event.js +16 -13
  230. package/dist/utils/use-effect-event.js.map +1 -0
  231. package/dist/utils/use-media-query.d.ts +3 -1
  232. package/dist/utils/use-media-query.d.ts.map +1 -0
  233. package/dist/utils/use-media-query.js +20 -20
  234. package/dist/utils/use-media-query.js.map +1 -0
  235. package/dist/utils/use-on-change.d.ts +3 -1
  236. package/dist/utils/use-on-change.d.ts.map +1 -0
  237. package/dist/utils/use-on-change.js +23 -7
  238. package/dist/utils/use-on-change.js.map +1 -0
  239. package/dist/utils-DUvi2WkD.js +134 -0
  240. package/dist/utils-DUvi2WkD.js.map +1 -0
  241. package/package.json +60 -58
  242. package/dist/algolia-IZEDLPHE.js +0 -58
  243. package/dist/chunk-5PMI7QDD.js +0 -220
  244. package/dist/chunk-ADBHPKXG.js +0 -78
  245. package/dist/chunk-APKPSBSB.js +0 -74
  246. package/dist/chunk-CH7YHH7V.js +0 -222
  247. package/dist/chunk-EFVXL2PP.js +0 -144
  248. package/dist/chunk-EMWGTXSW.js +0 -19
  249. package/dist/chunk-FAEPKD7U.js +0 -20
  250. package/dist/chunk-FUUVPEA5.js +0 -29
  251. package/dist/chunk-GINBKBVQ.js +0 -12
  252. package/dist/chunk-GLRQBLGN.js +0 -59
  253. package/dist/chunk-JUF4WZ6G.js +0 -117
  254. package/dist/chunk-K4WNLOVQ.js +0 -75
  255. package/dist/chunk-L4JKQWCM.js +0 -131
  256. package/dist/chunk-MA6O2UUE.js +0 -50
  257. package/dist/chunk-ONG4RVCR.js +0 -8
  258. package/dist/chunk-OTD7MV33.js +0 -53
  259. package/dist/chunk-PFNP6PEB.js +0 -11
  260. package/dist/chunk-SH7BNTG7.js +0 -38
  261. package/dist/chunk-TWIDBWFG.js +0 -84
  262. package/dist/chunk-U67V476Y.js +0 -35
  263. package/dist/chunk-VLSDGCJE.js +0 -47
  264. package/dist/chunk-W6WTLKRA.js +0 -73
  265. package/dist/chunk-X2HFD5QJ.js +0 -275
  266. package/dist/chunk-XJ6ZQNEX.js +0 -91
  267. package/dist/chunk-XN2LKXFZ.js +0 -101
  268. package/dist/chunk-XOFXGHS4.js +0 -93
  269. package/dist/chunk-XZSI7AHE.js +0 -67
  270. package/dist/chunk-YVVDKJ2H.js +0 -34
  271. package/dist/chunk-ZMWYLUDP.js +0 -21
  272. package/dist/definitions-pJ7PybYY.d.ts +0 -60
  273. package/dist/fetch-IBTWQCJR.js +0 -22
  274. package/dist/loader-_E2HOdV0.d.ts +0 -333
  275. package/dist/mixedbread-A3WLENES.js +0 -117
  276. package/dist/orama-cloud-UZAPMPFV.js +0 -93
  277. package/dist/static-A2YJ5TXV.js +0 -62
  278. package/dist/util-bZU2QeJ2.d.ts +0 -6
@@ -1,23 +1,2 @@
1
- import { Transformer } from 'unified';
2
- import { Root } from 'mdast';
3
-
4
- interface RemarkStepsOptions {
5
- /**
6
- * Class name for steps container
7
- *
8
- * @defaultValue fd-steps
9
- */
10
- steps?: string;
11
- /**
12
- * Class name for step container
13
- *
14
- * @defaultValue fd-step
15
- */
16
- step?: string;
17
- }
18
- /**
19
- * Convert headings in the format of `1. Hello World` into steps.
20
- */
21
- declare function remarkSteps({ steps, step, }?: RemarkStepsOptions): Transformer<Root, Root>;
22
-
23
- export { type RemarkStepsOptions, remarkSteps };
1
+ import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-CHJN-rtm.js";
2
+ export { RemarkStepsOptions, remarkSteps };
@@ -1,7 +1,77 @@
1
- import {
2
- remarkSteps
3
- } from "../chunk-XJ6ZQNEX.js";
4
- import "../chunk-U67V476Y.js";
5
- export {
6
- remarkSteps
7
- };
1
+ import { visit } from "unist-util-visit";
2
+
3
+ //#region src/mdx-plugins/remark-steps.ts
4
+ const StepRegex = /^(\d+)\.\s(.+)$/;
5
+ /**
6
+ * Convert headings in the format of `1. Hello World` into steps.
7
+ */
8
+ function remarkSteps({ steps = "fd-steps", step = "fd-step" } = {}) {
9
+ function convertToSteps(nodes) {
10
+ const depth = nodes[0].depth;
11
+ const children = [];
12
+ for (const node of nodes) if (node.type === "heading" && node.depth === depth) children.push({
13
+ type: "mdxJsxFlowElement",
14
+ name: "div",
15
+ attributes: [{
16
+ type: "mdxJsxAttribute",
17
+ name: "className",
18
+ value: step
19
+ }],
20
+ children: [node]
21
+ });
22
+ else children[children.length - 1].children.push(node);
23
+ return {
24
+ type: "mdxJsxFlowElement",
25
+ name: "div",
26
+ attributes: [{
27
+ type: "mdxJsxAttribute",
28
+ name: "className",
29
+ value: steps
30
+ }],
31
+ data: { _fd_step: true },
32
+ children
33
+ };
34
+ }
35
+ return (tree) => {
36
+ visit(tree, (parent) => {
37
+ if (!("children" in parent) || parent.type === "heading") return;
38
+ if (parent.data && "_fd_step" in parent.data) return "skip";
39
+ let startIdx = -1;
40
+ let i = 0;
41
+ const onEnd = () => {
42
+ if (startIdx === -1) return;
43
+ const item = {};
44
+ const nodes = parent.children.splice(startIdx, i - startIdx, item);
45
+ Object.assign(item, convertToSteps(nodes));
46
+ i = startIdx + 1;
47
+ startIdx = -1;
48
+ };
49
+ for (; i < parent.children.length; i++) {
50
+ const node = parent.children[i];
51
+ if (node.type !== "heading") continue;
52
+ if (startIdx !== -1) {
53
+ const startDepth = parent.children[startIdx].depth;
54
+ if (node.depth > startDepth) continue;
55
+ else if (node.depth < startDepth) onEnd();
56
+ }
57
+ const head = node.children.filter((c) => c.type === "text").at(0);
58
+ if (!head) {
59
+ onEnd();
60
+ continue;
61
+ }
62
+ const match = StepRegex.exec(head.value);
63
+ if (!match) {
64
+ onEnd();
65
+ continue;
66
+ }
67
+ head.value = match[2];
68
+ if (startIdx === -1) startIdx = i;
69
+ }
70
+ onEnd();
71
+ });
72
+ };
73
+ }
74
+
75
+ //#endregion
76
+ export { remarkSteps };
77
+ //# sourceMappingURL=remark-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-steps.js","names":["children: MdxJsxFlowElement[]"],"sources":["../../src/mdx-plugins/remark-steps.ts"],"sourcesContent":["import type { Transformer } from 'unified';\nimport type { BlockContent, Heading, Root, RootContent } from 'mdast';\nimport { visit } from 'unist-util-visit';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\n\nexport interface RemarkStepsOptions {\n /**\n * Class name for steps container\n *\n * @defaultValue fd-steps\n */\n steps?: string;\n\n /**\n * Class name for step container\n *\n * @defaultValue fd-step\n */\n step?: string;\n}\n\nconst StepRegex = /^(\\d+)\\.\\s(.+)$/;\n\n/**\n * Convert headings in the format of `1. Hello World` into steps.\n */\nexport function remarkSteps({\n steps = 'fd-steps',\n step = 'fd-step',\n}: RemarkStepsOptions = {}): Transformer<Root, Root> {\n function convertToSteps(nodes: RootContent[]): MdxJsxFlowElement {\n const depth = (nodes[0] as Heading).depth;\n const children: MdxJsxFlowElement[] = [];\n\n for (const node of nodes) {\n if (node.type === 'heading' && node.depth === depth) {\n children.push({\n type: 'mdxJsxFlowElement',\n name: 'div',\n attributes: [\n {\n type: 'mdxJsxAttribute',\n name: 'className',\n value: step,\n },\n ],\n children: [node],\n });\n } else {\n children[children.length - 1].children.push(node as BlockContent);\n }\n }\n\n return {\n type: 'mdxJsxFlowElement',\n name: 'div',\n attributes: [\n {\n type: 'mdxJsxAttribute',\n name: 'className',\n value: steps,\n },\n ],\n data: {\n _fd_step: true,\n } as object,\n children,\n };\n }\n\n return (tree) => {\n visit(tree, (parent) => {\n if (!('children' in parent) || parent.type === 'heading') return;\n if (parent.data && '_fd_step' in parent.data) return 'skip';\n\n let startIdx = -1;\n let i = 0;\n\n const onEnd = () => {\n if (startIdx === -1) return;\n // range: start index to i - 1\n const item = {};\n const nodes = parent.children.splice(startIdx, i - startIdx, item as RootContent);\n Object.assign(item, convertToSteps(nodes));\n i = startIdx + 1;\n startIdx = -1;\n };\n\n for (; i < parent.children.length; i++) {\n const node = parent.children[i];\n\n if (node.type !== 'heading') continue;\n if (startIdx !== -1) {\n const startDepth = (parent.children[startIdx] as Heading).depth;\n\n if (node.depth > startDepth) continue;\n else if (node.depth < startDepth) onEnd();\n }\n\n const head = node.children.filter((c) => c.type === 'text').at(0);\n if (!head) {\n onEnd();\n continue;\n }\n\n const match = StepRegex.exec(head.value);\n if (!match) {\n onEnd();\n continue;\n }\n\n head.value = match[2];\n if (startIdx === -1) startIdx = i;\n }\n\n onEnd();\n });\n };\n}\n"],"mappings":";;;AAqBA,MAAM,YAAY;;;;AAKlB,SAAgB,YAAY,EAC1B,QAAQ,YACR,OAAO,cACe,EAAE,EAA2B;CACnD,SAAS,eAAe,OAAyC;EAC/D,MAAM,QAAS,MAAM,GAAe;EACpC,MAAMA,WAAgC,EAAE;AAExC,OAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,SAAS,aAAa,KAAK,UAAU,MAC5C,UAAS,KAAK;GACZ,MAAM;GACN,MAAM;GACN,YAAY,CACV;IACE,MAAM;IACN,MAAM;IACN,OAAO;IACR,CACF;GACD,UAAU,CAAC,KAAK;GACjB,CAAC;MAEF,UAAS,SAAS,SAAS,GAAG,SAAS,KAAK,KAAqB;AAIrE,SAAO;GACL,MAAM;GACN,MAAM;GACN,YAAY,CACV;IACE,MAAM;IACN,MAAM;IACN,OAAO;IACR,CACF;GACD,MAAM,EACJ,UAAU,MACX;GACD;GACD;;AAGH,SAAQ,SAAS;AACf,QAAM,OAAO,WAAW;AACtB,OAAI,EAAE,cAAc,WAAW,OAAO,SAAS,UAAW;AAC1D,OAAI,OAAO,QAAQ,cAAc,OAAO,KAAM,QAAO;GAErD,IAAI,WAAW;GACf,IAAI,IAAI;GAER,MAAM,cAAc;AAClB,QAAI,aAAa,GAAI;IAErB,MAAM,OAAO,EAAE;IACf,MAAM,QAAQ,OAAO,SAAS,OAAO,UAAU,IAAI,UAAU,KAAoB;AACjF,WAAO,OAAO,MAAM,eAAe,MAAM,CAAC;AAC1C,QAAI,WAAW;AACf,eAAW;;AAGb,UAAO,IAAI,OAAO,SAAS,QAAQ,KAAK;IACtC,MAAM,OAAO,OAAO,SAAS;AAE7B,QAAI,KAAK,SAAS,UAAW;AAC7B,QAAI,aAAa,IAAI;KACnB,MAAM,aAAc,OAAO,SAAS,UAAsB;AAE1D,SAAI,KAAK,QAAQ,WAAY;cACpB,KAAK,QAAQ,WAAY,QAAO;;IAG3C,MAAM,OAAO,KAAK,SAAS,QAAQ,MAAM,EAAE,SAAS,OAAO,CAAC,GAAG,EAAE;AACjE,QAAI,CAAC,MAAM;AACT,YAAO;AACP;;IAGF,MAAM,QAAQ,UAAU,KAAK,KAAK,MAAM;AACxC,QAAI,CAAC,OAAO;AACV,YAAO;AACP;;AAGF,SAAK,QAAQ,MAAM;AACnB,QAAI,aAAa,GAAI,YAAW;;AAGlC,UAAO;IACP"}
@@ -1,71 +1,2 @@
1
- import { Nodes, Root } from 'mdast';
2
- import { Transformer, PluggableList } from 'unified';
3
- import { MdxJsxFlowElement, MdxJsxAttribute, MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
4
-
5
- interface Heading {
6
- id: string;
7
- content: string;
8
- }
9
- interface Content {
10
- heading: string | undefined;
11
- content: string;
12
- }
13
- interface StructuredData {
14
- headings: Heading[];
15
- /**
16
- * Refer to paragraphs, a heading may contain multiple contents as well
17
- */
18
- contents: Content[];
19
- }
20
- interface StructureOptions {
21
- /**
22
- * Types to be scanned as content.
23
- *
24
- * @defaultValue ['heading', 'paragraph', 'blockquote', 'tableCell', 'mdxJsxFlowElement']
25
- */
26
- types?: string[] | ((node: Nodes) => boolean);
27
- /**
28
- * A list of indexable MDX attributes, either:
29
- *
30
- * - an array of attribute names.
31
- * - a function that determines if attribute should be indexed.
32
- */
33
- allowedMdxAttributes?: string[] | ((node: MdxJsxFlowElement, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute) => boolean);
34
- /**
35
- * export as `structuredData` or specified variable name.
36
- */
37
- exportAs?: string | boolean;
38
- }
39
- declare module 'mdast' {
40
- interface Data {
41
- /**
42
- * [Fumadocs] Get content of unserializable element, `remarkStructure` uses it to generate search index.
43
- */
44
- _string?: string[];
45
- }
46
- }
47
- declare module 'vfile' {
48
- interface DataMap {
49
- /**
50
- * [Fumadocs] injected by `remarkStructure`
51
- */
52
- structuredData: StructuredData;
53
- }
54
- }
55
- declare const remarkStructureDefaultOptions: {
56
- types: string[];
57
- allowedMdxAttributes: (node: MdxJsxFlowElement) => boolean;
58
- exportAs: false;
59
- };
60
- /**
61
- * Extract content into structured data.
62
- *
63
- * By default, the output is stored into VFile (`vfile.data.structuredData`), you can specify `exportAs` to export it.
64
- */
65
- declare function remarkStructure({ types, allowedMdxAttributes, exportAs, }?: StructureOptions): Transformer<Root, Root>;
66
- /**
67
- * Extract data from markdown/mdx content
68
- */
69
- declare function structure(content: string, remarkPlugins?: PluggableList, options?: StructureOptions): StructuredData;
70
-
71
- export { type StructureOptions, type StructuredData, remarkStructure, remarkStructureDefaultOptions, structure };
1
+ import { a as structure, i as remarkStructureDefaultOptions, n as StructuredData, r as remarkStructure, t as StructureOptions } from "../remark-structure-RZD2gGKp.js";
2
+ export { StructureOptions, StructuredData, remarkStructure, remarkStructureDefaultOptions, structure };
@@ -1,12 +1,106 @@
1
- import {
2
- remarkStructure,
3
- remarkStructureDefaultOptions,
4
- structure
5
- } from "../chunk-JUF4WZ6G.js";
6
- import "../chunk-VLSDGCJE.js";
7
- import "../chunk-U67V476Y.js";
8
- export {
9
- remarkStructure,
10
- remarkStructureDefaultOptions,
11
- structure
1
+ import { n as toMdxExport, t as flattenNode } from "../mdast-utils-mc9-X-PK.js";
2
+ import { remark } from "remark";
3
+ import remarkGfm from "remark-gfm";
4
+ import Slugger from "github-slugger";
5
+ import { visit } from "unist-util-visit";
6
+
7
+ //#region src/mdx-plugins/remark-structure.ts
8
+ const remarkStructureDefaultOptions = {
9
+ types: [
10
+ "heading",
11
+ "paragraph",
12
+ "blockquote",
13
+ "tableCell",
14
+ "mdxJsxFlowElement"
15
+ ],
16
+ allowedMdxAttributes: (node) => {
17
+ if (!node.name) return false;
18
+ return ["TypeTable", "Callout"].includes(node.name);
19
+ },
20
+ exportAs: false
12
21
  };
22
+ /**
23
+ * Extract content into structured data.
24
+ *
25
+ * By default, the output is stored into VFile (`vfile.data.structuredData`), you can specify `exportAs` to export it.
26
+ */
27
+ function remarkStructure({ types = remarkStructureDefaultOptions.types, allowedMdxAttributes = remarkStructureDefaultOptions.allowedMdxAttributes, exportAs = remarkStructureDefaultOptions.exportAs } = {}) {
28
+ const slugger = new Slugger();
29
+ if (Array.isArray(allowedMdxAttributes)) {
30
+ const arr = allowedMdxAttributes;
31
+ allowedMdxAttributes = (_node, attribute) => attribute.type === "mdxJsxAttribute" && arr.includes(attribute.name);
32
+ }
33
+ if (Array.isArray(types)) {
34
+ const arr = types;
35
+ types = (node) => arr.includes(node.type);
36
+ }
37
+ return (tree, file) => {
38
+ slugger.reset();
39
+ const data = {
40
+ contents: [],
41
+ headings: []
42
+ };
43
+ let lastHeading;
44
+ if (file.data.frontmatter) {
45
+ const frontmatter = file.data.frontmatter;
46
+ if (frontmatter._openapi?.structuredData) {
47
+ data.headings.push(...frontmatter._openapi.structuredData.headings);
48
+ data.contents.push(...frontmatter._openapi.structuredData.contents);
49
+ }
50
+ }
51
+ visit(tree, (element) => {
52
+ if (element.type === "root" || !types(element)) return;
53
+ if (element.type === "heading") {
54
+ element.data ||= {};
55
+ element.data.hProperties ||= {};
56
+ const properties = element.data.hProperties;
57
+ const content$1 = flattenNode(element).trim();
58
+ const id = properties.id ?? slugger.slug(content$1);
59
+ data.headings.push({
60
+ id,
61
+ content: content$1
62
+ });
63
+ lastHeading = id;
64
+ return "skip";
65
+ }
66
+ if (element.data?._string) {
67
+ for (const content$1 of element.data._string) data.contents.push({
68
+ heading: lastHeading,
69
+ content: content$1
70
+ });
71
+ return "skip";
72
+ }
73
+ if (element.type === "mdxJsxFlowElement" && element.name) {
74
+ data.contents.push(...element.attributes.flatMap((attribute) => {
75
+ const value = typeof attribute.value === "string" ? attribute.value : attribute.value?.value;
76
+ if (!value || value.length === 0) return [];
77
+ if (allowedMdxAttributes && !allowedMdxAttributes(element, attribute)) return [];
78
+ return {
79
+ heading: lastHeading,
80
+ content: attribute.type === "mdxJsxAttribute" ? `${attribute.name}: ${value}` : value
81
+ };
82
+ }));
83
+ return;
84
+ }
85
+ const content = flattenNode(element).trim();
86
+ if (content.length === 0) return;
87
+ data.contents.push({
88
+ heading: lastHeading,
89
+ content
90
+ });
91
+ return "skip";
92
+ });
93
+ file.data.structuredData = data;
94
+ if (exportAs) tree.children.unshift(toMdxExport(typeof exportAs === "string" ? exportAs : "structuredData", data));
95
+ };
96
+ }
97
+ /**
98
+ * Extract data from markdown/mdx content
99
+ */
100
+ function structure(content, remarkPlugins = [], options = {}) {
101
+ return remark().use(remarkGfm).use(remarkPlugins).use(remarkStructure, options).processSync(content).data.structuredData;
102
+ }
103
+
104
+ //#endregion
105
+ export { remarkStructure, remarkStructureDefaultOptions, structure };
106
+ //# sourceMappingURL=remark-structure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-structure.js","names":["data: StructuredData","lastHeading: string | undefined","content"],"sources":["../../src/mdx-plugins/remark-structure.ts"],"sourcesContent":["import Slugger from 'github-slugger';\nimport type { Nodes, Root } from 'mdast';\nimport { remark } from 'remark';\nimport remarkGfm from 'remark-gfm';\nimport type { PluggableList, Transformer } from 'unified';\nimport { visit } from 'unist-util-visit';\nimport { flattenNode, toMdxExport } from './mdast-utils';\nimport type {\n MdxJsxAttribute,\n MdxJsxExpressionAttribute,\n MdxJsxFlowElement,\n} from 'mdast-util-mdx-jsx';\n\ninterface Heading {\n id: string;\n content: string;\n}\n\ninterface Content {\n heading: string | undefined;\n content: string;\n}\n\nexport interface StructuredData {\n headings: Heading[];\n /**\n * Refer to paragraphs, a heading may contain multiple contents as well\n */\n contents: Content[];\n}\n\nexport interface StructureOptions {\n /**\n * Types to be scanned as content.\n *\n * @defaultValue ['heading', 'paragraph', 'blockquote', 'tableCell', 'mdxJsxFlowElement']\n */\n types?: string[] | ((node: Nodes) => boolean);\n\n /**\n * A list of indexable MDX attributes, either:\n *\n * - an array of attribute names.\n * - a function that determines if attribute should be indexed.\n */\n allowedMdxAttributes?:\n | string[]\n | ((\n node: MdxJsxFlowElement,\n attribute: MdxJsxAttribute | MdxJsxExpressionAttribute,\n ) => boolean);\n\n /**\n * export as `structuredData` or specified variable name.\n */\n exportAs?: string | boolean;\n}\n\ndeclare module 'mdast' {\n interface Data {\n /**\n * [Fumadocs] Get content of unserializable element, `remarkStructure` uses it to generate search index.\n */\n _string?: string[];\n }\n}\n\ndeclare module 'vfile' {\n interface DataMap {\n /**\n * [Fumadocs] injected by `remarkStructure`\n */\n structuredData: StructuredData;\n }\n}\n\nexport const remarkStructureDefaultOptions = {\n types: ['heading', 'paragraph', 'blockquote', 'tableCell', 'mdxJsxFlowElement'],\n allowedMdxAttributes: (node) => {\n if (!node.name) return false;\n\n return ['TypeTable', 'Callout'].includes(node.name);\n },\n exportAs: false,\n} satisfies Required<StructureOptions>;\n\n/**\n * Extract content into structured data.\n *\n * By default, the output is stored into VFile (`vfile.data.structuredData`), you can specify `exportAs` to export it.\n */\nexport function remarkStructure({\n types = remarkStructureDefaultOptions.types,\n allowedMdxAttributes = remarkStructureDefaultOptions.allowedMdxAttributes,\n exportAs = remarkStructureDefaultOptions.exportAs,\n}: StructureOptions = {}): Transformer<Root, Root> {\n const slugger = new Slugger();\n\n if (Array.isArray(allowedMdxAttributes)) {\n const arr = allowedMdxAttributes;\n allowedMdxAttributes = (_node, attribute) =>\n attribute.type === 'mdxJsxAttribute' && arr.includes(attribute.name);\n }\n\n if (Array.isArray(types)) {\n const arr = types;\n types = (node) => arr.includes(node.type);\n }\n\n return (tree, file) => {\n slugger.reset();\n const data: StructuredData = { contents: [], headings: [] };\n let lastHeading: string | undefined;\n\n // Fumadocs OpenAPI Generated Structured Data\n if (file.data.frontmatter) {\n const frontmatter = file.data.frontmatter as {\n _openapi?: {\n structuredData?: StructuredData;\n };\n };\n\n if (frontmatter._openapi?.structuredData) {\n data.headings.push(...frontmatter._openapi.structuredData.headings);\n data.contents.push(...frontmatter._openapi.structuredData.contents);\n }\n }\n\n visit(tree, (element) => {\n if (element.type === 'root' || !types(element)) return;\n\n if (element.type === 'heading') {\n element.data ||= {};\n element.data.hProperties ||= {};\n const properties = element.data.hProperties;\n const content = flattenNode(element).trim();\n const id = properties.id ?? slugger.slug(content);\n\n data.headings.push({\n id,\n content,\n });\n\n lastHeading = id;\n return 'skip';\n }\n\n if (element.data?._string) {\n for (const content of element.data._string) {\n data.contents.push({\n heading: lastHeading,\n content,\n });\n }\n\n return 'skip';\n }\n\n if (element.type === 'mdxJsxFlowElement' && element.name) {\n data.contents.push(\n ...element.attributes.flatMap((attribute) => {\n const value =\n typeof attribute.value === 'string' ? attribute.value : attribute.value?.value;\n if (!value || value.length === 0) return [];\n if (allowedMdxAttributes && !allowedMdxAttributes(element, attribute)) return [];\n\n return {\n heading: lastHeading,\n content: attribute.type === 'mdxJsxAttribute' ? `${attribute.name}: ${value}` : value,\n };\n }),\n );\n\n return;\n }\n\n const content = flattenNode(element).trim();\n if (content.length === 0) return;\n\n data.contents.push({\n heading: lastHeading,\n content,\n });\n\n return 'skip';\n });\n\n file.data.structuredData = data;\n if (exportAs) {\n tree.children.unshift(\n toMdxExport(typeof exportAs === 'string' ? exportAs : 'structuredData', data),\n );\n }\n };\n}\n\n/**\n * Extract data from markdown/mdx content\n */\nexport function structure(\n content: string,\n remarkPlugins: PluggableList = [],\n options: StructureOptions = {},\n): StructuredData {\n const result = remark()\n .use(remarkGfm)\n .use(remarkPlugins)\n .use(remarkStructure, options)\n .processSync(content);\n\n return result.data.structuredData!;\n}\n"],"mappings":";;;;;;;AA4EA,MAAa,gCAAgC;CAC3C,OAAO;EAAC;EAAW;EAAa;EAAc;EAAa;EAAoB;CAC/E,uBAAuB,SAAS;AAC9B,MAAI,CAAC,KAAK,KAAM,QAAO;AAEvB,SAAO,CAAC,aAAa,UAAU,CAAC,SAAS,KAAK,KAAK;;CAErD,UAAU;CACX;;;;;;AAOD,SAAgB,gBAAgB,EAC9B,QAAQ,8BAA8B,OACtC,uBAAuB,8BAA8B,sBACrD,WAAW,8BAA8B,aACrB,EAAE,EAA2B;CACjD,MAAM,UAAU,IAAI,SAAS;AAE7B,KAAI,MAAM,QAAQ,qBAAqB,EAAE;EACvC,MAAM,MAAM;AACZ,0BAAwB,OAAO,cAC7B,UAAU,SAAS,qBAAqB,IAAI,SAAS,UAAU,KAAK;;AAGxE,KAAI,MAAM,QAAQ,MAAM,EAAE;EACxB,MAAM,MAAM;AACZ,WAAS,SAAS,IAAI,SAAS,KAAK,KAAK;;AAG3C,SAAQ,MAAM,SAAS;AACrB,UAAQ,OAAO;EACf,MAAMA,OAAuB;GAAE,UAAU,EAAE;GAAE,UAAU,EAAE;GAAE;EAC3D,IAAIC;AAGJ,MAAI,KAAK,KAAK,aAAa;GACzB,MAAM,cAAc,KAAK,KAAK;AAM9B,OAAI,YAAY,UAAU,gBAAgB;AACxC,SAAK,SAAS,KAAK,GAAG,YAAY,SAAS,eAAe,SAAS;AACnE,SAAK,SAAS,KAAK,GAAG,YAAY,SAAS,eAAe,SAAS;;;AAIvE,QAAM,OAAO,YAAY;AACvB,OAAI,QAAQ,SAAS,UAAU,CAAC,MAAM,QAAQ,CAAE;AAEhD,OAAI,QAAQ,SAAS,WAAW;AAC9B,YAAQ,SAAS,EAAE;AACnB,YAAQ,KAAK,gBAAgB,EAAE;IAC/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-ezknvj.js";
2
+ import Slugger from "github-slugger";
3
+
4
+ //#region ../../node_modules/.pnpm/remove-markdown@0.6.2/node_modules/remove-markdown/index.js
5
+ var require_remove_markdown = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
+ module.exports = function(md, options) {
7
+ options = options || {};
8
+ options.listUnicodeChar = options.hasOwnProperty("listUnicodeChar") ? options.listUnicodeChar : false;
9
+ options.stripListLeaders = options.hasOwnProperty("stripListLeaders") ? options.stripListLeaders : true;
10
+ options.gfm = options.hasOwnProperty("gfm") ? options.gfm : true;
11
+ options.useImgAltText = options.hasOwnProperty("useImgAltText") ? options.useImgAltText : true;
12
+ options.abbr = options.hasOwnProperty("abbr") ? options.abbr : false;
13
+ options.replaceLinksWithURL = options.hasOwnProperty("replaceLinksWithURL") ? options.replaceLinksWithURL : false;
14
+ options.htmlTagsToSkip = options.hasOwnProperty("htmlTagsToSkip") ? options.htmlTagsToSkip : [];
15
+ options.throwError = options.hasOwnProperty("throwError") ? options.throwError : false;
16
+ var output = md || "";
17
+ output = output.replace(/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/gm, "");
18
+ try {
19
+ if (options.stripListLeaders) if (options.listUnicodeChar) output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, options.listUnicodeChar + " $1");
20
+ else output = output.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm, "$1");
21
+ if (options.gfm) output = output.replace(/\n={2,}/g, "\n").replace(/~{3}.*\n/g, "").replace(/~~/g, "").replace(/```(?:.*)\n([\s\S]*?)```/g, (_, code) => code.trim());
22
+ if (options.abbr) output = output.replace(/\*\[.*\]:.*\n/, "");
23
+ let htmlReplaceRegex = /<[^>]*>/g;
24
+ if (options.htmlTagsToSkip && options.htmlTagsToSkip.length > 0) {
25
+ const joinedHtmlTagsToSkip = options.htmlTagsToSkip.join("|");
26
+ htmlReplaceRegex = new RegExp(`<(?!\/?(${joinedHtmlTagsToSkip})(?=>|\s[^>]*>))[^>]*>`, "g");
27
+ }
28
+ output = output.replace(htmlReplaceRegex, "").replace(/^[=\-]{2,}\s*$/g, "").replace(/\[\^.+?\](\: .*?$)?/g, "").replace(/\s{0,2}\[.*?\]: .*?$/g, "").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, options.useImgAltText ? "$1" : "").replace(/\[([\s\S]*?)\]\s*[\(\[].*?[\)\]]/g, options.replaceLinksWithURL ? "$2" : "$1").replace(/^(\n)?\s{0,3}>\s?/gm, "$1").replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g, "").replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm, "$1$3$4$6").replace(/([\*]+)(\S)(.*?\S)??\1/g, "$2$3").replace(/(^|\W)([_]+)(\S)(.*?\S)??\2($|\W)/g, "$1$3$4$5").replace(/(`{3,})(.*?)\1/gm, "$2").replace(/`(.+?)`/g, "$1").replace(/~(.*?)~/g, "$1");
29
+ } catch (e) {
30
+ if (options.throwError) throw e;
31
+ console.error("remove-markdown encountered error: %s", e);
32
+ return md;
33
+ }
34
+ return output;
35
+ };
36
+ }));
37
+
38
+ //#endregion
39
+ //#region src/search/client/mixedbread.ts
40
+ var import_remove_markdown = /* @__PURE__ */ __toESM(require_remove_markdown());
41
+ const slugger = new Slugger();
42
+ function extractHeadingTitle(text) {
43
+ const trimmedText = text.trim();
44
+ if (!trimmedText.startsWith("#")) return "";
45
+ const firstLine = trimmedText.split("\n")[0]?.trim();
46
+ if (firstLine) return (0, import_remove_markdown.default)(firstLine, { useImgAltText: false });
47
+ return "";
48
+ }
49
+ async function search(query, options) {
50
+ const { client, storeIdentifier, tag } = options;
51
+ if (!query.trim()) return [];
52
+ return (await client.stores.search({
53
+ query,
54
+ store_identifiers: [storeIdentifier],
55
+ top_k: 10,
56
+ filters: {
57
+ key: "generated_metadata.tag",
58
+ operator: "eq",
59
+ value: tag
60
+ },
61
+ search_options: { return_metadata: true }
62
+ })).data.flatMap((item) => {
63
+ const metadata = item.generated_metadata;
64
+ const url = metadata.url || "#";
65
+ const title = metadata.title || "Untitled";
66
+ const chunkResults = [{
67
+ id: `${item.file_id}-${item.chunk_index}-page`,
68
+ type: "page",
69
+ content: title,
70
+ url
71
+ }];
72
+ const headingTitle = item.type === "text" ? extractHeadingTitle(item.text) : "";
73
+ if (headingTitle) {
74
+ slugger.reset();
75
+ chunkResults.push({
76
+ id: `${item.file_id}-${item.chunk_index}-heading`,
77
+ type: "heading",
78
+ content: headingTitle,
79
+ url: `${url}#${slugger.slug(headingTitle)}`
80
+ });
81
+ }
82
+ return chunkResults;
83
+ });
84
+ }
85
+
86
+ //#endregion
87
+ export { search };
88
+ //# sourceMappingURL=mixedbread-DlByNYSd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mixedbread-DlByNYSd.js","names":["chunkResults: SortedResult[]"],"sources":["../../../node_modules/.pnpm/remove-markdown@0.6.2/node_modules/remove-markdown/index.js","../src/search/client/mixedbread.ts"],"sourcesContent":["module.exports = function(md, options) {\n options = options || {};\n options.listUnicodeChar = options.hasOwnProperty('listUnicodeChar') ? options.listUnicodeChar : false;\n options.stripListLeaders = options.hasOwnProperty('stripListLeaders') ? options.stripListLeaders : true;\n options.gfm = options.hasOwnProperty('gfm') ? options.gfm : true;\n options.useImgAltText = options.hasOwnProperty('useImgAltText') ? options.useImgAltText : true;\n options.abbr = options.hasOwnProperty('abbr') ? options.abbr : false;\n options.replaceLinksWithURL = options.hasOwnProperty('replaceLinksWithURL') ? options.replaceLinksWithURL : false;\n options.htmlTagsToSkip = options.hasOwnProperty('htmlTagsToSkip') ? options.htmlTagsToSkip : [];\n options.throwError = options.hasOwnProperty('throwError') ? options.throwError : false;\n\n var output = md || '';\n\n // Remove horizontal rules (stripListHeaders conflict with this rule, which is why it has been moved to the top)\n output = output.replace(/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/gm, '');\n\n try {\n if (options.stripListLeaders) {\n if (options.listUnicodeChar)\n output = output.replace(/^([\\s\\t]*)([\\*\\-\\+]|\\d+\\.)\\s+/gm, options.listUnicodeChar + ' $1');\n else\n output = output.replace(/^([\\s\\t]*)([\\*\\-\\+]|\\d+\\.)\\s+/gm, '$1');\n }\n if (options.gfm) {\n output = output\n // Header\n .replace(/\\n={2,}/g, '\\n')\n // Fenced codeblocks\n .replace(/~{3}.*\\n/g, '')\n // Strikethrough\n .replace(/~~/g, '')\n // Fenced codeblocks with backticks\n .replace(/```(?:.*)\\n([\\s\\S]*?)```/g, (_, code) => code.trim());\n }\n if (options.abbr) {\n // Remove abbreviations\n output = output.replace(/\\*\\[.*\\]:.*\\n/, '');\n }\n \n let htmlReplaceRegex = /<[^>]*>/g\n if (options.htmlTagsToSkip && options.htmlTagsToSkip.length > 0) {\n // Create a regex that matches tags not in htmlTagsToSkip\n const joinedHtmlTagsToSkip = options.htmlTagsToSkip.join('|')\n htmlReplaceRegex = new RegExp(\n `<(?!\\/?(${joinedHtmlTagsToSkip})(?=>|\\s[^>]*>))[^>]*>`,\n 'g',\n )\n }\n\n output = output\n // Remove HTML tags\n .replace(htmlReplaceRegex, '')\n // Remove setext-style headers\n .replace(/^[=\\-]{2,}\\s*$/g, '')\n // Remove footnotes?\n .replace(/\\[\\^.+?\\](\\: .*?$)?/g, '')\n .replace(/\\s{0,2}\\[.*?\\]: .*?$/g, '')\n // Remove images\n .replace(/\\!\\[(.*?)\\][\\[\\(].*?[\\]\\)]/g, options.useImgAltText ? '$1' : '')\n // Remove inline links\n .replace(/\\[([\\s\\S]*?)\\]\\s*[\\(\\[].*?[\\)\\]]/g, options.replaceLinksWithURL ? '$2' : '$1')\n // Remove blockquotes\n .replace(/^(\\n)?\\s{0,3}>\\s?/gm, '$1')\n // .replace(/(^|\\n)\\s{0,3}>\\s?/g, '\\n\\n')\n // Remove reference-style links?\n .replace(/^\\s{1,2}\\[(.*?)\\]: (\\S+)( \".*?\")?\\s*$/g, '')\n // Remove atx-style headers\n .replace(/^(\\n)?\\s{0,}#{1,6}\\s*( (.+))? +#+$|^(\\n)?\\s{0,}#{1,6}\\s*( (.+))?$/gm, '$1$3$4$6')\n // Remove * emphasis\n .replace(/([\\*]+)(\\S)(.*?\\S)??\\1/g, '$2$3')\n // Remove _ emphasis. Unlike *, _ emphasis gets rendered only if \n // 1. Either there is a whitespace character before opening _ and after closing _.\n // 2. Or _ is at the start/end of the string.\n .replace(/(^|\\W)([_]+)(\\S)(.*?\\S)??\\2($|\\W)/g, '$1$3$4$5')\n // Remove single-line code blocks (already handled multiline above in gfm section)\n .replace(/(`{3,})(.*?)\\1/gm, '$2')\n // Remove inline code\n .replace(/`(.+?)`/g, '$1')\n // // Replace two or more newlines with exactly two? Not entirely sure this belongs here...\n // .replace(/\\n{2,}/g, '\\n\\n')\n // // Remove newlines in a paragraph\n // .replace(/(\\S+)\\n\\s*(\\S+)/g, '$1 $2')\n // Replace strike through\n .replace(/~(.*?)~/g, '$1');\n } catch(e) {\n if (options.throwError) throw e;\n\n console.error(\"remove-markdown encountered error: %s\", e);\n return md;\n }\n return output;\n};\n","import type { SortedResult } from '@/search';\nimport type Mixedbread from '@mixedbread/sdk';\nimport removeMd from 'remove-markdown';\nimport Slugger from 'github-slugger';\nimport type { StoreSearchResponse } from '@mixedbread/sdk/resources/stores';\n\nexport interface MixedbreadOptions {\n /**\n * The identifier of the store to search in\n */\n storeIdentifier: string;\n\n /**\n * The Mixedbread SDK client instance\n */\n client: Mixedbread;\n\n /**\n * Filter results with specific tag.\n */\n tag?: string;\n\n /**\n * Filter by locale (unsupported at the moment)\n */\n locale?: string;\n}\n\nexport interface SearchMetadata {\n title?: string;\n description?: string;\n url?: string;\n tag?: string;\n}\n\ntype StoreSearchResult = StoreSearchResponse['data'][number] & {\n generated_metadata: SearchMetadata;\n};\n\nconst slugger = new Slugger();\n\nfunction extractHeadingTitle(text: string): string {\n const trimmedText = text.trim();\n\n if (!trimmedText.startsWith('#')) {\n return '';\n }\n\n const lines = trimmedText.split('\\n');\n const firstLine = lines[0]?.trim();\n\n if (firstLine) {\n // Use remove-markdown to convert to plain text and remove colons\n return removeMd(firstLine, {\n useImgAltText: false,\n });\n }\n\n return '';\n}\n\nexport async function search(query: string, options: MixedbreadOptions): Promise<SortedResult[]> {\n const { client, storeIdentifier, tag } = options;\n\n if (!query.trim()) {\n return [];\n }\n\n const res = await client.stores.search({\n query,\n store_identifiers: [storeIdentifier],\n top_k: 10,\n filters: {\n key: 'generated_metadata.tag',\n operator: 'eq',\n value: tag,\n },\n search_options: {\n return_metadata: true,\n },\n });\n\n return (res.data as StoreSearchResult[]).flatMap((item) => {\n const metadata = item.generated_metadata;\n\n const url = metadata.url || '#';\n const title = metadata.title || 'Untitled';\n\n const chunkResults: SortedResult[] = [\n {\n id: `${item.file_id}-${item.chunk_index}-page`,\n type: 'page',\n content: title,\n url,\n },\n ];\n\n const headingTitle = item.type === 'text' ? extractHeadingTitle(item.text) : '';\n\n if (headingTitle) {\n slugger.reset();\n\n chunkResults.push({\n id: `${item.file_id}-${item.chunk_index}-heading`,\n type: 'heading',\n content: headingTitle,\n url: `${url}#${slugger.slug(headingTitle)}`,\n });\n }\n\n return chunkResults;\n });\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAAA,QAAO,UAAU,SAAS,IAAI,SAAS;AACrC,YAAU,WAAW,EAAE;AACvB,UAAQ,kBAAkB,QAAQ,eAAe,kBAAkB,GAAG,QAAQ,kBAAkB;AAChG,UAAQ,mBAAmB,QAAQ,eAAe,mBAAmB,GAAG,QAAQ,mBAAmB;AACnG,UAAQ,MAAM,QAAQ,eAAe,MAAM,GAAG,QAAQ,MAAM;AAC5D,UAAQ,gBAAgB,QAAQ,eAAe,gBAAgB,GAAG,QAAQ,gBAAgB;AAC1F,UAAQ,OAAO,QAAQ,eAAe,OAAO,GAAG,QAAQ,OAAO;AAC/D,U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+ import Negotiator from "negotiator";
2
2
 
3
+ //#region src/negotiation/index.d.ts
3
4
  declare function getNegotiator(request: Request): Negotiator;
4
5
  /**
5
6
  * Rewrite incoming path matching the `source` pattern into the `destination` pattern.
@@ -10,10 +11,11 @@ declare function getNegotiator(request: Request): Negotiator;
10
11
  * @param destination - the target pattern to convert into
11
12
  */
12
13
  declare function rewritePath(source: string, destination: string): {
13
- rewrite(pathname: string): string | false;
14
+ rewrite(pathname: string): string | false;
14
15
  };
15
16
  declare function isMarkdownPreferred(request: Request, options?: {
16
- markdownMediaTypes?: string[];
17
+ markdownMediaTypes?: string[];
17
18
  }): boolean;
18
-
19
+ //#endregion
19
20
  export { getNegotiator, isMarkdownPreferred, rewritePath };
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/negotiation/index.ts"],"sourcesContent":[],"mappings":";;;iBAGgB,aAAA,UAAuB,UAAO;;AAA9C;AAiBA;AAcA;;;;;iBAdgB,WAAA;;;iBAcA,mBAAA,UACL"}
@@ -1,11 +1,41 @@
1
- import {
2
- getNegotiator,
3
- isMarkdownPreferred,
4
- rewritePath
5
- } from "../chunk-YVVDKJ2H.js";
6
- import "../chunk-U67V476Y.js";
7
- export {
8
- getNegotiator,
9
- isMarkdownPreferred,
10
- rewritePath
11
- };
1
+ import Negotiator from "negotiator";
2
+ import { compile, match } from "path-to-regexp";
3
+
4
+ //#region src/negotiation/index.ts
5
+ function getNegotiator(request) {
6
+ const headers = {};
7
+ request.headers.forEach((value, key) => {
8
+ headers[key] = value;
9
+ });
10
+ return new Negotiator({ headers });
11
+ }
12
+ /**
13
+ * Rewrite incoming path matching the `source` pattern into the `destination` pattern.
14
+ *
15
+ * See [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) for accepted pattern formats.
16
+ *
17
+ * @param source - the original pattern of incoming paths
18
+ * @param destination - the target pattern to convert into
19
+ */
20
+ function rewritePath(source, destination) {
21
+ const matcher = match(source, { decode: false });
22
+ const compiler = compile(destination, { encode: false });
23
+ return { rewrite(pathname) {
24
+ const result = matcher(pathname);
25
+ if (!result) return false;
26
+ return compiler(result.params);
27
+ } };
28
+ }
29
+ function isMarkdownPreferred(request, options) {
30
+ const { markdownMediaTypes = [
31
+ "text/plain",
32
+ "text/markdown",
33
+ "text/x-markdown"
34
+ ] } = options ?? {};
35
+ const mediaTypes = getNegotiator(request).mediaTypes();
36
+ return markdownMediaTypes.some((type) => mediaTypes.includes(type));
37
+ }
38
+
39
+ //#endregion
40
+ export { getNegotiator, isMarkdownPreferred, rewritePath };
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["headers: Record<string, string>"],"sources":["../../src/negotiation/index.ts"],"sourcesContent":["import Negotiator from 'negotiator';\nimport { compile, match } from 'path-to-regexp';\n\nexport function getNegotiator(request: Request) {\n const headers: Record<string, string> = {};\n request.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n return new Negotiator({ headers });\n}\n\n/**\n * Rewrite incoming path matching the `source` pattern into the `destination` pattern.\n *\n * See [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) for accepted pattern formats.\n *\n * @param source - the original pattern of incoming paths\n * @param destination - the target pattern to convert into\n */\nexport function rewritePath(source: string, destination: string) {\n const matcher = match(source, { decode: false });\n const compiler = compile(destination, { encode: false });\n\n return {\n rewrite(pathname: string) {\n const result = matcher(pathname);\n if (!result) return false;\n\n return compiler(result.params);\n },\n };\n}\n\nexport function isMarkdownPreferred(\n request: Request,\n options?: {\n markdownMediaTypes?: string[];\n },\n) {\n const { markdownMediaTypes = ['text/plain', 'text/markdown', 'text/x-markdown'] } = options ?? {};\n\n const mediaTypes = getNegotiator(request).mediaTypes();\n return markdownMediaTypes.some((type) => mediaTypes.includes(type));\n}\n"],"mappings":";;;;AAGA,SAAgB,cAAc,SAAkB;CAC9C,MAAMA,UAAkC,EAAE;AAC1C,SAAQ,QAAQ,SAAS,OAAO,QAAQ;AACtC,UAAQ,OAAO;GACf;AAEF,QAAO,IAAI,WAAW,EAAE,SAAS,CAAC;;;;;;;;;;AAWpC,SAAgB,YAAY,QAAgB,aAAqB;CAC/D,MAAM,UAAU,MAAM,QAAQ,EAAE,QAAQ,OAAO,CAAC;CAChD,MAAM,WAAW,QAAQ,aAAa,EAAE,QAAQ,OAAO,CAAC;AAExD,QAAO,EACL,QAAQ,UAAkB;EACxB,MAAM,SAAS,QAAQ,SAAS;AAChC,MAAI,CAAC,OAAQ,QAAO;AAEpB,SAAO,SAAS,OAAO,OAAO;IAEjC;;AAGH,SAAgB,oBACd,SACA,SAGA;CACA,MAAM,EAAE,qBAAqB;EAAC;EAAc;EAAiB;EAAkB,KAAK,WAAW,EAAE;CAEjG,MAAM,aAAa,cAAc,QAAQ,CAAC,YAAY;AACtD,QAAO,mBAAmB,MAAM,SAAS,WAAW,SAAS,KAAK,CAAC"}
@@ -0,0 +1,16 @@
1
+ //#region src/utils/normalize-url.tsx
2
+ /**
3
+ * normalize URL into the Fumadocs standard form (`/slug-1/slug-2`).
4
+ *
5
+ * This includes URLs with trailing slashes.
6
+ */
7
+ function normalizeUrl(url) {
8
+ if (url.startsWith("http://") || url.startsWith("https://")) return url;
9
+ if (!url.startsWith("/")) url = "/" + url;
10
+ if (url.length > 1 && url.endsWith("/")) url = url.slice(0, -1);
11
+ return url;
12
+ }
13
+
14
+ //#endregion
15
+ export { normalizeUrl as t };
16
+ //# sourceMappingURL=normalize-url-DP9-1I-S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-url-DP9-1I-S.js","names":[],"sources":["../src/utils/normalize-url.tsx"],"sourcesContent":["/**\n * normalize URL into the Fumadocs standard form (`/slug-1/slug-2`).\n *\n * This includes URLs with trailing slashes.\n */\nexport function normalizeUrl(url: string) {\n if (url.startsWith('http://') || url.startsWith('https://')) return url;\n\n if (!url.startsWith('/')) url = '/' + url;\n if (url.length > 1 && url.endsWith('/')) url = url.slice(0, -1);\n return url;\n}\n"],"mappings":";;;;;;AAKA,SAAgB,aAAa,KAAa;AACxC,KAAI,IAAI,WAAW,UAAU,IAAI,IAAI,WAAW,WAAW,CAAE,QAAO;AAEpE,KAAI,CAAC,IAAI,WAAW,IAAI,CAAE,OAAM,MAAM;AACtC,KAAI,IAAI,SAAS,KAAK,IAAI,SAAS,IAAI,CAAE,OAAM,IAAI,MAAM,GAAG,GAAG;AAC/D,QAAO"}
@@ -0,0 +1,84 @@
1
+ import { t as createContentHighlighter } from "./search-D6ChCLhY.js";
2
+ import { t as removeUndefined } from "./remove-undefined-Cfs4o_mM.js";
3
+
4
+ //#region src/search/client/orama-cloud.ts
5
+ async function searchDocs(query, options) {
6
+ const highlighter = createContentHighlighter(query);
7
+ const list = [];
8
+ const { index = "default", client, params: extraParams, tag } = options;
9
+ if (index === "crawler") {
10
+ const result$1 = await client.search({
11
+ datasources: [],
12
+ ...extraParams,
13
+ term: query,
14
+ where: {
15
+ category: tag ? { eq: tag.slice(0, 1).toUpperCase() + tag.slice(1) } : void 0,
16
+ ...extraParams?.where
17
+ },
18
+ limit: 10
19
+ });
20
+ if (!result$1) return list;
21
+ for (const hit of result$1.hits) {
22
+ const doc = hit.document;
23
+ list.push({
24
+ id: hit.id,
25
+ type: "page",
26
+ content: doc.title,
27
+ contentWithHighlights: highlighter.highlight(doc.title),
28
+ url: doc.path
29
+ }, {
30
+ id: "page" + hit.id,
31
+ type: "text",
32
+ content: doc.content,
33
+ contentWithHighlights: highlighter.highlight(doc.content),
34
+ url: doc.path
35
+ });
36
+ }
37
+ return list;
38
+ }
39
+ const params = {
40
+ datasources: [],
41
+ ...extraParams,
42
+ term: query,
43
+ where: removeUndefined({
44
+ tag,
45
+ ...extraParams?.where
46
+ }),
47
+ groupBy: {
48
+ properties: ["page_id"],
49
+ max_results: 7,
50
+ ...extraParams?.groupBy
51
+ }
52
+ };
53
+ const result = await client.search(params);
54
+ if (!result || !result.groups) return list;
55
+ for (const item of result.groups) {
56
+ let addedHead = false;
57
+ for (const hit of item.result) {
58
+ const doc = hit.document;
59
+ if (!addedHead) {
60
+ list.push({
61
+ id: doc.page_id,
62
+ type: "page",
63
+ content: doc.title,
64
+ breadcrumbs: doc.breadcrumbs,
65
+ contentWithHighlights: highlighter.highlight(doc.title),
66
+ url: doc.url
67
+ });
68
+ addedHead = true;
69
+ }
70
+ list.push({
71
+ id: doc.id,
72
+ content: doc.content,
73
+ contentWithHighlights: highlighter.highlight(doc.content),
74
+ type: doc.content === doc.section ? "heading" : "text",
75
+ url: doc.section_id ? `${doc.url}#${doc.section_id}` : doc.url
76
+ });
77
+ }
78
+ }
79
+ return list;
80
+ }
81
+
82
+ //#endregion
83
+ export { searchDocs };
84
+ //# sourceMappingURL=orama-cloud-DH3g37zc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orama-cloud-DH3g37zc.js","names":["list: SortedResult[]","result","params: OramaCloudSearchParams"],"sources":["../src/search/client/orama-cloud.ts"],"sourcesContent":["import type { OramaCloud, OramaCloudSearchParams } from '@orama/core';\nimport { removeUndefined } from '@/utils/remove-undefined';\nimport type { OramaIndex } from '@/search/orama-cloud';\nimport { createContentHighlighter, type SortedResult } from '@/search';\n\ninterface CrawlerIndex {\n path: string;\n title: string;\n content: string;\n section: string;\n category: string;\n}\n\nexport interface OramaCloudOptions {\n client: OramaCloud;\n /**\n * The type of your index.\n *\n * You can set it to `crawler` if you use crawler instead of the JSON index with schema provided by Fumadocs\n */\n index?: 'default' | 'crawler';\n params?: Partial<OramaCloudSearchParams>;\n\n /**\n * Filter results with specific tag.\n */\n tag?: string;\n\n /**\n * Filter by locale (unsupported at the moment)\n */\n locale?: string;\n}\n\nexport async function searchDocs(\n query: string,\n options: OramaCloudOptions,\n): Promise<SortedResult[]> {\n const highlighter = createContentHighlighter(query);\n const list: SortedResult[] = [];\n const { index = 'default', client, params: extraParams, tag } = options;\n\n if (index === 'crawler') {\n const result = await client.search({\n datasources: [],\n ...extraParams,\n term: query,\n where: {\n category: tag\n ? {\n eq: tag.slice(0, 1).toUpperCase() + tag.slice(1),\n }\n : undefined,\n ...extraParams?.where,\n },\n limit: 10,\n });\n if (!result) return list;\n\n for (const hit of result.hits) {\n const doc = hit.document as unknown as CrawlerIndex;\n\n list.push(\n {\n id: hit.id,\n type: 'page',\n content: doc.title,\n contentWithHighlights: highlighter.highlight(doc.title),\n url: doc.path,\n },\n {\n id: 'page' + hit.id,\n type: 'text',\n content: doc.content,\n contentWithHighlights: highlighter.highlight(doc.content),\n url: doc.path,\n },\n );\n }\n\n return list;\n }\n\n const params: OramaCloudSearchParams = {\n datasources: [],\n ...extraParams,\n term: query,\n where: removeUndefined({\n tag,\n ...extraParams?.where,\n }),\n groupBy: {\n properties: ['page_id'],\n max_results: 7,\n ...extraParams?.groupBy,\n },\n };\n\n const result = await client.search(params);\n if (!result || !result.groups) return list;\n\n for (const item of result.groups) {\n let addedHead = false;\n\n for (const hit of item.result) {\n const doc = hit.document as unknown as OramaIndex;\n\n if (!addedHead) {\n list.push({\n id: doc.page_id,\n type: 'page',\n content: doc.title,\n breadcrumbs: doc.breadcrumbs,\n contentWithHighlights: highlighter.highlight(doc.title),\n url: doc.url,\n });\n addedHead = true;\n }\n\n list.push({\n id: doc.id,\n content: doc.content,\n contentWithHighlights: highlighter.highlight(doc.content),\n type: doc.content === doc.section ? 'heading' : 'text',\n url: doc.section_id ? `${doc.url}#${doc.section_id}` : doc.url,\n });\n }\n }\n\n return list;\n}\n"],"mappings":";;;;AAkCA,eAAsB,WACpB,OACA,SACyB;CACzB,MAAM,cAAc,yBAAyB,MAAM;CACnD,MAAMA,OAAuB,EAAE;CAC/B,MAAM,EAAE,QAAQ,WAAW,QAAQ,QAAQ,aAAa,QAAQ;AAEhE,KAAI,UAAU,WAAW;EACvB,MAAMC,WAAS,MAAM,OAAO,OAAO;GACjC,aAAa,EAAE;GACf,GAAG;GACH,MAAM;GACN,OAAO;IACL,UAAU,MACN,EACE,IAAI,IAAI,MAAM,GAAG,EAAE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