export declare const docsTemplate = "import React from \"react\";\nimport { Flex } from \"cherry-styled-components\";\nimport {\n DocsContainer,\n StyledMarkdownContainer,\n} from \"@/components/layout/DocsComponents\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { compileMDX } from \"next-mdx-remote/rsc\";\nimport remarkGfm from \"remark-gfm\";\nimport { useMDXComponents } from \"@/components/MDXComponents\";\nimport { createMermaidPre } from \"@/components/MermaidPre\";\nimport { DocsSideBar } from \"@/components/DocsSideBar\";\nimport { ActionBar } from \"@/components/layout/ActionBar\";\nimport { ApiPlaygroundDemo } from \"@/components/layout/ApiPlaygroundDemo\";\nimport { createSlugger } from \"@/components/layout/Slug\";\nimport { rehypeCodeMeta } from \"@/utils/rehypeCodeMeta\";\n\ninterface DocsProps {\n content: string;\n sourcePath?: string;\n // Path of this page's RSS feed; when set, the action bar shows an RSS\n // button linking to it.\n rssHref?: string;\n // Extra content rendered inside the markdown column, after the MDX body.\n // Used to place generated widgets (e.g. the API playground) inside the docs\n // content area rather than outside its layout.\n children?: React.ReactNode;\n}\n\ninterface Heading {\n id: string;\n text: string;\n level: number;\n}\n\nfunction extractHeadings(content: string): Heading[] {\n const contentWithoutCodeBlocks = content.replace(/```[\\s\\S]*?```/g, \"\");\n const entries: { text: string; level: number; position: number }[] = [];\n let match;\n\n // Markdown headings (# .. ######)\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n while ((match = headingRegex.exec(contentWithoutCodeBlocks)) !== null) {\n const level = match[1].length;\n const text = match[2].trim();\n entries.push({ text, level, position: match.index });\n }\n\n // blocks surface their label as a top-level entry\n const updateRegex = /]*?\\blabel=[\"']([^\"']+)[\"'][^>]*>/g;\n while ((match = updateRegex.exec(contentWithoutCodeBlocks)) !== null) {\n entries.push({ text: match[1].trim(), level: 1, position: match.index });\n }\n\n // Assign ids in document order with a shared slugger so repeated heading\n // text produces unique anchors (\"setup\", \"setup-1\", ...) that stay in sync\n // with the ids rendered by MDXComponents/Update.\n const slug = createSlugger();\n return entries\n .sort((a, b) => a.position - b.position)\n .map(({ text, level }) => ({ id: slug(text), text, level }));\n}\n\nfunction extractComponentNames(source: string): string[] {\n const stripped = source\n .replace(/```[\\s\\S]*?```/g, \"\")\n .replace(/`[^`]*`/g, \"\");\n const tagRegex = /<([A-Z][a-zA-Z0-9]*)/g;\n const names = new Set();\n let match;\n while ((match = tagRegex.exec(stripped)) !== null) {\n names.add(match[1]);\n }\n return Array.from(names);\n}\n\nfunction MissingComponent({\n componentName,\n children: _children,\n}: {\n componentName: string;\n children?: React.ReactNode;\n}) {\n return (\n \n

Missing component: <{componentName} />

\n
\n );\n}\n\ninterface MdxBodyProps {\n source: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components: Record>;\n sourcePath?: string;\n}\n\n// Compiles the MDX body inside a try/catch so an authoring mistake (an\n// orphaned closing tag, a stray {expression}) renders an inline error panel\n// instead of throwing during static prerender - a broken page must never\n// fail `next build` for the rest of the site.\nasync function MdxBody({ source, components, sourcePath }: MdxBodyProps) {\n try {\n const { content } = await compileMDX({\n source,\n options: {\n blockJS: false,\n mdxOptions: {\n remarkPlugins: [remarkGfm],\n rehypePlugins: [rehypeCodeMeta],\n },\n },\n components,\n });\n // JS expressions in the body only run when the compiled component\n // renders, which would escape this try/catch and still fail the build.\n // The compiled component is a plain sync function, so invoke it once\n // here to surface those errors (a {placeholder} typo, for example).\n if (typeof content.type === \"function\") {\n await (content.type as React.FC)(content.props);\n }\n return content;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const where = sourcePath ? ` in ${sourcePath}` : \"\";\n console.error(`[doccupine] MDX error${where}:`, message);\n return (\n \n

\n This page has an MDX error{where}. The rest of the\n site still builds and renders. Fix the syntax below and save the file\n to rebuild this page.\n

\n
{message}
\n
\n );\n }\n}\n\nfunction Docs({ content, sourcePath, rssHref, children }: DocsProps) {\n const components = useMDXComponents({\n pre: createMermaidPre(sourcePath),\n ApiPlaygroundDemo,\n });\n\n const knownNames = Object.keys(components);\n const usedNames = extractComponentNames(content);\n const missingNames = usedNames.filter((name) => !knownNames.includes(name));\n\n // A takes over the right rail, so the table of contents that\n // normally lives there is dropped for that page. extractComponentNames\n // ignores code blocks, so a panel shown only as a code sample never counts.\n const hasSidePanel = usedNames.includes(\"SidePanel\");\n const headings = hasSidePanel ? [] : extractHeadings(content);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stubs: Record> = {};\n for (const name of missingNames) {\n stubs[name] = ({ children }: { children?: React.ReactNode }) => (\n {children}\n );\n }\n\n const allComponents = { ...components, ...stubs };\n\n return (\n <>\n \n \n \n \n {children}\n {content && (\n \n )}\n \n \n \n \n {!hasSidePanel && }\n \n );\n}\n\nexport { Docs };\n";