export declare const treeDataTemplate = "import React from \"react\";\n\nexport interface TreeNode {\n id: string;\n name: string;\n isFolder: boolean;\n defaultOpen: boolean;\n openable: boolean;\n children: TreeNode[];\n}\n\nexport interface TreeFolderProps {\n name: string;\n defaultOpen?: boolean;\n openable?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface TreeFileProps {\n name: string;\n}\n\n// Tree.Folder and Tree.File are declarative markers: the Tree compound in\n// MDXComponents parses them into TreeNode data before anything renders, so\n// they never render on their own. This module must stay free of\n// \"use client\" - parsing runs where MDX creates the elements (server\n// components included), and only there is comparing an element's type\n// against these markers guaranteed to work. Client modules would turn the\n// markers into reference proxies whose identity does not survive the\n// server boundary.\nexport function TreeFolder(_props: TreeFolderProps) {\n return null;\n}\n\nexport function TreeFile(_props: TreeFileProps) {\n return null;\n}\n\nfunction extractText(children: React.ReactNode): string {\n if (children == null || typeof children === \"boolean\") return \"\";\n if (typeof children === \"string\" || typeof children === \"number\") {\n return String(children);\n }\n if (Array.isArray(children)) return children.map(extractText).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractText(element.props.children);\n }\n return \"\";\n}\n\ntype ListElement = React.ReactElement<{ children?: React.ReactNode }>;\n\nfunction isListElement(child: React.ReactNode): child is ListElement {\n return (\n React.isValidElement(child) && (child.type === \"ul\" || child.type === \"ol\")\n );\n}\n\n// Markdown list syntax: a trailing slash or nested items mark a folder, and\n// folders that contain items expand by default. Names strip inline\n// formatting because only the text content is extracted. Ids derive from\n// position and name so open state survives re-renders.\nfunction parseListItems(list: ListElement, parentId: string): TreeNode[] {\n const nodes: TreeNode[] = [];\n React.Children.forEach(list.props.children, (item) => {\n if (!React.isValidElement(item) || item.type !== \"li\") return;\n const li = item as React.ReactElement<{ children?: React.ReactNode }>;\n const labelParts: React.ReactNode[] = [];\n const nestedLists: ListElement[] = [];\n React.Children.forEach(li.props.children, (child) => {\n if (isListElement(child)) nestedLists.push(child);\n else labelParts.push(child);\n });\n const raw = extractText(labelParts).trim();\n const name = raw.endsWith(\"/\") ? raw.slice(0, -1) : raw;\n if (!name) return;\n const id = parentId + \"/\" + nodes.length + \"-\" + name;\n nodes.push({\n id,\n name,\n isFolder: raw.endsWith(\"/\") || nestedLists.length > 0,\n defaultOpen: nestedLists.length > 0,\n openable: true,\n children: nestedLists.flatMap((nested) => parseListItems(nested, id)),\n });\n });\n return nodes;\n}\n\n// Both authoring syntaxes (Tree.Folder/Tree.File elements and markdown\n// lists) normalize into the same node model, so they can be mixed freely.\nexport function parseTreeChildren(\n children: React.ReactNode,\n parentId: string,\n): TreeNode[] {\n const nodes: TreeNode[] = [];\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) return;\n if (child.type === TreeFolder) {\n const props = child.props as TreeFolderProps;\n if (!props.name) return;\n const id = parentId + \"/\" + nodes.length + \"-\" + props.name;\n nodes.push({\n id,\n name: props.name,\n isFolder: true,\n defaultOpen: props.defaultOpen === true,\n openable: props.openable !== false,\n children: parseTreeChildren(props.children, id),\n });\n } else if (child.type === TreeFile) {\n const props = child.props as TreeFileProps;\n if (!props.name) return;\n nodes.push({\n id: parentId + \"/\" + nodes.length + \"-\" + props.name,\n name: props.name,\n isFolder: false,\n defaultOpen: false,\n openable: false,\n children: [],\n });\n } else if (isListElement(child)) {\n nodes.push(...parseListItems(child, parentId + \"/\" + nodes.length));\n }\n });\n return nodes;\n}\n";